瀏覽代碼

电子发票

lihong 4 月之前
父節點
當前提交
055f81f3e5
共有 2 個文件被更改,包括 86 次插入9 次删除
  1. 18 0
      src/api/zfsf/cashier-process.js
  2. 68 9
      src/views/hospitalization/zfsf/CashierProcessInfo.vue

+ 18 - 0
src/api/zfsf/cashier-process.js

@@ -115,6 +115,12 @@ export function queryZdChequeType() {
         method: 'get',
     })
 }
+export function queryFpVersion() {
+    return request({
+        url: '/cashierProcess/queryFpVersion',
+        method: 'get',
+    })
+}
 
 /**
  * 保存出纳处理数据
@@ -167,6 +173,18 @@ export function queryPrintZyFpData(data) {
         data
     })
 }
+/**
+ * 下载电子发票
+ * @param data
+ * @returns {*}
+ */
+export function downDzInvoice(data) {
+    return request({
+        url: '/cashierProcess/downDzInvoice',
+        method: 'post',
+        data
+    })
+}
 
 
 export function cashierDataTx(data) {

+ 68 - 9
src/views/hospitalization/zfsf/CashierProcessInfo.vue

@@ -34,7 +34,7 @@
                   <el-input v-model="settData.zhje" disabled style="width: 80px"></el-input>
                 </el-form-item>
               </el-col>
-              <el-col :span="4" >
+              <el-col :span="4" v-if="fpVersion ==='0'">
                 <el-form-item label="当前发票号:">
                   <span  style="display: inline-block;width: 110px;background-color: #0f5e0f;text-align: center;color: #2eff00;font-size: 18px">{{settData.currentNoStr}}</span>
                 </el-form-item>
@@ -125,13 +125,17 @@
                 </div>
                 <div class="border_solid layout_overflow_auto" style="float: right;width: 49%;height: 100%">
                   <el-table :data="zyFpInfoList" style="width: 100%"  height="180">
-                    <el-table-column   label="操作" >
+                    <el-table-column   label="操作" width="200"  >
                       <template #default="scope">
-                        <el-button v-if="scope.row.inpatientNo !=null" icon="Printer" type="success" @click="selectPrintZyFp(scope.row)">打印</el-button>
+                        <el-button v-if="scope.row.inpatientNo !=null && fpVersion==='0'" icon="Printer" type="success" @click="selectPrintZyFp(scope.row)">打印</el-button>
+                        <el-button v-if="scope.row.inpatientNo !=null && fpVersion==='1'" icon="Upload" title="上传电子发票" type="primary" @click="uploadZyFp(scope.row,3)"></el-button>
+                        <el-button v-if="scope.row.inpatientNo !=null && fpVersion==='1'" icon="Download" title="下载电子发票" type="primary" @click="downDzFp(scope.row,3)"></el-button>
+                        <el-button v-if="scope.row.inpatientNo !=null && fpVersion==='1'" icon="Delete" title="作废电子发票" type="danger" @click="uploadZyFp(scope.row,4)"></el-button>
+                        <el-button v-if="scope.row.inpatientNo !=null && fpVersion==='1'" icon="Download" title="下载已作废电子发票" type="danger" @click="downDzFp(scope.row,4)"></el-button>
                       </template>
                     </el-table-column>
                     <el-table-column  property="ledgerSn" label="账页" />
-                    <el-table-column  property="receiptNo" label="发票号" />
+                    <el-table-column v-if="fpVersion === '0'"  property="receiptNo" label="发票号" />
                     <el-table-column  property="responceUnitName" label="类型" />
                     <el-table-column  property="totalCharge" label="发票金额" />
                   </el-table>
@@ -409,7 +413,10 @@ import {queryCashierProcessInfo,
   queryZdChequeType,
   cancelCashierData,
   queryPrintZyFpData,
-  updatePrintZyFpData
+  updatePrintZyFpData,
+  downDzInvoice,
+  queryFpVersion
+
 } from '@/api/zfsf/cashier-process.js'
 import {getLodop, initLodop} from '@/utils/c-lodop'
 import {consume} from '@/api/zfsf/pos-transaction.js'
@@ -556,9 +563,11 @@ const shuaKa = (row,index)=>{
 
 
 const selectPatient =(val)=>{
-  queryCurrentNo({cashId:userIdCode.value}).then(res=>{
-    settData.value.currentNoStr = res.currentNoStr
-  })
+  if(fpVersion.value ==='0'){
+    queryCurrentNo({cashId:userIdCode.value}).then(res=>{
+      settData.value.currentNoStr = res.currentNoStr
+    })
+  }
   // 查询账页信息
   queryPatientZyLedgerFile(val).then(res=>{
     zyInfoList.value = res
@@ -658,10 +667,13 @@ const getCashierProcessInfo = (param,zyLedgerFile,checkParam)=>{
     })
   }
 }
-
+const fpVersion = ref('0')
 const userIdCode = ref('')
 onMounted(()=>{
   initLodop()
+  queryFpVersion().then((res)=>{
+   fpVersion.value =res
+  })
   try {
     let patInfo = JSON.parse(window.atob(router.currentRoute.value.params.patientInfo))
     userIdCode.value = patInfo.userIdCode
@@ -942,6 +954,53 @@ const selectPrintZyFp = (row)=>{
   })
 }
 
+const uploadZyFp=(row,typeFlag)=>{
+  row['typeFlag'] = typeFlag
+  let typeFlagStr = typeFlag == 3 ? '上传' : '作废'
+  ElMessageBox.confirm("请确认是否"+typeFlagStr+"电子发票", {
+    cancelButtonText: "取消",
+    confirmButtonText: "确定",
+  })
+      .then(() => {
+        queryPrintZyFpData(row).then(res=>{
+          ElMessage.error(typeFlagStr+"电子发票成功!");
+        })
+      })
+}
+
+const downDzFp = (row,typeFlag)=>{
+  row['typeFlag'] = typeFlag
+  downDzInvoice(row).then(res=>{
+    const link = document.createElement("a");
+    // 获取数据量
+    const blob = new Blob([base64ToArrayBuffer(res.pdfFileStr)]);
+    // 下载文件
+    const objectUrl = URL.createObjectURL(blob);
+    link.href = objectUrl;
+    var timestamp = Date.parse(new Date());
+    link.download = timestamp + ".pdf";
+    link.click();
+    URL.revokeObjectURL(objectUrl);
+    link.remove();
+  })
+}
+
+
+const base64ToArrayBuffer = (base64) => {
+  var bloBString = window.atob(base64);
+
+  var bloBLen = bloBString .length;
+
+  var bytes = new Uint8Array(bloBLen);
+
+  for (var i = 0; i < bloBLen; i++) {
+    var ascii = bloBString .charCodeAt(i);
+
+    bytes[i] = ascii;
+  }
+
+  return bytes;
+};
 
 const printFlag = ref(true)