fix(项目管理): 修复应用设置三方缺陷回显校验不能保存问题

This commit is contained in:
xinxin.wu 2024-04-09 12:03:46 +08:00 committed by 刘瑞斌
parent af6689835f
commit 7948c7f0a8
3 changed files with 44 additions and 3 deletions

View File

@ -1,5 +1,11 @@
<template>
<FormCreate v-model:api="fApi" :rule="formRuleList" :option="props.options || option" @change="changeHandler">
<FormCreate
v-model:api="fApi"
:rule="formRuleList"
:option="props.options || option"
@change="changeHandler"
@mounted="handleMounted"
>
</FormCreate>
</template>
@ -39,7 +45,7 @@
api: any; //
}>();
const emit = defineEmits(['update:api', 'update', 'update:formItem', 'change']);
const emit = defineEmits(['update:api', 'update', 'update:formItem', 'change', 'mounted']);
const fApi = computed({
get() {
@ -262,10 +268,24 @@
getFormCreateItem();
getControlFormItems();
}
function setValue() {
nextTick(() => {
console.log(props.formRule);
const tempObj: Record<string, any> = {};
props.formRule.forEach((item) => {
tempObj[item.name] = item.value;
});
fApi.value?.setValue({ ...tempObj });
});
}
watchEffect(() => {
formItems.value = props.formRule;
//
initFormItem();
// setValue();
});
const option = {
@ -291,6 +311,11 @@
emit('change', defaultValue, formRuleItem, api);
}
function handleMounted() {
// setValue();
emit('mounted');
}
watch(
() => formRuleList.value,
(val) => {

View File

@ -592,7 +592,6 @@
wrap: {
'asterisk-position': 'end',
'validate-trigger': ['change'],
'hide-asterisk': true,
},
};

View File

@ -33,6 +33,8 @@
v-model:api="fApi"
v-model:form-item="platformItem"
:form-rule="platformRules"
@change="changeHandler"
@mounted="handleMounted"
/>
<!-- 同步机制 -->
<a-form-item field="MECHANISM" :label="t('project.menu.syncMechanism')">
@ -280,7 +282,22 @@
console.log(e);
}
};
function setValue() {
const tempObj: Record<string, any> = {};
platformRules.value.forEach((item) => {
tempObj[item.name] = item.value;
});
fApi.value?.setValue({ ...tempObj });
}
function changeHandler(a, b) {
fApi.value.validateField(b.field);
fApi.value.refreshValidate();
}
function handleMounted() {
setValue();
}
watch(
() => props.visible,
(val) => {