| | |
| | | </a-col> |
| | | <a-col :md="6" :sm="6"> |
| | | <a-form-item label="时间"> |
| | | <a-range-picker @change="dateParamChange" :disabledDate="disabledDate" format="YYYYMMDD" |
| | | <a-range-picker @change="dateParamChange" :disabledDate="disabledDate" |
| | | @calendarChange="handleCalendarChange" @openChange="handleCalendarOpenChange" |
| | | format="YYYYMMDD" |
| | | v-model="dates" :allowClear="false"/> |
| | | </a-form-item> |
| | | </a-col> |
| | |
| | | <a-button type="primary" @click="searchQuery" icon="search">查询</a-button> |
| | | <a-button type="primary" @click="searchReset" icon="reload">重置</a-button> |
| | | <a-button type="primary" @click="exportExcel" icon="download">导出</a-button> |
| | | <!--<a-button type="primary" @click="exportOneYearExcel('设备TEEP')" icon="download">大数据导出</a-button>--> |
| | | <a-button type="primary" @click="handleShowFeedbackModal" icon="plus" v-has="'efficiency:feedback'">异常反馈</a-button> |
| | | <a-button type="primary" @click="exportLongTimeExcel('设备TEEP')" icon="download" |
| | | :loading="longTimeExportButtonLoading"> |
| | | 大数据导出 |
| | | </a-button> |
| | | <a-button type="primary" @click="handleShowFeedbackModal" icon="plus" v-has="'efficiency:feedback'"> |
| | | 异常反馈 |
| | | </a-button> |
| | | <a-button type="primary" icon="printer" v-print="'#Efficiency'" |
| | | v-has="'efficiency:print'">打印 |
| | | </a-button> |
| | |
| | | list: '/mdc/efficiencyReport/efficiencyList', |
| | | listByType: '/mdc/MdcUtilizationRate/getByType', |
| | | queryEquipmentType: '/mdc/mdcEquipmentType/queryEquipmentType', |
| | | exportOneYearXlsUrl: '' |
| | | exportLongTimeXlsUrl: '/mdc/efficiencyReport/exportEfficiencyXls' |
| | | }, |
| | | tableHeads: [], |
| | | utilizationRateRowAverage: '', |
| | |
| | | requestAllDataSize: 8,// 总共请求的列表项数目(默认值为默认日期的差值+1) |
| | | everyRequestDataSize: 15,// 每次请求的列表项数目 |
| | | toggleSearchStatus: false, |
| | | modalVisible: false// 异常反馈弹窗是否弹出 |
| | | modalVisible: false,// 异常反馈弹窗是否弹出 |
| | | preSelectFirstDate: null, |
| | | longTimeExportButtonLoading: false |
| | | } |
| | | }, |
| | | props: { nodeTree: '', Type: '', nodePeople: '' }, |
| | |
| | | } |
| | | return list |
| | | }, |
| | | disabledDate(current) { |
| | | //Can not slect days before today and today |
| | | return current && current > moment().subtract('days', 1) |
| | | |
| | | dateParamChange(v1, v2) { |
| | | this.queryParam.startTime = v2[0] |
| | | this.queryParam.endTime = v2[1] |
| | | }, |
| | | |
| | | /** |
| | | * 时间选择器面板上的值发生改变时触发 |
| | | * @param dates 面板上的两个值组成的数组 |
| | | */ |
| | | handleCalendarChange(dates) { |
| | | if (dates.length === 1) this.preSelectFirstDate = dates[0] |
| | | }, |
| | | |
| | | /** |
| | | * 控制时间选择器面板开启与关闭 |
| | | * @param status 开启状态 |
| | | */ |
| | | handleCalendarOpenChange(status) { |
| | | if (status) this.preSelectFirstDate = null |
| | | }, |
| | | |
| | | /** |
| | | * 面板上禁止选择的日期 |
| | | * @param current 禁止的时间范围 |
| | | */ |
| | | disabledDate(current) { |
| | | if (!this.preSelectFirstDate) { |
| | | return current > moment().startOf('days') |
| | | } else { |
| | | return current < moment(this.preSelectFirstDate).subtract(365, 'days').startOf('days') |
| | | || current > moment().startOf('days') |
| | | || current > moment(this.preSelectFirstDate).add(365, 'days').endOf('days') |
| | | } |
| | | }, |
| | | |
| | | exportExcel() { |
| | | $('#Efficiency').table2excel({ |
| | | exclude: '.noExl', |
| | |
| | | exclude_inputs: false |
| | | }) |
| | | }, |
| | | exportOneYearExcel(fileName) { |
| | | // let param = this.getQueryParams() |
| | | // console.log('导出参数', param) |
| | | downFile(this.url.exportOneYearXlsUrl) |
| | | exportLongTimeExcel(fileName) { |
| | | let param = { |
| | | startTime: moment(this.dates[0]).format('YYYYMMDD'), |
| | | endTime: moment(this.dates[1]).format('YYYYMMDD') |
| | | } |
| | | Object.keys(this.queryParams).forEach(item => { |
| | | if (Array.isArray(this.queryParams[item])) { |
| | | param[item] = this.queryParams[item].join() |
| | | // 此处为保证接口参数不多余,可省略 |
| | | if (this.queryParams[item].length === 0) delete param[item] |
| | | } |
| | | }) |
| | | param = Object.assign({}, this.queryParam, param) |
| | | |
| | | this.longTimeExportButtonLoading = true |
| | | downFile(this.url.exportLongTimeXlsUrl, param) |
| | | .then((data) => { |
| | | if (!data) { |
| | | this.$notification.warning({ |
| | |
| | | return |
| | | } |
| | | if (typeof window.navigator.msSaveBlob !== 'undefined') { |
| | | window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls') |
| | | window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xlsx') |
| | | } 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') |
| | | link.setAttribute('download', fileName + '.xlsx') |
| | | document.body.appendChild(link) |
| | | link.click() |
| | | document.body.removeChild(link) //下载完成移除元素 |
| | | window.URL.revokeObjectURL(url) //释放掉blob对象 |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | let timer = setTimeout(() => { |
| | | this.longTimeExportButtonLoading = false |
| | | clearTimeout(timer) |
| | | timer = null |
| | | }, 1000) |
| | | }) |
| | | }, |
| | | showIdentifying() { |
| | |
| | | } |
| | | }) |
| | | }, |
| | | dateParamChange(v1, v2) { |
| | | this.queryParam.startTime = v2[0] |
| | | this.queryParam.endTime = v2[1] |
| | | this.dates = [v1[0], v1[1]] |
| | | }, |
| | | efficiencyOptionsOnChange(checkedList) { |
| | | this.checkedList = checkedList |
| | | }, |
| | | searchQuery() { |
| | | // 因触底刷新会修改参数时间值,故在此用时间选择器的时间值对参数时间值再次赋值,若不这样做则参数时间值则会与时间选择器上的时间值不一致 |
| | | this.queryParam.startTime = moment(this.dates[0]).format('YYYYMMDD') |
| | | this.queryParam.endTime = moment(this.dates[1]).format('YYYYMMDD') |
| | | |
| | | if (this.queryParam.typeTree == '1') { |
| | | this.queryParam.parentId = this.queryParamEquip.parentId |
| | | this.queryParam.equipmentId = this.queryParamEquip.equipmentId |
| | |
| | | this.tableHeads = [] |
| | | this.dataList = [] |
| | | this.spinning = true |
| | | console.log('requestAllDataSize', this.requestAllDataSize) |
| | | console.log('everyRequestDataSize', this.everyRequestDataSize) |
| | | // 若日期选择器设置的查询请求数量超过15条则开启懒加载 |
| | | if (this.requestAllDataSize > this.everyRequestDataSize) { |
| | | // 开启懒加载后将结束日期设置为开始日期之后的14天,即先查询15天内的数据 |
| | | this.queryParam.endTime = moment(this.queryParam.startTime).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD') |
| | | this.isLazyRequest = true |
| | | this.tableScroll.removeEventListener('scroll', this.tableScrollX) // 为避免滚动条有滚动距离后后点击查询按钮触发滚动事件,因此在触发事件前移除事件 |
| | | } |
| | | |
| | | getAction(this.url.list, this.queryParam).then(res => { |
| | | if (res.success) { |
| | |
| | | |
| | | this.tableHeads = res.result.dates |
| | | this.dataList = res.result.mdcEfficiencyList |
| | | console.log('dataList', this.dataList) |
| | | this.checkSameData(this.dataList) |
| | | this.checkSameData1(this.dataList) |
| | | this.checkSameData2(this.dataList) |
| | | this.combineCell() |
| | | this.tableScroll.addEventListener('scroll', this.tableScrollX) |
| | | } |
| | | }).finally(() => { |
| | | this.spinning = false |
| | |
| | | handleShowFeedbackModal() { |
| | | this.$refs.modalForm.formParams = {} |
| | | this.modalVisible = true |
| | | }, |
| | | |
| | | // 滚动条触底刷新表格数据 |
| | | tableScrollX() { |
| | | // 当滚动条触底且懒加载开启时触发滚动条触底刷新 |
| | | if (Math.ceil(this.tableScroll.scrollLeft + this.tableScroll.clientWidth) + 1 >= this.tableScroll.scrollWidth && this.isLazyRequest) { |
| | | this.spinning = true |
| | | this.queryParam.startTime = moment(this.queryParam.endTime).add(1, 'days').format('YYYYMMDD') |
| | | // 判断设置懒加载后的结束时间是否超过时间选择器中设置的结束时间 |
| | | if (moment(this.queryParam.endTime).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD') - moment(this.dates[1]).format('YYYYMMDD') < 0) { |
| | | //再次查询后15天内的数据 |
| | | this.queryParam.endTime = moment(this.queryParam.endTime).add(this.everyRequestDataSize, 'days').format('YYYYMMDD') |
| | | } else { |
| | | // 如果不小于时间选择器中设置的时间则设置请求结束日期为时间选择器中设置的结束时间并且关闭懒加载(意味着最后一次触底刷新) |
| | | this.queryParam.endTime = moment(this.dates[1]).format('YYYYMMDD') |
| | | this.isLazyRequest = false |
| | | } |
| | | getAction(this.url.list, this.queryParam) |
| | | .then(res => { |
| | | if (res.success) { |
| | | this.tableHeads = [...this.tableHeads.slice(0, -2), ...res.result.dates] |
| | | console.log('dataList', this.dataList) |
| | | this.dataList.forEach(item1 => { |
| | | res.result.mdcEfficiencyList.forEach(item2 => { |
| | | if (item1.equipmentId === item2.equipmentId) { |
| | | item1.dataList = [...item1.dataList.slice(0, -2), ...item2.dataList] |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | }) |
| | | .finally(() => { |
| | | this.spinning = false |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 获取设备类型列表 |