| | |
| | | </div> |
| | | </div> |
| | | <div class="add-project-footer"> |
| | | <el-button @click="submitForm" type="primary">保存</el-button> |
| | | <el-button @click="submitForm" type="primary" :loading="loading" :disabled="loading">保存</el-button> |
| | | </div> |
| | | </template> |
| | | <SelectMember ref="selectMember" @submit="selectUser" /> |
| | |
| | | 1: { key: 'approver', limit: 1, label: '菌种审批人' }, |
| | | 2: { key: 'engineer', limit: 1, label: '菌种工程师' }, |
| | | }, |
| | | loading: false, |
| | | } |
| | | }, |
| | | methods: { |
| | | submitForm() { |
| | | if (this.loading) return; // 防止重复提交 |
| | | this.loading = true; |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | const requiredRoles = ['菌种审批人', '菌种工程师', '菌种实验员']; |
| | |
| | | for (const role of requiredRoles) { |
| | | if (!selectedRoleNames.includes(role)) { |
| | | this.$message.error(`请选择${role}`); |
| | | this.loading = false; |
| | | return; |
| | | } |
| | | } |
| | | if (this.selectMemberData.length == 0) { |
| | | this.$message.error('请选择项目组成员'); |
| | | this.loading = false; |
| | | return; |
| | | } |
| | | const ROLE_NAME_TO_TYPE = { |
| | |
| | | })) |
| | | } |
| | | addProject(data).then(res => { |
| | | this.loading = false; |
| | | if (res.code == 200) { |
| | | this.$message.success('添加成功'); |
| | | this.resetForm(); // 添加成功后重置表单 |
| | | this.$router.back(); // 跳转到上一个页面 |
| | | // Optionally, navigate away or give other feedback |
| | | // this.$router.push({ name: 'ProjectList' }); |
| | | } |
| | | }).catch(() => { |
| | | this.loading = false; // 失败时也关闭 loading |
| | | }) |
| | | } else { |
| | | this.loading = false; |
| | | } |
| | | }) |
| | | }, |