From bd0d5396694b67e39ebaa44535b0df39895d5743 Mon Sep 17 00:00:00 2001
From: Lius <Lius2225@163.com>
Date: 星期四, 09 一月 2025 17:01:21 +0800
Subject: [PATCH] 设备日志导出

---
 src/views/mdc/base/modules/DeviceLog/LogList.vue |   44 +++++++++++++++++++++++++++++++++++++++++---
 src/views/mdc/base/modules/DeviceLog/LogInfo.vue |   11 +++++++++--
 2 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/src/views/mdc/base/modules/DeviceLog/LogInfo.vue b/src/views/mdc/base/modules/DeviceLog/LogInfo.vue
index 5bf1df3..6031da0 100644
--- a/src/views/mdc/base/modules/DeviceLog/LogInfo.vue
+++ b/src/views/mdc/base/modules/DeviceLog/LogInfo.vue
@@ -24,6 +24,7 @@
             <a-space>
               <a-button type="primary" @click="searchQuery" icon="search">鏌ヨ</a-button>
               <a-button type="primary" @click="searchReset" icon="reload">閲嶇疆</a-button>
+              <a-button type="primary" icon="download" @click="handleExport">瀵煎嚭</a-button>
             </a-space>
           </a-col>
         </a-row>
@@ -165,7 +166,7 @@
   import AlarmLogList from './AlarmLogList'
   import WorkChartModel from './WorkChartModel'
   import WorkHistoryModel from './WorkHistoryModel'
-  import { getAction } from '@/api/manage'
+  import { downFile, getAction } from '@/api/manage'
 
   export default {
      components: {
@@ -199,7 +200,8 @@
         url: {
           getBaseTree: '/mdc/mdcequipment/loadTree',
           getEquipmentByPid: '/mdc/mdcEquipment/getEquipmentByPid',
-          list: '/mdc/mdcEquipmentRunningSection/logList'
+          list: '/mdc/mdcEquipmentRunningSection/logList',
+          exportXlsUrl: '/mdc/mdcEquipmentRunningSection/exportLogXls'
         },
         ProStartId: ''
       }
@@ -342,6 +344,11 @@
 
           }
         })
+      },
+
+      handleExport(){
+        this.$refs.logList.queryParam=Object.assign({},this.queryParams,this.$refs.logList.queryParam)
+        this.$refs.logList.handleExportXls('璁惧鏃ュ織')
       }
     },
     created() {
diff --git a/src/views/mdc/base/modules/DeviceLog/LogList.vue b/src/views/mdc/base/modules/DeviceLog/LogList.vue
index 4888611..7fbc7be 100644
--- a/src/views/mdc/base/modules/DeviceLog/LogList.vue
+++ b/src/views/mdc/base/modules/DeviceLog/LogList.vue
@@ -20,7 +20,7 @@
   import JDictSelectTag from '@/components/dict/JDictSelectTag'
   import {
     requestPut,
-    deleteAction
+    deleteAction, downFile
   } from '@/api/manage'
 
   import JInput from '@/components/jeecg/JInput'
@@ -141,7 +141,10 @@
             align: 'center',
             dataIndex: 'sequenceNumber'
           }
-        ]
+        ],
+        url: {
+          exportXlsUrl: '/mdc/mdcEquipmentRunningSection/exportLogXls'
+        },
       }
     },
     methods: {
@@ -174,7 +177,42 @@
             }
           }
         }
-      }
+      },
+
+      handleExportXls(fileName){
+        if(!fileName || typeof fileName != "string"){
+          fileName = "瀵煎嚭鏂囦欢"
+        }
+        let param = this.getQueryParams();
+        if(this.selectedRowKeys && this.selectedRowKeys.length>0){
+          param['selections'] = this.selectedRowKeys.join(",")
+        }
+        console.log("瀵煎嚭鍙傛暟",param)
+        downFile(this.url.exportXlsUrl,param).then((data)=>{
+          if (!data) {
+            // this.$message.warning("鏂囦欢涓嬭浇澶辫触")
+            this.$notification.warning({
+              message:'娑堟伅',
+              description:"鏂囦欢涓嬭浇澶辫触"
+            });
+            return
+          }
+          if (typeof window.navigator.msSaveBlob !== 'undefined') {
+            window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
+          }else{
+            let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
+            let link = document.createElement('a')
+            link.style.display = 'none'
+            link.href = url
+            link.setAttribute('download', fileName+'.xls')
+            document.body.appendChild(link)
+            link.click()
+            document.body.removeChild(link); //涓嬭浇瀹屾垚绉婚櫎鍏冪礌
+            window.URL.revokeObjectURL(url); //閲婃斁鎺塨lob瀵硅薄
+          }
+        })
+      },
+
     },
     created() {
     }

--
Gitblit v1.9.3