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

171 lines
5.7 KiB
Vue
Raw Normal View History

<template>
<div>
<!--治理效果报表 -->
<TableHeader :showReset="false" datePicker @selectChange="selectChange" v-if="fullscreen">
<template v-slot:select>
2025-11-24 14:53:07 +08:00
<el-form-item label="报表模板">
2025-11-28 11:22:33 +08:00
<el-select v-model="tableStore.table.params.tempId" placeholder="请选择报表模板" clearable>
2025-11-24 14:53:07 +08:00
<el-option v-for="item in templateList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="监测对象">
2025-11-28 11:22:33 +08:00
<el-select 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">导出excel</el-button>
</template>
</TableHeader>
2025-11-28 11:22:33 +08:00
<div style="display: flex">
<div
2025-11-25 14:35:38 +08:00
id="luckysheet"
2025-10-24 16:17:40 +08:00
:style="{
2025-11-25 14:35:38 +08:00
width: `calc(${prop.width} )`,
2025-10-24 16:17:40 +08:00
height: `calc(${prop.height} - 57px + ${fullscreen ? 0 : 56}px)`
}"
></div>
</div>
</div>
</template>
<script setup lang="ts">
2025-11-28 11:22:33 +08:00
import { ref, onMounted, provide, reactive, watch, h, computed, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import { exportExcel } from '@/views/govern/reportForms/export.js'
import TableHeader from '@/components/table/header/index.vue'
2025-11-24 14:53:07 +08:00
import { getTemplateList } from '@/api/harmonic-boot/luckyexcel'
import { getListByIds } from '@/api/harmonic-boot/cockpit/cockpit'
2025-11-28 11:22:33 +08:00
import Json from './index.json'
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] },
timeKey: { type: [String, Number] },
timeValue: { type: Object }
})
2025-11-24 14:53:07 +08:00
// 报表模板列表
2025-11-25 14:35:38 +08:00
const templateList = ref()
2025-11-24 14:53:07 +08:00
// 监测对象
const idList = ref()
// 监测对象
const initListByIds = () => {
getListByIds({}).then((res: any) => {
if (res.data.length > 0) {
idList.value = res.data
2025-11-28 11:22:33 +08:00
2025-11-24 14:53:07 +08:00
if (!tableStore.table.params.sensitiveUserId && idList.value?.length > 0) {
tableStore.table.params.sensitiveUserId = idList.value[0].id
}
2025-11-28 11:22:33 +08:00
templateListData()
2025-11-24 14:53:07 +08:00
}
})
}
const templateListData = () => {
getTemplateList({}).then(res => {
templateList.value = res.data
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(() => {
2025-11-24 14:53:07 +08:00
initListByIds()
2025-11-25 14:35:38 +08:00
})
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: () => {
tableStore.table.params.searchBeginTime = tableStore.table.params.searchBeginTime || prop.timeValue?.[0]
tableStore.table.params.searchEndTime = tableStore.table.params.searchEndTime || prop.timeValue?.[1]
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
}
},
loadCallback: () => {
luckysheet.create({
container: 'luckysheet',
title: '', // 表 头名
lang: 'zh', // 中文
showtoolbar: false, // 是否显示工具栏
showinfobar: false, // 是否显示顶部信息栏
showsheetbar: true, // 是否显示底部sheet按钮
allowEdit: false, // 禁止所有编辑操作(必填)
data: tableStore.table.data
})
}
})
const tableRef = ref()
provide('tableRef', tableRef)
provide('tableStore', tableStore)
watch(
() => prop.timeKey,
val => {
tableStore.index()
}
)
watch(
2025-11-14 14:09:34 +08:00
() => prop.timeValue,
(newVal, oldVal) => {
2025-11-14 14:09:34 +08:00
// 当外部时间值变化时,更新表格的时间参数
if (newVal && (!oldVal || newVal[0] !== oldVal[0] || newVal[1] !== oldVal[1])) {
tableStore.table.params.searchBeginTime = newVal[0]
tableStore.table.params.searchEndTime = newVal[1]
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;
// }
</style>