rebate_form.vue 13 KB

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