修改报表绑定指标

This commit is contained in:
guanj
2025-11-25 15:15:38 +08:00
parent f916721b6a
commit 0c71b2ac32
10 changed files with 785 additions and 572 deletions

View File

@@ -1,76 +1,115 @@
<template>
<el-tabs v-model.trim="activeName" class="demo-tabs">
<el-tab-pane label="数据单位" name="0">
绑定数据单位:
<el-cascader :popper-append-to-body="false" ref="cascaderUnit" placeholder="请选择数据单位" v-model.trim="value"
:options="options1" filterable @change="handleChange" :props="{
value: 'code',
label: 'name'
}"></el-cascader>
</el-tab-pane>
<el-tab-pane label="数据指标" name="1">
绑定数据指标:
<el-cascader :popper-append-to-body="false" ref="cascaderUnit" placeholder="请选择数据指标" v-model.trim="value"
:options="options2" filterable @change="handleChange" :props="{
value: 'name',
label: 'showName'
}"></el-cascader>
</el-tab-pane>
<el-tab-pane label="合格率判定" name="2">
绑定合格率判定:
<el-cascader :popper-append-to-body="false" ref="cascaderhgl" placeholder="请选择数据合格率" v-model.trim="value"
:options="options3" filterable @change="handleChange" :props="{
value: 'name',
label: 'showName'
}"></el-cascader>
</el-tab-pane>
<el-tab-pane label="监测点台账指标" name="3">
绑定数据指标:
<el-cascader :popper-append-to-body="false" ref="cascaderjcd" placeholder="请选择监测点台账" v-model.trim="value"
:options="options4" filterable @change="handleChange" :props="{
value: 'name',
label: 'showName'
}"></el-cascader>
</el-tab-pane>
</el-tabs>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { codeDicTree } from '@/api/system-boot/dictTree'
import { targetLimitChooseTree, getIndex, terminalChooseTree } from '@/api/harmonic-boot/luckyexcel'
const emit = defineEmits(['setValue'])
const activeName = ref('0')
const value = ref([])
const options1 = ref([])
const options2 = ref([])
const options3 = ref([])
const options4: any = ref([])
const handleChange = (e: any) => {
value.value = []
emit('setValue', e)
}
codeDicTree({ code: 'Device_Unit' }).then(res => {
options1.value = res.data
})
getIndex().then(res => {
options2.value = res.data
})
targetLimitChooseTree().then(res => {
options3.value = res.data
})
terminalChooseTree().then(res => {
options4.value = res.data
})
onMounted(() => { })
</script>
<style lang="scss" scoped>
:deep(.el-tab-pane) {
padding: 10px;
}
</style>
<template>
<el-tabs v-model.trim="activeName" class="demo-tabs">
<el-tab-pane label="数据单位" name="0">
绑定数据单位:
<el-cascader
:popper-append-to-body="false"
ref="cascaderUnit"
placeholder="请选择数据单位"
v-model.trim="value"
:options="options1"
filterable
@change="handleChange"
:props="{
value: 'code',
label: 'name'
}"
></el-cascader>
</el-tab-pane>
<el-tab-pane label="数据指标" name="1">
<div class="mb10" style="text-align: end;">
<el-radio-group v-model="frontAndBack">
<el-radio-button label="治理前" :value="0" />
<el-radio-button label="治理后" :value="1" />
</el-radio-group>
</div>
<div>
绑定数据指标:
<el-cascader
:popper-append-to-body="false"
ref="cascaderUnit"
placeholder="请选择数据指标"
v-model.trim="value"
:options="options2"
filterable
@change="handleChange"
:props="{
value: 'name',
label: 'showName'
}"
></el-cascader>
</div>
</el-tab-pane>
<el-tab-pane label="合格率判定" name="2">
绑定合格率判定:
<el-cascader
:popper-append-to-body="false"
ref="cascaderhgl"
placeholder="请选择数据合格率"
v-model.trim="value"
:options="options3"
filterable
@change="handleChange"
:props="{
value: 'name',
label: 'showName'
}"
></el-cascader>
</el-tab-pane>
<el-tab-pane label="监测点台账指标" name="3">
绑定数据指标:
<el-cascader
:popper-append-to-body="false"
ref="cascaderjcd"
placeholder="请选择监测点台账"
v-model.trim="value"
:options="options4"
filterable
@change="handleChange"
:props="{
value: 'name',
label: 'showName'
}"
></el-cascader>
</el-tab-pane>
</el-tabs>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { codeDicTree } from '@/api/system-boot/dictTree'
import { targetLimitChooseTree, getIndex, terminalChooseTree } from '@/api/harmonic-boot/luckyexcel'
const emit = defineEmits(['setValue'])
const activeName = ref('0')
const value = ref([])
const options1 = ref([])
const options2 = ref([])
const options3 = ref([])
const options4: any = ref([])
const frontAndBack = ref(0)
const handleChange = (e: any) => {
value.value = []
emit('setValue', e, activeName.value == '1' ? frontAndBack.value : 0)
}
codeDicTree({ code: 'Device_Unit' }).then(res => {
options1.value = res.data
})
getIndex().then(res => {
options2.value = res.data
})
targetLimitChooseTree().then(res => {
options3.value = res.data
})
terminalChooseTree().then(res => {
options4.value = res.data
})
onMounted(() => {})
</script>
<style lang="scss" scoped>
:deep(.el-tab-pane) {
padding: 10px;
}
</style>

View File

@@ -1,107 +1,107 @@
<template>
<el-dialog draggable :title="title" v-model.trim="formVisible" width="30%" :before-close="closeDialog">
<el-form :model="formdata" label-width="100px" :rules="rules" ref="ruleForm">
<el-form-item label="模板名称:" prop="name">
<el-input maxlength="32" show-word-limit placeholder="模板名称" v-model.trim="formdata.name"
style="width: 100%"></el-input>
</el-form-item>
<el-form-item label="部门:" prop="deptId">
<Area v-model.trim="formdata.deptId" style="width: 100%" collapse-tags
:props="{ multiple: true, label: 'name', value: 'id', emitPath: false }" />
</el-form-item>
<el-form-item label="模板类型:" prop="reportType">
<el-select style="width: 100%" v-model.trim="formdata.reportType" placeholder="请选择模板类型">
<el-option v-for="item in classificationData" :key="item.id" :label="item.label"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="报表类型:" prop="reportForm">
<el-select style="width: 100%" v-model.trim="formdata.reportForm" placeholder="请选择报表类型">
<el-option v-for="item in reportFormList" :key="item.value" :label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="closeDialog"> </el-button>
<el-button type="primary" @click="preservation"> </el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import Area from '@/components/form/area/index.vue'
import { getCustomReportTemplateById } from '@/api/harmonic-boot/luckyexcel'
import { ref, reactive } from 'vue'
const emit = defineEmits(['submitForm'])
const title = ref('')
const list = ref({})
const ruleForm = ref()
const formVisible = ref(false)
const classificationData = [
{
label: '电能质量报表类型',
id: '1'
},
{
label: '用能报表类型',
id: '2'
}
]
const reportFormList = [
{
value: '1',
label: '分析报表'
},
{
value: '2',
label: '统计报表'
},
{
value: '3',
label: '自定义报表'
}
]
const rules = {
name: [{ required: true, message: '请输入模板名称', trigger: 'blur' }],
deptId: [{ required: true, message: '请选择部门', trigger: 'change' }],
reportType: [{ required: true, message: '请选择模板类型', trigger: 'change' }],
reportForm: [{ required: true, message: '请选择报表类型', trigger: 'change' }]
}
const formdata = ref({
name: '',
deptId: [],
reportType: '',
reportForm: ''
})
// 确定
const preservation = () => {
ruleForm.value.validate((valid: boolean) => {
if (valid) {
emit('submitForm', formdata.value, title.value)
}
})
}
const shutDown = () => {
formVisible.value = false
}
// 关闭
const closeDialog = () => {
formVisible.value = false
}
const open = (text: string, row?: any) => {
title.value = text
if (row.id) {
getCustomReportTemplateById({ id: row.id }).then(res => {
formdata.value = res.data
formdata.value.deptId = res.data.valueTitle.split(',')
})
}
formVisible.value = true
}
defineExpose({ open,shutDown })
</script>
<style lang="scss" scoped></style>
<template>
<el-dialog draggable :title="title" v-model.trim="formVisible" width="30%" :before-close="closeDialog">
<el-form :model="formdata" label-width="100px" :rules="rules" ref="ruleForm">
<el-form-item label="模板名称:" prop="name">
<el-input maxlength="32" show-word-limit placeholder="模板名称" v-model.trim="formdata.name"
style="width: 100%"></el-input>
</el-form-item>
<!-- <el-form-item label="部门:" prop="deptId">
<Area v-model.trim="formdata.deptId" style="width: 100%" collapse-tags
:props="{ multiple: true, label: 'name', value: 'id', emitPath: false }" />
</el-form-item> -->
<el-form-item label="模板类型:" prop="reportType">
<el-select style="width: 100%" v-model.trim="formdata.reportType" placeholder="请选择模板类型">
<el-option v-for="item in classificationData" :key="item.id" :label="item.label"
:value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="报表类型:" prop="reportForm">
<el-select style="width: 100%" v-model.trim="formdata.reportForm" placeholder="请选择报表类型">
<el-option v-for="item in reportFormList" :key="item.value" :label="item.label"
:value="item.value"></el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="closeDialog"> </el-button>
<el-button type="primary" @click="preservation"> </el-button>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import Area from '@/components/form/area/index.vue'
import { getCustomReportTemplateById } from '@/api/harmonic-boot/luckyexcel'
import { ref, reactive } from 'vue'
const emit = defineEmits(['submitForm'])
const title = ref('')
const list = ref({})
const ruleForm = ref()
const formVisible = ref(false)
const classificationData = [
{
label: '电能质量报表类型',
id: '1'
},
{
label: '用能报表类型',
id: '2'
}
]
const reportFormList = [
{
value: '1',
label: '分析报表'
},
{
value: '2',
label: '统计报表'
},
{
value: '3',
label: '自定义报表'
}
]
const rules = {
name: [{ required: true, message: '请输入模板名称', trigger: 'blur' }],
deptId: [{ required: true, message: '请选择部门', trigger: 'change' }],
reportType: [{ required: true, message: '请选择模板类型', trigger: 'change' }],
reportForm: [{ required: true, message: '请选择报表类型', trigger: 'change' }]
}
const formdata = ref({
name: '',
deptId: [],
reportType: '',
reportForm: ''
})
// 确定
const preservation = () => {
ruleForm.value.validate((valid: boolean) => {
if (valid) {
emit('submitForm', formdata.value, title.value)
}
})
}
const shutDown = () => {
formVisible.value = false
}
// 关闭
const closeDialog = () => {
formVisible.value = false
}
const open = (text: string, row?: any) => {
title.value = text
if (row.id) {
getCustomReportTemplateById({ id: row.id }).then(res => {
formdata.value = res.data
formdata.value.deptId = res.data.valueTitle.split(',')
})
}
formVisible.value = true
}
defineExpose({ open,shutDown })
</script>
<style lang="scss" scoped></style>

View File

@@ -1,135 +1,135 @@
<template>
<div class="default-main">
<div v-show="show && lookShow">
<TableHeader ref="TableHeaderRef">
<template #operation>
<el-button icon="el-icon-Plus" type="primary" @click="add">新增</el-button>
</template>
</TableHeader>
<Table ref="tableRef" />
</div>
<luckysheet ref="luckysheetRef" v-if="!show" @shutDown="shutDown" />
<!-- 查看 -->
<look ref="lookRef" v-if="!lookShow" @shutDown="shutDown" />
<!-- 绑定 -->
<department ref="departmentRef" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { delTemplate } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData'
import { ElMessage } from 'element-plus'
import luckysheet from './luckysheet.vue'
import look from './look.vue'
import department from './department.vue'
defineOptions({
name: 'govern/reportForms/index'
})
const luckysheetRef = ref()
const lookRef = ref()
const departmentRef = ref()
const show = ref(true)
const lookShow = ref(true)
const tableStore: any = new TableStore({
url: '/harmonic-boot/customReport/getTemplateList',
method: 'POST',
isWebPaging: true,
column: [
{ field: 'name', title: '模板名称' },
{ field: 'reportForm', title: '模板类型',formatter: (row) => {
return row.cellValue == 1 ? '电能质量报表类型' : row.cellValue == 2 ? '用能报表类型' : ''
} },
{ field: 'updateBy', title: '更新用户' },
{ field: 'createTime', title: '创建时间' , sortable: true},
{ field: 'updateTime', title: '更新时间', sortable: true },
{
title: '操作',
width: '220',
render: 'buttons',
buttons: [
{
name: 'edit',
title: '查看 ',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
lookShow.value = false
setTimeout(() => {
lookRef.value.open(row)
}, 10)
}
},
{
name: 'edit',
title: '编辑',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
show.value = false
setTimeout(() => {
luckysheetRef.value.open('编辑报表模板', row)
}, 10)
}
},
// {
// name: 'edit',
// title: '绑定',
// type: 'primary',
// icon: 'el-icon-Plus',
// render: 'basicButton',
// click: row => {
// departmentRef.value.open(row)
// }
// },
{
name: 'del',
text: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除?'
},
click: row => {
delTemplate({ tempId: row.id, deptId: row.deptId }).then(res => {
ElMessage.success('删除成功')
tableStore.index()
})
}
}
]
}
],
loadCallback: () => {}
})
tableStore.table.params = {}
tableStore.table.params.pageSize = 20
tableStore.table.params.pageNum = 1
provide('tableStore', tableStore)
// 关闭
const shutDown = () => {
show.value = true
lookShow.value = true
tableStore.index()
}
const add = () => {
show.value = false
setTimeout(() => {
luckysheetRef.value.open('新增报表模板')
}, 10)
}
onMounted(() => {
tableStore.index()
})
</script>
<template>
<div class="default-main">
<div v-show="show && lookShow">
<TableHeader ref="TableHeaderRef">
<template #operation>
<el-button icon="el-icon-Plus" type="primary" @click="add">新增</el-button>
</template>
</TableHeader>
<Table ref="tableRef" />
</div>
<luckysheet ref="luckysheetRef" v-if="!show" @shutDown="shutDown" />
<!-- 查看 -->
<look ref="lookRef" v-if="!lookShow" @shutDown="shutDown" />
<!-- 绑定 -->
<department ref="departmentRef" />
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, provide, nextTick } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { delTemplate } from '@/api/harmonic-boot/luckyexcel'
import { useDictData } from '@/stores/dictData'
import { ElMessage } from 'element-plus'
import luckysheet from './luckysheet.vue'
import look from './look.vue'
import department from './department.vue'
defineOptions({
name: 'govern/reportForms/index'
})
const luckysheetRef = ref()
const lookRef = ref()
const departmentRef = ref()
const show = ref(true)
const lookShow = ref(true)
const tableStore: any = new TableStore({
url: '/harmonic-boot/customReport/getTemplateList',
method: 'POST',
isWebPaging: true,
column: [
{ field: 'name', title: '模板名称' },
{ field: 'reportForm', title: '模板类型',formatter: (row) => {
return row.cellValue == 1 ? '电能质量报表类型' : row.cellValue == 2 ? '用能报表类型' : ''
} },
{ field: 'updateBy', title: '更新用户' },
{ field: 'createTime', title: '创建时间' , sortable: true},
{ field: 'updateTime', title: '更新时间', sortable: true },
{
title: '操作',
width: '220',
render: 'buttons',
buttons: [
{
name: 'edit',
title: '查看 ',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
lookShow.value = false
setTimeout(() => {
lookRef.value.open(row)
}, 10)
}
},
{
name: 'edit',
title: '编辑',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
show.value = false
setTimeout(() => {
luckysheetRef.value.open('编辑报表模板', row)
}, 10)
}
},
// {
// name: 'edit',
// title: '绑定',
// type: 'primary',
// icon: 'el-icon-Plus',
// render: 'basicButton',
// click: row => {
// departmentRef.value.open(row)
// }
// },
{
name: 'del',
text: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除?'
},
click: row => {
delTemplate({ tempId: row.id, deptId: row.deptId }).then(res => {
ElMessage.success('删除成功')
tableStore.index()
})
}
}
]
}
],
loadCallback: () => {}
})
tableStore.table.params = {}
tableStore.table.params.pageSize = 20
tableStore.table.params.pageNum = 1
provide('tableStore', tableStore)
// 关闭
const shutDown = () => {
show.value = true
lookShow.value = true
tableStore.index()
}
const add = () => {
show.value = false
setTimeout(() => {
luckysheetRef.value.open('新增报表模板')
}, 10)
}
onMounted(() => {
tableStore.index()
})
</script>

View File

@@ -1,8 +1,14 @@
<template>
<div class="default-main">
<div class="mb10" style="display: flex; justify-content: flex-end">
<el-upload ref="upload" action="" :auto-upload="false" :show-file-list="false" :limit="1"
:on-change="beforeUpload">
<el-upload
ref="upload"
action=""
:auto-upload="false"
:show-file-list="false"
:limit="1"
:on-change="beforeUpload"
>
<el-button icon="el-icon-Upload" type="primary" class="mr10">导入excel</el-button>
</el-upload>
<el-button @click="downloadExcel" class="" type="primary" icon="el-icon-Download">导出excel</el-button>
@@ -54,13 +60,13 @@ const info = () => {
luckysheet.create(options.value)
}
//绑定value
const setValue = (e: any) => {
const setValue = (e: any, frontAndBack: number) => {
let data = luckysheet.getRange()
luckysheet.setCellValue(
data[0].row[0],
data[0].column[0],
{
v: e[e.length - 1],
v: frontAndBack == 0 ? e[e.length - 1] : `~` + e[e.length - 1],
tr: e
}
// checkedNodes[0].data.label
@@ -119,24 +125,28 @@ const submitForm = (formdata: any, text: string) => {
params.append('reportForm', formdata.reportForm)
ElMessage.info('正在保存请稍等!')
if (text == '新增报表模板') {
addTemplate(params).then(res => {
ElMessage.success('新增成功!')
formFer.value.shutDown()
emit('shutDown')
}).catch(err => {
ElMessage.error('保存失败!')
formFer.value.shutDown()
})
addTemplate(params)
.then(res => {
ElMessage.success('新增成功!')
formFer.value.shutDown()
emit('shutDown')
})
.catch(err => {
ElMessage.error('保存失败!')
formFer.value.shutDown()
})
} else if (text == '编辑报表模板') {
params.append('id', list.value.id)
dateTemplateup(params).then(res => {
ElMessage.success('编辑成功!')
formFer.value.shutDown()
emit('shutDown')
}).catch(err => {
ElMessage.error('保存失败!')
formFer.value.shutDown()
})
dateTemplateup(params)
.then(res => {
ElMessage.success('编辑成功!')
formFer.value.shutDown()
emit('shutDown')
})
.catch(err => {
ElMessage.error('保存失败!')
formFer.value.shutDown()
})
}
}
const open = async (text: string, row?: any) => {
@@ -150,7 +160,7 @@ const open = async (text: string, row?: any) => {
info()
}
defineExpose({ open })
onMounted(() => { })
onMounted(() => {})
</script>
<style lang="scss" scoped>
:deep(.el-tab-pane) {