change_apply.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. <div v-if="scope.$index == 0"></div>
  79. <el-input v-if="scope.$index == 1" size="mini" type="number" v-model="scope.row.allowanceAmount"></el-input>
  80. </template>
  81. </el-table-column>
  82. <el-table-column align="left" label="备注" prop="" min-width="160" show-overflow-tooltip>
  83. <template slot-scope="scope">
  84. <el-input size="mini" v-model="scope.row.bz"></el-input>
  85. </template>
  86. </el-table-column>
  87. </el-table>
  88. </div>
  89. </div>
  90. <!-- 按钮 -->
  91. <div class="btn-group clearfix">
  92. <div class="fl">
  93. <el-button type="primary" size="mini" @click="preservationFn">保存</el-button>
  94. <el-button type="primary" size="mini" @click="resetFn">重置</el-button>
  95. </div>
  96. </div>
  97. </div>
  98. </template>
  99. <script>
  100. import { mapGetters } from "vuex";
  101. import {
  102. getUserInfo,
  103. getWalletCustomerList,
  104. getTransferAdd,
  105. getTransferSubmit,
  106. getCustomerGroupList,
  107. } from "@/api/finance/change_apply";
  108. export default {
  109. data() {
  110. return {
  111. listLoading: false, // 列表加载loading
  112. dataList: [
  113. {
  114. customerNumber: "",
  115. customerId: "",
  116. name: "",
  117. money: "",
  118. bz: "",
  119. },
  120. {
  121. customerNumber: "",
  122. customerId: "",
  123. name: "",
  124. money: "",
  125. bz: "",
  126. allowanceAmount: "",
  127. },
  128. ],
  129. searchForm: {
  130. customerId: "",
  131. customerName: "",
  132. nickName: "",
  133. customerNumber: "",
  134. },
  135. customerData: [], //经销商数据
  136. typeList: [], //返利类型数据
  137. // rules: {
  138. // theTime: [
  139. // {
  140. // required: true,
  141. // message: "请选择日期",
  142. // trigger: "change",
  143. // },
  144. // ],
  145. // },
  146. };
  147. },
  148. computed: {
  149. ...mapGetters(["userid"]),
  150. },
  151. created() {
  152. this.getUserInfoFn();
  153. this.getCustomerData();
  154. },
  155. methods: {
  156. //选择经销商名称事件
  157. async changeCustomerFn1(v, index, value) {
  158. // value.customerWalletId = "";
  159. // console.log(v);
  160. const res = await getWalletCustomerList({
  161. customerId: v,
  162. type: "REBATE",
  163. });
  164. // console.log(res, 7878);
  165. const res2 = this.customerData.filter((i) => i.id == v);
  166. // console.log(res2, 8888);
  167. this.$set(this.dataList[1], "customerNumber", res2[0].number);
  168. // this.$set(this.dataList[index], "customerName", res2[0].name);
  169. // this.$set(this.dataList[index], "walletList", res.data);
  170. },
  171. // func(arr, target) {
  172. // var obj = {};
  173. // for (var i = 0; i < arr.length; i++) {
  174. // var item = arr[i].money;
  175. // if (obj[item] === undefined) {
  176. // var x = target - item;
  177. // obj[x] = i;
  178. // } else {
  179. // return [obj[item], i];
  180. // }
  181. // }
  182. // return null;
  183. // },
  184. resetFn() {
  185. this.searchForm.theTime = null;
  186. this.dataList.forEach((v) => {
  187. v.money = "";
  188. v.bz = "";
  189. v.name = "";
  190. });
  191. this.dataList[1].customerId = "";
  192. },
  193. // //返利类型数据
  194. async changeCustomerFn(v, index) {
  195. if (v.customerId == "") {
  196. return;
  197. }
  198. v.name = "";
  199. let res = await getWalletCustomerList({
  200. customerId: v.customerId,
  201. type: "REBATE",
  202. });
  203. this.$set(this.dataList[index], "typeList", res.data);
  204. // if (index == 1) {
  205. // let aa = res.data.filter(
  206. // (v) => v.customerWalletId != this.dataList[0].name
  207. // );
  208. // this.$set(this.dataList[index], "typeList", aa);
  209. // } else {
  210. // this.$set(this.dataList[index], "typeList", res.data);
  211. // }
  212. },
  213. // async typeFn(row) {
  214. // console.log(row);
  215. // let res = await getWalletCustomerList({
  216. // customerId: row.customerId,
  217. // type: "REBATE",
  218. // });
  219. // this.typeList = res.data;
  220. // },
  221. //查询同个集团的经销商数据
  222. async getCustomerData() {
  223. const res = await getCustomerGroupList();
  224. // console.log(res, 123214);
  225. this.customerData = res.data;
  226. },
  227. //保存
  228. async preservationFn() {
  229. // let receiverWalletRebateId;
  230. // let initiatorWalletRebateId;
  231. // let initiatorRemark;
  232. // let receiverRemark;
  233. // let amount;
  234. await this.$refs.searchForm.validate();
  235. let aaa = this.dataList.find((v) => {
  236. if (v.money == "") {
  237. this.$message.error("请输入返利金额");
  238. return v;
  239. }
  240. if (v.customerId == "") {
  241. this.$message.error("请选择经销商");
  242. return v;
  243. }
  244. if (v.name == "") {
  245. this.$message.error("请选择返利类型");
  246. return v;
  247. }
  248. });
  249. if (aaa != undefined) {
  250. return;
  251. }
  252. if (this.dataList[0].money > 0) {
  253. this.$message.error("转出金额必须为负数");
  254. return;
  255. }
  256. if (this.dataList[1].money < 0 && this.dataList[1].allowanceAmount < 0) {
  257. this.$message.error("转入金额必须为正数");
  258. return;
  259. }
  260. if (
  261. Number(this.dataList[0].money) !=
  262. Number(this.dataList[1].money) +
  263. Number(this.dataList[1].allowanceAmount)
  264. ) {
  265. this.$message.error("转入转出金额不等,请重新输入");
  266. return;
  267. }
  268. // if (this.dataList[0].money > 0) {
  269. // receiverWalletRebateId = this.dataList[0].name;
  270. // initiatorWalletRebateId = this.dataList[1].name;
  271. // initiatorRemark = this.dataList[1].bz;
  272. // receiverRemark = this.dataList[0].bz;
  273. // amount = this.dataList[0].money;
  274. // } else {
  275. // receiverWalletRebateId = this.dataList[1].name;
  276. // initiatorWalletRebateId = this.dataList[0].name;
  277. // initiatorRemark = this.dataList[0].bz;
  278. // receiverRemark = this.dataList[1].bz;
  279. // amount = this.dataList[1].money;
  280. // }
  281. let params = {
  282. amount: this.dataList[1].money,
  283. initiatorAmount: this.dataList[0].money,
  284. initiatorWalletRebateId: this.dataList[0].name,
  285. receiverWalletRebateId: this.dataList[1].name,
  286. allowanceAmount: this.dataList[1].allowanceAmount,
  287. initiatorRemark: this.dataList[0].bz,
  288. receiverRemark: this.dataList[1].bz,
  289. };
  290. await getTransferAdd(params);
  291. this.$router.push("/finance/rebate/change_list");
  292. this.$message.success("申请成功");
  293. },
  294. async getUserInfoFn() {
  295. const res = await getUserInfo({ adminUserId: this.userid });
  296. this.searchForm.customerNumber = res.data.customerNumber;
  297. this.dataList[0].customerId = res.data.customerId;
  298. this.searchForm.customerName = res.data.customerName;
  299. this.searchForm.customerNumber = res.data.customerNumber;
  300. this.searchForm.nickName = res.data.nickName;
  301. // const res2 = await getWalletCustomerList({
  302. // customerId: res.data.customerId,
  303. // type: "REBATE",
  304. // });
  305. // console.log(res2, 5555);
  306. // res2.data.forEach((v) => {
  307. // v.money = "";
  308. // v.bz = "";
  309. // });
  310. // this.dataList = res2.data;
  311. // console.log(this.dataList);
  312. },
  313. },
  314. };
  315. </script>
  316. <style lang="scss" scoped>
  317. .dateStyle {
  318. width: 100%;
  319. }
  320. </style>