From fcc84cfea24bb528fc9142240d4dbcf94eaa0a88 Mon Sep 17 00:00:00 2001 From: 董国庆 <364620639@qq.com> Date: 星期四, 26 六月 2025 16:26:19 +0800 Subject: [PATCH] Merge branch 'main' of http://120.76.84.145:10101/gitblit/r/H5/leshan-laboratory --- culture/src/views/projectList/addProject.vue | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/culture/src/views/projectList/addProject.vue b/culture/src/views/projectList/addProject.vue index 4d10357..64e6d42 100644 --- a/culture/src/views/projectList/addProject.vue +++ b/culture/src/views/projectList/addProject.vue @@ -31,7 +31,7 @@ </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" /> @@ -58,10 +58,13 @@ 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 = ['菌种审批人', '菌种工程师', '菌种实验员']; @@ -69,11 +72,13 @@ 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 = { @@ -90,14 +95,17 @@ })) } 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; } }) }, -- Gitblit v1.7.1