|
@@ -19,7 +19,7 @@
|
|
|
</template>
|
|
|
<template #main>
|
|
|
<el-form ref="ruleFormRef" :model="reportForm" :rules="rules" label-width="120px" class="demo-ruleForm"
|
|
|
- :size="formSize" status-icon :disabled="isShowForm">
|
|
|
+ :size="formSize" status-icon :disabled="isDisabledForm">
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="报表名称" prop="reportName">
|
|
@@ -36,7 +36,7 @@
|
|
|
<el-form-item label="报表类型" prop="reportType">
|
|
|
<!-- <el-input v-model="reportForm.reportType" minlength="1" maxlength="12"
|
|
|
show-word-limit /> -->
|
|
|
- <el-select v-model="reportForm.reportType" placeholder="请选择报表类型" clearable>
|
|
|
+ <el-select v-model="reportForm.reportType" placeholder="请选择报表类型">
|
|
|
<el-option v-for="item in reportTypeList" :key="item.reportType"
|
|
|
:label="item.reportLabel" :value="item.reportType">
|
|
|
<span style="float: left">{{ item.reportType }}</span>
|
|
@@ -73,12 +73,14 @@
|
|
|
<el-row>
|
|
|
<el-col :span="6">
|
|
|
<el-form-item label="菜单id" prop="menuId">
|
|
|
- <el-input v-model="reportForm.menuId" minlength="0" maxlength="12" show-word-limit />
|
|
|
+ <el-input v-model.number="reportForm.menuId" minlength="0" maxlength="12"
|
|
|
+ show-word-limit />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="6">
|
|
|
<el-form-item label="面板排序" prop="sort">
|
|
|
- <el-input v-model="reportForm.sort" minlength="0" maxlength="12" show-word-limit />
|
|
|
+ <el-input v-model.number="reportForm.sort" minlength="0" maxlength="12"
|
|
|
+ show-word-limit />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
@@ -143,8 +145,8 @@
|
|
|
</el-row>
|
|
|
</el-form>
|
|
|
<el-dialog v-model="showReportLevel" :close-on-click-modal="false" :close-on-press-escape="false"
|
|
|
- :title="reportLevelTitle" width="80%" height="80%">
|
|
|
- <ReportLevel :setlinfo="reportLevelDetail" />
|
|
|
+ :title="reportLevelTitle" width="80%" height="70%">
|
|
|
+ <ReportLevel :reportLevelDetail="reportLevelDetail" />
|
|
|
</el-dialog>
|
|
|
</template>
|
|
|
</PageLayer>
|
|
@@ -158,7 +160,7 @@ import PageLayer from '../../../layout/PageLayer.vue'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { formatDate } from '../../../utils/date'
|
|
|
import type { FormInstance, FormRules } from 'element-plus'
|
|
|
-import { selectReportDictTree, selectReportDict, selectReportType, reportSqlExecute, selectReportLevel } from '../../../api/target-management/report-dict'
|
|
|
+import { selectReportDictTree, selectReportDict, selectReportType, reportSqlExecute, selectReportLevel, saveReportBaseInfo } from '../../../api/target-management/report-dict'
|
|
|
import ReportLevel from '../target-comm/ReportLevel.vue'
|
|
|
import { queryDept } from '../../../api/public-api'
|
|
|
|
|
@@ -168,7 +170,8 @@ const reportTreeData = ref({
|
|
|
})
|
|
|
|
|
|
const isShowTree = ref(false)
|
|
|
-const isShowForm = ref(false)
|
|
|
+// 是否开启Form表单编辑
|
|
|
+const isDisabledForm = ref(false)
|
|
|
const deptWardList = ref([])
|
|
|
const nowDay = new Date()
|
|
|
const ds = formatDate(nowDay)
|
|
@@ -232,6 +235,26 @@ onMounted(() => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
+const rules = $ref<FormRules>({
|
|
|
+ reportId: [
|
|
|
+ { required: true, message: '请填写报表id', trigger: 'blur' },
|
|
|
+ { min: 1, max: 12, message: '报表id长度范围1-12个字符', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ reportName: [
|
|
|
+ { required: true, message: '请填写报表名称', trigger: 'blur' },
|
|
|
+ { min: 1, max: 256, message: '报表名称长度范围1-256个字符', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ reportType: [
|
|
|
+ { required: true, message: '请填写报表类型', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ gatherSql: [
|
|
|
+ { required: true, message: '请填写聚合函数sql', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ baseSql: [
|
|
|
+ { required: true, message: '请填写基础sql', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+})
|
|
|
+
|
|
|
// 查询指标字典树
|
|
|
const queryReportDictTree = () => {
|
|
|
isShowTree.value == true ? false : true
|
|
@@ -265,9 +288,12 @@ const treeNodeClick = async (data: any, node: any, obj: any) => {
|
|
|
});
|
|
|
return
|
|
|
} else {
|
|
|
- if (!isShowForm.value) {
|
|
|
- isShowForm.value = true
|
|
|
+ if (!isDisabledForm.value) {
|
|
|
+ isDisabledForm.value = true
|
|
|
}
|
|
|
+ ruleFormRef.value?.resetFields()
|
|
|
+ sqlForm.calcResult = ''
|
|
|
+
|
|
|
// 查询指标字典
|
|
|
let selectReportDictRes = await selectReportDict(queryParam)
|
|
|
reportForm = selectReportDictRes[0]
|
|
@@ -279,11 +305,14 @@ const treeNodeClick = async (data: any, node: any, obj: any) => {
|
|
|
const addForm = (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
|
|
|
|
- if (isShowForm.value) {
|
|
|
- isShowForm.value = false
|
|
|
+ if (isDisabledForm.value) {
|
|
|
+ isDisabledForm.value = false
|
|
|
}
|
|
|
|
|
|
formEl.resetFields()
|
|
|
+ reportForm = {}
|
|
|
+ ruleFormRef.value?.resetFields()
|
|
|
+ sqlForm.calcResult = ''
|
|
|
|
|
|
}
|
|
|
|
|
@@ -291,50 +320,75 @@ const addForm = (formEl: FormInstance | undefined) => {
|
|
|
const editForm = (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
|
|
|
|
+ if (isDisabledForm.value) {
|
|
|
+ isDisabledForm.value = false
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// ---------- 保存报表 ------------
|
|
|
const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
|
+
|
|
|
+ if (reportForm.reportId == '') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: '指标报表信息不全,请确认!',
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ await formEl.validate((valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ if (reportForm.gatherSql == '' || reportForm.baseSql == '' || reportForm.reportName == '') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: '指标报表信息不全,请确认!',
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ saveReportBaseInfo(reportForm).then((res: any) => {
|
|
|
+ ElMessage({
|
|
|
+ type: "success",
|
|
|
+ message: res.cg,
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (!isDisabledForm.value) {
|
|
|
+ isDisabledForm.value = true
|
|
|
+ }
|
|
|
+
|
|
|
+ queryReportDictTree()
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+
|
|
|
+ queryReportDictTree()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// ---------- 重置报表 ------------
|
|
|
const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
|
|
|
|
- if (isShowForm.value) {
|
|
|
- isShowForm.value = false
|
|
|
+ if (isDisabledForm.value) {
|
|
|
+ isDisabledForm.value = false
|
|
|
}
|
|
|
|
|
|
formEl.resetFields()
|
|
|
+ reportForm = {}
|
|
|
+ ruleFormRef.value?.resetFields()
|
|
|
+ sqlForm.calcResult = ''
|
|
|
}
|
|
|
|
|
|
-const rules = ref<FormRules>({
|
|
|
- reportId: [
|
|
|
- { required: true, message: '请填写报表id', trigger: 'blur' },
|
|
|
- { min: 1, max: 12, message: '报表id长度范围1-12个字符', trigger: 'blur' },
|
|
|
- ],
|
|
|
- reportName: [
|
|
|
- { required: true, message: '请填写报表名称', trigger: 'blur' },
|
|
|
- { min: 1, max: 256, message: '报表名称长度范围1-256个字符', trigger: 'blur' },
|
|
|
- ],
|
|
|
- reportType: [
|
|
|
- { required: true, message: '请填写报表类型', trigger: 'blur' },
|
|
|
- ],
|
|
|
- gatherSql: [
|
|
|
- { required: true, message: '请填写聚合函数sql', trigger: 'blur' },
|
|
|
- ],
|
|
|
- baseSql: [
|
|
|
- { required: true, message: '请填写基础sql', trigger: 'blur' },
|
|
|
- ],
|
|
|
- menuId: [
|
|
|
- { type: 'number', message: '菜单id请填写数字', trigger: 'blur' },
|
|
|
- ],
|
|
|
- sort: [
|
|
|
- { type: 'number', message: '面板排序请填写数字', trigger: 'blur' },
|
|
|
- ],
|
|
|
-})
|
|
|
-
|
|
|
// --------------- sql运行 ----------------
|
|
|
const sqlExecute = (formEl: FormInstance | undefined) => {
|
|
|
if (!formEl) return
|
|
@@ -393,7 +447,6 @@ const reportLevel = () => {
|
|
|
selectReportLevel(param).then((res: any) => {
|
|
|
showReportLevel.value = true
|
|
|
reportLevelDetail.value = res
|
|
|
- console.log(res)
|
|
|
})
|
|
|
}
|
|
|
|