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/strainReportLibrary/reportLibraryOne/add.vue |   94 +++++++++++++++++++++++++++++------------------
 1 files changed, 58 insertions(+), 36 deletions(-)

diff --git a/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue b/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue
index 77926ba..5de2cf6 100644
--- a/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue
+++ b/culture/src/views/strainReportLibrary/reportLibraryOne/add.vue
@@ -143,13 +143,14 @@
                 </div>
 
                 <div class="end-btn" style="margin-top: 38px">
-                    <el-button type="primary" @click="addData">发送</el-button>
-                    <el-button type="default" @click="saveData">存草稿</el-button>
+                    <el-button type="primary" @click="addData" :loading="submitLoading" :disabled="submitLoading">发送</el-button>
+                    <el-button type="default" @click="saveData" :loading="submitLoading" :disabled="submitLoading">存草稿</el-button>
                 </div>
             </el-form>
         </Card>
-        <chooseProject  @submit="getProjectData" :show="showChoose" @close="showChoose = false"></chooseProject>
-        <SelectMember :projectId="projectData.length&&projectData[0].id" title="选择菌种实验员" ref="selectMember" @submit="selectUser" :singleSelect="true" />
+        <chooseProject @submit="getProjectData" :show="showChoose" @close="showChoose = false"></chooseProject>
+        <SelectMember :projectId="projectData.length && projectData[0].id" title="选择菌种实验员" ref="selectMember"
+            @submit="selectUser" :singleSelect="true" />
     </div>
 
 </template>
@@ -158,7 +159,7 @@
 import AiEditor from '@/components/AiEditor'
 import ChooseProject from '@/components/chooseProject/index.vue'
 import SelectMember from '@/components/SelectMember'
-import { add,getDetail,update } from './service'
+import { add, getDetail, update } from './service'
 
 export default {
     components: { AiEditor, ChooseProject, SelectMember },
@@ -180,7 +181,7 @@
             showChoose: false,
             radio1: 1,
             rules: {
-               
+
                 reportName: [
                     { required: true, message: '请输入报告名称', trigger: 'blur' }
                 ]
@@ -228,6 +229,7 @@
                 }
             ],
             selectedMember: null, // 存储选中的菌种实验员
+            submitLoading: false // 提交 loading 状态
         }
     },
     computed: {
@@ -240,12 +242,12 @@
         this.$nextTick(() => {
             window.scrollTo(0, 0);
         });
-        
+
         if (this.$route.query.id) {
             getDetail(this.$route.query.id).then(res => {
                 const data = res.data || res;
-                console.log('qweqweqweq',data);
-                
+                console.log('qweqweqweq', data);
+
                 this.form = {
                     ...this.form,
                     ...data,
@@ -260,16 +262,16 @@
                 })
 
                 this.selectedMember = [{
-                    nickName:data.experimentName,
-                    userId:data.experimentId
+                    nickName: data.experimentName,
+                    userId: data.experimentId
                 }]
 
                 this.projectData = data.projectTeam ?
                     [{ ...data.projectTeam, staffName: data.projectTeam.staff || '' }] :
                     [];
 
-                    console.log('qwe45645664',this.tableData);
-                    
+                console.log('qwe45645664', this.tableData);
+
 
 
             }).catch(err => {
@@ -279,10 +281,12 @@
     },
     methods: {
         addData() {
+            if (this.submitLoading) return;
+            this.submitLoading = true;
             console.log('qeqweqeqwqrew', this.form, this.projectData);
 
             this.$refs.form.validate(async (valid) => {
-                if (!valid) return;
+                if (!valid) { this.submitLoading = false; return; }
                 let str = []
                 str = this.assessmentTable.map(item => {
                     return item.selectedScore
@@ -290,14 +294,17 @@
 
                 if (this.$refs.materialEditor.getContent() == '<p></p>') {
                     this.$message.error('请输入报告正文')
+                    this.submitLoading = false;
                     return
                 }
                 if (!this.projectData.length) {
                     this.$message.warning('请选择项目组');
+                    this.submitLoading = false;
                     return;
                 }
                 if (!this.selectedMember || !this.selectedMember[0]) {
                     this.$message.warning('请选择菌种实验员');
+                    this.submitLoading = false;
                     return;
                 }
                 const params = {
@@ -316,51 +323,66 @@
                 if (this.$route.query.id) {
                     params.id = this.$route.query.id
                     update(params).then(res => {
+                        this.submitLoading = false;
                         if (res.code == 200) {
                             this.$message.success('编辑成功');
                             this.$router.back()
+                        } else {
+                            this.$message.error(res.msg || '编辑失败');
+                            this.submitLoading = false;
                         }
-                    })
+                    }).catch(() => { this.submitLoading = false; })
                     return
                 }
 
                 add(params).then(res => {
+                    this.submitLoading = false;
                     if (res.code == 200) {
                         this.$message.success('发送成功');
                         this.$router.push('/strainReportLibrary/reportLibraryOne');
+                    } else {
+                        this.$message.error(res.msg || '发送失败');
+                        this.submitLoading = false;
                     }
-                })
+                }).catch(() => { this.submitLoading = false; })
             });
         },
         saveData() {
+            if (this.submitLoading) return;
+            this.submitLoading = true;
             this.$refs.form.validate(async (valid) => {
-                if (!valid) return;
+                if (!valid) { this.submitLoading = false; return; }
                 let str = []
                 str = this.assessmentTable.map(item => {
                     return item.selectedScore
                 })
 
-                    const params = {
-                        isDraft: 1,
-                        projectId: this.projectData[0].id,
-                        experimentId: this.selectedMember[0].userId,
-                        // reportCode: this.form.reportCode,
-                        reportContent: this.$refs.materialEditor.getContent(),
-                        reportName: this.form.reportName,
-                        evaluateTotal: this.totalScore,
-                        evaluate: str.join(','),
-                        reportType: 1
-                    };
-                    add(params).then(res => {
-                        if (res.code == 200) {
-                            this.$message.success('保存成功');
-                            this.$router.push('/strainReportLibrary/reportLibraryOne');
-                        }
-                    })
+                const params = {
+                    isDraft: 1,
+                    projectId: this.projectData[0].id,
+                    experimentId: this.selectedMember[0].userId,
+                    // reportCode: this.form.reportCode,
+                    reportContent: this.$refs.materialEditor.getContent(),
+                    reportName: this.form.reportName,
+                    evaluateTotal: this.totalScore,
+                    evaluate: str.join(','),
+                    reportType: 1
+                };
+                add(params).then(res => {
+                    this.submitLoading = false;
+                    if (res.code == 200) {
+                        this.$message.success('保存成功');
+                        this.$router.push('/strainReportLibrary/reportLibraryOne');
+                    } else {
+                        this.$message.error(res.msg || '保存失败');
+                        this.submitLoading = false;
+                    }
+                }).catch(() => { this.submitLoading = false; })
             });
-        }, getProjectData(data) {
+        },
+        getProjectData(data) {
             this.projectData = [data]; // 将选中的项目组数据存储到数组中
-            
+
             this.showChoose = false
         },
         selectUser(data) {

--
Gitblit v1.7.1