Explorar o código

Merge branch 'export_list' of shuzhihua/pms-iot-vue into master

yanghao hai 20 horas
pai
achega
8558d22a47

+ 1 - 1
.env.local

@@ -4,7 +4,7 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径  http://192.168.188.149:48080  https://iot.deepoil.cc
-VITE_BASE_URL='https://iot.deepoil.cc'
+VITE_BASE_URL='http://192.168.188.149:48080'
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server

+ 26 - 0
src/api/pms/inspect/order/index.ts

@@ -90,5 +90,31 @@ export const IotInspectOrderApi = {
   // 异常设备列表
   getExceptionDeviceList: async (params: any) => {
     return await request.get({ url: `/rq/iot-inspect-order/exception/device`, params })
+  },
+
+  // 导出巡检报表 Excel
+  exportInspectReport: async (params) => {
+    return await request.download({ url: `/rq/iot-inspect-order/report/export-excel`, params })
+  },
+
+  // 异常巡检点导出 Excel
+  exportExceptionPointInspectReport: async (params) => {
+    return await request.download({
+      url: `/rq/iot-inspect-order/report/exception/item/export-excel`,
+      params
+    })
+  },
+
+  //  异常设备导出 Excel
+  exportExceptionDeviceInspectReport: async (params) => {
+    return await request.download({
+      url: `/rq/iot-inspect-order/report/exception/device/export-excel`,
+      params
+    })
+  },
+
+  // 故障报表导出 Excel
+  exportFaultReport: async (params) => {
+    return await request.download({ url: `/rq/report/failure/report/export-excel`, params })
   }
 }

+ 30 - 6
src/views/report-statistics/device_book/index2.vue

@@ -78,7 +78,7 @@
                 >
               </el-form-item>
               <el-form-item>
-                <el-button type="success" plain @click="handleExport"
+                <el-button type="success" plain @click="handleExport" :loading="exportLoading"
                   ><Icon icon="ep:download" class="mr-3px" /> 导出</el-button
                 >
               </el-form-item>
@@ -239,7 +239,7 @@
         />
       </ContentWrap>
 
-      <el-dialog
+      <!-- <el-dialog
         v-model="exportDialogVisible"
         title="导出设置"
         width="600px"
@@ -281,7 +281,7 @@
             </el-button>
           </div>
         </template>
-      </el-dialog>
+      </el-dialog> -->
     </el-col>
   </el-row>
 </template>
@@ -297,6 +297,7 @@ import echarts from '@/plugins/echarts'
 import { formatDate } from '@/utils/formatTime'
 import { nextTick, watch } from 'vue'
 import download from '@/utils/download'
+const message = useMessage() // 消息弹窗
 
 /** 设备台账 列表 */
 defineOptions({ name: 'IotDevicePms' })
@@ -387,9 +388,32 @@ const getTableColumns = () => {
 }
 
 // 导出功能
+// const handleExport = async () => {
+//   exportDialogVisible.value = true
+//   getTableColumns()
+// }
+
+let exportLoading = ref(false)
 const handleExport = async () => {
-  exportDialogVisible.value = true
-  getTableColumns()
+  try {
+    const exportParams = {
+      pageNo: queryParams.pageNo,
+      pageSize: queryParams.pageSize,
+      deviceCode: queryParams.deviceCode,
+      deviceName: queryParams.deviceName,
+
+      exportFields: selectedColumns.value.join(',')
+    }
+    // 导出的二次确认
+    await message.exportConfirm()
+    // 发起导出
+    exportLoading.value = true
+    const data = await IotDeviceApi.exportDeviceReport(exportParams)
+    download.excel(data, '设备报表.xls')
+  } catch {
+  } finally {
+    exportLoading.value = false
+  }
 }
 
 // 确认导出
@@ -413,7 +437,7 @@ const confirmExport = async () => {
     // 调用后端导出接口
     const res = await IotDeviceApi.exportDeviceReport(exportParams)
 
-    download.excel(res, '设备报表.xls')
+    download.excel(res, '设备报表.xlsx')
     exportDialogVisible.value = false
   } catch (error) {
     console.error('导出失败:', error)

+ 26 - 0
src/views/report-statistics/fault_report/index.vue

@@ -145,6 +145,12 @@
                 >
               </el-form-item>
 
+              <el-form-item>
+                <el-button type="success" plain @click="handleExport" :loading="exportLoading"
+                  ><Icon icon="ep:download" class="mr-3px" /> 导出</el-button
+                >
+              </el-form-item>
+
               <el-form-item>
                 <el-button @click="resetQuery"
                   ><Icon icon="ep:refresh" class="mr-3px" />
@@ -263,6 +269,10 @@ import { DICT_TYPE } from '@/utils/dict'
 import DeptTree from '@/views/system/user/DeptTree.vue'
 import { dateFormatter } from '@/utils/formatTime'
 
+const message = useMessage() // 消息弹窗
+import { watch } from 'vue'
+import download from '@/utils/download'
+
 const { params } = useRoute()
 /** 巡检工单 列表 */
 defineOptions({ name: 'IotInspectOrder' })
@@ -303,6 +313,22 @@ const statusList = ref({
   close: false
 })
 
+let exportLoading = ref(false)
+const handleExport = async () => {
+  try {
+    // 导出的二次确认
+    await message.exportConfirm()
+    // 发起导出
+    exportLoading.value = true
+
+    const data = await IotInspectOrderApi.exportFaultReport(queryParams)
+    download.excel(data, '故障上报报表.xlsx')
+  } catch {
+  } finally {
+    exportLoading.value = false
+  }
+}
+
 /** 查询列表 */
 const getList = async (status: string = '', shouldResetStatus = true) => {
   if (shouldResetStatus) {

+ 34 - 2
src/views/report-statistics/inspection_order/index.vue

@@ -145,13 +145,18 @@
       </el-row>
 
       <el-row :gutter="20">
-        <el-col :span="24">
+        <el-col :span="22">
           <el-radio-group v-model="dateType" size="default" fill="#409eff">
             <el-radio-button label="年" value="year" />
             <el-radio-button label="月" value="month" />
             <el-radio-button label="日" value="day" />
           </el-radio-group>
         </el-col>
+        <el-col :span="2">
+          <el-button type="success" plain @click="handleExport" :loading="exportLoading"
+            ><Icon icon="ep:download" class="mr-3px" /> 导出</el-button
+          >
+        </el-col>
       </el-row>
 
       <!-- 列表 -->
@@ -328,8 +333,9 @@ import { IotInspectOrderApi, IotInspectOrderVO } from '@/api/pms/inspect/order'
 import { DICT_TYPE } from '@/utils/dict'
 import DeptTree from '@/views/system/user/DeptTree.vue'
 import { IotInspectItemVO, IotInspectOrderDetailApi } from '@/api/pms/inspect/order/detail'
-
+const message = useMessage() // 消息弹窗
 import { watch } from 'vue'
+import download from '@/utils/download'
 
 const { push } = useRouter()
 const { params } = useRoute()
@@ -419,6 +425,32 @@ const handleRowClick = (row, column: any, event: Event) => {
   }
 }
 
+let exportLoading = ref(false)
+const handleExport = async () => {
+  try {
+    // 导出的二次确认
+    await message.exportConfirm()
+    // 发起导出
+    exportLoading.value = true
+
+    if (isException.value) {
+      const data = await IotInspectOrderApi.exportExceptionDeviceInspectReport(queryParams)
+      download.excel(data, '异常设备报表.xlsx')
+    } else if (isExceptionPoint.value) {
+      const data = await IotInspectOrderApi.exportExceptionPointInspectReport(queryParams)
+      download.excel(data, '异常点报表.xlsx')
+    } else {
+      const data = await IotInspectOrderApi.exportInspectReport(queryParams)
+      download.excel(data, '巡检报表.xlsx')
+    }
+    // const data = await IotInspectOrderApi.exportInspectReport(queryParams)
+    // download.excel(data, '巡检报表.xlsx')
+  } catch {
+  } finally {
+    exportLoading.value = false
+  }
+}
+
 let isExceptionPoint = ref(false)
 const list2 = ref<IotInspectItemVO[]>([]) // 列表的数据