rebate_list-edit.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576
  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
  10. ref="searchForm"
  11. :rules="rules"
  12. :model="searchForm"
  13. label-width="100px"
  14. size="small"
  15. label-position="left"
  16. >
  17. <el-row :gutter="20">
  18. <el-col :xs="24" :sm="12" :lg="6">
  19. <el-form-item label="返利日期" prop="theTime">
  20. <el-date-picker
  21. class="selectStyle"
  22. v-model="searchForm.theTime"
  23. type="datetime"
  24. placeholder="选择日期时间"
  25. default-time="23:59:59"
  26. value-format="yyyy-MM-dd HH:mm:ss"
  27. >
  28. </el-date-picker>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="6">
  32. <el-form-item label="备注" prop="remark">
  33. <el-input
  34. v-model="searchForm.remark"
  35. placeholder="请输入"
  36. ></el-input>
  37. </el-form-item>
  38. </el-col>
  39. </el-row>
  40. </el-form>
  41. </div>
  42. <!-- 按钮 -->
  43. <div class="btn-group clearfix">
  44. <div class="fl">
  45. <el-button type="primary" size="small" @click="addFn">保存</el-button>
  46. </div>
  47. <div class="fr" v-if="state == 'SAVE'">
  48. <el-button type="primary" size="small" @click="addRowFn"
  49. >添加行</el-button
  50. >
  51. <el-button type="primary" size="small" @click="delRowFn"
  52. >删除行</el-button
  53. >
  54. </div>
  55. </div>
  56. <!-- 列表 -->
  57. <div v-if="this.state != 'SAVE'" class="mymain-container">
  58. <div class="table">
  59. <el-table
  60. v-loading="listLoading"
  61. :data="dataList"
  62. element-loading-text="Loading"
  63. border
  64. fit
  65. highlight-current-row
  66. stripe
  67. :row-class-name="rouClassNameFn"
  68. @row-click="onRowClick"
  69. >
  70. <el-table-column
  71. align="center"
  72. label="序号"
  73. type="index"
  74. width="100"
  75. show-overflow-tooltip
  76. ></el-table-column>
  77. <el-table-column
  78. align="center"
  79. label="经销商编码"
  80. prop="customerNumber"
  81. min-width="160"
  82. show-overflow-tooltip
  83. >
  84. </el-table-column>
  85. <el-table-column
  86. align="center"
  87. label="经销商名称"
  88. prop="customerName"
  89. min-width="200"
  90. show-overflow-tooltip
  91. >
  92. </el-table-column>
  93. <el-table-column
  94. align="center"
  95. label="返利类型"
  96. prop="walletName"
  97. min-width="160"
  98. show-overflow-tooltip
  99. >
  100. </el-table-column>
  101. <el-table-column
  102. align="center"
  103. label="返利总金额"
  104. prop="amount"
  105. min-width="160"
  106. show-overflow-tooltip
  107. >
  108. </el-table-column>
  109. <el-table-column
  110. align="center"
  111. label="暂扣返利"
  112. prop="withholdAmount"
  113. min-width="160"
  114. show-overflow-tooltip
  115. >
  116. </el-table-column>
  117. <el-table-column
  118. align="center"
  119. label="政策文件流水号"
  120. prop="policyFileNo"
  121. min-width="160"
  122. show-overflow-tooltip
  123. >
  124. </el-table-column>
  125. <el-table-column
  126. align="center"
  127. label="政策文号"
  128. prop="policyDocNo"
  129. min-width="160"
  130. show-overflow-tooltip
  131. >
  132. <template slot-scope="scope">
  133. <el-input v-model="scope.row.policyDocNo"></el-input>
  134. </template>
  135. </el-table-column>
  136. <el-table-column
  137. align="center"
  138. label="政策年份"
  139. prop="policyYear"
  140. min-width="160"
  141. show-overflow-tooltip
  142. >
  143. </el-table-column>
  144. <el-table-column
  145. align="center"
  146. label="政策月份"
  147. prop="policyMonth"
  148. min-width="160"
  149. show-overflow-tooltip
  150. >
  151. </el-table-column>
  152. <el-table-column
  153. align="center"
  154. label="政策归属部门"
  155. prop="policyOrg"
  156. min-width="160"
  157. show-overflow-tooltip
  158. >
  159. </el-table-column>
  160. <el-table-column
  161. align="center"
  162. label="客户区域"
  163. prop="customerArea"
  164. min-width="160"
  165. show-overflow-tooltip
  166. >
  167. </el-table-column>
  168. <el-table-column
  169. align="center"
  170. label="客户属性"
  171. prop="customerAttr"
  172. min-width="160"
  173. show-overflow-tooltip
  174. >
  175. </el-table-column>
  176. <el-table-column
  177. align="center"
  178. label="建立实际归属客户"
  179. prop="rewardActualCustomers"
  180. min-width="160"
  181. show-overflow-tooltip
  182. >
  183. </el-table-column>
  184. <el-table-column
  185. align="center"
  186. label="备注1"
  187. prop="remark1"
  188. min-width="160"
  189. show-overflow-tooltip
  190. >
  191. <template slot-scope="scope">
  192. <el-input v-model="scope.row.remark1"></el-input>
  193. </template>
  194. </el-table-column>
  195. <el-table-column
  196. align="center"
  197. label="备注2"
  198. prop="remark2"
  199. min-width="160"
  200. show-overflow-tooltip
  201. >
  202. <template slot-scope="scope">
  203. <el-input v-model="scope.row.remark2"></el-input>
  204. </template>
  205. </el-table-column>
  206. </el-table>
  207. </div>
  208. </div>
  209. <!-- 列表 -->
  210. <div v-if="this.state == 'SAVE'" class="mymain-container">
  211. <div class="table">
  212. <el-table
  213. v-loading="listLoading"
  214. :data="dataList"
  215. element-loading-text="Loading"
  216. border
  217. fit
  218. highlight-current-row
  219. stripe
  220. :row-class-name="rouClassNameFn"
  221. @row-click="onRowClick"
  222. >
  223. <el-table-column
  224. align="center"
  225. label="序号"
  226. type="index"
  227. width="100"
  228. show-overflow-tooltip
  229. ></el-table-column>
  230. <el-table-column
  231. align="center"
  232. label="经销商编码"
  233. prop="customerNumber"
  234. min-width="160"
  235. show-overflow-tooltip
  236. >
  237. <template slot-scope="scope">
  238. <el-input disabled v-model="scope.row.customerNumber"></el-input>
  239. </template>
  240. </el-table-column>
  241. <el-table-column
  242. align="center"
  243. label="经销商名称"
  244. prop="customerName"
  245. min-width="200"
  246. show-overflow-tooltip
  247. >
  248. <template slot-scope="scope">
  249. <el-select
  250. @change="changeCustomerFn($event, scope.$index, scope.row)"
  251. v-model="scope.row.customerId"
  252. placeholder="请选择"
  253. >
  254. <el-option
  255. v-for="item in customerData"
  256. :key="item.id"
  257. :label="item.name"
  258. :value="item.id"
  259. >
  260. </el-option>
  261. </el-select>
  262. </template>
  263. </el-table-column>
  264. <el-table-column
  265. align="center"
  266. label="返利类型"
  267. prop="customerWalletId"
  268. min-width="160"
  269. show-overflow-tooltip
  270. >
  271. <template slot-scope="scope">
  272. <el-select
  273. v-if="state2"
  274. v-model="scope.row.customerWalletId"
  275. placeholder="请选择"
  276. >
  277. <el-option
  278. v-for="item in scope.row.walletList"
  279. :key="item.customerWalletId"
  280. :label="item.name"
  281. :value="item.customerWalletId"
  282. >
  283. </el-option>
  284. </el-select>
  285. <el-select
  286. v-else
  287. v-model="scope.row.walletName"
  288. placeholder="请选择"
  289. >
  290. <el-option :label="scope.row.walletName" value=""> </el-option>
  291. </el-select>
  292. </template>
  293. </el-table-column>
  294. <el-table-column
  295. align="center"
  296. label="返利总金额"
  297. prop="amount"
  298. min-width="160"
  299. show-overflow-tooltip
  300. >
  301. <template slot-scope="scope">
  302. <el-input v-model.number="scope.row.amount"></el-input>
  303. </template>
  304. </el-table-column>
  305. <el-table-column
  306. align="center"
  307. label="暂扣返利"
  308. prop="withholdAmount"
  309. min-width="160"
  310. show-overflow-tooltip
  311. >
  312. <template slot-scope="scope">
  313. <el-input v-model.number="scope.row.withholdAmount"></el-input>
  314. </template>
  315. </el-table-column>
  316. <el-table-column
  317. align="center"
  318. label="政策文件流水号"
  319. prop="policyFileNo"
  320. min-width="160"
  321. show-overflow-tooltip
  322. >
  323. <template slot-scope="scope">
  324. <el-input v-model="scope.row.policyFileNo"></el-input>
  325. </template>
  326. </el-table-column>
  327. <el-table-column
  328. align="center"
  329. label="政策文号"
  330. prop="policyDocNo"
  331. min-width="160"
  332. show-overflow-tooltip
  333. >
  334. <template slot-scope="scope">
  335. <el-input v-model="scope.row.policyDocNo"></el-input>
  336. </template>
  337. </el-table-column>
  338. <el-table-column
  339. align="center"
  340. label="政策年份"
  341. prop="policyYear"
  342. min-width="160"
  343. show-overflow-tooltip
  344. >
  345. <template slot-scope="scope">
  346. <el-input v-model="scope.row.policyYear"></el-input>
  347. </template>
  348. </el-table-column>
  349. <el-table-column
  350. align="center"
  351. label="政策月份"
  352. prop="policyMonth"
  353. min-width="160"
  354. show-overflow-tooltip
  355. >
  356. <template slot-scope="scope">
  357. <el-input v-model="scope.row.policyMonth"></el-input>
  358. </template>
  359. </el-table-column>
  360. <el-table-column
  361. align="center"
  362. label="政策归属部门"
  363. prop="policyOrg"
  364. min-width="160"
  365. show-overflow-tooltip
  366. >
  367. <template slot-scope="scope">
  368. <el-input v-model="scope.row.policyOrg"></el-input>
  369. </template>
  370. </el-table-column>
  371. <el-table-column
  372. align="center"
  373. label="客户区域"
  374. prop="customerArea"
  375. min-width="160"
  376. show-overflow-tooltip
  377. >
  378. <template slot-scope="scope">
  379. <el-input v-model="scope.row.customerArea"></el-input>
  380. </template>
  381. </el-table-column>
  382. <el-table-column
  383. align="center"
  384. label="客户属性"
  385. prop="customerAttr"
  386. min-width="160"
  387. show-overflow-tooltip
  388. >
  389. <template slot-scope="scope">
  390. <el-input v-model="scope.row.customerAttr"></el-input>
  391. </template>
  392. </el-table-column>
  393. <el-table-column
  394. align="center"
  395. label="建立实际归属客户"
  396. prop="rewardActualCustomers"
  397. min-width="160"
  398. show-overflow-tooltip
  399. >
  400. <template slot-scope="scope">
  401. <el-input v-model="scope.row.rewardActualCustomers"></el-input>
  402. </template>
  403. </el-table-column>
  404. <el-table-column
  405. align="center"
  406. label="备注1"
  407. prop="remark1"
  408. min-width="160"
  409. show-overflow-tooltip
  410. >
  411. <template slot-scope="scope">
  412. <el-input v-model="scope.row.remark1"></el-input>
  413. </template>
  414. </el-table-column>
  415. <el-table-column
  416. align="center"
  417. label="备注2"
  418. prop="remark2"
  419. min-width="160"
  420. show-overflow-tooltip
  421. >
  422. <template slot-scope="scope">
  423. <el-input v-model="scope.row.remark2"></el-input>
  424. </template>
  425. </el-table-column>
  426. </el-table>
  427. </div>
  428. </div>
  429. </div>
  430. </template>
  431. <script>
  432. import {
  433. getRebateOrderDetail,
  434. getRebateOrderUpdate,
  435. } from "@/api/finance/rebate_list";
  436. import {
  437. getCustomerList,
  438. getWalletCustomerList,
  439. } from "@/api/finance/rebate_form";
  440. export default {
  441. props: {
  442. detailId: {
  443. type: String,
  444. required: true,
  445. },
  446. },
  447. data() {
  448. return {
  449. state: "", //单据状态
  450. state2: false, //状态
  451. dataList: [],
  452. listLoading: false, // 列表加载loading
  453. searchForm: {
  454. theTime: "",
  455. remark: "",
  456. },
  457. customerData: [],
  458. rules: {
  459. theTime: [
  460. {
  461. required: true,
  462. message: "请选择返利日期",
  463. trigger: "blur",
  464. },
  465. ],
  466. },
  467. };
  468. },
  469. created() {
  470. this.getDataList();
  471. this.getCustomerData();
  472. },
  473. methods: {
  474. goBack() {
  475. this.$parent.showPage = 1;
  476. },
  477. //获取详情数据
  478. async getDataList() {
  479. let res = await getRebateOrderDetail({ id: this.detailId });
  480. console.log(res, 11111);
  481. // this.searchForm.rebateOrderId = res.data.id;
  482. this.searchForm.theTime = res.data.theTime;
  483. // this.searchForm.createBy = res.data.createBy;
  484. // this.searchForm.createTime = res.data.createTime;
  485. this.searchForm.remark = res.data.remark;
  486. this.dataList = res.data.items;
  487. this.state = res.data.examineStatus;
  488. },
  489. //保存
  490. async addFn() {
  491. await this.$refs.searchForm.validate();
  492. if (this.state2) {
  493. this.dataList.forEach((v) => {
  494. const arr = v.walletList.filter(
  495. (i) => i.customerWalletId == v.customerWalletId
  496. );
  497. v.walletName = arr[0].name;
  498. });
  499. }
  500. console.log(this.dataList);
  501. await getRebateOrderUpdate({
  502. ...this.searchForm,
  503. items: this.dataList,
  504. id: this.detailId,
  505. });
  506. this.$emit("updateList");
  507. this.$message.success("保存成功");
  508. this.$parent.showPage = 1;
  509. },
  510. //选择经销商名称事件
  511. async changeCustomerFn(v, index, value) {
  512. this.state2 = true;
  513. this.$nextTick(function () {
  514. value.customerWalletId = "";
  515. value.walletName = "";
  516. });
  517. const res = await getWalletCustomerList({
  518. customerId: v,
  519. type: "REBATE",
  520. });
  521. const res2 = this.customerData.filter((i) => i.id == v);
  522. this.$set(this.dataList[index], "customerNumber", res2[0].number);
  523. this.$set(this.dataList[index], "customerName", res2[0].name);
  524. this.$set(this.dataList[index], "walletList", res.data);
  525. },
  526. //获取经销商数据
  527. async getCustomerData() {
  528. const res = await getCustomerList({ pageSize: -1, pageNum: 1 });
  529. this.customerData = res.data.records;
  530. },
  531. rouClassNameFn({ row, rowIndex }) {
  532. //把每一行的索引放进row
  533. row.index = rowIndex;
  534. },
  535. onRowClick(row, event, column) {
  536. this.delIndex = row.index;
  537. },
  538. //删除行
  539. delRowFn() {
  540. this.dataList.splice(this.delIndex, 1);
  541. },
  542. //添加行
  543. addRowFn() {
  544. this.dataList.push({
  545. customerNumber: "",
  546. customerName: "",
  547. customerWalletId: "",
  548. amount: null,
  549. withholdAmount: null,
  550. policyFileNo: "",
  551. policyDocNo: "",
  552. policyYear: "",
  553. policyMonth: "",
  554. policyOrg: "",
  555. customerArea: "",
  556. customerAttr: "",
  557. rewardActualCustomers: "",
  558. remark1: "",
  559. remark2: "",
  560. });
  561. },
  562. },
  563. };
  564. </script>
  565. <style lang="scss" scoped>
  566. .selectStyle {
  567. width: 100%;
  568. }
  569. </style>