From b4ac09eb2e493aab92557628e0436189337e2939 Mon Sep 17 00:00:00 2001
From: 董国庆 <364620639@qq.com>
Date: 星期二, 20 五月 2025 16:44:32 +0800
Subject: [PATCH] 样品管理大模块85%

---
 laboratory/src/views/dataManagement/sampleSubmissionList/submission.vue |  278 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 140 insertions(+), 138 deletions(-)

diff --git a/laboratory/src/views/dataManagement/sampleSubmissionList/submission.vue b/laboratory/src/views/dataManagement/sampleSubmissionList/submission.vue
index 9e8ef28..060a343 100644
--- a/laboratory/src/views/dataManagement/sampleSubmissionList/submission.vue
+++ b/laboratory/src/views/dataManagement/sampleSubmissionList/submission.vue
@@ -4,16 +4,22 @@
       <img src="@/assets/public/headercard.png" />
       <div>所属实验调度</div>
     </div>
-    <Table :data="schedulingData" :total="schedulingTotal" :height="null">
+    <Table :data="schedulingData" :total="0" :height="null" >
       <template>
-        <el-table-column prop="planCode" label="所属项目课题方案" width="150"></el-table-column>
-        <el-table-column prop="experimentCode" label="实验编号" width="150"></el-table-column>
-        <el-table-column prop="experimentName" label="实验名称" width="150"></el-table-column>
-        <el-table-column prop="notifyTime" label="通知时间" width="150"></el-table-column>
-        <el-table-column prop="startTime" label="实验开始时间" width="150"></el-table-column>
-        <el-table-column prop="endTime" label="实验结束时间" width="150"></el-table-column>
-        <el-table-column prop="participants" label="参加人员" width="150"></el-table-column>
-        <el-table-column prop="status" label="状态" width="100"></el-table-column>
+        <el-table-column prop="projectName" label="所属项目课题方案" width="200"></el-table-column>
+        <el-table-column prop="experimentCode" label="实验编号" width="200"></el-table-column>
+        <el-table-column prop="experimentName" label="实验名称" width="200"></el-table-column>
+        <el-table-column prop="experimentDate" label="通知时间" width="200"></el-table-column>
+        <el-table-column prop="experimentStartTime" label="实验开始时间" width="200"></el-table-column>
+        <el-table-column prop="experimentEndTime" label="实验结束时间" width="200"></el-table-column>
+        <el-table-column prop="participantsName" label="参加人员" width="200"></el-table-column>
+        <el-table-column prop="status" label="状态" width="150">
+          <template slot-scope="scope">
+            <el-tag :type="getStatusType(scope.row.status)">
+              {{ getStatusText(scope.row.status) }}
+            </el-tag>
+          </template>
+        </el-table-column>
       </template>
     </Table>
 
@@ -36,40 +42,52 @@
         <div class="table-header">
           <el-button type="primary" class="batch-send" @click="handleBatchSend">批量发送</el-button>
         </div>
-        <Table :data="sampleList" :total="sampleTotal" :height="null" @selection-change="handleSelectionChange">
+        <Table :data="sampleList" :total="sampleTotal" :height="null"
+         @selection-change="handleSelectionChange">
           <template>
-            <el-table-column type="selection" width="55"></el-table-column>
-            <el-table-column prop="index" label="序号" width="80"></el-table-column>
-            <el-table-column prop="processTime" label="工艺时间间/h" width="120"></el-table-column>
-            <el-table-column prop="sampleName" label="取样名称" width="150"></el-table-column>
+            <el-table-column type="selection" width="55" :selectable="isSelectable"></el-table-column>
+            <el-table-column type="index"  label="序号" width="80"></el-table-column>
+            <el-table-column prop="processTime" label="工艺时间" width="120"></el-table-column>
+            <el-table-column prop="samplingName" label="取样名称" width="150"></el-table-column>
             <el-table-column prop="sampleCode" label="取样样品编号" width="150"></el-table-column>
             <el-table-column prop="temperature" label="温度" width="100"></el-table-column>
-            <el-table-column prop="ph" label="PH" width="100"></el-table-column>
-            <el-table-column prop="waterAmount" label="加水量" width="100"></el-table-column>
+            <el-table-column prop="samplePh" label="PH" width="100"></el-table-column>
+            <el-table-column prop="waterAddition" label="加水量" width="100"></el-table-column>
             <template v-if="showAdditives">
-              <el-table-column prop="additive1" label="加辅1" width="150"></el-table-column>
-              <el-table-column prop="additive2" label="加辅2" width="150"></el-table-column>
-              <el-table-column prop="additive3" label="加辅3" width="150"></el-table-column>
-              <el-table-column prop="additive4" label="加辅4" width="150"></el-table-column>
-              <el-table-column prop="additive5" label="加辅5" width="150"></el-table-column>
-              <el-table-column prop="additive6" label="加辅6" width="150"></el-table-column>
-              <el-table-column prop="additive7" label="加辅7" width="150"></el-table-column>
-              <el-table-column prop="additive8" label="加辅8" width="150"></el-table-column>
-              <el-table-column prop="additive9" label="加辅9" width="150"></el-table-column>
-              <el-table-column prop="additive10" label="加辅10" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryOne" label="加辅1" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryTwo" label="加辅2" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryThree" label="加辅3" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryFour" label="加辅4" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryFive" label="加辅5" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliarySix" label="加辅6" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliarySeven" label="加辅7" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryEight" label="加辅8" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryNine" label="加辅9" width="150"></el-table-column>
+              <el-table-column prop="addAuxiliaryTen" label="加辅10" width="150"></el-table-column>
             </template>
             <el-table-column prop="sampleAmount" label="取样量" width="100"></el-table-column>
-            <el-table-column prop="sampleTime" label="取样时间" width="150"></el-table-column>
-            <el-table-column prop="photo" label="拍照" width="100">
+            <el-table-column prop="pictures" label="拍照" width="100">
               <template slot-scope="scope">
-                <img v-if="scope.row.photo" :src="scope.row.photo" class="sample-photo" />
+                <el-image
+                  v-for="(url, index) in scope.row.pictures.split(',')" 
+                  :key="index"
+                  :src="url"
+                  :preview-src-list="[url]"
+                  style="width: 50px; height: 50px;"
+                />
               </template>
             </el-table-column>
-            <el-table-column prop="operator" label="操作人" width="100"></el-table-column>
-            <el-table-column prop="status" label="状态" width="100"></el-table-column>
+            <el-table-column prop="handlePersonName" label="操作人员" width="100"></el-table-column>
+            <el-table-column prop="status" label="状态" width="100" fixed="right">
+              <template slot-scope="scope">
+                <el-tag :type="getSampleStatusType(scope.row.status)">
+                  {{ getSampleStatusText(scope.row.status) }}
+                </el-tag>
+              </template>
+            </el-table-column>
             <el-table-column label="操作" width="100" fixed="right">
               <template slot-scope="scope">
-                <el-button type="text" @click="handleSend(scope.row)" v-if="scope.row.status === '待发送'">发送</el-button>
+                <el-button type="text" @click="handleSend(scope.row)" v-if="scope.row.status == '1'">发送</el-button>
               </template>
             </el-table-column>
           </template>
@@ -87,6 +105,7 @@
 
 <script>
 import ReceiveConfirmDialog from './components/receiveConfirmDialog.vue'
+import { getDetail, commitRecord, batchSendSamples, sendSample } from './service'
 
 export default {
   name: "SampleSubmission",
@@ -95,131 +114,114 @@
   },
   data() {
     return {
+      id: null,
       showReceiveConfirm: false,
       showAdditives: true,
-      schedulingData: [{
-        planCode: 'DD-EX001',
-        experimentCode: 'DD-EX001',
-        experimentName: '名称名称名称',
-        notifyTime: '2025-1-2 14:50:19',
-        startTime: '2025-02-27',
-        endTime: '2025-06-06',
-        participants: '张弘, 李天浩, 陈三, 李四',
-        status: '已确认'
-      }],
-      schedulingTotal: 1,
+      schedulingData: [],
+      schedulingTotal: 0,
       form: {
-        sampleCode: "DD-25010BS01",
+        sampleCode: "",
       },
-      sampleList: [
-        {
-          index: 1,
-          processTime: "2",
-          sampleName: "名称名称名称",
-          sampleCode: "314234321",
-          temperature: "34",
-          ph: "34",
-          waterAmount: "34",
-          additive1: "10g",
-          additive2: "5g",
-          additive3: "3g",
-          additive4: "",
-          additive5: "",
-          additive6: "",
-          additive7: "",
-          additive8: "",
-          additive9: "",
-          additive10: "",
-          sampleAmount: "34",
-          sampleTime: "2025-1-9 15:26:08",
-          photo: "@/assets/sample-photos/photo1.jpg",
-          operator: "张三",
-          status: "待发送"
-        },
-        {
-          index: 2,
-          processTime: "4",
-          sampleName: "名称名称名称",
-          sampleCode: "314234321",
-          temperature: "23",
-          ph: "23",
-          waterAmount: "23",
-          additive1: "8g",
-          additive2: "4g",
-          additive3: "",
-          additive4: "",
-          additive5: "",
-          additive6: "",
-          additive7: "",
-          additive8: "",
-          additive9: "",
-          additive10: "",
-          sampleAmount: "23",
-          sampleTime: "2025-1-9 15:26:08",
-          photo: "@/assets/sample-photos/photo2.jpg",
-          operator: "李四",
-          status: "待接收"
-        },
-        {
-          index: 3,
-          processTime: "8",
-          sampleName: "名称名称名称",
-          sampleCode: "314234321",
-          temperature: "23",
-          ph: "23",
-          waterAmount: "23",
-          additive1: "",
-          additive2: "",
-          additive3: "",
-          additive4: "",
-          additive5: "",
-          additive6: "",
-          additive7: "",
-          additive8: "",
-          additive9: "",
-          additive10: "",
-          sampleAmount: "23",
-          sampleTime: "2025-1-9 15:26:08",
-          photo: "@/assets/sample-photos/photo3.jpg",
-          operator: "王五",
-          status: "已接收"
-        }
-      ],
-      sampleTotal: 3,
-      selectedSamples: []
+      sampleList: [],
+      sampleTotal: 0,
+      selectedSamples: [],
+      statusTypeMap: {
+        '-1': 'info',
+        '1': 'warning',
+        '2': 'success',
+        '3': 'info'
+      },
+      statusTextMap: {
+        '-1': '草稿箱',
+        '1': '待提交',
+        '2': '已提交',
+        '3': '已封存'
+      },
+      sampleStatusTypeMap: {
+        '1': 'warning',
+        '2': 'info',
+        '3': 'success'
+      },
+      sampleStatusTextMap: {
+        '1': '待发送',
+        '2': '待接收',
+        '3': '已接收'
+      }
     };
   },
+  created() {
+    this.id = this.$route.query.id;
+    if (this.id) {
+      this.getDetailData();
+    }
+  },
   methods: {
+    async getDetailData() {
+      try {
+        const res = await getDetail({ id: this.id });
+        if (res) {
+          this.schedulingData = [res.experimentDispatch] || [];
+          this.schedulingTotal = this.schedulingData.length;
+          this.form.sampleCode = res.samplingCode || '';
+          this.sampleList = res.samplingRecordOperations || [];
+          this.sampleTotal = this.sampleList.length;
+        }
+      } catch (error) {
+        console.error('获取详情失败:', error);
+        this.$message.error('获取详情失败');
+      }
+    },
     handleSelectionChange(selection) {
       this.selectedSamples = selection;
     },
-    handleSend(row) {
+    async handleSend(row) {
       this.selectedSamples = [row];
       this.showReceiveConfirm = true;
     },
-    handleBatchSend() {
-      if (this.selectedSamples.length === 0) {
+    async handleBatchSend() {
+      if (this.selectedSamples.length == 0) {
         this.$message.warning('请先选择要发送的样品');
         return;
       }
       this.showReceiveConfirm = true;
     },
-    confirmSend(signature) {
-      // 处理发送确认逻辑
-      const sampleIds = this.selectedSamples.map(item => item.id);
-      console.log('发送样品', { sampleIds, signature });
-      
-      // 更新状态
-      this.selectedSamples.forEach(sample => {
-        const index = this.sampleList.findIndex(item => item.id === sample.id);
-        if (index > -1) {
-          this.sampleList[index].status = '待接收';
+    async confirmSend(signature) {
+      try {
+        const recordOperationIds = this.selectedSamples.map(item => item.id).join(',');
+        const res = await batchSendSamples({ 
+          recordOperationId: recordOperationIds,
+          sendSign: signature
+        });
+
+        if (res.code == 200) {
+          this.$message.success(`成功发送 ${this.selectedSamples.length} 个样品`);
+          this.selectedSamples = [];
+          this.showReceiveConfirm = false;
+          // 刷新数据
+          this.getDetailData();
+        } else {
+          this.$message.error(res.msg || '发送失败');
         }
-      });
-      
-      this.$message.success(`成功发送 ${this.selectedSamples.length} 个样品`);
-      this.selectedSamples = [];
-    }
+      } catch (error) {
+        console.error('发送失败:', error);
+        this.$message.error('发送失败');
+      }
+    },
+    getStatusType(status) {
+      return this.statusTypeMap[status] || 'info';
+    },
+    getStatusText(status) {
+      return this.statusTextMap[status] || '未知状态';
+    },
+    isSelectable(row) {
+      return row.status == '1';
+    },
+    getSampleStatusType(status) {
+      return this.sampleStatusTypeMap[status] || 'info';
+    },
+    getSampleStatusText(status) {
+      return this.sampleStatusTextMap[status] || '未知状态';
+    },
   }
 };
 </script>

--
Gitblit v1.7.1