change_apply.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <div class="app-container">
  3. <span>返利互转单</span>
  4. <el-divider></el-divider>
  5. <!-- 筛选条件 -->
  6. <div>
  7. <el-form
  8. ref="searchForm"
  9. :model="searchForm"
  10. label-width="100px"
  11. size="small"
  12. label-position="left"
  13. >
  14. <el-row :gutter="20">
  15. <el-col :xs="24" :sm="12" :lg="6">
  16. <el-form-item label="返利互转单号" prop="">
  17. <el-input placeholder="请输入" disabled></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :xs="24" :sm="12" :lg="6">
  21. <el-form-item label="单据日期" prop="">
  22. <el-input placeholder="请输入"></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :xs="24" :sm="12" :lg="6">
  26. <el-form-item label="制单人" prop="">
  27. <el-input placeholder="请输入" disabled></el-input>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :xs="24" :sm="12" :lg="6">
  31. <el-form-item label="经销商编号" prop="">
  32. <el-input
  33. placeholder="请输入"
  34. v-model="searchForm.customerId"
  35. ></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :xs="24" :sm="12" :lg="6">
  39. <el-form-item label="经销商名称" prop="">
  40. <el-input
  41. placeholder="请输入"
  42. v-model="searchForm.customerName"
  43. ></el-input>
  44. </el-form-item>
  45. </el-col>
  46. <el-col :xs="24" :sm="12" :lg="6">
  47. <el-form-item label="备注信息" prop="">
  48. <el-input placeholder="请输入"></el-input>
  49. </el-form-item>
  50. </el-col>
  51. </el-row>
  52. </el-form>
  53. </div>
  54. <!-- 列表 -->
  55. <div class="mymain-container">
  56. <div class="table">
  57. <el-table
  58. v-loading="listLoading"
  59. :data="dataList"
  60. element-loading-text="Loading"
  61. border
  62. fit
  63. highlight-current-row
  64. stripe
  65. >
  66. <el-table-column
  67. label="序号"
  68. type="index"
  69. align="center"
  70. width="100"
  71. show-overflow-tooltip
  72. ></el-table-column>
  73. <el-table-column
  74. align="center"
  75. label="经销商名称"
  76. prop="customerName"
  77. min-width="160"
  78. show-overflow-tooltip
  79. >
  80. <template slot-scope="scope">
  81. <el-select
  82. filterable
  83. v-model="scope.row.customerId"
  84. placeholder="请选择"
  85. >
  86. <el-option
  87. v-for="item in customerData"
  88. :key="item.id"
  89. :label="item.name"
  90. :value="item.id"
  91. >
  92. </el-option>
  93. </el-select>
  94. </template>
  95. </el-table-column>
  96. <el-table-column
  97. align="center"
  98. label="返利类型"
  99. prop="name"
  100. min-width="160"
  101. show-overflow-tooltip
  102. >
  103. <template slot-scope="scope">
  104. <el-select
  105. filterable
  106. v-model="scope.row.name"
  107. placeholder="请选择"
  108. @focus="typeFn(scope.row)"
  109. >
  110. <el-option
  111. v-for="item in typeList"
  112. :key="item.id"
  113. :label="item.name"
  114. :value="item.id"
  115. >
  116. </el-option>
  117. </el-select>
  118. </template>
  119. </el-table-column>
  120. <el-table-column
  121. align="center"
  122. label="返利金额"
  123. prop=""
  124. min-width="160"
  125. show-overflow-tooltip
  126. >
  127. <template slot-scope="scope">
  128. <el-input v-model="scope.row.money"></el-input>
  129. </template>
  130. </el-table-column>
  131. <el-table-column
  132. align="center"
  133. label="备注"
  134. prop=""
  135. min-width="160"
  136. show-overflow-tooltip
  137. >
  138. <template slot-scope="scope">
  139. <el-input v-model="scope.row.bz"></el-input>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. </div>
  144. </div>
  145. <!-- 按钮 -->
  146. <div class="btn-group clearfix">
  147. <div class="fl">
  148. <el-button type="primary" size="small" @click="preservationFn"
  149. >保存</el-button
  150. >
  151. <el-button type="primary" size="small" @click="resetFn">重置</el-button>
  152. </div>
  153. </div>
  154. </div>
  155. </template>
  156. <script>
  157. import { mapGetters } from "vuex";
  158. import {
  159. getUserInfo,
  160. getWalletCustomerList,
  161. getTransferAdd,
  162. getTransferSubmit,
  163. getCustomerGroupList,
  164. } from "@/api/finance/change_apply";
  165. export default {
  166. data() {
  167. return {
  168. listLoading: false, // 列表加载loading
  169. dataList: [],
  170. searchForm: {
  171. customerId: "",
  172. customerName: "",
  173. },
  174. customerData: [], //经销商数据
  175. typeList: [], //返利类型数据
  176. };
  177. },
  178. computed: {
  179. ...mapGetters(["userid"]),
  180. },
  181. created() {
  182. this.getUserInfoFn();
  183. this.getCustomerData();
  184. },
  185. methods: {
  186. func(arr, target) {
  187. var obj = {};
  188. for (var i = 0; i < arr.length; i++) {
  189. var item = arr[i].money;
  190. if (obj[item] === undefined) {
  191. var x = target - item;
  192. obj[x] = i;
  193. } else {
  194. return [obj[item], i];
  195. }
  196. }
  197. return null;
  198. },
  199. resetFn() {
  200. this.dataList.forEach((v) => {
  201. v.money = "";
  202. v.bz = "";
  203. });
  204. },
  205. //返利类型数据
  206. async typeFn(row) {
  207. let res = await getWalletCustomerList({
  208. customerId: row.customerId,
  209. type: "REBATE",
  210. });
  211. this.typeList = res.data;
  212. },
  213. //查询同个集团的经销商数据
  214. async getCustomerData() {
  215. const res = await getCustomerGroupList();
  216. console.log(res, 123214);
  217. this.customerData = res.data;
  218. },
  219. //保存
  220. async preservationFn() {
  221. let receiverWalletRebateId;
  222. let initiatorWalletRebateId;
  223. let initiatorRemark;
  224. let receiverRemark;
  225. let amount;
  226. let res = this.func(this.dataList, 0);
  227. console.log(res);
  228. if (this.dataList[res[0]].money > 0) {
  229. receiverWalletRebateId = this.dataList[res[0]].customerWalletId;
  230. initiatorWalletRebateId = this.dataList[res[1]].customerWalletId;
  231. receiverRemark = this.dataList[res[0]].bz;
  232. initiatorRemark = this.dataList[res[1]].bz;
  233. amount = this.dataList[res[0]].money;
  234. } else {
  235. receiverWalletRebateId = this.dataList[res[1]].customerWalletId;
  236. initiatorWalletRebateId = this.dataList[res[0]].customerWalletId;
  237. receiverRemark = this.dataList[res[1]].bz;
  238. initiatorRemark = this.dataList[res[0]].bz;
  239. amount = this.dataList[res[1]].money;
  240. }
  241. await getTransferAdd({
  242. receiverWalletRebateId,
  243. initiatorWalletRebateId,
  244. receiverRemark,
  245. initiatorRemark,
  246. amount: amount * 1,
  247. });
  248. this.$message.success("申请成功");
  249. },
  250. async getUserInfoFn() {
  251. const res = await getUserInfo({ adminUserId: this.userid });
  252. console.log(res);
  253. this.searchForm.customerId = res.data.customerId;
  254. this.searchForm.customerName = res.data.customerName;
  255. const res2 = await getWalletCustomerList({
  256. customerId: res.data.customerId,
  257. type: "REBATE",
  258. });
  259. console.log(res2);
  260. res2.data.forEach((v) => {
  261. v.money = "";
  262. v.bz = "";
  263. });
  264. this.dataList = res2.data;
  265. console.log(this.dataList);
  266. },
  267. },
  268. };
  269. </script>
  270. <style>
  271. </style>