ソースを参照

过程分析新增导出

Shan9312 1 年間 前
コミット
d2d9eb7d41

BIN
dist-tmr-测试-20250107.zip


+ 1 - 0
package.json

@@ -27,6 +27,7 @@
     "fuse.js": "3.4.4",
     "js-cookie": "^2.2.0",
     "js-table2excel": "^1.0.3",
+    "jszip": "^3.10.1",
     "leaflet": "^1.9.4",
     "md5": "^2.3.0",
     "moment": "^2.24.0",

+ 9 - 0
src/api/common.js

@@ -505,3 +505,12 @@ export function getPastureData() {
     method: 'POST'
   })
 }
+
+
+export function processAnalysistDown(data) {
+  return request({
+    url: '/authdata/process/excel',
+    method: 'POST',
+    data
+  })
+}

+ 47 - 2
src/views/statisticalAnalysis/processAnalysis/pasture/index.vue

@@ -50,6 +50,7 @@
       <el-button class="successBorder" @click="form_search">查询</el-button>
       <el-button class="successBorder" @click="handleRefresh">重置</el-button>
       <el-button class="successBorder" @click="handleGetPastureData">牧场数据获取</el-button>
+      <el-button class="export" icon="el-icon-upload2" @click="handleDownLoad">导出</el-button>
     </div>
     <el-row :gutter="10">
       <el-col :span="8">
@@ -624,10 +625,12 @@
 import echarts from 'echarts'
 
 require('echarts/theme/macarons')
-import { GetDataByName, GetReportform, formatNum,processAnalysist,editWeightHL,editWeightSL,getPastureData } from '@/api/common'
+import { GetDataByName, GetReportform, formatNum,processAnalysist,editWeightHL,editWeightSL,getPastureData,processAnalysistDown } from '@/api/common'
 import Cookies from 'js-cookie'
-import { parseTime } from '@/utils/index.js'
+import { parseTime ,json2excel} from '@/utils/index.js'
 import { MessageBox } from 'element-ui';
+import axios from 'axios'
+import { getToken } from '@/utils/auth' // get token from cookie
 
 export default {
   name: 'PastureProcessAnalysis',
@@ -815,6 +818,48 @@ export default {
     this.getList()
   },
   methods: {
+
+    // 导出功能
+     handleDownLoad(){
+        if (this.table.getdataListParm.parammaps.inputDatetime !== '' && this.table.getdataListParm.parammaps.inputDatetime !== null) {
+        this.table.getdataListParm.parammaps.startTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[0], '{y}-{m}-{d}')
+        this.table.getdataListParm.parammaps.stopTime = parseTime(this.table.getdataListParm.parammaps.inputDatetime[1], '{y}-{m}-{d}')
+      } else {
+        this.table.getdataListParm.parammaps.inputDatetime = ''
+        this.table.getdataListParm.parammaps.startTime = ''
+        this.table.getdataListParm.parammaps.stopTime = ''
+      }
+        const url = Cookies.get('url') + 'authdata/process/excel' // 请求下载文件的地址
+        console.log(url)
+        axios({
+          method: 'POST',
+          url: url,
+          data: this.table.getdataListParm,
+          headers: { token: getToken(), optname: 'insertcustomdoc' },
+          responseType: 'blob'
+        }).then(res => {
+          if (!res) return
+          this.percentage = 99
+          setTimeout(() => {
+            this.isPercentage = false
+          }, 2000)
+          const blob = new Blob([res.data], {
+            type: 'application/octet-stream;charset=utf-8'
+          })
+          const url = window.URL.createObjectURL(blob)
+          const aLink = document.createElement('a')
+          aLink.style.display = 'none'
+          aLink.href = url
+          const docname = '过程分析.xlsx'
+          aLink.setAttribute('download', docname) // 下载的文件
+          document.body.appendChild(aLink)
+          aLink.click()
+          document.body.removeChild(aLink)
+          window.URL.revokeObjectURL(url)
+        })
+     },
+
+
     // 牧场数据获取
     handleGetPastureData(){
       console.log('牧场数据获取')