|
@@ -0,0 +1,387 @@
|
|
|
+<template>
|
|
|
+ <PageLayer>
|
|
|
+ <template #header class="hd-cl">
|
|
|
+ <el-button type="primary" icon="Plus" @click="onAddItem" style="margin-left: 5px">新增</el-button>
|
|
|
+ <el-text class="mx-1" type="danger"
|
|
|
+ style="margin-left: 10px; font-size: 1.2em">配置说明:1.列prop,label必填且prop值以“-t”结尾的表示二级表头的父级表头prop属性; 2.列id,pid必填且列id,pid相同则不属于父子表头范畴,不同pid则为父节点id</el-text>
|
|
|
+ </template>
|
|
|
+ <template #mainMaxContentHeight>
|
|
|
+ <el-table :data="tableDisplayData" border style="width: 100%" stripe highlight-current-row height="600">
|
|
|
+ <el-table-column type="index" label="序号" width="80" />
|
|
|
+ <el-table-column prop="reportId" label="报表Id" width="120"></el-table-column>
|
|
|
+ <el-table-column prop="title" label="名称" width="200">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.title"></el-input>
|
|
|
+ <span v-else>{{ scope.row.title }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="levelId" label="类型Id" width="80">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.levelId"></el-input>
|
|
|
+ <span v-else>{{ scope.row.levelId }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="levelName" label="类型名称" width="140">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.levelName"></el-input>
|
|
|
+ <span v-else>{{ scope.row.levelName }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="prop" label="列prop" width="140">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.prop"></el-input>
|
|
|
+ <span v-else>{{ scope.row.prop }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="label" label="列label" width="140">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.label"></el-input>
|
|
|
+ <span v-else>{{ scope.row.label }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="align" label="列align" width="140">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <div v-if="scope.row.isEdit">
|
|
|
+ <el-select v-model="scope.row.align" clearable placeholder="请选择列align">
|
|
|
+ <el-option v-for="option in alignOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-select v-model="scope.row.align" disabled placeholder="请选择列align">
|
|
|
+ <el-option v-for="option in alignOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="width" label="列width" width="140">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.width"></el-input>
|
|
|
+ <span v-else>{{ scope.row.width }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="sortable" label="列允许排序" width="140">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <div v-if="scope.row.isEdit">
|
|
|
+ <el-select v-model="scope.row.sortable" clearable placeholder="请选择列允许排序">
|
|
|
+ <el-option v-for="option in isOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-select v-model="scope.row.sortable" disabled placeholder="请选择列允许排序">
|
|
|
+ <el-option v-for="option in isOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="sort" label="列顺序" width="100">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.sort"></el-input>
|
|
|
+ <span v-else>{{ scope.row.sort }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="id" label="列id" width="100">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.id"></el-input>
|
|
|
+ <span v-else>{{ scope.row.id }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="pid" label="列pid" width="100">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-if="scope.row.isEdit" size="small" v-model="scope.row.pid"></el-input>
|
|
|
+ <span v-else>{{ scope.row.pid }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="flag" label="是否有效" width="100">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <div v-if="scope.row.isEdit">
|
|
|
+ <el-select v-model="scope.row.flag" clearable placeholder="请选择是否有效">
|
|
|
+ <el-option v-for="option in flagOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-select v-model="scope.row.flag" disabled placeholder="请选择是否有效">
|
|
|
+ <el-option v-for="option in flagOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="isShow" label="是否隐藏额外内容" width="130">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <div v-if="scope.row.isEdit">
|
|
|
+ <el-select v-model="scope.row.isShow" clearable placeholder="请选择是否隐藏">
|
|
|
+ <el-option v-for="option in isOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ <div v-else>
|
|
|
+ <el-select v-model="scope.row.isShow" disabled placeholder="请选择是否隐藏">
|
|
|
+ <el-option v-for="option in isOptions" :key="option.code" :label="option.name"
|
|
|
+ :value="option.code"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column fixed="right" label="操作" min-width="180" width="180" center>
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button type="primary" size="small" v-if="!scope.row.isEdit"
|
|
|
+ @click="editTableDisplay(scope.row)">编辑</el-button>
|
|
|
+ <el-button type="primary" size="small" v-if="scope.row.isEdit"
|
|
|
+ @click="updateTableDisplay(scope.row)">保存</el-button>
|
|
|
+ <el-button type="primary" size="small" v-if="scope.row.isEdit"
|
|
|
+ @click="cancelTableDisplay(scope.row, scope.$index)">取消
|
|
|
+ </el-button>
|
|
|
+ <el-button type="danger" size="small"
|
|
|
+ @click.prevent="deleteTableDisplay(scope.$index, scope.row)">
|
|
|
+ 删除
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </template>
|
|
|
+ </PageLayer>
|
|
|
+</template>
|
|
|
+<script setup name="ReportLevel">
|
|
|
+import { ref, onMounted, nextTick, watch } from 'vue'
|
|
|
+import PageLayer from '../../../layout/PageLayer.vue'
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
+import { selectTableDisplay, saveTableDisplay, delTableDisplayByProp } from '../../../api/target-management/report-dict'
|
|
|
+
|
|
|
+const megTip = '列(prop)属性有变更,原始字典记录存在关联,请谨慎做更改,是否确认!!!'
|
|
|
+const flagOptions = [{ code: 'Y', name: '有效' }, { code: 'N', name: '无效' }]
|
|
|
+const isOptions = [{ code: 'true', name: '是' }, { code: '', name: '否' }]
|
|
|
+const alignOptions = [{ code: 'left', name: '靠左' }, { code: 'center', name: '居中' }, { code: 'right', name: '靠右' }]
|
|
|
+
|
|
|
+const tableDisplayData = ref([])
|
|
|
+const reportData = ref({})
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ reportDetailsData: {
|
|
|
+ type: Object,
|
|
|
+ default: {}
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+watch(() => props.reportDetailsData, () => {
|
|
|
+ reportData.value = props.reportDetailsData
|
|
|
+ queryTableDisplay()
|
|
|
+})
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ nextTick(() => {
|
|
|
+ reportData.value = props.reportDetailsData
|
|
|
+ queryTableDisplay()
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
+// 查询指标报表详情配置
|
|
|
+const queryTableDisplay = () => {
|
|
|
+ selectTableDisplay(reportData.value)
|
|
|
+ .then((res) => {
|
|
|
+ tableDisplayData.value = res
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ tableDisplayData.value = []
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 新增行
|
|
|
+const onAddItem = () => {
|
|
|
+ tableDisplayData.value.push({
|
|
|
+ reportId: reportData.value.reportId,
|
|
|
+ title: reportData.value.reportName,
|
|
|
+ levelId: 'patient',
|
|
|
+ levelName: '病人',
|
|
|
+ prop: '',
|
|
|
+ label: '',
|
|
|
+ align: 'left',
|
|
|
+ width: '',
|
|
|
+ sortable: '',
|
|
|
+ flag: 'Y',
|
|
|
+ isShow: '',
|
|
|
+ sort: 1,
|
|
|
+ id: 1,
|
|
|
+ pid: 1,
|
|
|
+ isEdit: true,
|
|
|
+ isAdd: true,
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 指标报表详情配置增删改存开始
|
|
|
+// 编辑
|
|
|
+const editTableDisplay = (row) => {
|
|
|
+ // 备份原始数据
|
|
|
+ row['oldRow'] = JSON.parse(JSON.stringify(row))
|
|
|
+ row.isEdit = true
|
|
|
+}
|
|
|
+// 取消
|
|
|
+const cancelTableDisplay = (row, index) => {
|
|
|
+ // 如果是新增的数据
|
|
|
+ if (row.isAdd) {
|
|
|
+ tableDisplayData.value.splice(index, 1)
|
|
|
+ } else {
|
|
|
+ // 不是新增的数据 还原数据
|
|
|
+ for (const i in row.oldRow) {
|
|
|
+ row[i] = row.oldRow[i]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ queryTableDisplay()
|
|
|
+}
|
|
|
+// 保存
|
|
|
+const updateTableDisplay = (row) => {
|
|
|
+ if (row.isAdd) {
|
|
|
+ if (!row.prop || !row.label || !row.id || !row.pid) {
|
|
|
+ ElMessage({
|
|
|
+ type: "warning",
|
|
|
+ message: "指标报表详情配置prop/label/id/pid必填项当中有未填写,请检查!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ let fe = 0
|
|
|
+ for (let num in tableDisplayData.value) {
|
|
|
+ if (tableDisplayData.value[num].prop === row.prop) {
|
|
|
+ fe++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (fe == 2) {
|
|
|
+ ElMessage({
|
|
|
+ type: "warning",
|
|
|
+ message: "存在重复的指标报表详情配置,请核对!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ callSaveTableDisplay(row, null)
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (!row.reportId || !row.levelId || !row.prop) {
|
|
|
+ ElMessage({
|
|
|
+ type: "warning",
|
|
|
+ message: "指标报表详情配置id不存在,请检查!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!row.label || !row.id || !row.pid) {
|
|
|
+ ElMessage({
|
|
|
+ type: "warning",
|
|
|
+ message: "指标报表详情配置label/id/pid必填项不存在,请检查!",
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ let oldProp = row.oldRow.prop
|
|
|
+ if (oldProp !== row.prop) {
|
|
|
+ ElMessageBox.confirm(megTip, {
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ type: 'warning',
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ dangerouslyUseHTMLString: true
|
|
|
+ }).then(() => {
|
|
|
+ callSaveTableDisplay(row, oldProp)
|
|
|
+ }).catch((action) => {
|
|
|
+ if (action === 'cancel') {
|
|
|
+ queryTableDisplay()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ callSaveTableDisplay(row, oldProp)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const callSaveTableDisplay = (row, oldProp) => {
|
|
|
+ let title = '请确认是否保存<span style="color:#d12020;">' + row.label + '</span>?'
|
|
|
+ ElMessageBox.confirm(title, {
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ type: 'warning',
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ dangerouslyUseHTMLString: true
|
|
|
+ }).then(() => {
|
|
|
+ saveTableDisplay(row).then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ type: "success",
|
|
|
+ message: res.cg,
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ if (oldProp !== null && oldProp !== row.prop) {
|
|
|
+ // 删除原始数据
|
|
|
+ delTableDisplayByProp(row.reportId, row.levelId, oldProp).then((res) => {
|
|
|
+ queryTableDisplay()
|
|
|
+ })
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ queryTableDisplay()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }).catch((action) => {
|
|
|
+ if (action === 'cancel') {
|
|
|
+ queryTableDisplay()
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const deleteTableDisplay = (index, row) => {
|
|
|
+ let title = '请确认是否删除<span style="color:#d12020;">' + row.label + '</span>?'
|
|
|
+ ElMessageBox.confirm(title, {
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ type: 'warning',
|
|
|
+ distinguishCancelAndClose: true,
|
|
|
+ dangerouslyUseHTMLString: true
|
|
|
+ }).then(() => {
|
|
|
+ delTableDisplayByProp(row.reportId, row.levelId, row.prop).then((res) => {
|
|
|
+ ElMessage({
|
|
|
+ type: "success",
|
|
|
+ message: res.cg,
|
|
|
+ duration: 2500,
|
|
|
+ showClose: true,
|
|
|
+ });
|
|
|
+ queryTableDisplay()
|
|
|
+ return
|
|
|
+ })
|
|
|
+ }).catch((action) => {
|
|
|
+ if (action === 'cancel') {
|
|
|
+ queryTableDisplay()
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+// 指标报表详情配置增删改存结束
|
|
|
+</script>
|
|
|
+<style lang="scss" deep>
|
|
|
+.el-dialog__body {
|
|
|
+ padding: 0 16px;
|
|
|
+ height: calc(100% - 25px);
|
|
|
+}
|
|
|
+
|
|
|
+.el-tabs {
|
|
|
+ height: calc(100% - 27px);
|
|
|
+
|
|
|
+ .el-tabs__content {
|
|
|
+ padding: 5px;
|
|
|
+ height: calc(100% - 27px);
|
|
|
+ }
|
|
|
+
|
|
|
+ .el-tab-pane {
|
|
|
+ height: calc(100% - 27px);
|
|
|
+ overflow: auto;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|