rebate_form.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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 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 @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 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 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 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 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 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 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 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 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 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 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 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 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 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="small" @click="addFn">保存</el-button>
  158. <!-- <el-button type="primary" size="small" @click="submitFn"
  159. >提交审批</el-button
  160. > -->
  161. <el-button type="primary" size="small" @click="cancelFn">重置</el-button>
  162. </div>
  163. <div class="fr">
  164. <el-button type="primary" size="small" @click="addRowFn">添加行</el-button>
  165. <el-button type="primary" size="small" @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. console.log(this.dataList);
  258. this.selectList.sort(function (a, b) {
  259. return b - a;
  260. });
  261. console.log(this.selectList);
  262. for (let index = 0; index < this.selectList.length; index++) {
  263. // console.log(index);
  264. this.dataList.splice(this.selectList[index], 1);
  265. }
  266. },
  267. //选择项改变
  268. selectionChange(v) {
  269. console.log(v);
  270. this.selectList = v.map((v) => v.index);
  271. console.log(this.selectList);
  272. },
  273. // 导入
  274. async handleImport(param) {
  275. const file = param.file;
  276. const formData = new FormData();
  277. formData.append("file", file);
  278. let result = await handleImport("/rebate/order/import/data", formData);
  279. console.log(result);
  280. this.importFileList = [];
  281. if (result.code == 200) {
  282. this.$message.success("导入成功");
  283. let Arr = result.data.items;
  284. for (let v = 0; v < Arr.length; v++) {
  285. let arr = await getWalletCustomerList({
  286. customerId: Arr[v].customerId,
  287. type: "REBATE",
  288. });
  289. console.log(arr, 1212);
  290. this.dataList.push({
  291. customerId: Arr[v].customerId,
  292. customerNumber: Arr[v].customerNumber,
  293. customerName: Arr[v].customerName,
  294. customerWalletId: Arr[v].customerWalletId,
  295. amount: Arr[v].amount,
  296. withholdAmount: Arr[v].withholdAmount,
  297. policyFileNo: Arr[v].policyFileNo,
  298. policyDocNo: Arr[v].policyDocNo,
  299. policyYear: Arr[v].policyYear,
  300. policyMonth: Arr[v].policyMonth,
  301. policyOrg: Arr[v].policyOrg,
  302. customerArea: Arr[v].customerArea,
  303. customerAttr: Arr[v].customerAttr,
  304. rewardActualCustomers: Arr[v].rewardActualCustomers,
  305. remark1: Arr[v].remark1,
  306. remark2: Arr[v].remark2,
  307. walletName: Arr[v].walletName,
  308. walletList: arr.data,
  309. });
  310. }
  311. } else {
  312. this.$message.error(result.message);
  313. // this.$message.error(1231);
  314. }
  315. },
  316. //下载模板
  317. async downLoadFn() {
  318. downloadFiles("/rebate/order/download");
  319. },
  320. //重置
  321. cancelFn() {
  322. this.searchForm = {
  323. theTime: "",
  324. createTime: "",
  325. remark: "",
  326. createBy: "",
  327. };
  328. },
  329. rouClassNameFn({ row, rowIndex }) {
  330. //把每一行的索引放进row
  331. row.index = rowIndex;
  332. },
  333. onRowClick(row, event, column) {
  334. this.delIndex = row.index;
  335. },
  336. //删除行
  337. delRowFn() {
  338. this.dataList.splice(this.delIndex, 1);
  339. },
  340. // //提交审批
  341. // async submitFn() {
  342. // let res = await getRebateOrderList({ pageSize: -1, pageNum: 1 });
  343. // console.log(res);
  344. // let index = res.data.records.length - 1;
  345. // let arr = res.data.records;
  346. // await getRebateOrderApply({ id: arr[index].rebateOrderId });
  347. // this.$message.success("提交审批成功");
  348. // },
  349. //新增
  350. async addFn() {
  351. let arr;
  352. await this.$refs.searchForm.validate();
  353. this.dataList.forEach((v) => {
  354. arr = v.walletList.filter(
  355. (i) => i.customerWalletId == v.customerWalletId
  356. );
  357. console.log(arr);
  358. v.walletName = arr[0].name;
  359. });
  360. console.log({ ...this.searchForm, items: this.dataList });
  361. await getRebateOrderAdd({ ...this.searchForm, items: this.dataList });
  362. this.$message.success("保存成功");
  363. this.$router.push("/finance/rebate/rebate_list");
  364. },
  365. //选择经销商名称事件
  366. async changeCustomerFn(v, index, value) {
  367. value.customerWalletId = "";
  368. const res = await getWalletCustomerList({
  369. customerId: v,
  370. type: "REBATE",
  371. });
  372. const res2 = this.customerData.filter((i) => i.id == v);
  373. console.log(res2, 8888);
  374. this.$set(this.dataList[index], "customerNumber", res2[0].number);
  375. this.$set(this.dataList[index], "customerName", res2[0].name);
  376. this.$set(this.dataList[index], "walletList", res.data);
  377. },
  378. //获取经销商数据
  379. async getCustomerData() {
  380. const res = await getCustomerList({ pageSize: -1, pageNum: 1 });
  381. this.customerData = res.data.records;
  382. },
  383. //添加行
  384. addRowFn() {
  385. this.dataList.push({
  386. customerNumber: "",
  387. customerName: "",
  388. customerWalletId: "",
  389. amount: null,
  390. withholdAmount: null,
  391. policyFileNo: "",
  392. policyDocNo: "",
  393. policyYear: "",
  394. policyMonth: "",
  395. policyOrg: "",
  396. customerArea: "",
  397. customerAttr: "",
  398. rewardActualCustomers: "",
  399. remark1: "",
  400. remark2: "",
  401. });
  402. },
  403. },
  404. };
  405. </script>
  406. <style lang="scss" scoped>
  407. ::v-deep .mountclass {
  408. input {
  409. text-align: right;
  410. }
  411. }
  412. .selectStyle {
  413. width: 100%;
  414. }
  415. .import-btn {
  416. display: inline-block;
  417. margin-left: 10px;
  418. }
  419. .delStyle {
  420. margin-top: 20px;
  421. }
  422. </style>