修改报表绑定指标

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

@@ -85,6 +85,7 @@ const init = async () => {
handleAdminRoute(res.data) handleAdminRoute(res.data)
if (route.params.to) { if (route.params.to) {
const lastRoute = JSON.parse(route.params.to as string) const lastRoute = JSON.parse(route.params.to as string)
if (lastRoute.path != adminBaseRoutePath) { if (lastRoute.path != adminBaseRoutePath) {
let query = !isEmpty(lastRoute.query) ? lastRoute.query : {} let query = !isEmpty(lastRoute.query) ? lastRoute.query : {}
routePush({ path: lastRoute.path, query: query }) routePush({ path: lastRoute.path, query: query })

View File

@@ -10,7 +10,7 @@ import { compact, isEmpty, reverse } from 'lodash-es'
import { isAdminApp } from '@/utils/common' import { isAdminApp } from '@/utils/common'
import { getRouteMenu, dictDataCache } from '@/api/auth' import { getRouteMenu, dictDataCache } from '@/api/auth'
import { adminBaseRoutePath } from '@/router/static' import { adminBaseRoutePath } from '@/router/static'
const route = useRouter() const route:any = useRouter()
/** /**
* 导航失败有错误消息的路由push * 导航失败有错误消息的路由push
* @param to — 导航位置,同 router.push * @param to — 导航位置,同 router.push

View File

@@ -2,35 +2,75 @@
<el-tabs v-model.trim="activeName" class="demo-tabs"> <el-tabs v-model.trim="activeName" class="demo-tabs">
<el-tab-pane label="数据单位" name="0"> <el-tab-pane label="数据单位" name="0">
绑定数据单位: 绑定数据单位:
<el-cascader :popper-append-to-body="false" ref="cascaderUnit" placeholder="请选择数据单位" v-model.trim="value" <el-cascader
:options="options1" filterable @change="handleChange" :props="{ :popper-append-to-body="false"
ref="cascaderUnit"
placeholder="请选择数据单位"
v-model.trim="value"
:options="options1"
filterable
@change="handleChange"
:props="{
value: 'code', value: 'code',
label: 'name' label: 'name'
}"></el-cascader> }"
></el-cascader>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="数据指标" name="1"> <el-tab-pane label="数据指标" name="1">
绑定数据指标: <div class="mb10" style="text-align: end;">
<el-cascader :popper-append-to-body="false" ref="cascaderUnit" placeholder="请选择数据指标" v-model.trim="value" <el-radio-group v-model="frontAndBack">
:options="options2" filterable @change="handleChange" :props="{ <el-radio-button label="治理前" :value="0" />
value: 'name', <el-radio-button label="治理后" :value="1" />
label: 'showName' </el-radio-group>
}"></el-cascader> </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>
<el-tab-pane label="合格率判定" name="2"> <el-tab-pane label="合格率判定" name="2">
绑定合格率判定: 绑定合格率判定:
<el-cascader :popper-append-to-body="false" ref="cascaderhgl" placeholder="请选择数据合格率" v-model.trim="value" <el-cascader
:options="options3" filterable @change="handleChange" :props="{ :popper-append-to-body="false"
ref="cascaderhgl"
placeholder="请选择数据合格率"
v-model.trim="value"
:options="options3"
filterable
@change="handleChange"
:props="{
value: 'name', value: 'name',
label: 'showName' label: 'showName'
}"></el-cascader> }"
></el-cascader>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="监测点台账指标" name="3"> <el-tab-pane label="监测点台账指标" name="3">
绑定数据指标: 绑定数据指标:
<el-cascader :popper-append-to-body="false" ref="cascaderjcd" placeholder="请选择监测点台账" v-model.trim="value" <el-cascader
:options="options4" filterable @change="handleChange" :props="{ :popper-append-to-body="false"
ref="cascaderjcd"
placeholder="请选择监测点台账"
v-model.trim="value"
:options="options4"
filterable
@change="handleChange"
:props="{
value: 'name', value: 'name',
label: 'showName' label: 'showName'
}"></el-cascader> }"
></el-cascader>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</template> </template>
@@ -47,13 +87,12 @@ const options1 = ref([])
const options2 = ref([]) const options2 = ref([])
const options3 = ref([]) const options3 = ref([])
const options4: any = ref([]) const options4: any = ref([])
const frontAndBack = ref(0)
const handleChange = (e: any) => { const handleChange = (e: any) => {
value.value = [] value.value = []
emit('setValue', e, activeName.value == '1' ? frontAndBack.value : 0)
emit('setValue', e)
} }
codeDicTree({ code: 'Device_Unit' }).then(res => { codeDicTree({ code: 'Device_Unit' }).then(res => {
options1.value = res.data options1.value = res.data
}) })
@@ -67,7 +106,7 @@ terminalChooseTree().then(res => {
options4.value = res.data options4.value = res.data
}) })
onMounted(() => { }) onMounted(() => {})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
:deep(.el-tab-pane) { :deep(.el-tab-pane) {

View File

@@ -5,10 +5,10 @@
<el-input maxlength="32" show-word-limit placeholder="模板名称" v-model.trim="formdata.name" <el-input maxlength="32" show-word-limit placeholder="模板名称" v-model.trim="formdata.name"
style="width: 100%"></el-input> style="width: 100%"></el-input>
</el-form-item> </el-form-item>
<el-form-item label="部门:" prop="deptId"> <!-- <el-form-item label="部门:" prop="deptId">
<Area v-model.trim="formdata.deptId" style="width: 100%" collapse-tags <Area v-model.trim="formdata.deptId" style="width: 100%" collapse-tags
:props="{ multiple: true, label: 'name', value: 'id', emitPath: false }" /> :props="{ multiple: true, label: 'name', value: 'id', emitPath: false }" />
</el-form-item> </el-form-item> -->
<el-form-item label="模板类型:" prop="reportType"> <el-form-item label="模板类型:" prop="reportType">
<el-select style="width: 100%" v-model.trim="formdata.reportType" placeholder="请选择模板类型"> <el-select style="width: 100%" v-model.trim="formdata.reportType" placeholder="请选择模板类型">

View File

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

View File

@@ -19,7 +19,7 @@
<el-form-item class="top" label="组件路径" prop="path"> <el-form-item class="top" label="组件路径" prop="path">
<el-input v-model="form.path" placeholder="请输入组件路径"></el-input> <el-input v-model="form.path" placeholder="请输入组件路径"></el-input>
</el-form-item> </el-form-item>
<el-form-item class="top" label="组件查询时间"> <!-- <el-form-item class="top" label="组件查询时间">
<el-radio-group v-model="form.timeKey" style="width: 100%"> <el-radio-group v-model="form.timeKey" style="width: 100%">
<el-radio-button label="年" value="1" /> <el-radio-button label="年" value="1" />
<el-radio-button label="季" value="2" /> <el-radio-button label="季" value="2" />
@@ -27,7 +27,7 @@
<el-radio-button label="周" value="4" /> <el-radio-button label="周" value="4" />
<el-radio-button label="日" value="5" /> <el-radio-button label="日" value="5" />
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item> -->
<el-form-item class="top" label="组件排序" prop="sort"> <el-form-item class="top" label="组件排序" prop="sort">
<el-input v-model="form.sort" placeholder="请输入组件排序"></el-input> <el-input v-model="form.sort" placeholder="请输入组件排序"></el-input>
</el-form-item> </el-form-item>
@@ -54,15 +54,13 @@ import { ref, inject, onMounted, type Component, defineAsyncComponent, h, markRa
import { reactive } from 'vue' import { reactive } from 'vue'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
import { getFatherComponent, componentAdd, componentEdit } from '@/api/user-boot/dept' import { getFatherComponent, componentAdd, componentEdit } from '@/api/user-boot/dept'
import IconSelector from '@/components/baInput/components/iconSelector.vue' import IconSelector from '@/components/baInput/components/iconSelector.vue'
import html2canvas from 'html2canvas' import html2canvas from 'html2canvas'
const emit = defineEmits(['cancel','submit'])
const dictData = useDictData() const dictData = useDictData()
const dialogVisible = ref(false) const dialogVisible = ref(false)
const title = ref('') const title = ref('')
const tableStore = inject('tableStore') as TableStore
const formRef = ref() const formRef = ref()
// 注意不要和表单ref的命名冲突 // 注意不要和表单ref的命名冲突
const form = ref<anyObj>({ const form = ref<anyObj>({
@@ -121,6 +119,7 @@ const submit = () => {
image: url image: url
}).then(res => { }).then(res => {
ElMessage.success('新增成功!') ElMessage.success('新增成功!')
emit('submit')
cancel() cancel()
}) })
} else { } else {
@@ -131,6 +130,7 @@ const submit = () => {
image: url image: url
}).then(res => { }).then(res => {
ElMessage.success('修改成功!') ElMessage.success('修改成功!')
emit('submit')
cancel() cancel()
}) })
} }
@@ -176,7 +176,7 @@ const registerComponent = (path: string): Component | string | null => {
} }
} }
const cancel = () => { const cancel = () => {
tableStore.index() emit('cancel')
dialogVisible.value = false dialogVisible.value = false
} }
defineExpose({ open }) defineExpose({ open })

View File

@@ -0,0 +1,139 @@
<template>
<el-dialog draggable class="cn-operate-dialog" v-model="dialogVisible" width="500px" :title="title" @close="cancel">
<div style="display: flex">
<el-form :inline="false" :model="form" label-width="auto" :rules="rules" ref="formRef" style="flex: 1">
<el-form-item class="top" label="上级树">
<el-cascader
v-model="form.system"
:options="customDeptOption"
:props="props"
clearable
filterable
placeholder="请选择上级树"
style="width: 100%"
/>
</el-form-item>
<el-form-item class="top" label="树名称" prop="name">
<el-input v-model="form.name" placeholder="请输入组件名称"></el-input>
</el-form-item>
<el-form-item class="top" label="树排序" prop="sort">
<el-input v-model="form.sort" placeholder="请输入组件排序"></el-input>
</el-form-item>
</el-form>
</div>
<template #footer>
<span class="dialog-footer">
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="submit">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import { ref, inject, onMounted, type Component, defineAsyncComponent, h, markRaw } from 'vue'
import { reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { useDictData } from '@/stores/dictData'
import { getFatherComponent, componentAdd, componentEdit } from '@/api/user-boot/dept'
import { componentTree } from '@/api/user-boot/user'
const dictData = useDictData()
const emit = defineEmits(['cancel', 'submit'])
const dialogVisible = ref(false)
const title = ref('')
const formRef = ref()
// 注意不要和表单ref的命名冲突
const form = ref<anyObj>({
name: '',
sort: 100,
system: ''
})
const props = { label: 'name', value: 'id', checkStrictly: true }
const rules = {
name: [{ required: true, message: '请输输入树名称', trigger: 'blur' }],
system: [{ required: true, message: '请先择父组件节点', trigger: 'change' }],
sort: [{ required: true, message: '请输入排序', trigger: 'blur' }]
}
const customDeptOption: any = ref([])
onMounted(() => {})
const open = (text: string, data?: anyObj) => {
getFather()
title.value = text
dialogVisible.value = true
if (data) {
let Data = JSON.parse(JSON.stringify(data))
form.value.system = Data.systemType
form.value.name = Data.name
form.value.sort = Data.sort
}
}
// 查询父节点
const getFather = () => {
componentTree().then(res => {
customDeptOption.value = deletePathNotNull(JSON.parse(JSON.stringify(res.data)))
})
}
// 递归删除path不为null的数据
function deletePathNotNull(data:any) {
// 若为数组,遍历处理每个元素
if (Array.isArray(data)) {
const filtered = []
for (let item of data) {
// 递归处理子节点
if (item.children && item.children.length > 0) {
item.children = deletePathNotNull(item.children)
}
// 仅保留path为null或空字符串的节点
if (item.path === null || item.path === '') {
filtered.push(item)
}
}
return filtered
}
// 若为单个对象(递归子节点时用)
if (typeof data === 'object' && data !== null) {
if (data.children && data.children.length > 0) {
data.children = deletePathNotNull(data.children)
}
return data.path === null || data.path === '' ? data : null
}
return data
}
const submit = () => {
formRef.value.validate(async (valid: boolean) => {
if (valid) {
if (title.value == '新增树') {
await componentAdd({
...form.value,
systemType: form.value.system[0],
pid: form.value.system[1]
}).then(res => {
ElMessage.success('新增成功!')
emit('submit')
cancel()
})
} else {
await componentEdit({
...form.value,
systemType: form.value.system[0],
pid: form.value.system[1]
}).then(res => {
ElMessage.success('修改成功!')
emit('submit')
cancel()
})
}
}
})
}
const cancel = () => {
emit('cancel')
dialogVisible.value = false
}
defineExpose({ open })
</script>

View File

@@ -2,22 +2,29 @@
<div class="default-main"> <div class="default-main">
<TableHeader :showSearch="false"> <TableHeader :showSearch="false">
<template v-slot:operation> <template v-slot:operation>
<el-button type="primary" @click="add" icon="el-icon-Plus">新增</el-button> <el-button type="primary" @click="addTree" icon="el-icon-Plus">新增</el-button>
<el-button type="primary" @click="add" icon="el-icon-Plus">新增组件</el-button>
</template> </template>
</TableHeader> </TableHeader>
<Table ref="tableRef" :tree-config="{ transform: true, parentField: 'uPid', rowField: 'uId' }" <Table
:scroll-y="{ enabled: true }" /> ref="tableRef"
<Add ref="addRef" v-if="addFlag" @onSubmit="tableStore.index()" /> :tree-config="{ transform: true, parentField: 'uPid', rowField: 'uId' }"
:scroll-y="{ enabled: true }"
/>
<Add ref="addRef" v-if="addFlag" @cancel="cancel" @submit="tableStore.index()" />
<!-- 新增树 -->
<Tree ref="treeRef" v-if="addFlag" @cancel="cancel" @submit="tableStore.index()" />
</div> </div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, provide,nextTick } from 'vue' import { ref, onMounted, provide, nextTick } from 'vue'
import TableStore from '@/utils/tableStore' import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue' import Table from '@/components/table/index.vue'
import { useDictData } from '@/stores/dictData' import { useDictData } from '@/stores/dictData'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
import TableHeader from '@/components/table/header/index.vue' import TableHeader from '@/components/table/header/index.vue'
import Add from './add.vue' import Add from './add.vue'
import Tree from './addTree.vue'
import { deleteSubassembly } from '@/api/user-boot/dept' import { deleteSubassembly } from '@/api/user-boot/dept'
defineOptions({ defineOptions({
name: 'component' name: 'component'
@@ -25,6 +32,7 @@ defineOptions({
const addRef = ref() const addRef = ref()
const addFlag = ref(false) const addFlag = ref(false)
const tableRef = ref() const tableRef = ref()
const treeRef = ref()
const treeData: any = ref([]) const treeData: any = ref([])
const tableStore = new TableStore({ const tableStore = new TableStore({
url: '/user-boot/component/componentTree', url: '/user-boot/component/componentTree',
@@ -39,7 +47,7 @@ const tableStore = new TableStore({
width: '80', width: '80',
render: 'icon' render: 'icon'
}, },
{ field: 'code', title: '组件标识', minWidth: '100', }, { field: 'code', title: '组件标识', minWidth: '100' },
{ field: 'path', title: '组件路径' }, { field: 'path', title: '组件路径' },
{ field: 'image', title: '组件展示', render: 'image' }, { field: 'image', title: '组件展示', render: 'image' },
{ {
@@ -53,13 +61,18 @@ const tableStore = new TableStore({
type: 'primary', type: 'primary',
icon: 'el-icon-Plus', icon: 'el-icon-Plus',
render: 'basicButton', render: 'basicButton',
disabled: row => {
return row.path == '' || row.path == null
},
click: row => { click: row => {
addFlag.value = true addFlag.value = true
setTimeout(() => { setTimeout(() => {
addRef.value.open('修改组件', row) if (row.path == '' || row.path == null) {
// 修改树
treeRef.value.open('修改树', row)
} else {
// 组件修改
addRef.value.open('修改组件', row)
}
}, 100) }, 100)
} }
}, },
@@ -69,9 +82,7 @@ const tableStore = new TableStore({
type: 'danger', type: 'danger',
icon: 'el-icon-Delete', icon: 'el-icon-Delete',
render: 'confirmButton', render: 'confirmButton',
disabled: row => {
return row.path == '' || row.path == null
},
popconfirm: { popconfirm: {
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
@@ -79,10 +90,13 @@ const tableStore = new TableStore({
title: '确定删除?' title: '确定删除?'
}, },
click: row => { click: row => {
deleteSubassembly({ id: row.id }).then(() => { if (row.path == '' || row.path == null) {
ElMessage.success('删除成功!') } else {
tableStore.index() deleteSubassembly({ id: row.id }).then(() => {
}) ElMessage.success('删除成功!')
tableStore.index()
})
}
} }
} }
] ]
@@ -127,6 +141,16 @@ const add = () => {
addRef.value.open('新增组件') addRef.value.open('新增组件')
}, 100) }, 100)
} }
// 新增数
const addTree = () => {
addFlag.value = true
setTimeout(() => {
treeRef.value.open('新增树')
}, 100)
}
const cancel = () => {
addFlag.value = false
}
provide('tableStore', tableStore) provide('tableStore', tableStore)
onMounted(() => { onMounted(() => {
tableStore.index() tableStore.index()

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-dialog class="cn-operate-dialog" v-model.trim="dialogVisible" :title="title"> <el-dialog class="cn-operate-dialog" width="500px" v-model.trim="dialogVisible" :title="title">
<el-scrollbar> <el-scrollbar>
<el-form :inline="false" :model="form" label-width="120px" :rules="rules"> <el-form :inline="false" :model="form" label-width="120px" :rules="rules">
<el-form-item label="字典名称:" prop="name"> <el-form-item label="字典名称:" prop="name">