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> <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> </FormCreate>
</template> </template>
@ -39,7 +45,7 @@
api: any; // api: any; //
}>(); }>();
const emit = defineEmits(['update:api', 'update', 'update:formItem', 'change']); const emit = defineEmits(['update:api', 'update', 'update:formItem', 'change', 'mounted']);
const fApi = computed({ const fApi = computed({
get() { get() {
@ -262,10 +268,24 @@
getFormCreateItem(); getFormCreateItem();
getControlFormItems(); 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(() => { watchEffect(() => {
formItems.value = props.formRule; formItems.value = props.formRule;
//
initFormItem(); initFormItem();
// setValue();
}); });
const option = { const option = {
@ -291,6 +311,11 @@
emit('change', defaultValue, formRuleItem, api); emit('change', defaultValue, formRuleItem, api);
} }
function handleMounted() {
// setValue();
emit('mounted');
}
watch( watch(
() => formRuleList.value, () => formRuleList.value,
(val) => { (val) => {

View File

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

View File

@ -33,6 +33,8 @@
v-model:api="fApi" v-model:api="fApi"
v-model:form-item="platformItem" v-model:form-item="platformItem"
:form-rule="platformRules" :form-rule="platformRules"
@change="changeHandler"
@mounted="handleMounted"
/> />
<!-- 同步机制 --> <!-- 同步机制 -->
<a-form-item field="MECHANISM" :label="t('project.menu.syncMechanism')"> <a-form-item field="MECHANISM" :label="t('project.menu.syncMechanism')">
@ -280,7 +282,22 @@
console.log(e); 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( watch(
() => props.visible, () => props.visible,
(val) => { (val) => {