59b883fe by fanguang Committed by lihua

fix

1 parent 3470de9c
......@@ -6,7 +6,11 @@
class="standard-modal"
:close-on-click-modal="false"
>
<el-form :rules="formRules" :model="form" ref="formEl" require-asterisk-position="right">
<el-form
:rules="formRules" :model="form" ref="formEl"
require-asterisk-position="right"
v-loading="loading"
>
<el-row>
<el-col :span="12" style="padding-right:10px">
<el-form-item label="元数据标准名称" prop="standardName">
......@@ -32,15 +36,20 @@
</el-col>
<el-col :span="12">
<el-form-item label="上级标准" prop="parentGuid">
<!-- <el-tree-select
<el-tree-select
v-model="form.parentGuid"
:data="standardOptions"
:data="treeSelectData"
:props="standardProps"
node-key="guid"
:expandOnNodeClick="false"
:highlight-current="true"
:expand-on-click-node="true"
show-checkbox
check-strictly
placeholder="请选择"
/> -->
<el-cascader
:disabled="parentGuidDisabled"
@check-change="parentGuidCheck"
/>
<!-- <el-cascader
v-model="form.parentGuid"
:options="standardOptions"
:props="standardProps"
......@@ -48,7 +57,7 @@
style="width:100%"
clearable
@change="parentGuidChange"
/>
/> -->
</el-form-item>
</el-col>
<el-col :span="24">
......@@ -61,40 +70,41 @@
<div class="table-form">
<div class="table-form-wrapper" v-for="item,index in form.fieldRQVOS" :key="index">
<div class="table-form-item">
<el-select v-model="item.fileNameCode" style="width:160px" clearable>
<el-select v-model="item.fileNameCode" style="width:160px" clearable :disabled="fieldsDisabled">
<el-option v-for="item in fieldOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
</el-select>
</div>
<div class="table-form-item">
<el-select v-model="item.isNotnull" style="width: 96px" placeholder="是否必填" clearable>
<el-select v-model="item.isNotnull" style="width: 96px" placeholder="是否必填" clearable :disabled="fieldsDisabled">
<el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
</el-select>
</div>
<div class="table-form-item">
<el-select v-model="item.isDisplay" style="width:96px" placeholder="是否展示" clearable>
<el-select v-model="item.isDisplay" style="width:96px" placeholder="是否展示" clearable :disabled="fieldsDisabled">
<el-option v-for="item in isBooleanOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
</el-select>
</div>
<div class="table-form-item">
<el-select v-model="item.inputTypeCode" style="width:130px" clearable @change="v => inputTypeChange(v, item)">
<el-select v-model="item.inputTypeCode" style="width:130px" clearable :disabled="fieldsDisabled"
@change="v => inputTypeChange(v, item)">
<el-option v-for="item in inputOptions" :label="item.label" :value="item.value" :key="item.value"></el-option>
</el-select>
</div>
<div class="table-form-item">
<el-select v-if="item.inputTypeCode == 2" v-model="item.dataTypeCode" style="width:160px" filterable clearable>
<el-select v-if="item.inputTypeCode == 2" v-model="item.dataTypeCode" style="width:160px" filterable clearable :disabled="fieldsDisabled">
<el-option v-for="item in allDictOptions" :label="item.dictTypeName" :value="item.dictTypeName" :key="item.guid"></el-option>
</el-select>
<el-input v-else-if="item.inputTypeCode == 3" v-model="item.validateExpression" placeholder="请输入"></el-input>
</div>
<div class="table-form-operation">
<div class="table-form-operation" v-if="!fieldsDisabled">
<!-- <el-icon color="#4fa1a4" @click="() => addTableItem(index)">
<CirclePlus />
</el-icon> -->
<el-icon color="#b2b2b2" @click="() => deleteTableItem(index)" :size="25"><Delete /></el-icon>
<el-icon color="#b2b2b2" @click="() => deleteTableItem(index)" :size="22" class="custom-icon" style="margin-top:3px"><Delete /></el-icon>
</div>
</div>
<div class="table-form-add">
<el-icon color="#4fa1a4" @click="() => addTableItem(index)" :size="25">
<div class="table-form-add" v-if="!fieldsDisabled">
<el-icon color="#4fa1a4" @click="() => addTableItem(index)" :size="20" class="custom-icon">
<CirclePlus />
</el-icon>
<span @click="() => addTableItem(index)" style="cursor: pointer;">添加字段</span>
......@@ -115,6 +125,7 @@
</template>
<script setup lang="ts">
// import { cloneDeep } from 'lodesh-es'
import { watch } from 'vue'
import { Search, CirclePlus, Delete } from '@element-plus/icons-vue'
import { saveMetaStandard, deleteMetaStandard, updateMetaStandard, getMetaStandardDetail } from '@/api/modules/dataMetaService'
......@@ -138,6 +149,10 @@ const props = defineProps({
guid: {
type: String,
default: ''
},
currentNode: {
type: Object,
default: () => ({})
}
})
const emit = defineEmits(['update:modelValue', 'success', 'confirm']);
......@@ -152,6 +167,34 @@ const visible = computed({
const title = computed(() => {
return props.type === 'add' ? '新增元数据标准' : '编辑元数据标准'
})
const parentGuidDisabled = computed(() => {
// 元数据标准有数据,有子集,不可编辑上级标准
let { currentNode, type } = props
if (type === 'add') {
return false
}
if (currentNode.isHaveData === 'Y' || currentNode.children) {
return true
}
})
const fieldsDisabled = computed(() => {
// 二级节点: 该节点,所有子节点有字段数据后不可修改
// 三级节点以下:禁止修改
let { currentNode, type } = props
if (type === 'add') {
return false
}
if (currentNode.level == 2) {
if (currentNode.isHaveData === 'Y' || currentNode.children) {
return true
}
return false
}
if (currentNode.level <= 3) {
return true
}
})
const treeSelectData = ref([])
/**
* 配置项列表
......@@ -163,6 +206,10 @@ const standardProps = {
checkStrictly: true,
emitPath: false
}
const standardTreeProps = {
label: 'standardName',
value: 'guid',
}
const fieldOptions = ref([])
const isBooleanOptions = [
{ label: '是', value: 'Y' },
......@@ -197,6 +244,16 @@ function parentGuidChange (val) {
const isFirst = props.standardOptions.find(item => item.guid === val)
if (isFirst) {
form.value.fieldRQVOS = [{...tableFormTpl}]
}
}
function parentGuidCheck (node, isCheck) {
console.log(node, isCheck)
if (!node || !isCheck) {
form.value.fieldRQVOS = []
return
}
if (node.level == 1) {
form.value.fieldRQVOS = [{...tableFormTpl}]
}
}
......@@ -229,14 +286,16 @@ function inputTypeChange (val, item) {
}
}
const loading = ref(false)
function getDetail () {
getMetaStandardDetail(props.guid).then((res:any) => {
loading.value = true
return getMetaStandardDetail(props.guid).then((res:any) => {
if (res.code === proxy.$passCode) {
const data = res.data
data.fieldRQVOS = data.fieldRSVOS
form.value = { ...data }
}
})
}).finally(() => loading.value = false)
}
const confirmLoading = ref(false)
function confirm () {
......@@ -265,16 +324,33 @@ watch(
(v) => {
if (!v) return
// 上级标准:不能选自己,有数据的标准不能选
treeSelectData.value = JSON.parse(JSON.stringify(props.standardOptions))
if (props.type === 'edit') {
getDetail()
getDetail().then(() => formatOptions(treeSelectData.value))
} else {
form.value = { ...formTpl }
formatOptions(treeSelectData.value)
}
setTimeout(() => {
formEl.value.clearValidate()
}, 100)
}
)
function formatOptions (options) {
options.forEach((item:any) => {
let disabled = form.value.guid === item.guid ? true : false
if (item.isHaveData === 'Y') {
disabled = true
}
item.disabled = disabled
if (item.children) {
formatOptions(item.children)
}
})
}
onBeforeMount(() => {
getParamsList({ dictType: '发布单位' }).then((res:any) => {
if (res.code === proxy.$passCode) {
......@@ -334,6 +410,9 @@ onBeforeMount(() => {
display: flex;
align-items: center;
color: #4fa1a4;
> span {
margin-left: 4px;
}
}
}
</style>
\ No newline at end of file
......
......@@ -3,7 +3,7 @@ ame: metadataStandard
</route>
<script lang="ts" setup name="metadataStandard">
import { ref, reactive } from 'vue'
import { ref, reactive, computed } from 'vue'
import { ElMessage, ElMessageBox } from "element-plus";
import { Search, CirclePlus } from '@element-plus/icons-vue'
import Tree from '@/components/Tree/index.vue'
......@@ -62,6 +62,8 @@ function treeCustomClick (node, type) {
// 编辑
standardDialog.type = 'edit'
standardDialog.guid = node.data.guid
node.data.level = node.level
standardDialog.currentNode = node.data
standardDialog.visible = true
return
}
......@@ -74,7 +76,7 @@ function treeCustomClick (node, type) {
}).then(() => deleteTreeNode(node.data.guid))
}
}
function getTree () {
function getTree (refresh = false) {
getMetaStandardTree().then((res:any) => {
if (res.code === proxy.$passCode) {
let data = res.data || []
......@@ -89,6 +91,7 @@ function getTree () {
}
})
}
function deleteTreeNode (guid) {
deleteMetaStandard([guid]).then((res:any) => {
if (res.code === proxy.$passCode) {
......@@ -359,7 +362,8 @@ const formInfo = ref({
const standardDialog = reactive({
visible: false,
type: 'add',
guid: null
guid: null,
currentNode: null
})
function openStandardDialog () {
standardDialog.type = 'add'
......@@ -492,6 +496,7 @@ const viewGraph = () => {
:standardOptions="treeInfo.data"
:type="standardDialog.type"
:guid="standardDialog.guid"
:currentNode="standardDialog.currentNode"
@success="getTree"
/>
<StandardFieldsDialog
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!