zhangherong
2025-03-07 36e8795b59c7f7393758ca96e0c2438eddaee8be
src/views/mdc/base/modules/alarmAnalysis/alarmAnalysisMain.vue
@@ -5,18 +5,102 @@
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :md="7" :sm="7">
            <a-col :md="6" :sm="6">
              <a-form-item label="设备类型">
                <a-select
                  :value="queryParams.equipmentType"
                  mode="multiple"
                  placeholder="请选择设备类型"
                  allow-clear
                  :maxTagCount="1"
                  @change="selectChange($event,'equipmentType')"
                >
                  <a-select-option v-for="(item,index) in equipmentTypeList" :value="item.value" :key="index">
                    {{ item.label }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="6">
              <a-form-item label="驱动类型">
                <a-select
                  :value="queryParams.driveType"
                  mode="multiple"
                  placeholder="请选择驱动类型"
                  allow-clear
                  :maxTagCount="1"
                  @change="selectChange($event,'driveType')"
                >
                  <a-select-option v-for="(item,index) in driveTypeList" :value="item.value" :key="index">
                    {{ item.label }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="6" :sm="6">
              <a-form-item label="时间">
                <a-range-picker @change="dateParamChange" :disabledDate="disabledDate" format="YYYYMMDD"
                                v-model="dates" :allowClear="false"/>
              </a-form-item>
            </a-col>
            <a-col :lg="2" :md="2" :sm="2" :xs="2">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
            <a-col :md="3" :sm="3" :xs="3">
              <a-space>
                <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
              </a-space>
            </a-col>
            <a-col :md="2" :sm="2">
              <a
                @click="toggleSearchStatus=!toggleSearchStatus"
                @selectstart="$event.preventDefault()"
                style="display: inline-block;height: 32px;line-height: 32px"
              >
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </a-col>
          </a-row>
          <a-row :gutter="24" v-if="toggleSearchStatus">
            <a-col :md="6" :sm="6" :xs="6">
              <a-form-item label="设备级别">
                <a-select
                  :value="queryParams.deviceLevel"
                  mode="multiple"
                  placeholder="请选择设备级别"
                  allow-clear
                  :maxTagCount="1"
                  @change="selectChange($event,'deviceLevel')"
                >
                  <a-select-option v-for="(item,index) in device_level_list" :value="item.value" :key="index">
                    {{ item.label }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
            <a-col :md="5" :sm="5" :xs="5">
              <a-form-item label="重要程度">
                <a-select
                  v-model="queryParam.deviceImportanceLevel"
                  placeholder="请选择设备重要程度"
                  allow-clear
                >
                  <a-select-option v-for="(item,index) in device_importance_level_list" :value="item.value"
                                   :key="index">
                    {{ item.label }}
                  </a-select-option>
                </a-select>
              </a-form-item>
            </a-col>
          </a-row>
        </a-form>
      </div>
      <div id="DeviceList">
        <div class="openRateTrendDg">
          <a-table :columns="columns" :data-source="dataList" bordered :pagination="false" :scroll="{y:210}"
@@ -51,13 +135,11 @@
<script>
  import moment from 'moment'
  import { putAction, getAction } from '@/api/manage'
  import {  getAction } from '@/api/manage'
  import $ from 'jquery'
  import '@/components/table2excel/table2excel'
  import { ajaxGetDictItems, getDictItemsFromCache, duplicateCheck } from '@/api/api'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api'
  import api from '@api/mdc'
  const columns = [
    { title: '报警号', dataIndex: 'alarmCode', key: 'alarmCode', align: 'center' },
@@ -98,7 +180,6 @@
  ]
  export default {
    // mixins: [JeecgListMixin],
    name: 'alarmAnalysisMain',
    components: {},
    data() {
@@ -115,9 +196,17 @@
        TreeIDTwo: 2,
        deviceTypeDict: '',
        dates: [],
        equipmentTypeList: [],
        driveTypeList: [],
        device_level_list: [],
        device_importance_level_list: [],
        identifying: [],
        queryParam: {},
        queryParams: {},
        queryParams: {
          equipmentType: [],
          driveType: [],
          deviceLevel: []
        },
        queryParamEquip: {},
        queryParamPeople: {},
        efficiencyOptions: [
@@ -134,7 +223,8 @@
          efficiencyList: '/mdc/alarmAnalyze/alarmList',
          listByType: '/mdc/MdcUtilizationRate/getByType',
          alarmTrend: '/mdc/alarmAnalyze/alarmTrend',
          equipmentAlarmList: '/mdc/alarmAnalyze/equipmentAlarmList'
          equipmentAlarmList: '/mdc/alarmAnalyze/equipmentAlarmList',
          queryEquipmentType: '/mdc/mdcEquipmentType/queryEquipmentType'
        },
        tableHeads: [],
        pieDate: [0],
@@ -142,7 +232,8 @@
        YData: [0],
        columns,
        innerColumns,
        hasRequsetAlarmCodeList: []
        hasRequestAlarmCodeList: [],
        toggleSearchStatus: false
      }
    },
    props: { nodeTree: '', Type: '', nodePeople: '' },
@@ -150,12 +241,11 @@
     * 生命周期 挂载前
     * */
    created() {
      this.dates = [moment().subtract('days', 8), moment().subtract('days', 1)]
      this.queryParam.startDate = moment(this.dates[0]).format('YYYYMMDD')
      this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
      this.queryParam.typeTree = '1'
      this.loadData1()
      this.searchReset()
      this.queryGroup()
      this.getDriveTypeByApi()
      this.initDictData('device_level')
      this.initDictData('device_importance_level')
    },
    mounted() {
      this.drawWrin()
@@ -234,6 +324,46 @@
      }
    },
    methods: {
      queryGroup() {
        getAction(this.url.queryEquipmentType).then(res => {
          if (res.success) {
            this.equipmentTypeList = res.result.map(item => {
              return {
                label: item.equipmentTypeName,
                value: item.equipmentTypeName
              }
            })
          } else {
            this.$notification.warning({
              message: '消息',
              description: res.message
            })
          }
        })
      },
      // 调用接口获取控制系统类型
      getDriveTypeByApi() {
        api.getDriveTypeApi().then((res) => {
          if (res.success) this.driveTypeList = res.result
        })
      },
      initDictData(dictCode) {
        // //优先从缓存中读取字典配置
        if (getDictItemsFromCache(dictCode)) {
          this[dictCode + '_list'] = getDictItemsFromCache(dictCode)
          return
        }
        //根据字典Code, 初始化字典数组
        ajaxGetDictItems(dictCode, null).then((res) => {
          if (res.success) {
            this[dictCode + '_list'] = res.result
            return
          }
        })
      },
      numBerTwo(value) {
        if (value) {
          return parseFloat((value * 100).toFixed(2))
@@ -241,6 +371,7 @@
          return '0'
        }
      },
      TableDraw(key, val) {
        let that = this
        that.echartLoading = true
@@ -257,15 +388,6 @@
              })
              that.XData = res.result.dateCountList.map(item => item.key)
              that.YData = res.result.dateCountList.map(item => item.count)
              // this.tableHeads = res.result.dates
              // this.dataList = res.result
              // this.draw()
              // this.checkSameData(this.dataList)
              // this.checkSameData1(this.dataList)
              // this.checkSameData2(this.dataList)
              // this.combineCell();
              // this.initDeviceType(this.dataList)
              that.drawWrin()
            }
          })
@@ -279,37 +401,12 @@
        //Can not slect days before today and today
        return current && current > moment().subtract('days', 1)
      },
      initDeviceType(deviceList) {
        let dictCode = 'mdc_equipmentType'
        let items = []
        items = getDictItemsFromCache(dictCode)
        if (deviceList && items.length > 0) {
          for (let a = 0; a < deviceList.length; a++) {
            if (items && items.length > 0) {
              for (let i = 0; i < items.length; i++) {
                if (deviceList[a].equipmentType == items[i].value) {
                  deviceList[a].equipmentType = items[i].title
                }
              }
            } else {
              ajaxGetDictItems(dictCode, null).then((res) => {
                if (res.success) {
                  let items = res.result
                  for (let i = 0; i < items.length; i++) {
                    if (deviceList[a].equipmentType == items[i].value) {
                      deviceList[a].equipmentType = items[i].title
                    }
                  }
                }
              })
            }
          }
        }
      },
      dateParamChange(v1, v2) {
        this.queryParam.startDate = v2[0]
        this.queryParam.endDate = v2[1]
      },
      searchQuery() {
        if (this.queryParam.typeTree == '1') {
          this.queryParam.parentId = this.queryParamEquip.parentId
@@ -318,29 +415,44 @@
          this.queryParam.parentId = this.queryParamPeople.parentId
          this.queryParam.equipmentId = ''
        }
        this.loadData1()
        Object.keys(this.queryParams).forEach(item => {
          if (Array.isArray(this.queryParams[item])) {
            if (this.queryParams[item].length !== 0) this.queryParam[item] = this.queryParams[item].join()
            else delete this.queryParam[item]
          }
        })
        this.loadData()
      },
      loadData1() {
      searchReset() {
        this.queryParams = {
          equipmentType: [],
          driveType: [],
          deviceLevel: []
        }
        this.queryParam = {}
        this.dates = [moment().subtract('days', 8), moment().subtract('days', 1)]
        this.queryParam.startDate = moment(this.dates[0]).format('YYYYMMDD')
        this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
        this.queryParam.typeTree = '1'
        this.loadData()
      },
      loadData() {
        this.outerDataLoading = true
        this.tableHeads = []
        this.dataList = []
        getAction(this.url.efficiencyList, this.queryParam).then(res => {
          if (res.success) {
            // this.tableHeads = res.result.dates
            this.dataList = res.result
            this.hasRequsetAlarmCodeList = []
            // this.draw()
            // this.checkSameData(this.dataList)
            // this.checkSameData1(this.dataList)
            // this.checkSameData2(this.dataList)
            // this.combineCell();
            // this.initDeviceType(this.dataList)
            this.hasRequestAlarmCodeList = []
          }
        }).finally(() => {
          this.outerDataLoading = false
        })
      },
      drawWrin() {
        this.equipmentWarningPie = this.$echarts.init(document.getElementById('MdcEquipmentWarningPie'), 'macarons')
        let equipmentWarningPieOption = {
@@ -483,7 +595,7 @@
        let _this = this
        // 当展开时若该行未被展开过才会请求后台数据,展开过的数据会被缓存无需重复请求
        this.queryParam.alarmCode = record.alarmCode
        if (expanded && !this.hasRequsetAlarmCodeList.includes(record.alarmCode)) {
        if (expanded && !this.hasRequestAlarmCodeList.includes(record.alarmCode)) {
          this.innerDataLoading = true
          getAction(this.url.equipmentAlarmList, this.queryParam).then(res => {
            if (res.success) {
@@ -492,7 +604,7 @@
                  item.innerDataList = res.result
                }
              })
              _this.hasRequsetAlarmCodeList.push(record.alarmCode)
              _this.hasRequestAlarmCodeList.push(record.alarmCode)
            }
          })
            .finally(() => {
@@ -501,6 +613,10 @@
        }
      },
      selectChange(value, key) {
        this.queryParams[key] = value
      },
      /**
       * 当浏览器可视窗口尺寸发生改变时触发
       */