yuwandanmian 2 tahun lalu
induk
melakukan
3434c4ef3f

+ 21 - 0
src/api/excel.js

@@ -0,0 +1,21 @@
+import request_blob from '@/utils/request_blob'
+
+// 医院普通检索下载
+export function bassNormalSearchDownload(data) {
+  return request_blob({
+    url: `/bass/normalSearchExport`,
+    method: 'get',
+    responseType: 'blob',
+    params: data
+  })
+}
+
+// 医院高级检索下载
+export function bassHighSearchDownload(data) {
+    return request_blob({
+      url: `/bass/search_result_export`,
+      method: 'post',
+      responseType: 'blob',
+      data
+    })
+  }

+ 52 - 0
src/utils/request_blob.js

@@ -0,0 +1,52 @@
+import axios from 'axios'
+import { Message } from 'element-ui'
+import store from '@/store'
+import { getToken } from '@/utils/auth'
+
+// create an axios instance
+const service = axios.create({
+  timeout: 50000 // request timeout
+})
+
+// request interceptor
+service.interceptors.request.use(
+  config => {
+    if (store.getters.token) {
+      config.headers['token'] = `${getToken()}`
+    }
+    return config
+  },
+  error => {
+    // do something with request error
+    return Promise.reject(error)
+  }
+)
+
+// response interceptor
+service.interceptors.response.use(
+  /**
+   * If you want to get http information such as headers or status
+   * Please return  response => response
+  */
+
+  /**
+   * Determine the request status by custom code
+   * Here is just an example
+   * You can also judge the status by HTTP Status Code
+   */
+  response => {
+    return response
+  },
+  error => {
+    console.log('err' + error) // for debug
+    Message({
+      message: error.message,
+      type: 'error',
+      duration: 5 * 1000,
+      offset: 112
+    })
+    return Promise.reject(error)
+  }
+)
+
+export default service

+ 22 - 18
src/views/allcase/caseViews.vue

@@ -412,29 +412,33 @@ export default {
       // }
       // 病程记录
       if (item.bllb === 294) {
-        // 请求前先重置之前的数据
-        that.caseRecodeInfo = {};
-        let parm = { blbh: that.is_active };
-        if (this.$route.query.status) {
-          parm.is_tm = 1;
+        if (that.is_active) {
+          // 请求前先重置之前的数据
+          that.caseRecodeInfo = {};
+          let parm = { blbh: that.is_active };
+          if (this.$route.query.status) {
+            parm.is_tm = 1;
+          }
+          that.$axios.post('/get_bc_data', parm).then(res => {
+            that.caseRecodeInfo = res.data[0].bc_data;
+            that.caseRecodeInfo.is_format = res.data[0].is_format;
+          });
         }
-        that.$axios.post('/get_bc_data', parm).then(res => {
-          that.caseRecodeInfo = res.data[0].bc_data;
-          that.caseRecodeInfo.is_format = res.data[0].is_format;
-        });
       }
       // 手术记录
       if (item.bllb === 303) {
-        // 请求前先重置之前的数据
-        that.surgeryData = {};
-        let parm = { blbh: that.is_active };
-        if (this.$route.query.status) {
-          parm.is_tm = 1;
+        if (that.is_active) {
+          // 请求前先重置之前的数据
+          that.surgeryData = {};
+          let parm = { blbh: that.is_active };
+          if (this.$route.query.status) {
+            parm.is_tm = 1;
+          }
+          that.$axios.post('/get_surgery_data', parm).then(res => {
+            that.surgeryData = res.data[0].surgery_data;
+            that.surgeryData.is_format = res.data[0].is_format;
+          });
         }
-        that.$axios.post('/get_surgery_data', parm).then(res => {
-          that.surgeryData = res.data[0].surgery_data;
-          that.surgeryData.is_format = res.data[0].is_format;
-        });
       }
     },
   },

+ 49 - 8
src/views/searchSystem/components/BLSearch.vue

@@ -198,24 +198,19 @@
         </el-form>
       </div>
       <div v-if="choice == 1" class="fBtn" style="position: relative">
+        <el-button type="primary" icon="el-icon-download" style="position: absolute; right: 120px" @click="highDownload('病历-高级搜索')">导出execl</el-button>
         <el-button
           class="btn11"
           @click="reset"
           >重置条件</el-button
         >
-        <!-- <el-select
-          v-model="formData1.seniorList1"
-          class="inputOn"
-          style="position: absolute; right: 30px"
-          placeholder="检索历史"
-          @change="funSetformData2"
-        /> -->
         <el-button class="btn2" @click="funQuery(1)">检索</el-button>
       </div>
       <div v-else class="fBtn" style="position: relative">
+        <el-button type="primary" icon="el-icon-download" style="position: absolute; right: 220px" @click="normalDownload('病历-普通搜索')">导出execl</el-button>
         <el-select
           v-model="formData0.input1"
-          style="position: absolute; right: 30px"
+          style="position: absolute; right: 0px"
           placeholder="检索历史"
           @change="funSetList()"
         >
@@ -387,6 +382,7 @@
 import Title from "@/components/Title";
 import { mapGetters } from "vuex";
 import mPagination from "@/components/m-pagination";
+import { bassNormalSearchDownload, bassHighSearchDownload } from '@/api/excel'
 
 export default {
   name: "Dashboard",
@@ -491,6 +487,51 @@ export default {
   },
   created() {},
   methods: {
+    normalDownload(name) {
+      const params = {
+        keyword: this.formData0.input
+      }
+      bassNormalSearchDownload(params).then(res => {
+        const content = res.data // 后台返回二进制数据
+        const blob = new Blob([content])
+        const fileName = `${name}.xlsx`
+        if ('download' in document.createElement('a')) { // 非IE下载
+          const elink = document.createElement('a')
+          elink.download = fileName
+          elink.style.display = 'none'
+          elink.href = URL.createObjectURL(blob)
+          document.body.appendChild(elink)
+          elink.click()
+          URL.revokeObjectURL(elink.href) // 释放URL 对象
+          document.body.removeChild(elink)
+        } else { // IE10+下载
+          navigator.msSaveBlob(blob, fileName)
+        }
+      })
+    },
+    highDownload(name) {
+      alert('api 有问题 todo ')
+      // const params = {
+      //   keyword: this.formData0.input
+      // }
+      // bassNormalSearchDownload(params).then(res => {
+      //   const content = res.data // 后台返回二进制数据
+      //   const blob = new Blob([content])
+      //   const fileName = `${name}.xlsx`
+      //   if ('download' in document.createElement('a')) { // 非IE下载
+      //     const elink = document.createElement('a')
+      //     elink.download = fileName
+      //     elink.style.display = 'none'
+      //     elink.href = URL.createObjectURL(blob)
+      //     document.body.appendChild(elink)
+      //     elink.click()
+      //     URL.revokeObjectURL(elink.href) // 释放URL 对象
+      //     document.body.removeChild(elink)
+      //   } else { // IE10+下载
+      //     navigator.msSaveBlob(blob, fileName)
+      //   }
+      // })
+    },
     onLockResult() {
       this.lock = true
       this.formData1.seniorList.map(item => {