Просмотр исходного кода

账单缴费增加部分缴费,修改相应逻辑(不包含抹零规则)

xiongxing 3 недель назад
Родитель
Сommit
6396b0c397
2 измененных файлов с 105 добавлено и 47 удалено
  1. 52 36
      src/views/elderly/fee/bill-pay/Form.vue
  2. 53 11
      src/views/elderly/fee/bill-pay/pay.vue

+ 52 - 36
src/views/elderly/fee/bill-pay/Form.vue

@@ -28,7 +28,7 @@
       <div class="header">
         <div class="left">{{ tTitle }}</div>
         <div class="right">
-          {{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(dataForm.totalMonthPrice) }}</span></div>
+          {{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(monthSubtotalAmount) }}</span></div>
       </div>
       <el-table
         ref="monthTableRef"
@@ -64,11 +64,12 @@
         <el-table-column prop="totalAmount" label="应收金额(元)" align="center">
           <template #default="scope">
 
-              <el-input-number  v-if="isEdit" @blur="handlePrice(scope.row, 1)" v-model="scope.row.totalAmount" controls-position="right"/>
-              <span v-else>{{ formatTotalMonth(scope.row) }}</span>
+              <el-input-number  v-if="isEdit && scope.row.payStatus == 0" @blur="handlePrice(scope.row, 1)" v-model="scope.row.totalAmount" controls-position="right"/>
+              <span v-else>{{ (scope.row.payStatus == 1 || scope.row.payStatus == 2) ? (formatTotalMonth(scope.row) - scope.row.payAmount).toFixed(2) : formatTotalMonth(scope.row) }}</span>
 
           </template>
         </el-table-column>
+        <el-table-column prop="payAmount" label="已缴费用" width="100" align="center" />
         <el-table-column prop="isShow" label="是否显示在单据上" align="center">
           <template #default="scope">
             <el-checkbox v-if="isEdit" v-model="scope.row.isShow" :checked="scope.row.isShow == 1" @change="handlePrice(scope.row, 1)"/>
@@ -86,7 +87,7 @@
         <div class="header">
           <div class="left">预备金费用(元)</div>
           <div class="right"
-            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(dataForm.totalDepositPrice) }}</span></div
+            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(depositSubtotalAmount) }}</span></div
           >
         </div>
         <el-table
@@ -122,11 +123,12 @@
           <el-table-column prop="count" label="数量" width="100" align="center" />
           <el-table-column prop="totalAmount" label="应收金额(元)" align="center">
             <template #default="scope">
-              <el-input-number  v-if="isEdit" @blur="handlePrice(scope.row, 2)" v-model="scope.row.totalAmount" controls-position="right"/>
-              <span v-else>{{ tableRowPay(scope.row) }}</span>
+              <el-input-number  v-if="isEdit && scope.row.payStatus == 0" @blur="handlePrice(scope.row, 2)" v-model="scope.row.totalAmount" controls-position="right"/>
+              <span v-else>{{ (scope.row.payStatus == 1 || scope.row.payStatus == 2) ? (tableRowPay(scope.row) - scope.row.payAmount).toFixed(2) : tableRowPay(scope.row) }}</span>
 
           </template>
           </el-table-column>
+          <el-table-column prop="payAmount" label="已缴费用" width="100" align="center" />
           <el-table-column prop="isShow" label="是否显示在单据上" align="center">
           <template #default="scope">
             <el-checkbox v-if="isEdit" v-model="scope.row.isShow" :checked="scope.row.isShow == 1" @change="handlePrice(scope.row, 2)"/>
@@ -143,7 +145,7 @@
         <div class="header">
           <div class="left">阶段性费用(元)</div>
           <div class="right"
-            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(dataForm.totalStageExpandPrice) }}</span></div
+            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(stageSubtotalAmount) }}</span></div
           >
         </div>
         <el-table
@@ -206,10 +208,11 @@
           <el-table-column prop="totalAmount" label="应收金额(元)" align="center">
             <template #default="scope">
               <el-input-number  v-if="isEdit" @blur="handlePrice(scope.row, 3)" v-model="scope.row.totalAmount" controls-position="right"/>
-              <span v-else>{{ tableRowPay(scope.row) }}</span>
+              <span v-else>{{ (scope.row.payStatus == 1 || scope.row.payStatus == 2) ? (tableRowPay(scope.row) - scope.row.payAmount).toFixed(2) : tableRowPay(scope.row) }}</span>
 
             </template>
           </el-table-column>
+          <el-table-column prop="payAmount" label="已缴费用" width="100" align="center" />
           <el-table-column prop="isShow" label="是否显示在单据上" align="center">
             <template #default="scope">
               <el-checkbox v-if="isEdit" v-model="scope.row.isShow" :checked="scope.row.isShow == 1" @change="handlePrice(scope.row, 3)"/>
@@ -221,7 +224,7 @@
         <div class="header">
           <div class="left">其他费用(元)</div>
           <div class="right"
-            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(dataForm.totalOneTimeFeePrice) }}</span></div
+            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(oneTimeSubtotalAmount) }}</span></div
           >
         </div>
         <el-table
@@ -257,11 +260,12 @@
           <el-table-column prop="count" label="数量" width="100" align="center" />
           <el-table-column prop="totalAmount" label="应收金额(元)" align="center">
             <template #default="scope">
-              <el-input-number  v-if="isEdit" @blur="handlePrice(scope.row, 5)" v-model="scope.row.totalAmount" controls-position="right"/>
-              <span v-else>{{ tableRowPay(scope.row) }}</span>
+              <el-input-number  v-if="isEdit && scope.row.payStatus == 0" @blur="handlePrice(scope.row, 5)" v-model="scope.row.totalAmount" controls-position="right"/>
+              <span v-else>{{ (scope.row.payStatus == 1 || scope.row.payStatus == 2) ? (tableRowPay(scope.row) - scope.row.payAmount).toFixed(2) : tableRowPay(scope.row) }}</span>
 
             </template>
           </el-table-column>
+          <el-table-column prop="payAmount" label="已缴费用" width="100" align="center" />
           <el-table-column prop="isShow" label="是否显示在单据上" align="center">
             <template #default="scope">
               <el-checkbox v-if="isEdit" v-model="scope.row.isShow" :checked="scope.row.isShow == 1" @change="handlePrice(scope.row, 5)"/>
@@ -353,10 +357,11 @@
           </el-table-column> -->
           <el-table-column prop="totalAmount" width="180" label="应收金额(元)" align="center">
             <template #default="scope">
-              <el-input-number  v-if="isEdit" @blur="handlePrice(scope.row, 5)" v-model="scope.row.totalAmount" controls-position="right"/>
-              <span v-else>{{ tableRowPay(scope.row) }}</span>
+              <el-input-number  v-if="isEdit && scope.row.payStatus == 0" @blur="handlePrice(scope.row, 5)" v-model="scope.row.totalAmount" controls-position="right"/>
+              <span v-else>{{ (scope.row.payStatus == 1 || scope.row.payStatus == 2) ? (tableRowPay(scope.row) - scope.row.payAmount).toFixed(2) : tableRowPay(scope.row) }}</span>
             </template>
           </el-table-column>
+          <el-table-column prop="payAmount" label="已缴费用" width="100" align="center" />
           <el-table-column prop="isShow" label="是否显示在单据上" align="center">
             <template #default="scope">
               <el-checkbox v-if="isEdit" v-model="scope.row.isShow" :checked="scope.row.isShow == 1" @change="handlePrice(scope.row, 5)"/>
@@ -374,7 +379,7 @@
         <div class="header">
           <div class="left">阶段性费用(元)</div>
           <div class="right"
-            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(dataForm.totalStageExpandPrice) }}</span></div
+            >{{isDetail ? '已缴' : '小计'}}<span class="price">¥{{ formatNum(stageExpandSubtotalAmount) }}</span></div
           >
         </div>
         <el-table
@@ -436,11 +441,12 @@
           <el-table-column prop="count" label="数量" width="100" align="center" />
           <el-table-column prop="totalAmount" label="应收金额(元)" align="center">
             <template #default="scope">
-              <el-input-number  v-if="isEdit" @blur="handlePrice(scope.row, 3)" v-model="scope.row.totalAmount" controls-position="right"/>
-              <span v-else>{{ tableRowPay(scope.row) }}</span>
+              <el-input-number  v-if="isEdit && scope.row.payStatus == 0" @blur="handlePrice(scope.row, 3)" v-model="scope.row.totalAmount" controls-position="right"/>
+              <span v-else>{{ (scope.row.payStatus == 1 || scope.row.payStatus == 2) ? (tableRowPay(scope.row) - scope.row.payAmount).toFixed(2) : tableRowPay(scope.row) }}</span>
               <!-- <span class="underline" v-if="!settingStore.getRceivable||settingStore.getAdmissionBillRoundUp">{{ formatNum(scope.row.totalAmount) }}</span> -->
             </template>
           </el-table-column>
+          <el-table-column prop="payAmount" label="已缴费用" width="100" align="center" />
           <el-table-column prop="isShow" label="是否显示在单据上" align="center">
             <template #default="scope">
               <el-checkbox v-if="isEdit" v-model="scope.row.isShow" :checked="scope.row.isShow == 1" @change="handlePrice(scope.row, 3)"/>
@@ -594,6 +600,12 @@ const totalAllAmount = computed(()=>{
   return formatNum(dataForm.value.totalMonthPrice + dataForm.value.totalOneTimeFeePrice + dataForm.value.totalDepositPrice + dataForm.value.totalStageExpandPrice)
 })
 
+const monthSubtotalAmount = computed(() => monthSelected.value.length ? formatNum(dataForm.value.totalMonthPrice) : 0)
+const depositSubtotalAmount = computed(() => depositSelected.value.length ? formatNum(dataForm.value.totalDepositPrice) : 0)
+const oneTimeSubtotalAmount = computed(() => oneTimeSelected.value.length ? formatNum(dataForm.value.totalOneTimeFeePrice) : 0)
+const stageSubtotalAmount = computed(() => stageExpandSelected.value.length ? formatNum(dataForm.value.totalStageExpandPrice) : 0)
+const stageExpandSubtotalAmount = stageSubtotalAmount
+
 // 固定费用
 const formatTotalMonth = (item)=>{
   if(dataForm.value.type == 1){
@@ -644,6 +656,10 @@ const totalRoundAndTwoDecimalAmount = computed(()=>{
 
 // 账单总额 1.入院且入院配置了向上取整 2.账单四舍五入 3.账单实际金额 (需要减去长护险)
 const tAmount = computed(()=>{
+  let payAmountTotal = 0
+  dataForm.value.monthArr.map(item => {
+    payAmountTotal += item.payAmount ? Number(item.payAmount) : 0
+  })
   if(dataForm.value.type == 1){ //1入院,2月度
     return totalAllAmount.value
     // if(settingStore.getAdmissionBill == 2){ // 向上取整
@@ -655,11 +671,11 @@ const tAmount = computed(()=>{
   }else{
     console.log("取值",rounding.value,fixed2Num.value)
     if(rounding.value){
-      return formatRound(totalRoundAndTwoDecimalAmount.value.num)
+      return formatRound(totalRoundAndTwoDecimalAmount.value.num - payAmountTotal)
     }else if(fixed2Num.value){
-      return formatNum(totalRoundAndTwoDecimalAmount.value.decimal)
+      return formatNum(totalRoundAndTwoDecimalAmount.value.decimal - payAmountTotal)
     }else{
-      return formatNum(dataForm.value.actualAmount)
+      return formatNum(dataForm.value.actualAmount - payAmountTotal)
     }
   }
 })
@@ -797,7 +813,7 @@ const goToBill = () => {
 
 // 判断表格中那些数据可选
 const handleSelectable = (row) => {
-  return row.payStatus == 0
+  return row.payStatus == 0 || row.payStatus == 2
 }
 
 // 选中数据
@@ -809,21 +825,21 @@ const handleMonthSelectionChange = (val) => {
     if(item.isShow){
       if(dataForm.value.type == '1'){
         if(settingStore.getAdmissionBill == 2){ // 向上取整
-          total += formatDecimal(Number(formatCeil(item.totalAmount))) as number
+          total += formatDecimal(Number(formatCeil(item.totalAmount - (item.payAmount || 0)))) as number
         }else if(settingStore.getAdmissionBill == 3){ // 四舍五入保留两位
-          total += formatDecimal(formatNum(item.roundTwoDecimalAmount)) as number
+          total += formatDecimal(formatNum(item.roundTwoDecimalAmount - (item.payAmount || 0))) as number
         }else if(settingStore.getAdmissionBill == 4){ // 四舍五入取整
-          total += formatDecimal(formatNum(item.roundAmount)) as number
+          total += formatDecimal(formatNum(item.roundAmount - (item.payAmount || 0))) as number
         }else{ // 应收
-          total += formatDecimal(formatNum(item.totalAmount)) as number
+          total += formatDecimal(formatNum(item.totalAmount - (item.payAmount || 0))) as number
         }
       }else{
         if(rounding.value){ // 账单取整
-          total += formatDecimal(formatNum(item.roundAmount)) as number
+          total += formatDecimal(formatNum(item.roundAmount - (item.payAmount || 0))) as number
         } else if(fixed2Num.value){ // 四舍五入保留两位
-          total += formatDecimal(formatNum(item.roundTwoDecimalAmount)) as number
+          total += formatDecimal(formatNum(item.roundTwoDecimalAmount - (item.payAmount || 0))) as number
         } else{ // 实际应收
-          total += formatDecimal(formatNum(item.totalAmount)) as number
+          total += formatDecimal(formatNum(item.totalAmount - (item.payAmount || 0))) as number
         }
       }
     }
@@ -840,11 +856,11 @@ const handleDepositSelectionChange = (val) => {
   val.map((item) => {
     if(item.isShow){
       if(rounding.value){ // 账单取整
-        total += formatDecimal(formatNum(item.roundAmount)) as number
+        total += formatDecimal(formatNum(item.roundAmount - (item.payAmount || 0))) as number
       } else if(fixed2Num.value){ // 四舍五入保留两位
-        total += formatDecimal(formatNum(item.roundTwoDecimalAmount)) as number
+        total += formatDecimal(formatNum(item.roundTwoDecimalAmount - (item.payAmount || 0))) as number
       } else{ // 实际应收
-        total += formatDecimal(formatNum(item.totalAmount)) as number
+        total += formatDecimal(formatNum(item.totalAmount - (item.payAmount || 0))) as number
       }
     }
   })
@@ -860,11 +876,11 @@ const handleOneTimeSelectionChange = (val) => {
   val.map((item) => {
     if(item.isShow){
       if(rounding.value){ // 账单取整
-        total += formatDecimal(formatNum(item.roundAmount)) as number
+        total += formatDecimal(formatNum(item.roundAmount - (item.payAmount || 0))) as number
       } else if(fixed2Num.value){ // 四舍五入保留两位
-        total += formatDecimal(formatNum(item.roundTwoDecimalAmount)) as number
+        total += formatDecimal(formatNum(item.roundTwoDecimalAmount - (item.payAmount || 0))) as number
       } else{ // 实际应收
-        total += formatDecimal(formatNum(item.totalAmount)) as number
+        total += formatDecimal(formatNum(item.totalAmount - (item.payAmount || 0))) as number
       }
     }
   })
@@ -880,11 +896,11 @@ const handleStageExpandSelectionChange = (val) => {
     val.map((item) => {
       if(item.isShow){
         if(rounding.value){ // 账单取整
-          total += formatDecimal(formatNum(item.roundAmount)) as number
+          total += formatDecimal(formatNum(item.roundAmount - (item.payAmount || 0))) as number
         } else if(fixed2Num.value){ // 四舍五入保留两位
-          total += formatDecimal(formatNum(item.roundTwoDecimalAmount)) as number
+          total += formatDecimal(formatNum(item.roundTwoDecimalAmount - (item.payAmount || 0))) as number
         } else{ // 实际应收
-          total += formatDecimal(formatNum(item.totalAmount)) as number
+          total += formatDecimal(formatNum(item.totalAmount - (item.payAmount || 0))) as number
         }
       }
     })

+ 53 - 11
src/views/elderly/fee/bill-pay/pay.vue

@@ -60,13 +60,15 @@
             </el-select>
           </template>
         </el-table-column>
+
         <el-table-column prop="payAmount" label="收款金额">
           <template #default="scope">
             <TgInput
               placeholder="请输入收款金额"
               v-model="scope.row.payAmount"
               @blur="handleItemBlur(scope.row)"
-              :readonly="scope.$index == 0"
+              @change="handleItemChange(scope.row)"
+              :readonly="scope.$index == 0 && billForm.expenseOrderItems?.length > 1"
             />
           </template>
         </el-table-column>
@@ -217,14 +219,16 @@ const submitForm = async () => {
       message.error('请添加支付方式')
       return
     }
-    let total = 0
-    // 判断钱是否一致
-    billForm.value.items.map((item) => {
-      total += item.payAmount ? Number(item.payAmount) : 0
-    })
-    if (formatNum(total) != formatNum(billForm.value.payAmount)) {
-      message.error('收款金额与本次应缴不一致')
-      return
+    if (billForm.value.items.length > 1) {
+      let total = 0
+      // 判断钱是否一致
+      billForm.value.items.map((item) => {
+        total += item.payAmount ? Number(item.payAmount) : 0
+      })
+      if (formatNum(total) != formatNum(billForm.value.payAmount)) {
+        message.error('收款金额与本次应缴不一致')
+        return
+      }
     }
     // 判断如果为0不能缴费
     // if(total == 0){
@@ -243,7 +247,7 @@ const submitForm = async () => {
     })
 
     params.depositList = toRaw(depositList.value)
-    //console.log('缴费参数:',params)
+    console.log('缴费参数:',params)
     const res = await payExpenseOrder(params)
     if (res) {
       message.success(t('common.updateSuccess'))
@@ -267,12 +271,50 @@ const handleChange = () => {
   )
 }
 
+const handleItemChange = (row) => {
+  if (typeof row.payType == 'string' && (row.payType.indexOf("account_member_card") > -1 || row.payType == 'balance' || row.payType.indexOf("long_term_care_insurance") > -1) ) {
+    const item = options.value.find(item=>row.payType == item.value)
+    if (item) {
+      row.payAmount = row.payAmount > item.price ? item.price : row.payAmount
+    }
+  }
+
+  let allMoney = 0
+  if (billForm.value.expenseOrderItems?.length == 1) {
+    billForm.value.items.map((item, index) => {
+      allMoney += item.payAmount ? Number(item.payAmount) : 0
+    })
+    if(Number(formatNum(allMoney)) > Number(formatNum(actualAmount.value))){
+      message.error('收款金额不能大于账单总额')
+      row.payAmount = 0
+    }
+    billForm.value.payAmount = formatNum(allMoney)
+    return
+  }
+}
+
 // 比较最大值
 const handleItemBlur = (row) => {
   if (typeof row.payType == 'string' && (row.payType.indexOf("account_member_card") > -1 || row.payType == 'balance' || row.payType.indexOf("long_term_care_insurance") > -1) ) {
     const item = options.value.find(item=>row.payType == item.value)
-    row.payAmount = row.payAmount > item.price ? item.price : row.payAmount
+    if (item) {
+      row.payAmount = row.payAmount > item.price ? item.price : row.payAmount
+    }
   }
+
+  let allMoney = 0
+  if (billForm.value.expenseOrderItems?.length == 1) {
+    billForm.value.items.map((item, index) => {
+      allMoney += item.payAmount ? Number(item.payAmount) : 0
+    })
+    if(Number(formatNum(allMoney)) > Number(formatNum(actualAmount.value))){
+      message.error('收款金额不能大于账单总额')
+      row.payAmount = 0
+    }
+    billForm.value.payAmount = formatNum(allMoney)
+    return
+  }
+
   // 修改完后其余相加,扣减第一条的费用
   let firstTotal = 0
   // 判断钱是否一致