select-collection_confirm.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705
  1. /*******************************************************************************
  2. * Copyright(c) 2021 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.功能描述:客户收款确认
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * jyh 2022-5-25 1.00 新建
  9. *******************************************************************************/
  10. const app = getApp()
  11. const Constants = require('@/utils/Constants');
  12. const mixins = require('@/mixins/index.js')
  13. const utils = require('@/utils/util')
  14. mixins: [mixins],
  15. Page({
  16. mixins: [mixins],
  17. /**
  18. * 页面的初始数据
  19. */
  20. data: {
  21. annexPaths: [],
  22. dealFalg: "true",
  23. disabledSave: true,
  24. fileList: [],
  25. guId: "474fd125-7b97-4c30-88f2-5dd731fd111b",
  26. page: "orderBillingAdd",
  27. pageIndex: "undefined",
  28. routeObjName: 'receiptPayment',
  29. paymentService: app.globalData['paymentService'],
  30. moneyAccountService: app.globalData['moneyAccountService'],
  31. otherReceivableService: app.globalData['otherReceivableService'],
  32. orderService: app.globalData['orderService'],
  33. otherPayableService: app.globalData['otherPayableService'],
  34. },
  35. /**
  36. * @desc : 设置查询参数
  37. * @date : 2024年3月8日
  38. * @author : 姜永辉
  39. */
  40. setSearchParams(params) {
  41. return params;
  42. },
  43. /**
  44. * @desc : 查询 入库单
  45. * @date : 2024年3月8日
  46. * @author : 姜永辉
  47. */
  48. getData(params) {
  49. return this.excute(this.data.moneyAccountService, this.data.moneyAccountService.selectByCond, params);
  50. },
  51. /**
  52. * @desc : 处理接口返回数据
  53. * @date : 2024年3月8日
  54. * @author : 姜永辉
  55. */
  56. handleSearchData(tableData) {
  57. let formData = JSON.parse(this.data.item)
  58. // 根据formtype不同值
  59. // formType :1 收款单 ,2 付款单,3 客户收款保存参数,4 客户退款 5 退收款单 6 退付款单 7 订单开单收款
  60. if (this.data.formType == 1 || this.data.formType == 2
  61. || this.data.formType == 5 || this.data.formType == 6) {
  62. formData.sumAmount = formData.sumAmount
  63. }
  64. this.setData({
  65. formData: this.data.item,
  66. form: formData,
  67. })
  68. if ((this.data.formType == 3 || this.data.formType == 4) && formData.editFlag) { //客户收款/退款编辑
  69. this.setData({
  70. tableData: formData.dataItem,
  71. settlementTypeListLength: formData.dataItem.length
  72. })
  73. this.calculationScale(formData.dataItem)
  74. }
  75. },
  76. /**
  77. * @desc : 保存数据服务--校验
  78. * @date : 2024/2/1 15:49
  79. * @author : 姜永辉
  80. */
  81. validData() {
  82. let msgError = null
  83. let form = this.data.form
  84. // 请选择支付方式
  85. if (this.data.settlementTypeListLength == null || this.data.settlementTypeListLength == 0) {
  86. msgError = '请选择支付方式'
  87. }
  88. let sumAmount = Number(0)
  89. this.data.tableData.forEach(item => {
  90. if (item.checked) {
  91. sumAmount += Number(item.sumAmount)
  92. }
  93. })
  94. if (msgError != null) {
  95. utils.showToast(msgError);
  96. return false
  97. }
  98. if (sumAmount != form.sumAmount) {
  99. utils.showToast('输入收款金额不正确');
  100. return false
  101. }
  102. return true
  103. },
  104. /**
  105. * @desc : 将优惠和本次核销的金额分摊到应收单据的明细里
  106. * @date : 2024/2/1 15:49
  107. * @author : 姜永辉
  108. */
  109. setReturnReceivableList(list, sumWaiveAmt, currentReceivableResidue, totalAmount) {
  110. let retList = []
  111. if (sumWaiveAmt == null || sumWaiveAmt == undefined) {
  112. sumWaiveAmt = 0
  113. }
  114. if (currentReceivableResidue == null || currentReceivableResidue == null) {
  115. currentReceivableResidue = 0
  116. }
  117. if (currentReceivableResidue == 0 && sumWaiveAmt == 0 || list == null) {
  118. return retList
  119. }
  120. let finalAmout = currentReceivableResidue
  121. let finalSumWaiveAmt = sumWaiveAmt
  122. for (let index = 0; index < list.length; index++) {
  123. const element = list[index];
  124. // 应收冲抵金额 == 明细的剩余金额 默认
  125. let amtReceivableHandle = (finalAmout < element.amtResidue ? finalAmout : element.amtResidue)
  126. let amtWaive = Number(parseFloat(element.amtResidue / totalAmount * sumWaiveAmt).toFixed(2))
  127. retList.push({
  128. accDate: element.accDate,
  129. accItemId: element.accItemId,
  130. // 应收冲抵金额
  131. amtReceivableHandle: amtReceivableHandle,
  132. // 优惠金额-分摊之后 最后一条的数据取剩余的值
  133. amtWaive: (index == list.length - 1 ? finalSumWaiveAmt : amtWaive),
  134. })
  135. finalAmout -= amtReceivableHandle
  136. finalSumWaiveAmt -= amtWaive
  137. }
  138. return retList
  139. },
  140. /**
  141. * @desc : 将优惠和本次核销的金额分摊到应付单据的明细里
  142. * @date : 2024/2/1 15:49
  143. * @author : 姜永辉
  144. */
  145. setReturnPayableList(list, sumWaiveAmt, currentPayableResidue, totalAmount) {
  146. let retList = []
  147. if (sumWaiveAmt == null || sumWaiveAmt == undefined) {
  148. sumWaiveAmt = 0
  149. }
  150. if (currentPayableResidue == null || currentPayableResidue == null) {
  151. currentPayableResidue = 0
  152. }
  153. if (currentPayableResidue == 0 && sumWaiveAmt == 0 || list == null) {
  154. return retList
  155. }
  156. let finalAmout = currentPayableResidue
  157. let finalSumWaiveAmt = sumWaiveAmt
  158. for (let index = 0; index < list.length; index++) {
  159. const element = list[index];
  160. // 应付冲抵金额 == 明细的剩余金额 默认
  161. let amtReceivableHandle = (finalAmout < element.amtResidue ? finalAmout : element.amtResidue)
  162. let amtWaive = Number(parseFloat(element.amtResidue / totalAmount * sumWaiveAmt).toFixed(2))
  163. retList.push({
  164. accDate: element.accDate,
  165. accItemId: element.accItemId,
  166. // 应付冲抵金额
  167. amtPayableHandle: amtReceivableHandle,
  168. // 优惠金额-分摊之后 最后一条的数据取剩余的值
  169. amtWaive: (index == list.length - 1 ? finalSumWaiveAmt : amtWaive),
  170. })
  171. finalAmout -= amtReceivableHandle
  172. finalSumWaiveAmt -= amtWaive
  173. }
  174. return retList
  175. },
  176. /**
  177. * @desc : 保存的參數設置
  178. * @date : 2024/2/1 15:49
  179. * @author : 姜永辉
  180. */
  181. setParams(params) {
  182. let form = this.data.form
  183. let itemList = []
  184. //收付款类型-收款的查询参数
  185. params.rpType = params.rpType ? params.rpType : Constants.rpType.receipt
  186. params.orgId = form.orgId //组织部门
  187. params.staffId = form.staffId // 员工
  188. // 合计优惠金额
  189. params.sumWaiveAmt = 0
  190. params.annexPaths = form.annexPaths ? form.annexPaths : []
  191. params.accDate = form.accDate //
  192. params.remarks = form.remarks // 备注
  193. params.makeStaff = app.globalData.user.staffId // 制单人
  194. let tableData = this.data.tableData.filter(res => { return res.checked })
  195. // 根据formtype不同值
  196. // formType :1 收款单 ,2 付款单,3 客户收款保存参数,4 客户退款 5 退收款单 6 退付款单 7 订单开单收款
  197. if (this.data.formType == 1) {
  198. params.rpType = Constants.rpType.receipt
  199. // 1 收款单
  200. params.objectId = this.data.form.objInfo.cusId // 客户
  201. // 收款金额
  202. params.sumAmtRec = Number(form.sumAmount)
  203. // 合计应收冲抵金额
  204. params.sumAmtReceivableHandle = form.currentReceivableResidue
  205. // 合计优惠金额
  206. params.sumWaiveAmt = form.sumWaiveAmt
  207. // 预存抵扣
  208. params.sumUseReceiptResidue = form.receiptResidue
  209. // 待核销金额
  210. params.sumShouldHandle = form.receivableResidue
  211. let rlsit = this.setReturnReceivableList(form.receivableList || [], form.sumWaiveAmt, form.currentReceivableResidue, form.receivableResidue)
  212. params.receivableList = rlsit //应收收款的明细
  213. tableData.forEach(item => {
  214. itemList.push(
  215. {
  216. amtRec: item.sumAmount,
  217. balance: item.balance,
  218. macCode: item.macCode,
  219. macId: item.macId,
  220. macName: item.macName,
  221. }
  222. )
  223. })
  224. } else if (this.data.formType == 2) {
  225. params.rpType = Constants.rpType.payment
  226. // 2 付款单,
  227. params.objectId = this.data.form.objInfo.supId // 供应商
  228. // 收款金额
  229. params.sumAmtPay = Number(form.sumAmount)
  230. // 合计应付冲抵金额
  231. params.sumAmtPayableHandle = form.currentPayableResidue
  232. // 合计优惠金额
  233. params.sumWaiveAmt = form.sumWaiveAmt
  234. // 预付抵扣
  235. params.sumUsePaymentResidue = form.paymentResidue
  236. // 待核销金额
  237. params.sumShouldHandle = form.payableResidue
  238. let rlsit = this.setReturnPayableList(form.payableList || [], form.sumWaiveAmt, form.currentPayableResidue, form.payableResidue)
  239. params.payableList = rlsit //应付款的明细
  240. tableData.forEach(item => {
  241. itemList.push(
  242. {
  243. amtPay: item.sumAmount,
  244. balance: item.balance,
  245. macCode: item.macCode,
  246. macId: item.macId,
  247. macName: item.macName,
  248. }
  249. )
  250. })
  251. } else if (this.data.formType == 3) {
  252. //客户收款保存参数
  253. params.sumAmtRec = Number(params.sumAmtRec)
  254. if (form.editFlag) {
  255. tableData.forEach(res => {
  256. res.amtRec = res.sumAmount
  257. })
  258. itemList = tableData
  259. } else {
  260. tableData.forEach(item => {
  261. itemList.push(
  262. {
  263. amtRec: item.sumAmount,
  264. balance: item.balance,
  265. macCode: item.macCode,
  266. macId: item.macId,
  267. macName: item.macName,
  268. }
  269. )
  270. })
  271. }
  272. params.accDate = params.accDate ? params.accDate : utils.formatDayTime(new Date())
  273. } else if (this.data.formType == 4) {
  274. //客户退款保存参数
  275. params.sumAmtRec = Number(params.sumAmtRec)
  276. //编辑退款
  277. if (form.editFlag) {
  278. tableData.forEach(res => {
  279. res.amtRec = res.sumAmount
  280. })
  281. itemList = tableData
  282. } else {
  283. tableData.forEach(item => {
  284. itemList.push(
  285. {
  286. amtRec: item.sumAmount,
  287. balance: item.balance,
  288. macCode: item.macCode,
  289. macId: item.macId,
  290. macName: item.macName,
  291. }
  292. )
  293. })
  294. }
  295. params.accDate = params.accDate ? params.accDate : utils.formatDayTime(new Date())
  296. } else if (this.data.formType == 5) {
  297. // 5 退收款单
  298. params.rpType = Constants.rpType.returnReceipt
  299. params.objectId = this.data.form.objInfo.objectId // 客户
  300. // 收款金额
  301. params.sumAmtRec = Number(form.sumAmount)
  302. // 合计应收冲抵金额
  303. params.sumAmtReceivableHandle = form.currentReceivableResidue
  304. // 合计优惠金额
  305. params.sumWaiveAmt = form.sumWaiveAmt
  306. // 预存抵扣
  307. params.sumUseReceiptResidue = form.receiptResidue
  308. // 待核销金额
  309. params.sumShouldHandle = form.receivableResidue
  310. let rlsit = this.setReturnReceivableList(form.receivableList || [], form.sumWaiveAmt, form.currentReceivableResidue, form.receivableResidue)
  311. params.receivableList = rlsit //应收收款的明细
  312. tableData.forEach(item => {
  313. itemList.push(
  314. {
  315. amtRec: item.sumAmount,
  316. balance: item.balance,
  317. macCode: item.macCode,
  318. macId: item.macId,
  319. macName: item.macName,
  320. }
  321. )
  322. })
  323. } else if (this.data.formType == 6) {
  324. // 6 退付款单,
  325. params.rpType = Constants.rpType.returnPayment
  326. params.objectId = this.data.form.objInfo.objectId // 供应商
  327. // 收款金额
  328. params.sumAmtPay = Number(form.sumAmount)
  329. // 合计应付冲抵金额
  330. params.sumAmtPayableHandle = form.currentPayableResidue
  331. // 合计优惠金额
  332. params.sumWaiveAmt = form.sumWaiveAmt
  333. // 预付抵扣
  334. params.sumUsePaymentResidue = form.paymentResidue
  335. // 待核销金额
  336. params.sumShouldHandle = form.payableResidue
  337. let rlsit = this.setReturnPayableList(form.payableList || [], form.sumWaiveAmt, form.currentPayableResidue, form.payableResidue)
  338. params.payableList = rlsit //应付款的明细
  339. tableData.forEach(item => {
  340. itemList.push(
  341. {
  342. amtPay: item.sumAmount,
  343. balance: item.balance,
  344. macCode: item.macCode,
  345. macId: item.macId,
  346. macName: item.macName,
  347. }
  348. )
  349. })
  350. } else if (this.data.formType == 7) { //其他收入单
  351. let formData = JSON.parse(this.data.formData)
  352. //收付款类型-收款的查询参数
  353. params.objectType = '对象类型-客户'
  354. params.objectId = formData.objInfo.cusId
  355. params.orgId = formData.orgId //组织部门
  356. params.staffId = formData.staffId // 员工
  357. params.accDate = formData.accDate
  358. params.annexPaths = formData.annexPaths || [] //附件
  359. params.remarks = formData.remarks // 备注
  360. params.makeStaff = app.globalData.user.staffId // 制单人
  361. let itemNumber = 0
  362. //收入类别list
  363. formData.itemList.forEach(element => {
  364. if (!isNaN(element.amtReceivable)) { //是数字才能加减
  365. itemNumber = Number(itemNumber) + Number(element.amtReceivable)
  366. }
  367. let item = {}
  368. item.receivableType = element.dataId //收入类别
  369. item.amtReceivable = element.amtReceivable //收入金额
  370. itemList.push(item)
  371. });
  372. let receiptList = []
  373. //收款方式list
  374. tableData.forEach(item => {
  375. receiptList.push(
  376. {
  377. amtRec: item.sumAmount,
  378. macCode: item.macCode,
  379. macId: item.macId,
  380. macName: item.macName,
  381. }
  382. )
  383. })
  384. params.receiptList = receiptList
  385. params.sumAmtReceivable = itemNumber //合计应收
  386. params.sumAmtRec = formData.sumAmount
  387. } else if (this.data.formType == 8) { //订单开单收款
  388. let formData = JSON.parse(this.data.formData)
  389. params.sumAmtRec = Number(params.sumAmtRec)
  390. let itemIndex = Number(1)
  391. tableData.forEach(item => {
  392. itemList.push(
  393. {
  394. itemIndex: itemIndex++,
  395. amtRec: item.sumAmount,
  396. balance: item.balance,
  397. macCode: item.macCode,
  398. macId: item.macId,
  399. macName: item.macName,
  400. }
  401. )
  402. })
  403. params.accDate = params.accDate ? params.accDate : utils.formatDayTime(new Date())
  404. params.receiptList = itemList
  405. console.log('formData', formData)
  406. params.sumAmtPay = formData.sumAmount
  407. console.log('params', params)
  408. delete params['sumAmtPay']
  409. delete params['sumAmtRec']
  410. } else if (this.data.formType == 9) { //其他支出
  411. let formData = JSON.parse(this.data.formData)
  412. //收付款类型-收款的查询参数
  413. params.objectType = '对象类型-供应商'
  414. params.objectId = formData.objInfo.supId
  415. params.orgId = formData.orgId //组织部门
  416. params.staffId = formData.staffId // 员工
  417. params.accDate = formData.accDate
  418. params.annexPaths = formData.annexPaths || [] //附件
  419. params.remarks = formData.remarks // 备注
  420. params.makeStaff = app.globalData.user.staffId // 制单人
  421. let itemNumber = 0
  422. formData.itemList.forEach(element => {
  423. if (!isNaN(element.amtPayable)) { //是数字才能加减
  424. itemNumber = Number(itemNumber) + Number(element.amtPayable)
  425. }
  426. let item = {}
  427. item.payableType = element.dataId //收入类别
  428. item.amtPayable = element.amtPayable //收入金额
  429. itemList.push(item)
  430. });
  431. params.sumAmtPayable = itemNumber
  432. params.sumAmtPay = formData.sumAmount
  433. let paymentList = []
  434. tableData.forEach(item => {
  435. paymentList.push(
  436. {
  437. amtPay: item.sumAmount,
  438. macCode: item.macCode,
  439. macId: item.macId,
  440. macName: item.macName,
  441. }
  442. )
  443. })
  444. params.paymentList = paymentList
  445. }
  446. if (this.data.formType !== 8) {
  447. params.itemList = itemList
  448. }
  449. return params
  450. },
  451. /**
  452. * @desc : 收款保存
  453. * @date : 2024/2/1 15:49
  454. * @author : 姜永辉
  455. */
  456. saveData() {
  457. // 根据formtype不同值
  458. // formType :1 收款单 ,2 付款单, 3 客户收款 4 客户退款 5 退收款单 6 退付款单 7 其他收入单 8 订单开单收款 9 其他支出
  459. if (this.data.formType == 1) {
  460. return this.excute(this.data.service, this.data.service.insertReceivableReceipt, this.data.params)
  461. } else if (this.data.formType == 2) {
  462. return this.excute(this.data.paymentService, this.data.paymentService.insertPayableReceipt, this.data.params)
  463. } else if (this.data.formType == 3) { //客户收款
  464. if (this.data.form.editFlag) {
  465. return this.excute(this.data.service, this.data.service.update, this.data.params)
  466. } else {
  467. return this.excute(this.data.service, this.data.service.insertReceipt, this.data.params)
  468. }
  469. } else if (this.data.formType == 4) { //客户退款
  470. if (this.data.form.editFlag) {
  471. return this.excute(this.data.service, this.data.service.update, this.data.params)
  472. } else {
  473. return this.excute(this.data.service, this.data.service.insertRefund, this.data.params)
  474. }
  475. } else if (this.data.formType == 5) {
  476. return this.excute(this.data.service, this.data.service.insertReceivableReceipt, this.data.params)
  477. } else if (this.data.formType == 6) {
  478. return this.excute(this.data.paymentService, this.data.paymentService.insertPayableReceipt, this.data.params)
  479. } else if (this.data.formType == 7) {
  480. return this.excute(this.data.otherReceivableService, this.data.otherReceivableService.insert, this.data.params)
  481. } else if (this.data.formType == 8) {
  482. if (this.data.params.updateFlag) {
  483. return this.excute(this.data.orderService, this.data.orderService.update, this.data.params);
  484. } else {
  485. return this.excute(this.data.orderService, this.data.orderService.insert, this.data.params);
  486. }
  487. } else if (this.data.formType == 9) {
  488. return this.excute(this.data.otherPayableService, this.data.otherPayableService.insert, this.data.params);
  489. }
  490. },
  491. /**
  492. * @desc : 处理保存返回数据
  493. * @date : 2024年3月8日
  494. * @author : 姜永辉
  495. */
  496. handleData() {
  497. if (this.data.formType == 3 || this.data.formType == 4) { //客户收款/退款
  498. console.log('处理保存返回数据')
  499. let pages = getCurrentPages();
  500. let prevPage = pages[pages.length - 3]; //上二页
  501. prevPage.setData({
  502. refreshByAdd: true
  503. })
  504. wx.navigateBack({
  505. delta: 1
  506. })
  507. } else if (this.data.formType == 8) { //订单收款
  508. let pages = getCurrentPages();
  509. let prevPage = pages[pages.length - 2]; //上1页
  510. prevPage.setData({
  511. formData: true
  512. })
  513. }
  514. },
  515. /**
  516. * 显示放大图片
  517. * @param {*} e
  518. */
  519. previewImg: function (e) {
  520. let imgs = [e.currentTarget.dataset.imgurl]
  521. wx.previewImage({
  522. urls: imgs,
  523. current: e.currentTarget.dataset.imgurl, //当前图片地址
  524. success: function (res) { },
  525. fail: function (res) { },
  526. complete: function (res) { },
  527. })
  528. },
  529. /**
  530. * @desc : checkbox点击事件
  531. * @date : 2022/5/23 15:16
  532. */
  533. catchtapCheck(e) {
  534. let tableData = this.data.tableData
  535. let form = this.data.form
  536. if (form.editFlag) {
  537. return
  538. }
  539. let index = e.target.dataset.index
  540. tableData[index].checked = e.detail
  541. if (tableData && tableData.length > 0) {
  542. // formType :1 收款单 ,2 付款单,
  543. //客户收款结算方式多选
  544. if (tableData[index].checked) {
  545. tableData[index].sumAmount = Number(0)
  546. }
  547. //已选数量
  548. let settlementTypeListLength = tableData.filter(item => {
  549. return item.checked
  550. })
  551. //如果只选择一个 默认总的收款金额
  552. if (settlementTypeListLength.length == 1) {
  553. tableData.forEach(res => {
  554. if (res.checked) {
  555. res.sumAmount = form.sumAmount
  556. }
  557. })
  558. }
  559. if (settlementTypeListLength.length > 1) {
  560. this.calculationScale(tableData)
  561. }
  562. this.setData({
  563. tableData: tableData,
  564. settlementTypeListLength: settlementTypeListLength.length //已选数量
  565. })
  566. }
  567. },
  568. /**
  569. * @desc : 计算多选金额
  570. * @date : 2024/3/20 15:49
  571. * @author : 于继渤
  572. */
  573. calculationScale(tableData) {
  574. let form = this.data.form
  575. tableData = tableData.filter((item) => {
  576. return item.checked == true
  577. })
  578. let totalSumAmount = form.sumAmount
  579. let sumAmountIndexItem = Number(totalSumAmount / tableData.length).toFixed(2)
  580. let allocationRatioTotal = Number(0)
  581. //数据取余2为0
  582. if ((totalSumAmount % tableData.length) == 0) {
  583. //循环将计算好的百分比放入数据中
  584. for (let i in tableData) {
  585. tableData[i]['sumAmount'] = Number(sumAmountIndexItem).toFixed(2)
  586. }
  587. } else { //数据取余2不为0
  588. //获取最后选中checkbox数组中最后一个元素
  589. let endList = tableData.splice(-1)
  590. console.log('endList', endList)
  591. for (let i = 0; i < tableData.length; i++) {
  592. allocationRatioTotal = Number(allocationRatioTotal + Number(sumAmountIndexItem))
  593. tableData[i]['sumAmount'] = Number(sumAmountIndexItem).toFixed(2)
  594. }
  595. if (endList[0]) {
  596. endList[0]['sumAmount'] = Number(totalSumAmount - allocationRatioTotal).toFixed(2)
  597. }
  598. }
  599. this.setData({
  600. tableData: tableData
  601. })
  602. },
  603. /**
  604. * 结算方式金额输入事件
  605. * @param {*} e
  606. */
  607. sumAmountBindValue(e) {
  608. let tableData = this.data.tableData
  609. let value = e.detail.value ? Number(e.detail.value) : 0
  610. let index = e.currentTarget.dataset.index
  611. tableData[index].sumAmount = value
  612. this.setData({
  613. tableData: tableData
  614. })
  615. },
  616. // sumAmountBlurValue(e){
  617. // let tableData = this.data.tableData
  618. // let form = this.data.form
  619. // let index_ = e.currentTarget.dataset.index
  620. // let value = e.currentTarget.dataset.value
  621. // form.sumAmount - value
  622. // let tempList =[]
  623. // for(let i =0 ;i < tableData.length;i++){
  624. // if(i!=index_ && tableData[i].checked == true){
  625. // tempList.push(tableData[i])
  626. // }
  627. // }
  628. // console.log('tempList',tempList)
  629. // tableData[index_].sumAmount = value
  630. // this.setData({
  631. // tableData: tableData
  632. // })
  633. // },
  634. /**
  635. * @desc : 销售价格编辑
  636. * @author : 姜永辉
  637. * @date : 2022/5/31 14:45
  638. */
  639. changeSalesPriceField(e) {
  640. let form = this.data.form
  641. form.sumAmount = e.detail.value;
  642. let tableData = this.data.tableData
  643. if (tableData && tableData.length > 0) {
  644. tableData.forEach(res => {
  645. if (res.checked) {
  646. res.sumAmount = Number(e.detail.value ? e.detail.value : 0);
  647. }
  648. })
  649. }
  650. this.setData({
  651. tableData: tableData,
  652. form
  653. })
  654. },
  655. })