feat: 表单编辑逻辑修改
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
</slot>
|
</slot>
|
||||||
关闭
|
关闭
|
||||||
</a-button>
|
</a-button>
|
||||||
<a-button style="margin-right: 10px" type="primary" @click="editForm" v-if="mode === 'view' && type === 'readonly'">
|
<a-button style="margin-right: 10px" type="primary" @click="editForm" v-if="mode === 'view'">
|
||||||
<slot name="icon">
|
<slot name="icon">
|
||||||
<edit-outlined />
|
<edit-outlined />
|
||||||
</slot>
|
</slot>
|
||||||
@ -65,15 +65,14 @@ if (hash.indexOf('createForm') > 0) {
|
|||||||
} else if (hash.indexOf('viewForm') > 0) {
|
} else if (hash.indexOf('viewForm') > 0) {
|
||||||
mode.value = 'view';
|
mode.value = 'view';
|
||||||
}
|
}
|
||||||
const type = ref('readonly')
|
|
||||||
|
|
||||||
dynamicComponent.value = defineAsyncComponent({
|
dynamicComponent.value = defineAsyncComponent({
|
||||||
loader: () => import(`./../../views/${pathArr[0]}/${pathArr[1]}/components/Form.vue`)
|
loader: () => import(`./../../views/${pathArr[0]}/${pathArr[1]}/components/Form.vue`)
|
||||||
});
|
});
|
||||||
|
|
||||||
function editForm() {
|
function editForm() {
|
||||||
type.value = 'edit'
|
mode.value = 'update'
|
||||||
setFormType()
|
formRef.value.setEnabledForm();
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFormMounted(_formProps) {
|
function onFormMounted(_formProps) {
|
||||||
@ -88,11 +87,7 @@ async function setFormType() {
|
|||||||
}
|
}
|
||||||
await nextTick();
|
await nextTick();
|
||||||
if (_mode === 'view') {
|
if (_mode === 'view') {
|
||||||
if (type.value === 'readonly') {
|
await formRef.value.setDisabledForm();
|
||||||
await formRef.value.setDisabledForm();
|
|
||||||
} else {
|
|
||||||
await formRef.value.setEnabledForm();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await formRef.value.setFormDataFromId(formId.value);
|
await formRef.value.setFormDataFromId(formId.value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user