rebate_form.vue 17 KB

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