fix
Showing
2 changed files
with
106 additions
and
22 deletions
| ... | @@ -6,7 +6,11 @@ | ... | @@ -6,7 +6,11 @@ |
| 6 | class="standard-modal" | 6 | class="standard-modal" |
| 7 | :close-on-click-modal="false" | 7 | :close-on-click-modal="false" |
| 8 | > | 8 | > |
| 9 | <el-form :rules="formRules" :model="form" ref="formEl" require-asterisk-position="right"> | 9 | <el-form |
| 10 | :rules="formRules" :model="form" ref="formEl" | ||
| 11 | require-asterisk-position="right" | ||
| 12 | v-loading="loading" | ||
| 13 | > | ||
| 10 | <el-row> | 14 | <el-row> |
| 11 | <el-col :span="12" style="padding-right:10px"> | 15 | <el-col :span="12" style="padding-right:10px"> |
| 12 | <el-form-item label="元数据标准名称" prop="standardName"> | 16 | <el-form-item label="元数据标准名称" prop="standardName"> |
| ... | @@ -32,15 +36,20 @@ | ... | @@ -32,15 +36,20 @@ |
| 32 | </el-col> | 36 | </el-col> |
| 33 | <el-col :span="12"> | 37 | <el-col :span="12"> |
| 34 | <el-form-item label="上级标准" prop="parentGuid"> | 38 | <el-form-item label="上级标准" prop="parentGuid"> |
| 35 | <!-- <el-tree-select | 39 | <el-tree-select |
| 36 | v-model="form.parentGuid" | 40 | v-model="form.parentGuid" |
| 37 | :data="standardOptions" | 41 | :data="treeSelectData" |
| 38 | :props="standardProps" | 42 | :props="standardProps" |
| 39 | node-key="guid" | 43 | node-key="guid" |
| 40 | :expandOnNodeClick="false" | 44 | :highlight-current="true" |
| 45 | :expand-on-click-node="true" | ||
| 46 | show-checkbox | ||
| 47 | check-strictly | ||
| 41 | placeholder="请选择" | 48 | placeholder="请选择" |
| 42 | /> --> | 49 | :disabled="parentGuidDisabled" |
| 43 | <el-cascader | 50 | @check-change="parentGuidCheck" |
| 51 | /> | ||
| 52 | <!-- <el-cascader | ||
| 44 | v-model="form.parentGuid" | 53 | v-model="form.parentGuid" |
| 45 | :options="standardOptions" | 54 | :options="standardOptions" |
| 46 | :props="standardProps" | 55 | :props="standardProps" |
| ... | @@ -48,7 +57,7 @@ | ... | @@ -48,7 +57,7 @@ |
| 48 | style="width:100%" | 57 | style="width:100%" |
| 49 | clearable | 58 | clearable |
| 50 | @change="parentGuidChange" | 59 | @change="parentGuidChange" |
| 51 | /> | 60 | /> --> |
| 52 | </el-form-item> | 61 | </el-form-item> |
| 53 | </el-col> | 62 | </el-col> |
| 54 | <el-col :span="24"> | 63 | <el-col :span="24"> |
| ... | @@ -61,40 +70,41 @@ | ... | @@ -61,40 +70,41 @@ |
| 61 | <div class="table-form"> | 70 | <div class="table-form"> |
| 62 | <div class="table-form-wrapper" v-for="item,index in form.fieldRQVOS" :key="index"> | 71 | <div class="table-form-wrapper" v-for="item,index in form.fieldRQVOS" :key="index"> |
| 63 | <div class="table-form-item"> | 72 | <div class="table-form-item"> |
| 64 | <el-select v-model="item.fileNameCode" style="width:160px" clearable> | 73 | <el-select v-model="item.fileNameCode" style="width:160px" clearable :disabled="fieldsDisabled"> |
| 65 | <el-option v-for="item in fieldOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> | 74 | <el-option v-for="item in fieldOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> |
| 66 | </el-select> | 75 | </el-select> |
| 67 | </div> | 76 | </div> |
| 68 | <div class="table-form-item"> | 77 | <div class="table-form-item"> |
| 69 | <el-select v-model="item.isNotnull" style="width: 96px" placeholder="是否必填" clearable> | 78 | <el-select v-model="item.isNotnull" style="width: 96px" placeholder="是否必填" clearable :disabled="fieldsDisabled"> |
| 70 | <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> | 79 | <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> |
| 71 | </el-select> | 80 | </el-select> |
| 72 | </div> | 81 | </div> |
| 73 | <div class="table-form-item"> | 82 | <div class="table-form-item"> |
| 74 | <el-select v-model="item.isDisplay" style="width:96px" placeholder="是否展示" clearable> | 83 | <el-select v-model="item.isDisplay" style="width:96px" placeholder="是否展示" clearable :disabled="fieldsDisabled"> |
| 75 | <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> | 84 | <el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> |
| 76 | </el-select> | 85 | </el-select> |
| 77 | </div> | 86 | </div> |
| 78 | <div class="table-form-item"> | 87 | <div class="table-form-item"> |
| 79 | <el-select v-model="item.inputTypeCode" style="width:130px" clearable @change="v => inputTypeChange(v, item)"> | 88 | <el-select v-model="item.inputTypeCode" style="width:130px" clearable :disabled="fieldsDisabled" |
| 89 | @change="v => inputTypeChange(v, item)"> | ||
| 80 | <el-option v-for="item in inputOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> | 90 | <el-option v-for="item in inputOptions" :label="item.label" :value="item.value" :key="item.value"></el-option> |
| 81 | </el-select> | 91 | </el-select> |
| 82 | </div> | 92 | </div> |
| 83 | <div class="table-form-item"> | 93 | <div class="table-form-item"> |
| 84 | <el-select v-if="item.inputTypeCode == 2" v-model="item.dataTypeCode" style="width:160px" filterable clearable> | 94 | <el-select v-if="item.inputTypeCode == 2" v-model="item.dataTypeCode" style="width:160px" filterable clearable :disabled="fieldsDisabled"> |
| 85 | <el-option v-for="item in allDictOptions" :label="item.dictTypeName" :value="item.dictTypeName" :key="item.guid"></el-option> | 95 | <el-option v-for="item in allDictOptions" :label="item.dictTypeName" :value="item.dictTypeName" :key="item.guid"></el-option> |
| 86 | </el-select> | 96 | </el-select> |
| 87 | <el-input v-else-if="item.inputTypeCode == 3" v-model="item.validateExpression" placeholder="请输入"></el-input> | 97 | <el-input v-else-if="item.inputTypeCode == 3" v-model="item.validateExpression" placeholder="请输入"></el-input> |
| 88 | </div> | 98 | </div> |
| 89 | <div class="table-form-operation"> | 99 | <div class="table-form-operation" v-if="!fieldsDisabled"> |
| 90 | <!-- <el-icon color="#4fa1a4" @click="() => addTableItem(index)"> | 100 | <!-- <el-icon color="#4fa1a4" @click="() => addTableItem(index)"> |
| 91 | <CirclePlus /> | 101 | <CirclePlus /> |
| 92 | </el-icon> --> | 102 | </el-icon> --> |
| 93 | <el-icon color="#b2b2b2" @click="() => deleteTableItem(index)" :size="25"><Delete /></el-icon> | 103 | <el-icon color="#b2b2b2" @click="() => deleteTableItem(index)" :size="22" class="custom-icon" style="margin-top:3px"><Delete /></el-icon> |
| 94 | </div> | 104 | </div> |
| 95 | </div> | 105 | </div> |
| 96 | <div class="table-form-add"> | 106 | <div class="table-form-add" v-if="!fieldsDisabled"> |
| 97 | <el-icon color="#4fa1a4" @click="() => addTableItem(index)" :size="25"> | 107 | <el-icon color="#4fa1a4" @click="() => addTableItem(index)" :size="20" class="custom-icon"> |
| 98 | <CirclePlus /> | 108 | <CirclePlus /> |
| 99 | </el-icon> | 109 | </el-icon> |
| 100 | <span @click="() => addTableItem(index)" style="cursor: pointer;">添加字段</span> | 110 | <span @click="() => addTableItem(index)" style="cursor: pointer;">添加字段</span> |
| ... | @@ -115,6 +125,7 @@ | ... | @@ -115,6 +125,7 @@ |
| 115 | </template> | 125 | </template> |
| 116 | 126 | ||
| 117 | <script setup lang="ts"> | 127 | <script setup lang="ts"> |
| 128 | // import { cloneDeep } from 'lodesh-es' | ||
| 118 | import { watch } from 'vue' | 129 | import { watch } from 'vue' |
| 119 | import { Search, CirclePlus, Delete } from '@element-plus/icons-vue' | 130 | import { Search, CirclePlus, Delete } from '@element-plus/icons-vue' |
| 120 | import { saveMetaStandard, deleteMetaStandard, updateMetaStandard, getMetaStandardDetail } from '@/api/modules/dataMetaService' | 131 | import { saveMetaStandard, deleteMetaStandard, updateMetaStandard, getMetaStandardDetail } from '@/api/modules/dataMetaService' |
| ... | @@ -138,6 +149,10 @@ const props = defineProps({ | ... | @@ -138,6 +149,10 @@ const props = defineProps({ |
| 138 | guid: { | 149 | guid: { |
| 139 | type: String, | 150 | type: String, |
| 140 | default: '' | 151 | default: '' |
| 152 | }, | ||
| 153 | currentNode: { | ||
| 154 | type: Object, | ||
| 155 | default: () => ({}) | ||
| 141 | } | 156 | } |
| 142 | }) | 157 | }) |
| 143 | const emit = defineEmits(['update:modelValue', 'success', 'confirm']); | 158 | const emit = defineEmits(['update:modelValue', 'success', 'confirm']); |
| ... | @@ -152,6 +167,34 @@ const visible = computed({ | ... | @@ -152,6 +167,34 @@ const visible = computed({ |
| 152 | const title = computed(() => { | 167 | const title = computed(() => { |
| 153 | return props.type === 'add' ? '新增元数据标准' : '编辑元数据标准' | 168 | return props.type === 'add' ? '新增元数据标准' : '编辑元数据标准' |
| 154 | }) | 169 | }) |
| 170 | const parentGuidDisabled = computed(() => { | ||
| 171 | // 元数据标准有数据,有子集,不可编辑上级标准 | ||
| 172 | let { currentNode, type } = props | ||
| 173 | if (type === 'add') { | ||
| 174 | return false | ||
| 175 | } | ||
| 176 | if (currentNode.isHaveData === 'Y' || currentNode.children) { | ||
| 177 | return true | ||
| 178 | } | ||
| 179 | }) | ||
| 180 | const fieldsDisabled = computed(() => { | ||
| 181 | // 二级节点: 该节点,所有子节点有字段数据后不可修改 | ||
| 182 | // 三级节点以下:禁止修改 | ||
| 183 | let { currentNode, type } = props | ||
| 184 | if (type === 'add') { | ||
| 185 | return false | ||
| 186 | } | ||
| 187 | if (currentNode.level == 2) { | ||
| 188 | if (currentNode.isHaveData === 'Y' || currentNode.children) { | ||
| 189 | return true | ||
| 190 | } | ||
| 191 | return false | ||
| 192 | } | ||
| 193 | if (currentNode.level <= 3) { | ||
| 194 | return true | ||
| 195 | } | ||
| 196 | }) | ||
| 197 | const treeSelectData = ref([]) | ||
| 155 | 198 | ||
| 156 | /** | 199 | /** |
| 157 | * 配置项列表 | 200 | * 配置项列表 |
| ... | @@ -163,6 +206,10 @@ const standardProps = { | ... | @@ -163,6 +206,10 @@ const standardProps = { |
| 163 | checkStrictly: true, | 206 | checkStrictly: true, |
| 164 | emitPath: false | 207 | emitPath: false |
| 165 | } | 208 | } |
| 209 | const standardTreeProps = { | ||
| 210 | label: 'standardName', | ||
| 211 | value: 'guid', | ||
| 212 | } | ||
| 166 | const fieldOptions = ref([]) | 213 | const fieldOptions = ref([]) |
| 167 | const isBooleanOptions = [ | 214 | const isBooleanOptions = [ |
| 168 | { label: '是', value: 'Y' }, | 215 | { label: '是', value: 'Y' }, |
| ... | @@ -197,6 +244,16 @@ function parentGuidChange (val) { | ... | @@ -197,6 +244,16 @@ function parentGuidChange (val) { |
| 197 | const isFirst = props.standardOptions.find(item => item.guid === val) | 244 | const isFirst = props.standardOptions.find(item => item.guid === val) |
| 198 | if (isFirst) { | 245 | if (isFirst) { |
| 199 | form.value.fieldRQVOS = [{...tableFormTpl}] | 246 | form.value.fieldRQVOS = [{...tableFormTpl}] |
| 247 | } | ||
| 248 | } | ||
| 249 | function parentGuidCheck (node, isCheck) { | ||
| 250 | console.log(node, isCheck) | ||
| 251 | if (!node || !isCheck) { | ||
| 252 | form.value.fieldRQVOS = [] | ||
| 253 | return | ||
| 254 | } | ||
| 255 | if (node.level == 1) { | ||
| 256 | form.value.fieldRQVOS = [{...tableFormTpl}] | ||
| 200 | } | 257 | } |
| 201 | } | 258 | } |
| 202 | 259 | ||
| ... | @@ -229,14 +286,16 @@ function inputTypeChange (val, item) { | ... | @@ -229,14 +286,16 @@ function inputTypeChange (val, item) { |
| 229 | } | 286 | } |
| 230 | } | 287 | } |
| 231 | 288 | ||
| 289 | const loading = ref(false) | ||
| 232 | function getDetail () { | 290 | function getDetail () { |
| 233 | getMetaStandardDetail(props.guid).then((res:any) => { | 291 | loading.value = true |
| 292 | return getMetaStandardDetail(props.guid).then((res:any) => { | ||
| 234 | if (res.code === proxy.$passCode) { | 293 | if (res.code === proxy.$passCode) { |
| 235 | const data = res.data | 294 | const data = res.data |
| 236 | data.fieldRQVOS = data.fieldRSVOS | 295 | data.fieldRQVOS = data.fieldRSVOS |
| 237 | form.value = { ...data } | 296 | form.value = { ...data } |
| 238 | } | 297 | } |
| 239 | }) | 298 | }).finally(() => loading.value = false) |
| 240 | } | 299 | } |
| 241 | const confirmLoading = ref(false) | 300 | const confirmLoading = ref(false) |
| 242 | function confirm () { | 301 | function confirm () { |
| ... | @@ -265,16 +324,33 @@ watch( | ... | @@ -265,16 +324,33 @@ watch( |
| 265 | (v) => { | 324 | (v) => { |
| 266 | if (!v) return | 325 | if (!v) return |
| 267 | 326 | ||
| 327 | // 上级标准:不能选自己,有数据的标准不能选 | ||
| 328 | treeSelectData.value = JSON.parse(JSON.stringify(props.standardOptions)) | ||
| 329 | |||
| 330 | |||
| 268 | if (props.type === 'edit') { | 331 | if (props.type === 'edit') { |
| 269 | getDetail() | 332 | getDetail().then(() => formatOptions(treeSelectData.value)) |
| 270 | } else { | 333 | } else { |
| 271 | form.value = { ...formTpl } | 334 | form.value = { ...formTpl } |
| 335 | formatOptions(treeSelectData.value) | ||
| 272 | } | 336 | } |
| 273 | setTimeout(() => { | 337 | setTimeout(() => { |
| 274 | formEl.value.clearValidate() | 338 | formEl.value.clearValidate() |
| 275 | }, 100) | 339 | }, 100) |
| 276 | } | 340 | } |
| 277 | ) | 341 | ) |
| 342 | function formatOptions (options) { | ||
| 343 | options.forEach((item:any) => { | ||
| 344 | let disabled = form.value.guid === item.guid ? true : false | ||
| 345 | if (item.isHaveData === 'Y') { | ||
| 346 | disabled = true | ||
| 347 | } | ||
| 348 | item.disabled = disabled | ||
| 349 | if (item.children) { | ||
| 350 | formatOptions(item.children) | ||
| 351 | } | ||
| 352 | }) | ||
| 353 | } | ||
| 278 | onBeforeMount(() => { | 354 | onBeforeMount(() => { |
| 279 | getParamsList({ dictType: '发布单位' }).then((res:any) => { | 355 | getParamsList({ dictType: '发布单位' }).then((res:any) => { |
| 280 | if (res.code === proxy.$passCode) { | 356 | if (res.code === proxy.$passCode) { |
| ... | @@ -334,6 +410,9 @@ onBeforeMount(() => { | ... | @@ -334,6 +410,9 @@ onBeforeMount(() => { |
| 334 | display: flex; | 410 | display: flex; |
| 335 | align-items: center; | 411 | align-items: center; |
| 336 | color: #4fa1a4; | 412 | color: #4fa1a4; |
| 413 | > span { | ||
| 414 | margin-left: 4px; | ||
| 415 | } | ||
| 337 | } | 416 | } |
| 338 | } | 417 | } |
| 339 | </style> | 418 | </style> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -3,7 +3,7 @@ ame: metadataStandard | ... | @@ -3,7 +3,7 @@ ame: metadataStandard |
| 3 | </route> | 3 | </route> |
| 4 | 4 | ||
| 5 | <script lang="ts" setup name="metadataStandard"> | 5 | <script lang="ts" setup name="metadataStandard"> |
| 6 | import { ref, reactive } from 'vue' | 6 | import { ref, reactive, computed } from 'vue' |
| 7 | import { ElMessage, ElMessageBox } from "element-plus"; | 7 | import { ElMessage, ElMessageBox } from "element-plus"; |
| 8 | import { Search, CirclePlus } from '@element-plus/icons-vue' | 8 | import { Search, CirclePlus } from '@element-plus/icons-vue' |
| 9 | import Tree from '@/components/Tree/index.vue' | 9 | import Tree from '@/components/Tree/index.vue' |
| ... | @@ -62,6 +62,8 @@ function treeCustomClick (node, type) { | ... | @@ -62,6 +62,8 @@ function treeCustomClick (node, type) { |
| 62 | // 编辑 | 62 | // 编辑 |
| 63 | standardDialog.type = 'edit' | 63 | standardDialog.type = 'edit' |
| 64 | standardDialog.guid = node.data.guid | 64 | standardDialog.guid = node.data.guid |
| 65 | node.data.level = node.level | ||
| 66 | standardDialog.currentNode = node.data | ||
| 65 | standardDialog.visible = true | 67 | standardDialog.visible = true |
| 66 | return | 68 | return |
| 67 | } | 69 | } |
| ... | @@ -74,7 +76,7 @@ function treeCustomClick (node, type) { | ... | @@ -74,7 +76,7 @@ function treeCustomClick (node, type) { |
| 74 | }).then(() => deleteTreeNode(node.data.guid)) | 76 | }).then(() => deleteTreeNode(node.data.guid)) |
| 75 | } | 77 | } |
| 76 | } | 78 | } |
| 77 | function getTree () { | 79 | function getTree (refresh = false) { |
| 78 | getMetaStandardTree().then((res:any) => { | 80 | getMetaStandardTree().then((res:any) => { |
| 79 | if (res.code === proxy.$passCode) { | 81 | if (res.code === proxy.$passCode) { |
| 80 | let data = res.data || [] | 82 | let data = res.data || [] |
| ... | @@ -89,6 +91,7 @@ function getTree () { | ... | @@ -89,6 +91,7 @@ function getTree () { |
| 89 | } | 91 | } |
| 90 | }) | 92 | }) |
| 91 | } | 93 | } |
| 94 | |||
| 92 | function deleteTreeNode (guid) { | 95 | function deleteTreeNode (guid) { |
| 93 | deleteMetaStandard([guid]).then((res:any) => { | 96 | deleteMetaStandard([guid]).then((res:any) => { |
| 94 | if (res.code === proxy.$passCode) { | 97 | if (res.code === proxy.$passCode) { |
| ... | @@ -359,7 +362,8 @@ const formInfo = ref({ | ... | @@ -359,7 +362,8 @@ const formInfo = ref({ |
| 359 | const standardDialog = reactive({ | 362 | const standardDialog = reactive({ |
| 360 | visible: false, | 363 | visible: false, |
| 361 | type: 'add', | 364 | type: 'add', |
| 362 | guid: null | 365 | guid: null, |
| 366 | currentNode: null | ||
| 363 | }) | 367 | }) |
| 364 | function openStandardDialog () { | 368 | function openStandardDialog () { |
| 365 | standardDialog.type = 'add' | 369 | standardDialog.type = 'add' |
| ... | @@ -492,6 +496,7 @@ const viewGraph = () => { | ... | @@ -492,6 +496,7 @@ const viewGraph = () => { |
| 492 | :standardOptions="treeInfo.data" | 496 | :standardOptions="treeInfo.data" |
| 493 | :type="standardDialog.type" | 497 | :type="standardDialog.type" |
| 494 | :guid="standardDialog.guid" | 498 | :guid="standardDialog.guid" |
| 499 | :currentNode="standardDialog.currentNode" | ||
| 495 | @success="getTree" | 500 | @success="getTree" |
| 496 | /> | 501 | /> |
| 497 | <StandardFieldsDialog | 502 | <StandardFieldsDialog | ... | ... |
-
Please register or sign in to post a comment