rebate_list-edit.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div>
  3. <div class="sty">
  4. <el-page-header content="销售返利单" @back="goBack" />
  5. </div>
  6. <el-divider />
  7. <!-- 表头 -->
  8. <div>
  9. <el-form ref="searchForm" :model="searchForm" label-width="100px" size="small" label-position="left">
  10. <el-row :gutter="20">
  11. <el-col :xs="24" :sm="12" :lg="6">
  12. <el-form-item label="返利日期" prop="">
  13. <el-date-picker
  14. disabled
  15. class="selectStyle"
  16. type="datetime"
  17. placeholder="系统自动生成"
  18. default-time="23:59:59"
  19. value-format="yyyy-MM-dd HH:mm:ss"
  20. />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :xs="24" :sm="12" :lg="6">
  24. <el-form-item label="备注" prop="remark">
  25. <el-input v-model="searchForm.remark" placeholder="" />
  26. </el-form-item>
  27. </el-col>
  28. </el-row>
  29. </el-form>
  30. </div>
  31. <!-- 按钮 -->
  32. <div class="btn-group clearfix">
  33. <div class="fl">
  34. <el-button type="primary" size="small" @click="addFn">保存</el-button>
  35. </div>
  36. <div v-if="state == 'SAVE'" class="fr">
  37. <el-button type="primary" size="small" @click="addRowFn">添加行</el-button>
  38. <el-button type="primary" size="small" @click="delRowFn">删除行</el-button>
  39. </div>
  40. </div>
  41. <!-- 列表 -->
  42. <div v-if="state != 'SAVE' && state != 'OK'" class="mymain-container">
  43. <div class="table">
  44. <el-table
  45. v-loading="listLoading"
  46. :data="dataList"
  47. element-loading-text="Loading"
  48. border
  49. fit
  50. highlight-current-row
  51. stripe
  52. :row-class-name="rouClassNameFn"
  53. @row-click="onRowClick"
  54. >
  55. <el-table-column align="left" label="序号" type="index" width="100" show-overflow-tooltip />
  56. <el-table-column align="left" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip />
  57. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="250" show-overflow-tooltip />
  58. <el-table-column align="left" label="返利类型" prop="walletName" min-width="160" show-overflow-tooltip />
  59. <el-table-column align="right" label="返利总金额" prop="amount" min-width="160" show-overflow-tooltip />
  60. <el-table-column align="right" label="暂扣返利" prop="withholdAmount" min-width="160" show-overflow-tooltip />
  61. <el-table-column
  62. align="left"
  63. label="政策文件流水号"
  64. prop="policyFileNo"
  65. min-width="160"
  66. show-overflow-tooltip
  67. />
  68. <el-table-column align="left" label="政策文号" prop="policyDocNo" min-width="160" show-overflow-tooltip>
  69. <template slot-scope="scope">
  70. <el-input v-model="scope.row.policyDocNo" />
  71. </template>
  72. </el-table-column>
  73. <el-table-column align="left" label="政策年份" prop="policyYear" min-width="160" show-overflow-tooltip />
  74. <el-table-column align="left" label="政策月份" prop="policyMonth" min-width="160" show-overflow-tooltip />
  75. <el-table-column align="left" label="政策归属部门" prop="policyOrg" min-width="160" show-overflow-tooltip />
  76. <el-table-column align="left" label="客户区域" prop="customerArea" min-width="160" show-overflow-tooltip />
  77. <el-table-column align="left" label="客户属性" prop="customerAttr" min-width="160" show-overflow-tooltip />
  78. <el-table-column
  79. align="left"
  80. label="建立实际归属客户"
  81. prop="rewardActualCustomers"
  82. min-width="160"
  83. show-overflow-tooltip
  84. />
  85. <el-table-column align="left" label="备注1" prop="remark1" min-width="160" show-overflow-tooltip>
  86. <template slot-scope="scope">
  87. <el-input v-model="scope.row.remark1" />
  88. </template>
  89. </el-table-column>
  90. <el-table-column align="left" label="备注2" prop="remark2" min-width="160" show-overflow-tooltip>
  91. <template slot-scope="scope">
  92. <el-input v-model="scope.row.remark2" />
  93. </template>
  94. </el-table-column>
  95. </el-table>
  96. </div>
  97. </div>
  98. <!-- 列表 -->
  99. <div v-if="state == 'SAVE' || state =='OK' ||state =='OK_ONE'" class="mymain-container">
  100. <div class="table">
  101. <el-table
  102. v-loading="listLoading"
  103. :data="dataList"
  104. element-loading-text="Loading"
  105. border
  106. fit
  107. highlight-current-row
  108. stripe
  109. :row-class-name="rouClassNameFn"
  110. @row-click="onRowClick"
  111. >
  112. <el-table-column align="left" label="序号" type="index" width="100" show-overflow-tooltip />
  113. <el-table-column align="left" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip>
  114. <template slot-scope="scope">
  115. <el-input v-model="scope.row.customerNumber" disabled />
  116. </template>
  117. </el-table-column>
  118. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="250" show-overflow-tooltip>
  119. <template slot-scope="scope">
  120. <el-select
  121. v-model="scope.row.customerId"
  122. filterable
  123. placeholder="请选择"
  124. @change="changeCustomerFn($event, scope.$index, scope.row)"
  125. >
  126. <el-option v-for="item in customerData" :key="item.id" :label="item.name" :value="item.id" />
  127. </el-select>
  128. </template>
  129. </el-table-column>
  130. <el-table-column align="left" label="返利类型" prop="customerWalletId" min-width="160" show-overflow-tooltip>
  131. <template slot-scope="scope">
  132. <!-- v-if="state2" -->
  133. <el-select v-model="scope.row.customerWalletId" placeholder="请选择">
  134. <el-option
  135. v-for="item in scope.row.walletList"
  136. :key="item.customerWalletId"
  137. :label="item.name"
  138. :value="item.customerWalletId"
  139. />
  140. </el-select>
  141. <!-- <el-select v-else v-model="scope.row.walletName" placeholder="请选择">
  142. <el-option :label="scope.row.walletName" value=""> </el-option>
  143. </el-select> -->
  144. </template>
  145. </el-table-column>
  146. <el-table-column align="left" label="返利总金额" prop="amount" min-width="160" show-overflow-tooltip>
  147. <template slot-scope="scope">
  148. <el-input v-model.number="scope.row.amount" class="mountclass" />
  149. </template>
  150. </el-table-column>
  151. <el-table-column align="left" label="暂扣返利" prop="withholdAmount" min-width="160" show-overflow-tooltip>
  152. <template slot-scope="scope">
  153. <el-input v-model.number="scope.row.withholdAmount" class="mountclass" />
  154. </template>
  155. </el-table-column>
  156. <el-table-column
  157. align="left"
  158. label="政策文件流水号"
  159. prop="policyFileNo"
  160. min-width="160"
  161. show-overflow-tooltip
  162. >
  163. <template slot-scope="scope">
  164. <el-input v-model="scope.row.policyFileNo" />
  165. </template>
  166. </el-table-column>
  167. <el-table-column align="left" label="政策文号" prop="policyDocNo" min-width="160" show-overflow-tooltip>
  168. <template slot-scope="scope">
  169. <el-input v-model="scope.row.policyDocNo" />
  170. </template>
  171. </el-table-column>
  172. <el-table-column align="left" label="政策年份" prop="policyYear" min-width="160" show-overflow-tooltip>
  173. <template slot-scope="scope">
  174. <el-input v-model="scope.row.policyYear" />
  175. </template>
  176. </el-table-column>
  177. <el-table-column align="left" label="政策月份" prop="policyMonth" min-width="160" show-overflow-tooltip>
  178. <template slot-scope="scope">
  179. <el-input v-model="scope.row.policyMonth" />
  180. </template>
  181. </el-table-column>
  182. <el-table-column align="left" label="政策归属部门" prop="policyOrg" min-width="160" show-overflow-tooltip>
  183. <template slot-scope="scope">
  184. <el-input v-model="scope.row.policyOrg" />
  185. </template>
  186. </el-table-column>
  187. <el-table-column align="left" label="客户区域" prop="customerArea" min-width="160" show-overflow-tooltip>
  188. <template slot-scope="scope">
  189. <el-input v-model="scope.row.customerArea" />
  190. </template>
  191. </el-table-column>
  192. <el-table-column align="left" label="客户属性" prop="customerAttr" min-width="160" show-overflow-tooltip>
  193. <template slot-scope="scope">
  194. <el-input v-model="scope.row.customerAttr" />
  195. </template>
  196. </el-table-column>
  197. <el-table-column
  198. align="left"
  199. label="建立实际归属客户"
  200. prop="rewardActualCustomers"
  201. min-width="160"
  202. show-overflow-tooltip
  203. >
  204. <template slot-scope="scope">
  205. <el-input v-model="scope.row.rewardActualCustomers" />
  206. </template>
  207. </el-table-column>
  208. <el-table-column align="left" label="备注1" prop="remark1" min-width="160" show-overflow-tooltip>
  209. <template slot-scope="scope">
  210. <el-input v-model="scope.row.remark1" />
  211. </template>
  212. </el-table-column>
  213. <el-table-column align="left" label="备注2" prop="remark2" min-width="160" show-overflow-tooltip>
  214. <template slot-scope="scope">
  215. <el-input v-model="scope.row.remark2" />
  216. </template>
  217. </el-table-column>
  218. </el-table>
  219. </div>
  220. </div>
  221. </div>
  222. </template>
  223. <script>
  224. import { getRebateOrderDetail, getRebateOrderUpdate } from '@/api/finance/rebate_list'
  225. import { getCustomerList, getWalletCustomerList } from '@/api/finance/rebate_form'
  226. import { async } from 'q'
  227. import { tsThisType } from '@babel/types'
  228. export default {
  229. props: {
  230. detailId: {
  231. type: String,
  232. required: true
  233. }
  234. },
  235. data() {
  236. return {
  237. state: '', // 单据状态
  238. state2: false, // 状态
  239. dataList: [],
  240. listLoading: false, // 列表加载loading
  241. searchForm: {
  242. theTime: '',
  243. remark: ''
  244. },
  245. customerData: []
  246. // rules: {
  247. // theTime: [
  248. // {
  249. // required: true,
  250. // message: "请选择返利日期",
  251. // trigger: "blur",
  252. // },
  253. // ],
  254. // },
  255. }
  256. },
  257. created() {
  258. this.getDataList()
  259. this.getCustomerData()
  260. },
  261. methods: {
  262. goBack() {
  263. this.$emit('setShowPage', 1)
  264. },
  265. // 获取详情数据
  266. async getDataList() {
  267. const res = await getRebateOrderDetail({ id: this.detailId })
  268. // this.searchForm.rebateOrderId = res.data.id;
  269. this.searchForm.theTime = res.data.theTime
  270. // this.searchForm.createBy = res.data.createBy;
  271. // this.searchForm.createTime = res.data.createTime;
  272. this.searchForm.remark = res.data.remark
  273. this.state = res.data.examineStatus
  274. res.data.items.map(async k => {
  275. const wallet = await getWalletCustomerList({
  276. customerId: k.customerId,
  277. type: 'REBATE'
  278. })
  279. this.$set(k, 'walletList', wallet.data)
  280. })
  281. this.dataList = res.data.items
  282. // this.$set(this.dataList, 'walletList', wallet.data)
  283. },
  284. // 保存
  285. async addFn() {
  286. // await this.$refs.searchForm.validate();
  287. if (this.state2) {
  288. this.dataList.forEach(v => {
  289. const arr = v.walletList.filter(i => i.customerWalletId == v.customerWalletId)
  290. v.walletName = arr[0].name
  291. })
  292. }
  293. console.log(this.dataList)
  294. await getRebateOrderUpdate({
  295. ...this.searchForm,
  296. items: this.dataList,
  297. id: this.detailId
  298. })
  299. this.$emit('updateList')
  300. this.$message.success('保存成功')
  301. this.$emit('setShowPage', 1)
  302. },
  303. // 选择经销商名称事件
  304. async changeCustomerFn(v, index, value) {
  305. this.state2 = true
  306. this.$nextTick(function() {
  307. value.customerWalletId = ''
  308. value.walletName = ''
  309. })
  310. const res = await getWalletCustomerList({
  311. customerId: v,
  312. type: 'REBATE'
  313. })
  314. const res2 = this.customerData.filter(i => i.id == v)
  315. this.$set(this.dataList[index], 'customerNumber', res2[0].number)
  316. this.$set(this.dataList[index], 'customerName', res2[0].name)
  317. this.$set(this.dataList[index], 'walletList', res.data)
  318. },
  319. // 获取经销商数据
  320. async getCustomerData() {
  321. const res = await getCustomerList({ pageSize: -1, pageNum: 1 })
  322. this.customerData = res.data.records
  323. },
  324. rouClassNameFn({ row, rowIndex }) {
  325. // 把每一行的索引放进row
  326. row.index = rowIndex
  327. },
  328. onRowClick(row, event, column) {
  329. this.delIndex = row.index
  330. },
  331. // 删除行
  332. delRowFn() {
  333. this.dataList.splice(this.delIndex, 1)
  334. },
  335. // 添加行
  336. addRowFn() {
  337. this.dataList.push({
  338. customerNumber: '',
  339. customerName: '',
  340. customerWalletId: '',
  341. amount: null,
  342. withholdAmount: null,
  343. policyFileNo: '',
  344. policyDocNo: '',
  345. policyYear: '',
  346. policyMonth: '',
  347. policyOrg: '',
  348. customerArea: '',
  349. customerAttr: '',
  350. rewardActualCustomers: '',
  351. remark1: '',
  352. remark2: ''
  353. })
  354. }
  355. }
  356. }
  357. </script>
  358. <style lang="scss" scoped>
  359. ::v-deep .mountclass {
  360. input {
  361. text-align: right;
  362. }
  363. }
  364. .selectStyle {
  365. width: 100%;
  366. }
  367. </style>