rebate_form.vue 17 KB

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