rebate_form.vue 14 KB

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