| | |
| | | /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item> |
| | | <el-form-item class="dialog-footer"> |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm">重置</el-button> |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm">取消</el-button> |
| | | <el-button type="primary" @click="submitForm"> |
| | | 确定 |
| | | </el-button> |
| | | <el-button v-if="addOrEdit === 'edit'" @click="resetForm">重置</el-button> |
| | | <el-button v-if="addOrEdit === 'add'" @click="cancelForm">取消</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | </el-dialog> |
| | |
| | | default: '' |
| | | }, |
| | | }) |
| | | |
| | | const copyForm = defineModel("copyForm", { |
| | | required: true, |
| | | type: Object, |
| | | }); |
| | | // 在组件挂载时获取用户信息 |
| | | onMounted(async () => { |
| | | // 如果store中没有用户信息,则获取用户信息 |
| | | if (!userStore.name) { |
| | | try { |
| | | await userStore.getInfo() |
| | | console.log('用户信息:', { |
| | | id: userStore.id, |
| | | name: userStore.name, |
| | | nickName: userStore.nickName |
| | | }) |
| | | // 自动填充维护人ID |
| | | if (props.addOrEdit === 'add') { |
| | | formData.value.maintainerId = userStore.id |
| | |
| | | console.error('获取用户信息失败:', error) |
| | | } |
| | | } else { |
| | | console.log('用户信息:', { |
| | | id: userStore.id, |
| | | name: userStore.name, |
| | | nickName: userStore.nickName |
| | | }) |
| | | // 自动填充维护人ID |
| | | if (props.addOrEdit === 'add') { |
| | | formData.value.maintainerId = userStore.id |
| | |
| | | // 重置表单 |
| | | const resetForm = () => { |
| | | if (!formRef.value) return |
| | | formRef.value.resetFields() |
| | | formData.value = JSON.parse(JSON.stringify(copyForm.value)); |
| | | // formRef.value.resetFields() |
| | | } |
| | | // 关闭弹窗 |
| | | const handleClose = () => { |
| | |
| | | } |
| | | </script> |
| | | |
| | | <style lang="sass" scoped> |
| | | <style lang="scss" scoped> |
| | | .dialog-footer { |
| | | display: flex; |
| | | margin-top: 20px; |
| | | flex-direction: column; |
| | | align-items: flex-end; |
| | | } |
| | | </style> |