Kaynağa Gözat

电子发票完成

lighter 5 ay önce
ebeveyn
işleme
4732fdd101

+ 59 - 0
src/utils/dzfp.js

@@ -0,0 +1,59 @@
+import { queryDzfp} from '@/api/pay-mz-fee';
+import {showConfirmDialog, showToast} from "vant";
+
+export function getDzfpDownloadUrl(hisOrdNum) {
+  queryDzfp(hisOrdNum).then(addr => {
+    showDzfpDialog(addr)
+  })
+}
+
+function showDzfpDialog(addr) {
+  showConfirmDialog({
+    title: '温馨提示',
+    confirmButtonText: '复制',
+    cancelButtonText: '取消',
+    allowHtml: true,
+    message: `<div>以下是您的电子发票下载地址,请复制后使用手机默认浏览器打开。
+                <span style="color: dodgerblue">${addr}</span>
+              </div><span style="color: red">下载地址将在30分钟后过期</span>
+            `,
+    beforeClose: (action) => {
+      return new Promise((resolve) => {
+        if (action === 'confirm') {
+          fallbackCopyText(addr).then(() => {
+            resolve(true)
+          })
+        } else {
+          resolve(true);
+        }
+      })
+    },
+  }).then(r => {})
+}
+
+function fallbackCopyText(text) {
+  return new Promise((resolve, reject) => {
+    const textarea = document.createElement('textarea');
+    textarea.value = text;
+    textarea.style.position = 'fixed';
+    textarea.style.left = '-9999px';
+    textarea.style.top = '0';
+    textarea.setAttribute('readonly', 'readonly');
+    document.body.appendChild(textarea);
+    textarea.select();
+
+    try {
+      const successful = document.execCommand('copy');
+      document.body.removeChild(textarea);
+      if (successful) {
+        showToast('复制成功')
+        resolve();
+      } else {
+        reject(new Error('复制失败'));
+      }
+    } catch (err) {
+      document.body.removeChild(textarea);
+      reject(err);
+    }
+  });
+}

+ 14 - 1
src/views/mine/appointment-record/AppointmentRecords.vue

@@ -21,6 +21,14 @@
               <div>就诊日期:{{ item.requestDay.split(' ')[0] }}</div>
             </div>
           </template>
+          <template #label v-if="item.dzfpShow">
+            <span
+                style="color: deepskyblue; text-decoration: underline"
+                @click="onClickDzfp(item)"
+            >
+              电子发票
+            </span>
+          </template>
         </van-cell>
       </div>
     </div>
@@ -32,8 +40,8 @@ import { computed, ref } from 'vue'
 import { useRouter } from 'vue-router'
 import empty from '@/assets/empty.png'
 import { getPaidMzGhList } from '@/api/appointment'
-import { queryDzfp} from '@/api/pay-mz-fee';
 import MyDateRange from '@/components/date-range'
+import {getDzfpDownloadUrl} from "@/utils/dzfp";
 
 const router = useRouter()
 const patientId = router.currentRoute.value.params.patientId
@@ -48,4 +56,9 @@ function confirmRange(range) {
   })
 }
 
+function onClickDzfp(row) {
+  let hisOrdNum = row.patientId + '_' + row.times + '_0'
+  getDzfpDownloadUrl(hisOrdNum)
+}
+
 </script>

+ 25 - 2
src/views/mine/mz-pay-record/MzFeePaymentRecords.vue

@@ -3,13 +3,30 @@
   <div v-for="item in records" :key="item.hisOrdNum">
     <van-cell
         :title="item.visitDeptName + ' | ' + item.doctorName"
-        :label="item.chargeDate"
         is-link
         center
         @click="toDetail(item)"
     >
       <template #default>
-        <div style="color: orangered">¥ {{ item.amount }}</div>
+        <div v-if="item.dzfpShow" style="display: flex">
+          <div
+              style="color: #4498ed; text-decoration: underline;
+              width: 60%;height: 100%;text-align: center;
+              background: rgba(0,0,0,.1);border-radius: 2px"
+              @click.stop="onClickDzfp(item)"
+          >
+            电子发票
+          </div>
+          <div style="color: orangered; width: 40%; text-align: right">
+            ¥ {{ item.amount }}
+          </div>
+        </div>
+        <div v-else style="color: orangered;">
+          ¥ {{ item.amount }}
+        </div>
+      </template>
+      <template #label>
+        {{ item.chargeDate }}
       </template>
     </van-cell>
   </div>
@@ -20,6 +37,7 @@ import {computed, ref} from 'vue'
 import {useRouter} from 'vue-router'
 import empty from '@/assets/empty.png'
 import {getMzPaidList} from '@/api/pay-mz-fee'
+import {getDzfpDownloadUrl} from "@/utils/dzfp";
 
 const router = useRouter()
 const records = ref([])
@@ -45,6 +63,11 @@ function confirmDateRange(patientId, range) {
   })
 }
 
+function onClickDzfp(item) {
+  item.hisOrdNum = '290509-4_726_1'
+  getDzfpDownloadUrl(item.hisOrdNum)
+}
+
 defineExpose({confirmDateRange})
 
 </script>