Ver Fonte

导出样本来源方法

jianglw há 4 anos atrás
pai
commit
0a853882d8

+ 11 - 0
src/dashoo.cn/frontend_animal/src/api/system/auditsetting.js

@@ -1,3 +1,6 @@
+// eslint-disable-next-line camelcase
+import micro_request from '../../utils/micro_request'
+
 export default {
   getList (CreateOn, params, myAxios) {
     return myAxios({
@@ -37,5 +40,13 @@ export default {
       url: '/auditsetting/delete/' + entityId,
       method: 'delete'
     })
+  },
+  // 查询有效角色列表
+  exportExcel (fileName) {
+    micro_request.downloadExcel('dashoo.biobank.bee-0.1', 'SampleSource', 'ExportExcel', '样本来源.xlsx')
+    // return request({
+    //   url: 'role/getdict',
+    //   method: 'get'
+    // })
   }
 }

+ 27 - 17
src/dashoo.cn/frontend_animal/src/pages/biobank/source/animal.vue

@@ -203,6 +203,8 @@
 import {
   mapGetters
 } from 'vuex'
+import exportExcel from '../../../api/system/auditsetting'
+import service from "../../../utils/micro_request";
 export default {
 
   computed: {
@@ -533,13 +535,13 @@ export default {
         }
       } */
       let params = {
-        _currentPage: this.currentPage,
-        _size: this.size,
+        currentPage: this.currentPage,
+        size: this.size,
         GenusId: this.GenusId,
         Genus: this.Genus,
         Address: this.Address,
         InnerNo: this.InnerNo,
-        CreateOn: this.CreateOn,
+        CreateOn: (this.CreateOn).join(','),
         SourceType: this.SourceType,
         ProjectName: this.ProjectName,
         Name: this.Name,
@@ -591,20 +593,28 @@ export default {
         }
         params = Object.assign(params, paramsid)
       }
-      console.log(1)
-
-      _this.$axios.get('/samplesource/exportexcel', {
-        params
-      })
-        .then(res => {
-          _this.exportloading = false
-          window.location = 'http://' + res.data
-        })
-        .catch(err => {
-          _this.exportloading = false
-          // handle error
-          console.error(err)
-        })
+      // console.log(params)
+      // this.$confirm('是否确认导?', "警告", {
+      //   confirmButtonText: '确定',
+      //   cancelButtonText: '取消',
+      //   type: "warning"
+      // }).then(function () {
+      //   exportExcel('样本来源.xlsx')
+      // }).catch(function () { })
+      // eslint-disable-next-line no-undef
+      service.downloadExcel('dashoo.biobank.bee-0.1', 'SampleSource', 'ExportExcel', '样本来源.xlsx', params)
+      // _this.$axios.get('/samplesource/exportexcel', {
+      //   params
+      // })
+      //   .then(res => {
+      //     _this.exportloading = false
+      //     window.location = 'http://' + res.data
+      //   })
+      //   .catch(err => {
+      //     _this.exportloading = false
+      //     // handle error
+      //     console.error(err)
+      //   })
     },
     jstimehandle (val) {
       if (val === '') {

+ 65 - 64
src/dashoo.cn/frontend_animal/src/utils/micro_request.js

@@ -1,80 +1,81 @@
 import axios from 'axios'
 import { Notification, MessageBox, Message } from 'element-ui'
 import store from '@/store'
-import { getToken } from '@/utils/auth'
-import errorCode from '@/utils/errorCode'
+// import { getToken } from '@/utils/auth'
+// import errorCode from '@/utils/errorCode'
 
 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
 
 const service = axios.create({
   // axios中请求配置有baseURL选项,表示请求URL公共部分
-  baseURL: process.env.VUE_APP_BASE_API,
+  // baseURL: process.env.VUE_APP_BASE_API,
+  baseURL: 'http://localhost:9981',
   // 超时
   timeout: 60000
 })
 
 // request拦截器
-service.interceptors.request.use(config => {
-  config.headers['Tenant'] = process.env.VUE_APP_TENANT
-  config.headers['X-RPCX-Meta'] = 'tenant='+ process.env.VUE_APP_TENANT
-  // 是否需要设置 token
-  const isToken = (config.headers || {}).isToken === false
-  if (getToken() && !isToken) {
-    config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
-  }
-  return config
-}, error => {
-    console.log(error)
-    Promise.reject(error)
-})
+// service.interceptors.request.use(config => {
+//   config.headers['Tenant'] = process.env.VUE_APP_TENANT
+//   config.headers['X-RPCX-Meta'] = 'tenant='+ process.env.VUE_APP_TENANT
+//   // 是否需要设置 token
+//   const isToken = (config.headers || {}).isToken === false
+//   if (getToken() && !isToken) {
+//     config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
+//   }
+//   return config
+// }, error => {
+//     console.log(error)
+//     Promise.reject(error)
+// })
 
 
 // 响应拦截器
-service.interceptors.response.use(res => {
-  // 未设置状态码则默认成功状态
-  const code = res.data.code || 200;
-  // 获取错误信息
-  const message = errorCode[code] || res.data.msg || errorCode['default']
-  if (code === 401) {
-    MessageBox.confirm(
-      '登录状态已过期,您可以继续留在该页面,或者重新登录',
-      '系统提示',
-      {
-        confirmButtonText: '重新登录',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }
-    ).then(() => {
-      store.dispatch('LogOut').then(() => {
-        location.reload() // 为了重新实例化vue-router对象 避免bug
-      })
-    })
-  }
-  else if (code === 500) {
-    Message({
-      message: message,
-      type: 'error'
-    })
-    return Promise.reject(new Error(message))
-  } else if (code !== 200) {
-    Notification.error({
-      title: message
-    })
-    return Promise.reject('error')
-  }
-  else {
-    return res.data
-  }
-},
-error => {
-  console.log('err' + error)
-  Message({
-    message: error.message,
-    type: 'error',
-    duration: 5 * 1000
-  })
-  return Promise.reject(error)
-})
+// service.interceptors.response.use(res => {
+//   // 未设置状态码则默认成功状态
+//   const code = res.data.code || 200;
+//   // 获取错误信息
+//   const message = errorCode[code] || res.data.msg || errorCode['default']
+//   if (code === 401) {
+//     MessageBox.confirm(
+//       '登录状态已过期,您可以继续留在该页面,或者重新登录',
+//       '系统提示',
+//       {
+//         confirmButtonText: '重新登录',
+//         cancelButtonText: '取消',
+//         type: 'warning'
+//       }
+//     ).then(() => {
+//       store.dispatch('LogOut').then(() => {
+//         location.reload() // 为了重新实例化vue-router对象 避免bug
+//       })
+//     })
+//   }
+//   else if (code === 500) {
+//     Message({
+//       message: message,
+//       type: 'error'
+//     })
+//     return Promise.reject(new Error(message))
+//   } else if (code !== 200) {
+//     Notification.error({
+//       title: message
+//     })
+//     return Promise.reject('error')
+//   }
+//   else {
+//     return res.data
+//   }
+// },
+// error => {
+//   console.log('err' + error)
+//   Message({
+//     message: error.message,
+//     type: 'error',
+//     duration: 5 * 1000
+//   })
+//   return Promise.reject(error)
+// })
 
 service.postRequest = function postRequest(basePath, srvName, funcName, data) {
   if (data == undefined){
@@ -82,7 +83,7 @@ service.postRequest = function postRequest(basePath, srvName, funcName, data) {
     data = nullParam
   }
   return service.request({
-    url: process.env.VUE_APP_MicroSrvProxy_API + basePath,
+    url: 'localhost:9981' + basePath,
     method: 'post',
     headers: {
       'Content-Type': 'application/rpcx',
@@ -104,7 +105,7 @@ service.downloadExcel = function downloadExcel(basePath, srvName, funcName, file
     data = nullParam
   }
   service.request({
-    url: process.env.VUE_APP_MicroSrvProxy_API + basePath,
+    url: basePath,
     method: 'post',
     responseType: 'blob',
     headers: {
@@ -116,7 +117,7 @@ service.downloadExcel = function downloadExcel(basePath, srvName, funcName, file
     data: data
   }).then(res => {
     const aLink = document.createElement('a')
-    var blob = new Blob([res], { type: 'application/vnd.ms-excel' })
+    var blob = new Blob([res.data], { type: 'application/vnd.ms-excel' })
     aLink.href = URL.createObjectURL(blob)
     aLink.setAttribute('download', fileName) // 设置下载文件名称
     document.body.appendChild(aLink)