具体业务:<!-- SomePage.vue -->
<template>
<div>
<el-button @
click="showDrawer1 = true">Open Drawer 1</el-button>
<el-button @
click="showDrawer2 = true">Open Drawer 2</el-button>
<DrawerForm :visible.sync="showDrawer1" @
submit="handleFormSubmit1">
<template #header>
认领
</template>
<CommonFormFields
:formData="formData1"
:rules="rules1"
:isDepartmentDisabled="true"
:isDateDisabled="false" />
</DrawerForm>
<DrawerForm :visible.sync="showDrawer2" @
submit="handleFormSubmit2">
<template #header>
指派
</template>
<CommonFormFields
:formData="formData2"
:rules="rules2"
:isDepartmentDisabled="false"
:isDateDisabled="false" />
</DrawerForm>
</div>
</template>
<script>
import DrawerForm from './DrawerForm.vue';
import CommonFormFields from './CommonFormFields.vue';
export default {
components: {
DrawerForm,
CommonFormFields
},
data() {
return {
showDrawer1: false,
showDrawer2: false,
formData1: {
department: '',
person: '',
date: ''
},
formData2: {
department: '',
person: '',
date: ''
},
rules1: {
department: [{ required: true, message: '请选择部门', trigger: 'change' }],
person: [{ required: true, message: '请选择认领人', trigger: 'change' }],
date: [{ required: true, message: '请选择日期', trigger: 'change' }]
},
rules2: {
department: [{ required: true, message: '请选择部门', trigger: 'change' }],
person: [{ required: true, message: '请选择指派人', trigger: 'change' }],
date: [{ required: true, message: '请选择日期', trigger: 'change' }]
}
};
},
methods: {
handleFormSubmit1() {
this.$refs.form1.validate((valid) => {
if (valid) {
// 提交逻辑
}
});
},
handleFormSubmit2() {
this.$refs.form2.validate((valid) => {
if (valid) {
// 提交逻辑
}
});
}
}
};
</script>