zhangherong
2025-03-07 36e8795b59c7f7393758ca96e0c2438eddaee8be
src/views/mdc/base/modules/openRateTrendAnalysis/openRateTrendAnalysisMain.vue
@@ -5,14 +5,97 @@
      <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="3" :sm="3" :xs="3">
            <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>
@@ -65,16 +148,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 { ajaxGetDictItems, getDictItemsFromCache } from '@/api/api'
import api from '@api/mdc'
  export default {
    // mixins: [JeecgListMixin],
    name: 'openRateTrendAnalysisMain',
    components: {},
    data() {
@@ -89,9 +169,17 @@
        TreeIDTwo: 2,
        deviceTypeDict: '',
        dates: [],
      equipmentTypeList: [],
      driveTypeList: [],
      device_level_list: [],
      device_importance_level_list: [],
        identifying: [],
        queryParam: {},
        queryParams: {},
      queryParams: {
        equipmentType: [],
        driveType: [],
        deviceLevel: []
      },
        queryParamEquip: {},
        queryParamPeople: {},
        efficiencyOptions: [
@@ -106,14 +194,16 @@
        dataList: [],
        url: {
          efficiencyList: '/mdc/efficiencyReport/utilizationRateTrendAnalyze',
          listByType: '/mdc/MdcUtilizationRate/getByType'
        listByType: '/mdc/MdcUtilizationRate/getByType',
        queryEquipmentType: '/mdc/mdcEquipmentType/queryEquipmentType'
        },
        tableHeads: [],
        XData: [0],
        YData: [0],
        isLazyRequest: '',// 是否开启懒加载
        requestAlldataSize: 8,// 总共请求的列表项数目
        everyRequestDataSize: 15// 每次请求的列表项数目
      everyRequestDataSize: 15,// 每次请求的列表项数目
      toggleSearchStatus: false
      }
    },
    props: { nodeTree: '', Type: '', nodePeople: '' },
@@ -121,11 +211,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.tableScroll = document.querySelector('.table2')
@@ -176,151 +266,47 @@
      }
    },
    methods: {
      numBerTwo(value) {
        if (value) {
          return parseFloat((value * 100).toFixed(2))
        } else {
          return '0'
        }
      },
      TableDraw(key, val) {
        this.XData = [0]
        this.YData[0]
        var Xarr = []
        var Yarr = []
        for (var i = 0; i < val.dataList.length; i++) {
          Xarr.push(val.dataList[i].theDate)
          Yarr.push(this.numBerTwo(val.dataList[i].utilizationRate))
        }
        this.XData = Xarr
        this.YData = Yarr
        // if(this.openRateTrendAnalysisChart !=null && this.openRateTrendAnalysisChart != '' && this.openRateTrendAnalysisChart != undefined){
        //     this.openRateTrendAnalysisChart.dispose()
        // }
        this.draw()
      },
      disabledDate(current) {
        //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) => {
    queryGroup() {
      getAction(this.url.queryEquipmentType).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
                    }
                  }
          this.equipmentTypeList = res.result.map(item => {
            return {
              label: item.equipmentTypeName,
              value: item.equipmentTypeName
                }
              })
            }
          }
        }
      },
      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.$notification.warning({
            message: '消息',
            description: res.message
          })
        }
        this.requestAlldataSize = moment.duration(moment(this.queryParam.endDate) - moment(this.queryParam.startDate), 'millisecond').asDays() + 1
        this.loadData1()
      })
      },
      // searchReset() {
      //   this.typeTree = this.queryParam.typeTree
      //   this.typeParent =  this.queryParam.parentId
      //   this.typeEquipment = this.queryParam.equipmentId
      //   this.queryParam = {}
      //   this.dates = []
      //   this.queryParam.typeTree = this.typeTree
      //   this.queryParam.parentId = this.typeParent
      //   this.queryParam.equipmentId =  this.typeEquipment
      //   // this.ipagination.current = 1
      //   this.loadData1();
      //   // this.queryParam = {}
      //   // this.dates = []
      //   // this.loadData()
      //   // this.onClearSelected()
      // },
      // loadData1() {
      //   let that = this
      //   that.columns=[
      //     {
      //       title: '设备编号',
      //       align: 'center',
      //       dataIndex: 'equipmentId',
      //       width:'150px'
      //     },
      //     {
      //       title: '设备名称',
      //       align: 'center',
      //       dataIndex: 'equipmentName',
      //       width:'150px'
      //     },
      //   ]
      //   that.tableHeads = []
      //   that.dataList = []
      //   getAction(this.url.efficiencyList, that.queryParam).then(res => {
      //     var tmp = {}
      //     console.log(res)
      //     if (res.success)
      //
      //       that.dataSource = res.result.mdcEfficiencyList
      //       for(var k = 0;k<that.dataSource[0].dataList.length;k++){
      //         that.columns.push(
      //           {
      //             title:that.dataSource[0].dataList.theDate,
      //             align: 'center',
      //             width:'120px',
      //             // dataIndex:'utilizationRate',
      //           }
      //         )
      //       }
      //       for(var i = 0;i<that.dataSource.length;i++){
      //         for (var j = 0; j < that.dataSource[i].dataList.length;j++){
      //           // that.columns.push(
      //           //   {
      //           //     title:that.dataSource[0].dataList[j].theDate,
      //           //     align: 'center',
      //           //     width:'120px',
      //           //     dataIndex:'utilizationRate',
      //           //   }
      //           // )
      //         }
      //
      //       }
      //       console.log(that.columns)
      //       console.log(that.dataSource)
      //       // this.initDeviceType(this.dataList)
      //       this.draw()
      //     }
      //   }
      loadData1() {
    // 调用接口获取控制系统类型
    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
        }
      })
    },
    loadData() {
        this.loading = true
        this.tableHeads = []
        this.dataList = []
@@ -336,17 +322,64 @@
            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
        })
      },
    TableDraw(key, val) {
      this.XData = [0]
      this.YData[0]
      var Xarr = []
      var Yarr = []
      for (var i = 0; i < val.dataList.length; i++) {
        Xarr.push(val.dataList[i].theDate)
        Yarr.push(this.numBerTwo(val.dataList[i].utilizationRate))
      }
      this.XData = Xarr
      this.YData = Yarr
      this.draw()
    },
    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.loadData()
    },
      draw() {
        this.openRateTrendAnalysisChart = this.$echarts.init(document.getElementById('openRateTrendChart'), 'macarons')
        let openRateTrendChartOptions = {
@@ -406,6 +439,29 @@
        this.openRateTrendAnalysisChart.setOption(openRateTrendChartOptions, true)
      },
    selectChange(value, key) {
      this.queryParams[key] = value
    },
    numBerTwo(value) {
      if (value) {
        return parseFloat((value * 100).toFixed(2))
      } else {
        return '0'
      }
    },
    disabledDate(current) {
      //Can not slect days before today and today
      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]]
    },
      /**
       * 滚动条触底刷新表格数据
       */