zhangherong
2025-03-07 36e8795b59c7f7393758ca96e0c2438eddaee8be
src/views/mdc/base/modules/openRateFractionAnalysis/openRateFractionAnalysisMain.vue
@@ -5,25 +5,107 @@
      <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.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 :md="17" :sm="17" :xs="17">
            <a-col :md="9" :sm="9" :xs="9">
              <a-form-item label="时间段">
                <a-space>
                  <a-time-picker :default-value="moment('00:00', 'HH:mm')" format="HH:mm" @change="onChangeStart" :allowClear="false"/>
                  至
                  <a-time-picker :default-value="moment('08:00', 'HH:mm')" format="HH:mm" @change="onChangeEnd" :allowClear="false"/>
                  <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
                  <a-button type="primary" @click="searchReset" icon="reload">重置</a-button>
                </a-space>
              </a-form-item>
            </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">
              <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" :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">
        <a-spin :spinning="loading">
          <div id="Efficiency" class="container" style="margin-bottom: 15px;">
@@ -69,16 +151,13 @@
<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 api from '@api/mdc'
  export default {
    // mixins: [JeecgListMixin],
    name: 'openRateFractionAnalysisMain',
    data() {
      return {
@@ -92,9 +171,17 @@
        TreeIDTwo: 2,
        deviceTypeDict: '',
        dates: [],
        equipmentTypeList: [],
        driveTypeList: [],
        device_level_list: [],
        device_importance_level_list: [],
        identifying: [],
        queryParam: {},
        queryParams: {},
        queryParams: {
          equipmentType: [],
          driveType: [],
          deviceLevel: []
        },
        queryParamEquip: {},
        queryParamPeople: {},
        efficiencyOptions: [
@@ -109,14 +196,16 @@
        dataList: [],
        url: {
          efficiencyList: '/mdc/efficiencyReport/utilizationRateSectionAnalyze',
          listByType: '/mdc/MdcUtilizationRate/getByType'
          listByType: '/mdc/MdcUtilizationRate/getByType',
          queryEquipmentType: '/mdc/mdcEquipmentType/queryEquipmentType'
        },
        tableHeads: [],
        XData: [0],
        YData: [0],
        isLazyRequest: '',// 是否开启懒加载
        requestAlldataSize: 8,// 总共请求的列表项数目
        everyRequestDataSize: 15// 每次请求的列表项数目
        requestAllDataSize: 8,// 总共请求的列表项数目
        everyRequestDataSize: 15,// 每次请求的列表项数目
        toggleSearchStatus:false
      }
    },
    props: { nodeTree: '', Type: '', nodePeople: '' },
@@ -124,13 +213,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.startTime = '00:00'
      this.queryParam.endTime = '08:00'
      this.queryParam.typeTree = '1'
      this.loadData1()
      this.searchReset()
      this.queryGroup()
      this.getDriveTypeByApi()
      this.initDictData('device_level')
      this.initDictData('device_importance_level')
    },
    mounted() {
@@ -182,22 +269,69 @@
      }
    },
    methods: {
      moment,
      onChangeStart(time, timeString) {
        this.queryParam.startTime = timeString
        // console.log(time, timeString);
      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
            })
          }
        })
      },
      onChangeEnd(time, timeString) {
        this.queryParam.endTime = timeString
        // console.log(time, timeString);
      // 调用接口获取控制系统类型
      getDriveTypeByApi() {
        api.getDriveTypeApi().then((res) => {
          if (res.success) this.driveTypeList = res.result
        })
      },
      numBerTwo(value) {
        if (value) {
          return parseFloat((value * 100).toFixed(2))
        } else {
          return '0'
      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
          }
        })
      },
      loadData() {
        this.loading = true
        this.tableHeads = []
        this.dataList = []
        // 若日期选择器设置的查询请求数量超过15条则开启懒加载
        if (this.requestAllDataSize > 15) {
          // 开启懒加载后将结束日期设置为开始日期之后的14天,即先查询15天内的数据
          this.queryParam.endDate = moment(this.queryParam.startDate).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD')
          this.isLazyRequest = true
          this.tableScroll.removeEventListener('scroll', this.tableScrollX) // 为避免滚动条有滚动距离后后点击查询按钮触发滚动事件,因此在触发事件前移除事件
        }
        getAction(this.url.efficiencyList, this.queryParam).then(res => {
          if (res.success) {
            this.tableHeads = res.result.dates
            this.dataList = res.result.mdcEfficiencyList
            this.draw()
            this.tableScroll.addEventListener('scroll', this.tableScrollX)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      TableDraw(key, val) {
        this.XData = [0]
        this.YData[0]
@@ -209,63 +343,10 @@
        }
        this.XData = Xarr
        this.YData = Yarr
        // if(this.openRateTrendAnalysisChart !=null && this.openRateTrendAnalysisChart != '' && this.openRateTrendAnalysisChart != undefined){
        //     this.openRateTrendAnalysisChart.dispose()
        // }
        this.draw()
      },
      //Can not slect days before today and today
      disabledDate(current) {
        return current && current > moment().subtract('days', 1)
      },
      dateParamChange(v1, v2) {
        this.queryParam.startDate = v2[0]
        this.queryParam.endDate = v2[1]
        this.dates = [v1[0], v1[1]]
      },
      searchQuery() {
        // 因触底刷新会修改参数时间值,故在此用时间选择器的时间值对参数时间值再次赋值,若不这样做则参数时间值则会与时间选择器上的时间值不一致
        this.queryParam.startDate = moment(this.dates[0]).format('YYYYMMDD')
        this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
        if (this.queryParam.typeTree == '1') {
          this.queryParam.parentId = this.queryParamEquip.parentId
          this.queryParam.equipmentId = this.queryParamEquip.equipmentId
        } else {
          this.queryParam.parentId = this.queryParamPeople.parentId
          this.queryParam.equipmentId = ''
        }
        this.requestAlldataSize = moment.duration(moment(this.queryParam.endDate) - moment(this.queryParam.startDate), 'millisecond').asDays() + 1
        this.loadData1()
      },
      loadData1() {
        this.loading = true
        this.tableHeads = []
        this.dataList = []
        // 若日期选择器设置的查询请求数量超过15条则开启懒加载
        if (this.requestAlldataSize > 15) {
          // 开启懒加载后将结束日期设置为开始日期之后的14天,即先查询15天内的数据
          this.queryParam.endDate = moment(this.queryParam.startDate).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD')
          this.isLazyRequest = true
          this.tableScroll.removeEventListener('scroll', this.tableScrollX) // 为避免滚动条有滚动距离后后点击查询按钮触发滚动事件,因此在触发事件前移除事件
        }
        getAction(this.url.efficiencyList, this.queryParam).then(res => {
          if (res.success) {
            this.tableHeads = res.result.dates
            this.dataList = res.result.mdcEfficiencyList
            this.draw()
            // this.checkSameData(this.dataList)
            // this.checkSameData1(this.dataList)
            // this.checkSameData2(this.dataList)
            // this.combineCell();
            // this.initDeviceType(this.dataList)
            this.tableScroll.addEventListener('scroll', this.tableScrollX)
          }
        }).finally(() => {
          this.loading = false
        })
      },
      draw() {
        this.openRateTrendAnalysisChart = this.$echarts.init(document.getElementById('openRateTrendChart'), 'macarons')
        let openRateTrendChartOptions = {
@@ -325,6 +406,80 @@
        this.openRateTrendAnalysisChart.setOption(openRateTrendChartOptions, true)
      },
      searchQuery() {
        // 因触底刷新会修改参数时间值,故在此用时间选择器的时间值对参数时间值再次赋值,若不这样做则参数时间值则会与时间选择器上的时间值不一致
        this.queryParam.startDate = moment(this.dates[0]).format('YYYYMMDD')
        this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
        if (this.queryParam.typeTree == '1') {
          this.queryParam.parentId = this.queryParamEquip.parentId
          this.queryParam.equipmentId = this.queryParamEquip.equipmentId
        } else {
          this.queryParam.parentId = this.queryParamPeople.parentId
          this.queryParam.equipmentId = ''
        }
        this.requestAllDataSize = moment.duration(moment(this.queryParam.endDate) - moment(this.queryParam.startDate), 'millisecond').asDays() + 1
        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()
      },
      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.startTime = '00:00'
        this.queryParam.endTime = '08:00'
        this.queryParam.typeTree = '1'
        this.loadData()
      },
      selectChange(value, key) {
        this.queryParams[key] = value
      },
      onChangeStart(time, timeString) {
        this.queryParam.startTime = timeString
        // console.log(time, timeString);
      },
      onChangeEnd(time, timeString) {
        this.queryParam.endTime = timeString
        // console.log(time, timeString);
      },
      numBerTwo(value) {
        if (value) {
          return parseFloat((value * 100).toFixed(2))
        } else {
          return '0'
        }
      },
      //Can not slect days before today and today
      disabledDate(current) {
        return current && current > moment().subtract('days', 1)
      },
      dateParamChange(v1, v2) {
        this.queryParam.startDate = v2[0]
        this.queryParam.endDate = v2[1]
        this.dates = [v1[0], v1[1]]
      },
      moment,
      /**
       * 滚动条触底刷新表格数据
       */