|
@@ -0,0 +1,777 @@
|
|
|
+<template>
|
|
|
+ <div class="layout_container">
|
|
|
+ <div class="layout_main layout_container layout-horizontal">
|
|
|
+ <aside style="width: 600px;">
|
|
|
+ <TargetTree v-if="isShowTree" :targetTreeData="targetTreeData" @treeNodeClick="treeNodeClick"/>
|
|
|
+ </aside>
|
|
|
+ <div class="layout_container layout_overflow_auto">
|
|
|
+ <header>
|
|
|
+<!-- <el-button type="primary" icon="Plus" @click="addForm(ruleFormRef)" style="margin-left: 10px">新增-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- <el-button type="primary" icon="Edit" @click="editForm(ruleFormRef)" style="margin-left: 10px">编辑-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- <el-button type="primary" icon="Check" @click="submitForm(ruleFormRef)" style="margin-left: 10px">保存-->
|
|
|
+<!-- </el-button>-->
|
|
|
+<!-- <select-v4 :data="deptWardList" style="width: 220px;" clearable v-model="ks" :oncharge="deptFormat"/>-->
|
|
|
+ <el-select v-model="ks" placeholder="请选择科室" filterable clearable style="width: 240px" @change="deptFormat">
|
|
|
+ <el-option v-for="item in deptWardList" :key="item.code"
|
|
|
+ :label="item.name" :value="item.code" selected>
|
|
|
+ <span style="float: left">{{ item.code }}</span>
|
|
|
+ <span style="float: right; padding-left: 4px; color: var(--el-text-color-secondary); font-size: 13px;">
|
|
|
+ {{ item.name }}</span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ <el-button type="primary" icon="Refresh" @click="resetForm(ruleFormRef)" style="margin-left: 10px">重置
|
|
|
+ </el-button>
|
|
|
+ </header>
|
|
|
+ <div class="layout_main layout_card">
|
|
|
+ <el-form ref="ruleFormRef" :model="ruleForm" :rules="rulesForm" label-width="120px" class="demo-ruleForm"
|
|
|
+ :size="formSize" status-icon :disabled="isShowForm">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="指标名称" prop="name">
|
|
|
+ <el-input v-model="ruleForm.name" minlength="1" maxlength="256" show-word-limit />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="指标编码" prop="id">
|
|
|
+ <el-input v-model="ruleForm.id" minlength="1" maxlength="12" show-word-limit />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="父级编码" prop="pid">
|
|
|
+ <el-input v-model="ruleForm.pid" minlength="1" maxlength="12" show-word-limit />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="指标序号" prop="sort">
|
|
|
+ <el-input v-model="ruleForm.sort" maxlength="12" show-word-limit />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="总分" prop="score">
|
|
|
+ <el-input v-model="ruleForm.score" placeholder="请输入正整数或两位小数" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="责任科室" prop="deptCode">
|
|
|
+ <el-select-v2 ref="deptInfoRef" v-model="ruleForm.deptCode" clearable remote filterable
|
|
|
+ :remote-method="deptMethod" :options="deptWardList" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="责任人" prop="opId">
|
|
|
+ <el-select-v2 ref="opInfoRef" v-model="ruleForm.opId" clearable remote filterable
|
|
|
+ :remote-method="empMethod" :options="empList" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item label="是否叶子节点" prop="isLeaf">
|
|
|
+ <el-switch v-model="ruleForm.isLeaf" active-value="1" inactive-value="0" active-color="#13ce66"
|
|
|
+ inactive-color="#ff4949" @change='changeNode(ruleFormRef)' />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="10" v-show="ruleForm.isLeaf === '1'">
|
|
|
+ <el-form-item label="分子" prop="childId">
|
|
|
+ <el-select v-model="ruleForm.childId" placeholder="请选择报表分子" filterable clearable>
|
|
|
+ <el-option v-for="item in reportIdOptions" :key="item.code" :label="item.name" :value="item.code">
|
|
|
+ <span style="float: left">{{ item.code }}</span>
|
|
|
+ <span style="float: right; color: var(--el-text-color-secondary); font-size: 13px; ">
|
|
|
+ {{ item.name }}
|
|
|
+ </span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="10" v-show="ruleForm.isLeaf === '1'">
|
|
|
+ <el-form-item label="分母" prop="momId">
|
|
|
+ <el-select v-model="ruleForm.momId" placeholder="请选择报表分母" filterable clearable>
|
|
|
+ <el-option v-for="item in reportIdOptions" :key="item.code" :label="item.name" :value="item.code">
|
|
|
+ <span style="float: left">{{ item.code }}</span>
|
|
|
+ <span style="float: right; color: var(--el-text-color-secondary); font-size: 13px; ">
|
|
|
+ {{ item.name }}
|
|
|
+ </span>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-form-item label="指标定义" prop="definition">
|
|
|
+ <el-input v-model="ruleForm.definition" type="textarea" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="评审方法" prop="method">
|
|
|
+ <el-input v-model="ruleForm.method" type="textarea" :rows="4" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="计分细则" prop="scoreRule">
|
|
|
+ <el-input v-model="ruleForm.scoreRule" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-divider />
|
|
|
+ <el-form ref="upFormRef" label-width="100px" :model="sqlForm" class="demo-ruleForm" :size="formSize">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="月份">
|
|
|
+ <el-form-item prop="startTime">
|
|
|
+ <el-date-picker v-model="sqlForm.startTime" type="month" aria-label="选择月份" :editable="false"
|
|
|
+ placeholder="选择月份" format="YYYYMM" value-format="YYYYMM" @change="monthFormat"/>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="sqlExecute(ruleFormRef)"> 指标运行结果</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="saveTargetDictResult()"> 指标结果保存</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="4">
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="queryTargetReportResult()"> 指标结果查询</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="分子结果" prop="childResult">
|
|
|
+ <el-input v-model="resultMap.childResult" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="分母结果" prop="momResult">
|
|
|
+ <el-input v-model="resultMap.momResult" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="计算结果" prop="calcResult">
|
|
|
+ <el-input v-model="resultMap.calcResult" disabled />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="得分" prop="score">
|
|
|
+ <el-input v-model="resultMap.score" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <el-row>
|
|
|
+ <el-table :data="QtResultData" stripe border highlight-current-row row-key="childKey" height="320"
|
|
|
+ style="width: 100%">
|
|
|
+ <el-table-column prop="month" label="月份" header-align="center" />
|
|
|
+ <el-table-column prop="dataType" label="数据方式" header-align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.row.dataType == '1' ? 'sql统计' : '手动输入' }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="childResult" label="分子结果" header-align="center" />
|
|
|
+ <el-table-column prop="momResult" label="分母结果" header-align="center" />
|
|
|
+ <el-table-column prop="calcResult" label="计算结果" header-align="center" />
|
|
|
+ <el-table-column prop="score" label="得分" header-align="center" />
|
|
|
+ <el-table-column prop="authorName" label="统计人员" header-align="center" />
|
|
|
+ <el-table-column prop="deptName" label="统计科室" header-align="center" />
|
|
|
+ <el-table-column prop="createTime" label="统计时间" header-align="center" width="200" />
|
|
|
+ </el-table>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup name="TargetDictScore" lang="ts">
|
|
|
+import { ref, reactive, onMounted, nextTick } from 'vue'
|
|
|
+import TargetTree from '../target-comm/targetTree.vue'
|
|
|
+import SqlEditPage from '../target-comm/SqlEditPage.vue'
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import type { FormInstance, FormRules } from 'element-plus'
|
|
|
+import { clone } from '@/utils/clone'
|
|
|
+import {formatDate, formatYear} from '@/utils/date'
|
|
|
+import { queryDept } from '@/api/public-api'
|
|
|
+import {
|
|
|
+ selectTargetDictById,
|
|
|
+ selectTargetDictTree,
|
|
|
+ saveTargetDict,
|
|
|
+ updateTargetReportScore,
|
|
|
+ selectTargetReportMonthScore,
|
|
|
+ selectTargetReportResultByMonth,
|
|
|
+ selectScoreCyclePermissions
|
|
|
+} from '@/api/target-management/target-dict'
|
|
|
+import { selectTargetZbReportId } from '@/api/target-management/report-dict'
|
|
|
+import { employeeList } from "@/api/zhu-yuan-yi-sheng/pat-info-query"
|
|
|
+import {
|
|
|
+ targetSqlExecuteMonthById,
|
|
|
+ saveTargetReportMonthResult
|
|
|
+} from '@/api/target-management/target-sql'
|
|
|
+import {useUserStore} from "@/pinia/user-store";
|
|
|
+import SelectV4 from "@/components/xiao-chan/select-v4/SelectV4.vue";
|
|
|
+
|
|
|
+const targetTreeData = ref({
|
|
|
+ data: [{}],
|
|
|
+ height: 940,
|
|
|
+})
|
|
|
+
|
|
|
+const isShowTree = ref(false)
|
|
|
+const isShowForm = ref(false)
|
|
|
+const userInfo = useUserStore().userInfo
|
|
|
+const nowDay = new Date()
|
|
|
+const ds = formatDate(nowDay)
|
|
|
+const deptWardList = ref([])
|
|
|
+const empList = ref([])
|
|
|
+const deptInfoRef = ref()
|
|
|
+const opInfoRef = ref()
|
|
|
+const reportIdOptions = ref([{ code: '', name: '' }])
|
|
|
+// 查询科室
|
|
|
+const ks = ref('')
|
|
|
+
|
|
|
+let sqlEditData = ref({
|
|
|
+ id: '', // 指标编码
|
|
|
+ name: '', // 指标名称
|
|
|
+ pid: '', // 父级编码
|
|
|
+ sort: '', // 指标序号
|
|
|
+ calcChild: '', // 计算分子sql
|
|
|
+ calcMom: '', // 计算分母sql
|
|
|
+ childId: '', // 分子sql的报表id
|
|
|
+ momId: '', // 分母sql的报表id
|
|
|
+})
|
|
|
+
|
|
|
+const queryParam = reactive({
|
|
|
+ id: '', // 指标编码
|
|
|
+ name: '', // 指标名称
|
|
|
+ pid: '', // 父级编码
|
|
|
+ sort: '', // 指标序号
|
|
|
+ type: '', // 对接类型
|
|
|
+ state: '', // 状态
|
|
|
+ openTime: '', // 启用时间
|
|
|
+ dept: '', // 责任科室id
|
|
|
+ source: '', // 数据来源
|
|
|
+ calcChild: '', // 计算分子sql
|
|
|
+ calcMom: '', // 计算分母sql
|
|
|
+ isLeaf: '', //是否叶子节点(0:否, 1:是)
|
|
|
+})
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ nextTick(() => {
|
|
|
+ queryTargetDictTree()
|
|
|
+ queryTargetZbReportId()
|
|
|
+ deptMethod('')
|
|
|
+ empMethod('')
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+const deptMethod = (val: string) => {
|
|
|
+ queryDept(val).then((res: any) => {
|
|
|
+ deptWardList.value = res
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const empMethod = (val: string) => {
|
|
|
+ employeeList(val).then((res: any) => {
|
|
|
+ empList.value = res
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const queryTargetZbReportId = () => {
|
|
|
+ selectTargetZbReportId('zb').then((res: any) => {
|
|
|
+ reportIdOptions.value = res
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 查询指标字典树
|
|
|
+const queryTargetDictTree = () => {
|
|
|
+ isShowTree.value == true ? false : true
|
|
|
+ queryParam.id = '';
|
|
|
+ queryParam.pid = '';
|
|
|
+ selectTargetDictTree(queryParam)
|
|
|
+ .then((res: any) => {
|
|
|
+ targetTreeData.value.data = res
|
|
|
+ isShowTree.value = true
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// ------ 指标字典新增,修改保存表单开始 ------
|
|
|
+let ruleForm = ref({
|
|
|
+ id: '', // 指标编码
|
|
|
+ name: '', // 指标名称
|
|
|
+ pid: '', // 父级编码
|
|
|
+ sort: '', // 指标序号
|
|
|
+ score: '', // 总分
|
|
|
+ ratio: '', // 所占比率
|
|
|
+ type: '0', // 对接类型
|
|
|
+ state: 'Y', // 状态
|
|
|
+ openTime: ds, // 启用时间
|
|
|
+ dept: '', // 责任科室
|
|
|
+ deptCode: '', // 责任科室id
|
|
|
+ op: '', // 责任人
|
|
|
+ opId: '', // 责任人id
|
|
|
+ definition: '', // 指标定义
|
|
|
+ method: '', // 评审方法
|
|
|
+ scoreRule: '', // 计分细则
|
|
|
+ source: '', // 数据来源
|
|
|
+ isLeaf: '1', // 是否叶子节点(0:否, 1:是)
|
|
|
+ calcChild: '', // 计算-分子
|
|
|
+ calcMom: '', // 计算-分母
|
|
|
+ childId: '',
|
|
|
+ momId: '',
|
|
|
+})
|
|
|
+
|
|
|
+let sqlForm = ref({
|
|
|
+ id: '', // 指标编码
|
|
|
+ pid: '', // 父级编码
|
|
|
+ calcChild: '', // 计算分子sql
|
|
|
+ calcMom: '', // 计算分母sql
|
|
|
+ startTime: '', // 计算开始时间
|
|
|
+ endTime: '', // 计算结束时间
|
|
|
+ childResult: '',
|
|
|
+ momResult: '',
|
|
|
+ calcResult: '',
|
|
|
+ childId: '',
|
|
|
+ momId: '',
|
|
|
+})
|
|
|
+
|
|
|
+const formSize = ref('default')
|
|
|
+const ruleFormRef = ref<FormInstance>()
|
|
|
+const upFormRef = ref<FormInstance>()
|
|
|
+
|
|
|
+const rulesForm = ref<FormRules>({
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请填写指标名称', trigger: 'blur' },
|
|
|
+ { min: 1, max: 256, message: '指标名称长度范围1-256个字符', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ id: [
|
|
|
+ { required: true, message: '请填写指标id', trigger: 'blur' },
|
|
|
+ { min: 1, max: 12, message: '指标id长度范围1-12个字符', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ pid: [
|
|
|
+ { required: true, message: '请填写指标父id', trigger: 'blur' },
|
|
|
+ { min: 1, max: 12, message: '指标父id长度范围1-12个字符', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ sort: [
|
|
|
+ { min: 0, max: 12, message: '指标序号长度范围0-12个字符', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ score: [
|
|
|
+ { required: true, message: '请填写指标总分', trigger: 'blur' },
|
|
|
+ {
|
|
|
+ validator: (rule: any, value: any, callback: any) => {
|
|
|
+ if (/^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/.test(value) == false) {
|
|
|
+ callback(new Error("请输入正整数或两位小数"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ trigger: "blur",
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ ratio: [
|
|
|
+ { min: 0, max: 48, message: '指标所占比例长度范围0-48个字符', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ definition: [
|
|
|
+ { required: true, message: '请填写指标定义', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ method: [
|
|
|
+ { required: true, message: '请填写评审方法', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ scoreRule: [
|
|
|
+ { required: true, message: '请填写计分细则', trigger: 'blur' },
|
|
|
+ ]
|
|
|
+})
|
|
|
+
|
|
|
+// 需要添加的叶子节点的校验
|
|
|
+const leafRuleFields = ['definition', 'method', 'scoreRule']
|
|
|
+
|
|
|
+const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ // 处理叶子节点验证
|
|
|
+ await leafRulesChange(formEl)
|
|
|
+
|
|
|
+ await formEl.validate((valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ ruleForm.value.dept = deptInfoRef.value.states.selectedLabel
|
|
|
+ ruleForm.value.op = opInfoRef.value.states.selectedLabel
|
|
|
+ saveTargetDict(ruleForm.value).then((res: any) => {
|
|
|
+ if (res) {
|
|
|
+ nextTick(() => {
|
|
|
+ queryTargetDictTree()
|
|
|
+
|
|
|
+ if (!isShowForm.value) {
|
|
|
+ isShowForm.value = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ queryTargetDictTree()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const addForm = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+
|
|
|
+ if (queryParam.id === '') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "请选择一个指标!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (queryParam.isLeaf === '1') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "请选择一个父节点指标!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isShowForm.value) {
|
|
|
+ isShowForm.value = false
|
|
|
+ }
|
|
|
+
|
|
|
+ formEl.resetFields()
|
|
|
+
|
|
|
+ // 新增自动映射父指标id作为子指标的父id
|
|
|
+ ruleForm.value.pid = queryParam.id
|
|
|
+ sqlForm.value = {}
|
|
|
+}
|
|
|
+
|
|
|
+const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+
|
|
|
+ if (isShowForm.value) {
|
|
|
+ isShowForm.value = false
|
|
|
+ }
|
|
|
+
|
|
|
+ sqlForm.value = {}
|
|
|
+ resultMap.value = {}
|
|
|
+ QtResultData.value = []
|
|
|
+
|
|
|
+ formEl.resetFields()
|
|
|
+ upFormRef.value?.resetFields()
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const changeNode = async (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ await leafRulesChange(formEl)
|
|
|
+}
|
|
|
+
|
|
|
+// 叶子节点校验
|
|
|
+const leafRulesChange = async (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ // 父节点
|
|
|
+ if (ruleForm.value.isLeaf === '0') {
|
|
|
+ // 取消叶子节点的字典值校验
|
|
|
+ leafRuleFields.forEach(e => {
|
|
|
+ if (rulesForm.value[e]) {
|
|
|
+ let dfas = rulesForm.value[e] as any
|
|
|
+ dfas[0].required = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ formEl.clearValidate(leafRuleFields)
|
|
|
+ } else { // 叶子节点
|
|
|
+ // 增加叶子节点的字典值校验
|
|
|
+ leafRuleFields.forEach(e => {
|
|
|
+ if (rulesForm.value[e]) {
|
|
|
+ let dfas = rulesForm.value[e] as any
|
|
|
+ dfas[0].required = true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const editForm = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ if (isShowForm.value) {
|
|
|
+ isShowForm.value = false
|
|
|
+ if ('1' === ruleForm.value.isLeaf) {
|
|
|
+ changeNode(formEl)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// ------ 指标字典新增,修改保存表单结束 ------
|
|
|
+
|
|
|
+// ------ 接收树页面传来的数据 -------
|
|
|
+const treeNodeClick = (data: any, node: any, obj: any) => {
|
|
|
+ const d2 = formatYear(nowDay)
|
|
|
+ if (node.data) {
|
|
|
+ let params = {
|
|
|
+ id: node.data.id,
|
|
|
+ pid: node.data.pid,
|
|
|
+ startTime: d2 + '01',
|
|
|
+ endTime: d2 + '12',
|
|
|
+ }
|
|
|
+ // 查询指标得分情况
|
|
|
+ queryTargetReportMonthScore(params)
|
|
|
+ resultMap.value = {}
|
|
|
+ queryParam.id = node.data.id
|
|
|
+ queryParam.pid = node.data.pid
|
|
|
+ selectTargetDictById(queryParam)
|
|
|
+ .then((res: any) => {
|
|
|
+ if (res) {
|
|
|
+ nextTick(() => {
|
|
|
+ isShowForm.value = true
|
|
|
+ ruleForm.value = res
|
|
|
+ // 获取点击树的是否叶子节点数据
|
|
|
+ queryParam.isLeaf = ruleForm.value.isLeaf
|
|
|
+ ruleFormRef.value?.resetFields()
|
|
|
+ ruleFormRef.value?.clearValidate()
|
|
|
+ leafRulesChange(ruleFormRef.value)
|
|
|
+ upFormRef.value?.resetFields()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// --------------- sql运行 ----------------
|
|
|
+interface DataType {
|
|
|
+ id: string,
|
|
|
+ pid: string,
|
|
|
+ childLabel: string,
|
|
|
+ childResult: string,
|
|
|
+ momLabel: string,
|
|
|
+ momResult: string,
|
|
|
+ calcLabel: string,
|
|
|
+ calcResult: string,
|
|
|
+ index: number,
|
|
|
+ year: number,
|
|
|
+ dataType: string, // 数据统计类型:1 sql计算获得; 2 手动输入填写获得
|
|
|
+}
|
|
|
+
|
|
|
+const resultMap = ref({
|
|
|
+ id: '',
|
|
|
+ pid: '',
|
|
|
+ name: '',
|
|
|
+ childId: '',
|
|
|
+ childResult: '',
|
|
|
+ momId: '',
|
|
|
+ momResult: '',
|
|
|
+ calcResult: '',
|
|
|
+ month: '',
|
|
|
+ deptId: '',
|
|
|
+ deptName: '',
|
|
|
+ dataType: '',
|
|
|
+ authorName: '',
|
|
|
+ score: '',
|
|
|
+ createTime: '',
|
|
|
+})
|
|
|
+
|
|
|
+const sqlExecute = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return
|
|
|
+ // 验证是否填写完整
|
|
|
+ if (ruleForm.value.id === '' || ruleForm.value.id === undefined) {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "指标信息不全,请确认!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (ruleForm.value.isLeaf === '0') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "不是基础指标,不需要执行sql,请确认!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ruleForm.value.deptCode !== userInfo.deptCode) {
|
|
|
+ ElMessage({
|
|
|
+ type: "error",
|
|
|
+ message: "登录人所在科室【" + userInfo.deptName + "】与指标责任科室【" + ruleForm.value.dept + "】不一致无法执行此操作,请确认!",
|
|
|
+ duration: 4000,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ruleForm.value.calcChild === '') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "未编写sql,请联系管理员编写!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sqlForm.value.startTime === '') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "时间条件未选择,请确认!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ sqlForm.value.endTime = sqlForm.value.startTime
|
|
|
+ sqlForm.value.id = ruleForm.value.id
|
|
|
+ sqlForm.value.pid = ruleForm.value.pid
|
|
|
+ sqlForm.value.name = ruleForm.value.name
|
|
|
+ sqlForm.value.childId = ruleForm.value.childId
|
|
|
+ sqlForm.value.momId = ruleForm.value.momId
|
|
|
+ targetSqlExecuteMonthById(sqlForm.value)
|
|
|
+ .then((res: any) => {
|
|
|
+ resultMap.value = res
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// ------------ 统计结果保存 --------------
|
|
|
+const saveTargetDictResult = () => {
|
|
|
+
|
|
|
+ if (ruleForm.value.id === '' || ruleForm.value.id === undefined) {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "指标信息不全,请确认!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ruleForm.value.deptCode !== userInfo.deptCode) {
|
|
|
+ ElMessage({
|
|
|
+ type: "error",
|
|
|
+ message: "登录人所在科室【" + userInfo.deptName + "】与指标责任科室【" + ruleForm.value.dept + "】不一致无法执行此操作,请确认!",
|
|
|
+ duration: 4000,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ ElMessageBox.confirm('请确认是否保存统计结果?', {
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ }).then(() => {
|
|
|
+ let targetResult = clone(resultMap.value)
|
|
|
+ if (targetResult) {
|
|
|
+ saveTargetReportMonthResult(targetResult)
|
|
|
+ .then((res: any) => {
|
|
|
+ if (res) {
|
|
|
+ ElMessage({
|
|
|
+ type: "success",
|
|
|
+ message: "保存统计结果成功!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ // 查询结果
|
|
|
+ queryTargetReportResult()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "保存统计结果为空,请确认!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }).catch(() => {
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// -------------------- 指标统计结果查询 --------------------
|
|
|
+const queryData = ref({
|
|
|
+ id: '',
|
|
|
+ pid: '',
|
|
|
+ startTime: '',
|
|
|
+ endTime: '',
|
|
|
+})
|
|
|
+let QtResultData = ref([])
|
|
|
+const queryTargetReportResult = () => {
|
|
|
+ if (ruleForm.value.id === '') {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "指标信息不全,请确认!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (sqlForm.value.startTime !== '') {
|
|
|
+ let year = sqlForm.value.startTime.substring(0,4);
|
|
|
+ queryData.value.startTime = year + '01'
|
|
|
+ queryData.value.endTime = year + '12'
|
|
|
+ } else {
|
|
|
+ const df = formatYear(nowDay)
|
|
|
+ queryData.value.startTime = df + '01'
|
|
|
+ queryData.value.endTime = df + '12'
|
|
|
+ }
|
|
|
+
|
|
|
+ queryData.value.id = ruleForm.value.id
|
|
|
+ queryData.value.pid = ruleForm.value.pid
|
|
|
+ selectTargetReportMonthScore(queryData.value)
|
|
|
+ .then((res: any) => {
|
|
|
+ QtResultData.value = res
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 查询指标月度得分情况
|
|
|
+const queryTargetReportMonthScore = (params) => {
|
|
|
+ selectTargetReportMonthScore(params)
|
|
|
+ .then((res: any) => {
|
|
|
+ if(res){
|
|
|
+ QtResultData.value = res
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// 月份改变时查询分数统计结果
|
|
|
+const monthFormat = () => {
|
|
|
+ if(!sqlForm.value.startTime){
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resultMap.value = {}
|
|
|
+ let param = {
|
|
|
+ id: ruleForm.value.id,
|
|
|
+ pid: ruleForm.value.pid,
|
|
|
+ month: sqlForm.value.startTime
|
|
|
+ }
|
|
|
+ selectTargetReportResultByMonth(param)
|
|
|
+ .then((res: any) => {
|
|
|
+ if(res){
|
|
|
+ resultMap.value = res
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 查询当前年月的得分情况
|
|
|
+ queryTargetReportResult()
|
|
|
+}
|
|
|
+
|
|
|
+const deptFormat = () => {
|
|
|
+ queryParam.dept = ks.value
|
|
|
+ ruleForm.value = {}
|
|
|
+ sqlForm.value = {}
|
|
|
+ resultMap.value = {}
|
|
|
+ QtResultData.value = []
|
|
|
+ selectTargetDictTree(queryParam)
|
|
|
+ .then((res: any) => {
|
|
|
+ targetTreeData.value.data = res
|
|
|
+ isShowTree.value = true
|
|
|
+ });
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+:deep(.hd-cl) {
|
|
|
+ margin-bottom: 1px !important;
|
|
|
+}
|
|
|
+</style>
|