change_apply.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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">{{ searchForm.customerNumber }}</div>
  65. <div v-if="scope.$index == 1">{{ scope.row.customerNumber }}</div>
  66. </template>
  67. </el-table-column>
  68. <el-table-column align="left" label="经销商名称" prop="customerName" min-width="260" show-overflow-tooltip>
  69. <template slot-scope="scope">
  70. <div v-if="scope.$index == 0">{{ searchForm.customerName }}</div>
  71. <el-select
  72. size="mini"
  73. class="dateStyle"
  74. @change="changeCustomerFn1($event, scope.$index, scope.row)"
  75. v-if="scope.$index == 1"
  76. filterable
  77. v-model="scope.row.customerId"
  78. placeholder="请选择"
  79. >
  80. <el-option v-for="item in customerData" :key="item.id" :label="item.name" :value="item.id"> </el-option>
  81. </el-select>
  82. </template>
  83. </el-table-column>
  84. <el-table-column align="left" label="返利类型" prop="name" min-width="160" show-overflow-tooltip>
  85. <template slot-scope="scope">
  86. <el-select
  87. size="mini"
  88. filterable
  89. v-model="scope.row.name"
  90. placeholder="请选择"
  91. @click.native="changeCustomerFn(scope.row, scope.$index)"
  92. >
  93. <el-option
  94. v-for="item in scope.row.typeList"
  95. :key="item.customerWalletId"
  96. :label="item.name"
  97. :value="item.customerWalletId"
  98. >
  99. </el-option>
  100. </el-select>
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="left" label="返利金额" prop="" min-width="160" show-overflow-tooltip>
  104. <template slot-scope="scope">
  105. <el-input size="mini" type="number" @mousewheel.native.prevent v-model="scope.row.money"></el-input>
  106. </template>
  107. </el-table-column>
  108. <el-table-column align="left" label="折让金额" prop="" min-width="160" show-overflow-tooltip>
  109. <template slot-scope="scope">
  110. <div v-if="scope.$index == 0"></div>
  111. <el-input
  112. v-if="scope.$index == 1"
  113. size="mini"
  114. type="number"
  115. @mousewheel.native.prevent
  116. v-model="scope.row.allowanceAmount"
  117. ></el-input>
  118. </template>
  119. </el-table-column>
  120. <el-table-column align="left" label="备注" prop="" min-width="160" show-overflow-tooltip>
  121. <template slot-scope="scope">
  122. <el-input size="mini" v-model="scope.row.bz"></el-input>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. </div>
  127. </div>
  128. <!-- 按钮 -->
  129. <div class="btn-group clearfix">
  130. <div class="fl">
  131. <el-button type="primary" size="mini" @click="preservationFn">保存</el-button>
  132. <el-button type="primary" size="mini" @click="resetFn">重置</el-button>
  133. </div>
  134. </div>
  135. </div>
  136. </template>
  137. <script>
  138. import { mapGetters } from 'vuex'
  139. import {
  140. getUserInfo,
  141. getWalletCustomerList,
  142. getTransferAdd,
  143. getTransferSubmit,
  144. getCustomerGroupList
  145. } from '@/api/finance/change_apply'
  146. export default {
  147. data() {
  148. return {
  149. listLoading: false, // 列表加载loading
  150. dataList: [
  151. {
  152. customerNumber: '',
  153. customerId: '',
  154. name: '',
  155. money: '',
  156. bz: ''
  157. },
  158. {
  159. customerNumber: '',
  160. customerId: '',
  161. name: '',
  162. money: '',
  163. bz: '',
  164. allowanceAmount: ''
  165. }
  166. ],
  167. searchForm: {
  168. customerId: '',
  169. customerName: '',
  170. nickName: '',
  171. customerNumber: ''
  172. },
  173. customerData: [], //经销商数据
  174. typeList: [] //返利类型数据
  175. // rules: {
  176. // theTime: [
  177. // {
  178. // required: true,
  179. // message: "请选择日期",
  180. // trigger: "change",
  181. // },
  182. // ],
  183. // },
  184. }
  185. },
  186. computed: {
  187. ...mapGetters(['userid'])
  188. },
  189. created() {
  190. this.getUserInfoFn()
  191. this.getCustomerData()
  192. },
  193. methods: {
  194. //选择经销商名称事件
  195. async changeCustomerFn1(v, index, value) {
  196. // value.customerWalletId = "";
  197. // console.log(v);
  198. const res = await getWalletCustomerList({
  199. customerId: v,
  200. type: 'REBATE'
  201. })
  202. // console.log(res, 7878);
  203. const res2 = this.customerData.filter(i => i.id == v)
  204. // console.log(res2, 8888);
  205. this.$set(this.dataList[1], 'customerNumber', res2[0].number)
  206. // this.$set(this.dataList[index], "customerName", res2[0].name);
  207. // this.$set(this.dataList[index], "walletList", res.data);
  208. },
  209. // func(arr, target) {
  210. // var obj = {};
  211. // for (var i = 0; i < arr.length; i++) {
  212. // var item = arr[i].money;
  213. // if (obj[item] === undefined) {
  214. // var x = target - item;
  215. // obj[x] = i;
  216. // } else {
  217. // return [obj[item], i];
  218. // }
  219. // }
  220. // return null;
  221. // },
  222. resetFn() {
  223. // this.searchForm.theTime = null;
  224. // this.dataList.forEach(v => {
  225. // v.money = ''
  226. // v.bz = ''
  227. // v.name = ''
  228. // })
  229. // this.dataList[1].customerId = ''
  230. // this.dataList[1].customerNumber = ''
  231. // this.dataList[1].allowanceAmount = ''
  232. Object.assign(this.$data, this.$options.data())
  233. },
  234. // //返利类型数据
  235. async changeCustomerFn(v, index) {
  236. if (v.customerId == '') {
  237. return
  238. }
  239. v.name = ''
  240. let res = await getWalletCustomerList({
  241. customerId: v.customerId,
  242. type: 'REBATE'
  243. })
  244. this.$set(this.dataList[index], 'typeList', res.data)
  245. // if (index == 1) {
  246. // let aa = res.data.filter(
  247. // (v) => v.customerWalletId != this.dataList[0].name
  248. // );
  249. // this.$set(this.dataList[index], "typeList", aa);
  250. // } else {
  251. // this.$set(this.dataList[index], "typeList", res.data);
  252. // }
  253. },
  254. // async typeFn(row) {
  255. // console.log(row);
  256. // let res = await getWalletCustomerList({
  257. // customerId: row.customerId,
  258. // type: "REBATE",
  259. // });
  260. // this.typeList = res.data;
  261. // },
  262. //查询同个集团的经销商数据
  263. async getCustomerData() {
  264. const res = await getCustomerGroupList()
  265. // console.log(res, 123214);
  266. this.customerData = res.data
  267. },
  268. //保存
  269. async preservationFn() {
  270. // let receiverWalletRebateId;
  271. // let initiatorWalletRebateId;
  272. // let initiatorRemark;
  273. // let receiverRemark;
  274. // let amount;
  275. await this.$refs.searchForm.validate()
  276. let aaa = this.dataList.find(v => {
  277. if (v.money == '') {
  278. this.$message.error('请输入返利金额')
  279. return v
  280. }
  281. if (v.customerId == '') {
  282. this.$message.error('请选择经销商')
  283. return v
  284. }
  285. if (v.name == '') {
  286. this.$message.error('请选择返利类型')
  287. return v
  288. }
  289. })
  290. if (aaa != undefined) {
  291. return
  292. }
  293. if (this.dataList[0].money > 0) {
  294. this.$message.error('转出金额必须为负数')
  295. return
  296. }
  297. if (this.dataList[1].money < 0 && this.dataList[1].allowanceAmount < 0) {
  298. this.$message.error('转入金额必须为正数')
  299. return
  300. }
  301. if (
  302. Number(-this.dataList[0].money) !=
  303. Number(this.dataList[1].money) + Number(this.dataList[1].allowanceAmount)
  304. ) {
  305. this.$message.error('转入转出金额不等,请重新输入')
  306. return
  307. }
  308. // if (this.dataList[0].money > 0) {
  309. // receiverWalletRebateId = this.dataList[0].name;
  310. // initiatorWalletRebateId = this.dataList[1].name;
  311. // initiatorRemark = this.dataList[1].bz;
  312. // receiverRemark = this.dataList[0].bz;
  313. // amount = this.dataList[0].money;
  314. // } else {
  315. // receiverWalletRebateId = this.dataList[1].name;
  316. // initiatorWalletRebateId = this.dataList[0].name;
  317. // initiatorRemark = this.dataList[0].bz;
  318. // receiverRemark = this.dataList[1].bz;
  319. // amount = this.dataList[1].money;
  320. // }
  321. let params = {
  322. amount: this.dataList[1].money,
  323. initiatorAmount: this.dataList[0].money,
  324. initiatorWalletRebateId: this.dataList[0].name,
  325. receiverWalletRebateId: this.dataList[1].name,
  326. allowanceAmount: this.dataList[1].allowanceAmount,
  327. initiatorRemark: this.dataList[0].bz,
  328. receiverRemark: this.dataList[1].bz
  329. }
  330. await getTransferAdd(params)
  331. this.resetFn()
  332. this.$router.push('/finance/rebate/change_list')
  333. this.$message.success('申请成功')
  334. },
  335. async getUserInfoFn() {
  336. const res = await getUserInfo({ adminUserId: this.userid })
  337. this.searchForm.customerNumber = res.data.customerNumber
  338. this.dataList[0].customerId = res.data.customerId
  339. this.searchForm.customerName = res.data.customerName
  340. this.searchForm.customerNumber = res.data.customerNumber
  341. this.searchForm.nickName = res.data.nickName
  342. // const res2 = await getWalletCustomerList({
  343. // customerId: res.data.customerId,
  344. // type: "REBATE",
  345. // });
  346. // console.log(res2, 5555);
  347. // res2.data.forEach((v) => {
  348. // v.money = "";
  349. // v.bz = "";
  350. // });
  351. // this.dataList = res2.data;
  352. // console.log(this.dataList);
  353. }
  354. }
  355. }
  356. </script>
  357. <style lang="scss" scoped>
  358. .dateStyle {
  359. width: 100%;
  360. }
  361. </style>