1、设备管理中设备属性的字段显隐权限调整到设备状态字段
2、设备日志添加批量导出功能
已添加1个文件
已修改2个文件
154 ■■■■■ 文件已修改
src/views/mdc/base/modules/DeviceLog/DeviceLogBatchExportModal.vue 130 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/base/modules/DeviceLog/LogInfo.vue 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mdc/base/modules/EquipmentList/UserModal.vue 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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) //释放掉blob对象
                }
                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>
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: {
      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)
@@ -347,8 +354,12 @@
      },
      handleExport(){
        this.$refs.logList.queryParam=Object.assign({},this.queryParams,this.$refs.logList.queryParam)
        this.$refs.logList.queryParam = Object.assign({}, this.queryParams)
        this.$refs.logList.handleExportXls('设备日志')
      },
      openBatchExportModal() {
        this.$refs.batchExportModalRef.visible = true
      }
    },
    created() {
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">