rebate_list-edit.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <div>
  3. <div class="sty">
  4. <el-page-header @back="goBack" content="销售返利单"> </el-page-header>
  5. </div>
  6. <el-divider></el-divider>
  7. <!-- 表头 -->
  8. <div>
  9. <el-form ref="searchForm" :model="searchForm" label-width="100px" size="small" label-position="left">
  10. <el-row :gutter="20">
  11. <el-col :xs="24" :sm="12" :lg="6">
  12. <el-form-item label="返利日期" prop="">
  13. <el-date-picker disabled class="selectStyle" type="datetime" placeholder="系统自动生成" default-time="23:59:59" value-format="yyyy-MM-dd HH:mm:ss">
  14. </el-date-picker>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :xs="24" :sm="12" :lg="6">
  18. <el-form-item label="备注" prop="remark">
  19. <el-input v-model="searchForm.remark" placeholder=""></el-input>
  20. </el-form-item>
  21. </el-col>
  22. </el-row>
  23. </el-form>
  24. </div>
  25. <!-- 按钮 -->
  26. <div class="btn-group clearfix">
  27. <div class="fl">
  28. <el-button type="primary" size="small" @click="addFn">保存</el-button>
  29. </div>
  30. <div class="fr" v-if="state == 'SAVE'">
  31. <el-button type="primary" size="small" @click="addRowFn">添加行</el-button>
  32. <el-button type="primary" size="small" @click="delRowFn">删除行</el-button>
  33. </div>
  34. </div>
  35. <!-- 列表 -->
  36. <div v-if="this.state != 'SAVE'" class="mymain-container">
  37. <div class="table">
  38. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe :row-class-name="rouClassNameFn" @row-click="onRowClick">
  39. <el-table-column align="center" label="序号" type="index" width="100" show-overflow-tooltip></el-table-column>
  40. <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip>
  41. </el-table-column>
  42. <el-table-column align="center" label="经销商名称" prop="customerName" min-width="200" show-overflow-tooltip>
  43. </el-table-column>
  44. <el-table-column align="center" label="返利类型" prop="walletName" min-width="160" show-overflow-tooltip>
  45. </el-table-column>
  46. <el-table-column align="center" label="返利总金额" prop="amount" min-width="160" show-overflow-tooltip>
  47. </el-table-column>
  48. <el-table-column align="center" label="暂扣返利" prop="withholdAmount" min-width="160" show-overflow-tooltip>
  49. </el-table-column>
  50. <el-table-column align="center" label="政策文件流水号" prop="policyFileNo" min-width="160" show-overflow-tooltip>
  51. </el-table-column>
  52. <el-table-column align="center" label="政策文号" prop="policyDocNo" min-width="160" show-overflow-tooltip>
  53. <template slot-scope="scope">
  54. <el-input v-model="scope.row.policyDocNo"></el-input>
  55. </template>
  56. </el-table-column>
  57. <el-table-column align="center" label="政策年份" prop="policyYear" min-width="160" show-overflow-tooltip>
  58. </el-table-column>
  59. <el-table-column align="center" label="政策月份" prop="policyMonth" min-width="160" show-overflow-tooltip>
  60. </el-table-column>
  61. <el-table-column align="center" label="政策归属部门" prop="policyOrg" min-width="160" show-overflow-tooltip>
  62. </el-table-column>
  63. <el-table-column align="center" label="客户区域" prop="customerArea" min-width="160" show-overflow-tooltip>
  64. </el-table-column>
  65. <el-table-column align="center" label="客户属性" prop="customerAttr" min-width="160" show-overflow-tooltip>
  66. </el-table-column>
  67. <el-table-column align="center" label="建立实际归属客户" prop="rewardActualCustomers" min-width="160" show-overflow-tooltip>
  68. </el-table-column>
  69. <el-table-column align="center" label="备注1" prop="remark1" min-width="160" show-overflow-tooltip>
  70. <template slot-scope="scope">
  71. <el-input v-model="scope.row.remark1"></el-input>
  72. </template>
  73. </el-table-column>
  74. <el-table-column align="center" label="备注2" prop="remark2" min-width="160" show-overflow-tooltip>
  75. <template slot-scope="scope">
  76. <el-input v-model="scope.row.remark2"></el-input>
  77. </template>
  78. </el-table-column>
  79. </el-table>
  80. </div>
  81. </div>
  82. <!-- 列表 -->
  83. <div v-if="this.state == 'SAVE'" class="mymain-container">
  84. <div class="table">
  85. <el-table v-loading="listLoading" :data="dataList" element-loading-text="Loading" border fit highlight-current-row stripe :row-class-name="rouClassNameFn" @row-click="onRowClick">
  86. <el-table-column align="center" label="序号" type="index" width="100" show-overflow-tooltip></el-table-column>
  87. <el-table-column align="center" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip>
  88. <template slot-scope="scope">
  89. <el-input disabled v-model="scope.row.customerNumber"></el-input>
  90. </template>
  91. </el-table-column>
  92. <el-table-column align="center" label="经销商名称" prop="customerName" min-width="200" show-overflow-tooltip>
  93. <template slot-scope="scope">
  94. <el-select @change="changeCustomerFn($event, scope.$index, scope.row)" v-model="scope.row.customerId" placeholder="请选择">
  95. <el-option v-for="item in customerData" :key="item.id" :label="item.name" :value="item.id">
  96. </el-option>
  97. </el-select>
  98. </template>
  99. </el-table-column>
  100. <el-table-column align="center" label="返利类型" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  101. <template slot-scope="scope">
  102. <el-select v-if="state2" v-model="scope.row.customerWalletId" placeholder="请选择">
  103. <el-option v-for="item in scope.row.walletList" :key="item.customerWalletId" :label="item.name" :value="item.customerWalletId">
  104. </el-option>
  105. </el-select>
  106. <el-select v-else v-model="scope.row.walletName" placeholder="请选择">
  107. <el-option :label="scope.row.walletName" value=""> </el-option>
  108. </el-select>
  109. </template>
  110. </el-table-column>
  111. <el-table-column align="center" label="返利总金额" prop="amount" min-width="160" show-overflow-tooltip>
  112. <template slot-scope="scope">
  113. <el-input v-model.number="scope.row.amount"></el-input>
  114. </template>
  115. </el-table-column>
  116. <el-table-column align="center" label="暂扣返利" prop="withholdAmount" min-width="160" show-overflow-tooltip>
  117. <template slot-scope="scope">
  118. <el-input v-model.number="scope.row.withholdAmount"></el-input>
  119. </template>
  120. </el-table-column>
  121. <el-table-column align="center" label="政策文件流水号" prop="policyFileNo" min-width="160" show-overflow-tooltip>
  122. <template slot-scope="scope">
  123. <el-input v-model="scope.row.policyFileNo"></el-input>
  124. </template>
  125. </el-table-column>
  126. <el-table-column align="center" label="政策文号" prop="policyDocNo" min-width="160" show-overflow-tooltip>
  127. <template slot-scope="scope">
  128. <el-input v-model="scope.row.policyDocNo"></el-input>
  129. </template>
  130. </el-table-column>
  131. <el-table-column align="center" label="政策年份" prop="policyYear" min-width="160" show-overflow-tooltip>
  132. <template slot-scope="scope">
  133. <el-input v-model="scope.row.policyYear"></el-input>
  134. </template>
  135. </el-table-column>
  136. <el-table-column align="center" label="政策月份" prop="policyMonth" min-width="160" show-overflow-tooltip>
  137. <template slot-scope="scope">
  138. <el-input v-model="scope.row.policyMonth"></el-input>
  139. </template>
  140. </el-table-column>
  141. <el-table-column align="center" label="政策归属部门" prop="policyOrg" min-width="160" show-overflow-tooltip>
  142. <template slot-scope="scope">
  143. <el-input v-model="scope.row.policyOrg"></el-input>
  144. </template>
  145. </el-table-column>
  146. <el-table-column align="center" label="客户区域" prop="customerArea" min-width="160" show-overflow-tooltip>
  147. <template slot-scope="scope">
  148. <el-input v-model="scope.row.customerArea"></el-input>
  149. </template>
  150. </el-table-column>
  151. <el-table-column align="center" label="客户属性" prop="customerAttr" min-width="160" show-overflow-tooltip>
  152. <template slot-scope="scope">
  153. <el-input v-model="scope.row.customerAttr"></el-input>
  154. </template>
  155. </el-table-column>
  156. <el-table-column align="center" label="建立实际归属客户" prop="rewardActualCustomers" min-width="160" show-overflow-tooltip>
  157. <template slot-scope="scope">
  158. <el-input v-model="scope.row.rewardActualCustomers"></el-input>
  159. </template>
  160. </el-table-column>
  161. <el-table-column align="center" label="备注1" prop="remark1" min-width="160" show-overflow-tooltip>
  162. <template slot-scope="scope">
  163. <el-input v-model="scope.row.remark1"></el-input>
  164. </template>
  165. </el-table-column>
  166. <el-table-column align="center" label="备注2" prop="remark2" min-width="160" show-overflow-tooltip>
  167. <template slot-scope="scope">
  168. <el-input v-model="scope.row.remark2"></el-input>
  169. </template>
  170. </el-table-column>
  171. </el-table>
  172. </div>
  173. </div>
  174. </div>
  175. </template>
  176. <script>
  177. import {
  178. getRebateOrderDetail,
  179. getRebateOrderUpdate,
  180. } from "@/api/finance/rebate_list";
  181. import {
  182. getCustomerList,
  183. getWalletCustomerList,
  184. } from "@/api/finance/rebate_form";
  185. export default {
  186. props: {
  187. detailId: {
  188. type: String,
  189. required: true,
  190. },
  191. },
  192. data() {
  193. return {
  194. state: "", //单据状态
  195. state2: false, //状态
  196. dataList: [],
  197. listLoading: false, // 列表加载loading
  198. searchForm: {
  199. theTime: "",
  200. remark: "",
  201. },
  202. customerData: [],
  203. // rules: {
  204. // theTime: [
  205. // {
  206. // required: true,
  207. // message: "请选择返利日期",
  208. // trigger: "blur",
  209. // },
  210. // ],
  211. // },
  212. };
  213. },
  214. created() {
  215. this.getDataList();
  216. this.getCustomerData();
  217. },
  218. methods: {
  219. goBack() {
  220. this.$parent.showPage = 1;
  221. },
  222. //获取详情数据
  223. async getDataList() {
  224. let res = await getRebateOrderDetail({ id: this.detailId });
  225. console.log(res, 11111);
  226. // this.searchForm.rebateOrderId = res.data.id;
  227. this.searchForm.theTime = res.data.theTime;
  228. // this.searchForm.createBy = res.data.createBy;
  229. // this.searchForm.createTime = res.data.createTime;
  230. this.searchForm.remark = res.data.remark;
  231. this.dataList = res.data.items;
  232. this.state = res.data.examineStatus;
  233. },
  234. //保存
  235. async addFn() {
  236. // await this.$refs.searchForm.validate();
  237. if (this.state2) {
  238. this.dataList.forEach((v) => {
  239. const arr = v.walletList.filter(
  240. (i) => i.customerWalletId == v.customerWalletId
  241. );
  242. v.walletName = arr[0].name;
  243. });
  244. }
  245. console.log(this.dataList);
  246. await getRebateOrderUpdate({
  247. ...this.searchForm,
  248. items: this.dataList,
  249. id: this.detailId,
  250. });
  251. this.$emit("updateList");
  252. this.$message.success("保存成功");
  253. this.$parent.showPage = 1;
  254. },
  255. //选择经销商名称事件
  256. async changeCustomerFn(v, index, value) {
  257. this.state2 = true;
  258. this.$nextTick(function () {
  259. value.customerWalletId = "";
  260. value.walletName = "";
  261. });
  262. const res = await getWalletCustomerList({
  263. customerId: v,
  264. type: "REBATE",
  265. });
  266. const res2 = this.customerData.filter((i) => i.id == v);
  267. this.$set(this.dataList[index], "customerNumber", res2[0].number);
  268. this.$set(this.dataList[index], "customerName", res2[0].name);
  269. this.$set(this.dataList[index], "walletList", res.data);
  270. },
  271. //获取经销商数据
  272. async getCustomerData() {
  273. const res = await getCustomerList({ pageSize: -1, pageNum: 1 });
  274. this.customerData = res.data.records;
  275. },
  276. rouClassNameFn({ row, rowIndex }) {
  277. //把每一行的索引放进row
  278. row.index = rowIndex;
  279. },
  280. onRowClick(row, event, column) {
  281. this.delIndex = row.index;
  282. },
  283. //删除行
  284. delRowFn() {
  285. this.dataList.splice(this.delIndex, 1);
  286. },
  287. //添加行
  288. addRowFn() {
  289. this.dataList.push({
  290. customerNumber: "",
  291. customerName: "",
  292. customerWalletId: "",
  293. amount: null,
  294. withholdAmount: null,
  295. policyFileNo: "",
  296. policyDocNo: "",
  297. policyYear: "",
  298. policyMonth: "",
  299. policyOrg: "",
  300. customerArea: "",
  301. customerAttr: "",
  302. rewardActualCustomers: "",
  303. remark1: "",
  304. remark2: "",
  305. });
  306. },
  307. },
  308. };
  309. </script>
  310. <style lang="scss" scoped>
  311. .selectStyle {
  312. width: 100%;
  313. }
  314. </style>