change_apply.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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="theTime">
  16. <el-date-picker
  17. disabled
  18. class="dateStyle"
  19. placeholder="系统自动生成"
  20. type="datetime"
  21. value-format="yyyy-MM-dd HH:mm:ss"
  22. >
  23. </el-date-picker>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :xs="24" :sm="12" :lg="6">
  27. <el-form-item label="制单人" prop="">
  28. <el-input v-model="searchForm.nickName" disabled></el-input>
  29. </el-form-item>
  30. </el-col>
  31. <el-col :xs="24" :sm="12" :lg="6">
  32. <el-form-item label="经销商编号" prop="">
  33. <el-input disabled v-model="searchForm.customerNumber"></el-input>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :xs="24" :sm="12" :lg="6">
  37. <el-form-item label="经销商名称" prop="">
  38. <el-input disabled v-model="searchForm.customerName"></el-input>
  39. </el-form-item>
  40. </el-col>
  41. <!-- <el-col :xs="24" :sm="12" :lg="6">
  42. <el-form-item label="备注信息" prop="">
  43. <el-input placeholder="请输入"></el-input>
  44. </el-form-item>
  45. </el-col> -->
  46. </el-row>
  47. </el-form>
  48. </div>
  49. <!-- 列表 -->
  50. <div class="mymain-container">
  51. <div class="table">
  52. <el-table
  53. v-loading="listLoading"
  54. :data="dataList"
  55. element-loading-text="Loading"
  56. border
  57. fit
  58. highlight-current-row
  59. stripe
  60. >
  61. <el-table-column label="序号" type="index" align="left" width="100" show-overflow-tooltip></el-table-column>
  62. <el-table-column align="left" label="经销商编码" prop="customerNumber" min-width="160" show-overflow-tooltip>
  63. <template slot-scope="scope">
  64. <div v-if="scope.$index == 0">
  65. <div v-if="isCustomer">{{ searchForm.customerNumber }}</div>
  66. <div v-else>
  67. <el-select
  68. size="mini"
  69. class="dateStyle"
  70. @change="changeCustomerNumber($event, 0)"
  71. filterable
  72. v-model.trim="scope.row.customerNumber"
  73. placeholder="请选择"
  74. >
  75. <el-option v-for="item in customerData" :key="item.id" :label="item.number" :value="item.number">
  76. </el-option>
  77. </el-select>
  78. </div>
  79. </div>
  80. <div v-if="scope.$index == 1">
  81. <div v-if="isCustomer">{{ scope.row.customerNumber }}</div>
  82. <div v-else>
  83. <el-select
  84. size="mini"
  85. class="dateStyle"
  86. @change="changeCustomerNumber($event, 1)"
  87. filterable
  88. v-model.trim="scope.row.customerNumber"
  89. placeholder="请选择"
  90. >
  91. <el-option v-for="item in customerData" :key="item.id" :label="item.number" :value="item.number">
  92. </el-option>
  93. </el-select>
  94. </div>
  95. </div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="260" show-overflow-tooltip>
  99. <template slot-scope="scope">
  100. <div v-if="scope.$index == 0">{{ searchForm.customerName }}</div>
  101. <el-select
  102. size="mini"
  103. class="dateStyle"
  104. @change="changeCustomerFn1($event, scope.$index, scope.row)"
  105. v-if="scope.$index == 1"
  106. filterable
  107. v-model="scope.row.customerId"
  108. placeholder="请选择"
  109. >
  110. <el-option v-for="item in customerData" :key="item.id" :label="item.name" :value="item.id"> </el-option>
  111. </el-select>
  112. </template>
  113. </el-table-column>
  114. <el-table-column align="left" label="返利类型" prop="name" min-width="160" show-overflow-tooltip>
  115. <template slot-scope="scope">
  116. <el-select
  117. size="mini"
  118. filterable
  119. v-model="scope.row.name"
  120. placeholder="请选择"
  121. @click.native="changeCustomerFn(scope.row, scope.$index)"
  122. >
  123. <el-option
  124. v-for="item in scope.row.typeList"
  125. :key="item.customerWalletId"
  126. :label="item.name"
  127. :value="item.customerWalletId"
  128. >
  129. </el-option>
  130. </el-select>
  131. </template>
  132. </el-table-column>
  133. <el-table-column align="left" label="返利金额" prop="" min-width="160" show-overflow-tooltip>
  134. <template slot-scope="scope">
  135. <el-input size="mini" type="number" @mousewheel.native.prevent v-model="scope.row.money"></el-input>
  136. </template>
  137. </el-table-column>
  138. <el-table-column align="left" label="折让金额" prop="" min-width="160" show-overflow-tooltip>
  139. <template slot-scope="scope">
  140. <div v-if="scope.$index == 0"></div>
  141. <el-input
  142. v-if="scope.$index == 1"
  143. size="mini"
  144. type="number"
  145. @mousewheel.native.prevent
  146. v-model="scope.row.allowanceAmount"
  147. ></el-input>
  148. </template>
  149. </el-table-column>
  150. <el-table-column align="left" label="备注" prop="" min-width="160" show-overflow-tooltip>
  151. <template slot-scope="scope">
  152. <el-input size="mini" v-model="scope.row.bz"></el-input>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. </div>
  157. </div>
  158. <!-- 按钮 -->
  159. <div class="btn-group clearfix">
  160. <div class="fl">
  161. <el-button type="primary" size="mini" @click="preservationFn">保存</el-button>
  162. <el-button type="primary" size="mini" @click="resetFn">重置</el-button>
  163. </div>
  164. </div>
  165. </div>
  166. </template>
  167. <script>
  168. import { mapGetters } from 'vuex'
  169. import {
  170. getUserInfo,
  171. getWalletCustomerList,
  172. getTransferAdd,
  173. getTransferSubmit,
  174. getCustomerGroupList
  175. } from '@/api/finance/change_apply'
  176. import ret from 'bluebird/js/release/util'
  177. export default {
  178. data() {
  179. return {
  180. listLoading: false, // 列表加载loading
  181. dataList: [
  182. {
  183. customerNumber: '',
  184. customerId: '',
  185. name: '',
  186. money: '',
  187. bz: ''
  188. },
  189. {
  190. customerNumber: '',
  191. customerId: '',
  192. name: '',
  193. money: '',
  194. bz: '',
  195. allowanceAmount: ''
  196. }
  197. ],
  198. searchForm: {
  199. customerId: '',
  200. customerName: '',
  201. nickName: '',
  202. customerNumber: ''
  203. },
  204. customerData: [], //经销商数据
  205. typeList: [], //返利类型数据
  206. // rules: {
  207. // theTime: [
  208. // {
  209. // required: true,
  210. // message: "请选择日期",
  211. // trigger: "change",
  212. // },
  213. // ],
  214. // },
  215. isCustomer: JSON.parse(localStorage.getItem('supply_user')).isCustomer
  216. }
  217. },
  218. computed: {
  219. ...mapGetters(['userid'])
  220. },
  221. created() {
  222. this.getUserInfoFn()
  223. this.getCustomerData()
  224. },
  225. methods: {
  226. //选择经销商名称事件
  227. async changeCustomerFn1(v, index, value) {
  228. // value.customerWalletId = "";
  229. // console.log(v);
  230. const res = await getWalletCustomerList({
  231. customerId: v,
  232. type: 'REBATE'
  233. })
  234. // console.log(res, 7878);
  235. const res2 = this.customerData.filter(i => i.id == v)
  236. // console.log(res2, 8888);
  237. this.$set(this.dataList[1], 'customerNumber', res2[0].number)
  238. // this.$set(this.dataList[index], "customerName", res2[0].name);
  239. // this.$set(this.dataList[index], "walletList", res.data);
  240. },
  241. // func(arr, target) {
  242. // var obj = {};
  243. // for (var i = 0; i < arr.length; i++) {
  244. // var item = arr[i].money;
  245. // if (obj[item] === undefined) {
  246. // var x = target - item;
  247. // obj[x] = i;
  248. // } else {
  249. // return [obj[item], i];
  250. // }
  251. // }
  252. // return null;
  253. // },
  254. changeCustomerNumber(e, index) {
  255. if (!index) {
  256. const customerData = this.customerData.find(k => {
  257. return k.number === e
  258. })
  259. this.searchForm.customerName = customerData.name
  260. this.$set(this.dataList[index], 'customerId', customerData.id)
  261. } else {
  262. const id = this.customerData.find(k => {
  263. return k.number === e
  264. }).id
  265. this.$set(this.dataList[index], 'customerId', id)
  266. }
  267. this.$set(this.dataList[index], 'customerNumber', e)
  268. },
  269. resetFn() {
  270. this.searchForm.theTime = null
  271. this.dataList.forEach(v => {
  272. v.money = ''
  273. v.bz = ''
  274. v.name = ''
  275. })
  276. this.searchForm.customerName = ''
  277. this.dataList[0].customerId = ''
  278. this.dataList[0].customerNumber = ''
  279. this.dataList[0].customerName = ''
  280. this.dataList[0].allowanceAmount = ''
  281. this.dataList[1].customerId = ''
  282. this.dataList[1].customerNumber = ''
  283. this.dataList[1].allowanceAmount = ''
  284. },
  285. // //返利类型数据
  286. async changeCustomerFn(v, index) {
  287. console.log(v)
  288. if (v.customerId == '') {
  289. return
  290. }
  291. v.name = ''
  292. let res = await getWalletCustomerList({
  293. customerId: v.customerId,
  294. type: 'REBATE'
  295. })
  296. this.$set(this.dataList[index], 'typeList', res.data)
  297. // if (index == 1) {
  298. // let aa = res.data.filter(
  299. // (v) => v.customerWalletId != this.dataList[0].name
  300. // );
  301. // this.$set(this.dataList[index], "typeList", aa);
  302. // } else {
  303. // this.$set(this.dataList[index], "typeList", res.data);
  304. // }
  305. },
  306. // async typeFn(row) {
  307. // console.log(row);
  308. // let res = await getWalletCustomerList({
  309. // customerId: row.customerId,
  310. // type: "REBATE",
  311. // });
  312. // this.typeList = res.data;
  313. // },
  314. //查询同个集团的经销商数据
  315. async getCustomerData() {
  316. const res = await getCustomerGroupList()
  317. // console.log(res, 123214);
  318. this.customerData = res.data
  319. },
  320. //保存
  321. async preservationFn() {
  322. // let receiverWalletRebateId;
  323. // let initiatorWalletRebateId;
  324. // let initiatorRemark;
  325. // let receiverRemark;
  326. // let amount;
  327. await this.$refs.searchForm.validate()
  328. let aaa = this.dataList.find(v => {
  329. if (v.money == '') {
  330. this.$message.error('请输入返利金额')
  331. return v
  332. }
  333. if (v.customerId == '') {
  334. this.$message.error('请选择经销商')
  335. return v
  336. }
  337. if (v.name == '') {
  338. this.$message.error('请选择返利类型')
  339. return v
  340. }
  341. })
  342. if (aaa != undefined) {
  343. return
  344. }
  345. if (this.dataList[0].money > 0) {
  346. this.$message.error('转出金额必须为负数')
  347. return
  348. }
  349. if (this.dataList[1].money < 0 && this.dataList[1].allowanceAmount < 0) {
  350. this.$message.error('转入金额必须为正数')
  351. return
  352. }
  353. if (
  354. Number(-this.dataList[0].money) !=
  355. Number(this.dataList[1].money) + Number(this.dataList[1].allowanceAmount)
  356. ) {
  357. this.$message.error('转入转出金额不等,请重新输入')
  358. return
  359. }
  360. // if (this.dataList[0].money > 0) {
  361. // receiverWalletRebateId = this.dataList[0].name;
  362. // initiatorWalletRebateId = this.dataList[1].name;
  363. // initiatorRemark = this.dataList[1].bz;
  364. // receiverRemark = this.dataList[0].bz;
  365. // amount = this.dataList[0].money;
  366. // } else {
  367. // receiverWalletRebateId = this.dataList[1].name;
  368. // initiatorWalletRebateId = this.dataList[0].name;
  369. // initiatorRemark = this.dataList[0].bz;
  370. // receiverRemark = this.dataList[1].bz;
  371. // amount = this.dataList[1].money;
  372. // }
  373. let params = {
  374. amount: this.dataList[1].money,
  375. initiatorAmount: this.dataList[0].money,
  376. initiatorWalletRebateId: this.dataList[0].name,
  377. receiverWalletRebateId: this.dataList[1].name,
  378. allowanceAmount: this.dataList[1].allowanceAmount,
  379. initiatorRemark: this.dataList[0].bz,
  380. receiverRemark: this.dataList[1].bz
  381. }
  382. await getTransferAdd(params)
  383. this.resetFn()
  384. this.$router.push('/finance/change_list')
  385. // this.$router.push('/rebate/change_list')
  386. this.$message.success('申请成功')
  387. },
  388. async getUserInfoFn() {
  389. const res = await getUserInfo({ adminUserId: this.userid })
  390. this.searchForm.customerNumber = res.data.customerNumber
  391. this.dataList[0].customerId = res.data.customerId
  392. this.searchForm.customerName = res.data.customerName
  393. this.searchForm.customerNumber = res.data.customerNumber
  394. this.searchForm.nickName = res.data.nickName
  395. // const res2 = await getWalletCustomerList({
  396. // customerId: res.data.customerId,
  397. // type: "REBATE",
  398. // });
  399. // console.log(res2, 5555);
  400. // res2.data.forEach((v) => {
  401. // v.money = "";
  402. // v.bz = "";
  403. // });
  404. // this.dataList = res2.data;
  405. // console.log(this.dataList);
  406. }
  407. }
  408. }
  409. </script>
  410. <style lang="scss" scoped>
  411. .dateStyle {
  412. width: 100%;
  413. }
  414. </style>