From 0db8c9b94a9ac655549d5eba5c2a6c92ac386c06 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期四, 08 十月 2026 11:20:56 +0800
Subject: [PATCH] 提交最新代码

---
 culture/src/views/strain-library/breeding-record/add.vue |  395 ++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 270 insertions(+), 125 deletions(-)

diff --git a/culture/src/views/strain-library/breeding-record/add.vue b/culture/src/views/strain-library/breeding-record/add.vue
index c4f0292..f473d51 100644
--- a/culture/src/views/strain-library/breeding-record/add.vue
+++ b/culture/src/views/strain-library/breeding-record/add.vue
@@ -1,6 +1,24 @@
 <template>
   <div>
     <Card>
+      <div class="header-title" style="width: 100%;">
+        <div class="header-title-left">
+          <img src="@/assets/public/headercard.png" />
+          <div>所属项目组</div>
+        </div>
+        <div class="header-title-right" v-if="!isReadOnly">
+          <el-button @click="showChoose = true" class="el-icon-circle-plus-outline" type="primary">
+            选择项目组</el-button>
+        </div>
+      </div>
+      <Table :height="null" :queryForm="queryForm" :total="0" :data="projectData" style="margin-bottom: 20px">
+        <template>
+          <el-table-column prop="teamName" label="项目组名称" />
+          <el-table-column prop="personCharge" label="项目负责人" />
+          <el-table-column prop="staff" label="项目组成员" />
+          <el-table-column prop="createTime" label="创建时间" />
+        </template>
+      </Table>
       <el-form ref="form" :model="form" :rules="rules" inline label-position="top">
         <div class="header-title" style="width: 100%">
           <div class="header-title-left">
@@ -10,10 +28,10 @@
         </div>
         <div class="flex" style="margin-bottom: 20px">
           <div class="tabs">
-            <div :class="{ active: activeTab === 'strain' }" @click="activeTab = 'strain'">
+            <div :class="{ active: activeTab === 'strain' }" @click="ChangeTab('strain')">
               来源菌株
             </div>
-            <div :class="{ active: activeTab === 'material' }" @click="activeTab = 'material'">
+            <div :class="{ active: activeTab === 'material' }" @click="ChangeTab('material')">
               来源物资
             </div>
           </div>
@@ -22,19 +40,20 @@
         <el-row v-if="activeTab === 'strain'" :gutter="10">
           <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
             <el-form-item label="菌株编号" prop="strainCode">
-              <el-input :disabled="$route.query.isDetail" v-model="form.strainCode" class="w-380"
+              <el-input :disabled="isReadOnly" v-model="form.strainCode" class="w-380"
                 placeholder="请输入菌株编号" />
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
             <el-form-item label="菌株名称" prop="strainName">
-              <el-input :disabled="$route.query.isDetail" v-model="form.strainName" class="w-380"
+              <el-input :disabled="isReadOnly" v-model="form.strainName" class="w-380"
                 placeholder="请输入菌株名称" />
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="8" :xl="8">
             <el-form-item label="培养基配方" prop="formula">
-              <el-input :disabled="$route.query.isDetail" v-model="form.formula" class="w-380" placeholder="请输入培养基配方" />
+              <el-input :disabled="isReadOnly" v-model="form.formula" class="w-380"
+                placeholder="请输入培养基配方" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -42,18 +61,19 @@
         <el-row v-if="activeTab === 'material'" :gutter="10">
           <el-col :span="24">
             <el-form-item label="来源物资、时间及批号" prop="sourceMaterialTimeBatchNumber">
-              <el-input :disabled="$route.query.isDetail" v-model="form.sourceMaterialTimeBatchNumber"
+              <el-input :disabled="isReadOnly" v-model="form.sourceMaterialTimeBatchNumber"
                 placeholder="请输入物资编号" />
             </el-form-item>
           </el-col>
           <el-col :span="24">
             <el-form-item label="培养基配方" prop="formula">
-              <el-input :disabled="$route.query.isDetail" v-model="form.formula" placeholder="请输入培养基配方" />
+              <el-input :disabled="isReadOnly" v-model="form.formula" placeholder="请输入培养基配方" />
             </el-form-item>
           </el-col>
           <el-col :span="24">
             <el-form-item label="分离菌落编号" prop="separateColonyNumber">
-              <el-input :disabled="$route.query.isDetail" v-model="form.separateColonyNumber" placeholder="请输入分离菌落编号" />
+              <el-input :disabled="isReadOnly" v-model="form.separateColonyNumber"
+                placeholder="请输入分离菌落编号" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -66,30 +86,30 @@
         <el-row :gutter="10">
           <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
             <el-form-item label="培养基" prop="cultureMedium">
-              <el-input :disabled="$route.query.isDetail" v-model="form.cultureMedium" class="w-380"
+              <el-input :disabled="isReadOnly" v-model="form.cultureMedium" class="w-380"
                 placeholder="请输入培养基" />
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
             <el-form-item label="培养温度" prop="temperature">
-              <el-input :disabled="$route.query.isDetail" v-model="form.temperature" class="w-380"
+              <el-input :disabled="isReadOnly" v-model="form.temperature" class="w-380"
                 placeholder="请输入培养温度" />
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
             <el-form-item label="需氧类型" prop="aerobicType">
-              <el-select :disabled="$route.query.isDetail" v-model="form.aerobicType" class="w-380"
+              <el-select :disabled="isReadOnly" v-model="form.aerobicType" class="w-380"
                 placeholder="请选择需氧类型">
-                <el-option label="专性需氧" value="1"></el-option>
-                <el-option label="专性厌氧" value="2"></el-option>
-                <el-option label="兼性需氧" value="3"></el-option>
-                <el-option label="耐氧厌氧" value="4"></el-option>
+                <el-option label="专性需氧" :value="1"></el-option>
+                <el-option label="专性厌氧" :value="2"></el-option>
+                <el-option label="兼性需氧" :value="3"></el-option>
+                <el-option label="耐氧厌氧" :value="4"></el-option>
               </el-select>
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
             <el-form-item label="培养时间" prop="cultureTime">
-              <el-input :disabled="$route.query.isDetail" v-model="form.cultureTime" class="w-380"
+              <el-input :disabled="isReadOnly" v-model="form.cultureTime" class="w-380"
                 placeholder="请输入培养时间" />
               <!-- <el-date-picker v-model="form.cultureTime" class="w-380" placeholder="请选择培养时间" type="date" value-format="yyyy-MM-dd" /> -->
             </el-form-item>
@@ -101,27 +121,30 @@
             <div>一、培养皿分离记录</div>
           </div>
           <div class="header-title-right">
-            <el-button @click="handleAddSeparation" v-if="!$route.query.isDetail && [1, 4].includes(roleType)"
+            <el-button @click="handleAddSeparation" v-if="canEditRecord"
               class="el-icon-circle-plus-outline" type="primary">
               新增培养皿分离记录</el-button>
           </div>
         </div>
-        <Table :data="form.separationOfCultureDishesList" :height="null" :queryForm="queryForm" :total="0">
-          <el-table-column width="100" type="index" label="培养皿序号" />
+        <Table ref="separationTable" :data="separationTableData" :height="null"
+          :total="form.separationOfCultureDishesList.length" :queryForm="separationPagination" :type="2"
+          @handleCurrentChange="handleSeparationPageChange" @handleSizeChange="handleSeparationSizeChange">
+          <el-table-column width="100" type="index" label="序号" />
+          <el-table-column prop="petriDishNumber" label="培养皿编号" />
           <el-table-column prop="separateBacterialColoniesCode" label="分离菌落编号" />
           <el-table-column prop="handleSignature" label="接种操作人签字">
             <template slot-scope="scope">
-              <el-image :preview-src-list="[scope.row.handleSignature]" style="width: 40px;"
-                :src="scope.row.handleSignature" alt="操作人签字" />
+              <el-image :preview-src-list="[getFullUrl(scope.row.handleSignature)]" style="width: 120px;height: 48px;"
+                :src="getFullUrl(scope.row.handleSignature)" alt="操作人签字" />
             </template>
           </el-table-column>
           <el-table-column prop="createTime" label="操作时间" />
-          <el-table-column prop="address" label="操作" v-if="!$route.query.isDetail">
-            <template slot-scope="scope" v-if="[1, 4].includes(roleType)">
+          <el-table-column prop="address" label="操作" v-if="canEditRecord">
+            <template slot-scope="scope">
               <el-button type="text" @click="handleEditSeparation(scope.row, scope.$index)"
-                v-if="!$route.query.isDetail">编辑</el-button>
+                v-if="canEditRecord">编辑</el-button>
               <el-button type="text" @click="handleDeleteSeparation(scope.$index)"
-                v-if="!$route.query.isDetail">删除</el-button>
+                v-if="canEditRecord">删除</el-button>
             </template>
           </el-table-column>
         </Table>
@@ -131,12 +154,14 @@
             <div>二、培养皿生物学形态观察记录</div>
           </div>
           <div class="header-title-right">
-            <el-button @click="handleAddObservation" v-if="!$route.query.isDetail && [1, 4].includes(roleType)"
+            <el-button @click="handleAddObservation" v-if="canEditRecord"
               class="el-icon-circle-plus-outline" type="primary">
               新增观察记录</el-button>
           </div>
         </div>
-        <Table :data="form.observationOfPetriDishes" :height="null" :queryForm="queryForm" :total="0">
+        <Table :data="observationTableData" :total="form.observationOfPetriDishes.length"
+          :queryForm="observationPagination" :height="null" :type="2" @handleCurrentChange="handleObservationPageChange"
+          @handleSizeChange="handleObservationSizeChange">
           <el-table-column prop="separateColonyCode" label="分离菌落编号" />
           <el-table-column prop="strength" label="形状强壮度排名" />
           <el-table-column prop="address" label="操作">
@@ -144,7 +169,7 @@
               <!-- <el-button type="text" @click="handleEditObservation(scope.row)" v-if="!$route.query.isDetail">编辑</el-button> -->
               <el-button type="text" @click="handleEditObservation(scope.row)">形态记录</el-button>
               <el-button type="text" @click="handleDeleteObservation(scope.$index)"
-                v-if="!$route.query.isDetail && [1, 4].includes(roleType)">删除</el-button>
+                v-if="canEditRecord">删除</el-button>
             </template>
           </el-table-column>
         </Table>
@@ -154,20 +179,22 @@
             <div>三、接种斜面记录</div>
           </div>
           <div class="header-title-right">
-            <el-button @click="handleAddInoculation" v-if="!$route.query.isDetail && [1, 4].includes(roleType)"
+            <el-button @click="handleAddInoculation" v-if="canEditRecord"
               class="el-icon-circle-plus-outline" type="primary">
               新增斜面记录</el-button>
           </div>
         </div>
-        <el-table :data="form.vaccinationSlopes" border style="width: 100%; margin-bottom: 16px;"
+        <Table :data="inoculationTableData" :total="form.vaccinationSlopes.length" :queryForm="inoculationPagination"
+          :height="null" :type="2" @handleCurrentChange="handleInoculationPageChange"
+          @handleSizeChange="handleInoculationSizeChange" border style="width: 100%; margin-bottom: 16px;"
           :span-method="inoculationRowSpan">
           <el-table-column prop="separateColonyCode" label="分离菌落编号" />
           <el-table-column prop="vaccinationSlopeCode" label="接种斜面编号" />
           <el-table-column prop="handleName" label="接种操作人" />
           <el-table-column prop="handleSignature" label="接种操作人签字">
             <template slot-scope="scope">
-              <el-image v-if="scope.row.handleSignature" :preview-src-list="[scope.row.handleSignature]"
-                style="width: 40px;" :src="scope.row.handleSignature" alt="操作人签字" />
+              <el-image v-if="scope.row.handleSignature" :preview-src-list="[getFullUrl(scope.row.handleSignature)]"
+                style="width: 120px;height: 48px;" :src="getFullUrl(scope.row.handleSignature)" alt="操作人签字" />
             </template>
           </el-table-column>
           <el-table-column prop="handleTime" label="接种操作时间" />
@@ -183,67 +210,69 @@
           </el-table-column>
           <el-table-column prop="preserveSignature" label="菌种保藏人签字">
             <template slot-scope="scope">
-              <el-image v-if="scope.row.preserveSignature" :preview-src-list="[scope.row.preserveSignature]"
-                style="width: 40px;" :src="scope.row.preserveSignature" alt="操作人签字" />
+              <el-image v-if="scope.row.preserveSignature" :preview-src-list="[getFullUrl(scope.row.preserveSignature)]"
+                style="width: 120px;height: 48px;" :src="getFullUrl(scope.row.preserveSignature)" alt="操作人签字" />
             </template>
           </el-table-column>
           <el-table-column prop="preserveTime" label="入库保藏/废弃时间" />
-          <el-table-column label="操作" v-if="[1, 3].includes(roleType) && $route.query.isDetail || (!$route.query.isDetail &&  [4].includes(roleType))">
+          <el-table-column label="操作" v-if="canEditRecord || canEngineerConfirm">
             <template slot-scope="scope">
               <el-button type="text" @click="handleEditInoculation(scope.row, scope.$index)"
-                v-if="!$route.query.isDetail && [1, 4].includes(roleType)">编辑</el-button>
+                v-if="canEditRecord">编辑</el-button>
               <el-button type="text" @click="handleConfirmStorageClick(scope.row, scope.$index)"
-                v-if="$route.query.isDetail && [3].includes(roleType)">确认入库</el-button>
+                v-if="canEngineerConfirm && !scope.row.preserveSignature">确认入库</el-button>
               <el-button type="text" @click="handleDeleteInoculation(scope.$index)"
-                v-if="!$route.query.isDetail && !scope.row.preserveSignature && [1, 4].includes(roleType)">删除</el-button>
+                v-if="canEditRecord && !scope.row.preserveSignature">删除</el-button>
             </template>
           </el-table-column>
-        </el-table>
+        </Table>
         <div class="header-title" style="margin-top: 20px;">
           <div class="header-title-left">
             <img src="@/assets/public/headercard.png" />
             <div>四、菌种保藏记录</div>
           </div>
           <div class="header-title-right">
-            <el-button @click="handleAddPreserve" v-if="!$route.query.isDetail && [1, 4].includes(roleType)"
+            <el-button @click="handleAddPreserve" v-if="canEditRecord"
               class="el-icon-circle-plus-outline" type="primary">
               新增菌种保藏记录</el-button>
           </div>
         </div>
-        <Table :data="form.culturePreservations" :height="null" :queryForm="queryForm" :total="0">
+        <Table :data="preserveTableData" :total="form.culturePreservations.length" :queryForm="preservePagination"
+          :height="null" :type="2" @handleCurrentChange="handlePreservePageChange"
+          @handleSizeChange="handlePreserveSizeChange">
           <el-table-column prop="forPreserveCode" label="用于保藏的菌种编号" />
           <el-table-column prop="verificationConclusion" label="实验验证结论" />
           <el-table-column prop="preserveMethod" label="保藏方法" />
           <el-table-column prop="preserveCode" label="保藏菌种编号" />
           <el-table-column prop="handleSignature" label="菌种操作人签字">
             <template slot-scope="scope">
-              <el-image v-if="scope.row.handleSignature" :preview-src-list="[scope.row.handleSignature]"
-                style="width: 40px;" :src="scope.row.handleSignature" alt="签字" />
+              <el-image v-if="scope.row.handleSignature" :preview-src-list="[getFullUrl(scope.row.handleSignature)]"
+                style="width: 120px;height: 48px;" :src="getFullUrl(scope.row.handleSignature)" alt="签字" />
             </template>
           </el-table-column>
           <el-table-column prop="handleTime" label="操作人" />
           <el-table-column prop="preserveSignature" label="菌种保藏人签字">
             <template slot-scope="scope">
-              <el-image v-if="scope.row.preserveSignature" :preview-src-list="[scope.row.preserveSignature]"
-                style="width: 40px;" :src="scope.row.preserveSignature" alt="签字" />
+              <el-image v-if="scope.row.preserveSignature" :preview-src-list="[getFullUrl(scope.row.preserveSignature)]"
+                style="width: 120px;height: 48px;" :src="getFullUrl(scope.row.preserveSignature)" alt="签字" />
             </template>
           </el-table-column>
           <el-table-column prop="preserveTime" label="保藏时间" />
-          <el-table-column label="操作" v-if="[1, 3].includes(roleType) && $route.query.isDetail || (!$route.query.isDetail &&  [4].includes(roleType))">
+          <el-table-column label="操作" v-if="canEditRecord || canEngineerConfirm">
             <template slot-scope="scope">
               <el-button type="text" @click="handleEditPreserve(scope.row, scope.$index)"
-                v-if="!$route.query.isDetail && [1, 4].includes(roleType)">编辑</el-button>
+                v-if="canEditRecord">编辑</el-button>
               <el-button type="text" @click="handleConfirmPreserve(scope.row, scope.$index)"
-                v-if="$route.query.isDetail && [3].includes(roleType)">确认入库</el-button>
+                v-if="canEngineerConfirm && !scope.row.preserveSignature">确认入库</el-button>
               <el-button type="text" @click="handleDeletePreserve(scope.$index)"
-                v-if="!$route.query.isDetail && !scope.row.preserveSignature && [1, 4].includes(roleType)">删除</el-button>
+                v-if="canEditRecord && !scope.row.preserveSignature">删除</el-button>
             </template>
           </el-table-column>
         </Table>
         <!-- 弹窗组件 -->
         <SeparationRecordDialog :visible.sync="showSeparationDialog" :editData="editSeparationData"
           @confirm="handleSeparationConfirm" @close="resetSeparationEdit" />
-        <SlantRecordDialog :visible.sync="showObservationDialog" :editData="editObservationData"
+        <SlantRecordDialog :visible.sync="showObservationDialog" :editData="editObservationData" :read-only="isReadOnly"
           @ok="handleObservationConfirm" />
         <InoculationSlopeRecordDialog :visible.sync="showInoculationDialog" :editData="editInoculationData"
           @save="handleInoculationConfirm" />
@@ -253,13 +282,15 @@
           @confirm="handleConfirmStorage" />
         <ConfirmPreserveDialog :visible.sync="showConfirmPreserveDialog" :editData="editPreserveData"
           @confirm="handleConfirmPreserveSubmit" />
-        <div class="end-btn" style="margin-top: 20px;" v-if="$route.query.isDetail&& [3, 4].includes(roleType)">
-          <el-button type="primary" @click="handleSubmit(1)">提交</el-button>
-          <el-button type="primary" @click="handleSubmit(3)">同步给保藏人</el-button>
-          <el-button type="default" @click="handleSubmit(2)">存草稿</el-button>
+        <div class="end-btn" style="margin-top: 20px;" v-if="canEditRecord">
+          <el-button type="primary" v-if="[1, 4].includes(roleType)" @click="handleSubmit(1)">提交</el-button>
+          <el-button v-if="[1, 4].includes(roleType)" type="primary" @click="handleSubmit(3)">同步给保藏人</el-button>
+          <el-button v-if="!$route.query.isDetail && roleType != 1" type="default" @click="handleSubmit(2)">存草稿</el-button>
         </div>
       </el-form>
     </Card>
+
+    <chooseProject v-if="!isReadOnly" @submit="getProjectData" :show="showChoose" @close="showChoose = false"></chooseProject>
   </div>
 </template>
 <script>
@@ -270,10 +301,12 @@
 import PreserveStrainRecordDialog from "./preserve-strain-record-dialog.vue";
 import ConfirmStorageDialog from "./confirm-storage-dialog.vue";
 import ConfirmPreserveDialog from "./confirm-preserve-dialog.vue";
-
-import { add, detail, edit } from './service'
+import { getFullUrl } from "@/utils/utils";
+import { add, detail, edit, vaccinationSlopesConfirm, culturePreservationsConfirm } from './service'
+import ChooseProject from "@/components/chooseProject/index.vue";
 export default {
   components: {
+    ChooseProject,
     AiEditor,
     SeparationRecordDialog,
     SlantRecordDialog,
@@ -281,10 +314,12 @@
     PreserveStrainRecordDialog,
     ConfirmStorageDialog,
     ConfirmPreserveDialog,
+
   },
-  name: "AddBreedingRecord",
+  name: "BreedingRecordAdd",
   data() {
     return {
+      cacheForm: null,
       form: {
         id: '', // 主键
         strainCode: '', // 菌株编号
@@ -304,7 +339,6 @@
         separateColonyNumber: '', // 分离菌落编号
         sourceMaterialTimeBatchNumber: '', // 来源物资存值批号
         // 下面是 array 类型字段
-        culturePreservations: [],
         observationOfPetriDishes: [],
         separationOfCultureDishesList: [],
         vaccinationSlopes: [],
@@ -313,6 +347,7 @@
         materialCode: '',
         materialName: '',
         materialDescription: '',
+        projectId: '',
         planName: '',
         planCode: '',
         stage: '',
@@ -340,6 +375,7 @@
       radio1: 1,
       status: "1",
       remark: "",
+      projectData: [], // 存储选中的项目组数据
       queryForm: {},
       showSeparationDialog: false,
       showObservationDialog: false,
@@ -355,9 +391,24 @@
       editPreserveIndex: null,
       editPreserveData: null,
       roleType: Number(JSON.parse(sessionStorage.getItem('userInfo')).roleType || 1),  // 1.超级管理员 2.审批人 3.工程师 4.实验员
+      separationPagination: { pageNum: 1, pageSize: 5 },
+      observationPagination: { pageNum: 1, pageSize: 5 },
+      inoculationPagination: { pageNum: 1, pageSize: 5 },
+      preservePagination: { pageNum: 1, pageSize: 5 },
     };
   },
   computed: {
+    isReadOnly() {
+      return Boolean(this.$route.query.isDetail) || Number(this.form.status) === 1
+    },
+    canEditRecord() {
+      return !this.isReadOnly && [1, 4].includes(this.roleType)
+    },
+    canEngineerConfirm() {
+      return Boolean(this.$route.query.isDetail)
+        && this.roleType === 3
+        && Number(this.form.status) === 2
+    },
     totalInoculationCount() {
       // 只统计入库(保存)
       return this.form.vaccinationSlopes
@@ -367,31 +418,79 @@
     firstInoculationOrDiscardIndex() {
       // 第一个入库或废弃行
       return this.form.vaccinationSlopes.findIndex(item => item.handleType === '保存' || item.handleType === '废弃');
+    },
+    separationTableData() {
+      const { pageNum, pageSize } = this.separationPagination;
+      const start = (pageNum - 1) * pageSize;
+      return this.form.separationOfCultureDishesList.slice(start, start + pageSize);
+    },
+    observationTableData() {
+      const { pageNum, pageSize } = this.observationPagination;
+      const start = (pageNum - 1) * pageSize;
+      return this.form.observationOfPetriDishes.slice(start, start + pageSize);
+    },
+    inoculationTableData() {
+      const { pageNum, pageSize } = this.inoculationPagination;
+      const start = (pageNum - 1) * pageSize;
+      return this.form.vaccinationSlopes.slice(start, start + pageSize);
+    },
+    preserveTableData() {
+      const { pageNum, pageSize } = this.preservePagination;
+      const start = (pageNum - 1) * pageSize;
+      return this.form.culturePreservations.slice(start, start + pageSize);
     }
   },
-  mounted() {
-    if (this.$route.query.id) {
+  activated() {
+    if (this.cacheForm) {
+      this.form = this.cacheForm;
+    }
+    if (this.$route.query.id && !this.cacheForm) {
       this.getDetail()
     }
   },
+  deactivated() {
+    this.cacheForm = JSON.parse(JSON.stringify(this.form));
+  },
   methods: {
+    getProjectData(data) {
+      this.projectData = [data]; // 将选中的项目组数据存储到数组中
+      this.showChoose = false;
+      this.form.projectId = this.projectData[0].id;
+    },
+    getFullUrl(url) {
+      if (url) {
+        return getFullUrl(url)
+      }
+    },
+    ChangeTab(tab) {
+      if (this.isReadOnly) return
+      this.activeTab = tab
+      this.form.preserveSource = tab === 'strain' ? 1 : 2
+    },
     async getDetail() {
-      const res = await detail({ id: this.$route.query.id })
+      const response = await detail({ id: this.$route.query.id })
+      const res = response.data || response
       if (res.preserveSource == 1) {
         this.activeTab = 'strain'
       } else {
         this.activeTab = 'material'
       }
-      res.vaccinationSlopes = res.vaccinationSlopes.map(item => {
+      res.vaccinationSlopes = (res.vaccinationSlopes || []).map(item => {
         return {
           ...item,
           handleType: item.handleType === 1 ? '保存' : '废弃'
         }
       })
-      this.form = res
+      this.form = {
+        ...this.form,
+        ...res,
+        observationOfPetriDishes: res.observationOfPetriDishes || [],
+        separationOfCultureDishesList: res.separationOfCultureDishesList || [],
+        culturePreservations: res.culturePreservations || []
+      }
+      this.projectData = res.tprojectTeamList || [];
     },
     handleSeparationConfirm(data) {
-      console.log('分离', data)
       if (this.editSeparationIndex !== null) {
         // 编辑
         this.$set(this.form.separationOfCultureDishesList, this.editSeparationIndex, data);
@@ -451,54 +550,45 @@
       this.editPreserveData = null;
     },
     handleSubmit(type) {
-      if (this.activeTab === 'material') {
-        this.form.preserveSource = 2
-      } else {
-        this.form.preserveSource = 1
+      if (this.isReadOnly) return
+      if (type === 1) {
+        if (!this.form.id || Number(this.form.status) !== 2) {
+          this.$message.warning('请先同步给保藏人并完成入库确认')
+          return
+        }
+        const hasUnconfirmedSlope = this.form.vaccinationSlopes.some(item => !item.preserveId && !item.preserveSignature)
+        const hasUnconfirmedPreservation = this.form.culturePreservations.some(item => !item.preserveId && !item.preserveSignature)
+        if (hasUnconfirmedSlope || hasUnconfirmedPreservation) {
+          this.$message.warning('存在未确认的接种斜面或菌种保藏记录,不能提交')
+          return
+        }
       }
-
-      if (type == 1) {
-        this.form.status = 1
-      } else if (type == 3) {
-        this.form.status = 2
-      } else {
-        this.form.status = 3
-      }
-
       this.$refs.form.validate(async (valid) => {
         if (!valid) return;
         try {
-          if (this.form.vaccinationSlopes.length > 0) {
-            let arr = this.form.vaccinationSlopes
-            this.form.vaccinationSlopes = arr.map(item => {
-              return {
-                ...item,
-                handleType: item.handleType === '保存' ? 1 : 2,
-              }
-            })
+          const status = type === 1 ? 1 : type === 3 ? 2 : 3
+          const payload = {
+            ...this.form,
+            preserveSource: this.activeTab === 'material' ? 2 : 1,
+            status,
+            isDraft: status === 2 ? this.form.isDraft : 0,
+            vaccinationSlopes: (this.form.vaccinationSlopes || []).map(item => ({
+              ...item,
+              handleType: item.handleType === '保存' || item.handleType === 1 ? 1 : 2
+            }))
           }
-          if (this.form.id && this.form.isDraft == 0) {
-            edit(this.form).then(res => {
-              if (res.code === 200) {
-                this.$message.success('编辑成功');
-                this.$router.back();
-              } else {
-                this.$message.error('编辑失败');
-              }
-            })
+          const request = payload.id ? edit(payload) : add(payload)
+          const res = await request
+          if (res.code === 200) {
+            this.$message.success(payload.id ? '编辑成功' : '添加成功')
+            this.cacheForm = null
+            this.$closeCurrentView('/strain/breeding-record')
           } else {
-            add(this.form).then(res => {
-              if (res.code === 200) {
-                this.$message.success('添加成功');
-                this.$router.back();
-              } else {
-                this.$message.error('添加失败');
-              }
-            });
+            this.$message.error(res.msg || (payload.id ? '编辑失败' : '添加失败'))
           }
 
         } catch (e) {
-          this.$message.error('添加失败');
+          this.$message.error(this.form.id ? '编辑失败' : '添加失败');
         }
       });
     },
@@ -509,6 +599,12 @@
     },
     handleDeleteSeparation(index) {
       this.form.separationOfCultureDishesList.splice(index, 1);
+      // 如果当前页数据被删空,自动回到上一页
+      const total = this.form.separationOfCultureDishesList.length;
+      const { pageNum, pageSize } = this.separationPagination;
+      if (total && (pageNum - 1) * pageSize >= total) {
+        this.separationPagination.pageNum = Math.max(1, pageNum - 1);
+      }
     },
     resetSeparationEdit() {
       this.editSeparationIndex = null;
@@ -529,6 +625,11 @@
     },
     handleDeleteObservation(index) {
       this.form.observationOfPetriDishes.splice(index, 1);
+      const total = this.form.observationOfPetriDishes.length;
+      const { pageNum, pageSize } = this.observationPagination;
+      if (total && (pageNum - 1) * pageSize >= total) {
+        this.observationPagination.pageNum = Math.max(1, pageNum - 1);
+      }
     },
     handleAddInoculation() {
       this.editInoculationIndex = null;
@@ -548,20 +649,28 @@
       this.showConfirmStorageDialog = true;
     },
     handleConfirmStorage(data) {
-      // 更新对应行的数据,保留原有数据并更新签名
-      if (this.editInoculationIndex !== null) {
-        this.$set(this.form.vaccinationSlopes, this.editInoculationIndex, {
-          ...this.form.vaccinationSlopes[this.editInoculationIndex],
-          preserveSignature: data.preserveSignature, // 更新签名数据
-          status: '保存' // 更新状态为保存
-        });
+      if (data.preserveSignature) {
+        vaccinationSlopesConfirm({ id: this.form.vaccinationSlopes[this.editInoculationIndex].id, preserveSignature: data.preserveSignature }).then(res => {
+          if (this.editInoculationIndex !== null) {
+            this.$set(this.form.vaccinationSlopes, this.editInoculationIndex, {
+              ...this.form.vaccinationSlopes[this.editInoculationIndex],
+              preserveSignature: data.preserveSignature, // 更新签名数据
+              status: '保存' // 更新状态为保存
+            });
+          }
+          this.showConfirmStorageDialog = false;
+          this.editInoculationIndex = null;
+          this.editInoculationData = null;
+        })
       }
-      this.showConfirmStorageDialog = false;
-      this.editInoculationIndex = null;
-      this.editInoculationData = null;
     },
     handleDeleteInoculation(index) {
       this.form.vaccinationSlopes.splice(index, 1);
+      const total = this.form.vaccinationSlopes.length;
+      const { pageNum, pageSize } = this.inoculationPagination;
+      if (total && (pageNum - 1) * pageSize >= total) {
+        this.inoculationPagination.pageNum = Math.max(1, pageNum - 1);
+      }
     },
     inoculationRowSpan({ row, rowIndex, columnIndex }) {
       // 入库总数(只)列合并
@@ -587,6 +696,11 @@
     },
     handleDeletePreserve(index) {
       this.form.culturePreservations.splice(index, 1);
+      const total = this.form.culturePreservations.length;
+      const { pageNum, pageSize } = this.preservePagination;
+      if (total && (pageNum - 1) * pageSize >= total) {
+        this.preservePagination.pageNum = Math.max(1, pageNum - 1);
+      }
     },
     handleConfirmPreserve(row, index) {
       this.editPreserveIndex = index;
@@ -595,18 +709,49 @@
       this.showConfirmPreserveDialog = true;
     },
     handleConfirmPreserveSubmit(data) {
-      console.log('确认保藏', data)
-      // 更新对应行的数据,保留原有数据并更新签名
-      if (this.editPreserveIndex !== null) {
-        this.$set(this.form.culturePreservations, this.editPreserveIndex, {
-          ...this.form.culturePreservations[this.editPreserveIndex],
-          preserveSignature: data.preserveSignature, // 更新签名数据
-          preserveTime: data.preserveTime,
-        });
+      if (data.preserveSignature) {
+        culturePreservationsConfirm({ id: this.form.culturePreservations[this.editPreserveIndex].id, preserveSignature: data.preserveSignature }).then(res => {
+          if (this.editPreserveIndex !== null) {
+            this.$set(this.form.culturePreservations, this.editPreserveIndex, {
+              ...this.form.culturePreservations[this.editPreserveIndex],
+              preserveSignature: data.preserveSignature, // 更新签名数据
+              preserveTime: data.preserveTime,
+            });
+          }
+          this.showConfirmPreserveDialog = false;
+          this.editPreserveIndex = null;
+          this.editPreserveData = null;
+        })
       }
-      this.showConfirmPreserveDialog = false;
-      this.editPreserveIndex = null;
-      this.editPreserveData = null;
+
+    },
+    handleSeparationPageChange(val) {
+      this.separationPagination.pageNum = val;
+    },
+    handleSeparationSizeChange(val) {
+      this.separationPagination.pageSize = val;
+      this.separationPagination.pageNum = 1;
+    },
+    handleObservationPageChange(val) {
+      this.observationPagination.pageNum = val;
+    },
+    handleObservationSizeChange(val) {
+      this.observationPagination.pageSize = val;
+      this.observationPagination.pageNum = 1;
+    },
+    handleInoculationPageChange(val) {
+      this.inoculationPagination.pageNum = val;
+    },
+    handleInoculationSizeChange(val) {
+      this.inoculationPagination.pageSize = val;
+      this.inoculationPagination.pageNum = 1;
+    },
+    handlePreservePageChange(val) {
+      this.preservePagination.pageNum = val;
+    },
+    handlePreserveSizeChange(val) {
+      this.preservePagination.pageSize = val;
+      this.preservePagination.pageNum = 1;
     },
   },
 };
@@ -641,7 +786,7 @@
   padding: 4px;
 
   div {
-    width: 183px;
+    width: 178px;
     height: 32px;
     border-radius: 10px;
     text-align: center;

--
Gitblit v1.7.1