rebate_list-edit.vue 16 KB

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