xiongxing пре 1 недеља
родитељ
комит
34483e08cf
1 измењених фајлова са 145 додато и 101 уклоњено
  1. 145 101
      src/views/elderly/fee/bill-pay/preview.vue

+ 145 - 101
src/views/elderly/fee/bill-pay/preview.vue

@@ -1,40 +1,56 @@
 <template>
-  <Dialog v-model="dialogVisible" title="对账单预览" class="billPayPreview" width="60%" scroll @closed="handleClosed">
+  <Dialog
+    v-model="dialogVisible"
+    title="对账单预览"
+    class="billPayPreview"
+    width="60%"
+    scroll
+    @closed="handleClosed"
+  >
     <el-tabs v-model="activeName" class="demo-tabs" @tab-change="handleClick">
       <el-tab-pane label="打印类型A(含固定费明细)" name="first">
         <div class="first" id="printTab1">
           <div class="header">
             <p class="title" style="font-size: 18px">{{ tenantName }}对账单预览</p>
             <div class="info-wrap" style="margin-top: -4px">
-              <span><b>姓名:</b> {{
-                  dataForm.elderName
-                }}{{ (dataForm.contractNumber == null || dataForm.contractNumber == '')?'':`(${dataForm.contractNumber})`}}</span>
+              <span
+                ><b>姓名:</b> {{ dataForm.elderName
+                }}{{
+                  dataForm.contractNumber == null || dataForm.contractNumber == ''
+                    ? ''
+                    : `(${dataForm.contractNumber})`
+                }}</span
+              >
               <span><b>床位号:</b> {{ dataForm.bedName }}</span>
               <span><b>缴费时间:</b> {{ formatTime(dataForm.payTime, 'yyyy-MM-dd') }}</span>
-<!--              <span><b>应收金额:</b> {{ totalPayAmount }}元</span>-->
+              <!--              <span><b>应收金额:</b> {{ totalPayAmount }}元</span>-->
               <span><b>经手人:</b> {{ dataForm.payeeName }}</span>
-<!--              <span><b>账单月:</b> {{ dataForm.billingMonth }}</span>-->
-<!--              <span><b>打印时间:</b> {{ dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') }}</span>-->
+              <!--              <span><b>账单月:</b> {{ dataForm.billingMonth }}</span>-->
+              <!--              <span><b>打印时间:</b> {{ dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') }}</span>-->
             </div>
-<!--            <div class="info-wrap" style="margin-top: -10px">-->
-              <!-- <span><b>发票号:</b> {{ dataForm.invoiceNumber }}</span> -->
-<!--              <span><b>应收金额:</b> {{ totalPayAmount }}元</span>-->
-              <!-- <span><b>医保费用:</b> {{ formatNum(dataForm.insuranceAmount) || '0' }}元</span>
+            <!--            <div class="info-wrap" style="margin-top: -10px">-->
+            <!-- <span><b>发票号:</b> {{ dataForm.invoiceNumber }}</span> -->
+            <!--              <span><b>应收金额:</b> {{ totalPayAmount }}元</span>-->
+            <!-- <span><b>医保费用:</b> {{ formatNum(dataForm.insuranceAmount) || '0' }}元</span>
               <span><b>个人应缴:</b> {{ formatNum(dataForm.payAmount) }}元</span> -->
-<!--              <span><b>长护险余额:</b> {{ formatNum(longTermAmount) || '0' }}元</span>-->
-<!--              <span><b>抹零金额:</b> {{ roundDown }}元</span>-->
-<!--              <span><b>个人应缴:</b> {{ payTotal }}元</span>-->
-<!--            </div>-->
-<!--            <div class="info-wrap" style="margin-top: -10px">-->
-<!--              <span><b>缴费时间:</b> {{ formatTime(dataForm.payTime, 'yyyy-MM-dd') }}</span>-->
+            <!--              <span><b>长护险余额:</b> {{ formatNum(longTermAmount) || '0' }}元</span>-->
+            <!--              <span><b>抹零金额:</b> {{ roundDown }}元</span>-->
+            <!--              <span><b>个人应缴:</b> {{ payTotal }}元</span>-->
+            <!--            </div>-->
+            <!--            <div class="info-wrap" style="margin-top: -10px">-->
+            <!--              <span><b>缴费时间:</b> {{ formatTime(dataForm.payTime, 'yyyy-MM-dd') }}</span>-->
 
-<!--            </div>-->
+            <!--            </div>-->
           </div>
-          <el-divider style="margin-top: 0px"/>
+          <el-divider style="margin-top: 0px" />
           <div class="content">
-<!--            <p class="info">以下是账单明细</p>-->
+            <!--            <p class="info">以下是账单明细</p>-->
             <div class="flex">
-              <b>{{ dataForm.description ? tTitle + '(' + dataForm.description + ')' : tTitle + '(' + bTitle + ')' }}</b>
+              <b>{{
+                dataForm.description
+                  ? tTitle + '(' + dataForm.description + ')'
+                  : tTitle + '(' + bTitle + ')'
+              }}</b>
               <span><b>金额小计:</b>¥ {{ tableSubtotal }}</span>
             </div>
             <table style="width: 100%" border="2">
@@ -147,7 +163,14 @@
 import { getExpenseOrderDetail } from '@/api/elderly/fee/bill-pay'
 import dayjs from 'dayjs'
 import { useUserStore } from '@/store/modules/user'
-import { fixedNum, formatCeil, formatDecimal, formatNum, formatRid, formatRound } from '@/utils/formatter'
+import {
+  fixedNum,
+  formatCeil,
+  formatDecimal,
+  formatNum,
+  formatRid,
+  formatRound
+} from '@/utils/formatter'
 import { useSettingStore } from '@/store/modules/setting'
 import { formatTime } from '@/utils'
 import { getDictLabel, DICT_TYPE } from '@/utils/dict'
@@ -162,7 +185,7 @@ const dataForm = ref({
   billingMonth: '',
   contractNumber: '',
   items: [],
-  payInfos:[],
+  payInfos: [],
   otherName: '',
   otherNum: '',
   monthNum: '',
@@ -185,19 +208,19 @@ const open = async (id, row) => {
   const res = await getExpenseOrderDetail(id)
   let flag = false
   dataForm.value = res
-  res.items = res.items.filter(item=> item.isShow == 1)
+  res.items = res.items.filter((item) => item.isShow == 1)
   res.items.map((item) => {
-    if(item.expenseSource == 'long_term_care_insurance'){
+    if (item.expenseSource == 'long_term_care_insurance') {
       longTermAmount.value += item.actualPrice
       item.payStatus = 0
       flag = true
       // 遍历长护险
-      res.expenseSubsidyDO.map(d => {
-        if(Math.abs(d.id||1) ==  Math.abs(item.sourceExpenseItemId||0)){
+      res.expenseSubsidyDO.map((d) => {
+        if (Math.abs(d.id || 1) == Math.abs(item.sourceExpenseItemId || 0)) {
           item.createdTime = d.month
           item.description = d.remarks
-          if(!item.itemCategoryName){
-            item.itemCategoryName="长护险"
+          if (!item.itemCategoryName) {
+            item.itemCategoryName = '长护险'
           }
         }
       })
@@ -219,13 +242,14 @@ const open = async (id, row) => {
   let num = 0
   let insurance = 0
   res.payInfos.map((item) => {
-    item.items.map(info => {
-      payText.value += getDictLabel(DICT_TYPE.BILL_PAY_TYPE, info.payType) + ':' + info.payAmount + '元;'
+    item.items.map((info) => {
+      payText.value +=
+        getDictLabel(DICT_TYPE.BILL_PAY_TYPE, info.payType) + ':' + info.payAmount + '元;'
     })
     num += formatDecimal(item.payAmount) as number
     insurance += item.insuranceAmount ? (formatDecimal(item.insuranceAmount) as number) : 0
     // 看看是否有抹零金额
-    if(item.discountAmount){
+    if (item.discountAmount) {
       roundDown.value += item.discountAmount
     }
   })
@@ -233,17 +257,17 @@ const open = async (id, row) => {
   dataForm.value.insuranceAmount = formatRid(insurance) as number
 
   // 有长护险
-  if(!flag){
+  if (!flag) {
     if (res.expenseSubsidyDO && res.expenseSubsidyDO.length) {
       let num = 0
-      res.expenseSubsidyDO.map(item=>{
+      res.expenseSubsidyDO.map((item) => {
         num += item.amount
 
         dataForm.value.items.push({
-          expenseSource:'long_term_care_insurance',
+          expenseSource: 'long_term_care_insurance',
           itemCategoryName: '长护险',
           itemName: '长护险抵扣',
-          description: item.remarks ? item.remarks :  item.month + '长护险抵扣',
+          description: item.remarks ? item.remarks : item.month + '长护险抵扣',
           roundAmount: -item.amount,
           roundTwoDecimalAmount: -item.amount,
           totalAmount: -item.amount,
@@ -274,26 +298,26 @@ const handleClick = (val) => {
       if (item.isMonthlyExpense == 1) {
         if (rounding.value) {
           // 取整
-          monthNum += Number(item.roundAmount)
+          monthNum += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundAmount)
         } else if (fixed2Num.value) {
           // 四舍五入
-          monthNum += Number(item.roundTwoDecimalAmount)
+          monthNum += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundTwoDecimalAmount)
         } else {
           // 应收
-          monthNum += Number(formatNum(item.totalAmount))
+          monthNum += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : formatNum(item.totalAmount))
         }
       } else {
         if (item.itemName != '长护险护理补贴费用') {
           otherName += item.itemName + ';'
           if (rounding.value) {
             // 取整
-            otherNum += Number(item.roundAmount)
+            otherNum += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundAmount)
           } else if (fixed2Num.value) {
             // 四舍五入
-            otherNum += Number(item.roundTwoDecimalAmount)
+            otherNum += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundTwoDecimalAmount)
           } else {
             // 应收
-            otherNum += Number(formatNum(item.totalAmount))
+            otherNum += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : formatNum(item.totalAmount))
           }
         }
       }
@@ -329,32 +353,35 @@ const totalPayAmount = computed(() => {
   // 遍历里面的所有数据得到数据
   dataForm.value.items.map((item) => {
     if (item.itemName != '长护险护理补贴费用') {
-      num1 += item.roundAmount
-      num2 += item.roundTwoDecimalAmount
-      if(item.isMonthlyExpense == 1 && dataForm.value.type == 1){
-        if(settingStore.getAdmissionBill == 2){ // 向上取整
-          num3 += Number(formatCeil(item.totalAmount))
-        }else if(settingStore.getAdmissionBill == 3){// 四舍五入保留两位
-          num3 += Number(item.roundTwoDecimalAmount)
-        }else if(settingStore.getAdmissionBill == 4){ // 四舍五入取整
-          num3 += Number(item.roundAmount)
-        }else{
-          num3 += Number(formatNum(item.totalAmount))
+      num1 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundAmount)
+      num2 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundTwoDecimalAmount)
+      if (item.isMonthlyExpense == 1 && dataForm.value.type == 1) {
+        if (settingStore.getAdmissionBill == 2) {
+          // 向上取整
+          num3 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : formatCeil(item.totalAmount))
+        } else if (settingStore.getAdmissionBill == 3) {
+          // 四舍五入保留两位
+          num3 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundTwoDecimalAmount)
+        } else if (settingStore.getAdmissionBill == 4) {
+          // 四舍五入取整
+          num3 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundAmount)
+        } else {
+          num3 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.totalAmount)
         }
-      }else{
+      } else {
         if (rounding.value) {
-          num3 += Number(item.roundAmount)
+          num3 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundAmount)
         } else if (fixed2Num.value) {
-          num3 += Number(item.roundTwoDecimalAmount)
+          num3 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundTwoDecimalAmount)
         } else {
-          num3 += Number(formatNum(item.totalAmount))
+          num3 += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.totalAmount)
         }
       }
     }
   })
-  if(dataForm.value.type == 1){
+  if (dataForm.value.type == 1) {
     return formatNum(num3)
-  }else{
+  } else {
     if (rounding.value) {
       // 取整(有问题)
       return formatNum(num1)
@@ -370,7 +397,7 @@ const totalPayAmount = computed(() => {
 // 个人应缴
 const payTotal = computed(() => {
   let num = 0
-  dataForm.value.payInfos.map(item=>{
+  dataForm.value.payInfos.map((item) => {
     num += item.payAmount
   })
   return formatNum(num)
@@ -384,48 +411,61 @@ const tableRowPrice = (row) => {
 
 // 表格1总额单项小计
 const tableRowPay = (row) => {
-  if(dataForm.value.type == '1' && row.isMonthlyExpense == 1){
-    if(settingStore.getAdmissionBill == 2){ // 向上取整
-      return formatNum(formatCeil(row.totalAmount))
-    }else if(settingStore.getAdmissionBill == 3){ // 四舍五入保留两位
-      return formatNum(row.roundTwoDecimalAmount)
-    }else if(settingStore.getAdmissionBill == 4){ // 四舍五入取整
-      return formatNum(row.roundAmount)
-    }else{
-      return formatNum(row.totalAmount)
+  if (dataForm.value.type == '1' && row.isMonthlyExpense == 1) {
+    if (settingStore.getAdmissionBill == 2) {
+      // 向上取整
+      return formatNum(row.expenseSource == 'consumer_voucher' ? row.payAmount : formatCeil(row.totalAmount))
+    } else if (settingStore.getAdmissionBill == 3) {
+      // 四舍五入保留两位
+      return formatNum(row.expenseSource == 'consumer_voucher' ? row.payAmount : row.roundTwoDecimalAmount)
+    } else if (settingStore.getAdmissionBill == 4) {
+      // 四舍五入取整
+      return formatNum(row.expenseSource == 'consumer_voucher' ? row.payAmount : row.roundAmount)
+    } else {
+      return formatNum(row.expenseSource == 'consumer_voucher' ? row.payAmount : row.totalAmount)
     }
-  }else{
+  } else {
     if (rounding.value) {
-      return formatNum(row.roundAmount)
+      return row.expenseSource == 'consumer_voucher'
+        ? formatNum(row.payAmount)
+        : formatNum(row.roundAmount)
     } else if (fixed2Num.value) {
-      return formatNum(row.roundTwoDecimalAmount)
+      return row.expenseSource == 'consumer_voucher'
+        ? formatNum(row.payAmount)
+        : formatNum(row.roundTwoDecimalAmount)
     } else {
-      return formatNum(row.totalAmount)
+      return row.expenseSource == 'consumer_voucher'
+        ? formatNum(row.payAmount)
+        : formatNum(row.totalAmount)
     }
   }
 }
 
 // 表格1总额小计
-const tableSubtotal = computed(()=>{
+const tableSubtotal = computed(() => {
   let num = 0
-  dataForm.value.items.map((item)=>{
-    if(dataForm.value.type == '1' && item.isMonthlyExpense == 1){
-      if(settingStore.getAdmissionBill == 2){ // 向上取整
-        num += Number(formatCeil(item.totalAmount))
-      }else if(settingStore.getAdmissionBill == 3){ // 四舍五入保留两位
-        num += Number(item.roundTwoDecimalAmount)
-      }else if(settingStore.getAdmissionBill == 4){ // 四舍五入取整
-        num += Number(item.roundAmount)
-      }else{ // 应收
-        num += Number(formatNum(item.totalAmount))
+  dataForm.value.items.map((item) => {
+    if (dataForm.value.type == '1' && item.isMonthlyExpense == 1) {
+      if (settingStore.getAdmissionBill == 2) {
+        // 向上取整
+        num += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : formatCeil(item.totalAmount))
+      } else if (settingStore.getAdmissionBill == 3) {
+        // 四舍五入保留两位
+        num += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundTwoDecimalAmount)
+      } else if (settingStore.getAdmissionBill == 4) {
+        // 四舍五入取整
+        num += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundAmount)
+      } else {
+        // 应收
+        num += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.totalAmount)
       }
-    }else{
+    } else {
       if (rounding.value) {
-        num += item.roundAmount
+        num += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundAmount)
       } else if (fixed2Num.value) {
-        num += item.roundTwoDecimalAmount
+        num += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.roundTwoDecimalAmount)
       } else {
-        num += item.totalAmount
+        num += Number(item.expenseSource == 'consumer_voucher' ? item.payAmount : item.totalAmount)
       }
     }
   })
@@ -463,41 +503,45 @@ const bTitle = computed(() => {
 //   return item.expenseSource == 'long_term_care_insurance' || item.itemName == '长护险护理补贴费用' ? item.createdTime : (item.expenseSource == 'expense_item' ? (dataForm.value.description ? dataForm.value.description : bTitle) : (item.startDate + '至' + item.endDate))
 // }
 const formatStartDate = (item) => {
-  if(item.itemName == '长护险护理补贴费用' || item.expenseSource == 'long_term_care_insurance'){ // 长护险
-     return item.createdTime
+  if (item.itemName == '长护险护理补贴费用' || item.expenseSource == 'long_term_care_insurance') {
+    // 长护险
+    return item.createdTime
     // let dataStr = item.startDate??"--"
     // if(dataStr.length>=10){
     //   dataStr = dataStr.substring(0,7)
     // }
     // return dataStr
-  }else if(item.expenseSource == 'expense_item'){
+  } else if (item.expenseSource == 'expense_item') {
     // if(dataForm.value.description){
     //   return dataForm.value.description
     // }else{
     //   return bTitle
     // }
-    if(item.description && item.description.includes('的')){
+    if (item.description && item.description.includes('的')) {
       return item.description.split('的')[0]
-    }else if(item.startDate!=null && item.endDate!=null){
-
+    } else if (item.startDate != null && item.endDate != null) {
       return `${item.startDate}至${item.endDate}`
-    }else if(item.startDate==null && dataForm.value.description && dataForm.value.description.length>21){
-      return dataForm.value.description.toString().substring(0,21)
-    }else {
+    } else if (
+      item.startDate == null &&
+      dataForm.value.description &&
+      dataForm.value.description.length > 21
+    ) {
+      return dataForm.value.description.toString().substring(0, 21)
+    } else {
       return bTitle
     }
-  }else {
+  } else {
     return item.startDate + '至' + item.endDate
   }
 }
 
 const formatStr = (dateStr) => {
-  if(dateStr){
+  if (dateStr) {
     // 2. 按 "-" 拆分字符串,得到 [年, 月, 日] 数组
-    const [year, month, day] = dateStr.split("-");
+    const [year, month, day] = dateStr.split('-')
 
     // 3. 按目标格式拼接
-    return `${year}年${month}月${day}日`;
+    return `${year}年${month}月${day}日`
   }
   return ''
 }