change_apply.vue 10 KB

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