姜永辉 před 2 roky
rodič
revize
a98bef8bb4

+ 9 - 9
api/pages/mac/receiptPayment.js

@@ -11,10 +11,10 @@ module.exports = {
 	receiptPaymentService: {
 		// 前缀
 		prefix: 'mdm-server/mac/recPay/',
-		insertReceivableReceipt:'insert_receivable_receipt',
-    insertPayableReceipt:'insert_payable_receipt',
-    insertReceipt:'insert_receipt',
-    insertRefund:'insert_refund'
+		insertReceivableReceipt: 'insert_receivable_receipt',
+		insertPayableReceipt: 'insert_payable_receipt',
+		insertReceipt: 'insert_receipt',
+		insertRefund: 'insert_refund'
 	},
 
 	routeUrl: {
@@ -23,7 +23,7 @@ module.exports = {
 			add: { key: 'add', url: '/package-accounts-manage/pages/receipt/add/add' },
 			// 付款单新建
 			addPay: { key: 'addPay', url: '/package-accounts-manage/pages/payment-order/add/add' },
-			
+
 			edit: { key: 'edit', url: '/package-accounts-manage/pages/receipt/detail/detail' },
 			detail: {
 				key: 'detail', url: '/package-purchase/pages/purchase-return/detail/detail'
@@ -31,11 +31,11 @@ module.exports = {
 			selectBill: {
 				key: 'selectBill', url: '/package-base-select/pages/select-bill/select-bill'
 			},
-			chooseSupplier: { key: 'chooseSupplier', url: '/package-base-select/pages/select-data/select-data',type:'supplier'  },
-			chooseStaff: { key: 'chooseStaff', url: '/package-base-select/pages/select-data/select-data',type:'staff'  },
+			chooseSupplier: { key: 'chooseSupplier', url: '/package-base-select/pages/select-data/select-data', type: 'supplier' },
+			chooseStaff: { key: 'chooseStaff', url: '/package-base-select/pages/select-data/select-data', type: 'staff' },
 			staffadd: { key: 'staffadd', url: '/package-basic-data/pages/staff/add/add' },
-			chooseOrg: { key: 'chooseOrg',url: '/package-base-select/pages/select-data/select-data',type:'org' }, 
-			chooseWh: { key: 'chooseWh', url: '/package-base-select/pages/select-data/select-data',type:'warehouse'  },
+			chooseOrg: { key: 'chooseOrg', url: '/package-base-select/pages/select-data/select-data', type: 'org' },
+			chooseWh: { key: 'chooseWh', url: '/package-base-select/pages/select-data/select-data', type: 'warehouse' },
 		}
 	}
 }; 

+ 4 - 2
components/dkbase/dk-form-more-items/dk-form-more-items.js

@@ -398,6 +398,7 @@ Component({
      * @date   : 2024/1/26 11:46
      */
     openDatePop(e) {
+      
       // 只读
       if (this.data.readonly) {
         return;
@@ -405,7 +406,7 @@ Component({
       this.setData({
         showDate: true
       })
-      let item = e.currentTarget.dataset;
+      let item = e.currentTarget.dataset; 
       if (item) {
         this.setData({
           index: item.index,
@@ -430,7 +431,7 @@ Component({
      * @date   : 2024/1/26 11:46
      */
     chooseDate(e) {
-      let form = this.data.form;
+      let form = this.data.form; 
       if (this.data.dateCol) {
         form[this.data.dateCol + '_time'] = e.detail;
         form[this.data.dateCol] = util.toDateStr(e.detail);
@@ -753,6 +754,7 @@ Component({
         form: form,
         contentObj: contentObj
       })
+      console.log("changeNumber组件",form);
       this.triggerEvent("changeNumber", { code: key, data: e.detail.value })
     },
     /**

+ 125 - 12
package-accounts-manage/pages/payment-order/add/add.js

@@ -1,3 +1,11 @@
+/*******************************************************************************
+ * Copyright(c) 2022 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:  新建付款单
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		姜永辉      2024-03-22    1.00		   	    
+ *******************************************************************************/
 const mixins = require('@/mixins/index.js')
 const Constants = require('@/utils/Constants.js');
 const app = getApp();
@@ -43,7 +51,7 @@ Page({
 
       ],
       bill: [
-        { code: 'cancelAmount', type: 'cancel', title: '核销应付', bill: 4, amount: 500 },
+        { code: 'cancelAmount', type: 'cancel', title: '核销应付', bill: 0, amount: 0 },
         { code: 'payableResidue', type: 'number', title: '待核销金额', readonly: true, },
 
         { code: 'sumWaiveAmt', type: 'number', title: '优惠金额', },
@@ -75,6 +83,7 @@ Page({
     paymentResidue: 0,
     bill: 0,
     objInfo: {},
+    table: Constants.tables.recPay,
   },
 
   /**
@@ -102,13 +111,15 @@ Page({
       formData.orgName = data.name
     }
     if (code == "bill") { //选取应付的返回值     
+      formData.payableList = data.payableList
       _this.setData({
+        payableList: data.payableList,
         objInfo: data.objInfo,
         payableResidue: data.payableResidue,
         paymentResidue: data.paymentResidue,
-        bill: data.itemLists.length,
+        bill: data.payableList.length,
       })
-      this.setForm(formData, contentObj, data.payableResidue, data.paymentResidue, data.itemLists.length)
+      this.setForm(formData, contentObj, data.payableResidue, data.paymentResidue, data.payableList.length)
       return
     }
     this.setData({
@@ -135,15 +146,17 @@ Page({
       accItemType: '账款类型-应付',
       amtResidueFlg: true,
     }
-    this.excute(this.data.accountService, this.data.accountService.getReceivableAccountItemCount, params).then(res => {
+    this.excute(this.data.accountService, this.data.accountService.getReceivableAccountItem, params).then(res => {
       formData.cancelAmount = true
+      formData.payableList = res.data.data
       _this.setForm(formData, contentObj, objInfo.payableResidue,
         objInfo.paymentResidue, res.data.data)
       _this.setData({
+        payableList: data.payableList,
         objInfo,
         payableResidue: objInfo.payableResidue,
         paymentResidue: objInfo.paymentResidue,
-        bill: res.data.data
+        bill: res.data.data.length
       })
 
     })
@@ -159,19 +172,72 @@ Page({
     let formData = JSON.parse(this.data.formData)
     let contentObj = this.data.contentObj
     if (cancelAmount) {
+      formData.payableList = this.data.payableList
       this.setForm(formData, contentObj, this.data.payableResidue, this.data.paymentResidue, this.data.bill)
     } else {
-
+      formData.payableList = []
       this.setForm(formData, contentObj, 0, 0, 0)
     }
   },
 
   /**
+ * @desc : 设置表单的数据
+ * @date : 2024/2/1 15:49
+ * @author : 姜永辉
+ */
+  changeNumber(e) {
+    let formData = JSON.parse(this.data.formData)
+    let code = e.detail.code
+    let data = e.detail.data
+    // 本次付款金额
+    if (code == "sumAmtPay") {
+      formData.sumAmtPay = data
+      formData.sumAmount = data
+      let contentList = this.data.contentList
+      contentList.forEach(it => {
+        if (it.type == 'number') {
+          it.content = data
+        }
+      })
+      this.setData({
+        contentList,
+      })
+    }
+    // 本次核销金额
+    if (code == "currentPayableResidue") {
+      formData.currentPayableResidue = data
+    }
+    // 优惠金额
+    if (code == "sumWaiveAmt") {
+      formData.sumWaiveAmt = data
+    }
+    this.setData({
+      formData: JSON.stringify(formData)
+    })
+  },
+
+  /**
    * @desc : 设置表单的数据
    * @date : 2024/2/1 15:49
    * @author : 姜永辉
    */
   setForm(formData, contentObj, payableResidue, paymentResidue, bill) {
+    console.log("app.globalData.user", app.globalData.user);
+    if (payableResidue == null) {
+      payableResidue = 0
+    }
+    if (paymentResidue == null) {
+      paymentResidue = 0
+    }
+    if (bill == null) {
+      bill = 0
+    }
+    if (formData.staffId == null) {
+      formData.staffId = app.globalData.user.staffId
+      formData.orgId = app.globalData.user.orgId
+      formData.staffName = app.globalData.user.staffName
+      formData.orgName = app.globalData.user.orgName
+    }
     formData.payableResidue = payableResidue  // 总剩余应付
     formData.currentPayableResidue = payableResidue  // 总剩余应付
     formData.sumAmount = payableResidue  // 总剩余应付
@@ -202,8 +268,12 @@ Page({
       > Number(formData.payableResidue)) {
       msgError = '本次核销不能大于待核销金额'
     }
+    if (Number(formData.currentPayableResidue) == 0
+      && Number(formData.sumAmtPay) == 0) {
+      msgError = '本次核销金额和本次付款不能同时为0'
+    }
     // 本次付款》= 本次核销
-    if (Number(formData.sumAmtRec)
+    if (Number(formData.sumAmtPay)
       < Number(formData.currentPayableResidue)) {
       msgError = '本次核销金额不能大于付款金额'
     }
@@ -227,22 +297,23 @@ Page({
    * @author : 姜永辉
    */
   setParams(params) {
-    let btnFormData = this.data.btnFormData ? JSON.parse(this.data.btnFormData) : ''
     let formData = JSON.parse(this.data.formData)
-
+    if (Number(formData.sumAmtPay) != 0) {
+      return params
+    }
     //收付款类型-收款的查询参数
     params.rpType = Constants.rpType.payment
     params.orgId = formData.orgId  //组织部门
     params.staffId = formData.staffId  // 员工
     //  // 供应商1 客户2 所有 传空
-    params.objectId = this.data.objInfo.cusId  // 客户
+    params.objectId = this.data.objInfo.supId  // 经销商
     // 收款金额					
-    params.sumAmtPay = 0
+    params.sumAmtPay = formData.sumAmtPay
     // 合计应付冲抵金额								
     params.sumAmtPayableHandle = formData.currentPayableResidue
     // 合计优惠金额
     params.sumWaiveAmt = formData.sumWaiveAmt
-    params.annexPaths = {}
+    params.annexPaths = formData.annexPaths || [] //附件 
     // params.biznisType = null
     // params.biznisId	 = null
     // params.biznisNo	= null	 
@@ -251,10 +322,52 @@ Page({
     params.makeStaff = app.globalData.user.staffId  // 制单人
 
     params.itemList = [] //明细 
+    let rlsit = this.setReturnPayableList(formData.payableList || [], formData.sumWaiveAmt, formData.currentPayableResidue, formData.payableResidue)
+    params.payableList = rlsit //应付款的明细 
     return params
   },
 
   /**
+ * @desc : 将优惠和本次核销的金额分摊到应付单据的明细里
+ * @date : 2024/2/1 15:49
+ * @author : 姜永辉
+ */
+  setReturnPayableList(list, sumWaiveAmt, currentPayableResidue, totalAmount) {
+    let retList = []
+    if (sumWaiveAmt == null || sumWaiveAmt == undefined) {
+      sumWaiveAmt = 0
+    }
+    if (currentPayableResidue == null || currentPayableResidue == null) {
+      currentPayableResidue = 0
+    }
+    if (currentPayableResidue == 0 && sumWaiveAmt == 0 || list == null) {
+      return retList
+    }
+    let finalAmout = currentPayableResidue
+    let finalSumWaiveAmt = sumWaiveAmt
+    for (let index = 0; index < list.length; index++) {
+      const element = list[index];
+      // 应付冲抵金额	== 明细的剩余金额	默认
+      let amtReceivableHandle = (finalAmout < element.amtResidue ? finalAmout : element.amtResidue)
+      let amtWaive = Number(parseFloat(element.amtResidue / totalAmount * sumWaiveAmt).toFixed(2))
+      finalAmout -= amtReceivableHandle
+      finalSumWaiveAmt -= amtWaive
+
+      retList.push({
+        accDate: list.accDate,
+        accItemId: element.accItemId,
+        // 应付冲抵金额	
+        amtPayableHandle: amtReceivableHandle,
+        // 优惠金额-分摊之后 最后一条的数据取剩余的值
+        amtWaive: (index == list.length - 1 ? finalSumWaiveAmt : amtWaive),
+      })
+    }
+
+    return retList
+
+  },
+
+  /**
   * @desc : 保存数据服务
   * @date : 2024/2/1 15:49
   * @author : 姜永辉

+ 16 - 16
package-accounts-manage/pages/payment-order/payment-order.wxml

@@ -1,18 +1,18 @@
-<!-- 前台导入wxmlUtil.wxs -->
-<wxs src='/utils/wxmlUtil.wxs' module="wxmlUtil"></wxs>
-<loading wx:if="{{loading}}"></loading>
-<van-sticky scroll-top="0">
-  <!-- 查询条件 -->
-  <dk-dropdown-menu model:value="{{searchForm}}" menuList="{{searchContent}}" pullMenuList="{{pullMenuList}}" bind:search="searchData" searchTextPlaceholder="{{wxmlUtil.setSearchPlaceholder($t,['orderNo','supplierName'])}}">
-  </dk-dropdown-menu>
-</van-sticky>
-<!-- 暂无数据 -->
-<van-empty wx:if="{{tableData.length<=0}}" description="{{$t['nodata']}}" />
-<!-- 列表区 -->
-<dk-list list="{{tableData}}" title="supplierName" subTitle="makeTime" content="{{contentList}}" collectCol="sumAmtPay" collectName="付款" contentObj="{{contentObj}}" contentCol="" footerAmount="{{footerAmount}}" footerInfo="{{footerInfo}}" bind:toDetail="toDetail" bind:toTitle="toTitle" routeObjName="{{routeObjName}}" buttonList="{{buttonList}}" bind:open="open"></dk-list>
+  <!-- 前台导入wxmlUtil.wxs -->
+  <wxs src='/utils/wxmlUtil.wxs' module="wxmlUtil"></wxs>
+  <loading wx:if="{{loading}}"></loading>
+  <van-sticky scroll-top="0">
+    <!-- 查询条件 -->
+    <dk-dropdown-menu model:value="{{searchForm}}" menuList="{{searchContent}}" pullMenuList="{{pullMenuList}}" bind:search="searchData" searchTextPlaceholder="{{wxmlUtil.setSearchPlaceholder($t,['orderNo','supplierName'])}}">
+    </dk-dropdown-menu>
+  </van-sticky>
+  <!-- 暂无数据 -->
+  <van-empty wx:if="{{tableData.length<=0}}" description="{{$t['nodata']}}" />
+  <!-- 列表区 -->
+  <dk-list list="{{tableData}}" title="supplierName" subTitle="makeTime" content="{{contentList}}" collectCol="sumAmtPay" collectName="付款" contentObj="{{contentObj}}" contentCol="" footerAmount="{{footerAmount}}" footerInfo="{{footerInfo}}" bind:toDetail="toDetail" bind:toTitle="toTitle" routeObjName="{{routeObjName}}" buttonList="{{buttonList}}" bind:open="open"></dk-list>
 
-<van-divider wx:if="{{noMore}}" contentPosition="center" borderColor="#DCDCDC">{{$t['noMore']}}~</van-divider>
+  <van-divider wx:if="{{noMore}}" contentPosition="center" borderColor="#DCDCDC">{{$t['noMore']}}~</van-divider>
 
-<view style="height: 180rpx;"></view>
-<!-- 新建按钮 -->
-<dk-save-button model:value="{{btnFormData}}" btnAutoWidthFlag="{{false}}" btnRightFlag="{{true}}"  buttonList="{{buttonFootList}}" contentList="{{contentnFootList}}" bind:open="open"></dk-save-button> 
+  <view style="height: 180rpx;"></view>
+  <!-- 新建按钮 -->
+  <dk-save-button model:value="{{btnFormData}}" btnAutoWidthFlag="{{false}}" btnRightFlag="{{true}}"  buttonList="{{buttonFootList}}" contentList="{{contentnFootList}}" bind:open="open"></dk-save-button> 

+ 132 - 20
package-accounts-manage/pages/receipt/add/add.js

@@ -1,3 +1,11 @@
+/*******************************************************************************
+ * Copyright(c) 2022 dongke All rights reserved. / Confidential
+ * 类的信息:
+ *		1.程序名称:  新建收款单
+ * 编辑履历:
+ *		作者				日期					版本				修改内容
+ *		姜永辉      2024-03-22    1.00		   	    
+ *******************************************************************************/
 const mixins = require('@/mixins/index.js')
 const Constants = require('@/utils/Constants.js');
 const app = getApp();
@@ -43,9 +51,9 @@ Page({
 
       ],
       bill: [
-        { code: 'cancelAmount', type: 'cancel', title: '核销应收', bill: 4, amount: 500 },
+        { code: 'cancelAmount', type: 'cancel', title: '核销应收', bill: 0, amount: 0 },
         { code: 'receivableResidue', type: 'number', title: '待核销金额', readonly: true, },
-        { code: 'receiptResidue', type: 'number', title: '使用预存', },
+        { code: 'receiptResidue', type: 'number', title: '使用预存', readonly: true, },
         { code: 'sumWaiveAmt', type: 'number', title: '优惠金额', },
         { code: 'currentReceivableResidue', type: 'number', title: '本次核销', required: true },
       ],
@@ -75,6 +83,7 @@ Page({
     receiptResidue: 0,
     bill: 0,
     objInfo: {},
+    table: Constants.tables.recPay,
   },
 
   /**
@@ -102,13 +111,15 @@ Page({
       formData.orgName = data.name
     }
     if (code == "bill") { //选取应收的返回值     
-      _this.setData({
+      formData.receivableList = data.receivableList
+      this.setData({
+        receivableList: data.receivableList,
         objInfo: data.objInfo,
         receivableResidue: data.receivableResidue,
         receiptResidue: data.receiptResidue,
-        bill: data.itemLists.length,
+        bill: data.receivableList.length,
       })
-      this.setForm(formData, contentObj, data.receivableResidue, data.receiptResidue, data.itemLists.length)
+      this.setForm(formData, contentObj, data.receivableResidue, data.receiptResidue, data.receivableList.length)
       return
     }
     this.setData({
@@ -134,15 +145,18 @@ Page({
       accItemType: '账款类型-应收',
       amtResidueFlg: true,
     }
-    this.excute(this.data.accountService, this.data.accountService.getReceivableAccountItemCount, params).then(res => {
+    this.excute(this.data.accountService, this.data.accountService.getReceivableAccountItem, params).then(res => {
+      console.log("getReceivableAccountItem", res);
       formData.cancelAmount = true
+      formData.receivableList = res.data.data
       _this.setForm(formData, contentObj, objInfo.receivableResidue,
-        objInfo.receiptResidue, res.data.data)
+        objInfo.receiptResidue, res.data.data.length)
       _this.setData({
         objInfo,
+        receivableList: res.data.data,
         receivableResidue: objInfo.receivableResidue,
         receiptResidue: objInfo.receiptResidue,
-        bill: res.data.data
+        bill: res.data.data.length
       })
 
     })
@@ -158,26 +172,78 @@ Page({
     let formData = JSON.parse(this.data.formData)
     let contentObj = this.data.contentObj
     if (cancelAmount) {
+      formData.receivableList = this.data.receivableList
       this.setForm(formData, contentObj, this.data.receivableResidue, this.data.receiptResidue, this.data.bill)
     } else {
-
+      formData.receivableList = []
       this.setForm(formData, contentObj, 0, 0, 0)
     }
   },
 
   /**
+  * @desc : 设置表单的数据
+  * @date : 2024/2/1 15:49
+  * @author : 姜永辉
+  */
+  changeNumber(e) {
+    let formData = JSON.parse(this.data.formData)
+    let code = e.detail.code
+    let data = e.detail.data
+    console.log(code, data, e);
+    // 本次收款金额
+    if (code == "sumAmtRec") {
+      formData.sumAmtRec = data
+      formData.sumAmount = data
+      let contentList = this.data.contentList
+      contentList.forEach(it => {
+        if (it.type == 'number') {
+          it.content = data
+        }
+      })
+      this.setData({
+        contentList,
+      })
+    }
+    // 本次核销金额
+    if (code == "currentReceivableResidue") {
+      formData.currentReceivableResidue = data
+    }
+    // 优惠金额
+    if (code == "sumWaiveAmt") {
+      formData.sumWaiveAmt = data
+    }
+    this.setData({
+      formData: JSON.stringify(formData)
+    })
+  },
+
+  /**
    * @desc : 设置表单的数据
    * @date : 2024/2/1 15:49
    * @author : 姜永辉
    */
   setForm(formData, contentObj, receivableResidue, receiptResidue, bill) {
+    if (receivableResidue == null) {
+      receivableResidue = 0
+    }
+    if (receiptResidue == null) {
+      receiptResidue = 0
+    }
+    if (bill == null) {
+      bill = 0
+    }
     formData.receivableResidue = receivableResidue  // 总剩余应收
-    formData.currentReceivableResidue = receivableResidue  // 总剩余应收
-    formData.receivableResidue = receivableResidue  // 总剩余应收
-    formData.receiptResidue = receiptResidue  // 预存 
+    formData.currentReceivableResidue = receivableResidue  // 总剩余应收 
+    if (receivableResidue > receiptResidue) {
+      formData.receiptResidue = receiptResidue  // 预存 
+    } else {
+      formData.receiptResidue = receivableResidue  // 预存 (用总剩余应收来负值)
+    }
     if (formData.staffId == null) {
       formData.staffId = app.globalData.user.staffId
       formData.orgId = app.globalData.user.orgId
+      formData.staffName = app.globalData.user.staffName
+      formData.orgName = app.globalData.user.orgName
     }
     contentObj['bill'].forEach(itcard => {
       if (itcard.code === 'cancelAmount') {
@@ -205,6 +271,10 @@ Page({
       > Number(formData.receivableResidue)) {
       msgError = '本次核销不能大于待核销金额'
     }
+    if (Number(formData.currentReceivableResidue) == 0
+      && Number(formData.sumAmtRec) == 0) {
+      msgError = '本次核销金额和本次收款不能同时为0'
+    }
     // 预存+本次收款》= 本次核销
     if (Number(formData.sumAmtRec) + Number(formData.receiptResidue)
       < Number(formData.currentReceivableResidue)) {
@@ -217,22 +287,22 @@ Page({
         icon: 'none'
       })
       return false
-    }   
+    }
 
     return true
   },
 
-
-
   /**
    * @desc : 保存的參數設置
    * @date : 2024/2/1 15:49
    * @author : 姜永辉
    */
   setParams(params) {
-    let btnFormData = this.data.btnFormData ? JSON.parse(this.data.btnFormData) : ''
-    let formData = JSON.parse(this.data.formData)
 
+    let formData = JSON.parse(this.data.formData)
+    if (Number(formData.sumAmtRec) != 0) {
+      return params
+    }
     //收付款类型-收款的查询参数
     params.rpType = Constants.rpType.receipt
     params.orgId = formData.orgId  //组织部门
@@ -246,8 +316,8 @@ Page({
     // 合计优惠金额
     params.sumWaiveAmt = formData.sumWaiveAmt
     // 预存的使用
-    params.receiptResidue = formData.receiptResidue 
-    params.annexPaths = {}
+    params.receiptResidue = formData.receiptResidue
+    params.annexPaths = formData.annexPaths || [] //附件 
     // params.biznisType = null
     // params.biznisId	 = null
     // params.biznisNo	= null	 
@@ -256,10 +326,53 @@ Page({
     params.makeStaff = app.globalData.user.staffId  // 制单人
 
     params.itemList = [] //明细 
+    let rlsit = this.setReturnReceivableList(formData.receivableList || [], formData.sumWaiveAmt, formData.currentReceivableResidue, formData.receivableResidue)
+    params.receivableList = rlsit //应收收款的明细 
+
     return params
   },
 
   /**
+  * @desc : 将优惠和本次核销的金额分摊到应收单据的明细里
+  * @date : 2024/2/1 15:49
+  * @author : 姜永辉
+  */
+  setReturnReceivableList(list, sumWaiveAmt, currentReceivableResidue, totalAmount) {
+    let retList = []
+    if (sumWaiveAmt == null || sumWaiveAmt == undefined) {
+      sumWaiveAmt = 0
+    }
+    if (currentReceivableResidue == null || currentReceivableResidue == null) {
+      currentReceivableResidue = 0
+    }
+    if (currentReceivableResidue == 0 && sumWaiveAmt == 0 || list == null) {
+      return retList
+    }
+    let finalAmout = currentReceivableResidue
+    let finalSumWaiveAmt = sumWaiveAmt
+    for (let index = 0; index < list.length; index++) {
+      const element = list[index];
+      // 应收冲抵金额	== 明细的剩余金额	默认
+      let amtReceivableHandle = (finalAmout < element.amtResidue ? finalAmout : element.amtResidue)
+      let amtWaive = Number(parseFloat(element.amtResidue / totalAmount * sumWaiveAmt).toFixed(2))
+      finalAmout -= amtReceivableHandle
+      finalSumWaiveAmt -= amtWaive
+
+      retList.push({
+        accDate: list.accDate,
+        accItemId: element.accItemId,
+        // 应收冲抵金额	
+        amtReceivableHandle: amtReceivableHandle,
+        // 优惠金额-分摊之后 最后一条的数据取剩余的值
+        amtWaive: (index == list.length - 1 ? finalSumWaiveAmt : amtWaive),
+      })
+    }
+
+    return retList
+
+  },
+
+  /**
   * @desc : 保存数据服务
   * @date : 2024/2/1 15:49
   * @author : 姜永辉
@@ -275,7 +388,6 @@ Page({
 
   },
 
-
   /**
   * @desc : 保存数据服务-跳转收款页面
   * @date : 2024/2/1 15:49

+ 1 - 3
package-accounts-manage/pages/receipt/add/add.wxml

@@ -3,9 +3,7 @@
 
 <loading wx:if="{{loading}}"></loading>
 
-<dk-form-more-items id="{{formName}}" routeObjName="{{routeObjName}}" objCol="customerId" objLabel="客户名称" objType="customer"  cardList="{{cardList}}" contentObj="{{contentObj}}" model:value="{{formData}}" bind:chooseData="chooseData" bind:chooseObjTypeData="chooseObjTypeData" 
-bind:onCheckChange="onCheckChange" 
->
+<dk-form-more-items id="{{formName}}" routeObjName="{{routeObjName}}" objCol="customerId" objLabel="客户名称" objType="customer" cardList="{{cardList}}" contentObj="{{contentObj}}" model:value="{{formData}}" bind:chooseData="chooseData" table="{{table}}" bind:chooseObjTypeData="chooseObjTypeData" bind:onCheckChange="onCheckChange" bind:changeNumber="changeNumber">
 </dk-form-more-items>
 
 <view style="height: 220rpx;"></view>

+ 7 - 1
package-base-select/pages/select-bill/select-bill.js

@@ -306,6 +306,12 @@ Page({
     // 路由
     routeObjName: 'account',
     formMode: Constants.formMode.index,
+     // 弹出按钮
+     buttonList: [{
+      name: 'merge',
+      title: mixins.$t('confirm')
+    }],
+     
   },
 
   /**
@@ -415,7 +421,7 @@ Page({
     const eventChannel = that.getOpenerEventChannel();
     eventChannel.emit('bindData', {
       data: {
-        itemLists: itemLists,
+        receivableList: itemLists,
         objInfo: that.data.objInfo,
         receivableResidue: that.data.totalAmount,
         receiptResidue: that.data.objInfo.receiptResidue, //剩余预存

+ 3 - 2
package-base-select/pages/select-bill/select-bill.wxml

@@ -61,5 +61,6 @@
 <van-empty wx:if="{{tableData.length<=0}}" description="{{$t['nodata']}}" />
 
 <view style="height: 200rpx;"></view>
-<!--  底部工具栏-保存 -->
-<dk-save-bottom checked="{{allChecked}}" totallength="{{returnTotalAmount}}" flagTypeName="select-source-purchase-order" bottomClass="{{true}}" bind:onCheckboxChange="onCheckboxChange" bind:allClean="returnData" />
+ 
+
+<dk-save-button   model:value="{{btnFormData}}" btnAutoWidthFlag="{{true}}" btnRightFlag="{{true}}" buttonList="{{buttonList}}" contentList="{{contentList}}" bind:open="returnData"></dk-save-button>

+ 97 - 10
package-base-select/pages/select-collection_confirm/select-collection_confirm.js

@@ -104,6 +104,86 @@ mixins: [mixins],
     },
 
     /**
+  * @desc : 将优惠和本次核销的金额分摊到应收单据的明细里
+  * @date : 2024/2/1 15:49
+  * @author : 姜永辉
+  */
+    setReturnReceivableList(list, sumWaiveAmt, currentReceivableResidue, totalAmount) {
+      let retList = []
+      if (sumWaiveAmt == null || sumWaiveAmt == undefined) {
+        sumWaiveAmt = 0
+      }
+      if (currentReceivableResidue == null || currentReceivableResidue == null) {
+        currentReceivableResidue = 0
+      }
+      if (currentReceivableResidue == 0 && sumWaiveAmt == 0 || list == null) {
+        return retList
+      }
+      let finalAmout = currentReceivableResidue
+      let finalSumWaiveAmt = sumWaiveAmt
+      for (let index = 0; index < list.length; index++) {
+        const element = list[index];
+        // 应收冲抵金额	== 明细的剩余金额	默认
+        let amtReceivableHandle = (finalAmout < element.amtResidue ? finalAmout : element.amtResidue)
+        let amtWaive = Number(parseFloat(element.amtResidue / totalAmount * sumWaiveAmt).toFixed(2))
+        finalAmout -= amtReceivableHandle
+        finalSumWaiveAmt -= amtWaive
+
+        retList.push({
+          accDate: list.accDate,
+          accItemId: element.accItemId,
+          // 应收冲抵金额	
+          amtReceivableHandle: amtReceivableHandle,
+          // 优惠金额-分摊之后 最后一条的数据取剩余的值
+          amtWaive: (index == list.length - 1 ? finalSumWaiveAmt : amtWaive),
+        })
+      }
+
+      return retList
+
+    },
+
+    /**
+ * @desc : 将优惠和本次核销的金额分摊到应付单据的明细里
+ * @date : 2024/2/1 15:49
+ * @author : 姜永辉
+ */
+    setReturnPayableList(list, sumWaiveAmt, currentPayableResidue, totalAmount) {
+      let retList = []
+      if (sumWaiveAmt == null || sumWaiveAmt == undefined) {
+        sumWaiveAmt = 0
+      }
+      if (currentPayableResidue == null || currentPayableResidue == null) {
+        currentPayableResidue = 0
+      }
+      if (currentPayableResidue == 0 && sumWaiveAmt == 0 || list == null) {
+        return retList
+      }
+      let finalAmout = currentPayableResidue
+      let finalSumWaiveAmt = sumWaiveAmt
+      for (let index = 0; index < list.length; index++) {
+        const element = list[index];
+        // 应付冲抵金额	== 明细的剩余金额	默认
+        let amtReceivableHandle = (finalAmout < element.amtResidue ? finalAmout : element.amtResidue)
+        let amtWaive = Number(parseFloat(element.amtResidue / totalAmount * sumWaiveAmt).toFixed(2))
+        finalAmout -= amtReceivableHandle
+        finalSumWaiveAmt -= amtWaive
+
+        retList.push({
+          accDate: list.accDate,
+          accItemId: element.accItemId,
+          // 应付冲抵金额	
+          amtPayableHandle: amtReceivableHandle,
+          // 优惠金额-分摊之后 最后一条的数据取剩余的值
+          amtWaive: (index == list.length - 1 ? finalSumWaiveAmt : amtWaive),
+        })
+      }
+
+      return retList
+
+    },
+
+    /**
      * @desc : 保存的參數設置
      * @date : 2024/2/1 15:49
      * @author : 姜永辉
@@ -112,12 +192,12 @@ mixins: [mixins],
       let form = this.data.form
       let itemList = []
       //收付款类型-收款的查询参数
-      params.rpType =  params.rpType ?  params.rpType : Constants.rpType.receipt
+      params.rpType = params.rpType ? params.rpType : Constants.rpType.receipt
       params.orgId = form.orgId  //组织部门
       params.staffId = form.staffId  // 员工
       // 合计优惠金额
       params.sumWaiveAmt = 0
-      params.annexPaths = form.annexPaths ? form.annexPaths :[]
+      params.annexPaths = form.annexPaths ? form.annexPaths : []
       params.accDate = form.accDate  // 
       params.remarks = form.remarks  // 备注
       params.makeStaff = app.globalData.user.staffId  // 制单人 
@@ -126,13 +206,17 @@ mixins: [mixins],
       // formType :1 收款单 ,2 付款单,3 客户收款保存参数
       if (this.data.formType == 1) {
         // 1 收款单
-        params.objectId = this.data.objInfo.cusId  // 客户
+        params.objectId = this.data.form.objInfo.cusId  // 客户
         // 收款金额					
         params.sumAmtRec = Number(form.sumAmount)
         // 合计应收冲抵金额								
         params.sumAmtReceivableHandle = form.currentReceivableResidue
         // 预存的使用
-        params.receiptResidue = formData.receiptResidue
+        params.receiptResidue = form.receiptResidue
+        // 合计优惠金额
+        params.sumWaiveAmt = form.sumWaiveAmt
+        let rlsit = this.setReturnReceivableList(form.receivableList || [], form.sumWaiveAmt, form.currentReceivableResidue, form.receivableResidue)
+        params.receivableList = rlsit //应收收款的明细 
         tableData.forEach(item => {
           itemList.push(
             {
@@ -147,13 +231,16 @@ mixins: [mixins],
 
       } else if (this.data.formType == 2) {
         // 2 付款单,
-        params.objectId = this.data.objInfo.supId  // 供应商
+        params.objectId = this.data.form.objInfo.supId  // 供应商
         // 收款金额					
         params.sumAmtPay = Number(form.sumAmount)
         // 合计应付冲抵金额								
-        params.sumAmtPayableHandle = formData.currentPayableResidue
+        params.sumAmtPayableHandle = form.currentPayableResidue
         // 合计优惠金额
-        params.sumWaiveAmt = formData.sumWaiveAmt
+        params.sumWaiveAmt = form.sumWaiveAmt
+        let rlsit = this.setReturnPayableList(form.payableList || [], form.sumWaiveAmt, form.currentPayableResidue, form.payableResidue)
+        params.payableList = rlsit //应付款的明细 
+
         tableData.forEach(item => {
           itemList.push(
             {
@@ -182,8 +269,8 @@ mixins: [mixins],
             }
           )
         })
-        params.accDate = params.accDate ? params.accDate: utils.formatDayTime(new Date())
-      }else if (this.data.formType == 4) {
+        params.accDate = params.accDate ? params.accDate : utils.formatDayTime(new Date())
+      } else if (this.data.formType == 4) {
         //客户退款保存参数
         console.log('params', params)
         params.sumAmtRec = Number(params.sumAmtRec)
@@ -199,7 +286,7 @@ mixins: [mixins],
             }
           )
         })
-        params.accDate = params.accDate ? params.accDate: utils.formatDayTime(new Date())
+        params.accDate = params.accDate ? params.accDate : utils.formatDayTime(new Date())
       }
       params.itemList = itemList
       return params