Files
admin-govern/src/components/cockpit/governanceReport/index.vue

221 lines
7.5 KiB
Vue
Raw Normal View History

<template>
2026-06-11 20:27:37 +08:00
<div class="device-control">
<!--治理效果报表 -->
2026-06-11 20:27:37 +08:00
<div v-show="fullscreen">
<!-- <PointTree :height="flag ? 106 : 50" @node-click="nodeClick" @pointTypeChange="pointTypeChange"></PointTree> -->
<APFTree :height="flag ? 126 : 70" @node-click="handleNodeClick" template @init="handleNodeClick"></APFTree>
</div>
2026-06-11 20:27:37 +08:00
<div>
<TableHeader :showReset="false" :timeKeyList="prop.timeKey" ref="TableHeaderRef" datePicker
@selectChange="selectChange" v-if="fullscreen">
<template v-slot:select>
<el-form-item label="模板策略">
<el-select filterable v-model="tableStore.table.params.tempId" placeholder="请选择模板策略" clearable>
<el-option v-for="item in templateList" :key="item.id" :label="item.excelName"
:value="item.id" />
</el-select>
</el-form-item>
<!-- <el-form-item label="监测对象">
<el-select filterable v-model="tableStore.table.params.sensitiveUserId" placeholder="请选择监测对象"
clearable>
<el-option v-for="item in idList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item> -->
</template>
<template v-slot:operation>
<el-button @click="downloadExcel" class="" type="primary" icon="el-icon-Download">导出</el-button>
</template>
</TableHeader>
<div style="display: flex">
<div id="luckysheet" :style="{
width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
height: `calc(${prop.height} - 57px + ${fullscreen ? 0 : 56}px)`
}" v-if="tableStore.table.data.length"></div>
<el-empty description="暂无报表" v-else style="flex: 1" :style="{
width: `calc(${prop.width} - ${fullscreen ? 290 : 0}px)`,
height: `calc(${prop.height} - 57px + ${fullscreen ? 0 : 56}px)`
}"></el-empty>
</div>
</div>
</div>
</template>
<script setup lang="ts">
2026-06-04 19:06:36 +08:00
import { ref, onMounted, onUnmounted, provide, reactive, watch, h, computed, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import { exportExcel } from '@/views/govern/reportForms/export.js'
2026-06-04 19:06:36 +08:00
import { destroyLuckysheet, renderLuckysheetReport } from '@/utils/luckysheetHelper'
import TableHeader from '@/components/table/header/index.vue'
2026-01-27 16:32:33 +08:00
import { querySysExcel } from '@/api/harmonic-boot/luckyexcel'
2025-11-24 14:53:07 +08:00
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
2025-12-04 20:08:37 +08:00
import { getTime } from '@/utils/formatTime'
2026-01-07 21:01:28 +08:00
import { ElMessage } from 'element-plus'
2026-06-11 20:27:37 +08:00
import APFTree from '@/components/tree/govern/APFTree.vue'
const prop = defineProps({
2025-11-24 14:53:07 +08:00
w: { type: [String, Number] },
h: { type: [String, Number] },
width: { type: [String, Number] },
height: { type: [String, Number] },
2026-05-28 20:36:49 +08:00
timeKey: { type: Array as () => string[] },
2025-12-04 20:08:37 +08:00
timeValue: { type: Object },
2026-06-11 20:27:37 +08:00
interval: { type: Number },
flag: { type: Boolean }
})
2025-12-04 20:08:37 +08:00
const TableHeaderRef = ref()
2025-11-24 14:53:07 +08:00
// 报表模板列表
2026-06-11 20:27:37 +08:00
const templateList = ref([])
2025-11-24 14:53:07 +08:00
// 监测对象
const idList = ref()
2025-11-28 11:22:33 +08:00
2026-06-11 20:27:37 +08:00
const handleNodeClick = async (data: any) => {
if (templateList.value.length == 0) {
await querySysExcel({}).then(res => {
templateList.value = res.data.filter(item => item.excelType == 4)
if (!tableStore.table.params.tempId && templateList.value?.length > 0) {
tableStore.table.params.tempId = templateList.value[0].id
2025-11-24 14:53:07 +08:00
}
2026-06-11 20:27:37 +08:00
})
}
if (data?.level == 3 || data?.level == 2) {
tableStore.table.params.sensitiveUserId = data.id
await tableStore.index()
} else {
tableStore.table.loading = false
}
2025-11-24 14:53:07 +08:00
}
2026-06-11 20:27:37 +08:00
2025-11-24 14:53:07 +08:00
const templateListData = () => {
2026-01-27 16:32:33 +08:00
querySysExcel({}).then(res => {
templateList.value = res.data.filter(item => item.excelType == 4)
2025-11-24 14:53:07 +08:00
if (!tableStore.table.params.tempId && templateList.value?.length > 0) {
2025-11-28 11:22:33 +08:00
tableStore.table.params.tempId = templateList.value[0].id
2025-11-24 14:53:07 +08:00
}
2025-11-28 11:22:33 +08:00
nextTick(() => {
tableStore.index()
})
2025-11-24 14:53:07 +08:00
})
}
// 下载表格
const downloadExcel = () => {
2025-11-25 14:35:38 +08:00
exportExcel(luckysheet.getAllSheets(), '治理效果报表')
}
2025-11-24 14:53:07 +08:00
onMounted(() => {
2026-06-08 18:34:49 +08:00
2026-06-11 20:27:37 +08:00
// initListByIds()
2025-11-25 14:35:38 +08:00
})
2026-06-04 19:06:36 +08:00
onUnmounted(() => {
destroyLuckysheet()
})
2025-11-24 14:53:07 +08:00
const selectChange = (showSelect: any, height: any, datePickerValue?: any) => {
2025-11-14 14:09:34 +08:00
if (datePickerValue && datePickerValue.timeValue) {
// 更新时间参数
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-11-28 11:22:33 +08:00
const tableStore: any = new TableStore({
url: '/cs-harmonic-boot/customReport/getSensitiveUserReport',
method: 'POST',
showPage: false,
exportName: '治理效果报表',
column: [],
beforeSearchFun: () => {
2025-12-04 20:08:37 +08:00
setTime()
2026-01-07 21:01:28 +08:00
// if (!tableStore.table.params.sensitiveUserId && idList.value?.length > 0) {
// tableStore.table.params.sensitiveUserId = idList.value[0].id
// }
// if (!tableStore.table.params.tempId && templateList.value?.length > 0) {
// tableStore.table.params.tempId = templateList.value[0].id
// }
// if( !tableStore.table.params.tempId){
// return ElMessage.warning('请选择模板')
// }
2025-11-28 11:22:33 +08:00
},
loadCallback: () => {
2026-06-04 19:06:36 +08:00
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
2025-11-28 11:22:33 +08:00
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
2025-12-04 20:08:37 +08:00
const setTime = () => {
const time = getTime(
(TableHeaderRef.value?.datePickerRef.interval || prop.interval) ?? 0,
prop.timeKey,
fullscreen.value
? [tableStore.table.params.searchBeginTime, tableStore.table.params.searchEndTime]
: prop.timeValue
)
if (Array.isArray(time)) {
tableStore.table.params.searchBeginTime = time[0]
tableStore.table.params.searchEndTime = time[1]
2026-01-04 14:55:31 +08:00
tableStore.table.params.startTime = time[0]
tableStore.table.params.endTime = time[1]
2025-12-04 20:08:37 +08:00
TableHeaderRef.value?.setInterval(time[2] - 0)
TableHeaderRef.value?.setTimeInterval([time[0], time[1]])
} else {
console.warn('获取时间失败time 不是一个有效数组')
}
}
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
2026-06-08 18:34:49 +08:00
watch(
2026-06-11 20:27:37 +08:00
() => prop.height,
2026-06-08 18:34:49 +08:00
val => {
renderLuckysheetReport('luckysheet', tableStore.table.data, { allowEdit: false })
}
)
watch(
2025-11-14 14:09:34 +08:00
() => prop.timeValue,
(newVal, oldVal) => {
2025-12-04 20:08:37 +08:00
tableStore.index()
},
{
2025-11-14 14:09:34 +08:00
deep: true
}
)
</script>
<style lang="scss" scoped>
2025-11-24 14:53:07 +08:00
// :deep(.el-select) {
// min-width: 80px;
// }
2026-06-11 20:27:37 +08:00
.device-control {
display: flex;
}
:deep(.cn-tree) {
padding: 0 10px 0 0 !important;
}
</style>