From f360cde8ff0b28ba677a4693cf45f47f206dd746 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期三, 21 五月 2025 17:52:54 +0800 Subject: [PATCH] 1、设备管理中设备属性的字段显隐权限调整到设备状态字段 2、设备日志添加批量导出功能 --- src/views/mdc/base/modules/EquipmentList/UserModal.vue | 7 +- src/views/mdc/base/modules/DeviceLog/DeviceLogBatchExportModal.vue | 130 +++++++++++++++++++++++++++++++++++++++++++ src/views/mdc/base/modules/DeviceLog/LogInfo.vue | 25 ++++++-- 3 files changed, 151 insertions(+), 11 deletions(-) diff --git a/src/views/mdc/base/modules/DeviceLog/DeviceLogBatchExportModal.vue b/src/views/mdc/base/modules/DeviceLog/DeviceLogBatchExportModal.vue new file mode 100644 index 0000000..f1019d4 --- /dev/null +++ b/src/views/mdc/base/modules/DeviceLog/DeviceLogBatchExportModal.vue @@ -0,0 +1,130 @@ +<template> + <j-modal :visible="visible" title="鎵归噺瀵煎嚭" :confirmLoading="confirmLoading" @ok="handleSubmit('璁惧鏃ュ織')" + @cancel="handleCancel"> + <a-spin :spinning="confirmLoading"> + <a-form-model ref="form" :model="model" :rules="validateRules" :labelCol="{span:4}" :wrapperCol="{span:20}"> + <a-form-model-item label="鏃ユ湡" prop="dates"> + <a-range-picker v-model="model.dates" value-format="YYYY-MM-DD" :disabledDate="disabledDate" + @calendarChange="handleCalendarChange" @openChange="handleCalendarOpenChange" + :allow-clear="false"/> + </a-form-model-item> + </a-form-model> + </a-spin> + + </j-modal> +</template> + +<script> + import moment from 'moment' + import { downFile } from '@/api/manage' + + export default { + name: 'DeviceLogBatchExportModal', + props: { + equipmentId: { + type: String + } + }, + data() { + return { + visible: false, + confirmLoading: false, + model: {}, + validateRules: { + dates: [{ required: true, message: '璇烽�夋嫨鏃ユ湡锛�' }] + }, + preSelectFirstDate: null, + url: { + batchExportXlsUrl: '/mdc/mdcEquipmentRunningSection/batchExportLogXls' + } + } + }, + computed: { + disabledDate() { + // current涓洪渶瑕佺鐢ㄧ殑鏃堕棿娈� + return current => { + if (!this.preSelectFirstDate) { + return current > moment().endOf('days') + } else { + return current < moment(this.preSelectFirstDate).subtract(30, 'days').startOf('days') + || current > moment().endOf('days') + || current > moment(this.preSelectFirstDate).add(30, 'days').endOf('days') + } + } + } + }, + methods: { + handleSubmit(fileName) { + this.$refs.form.validate(valid => { + if (valid) { + this.confirmLoading = true + if (!fileName || typeof fileName != 'string') { + fileName = '瀵煎嚭鏂囦欢' + } + const param = { + equipmentId: this.equipmentId, + startTime: this.model.dates[0], + endTime: this.model.dates[1] + } + console.log('瀵煎嚭鍙傛暟', param) + downFile(this.url.batchExportXlsUrl, 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瀵硅薄 + } + this.handleCancel() + }) + .finally(() => { + this.confirmLoading = false + }) + } else { + return false + } + }) + }, + + handleCalendarChange(dates) { + console.log('dates', dates) + if (dates.length === 1) this.preSelectFirstDate = dates[0] + }, + + handleCalendarOpenChange(status) { + if (status) { + if (this.model.dates && this.model.dates.length > 0) { + this.preSelectFirstDate = this.model.dates[0] + } else { + this.preSelectFirstDate = null + } + } + }, + + handleCancel() { + this.$refs.form.clearValidate() + this.model = {} + this.visible = false + } + } + } +</script> + +<style scoped> + +</style> \ No newline at end of file diff --git a/src/views/mdc/base/modules/DeviceLog/LogInfo.vue b/src/views/mdc/base/modules/DeviceLog/LogInfo.vue index 6031da0..a12f4d4 100644 --- a/src/views/mdc/base/modules/DeviceLog/LogInfo.vue +++ b/src/views/mdc/base/modules/DeviceLog/LogInfo.vue @@ -16,7 +16,7 @@ </a-col> <a-col :md="4" :sm="4"> <a-form-item label="鏃ユ湡"> - <a-date-picker v-model="queryParams.collectTime" :disabledDate="disabledDate" @change="dataChange" + <a-date-picker v-model="queryParams.collectTime" :disabledDate="disabledDate" @change="handleDateChange" format='YYYY-MM-DD'/> </a-form-item> </a-col> @@ -25,6 +25,8 @@ <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-button v-if="queryParams.equipmentId" type="primary" icon="download" @click="openBatchExportModal">鎵归噺瀵煎嚭 + </a-button> </a-space> </a-col> </a-row> @@ -155,6 +157,8 @@ <work-chart-model ref="workChartModel" :collectTime="this.queryParams.collectTime" :equipment="this.equipment"></work-chart-model> <work-history-model ref="workHistoryModel"></work-history-model> + + <DeviceLogBatchExportModal ref="batchExportModalRef" :equipmentId="queryParams.equipmentId"/> </div> </template> @@ -167,9 +171,11 @@ import WorkChartModel from './WorkChartModel' import WorkHistoryModel from './WorkHistoryModel' import { downFile, getAction } from '@/api/manage' + import DeviceLogBatchExportModal from './DeviceLogBatchExportModal' export default { - components: { + components: { + DeviceLogBatchExportModal, LogList, WorkLogList, AlarmLogList, @@ -255,9 +261,10 @@ this.cardLoading = false }) }, - dataChange(val) { + handleDateChange(val) { this.queryParams.collectTime = val this.queryParams.collectTimeStr = this.queryParams.collectTime.format('YYYY-MM-DD') + }, searchQuery() { // console.log(this.queryParams.collectTime) @@ -273,8 +280,8 @@ }, searchReset() { this.queryParams = { - collectTime : moment() - } + collectTime: moment() + } this.equipment = {} this.queryChart() }, @@ -346,9 +353,13 @@ }) }, - handleExport(){ - this.$refs.logList.queryParam=Object.assign({},this.queryParams,this.$refs.logList.queryParam) + handleExport() { + this.$refs.logList.queryParam = Object.assign({}, this.queryParams) this.$refs.logList.handleExportXls('璁惧鏃ュ織') + }, + + openBatchExportModal() { + this.$refs.batchExportModalRef.visible = true } }, created() { diff --git a/src/views/mdc/base/modules/EquipmentList/UserModal.vue b/src/views/mdc/base/modules/EquipmentList/UserModal.vue index 088ba27..fe32e7a 100644 --- a/src/views/mdc/base/modules/EquipmentList/UserModal.vue +++ b/src/views/mdc/base/modules/EquipmentList/UserModal.vue @@ -120,7 +120,7 @@ </a-form-model-item> </a-col> <a-col :span="12"> - <a-form-model-item label="璁惧鐘舵��"> + <a-form-model-item label="璁惧鐘舵��" v-has="'equipment_attribute'"> <j-dict-select-tag placeholder="璇烽�夋嫨璁惧鐘舵��" :triggerChange="true" dictCode="mdc_equipment_status" v-model="model.equipmentStatus" allow-clear/> </a-form-model-item> @@ -128,10 +128,9 @@ </a-row> <a-row :gutter="24"> - <a-col :span="12" v-has="'equipment_attribute'"> + <a-col :span="12"> <a-form-model-item label="璁惧灞炴��"> - <j-dict-select-tag v-model="model.attribute" type="radio" - dictCode="equipment_attribute"/> + <j-dict-select-tag v-model="model.attribute" type="radio" dictCode="equipment_attribute"/> </a-form-model-item> </a-col> <a-col :span="12"> -- Gitblit v1.9.3