rebate_form.vue 15 KB

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