2025-10-20 13:25:30 +08:00
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<!--治理效果报表 -->
|
2025-11-07 10:32:55 +08:00
|
|
|
<TableHeader :showReset="false" datePicker @selectChange="selectChange" v-if="fullscreen">
|
2025-10-20 13:25:30 +08:00
|
|
|
<template v-slot:select>
|
|
|
|
|
<el-form-item label="治理对象">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="tableStore.table.params.power"
|
|
|
|
|
placeholder="请选择治理对象"
|
|
|
|
|
clearable
|
|
|
|
|
style="width: 130px"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in powerList"
|
|
|
|
|
:key="item.value"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
:value="item.value"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:operation>
|
|
|
|
|
<el-button @click="downloadExcel" class="" type="primary" icon="el-icon-Download">导出excel</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</TableHeader>
|
|
|
|
|
<div style="display: flex">
|
|
|
|
|
<div
|
|
|
|
|
id="luckysheet"
|
2025-10-24 16:17:40 +08:00
|
|
|
:style="{
|
|
|
|
|
width: `calc(${prop.width} )`,
|
|
|
|
|
height: `calc(${prop.height} - 57px + ${fullscreen ? 0 : 56}px)`
|
|
|
|
|
}"
|
2025-10-20 13:25:30 +08:00
|
|
|
></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup lang="ts">
|
2025-10-24 16:17:40 +08:00
|
|
|
import { ref, onMounted, provide, reactive, watch, h, computed } from 'vue'
|
2025-10-20 13:25:30 +08:00
|
|
|
import TableStore from '@/utils/tableStore'
|
|
|
|
|
import { exportExcel } from '@/views/govern/reportForms/export.js'
|
|
|
|
|
import TableHeader from '@/components/table/header/index.vue'
|
|
|
|
|
import { getTimeOfTheMonth } from '@/utils/formatTime'
|
|
|
|
|
import { useConfig } from '@/stores/config'
|
|
|
|
|
import Json from './index.json'
|
2025-11-07 10:32:55 +08:00
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
import { useTimeCacheStore } from '@/stores/timeCache'
|
2025-10-20 13:25:30 +08:00
|
|
|
|
|
|
|
|
const prop = defineProps({
|
2025-11-14 09:51:18 +08:00
|
|
|
w: { type: [String, Number]},
|
|
|
|
|
h: { type: [String, Number]},
|
|
|
|
|
width: { type: [String, Number]},
|
|
|
|
|
height: { type: [String, Number]},
|
|
|
|
|
timeKey: { type: [String, Number]},
|
2025-10-20 13:25:30 +08:00
|
|
|
timeValue: { type: Object }
|
|
|
|
|
})
|
|
|
|
|
const config = useConfig()
|
|
|
|
|
const powerList: any = ref([
|
|
|
|
|
{
|
|
|
|
|
label: '1#变压器',
|
|
|
|
|
value: '1'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
label: '2#变压器',
|
|
|
|
|
value: '2'
|
|
|
|
|
}
|
|
|
|
|
])
|
|
|
|
|
|
2025-11-07 10:32:55 +08:00
|
|
|
const route = useRoute()
|
|
|
|
|
const timeCacheStore = useTimeCacheStore()
|
|
|
|
|
|
2025-10-20 13:25:30 +08:00
|
|
|
const tableStore: any = new TableStore({
|
|
|
|
|
url: '/user-boot/role/selectRoleDetail?id=0',
|
|
|
|
|
method: 'POST',
|
|
|
|
|
|
|
|
|
|
showPage: false,
|
|
|
|
|
exportName: '主要监测点列表',
|
|
|
|
|
column: [],
|
|
|
|
|
beforeSearchFun: () => {
|
2025-11-07 10:32:55 +08:00
|
|
|
// 尝试从缓存获取时间值
|
|
|
|
|
let beginTime, endTime
|
|
|
|
|
|
|
|
|
|
if (fullscreen.value) {
|
|
|
|
|
const cached = timeCacheStore.getCache(route.path)
|
|
|
|
|
if (cached && cached.timeValue) {
|
|
|
|
|
beginTime = cached.timeValue[0]
|
|
|
|
|
endTime = cached.timeValue[1]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果缓存中没有则使用默认值
|
|
|
|
|
tableStore.table.params.searchBeginTime = beginTime || prop.timeValue?.[0] || getTimeOfTheMonth(prop.timeKey)[0]
|
|
|
|
|
tableStore.table.params.searchEndTime = endTime || prop.timeValue?.[1] || getTimeOfTheMonth(prop.timeKey)[1]
|
2025-10-20 13:25:30 +08:00
|
|
|
},
|
|
|
|
|
loadCallback: () => {}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const tableRef = ref()
|
|
|
|
|
provide('tableRef', tableRef)
|
|
|
|
|
tableStore.table.params.power = '1'
|
|
|
|
|
|
|
|
|
|
provide('tableStore', tableStore)
|
|
|
|
|
// 下载表格
|
|
|
|
|
const downloadExcel = () => {
|
|
|
|
|
exportExcel(luckysheet.getAllSheets(), '治理效果报表')
|
|
|
|
|
}
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
luckysheet.create({
|
|
|
|
|
container: 'luckysheet',
|
|
|
|
|
title: '', // 表 头名
|
|
|
|
|
lang: 'zh', // 中文
|
|
|
|
|
showtoolbar: false, // 是否显示工具栏
|
|
|
|
|
showinfobar: false, // 是否显示顶部信息栏
|
|
|
|
|
showsheetbar: true, // 是否显示底部sheet按钮
|
|
|
|
|
allowEdit: false, // 禁止所有编辑操作(必填)
|
|
|
|
|
data: Json
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
})
|
2025-11-07 10:32:55 +08:00
|
|
|
|
|
|
|
|
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
|
|
|
|
|
// 如果有传入 datePicker 的值
|
|
|
|
|
if (datePickerValue) {
|
|
|
|
|
// 更新表格参数
|
|
|
|
|
tableStore.table.params.searchBeginTime = datePickerValue.timeValue?.[0]
|
|
|
|
|
tableStore.table.params.searchEndTime = datePickerValue.timeValue?.[1]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-24 16:17:40 +08:00
|
|
|
// 计算是否全屏展示
|
|
|
|
|
const fullscreen = computed(() => {
|
|
|
|
|
const w = Number(prop.w)
|
|
|
|
|
const h = Number(prop.h)
|
|
|
|
|
if (!isNaN(w) && !isNaN(h) && w === 12 && h === 6) {
|
|
|
|
|
// 执行相应逻辑
|
|
|
|
|
return true
|
|
|
|
|
} else {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-10-20 13:25:30 +08:00
|
|
|
watch(
|
|
|
|
|
() => prop.timeKey,
|
|
|
|
|
val => {
|
|
|
|
|
tableStore.index()
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
watch(
|
|
|
|
|
() => prop.timeValue, // 监听的目标(函数形式避免直接传递 props 导致的警告)
|
|
|
|
|
(newVal, oldVal) => {
|
|
|
|
|
tableStore.index()
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
deep: true // 若 timeValue 是对象/数组,需开启深度监听
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const addMenu = () => {}
|
|
|
|
|
</script>
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
:deep(.el-select) {
|
|
|
|
|
min-width: 80px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|