<template>
  <div id="main" class="h-all">
    <el-container class="h-all">
      <el-header height="auto">
        <!-- 条件查询工具栏 -->
        <div class="header-search">
          <div class="search-input-box">
            <label>{{$t("Performance.startTime") + '：'}}</label>
            <el-date-picker
              v-model="beginTimestamp"
              type="datetime"
              size="mini"
              format="yyyy-MM-dd HH:mm"
              :clearable="false"
              align="center"
              :picker-options="startDatePicker"
              @change="beginDateChange"
              :placeholder="$t('Performance.startTimePlaceholder')">
            </el-date-picker>
          </div>
          <div class="search-input-box">
            <label>{{$t("Performance.endTime") + '：'}}</label>
            <el-date-picker
              v-model="endTimestamp"
              type="datetime"
              size="mini"
              format="yyyy-MM-dd HH:mm"
              :clearable="false"
              align="center"
              :picker-options="endDatePicker"
              @change="endDateChange"
              :placeholder="$t('Performance.endTimePlaceholder')">
            </el-date-picker>
          </div>
          <div class="search-input-box">
            <label>{{$t("Performance.networkElementType") + '：'}}</label>
            <el-select v-model="deviceType"
                       size="mini"
                       :placeholder="$t('common.selectOption')"
                       @change="deviceTypeChange"
                       :clearable="true">
              <el-option
                v-for="item in deviceTypeList"
                :key="item.deviceTypeKey"
                :label="item.deviceTypeName"
                :value="item.deviceTypeKey">
              </el-option>
            </el-select>
          </div>
          <div class="search-input-box">
            <label>{{$t("Performance.deviceModel") + '：'}}</label>
            <el-select v-model="deviceModel"
                       size="mini"
                       @change="deviceModelChange"
                       :placeholder="$t('common.selectOption')"
                       :clearable="true">
              <el-option v-for="item in deviceModelList"
                         :key="item.deviceModelKey"
                         :label="item.deviceModel"
                         :value="item.deviceModel">
              </el-option>
            </el-select>
          </div>
          <div class="search-input-box">
            <label>{{$t("Performance.networkElementName") + '：'}}</label>
            <el-select v-model="queryDeviceList" size="mini" :placeholder="$t('common.selectOption')"
                       :disabled="queryDeviceShow" :clearable="true">
              <el-option
                v-for="item in deviceList"
                :key="item.deviceKey"
                :label="item.displayName"
                :value="item.deviceKey">
              </el-option>
            </el-select>
          </div>
          <div class="search-input-box">
            <label>{{$t("Performance.performanceEvent") + '：'}}</label>
            <el-select v-model="queryPerformType" size="mini" :placeholder="$t('common.selectOption')" :clearable="true">
              <el-option
                v-for="item in performTypeList"
                :key="item.deviceParam"
                :label="item.peformTypeName"
                :value="item.deviceParam">
              </el-option>
            </el-select>
          </div>
          <div class="search-input-box">
            <label>{{$t("Performance.subnet") + '：'}}</label>
            <el-select v-model="querySubnet" size="mini" :placeholder="$t('common.selectOption')" :clearable="true">
              <el-option
                v-for="item in subnetList"
                :key="item.subnetKey"
                :label="item.subnetName"
                :value="item.subnetKey">
              </el-option>
            </el-select>
          </div>
          <div class="search-input-box">
            <el-button size='mini' icon="el-icon-search" type="primary" @click="queryPerformDataByCondition">{{$t("common.queryBtn")}}</el-button>
<!--            <el-button size='mini' icon="el-icon-download" type="success" @click="exportToExcelInit">{{$t("common.exportBtn")}}</el-button>-->
            <el-button size='mini' icon="el-icon-download" type="success" @click="downloadInit = true">{{$t('common.exportBtn')}}
            </el-button>
          </div>
        </div>
      </el-header>
      <!-- table数据表格 -->
      <el-main class="adapt-height-box">
        <el-table
          :empty-text="$t('common.noData')"
          ref="multipleTable"
          :data="performList"
          header-row-class-name="table-header"
          cell-class-name="table-cell"
          class="adapt-height"
          stripe
          tooltip-effect="dark"
          :highlight-current-row="true"
          height="auto"
          border
          @selection-change="handleSelectionChange">
          <el-table-column
            type="index"
            :label="$t('Performance.index')"
            width="50">
          </el-table-column>
          <el-table-column
            prop="timestamp"
            :label="$t('Performance.acquisitionTime')"
            :formatter="formatDate"
            :show-overflow-tooltip="true">
          </el-table-column>
          <!--<el-table-column-->
            <!--prop="deviceParam"-->
            <!--:label="$t('Performance.performanceEvent')"-->
            <!--:show-overflow-tooltip="true">-->
          <!--</el-table-column>-->
          <el-table-column
            prop="performName"
            :label="$t('Performance.performanceEvent')"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="resourceName"
            :label="$t('Performance.resourceName')"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="displayName"
            :label="$t('Performance.networkElementName')"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="deviceTypeKey"
            :label="$t('Performance.networkElementType')"
            width="180"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="deviceModel"
            :label="$t('Performance.deviceModel')"
            width="180"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="period"
            :label="$t('Performance.monitoringPeriod') + '(min)'"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="performValue"
            :label="$t('Performance.monitoringValue')"
            :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column
            prop="unit"
            :label="$t('Performance.unit')"
            :show-overflow-tooltip="true">
          </el-table-column>
        </el-table>
        <el-pagination
          background
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper"
          :total="total">
        </el-pagination>
      </el-main>
    </el-container>
    <el-dialog
      v-dialogDrag
      title="导出文件格式选择"
      :visible.sync="downloadInit"
      width="400px"
      height="360px"
      style="font-size: 20px; "
    >
      <div>
        <el-radio-group v-model="radio1"  size="mini">
          <el-radio label="excel表格" border>excel</el-radio>
          <el-radio label="csv" border>csv</el-radio>
        </el-radio-group>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" icon='el-icon-circle-check' @click="exportToInit" size="mini">{{$t("common.ok")}}</el-button>
        <el-button icon='el-icon-circle-close' @click="downloadCancle" size="mini">{{$t("common.cancel")}}</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import DeviceService from '../../domain/services/DeviceService'
import PerformanceMonitorService from '../../domain/services/PerformanceMonitorService'
import PerformanceDataQuaryService from '../../domain/services/PerformanceDataQuaryService'
import DeviceManager from '../../domain/models/DeviceManager'
import HelperUtil from '../../utils/HelperUtil'
import loading from "../../utils/Loading";
import SubnetService from "../../domain/services/SubnetService";
import IndexTeplateService from "../../domain/services/IndexTeplateService";

export default {
  name: 'PerformanceDataQuery',
  // 创建期间
  beforeCreate () {

  },
  // vue加载初始化函数，加载数据
  created: function () {
    this.setDefaultDateTime()
    this.getAllSubnetInit()
    this.getAllDevice()
    this.getAllPerformType()
    this.getAllDeviceModel()
    this.getAllDeviceType()

    if (this.$route.params.performList != null) {
      // this.TurnFromCollectTask(this.$route.query.collectTask)
      this.performList = this.$route.params.performList
      this.total = this.performList.length
    }
    if (this.$route.query.performTemplateName == null) {
      // this.getAllIndexTemplate()
    }
  },

  // 存放数据
  data: function () {
    return {
      deviceKeyShow: true,
      downloadInit: false,
      radio1: 'excel表格',

      // 日期控件
      beginTimestamp: '', // 开始时间
      endTimestamp: '', // 结束时间
      addBeginTimestamp: '00.000', // 查询开始时间默认添加
      addEndTimestamp: '59.999', // 查询结束时间默认添加
      startDatePicker: this.beginDate(),
      endDatePicker: this.endDate(),

      // 查询条件控件
      queryDeviceOptions: [], // 设备名称
      queryDeviceShow: false, // 设备名称选择器是否禁用
      deviceKey: '', // 设备ID（对应设备名称）（下拉列表）
      deviceTypeKey: '',
      deviceParam: '',
      deviceCollection: {}, // 设备collection

      performTypeList: [],
      performTypeList1: [], // 全部性能事件
      performTypeCollection: {},
      queryPerformTypeOptions: [], // 性能事件选项
      deviceType: '',
      deviceModel: '',
      queryDeviceList: '',
      queryPerformType: '',
      querySubnet: '',
      // 双向绑定展示数据
      performList: [],
      subnetList: [],
      // 查询条件List
      selectList: [],
      deviceList: [],
      deviceList0: [], // 设备列表
      deviceTypeList: [],
      deviceModelList: [],
      deviceModelList0: [],
      deviceModelList1: [],

      // 多选分页控制
      multipleSelection: [],
      beginItem: 1,
      endItem: 100,
      total: 0,
      currentPage: 1,
      pageSize: 100
    }
  },
  methods: {
    /**
     * @Description  : TurnFromCOlectTask
     * @author       : ls
     * @date         : 2021/3/29 16:26
     * @param        :
     * @return       :
     */
    TurnFromCollectTask: function (val) {
      let _this = this
      PerformanceDataQuaryService.queryPerformTaskData(val).then(result => {
        _this.performList = Object.values(result)
        if (_this.performList.length === 0) {
          this.InfoTip.warningTip(_this, HelperUtil.getCheckStatusCodeObjectByCode(_this.successCode.QUERY_NULL_CODE))
        } else {
          this.InfoTip.successTip(_this, HelperUtil.getStatusCodeObjectByCode(_this.successCode.QUERY_CODE))
        }
      }).catch(err => {
        this.InfoTip.errorTip(_this, err)
      })
    },
    /**
     * @Description  : exportToInit
     * @author       : ls
     * @date         : 2021/3/29 16:25
     * @param        :
     * @return       :
     */
    exportToInit: function () {
      switch (this.radio1) {
        case 'excel表格':
          this.exportToExcel()
          break
        case 'csv':
          this.exportToCsv()
          break
        default:
          this.exportToExcel()
      }
    },

    // 导出格式为excel
    exportToExcel: function () {
      this.downloadInit = false
      let _this = this
      this.setQuerySelectList()
      let loadingInstance = _this.Loading.openLoading()
      PerformanceDataQuaryService.exportToExcel(this.selectList).then(result => {
        // 成功
        this.radio1 = 'excel表格'
        _this.Loading.closeLoading(loadingInstance)
      }).catch(err => {
        // 失败
        _this.Loading.closeLoading(loadingInstance)
        _this.InfoTip.errorTip(_this, err)
      })
    },

    // 导出格式为csv
    exportToCsv: function () {
      this.downloadInit = false
      let _this = this
      this.setQuerySelectList()
      let loadingInstance = _this.Loading.openLoading()
      PerformanceDataQuaryService.downloadPerformCsv(this.selectList).then(result => {
        // 成功
        this.radio1 = 'excel表格'
        _this.Loading.closeLoading(loadingInstance)
      }).catch(err => {
        // 失败
        _this.Loading.closeLoading(loadingInstance)
        _this.InfoTip.errorTip(_this, err)
      })
    },

    downloadCancle: function () {
      this.downloadInit = false
      this.radio1 = 'excel表格'
    },

    /***
       * @Description  : 检测时间合法
       * @author       : zf
       * @date         : 2019/1/21 13:37
       */
    // 设置禁止选择当前日期之后的时间，且开始时间小于结束时间
    beginDate: function () {
      let self = this
      return {
        disabledDate (time) {
          return time.getTime() > self.endTimestamp.getTime() || time.getTime() > Date.now()
        }
      }
    },
    // 结束时间必须大于开始时间
    endDate: function () {
      let self = this
      return {
        disabledDate (time) {
          return time.getTime() < (self.beginTimestamp.getTime() - 1000 * 3600 * 24) || time.getTime() > Date.now()
        }
      }
    },
    // 开始时间被清空后重新赋值
    beginDateChange: function () {
      const setTimes = new Date()
      if (this.beginTimestamp === null) {
        setTimes.setTime(this.endTimestamp.getTime() - (60 * 60 * 1000))
        this.beginTimestamp = setTimes
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.START_TIME_EMPTY_CODE))
      }
      if (this.beginTimestamp > this.endTimestamp) {
        setTimes.setTime(this.endTimestamp.getTime() - (60 * 60 * 1000))
        this.beginTimestamp = setTimes
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.START_END_TIME_CODE))
      }
      // if ((this.endTimestamp.getTime() - this.beginTimestamp.getTime()) > 24 * 60 * 60 * 1000) {
      //   setTimes.setTime(this.beginTimestamp.getTime() + (24 * 60 * 60 * 1000));
      //   this.endTimestamp = setTimes;
      //   this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PERIOD_TIME_CODE))
      // }
    },
    // 结束时间被清空后重新赋值
    endDateChange: function () {
      const setTimes = new Date()
      const curTimes = new Date()
      if (this.endTimestamp === null) {
        if ((this.beginTimestamp.getTime() + (60 * 60 * 1000)) > curTimes.getTime()) {
          this.endTimestamp = curTimes
        } else {
          setTimes.setTime(this.beginTimestamp.getTime() + (60 * 60 * 1000))
          this.endTimestamp = setTimes
        }
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.END_TIME_EMPTY_CODE))
      }
      if (this.endTimestamp < this.beginTimestamp) {
        if ((this.beginTimestamp.getTime() + (60 * 60 * 1000)) > curTimes.getTime()) {
          this.endTimestamp = curTimes
        } else {
          setTimes.setTime(this.beginTimestamp.getTime() + (60 * 60 * 1000))
          this.endTimestamp = setTimes
        }
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.START_END_TIME_CODE))
      }
      if (this.endTimestamp > curTimes) {
        if ((this.beginTimestamp.getTime() + (60 * 60 * 1000)) > curTimes.getTime()) {
          this.endTimestamp = curTimes
        } else {
          setTimes.setTime(this.beginTimestamp.getTime() + (60 * 60 * 1000))
          this.endTimestamp = setTimes
        }
        this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.END_TIME_CURRENT_CODE))
      }
      // if ((this.endTimestamp.getTime() - this.beginTimestamp.getTime()) >  24 * 3600 * 1000) {
      //   setTimes.setTime(this.endTimestamp.getTime() - (24 * 60 * 60 * 1000));
      //   this.beginTimestamp = setTimes;
      //   this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.PERIOD_TIME_CODE))
      // }
    },
    /**
     * @Description  : 格式化日期
     * @author       : ls
     * @date         : 2020/6/24 16:28
     * @param        :
     * @return       :
     */
    formatDate: function (row) {
      return HelperUtil.timeTran(row.timestamp)
    },

    /* ---------------------------初始化页面数据--------------------------- */

    /***
       * @Description  : 获取默认时间
       * @author       : zf
       * @date         : 2019/1/4 11:32
       */
    setDefaultDateTime: function () {
      const start = new Date()
      const end = new Date()
      start.setTime(start.getTime() - 3600 * 1000)
      this.beginTimestamp = start
      this.endTimestamp = end
    },
    /**
     * @Description  : deviceTypeChange
     * @author       : ls
     * @date         : 2020/11/17 23:48
     * @param        :
     * @return       :
     */
    deviceTypeChange: function () {
      var a = HelperUtil.deviceTypeChangeDevice(this.deviceModelList1, this.deviceType, this.deviceModel, this.deviceList0)
      this.deviceModelList = a[0]
      this.deviceModel = a[1]
      this.queryDeviceList = ''
      this.deviceList = []
      this.deviceList = a[2]


      // this.deviceModel = ''
      // this.queryDeviceName = ''
      // this.deviceModelList = []
      // this.deviceList = []
      // for (let j in this.deviceModelList0) {
      //   if (this.deviceType === null) {
      //     this.deviceModelList.push(this.deviceModelList0[j])
      //   } else {
      //     if (this.deviceModelList0[j]['deviceTypeKey'] === this.deviceType) {
      //       this.deviceModelList.push(this.deviceModelList0[j])
      //     }
      //   }
      // }
      // for (let i in this.deviceList0) {
      //   if (this.deviceType === null) {
      //     this.deviceList.push(this.deviceList0[i])
      //   } else {
      //     if (this.deviceType === this.deviceList0[i].deviceTypeKey) {
      //       this.deviceList.push(this.deviceList0[i])
      //     }
      //   }
      // }
    },
    /**
     * @Description  : deviceModelChange
     * @author       : ls
     * @date         : 2020/11/17 23:48
     * @param        :
     * @return       :
     */
    deviceModelChange: function () {
      this.queryDeviceList = ''
      this.deviceList = []
      this.deviceList = HelperUtil.deviceModelChange(this.deviceType, this.deviceModel, this.deviceList0)

      //
      // this.queryDeviceName = ''
      // this.deviceList = []
      // for (let k in this.deviceList0) {
      //   if (this.deviceModel === null) {
      //     if (this.deviceType === null) {
      //       this.deviceList.push(this.deviceList0[k])
      //     }
      //   } else {
      //     if (this.deviceModel === this.deviceList0[k]['deviceModel']) {
      //       if (this.deviceType === null) {
      //         this.deviceList.push(this.deviceList0[k])
      //       } else {
      //         if (this.deviceType === this.deviceList0[k]['deviceTypeKey']) {
      //           this.deviceList.push(this.deviceList0[k])
      //         }
      //       }
      //     }
      //   }
      // }
    },
    /**
     * @Description  : getAllDeviceType
     * @author       : ls
     * @date         : 2020/11/18 0:46
     * @param        :
     * @return       :
     */
    getAllDeviceType: function () {
      let _this = this
      DeviceService.getAllDeviceTypeCollection().then(result => {
        _this.deviceTypeList = Object.values(result)
      }).catch(err => {
        _this.InfoTip.errorTip(_this, err)
      })
    },
    /**
     * @description   : 获取子网
     * @author        : ls
     * @date          : 2020/6/22 20:52
     * @param         :
     * @return        :
     **/
    getAllSubnetInit: function () {
      let _this = this
      let loadingInstance = loading.openLoading()
      SubnetService.getAllSubnetCollection().then(result => {
        _this.subnetList = Object.values(result)
        loadingInstance.close()
      }).catch(err => {
        this.InfoTip.errorTip(this, err)
        loadingInstance.close()
      })
    },
    /***
       * @Description  : 设备/服务器下拉列表
       * @author       : zf
       * @date         : 2018/12/24 11:29
       */
    getAllDevice: function () {
      let _this = this
      this.deviceList0 = []
      DeviceService.getAllDeviceCollection().then(result => {
        // 成功
        _this.deviceCollection = result
        _this.deviceList = Object.values(result) // 新加字段，用于formatter查询数据表格
        let DevMgr = DeviceManager(_this.deviceCollection)
        _this.queryDeviceOptions = Object.values(DevMgr.getInUsingDeviceList())
        _this.deviceList0 = Object.values(DevMgr.getInUsingDeviceList())
        // _this.getAllDeviceModelListSelf()
      }).catch(err => {
        // 失败
        _this.InfoTip.errorTip(_this, err)
      })
    },
    /**
     * @Description  : getAllDeviceModelListSelf
     * @author       : ls
     * @date         : 2020/11/18 0:42
     * @param        :
     * @return       :
     */
    getAllDeviceModelListSelf: function () {
      for (let key in this.deviceList0) {
        let containIs = false
        for (let i in this.deviceModelList) {
          if (this.deviceList0[key].deviceModel === this.deviceModelList[i].value) {
            containIs = true
            break
          }
        }
        if (containIs === false && this.deviceList0[key].deviceModel !== '') {
          let device = {}
          device.key = key
          device.deviceTypeKey = this.deviceList0[key].deviceTypeKey
          device.label = this.deviceList0[key].deviceModel
          device.value = this.deviceList0[key].deviceModel
          this.deviceModelList.push(device)
          this.deviceModelList0.push(device)
        }
      }
    },
    /**
     * @Description  : 获取性能
     * @author       : ls
     * @date         : 2020/6/24 14:35
     * @param        :
     * @return       :
     */
    getAllPerformType: function () {
      let _this = this
      PerformanceMonitorService.getAllPerformanceTypeCollection().then(result => {
        // 成功
        _this.performTypeList = Object.values(result)
      }).catch(err => {
        // 失败
        _this.InfoTip.errorTip(_this, err)
      })
    },
    /**
     * @Description  : 获取型号
     * @author       : ls
     * @date         : 2020/6/24 14:34
     * @param        :
     * @return       :
     */
    getAllDeviceModel: function () {
      let _this = this
      DeviceService.getAllDeviceModelCollection().then(result => {
        _this.deviceModelList = Object.values(result)
        _this.deviceModelList1 = Object.values(result)
      }).catch(err => {
        _this.InfoTip.errorTip(_this, err)
      })
    },

    /* ---------------------------查询功能实现--------------------------- */

    /***
       * @Description  : 获取查询条件列表
       * @author       : zf
       * @date         : 2019/1/4 11:29
       */
    setQuerySelectList: function () {
      this.selectList = []
      if (this.beginTimestamp !== '' && this.beginTimestamp !== null) {
        this.selectList.push({
          quaryAttribute: 'timestamp',
          compareSymbol: '>=',
          compareValue: HelperUtil.getTimeInit(this.beginTimestamp) + this.addBeginTimestamp
        })
      }
      if (this.endTimestamp !== '' && this.endTimestamp !== null) {
        this.selectList.push({
          quaryAttribute: 'timestamp',
          compareSymbol: '<=',
          compareValue: HelperUtil.getTimeInit(this.endTimestamp) + this.addEndTimestamp
        })
      }
      if (this.queryDeviceList !== '' && this.queryDeviceList !== null) {
        this.selectList.push({
          quaryAttribute: 'deviceKey',
          compareSymbol: '=',
          compareValue: this.queryDeviceList
        })
      }
      if (this.queryPerformType !== '' && this.queryPerformType !== null) {
        this.selectList.push({
          quaryAttribute: 'deviceParam',
          compareSymbol: '=',
          compareValue: this.queryPerformType
        })
      }
      if (this.deviceType !== '' && this.deviceType !== null) {
        this.selectList.push({
          quaryAttribute: 'deviceTypeKey',
          compareSymbol: '=',
          compareValue: this.deviceType
        })
      }
      if (this.deviceModel !== '' && this.deviceModel !== null) {
        this.selectList.push({
          quaryAttribute: 'deviceModel',
          compareSymbol: '=',
          compareValue: this.deviceModel
        })
      }
      if (this.querySubnet !== '' && this.querySubnet !== null) {
        this.selectList.push({
          quaryAttribute: 'subnetKey',
          compareSymbol: '=',
          compareValue: this.querySubnet
        })
      }
    },
    /**
     * @Description  : 变化
     * @author       : ls
     * @date         : 2020/6/24 10:57
     * @param        :
     * @return       :
     */
    handleCurrentChange (val) {
      this.currentPage = val
      this.beginItem = ((val - 1) * 100) + 1
      this.endItem = this.beginItem + 99
      if (this.endItem > this.total) {
        this.endItem = this.total
      }
      this.queryPerformDataByConditionCurrentPage()
    },

    /***
       * @Description  : 点击查询按钮事件
       * @author       : zf
       * @date         : 2018/12/13 16:37
       */
    queryPerformDataByCondition: function () {
      this.beginItem = 1
      this.performList = []
      // this.nodeTypeDefineTable();
      this.setQuerySelectList()
      this.queryPerformDataTotalNumber()
    },

    /***
       * @Description  : 按条件查询性能数据总条数
       * @author       : zf
       * @date         : 2018/12/13 16:37
       */
    queryPerformDataTotalNumber: function () {
      let _this = this
      let loadingInstance = _this.Loading.openLoading()
      PerformanceDataQuaryService.queryPerformDataTotalNumber(this.selectList).then(result => {
        // 成功
        _this.Loading.closeLoading(loadingInstance)
        _this.total = result
        if (_this.total === 0 || _this.total < 0) {
          _this.InfoTip.warningTip_alarm(this, HelperUtil.getCheckStatusCodeObjectByCode(this.successCode.QUERY_NULL_CODE))
        } else {
          if (_this.total < 100 && _this.total > 0) {
            _this.endItem = _this.total
          } else {
            _this.endItem = 100
          }
        }
        _this.queryPerformDataByConditionCurrentPage()
      }).catch(err => {
        // 失败
        _this.endItem = 100
        _this.Loading.closeLoading(loadingInstance)
        _this.InfoTip.errorTip(_this, err)
      })
    },

    /***
       * @Description  : 获取当前分页性能列表
       * @author       : zf
       * @date         : 2018/12/20 20:17
       */
    queryPerformDataByConditionCurrentPage: function () {
      let _this = this
      let loadingInstance = _this.Loading.openLoading()
      PerformanceDataQuaryService.queryPerformDataSplitNumber(this.beginItem, this.endItem, this.selectList).then(result => {
        // 成功
        _this.performList = Object.values(result)
        _this.Loading.closeLoading(loadingInstance)
      }).catch(err => {
        // 失败
        _this.Loading.closeLoading(loadingInstance)
        _this.InfoTip.errorTip(_this, err)
      })
    },

    /* ---------------------------导出功能实现--------------------------- */

    /**
       * @Description  ：导出文件
       */
    exportToExcelInit: function () {
      this.setQuerySelectList()
      let _this = this
      let loadingInstance = _this.Loading.openLoading()
      PerformanceDataQuaryService.exportToExcel(this.selectList).then(result => {
        // 成功
        _this.Loading.closeLoading(loadingInstance)
      }).catch(err => {
        // 失败
        _this.Loading.closeLoading(loadingInstance)
        _this.InfoTip.errorTip(_this, err)
      })
    },

    /* ---------------------------留用--------------------------- */

    /***
       * @Description  : 多选框变化：未用
       * @author       : zf
       * @date         : 2019/1/4 11:33
       */
    handleSelectionChange (val) {
      this.multipleSelection = val
    }
  },

  computed: {},

  watch: {
    '$route' (to) {
      if (to.name === '性能查询' && to.params.performList !== undefined) {
        this.queryIndexTemplateName = to.query.collectTask
        // this.performList = this.$route.query.collectTask
        this.performList = this.$route.params.performList
        this.total = this.performList.length
      }
    },
    '$i18n.locale' () {

    }
  }
}
</script>

<style scoped>
</style>
