From 19636a3507391a5ac137bb1f46a413ff662e1177 Mon Sep 17 00:00:00 2001
From: tuqin <tuqin@tuqin.cn>
Date: 星期四, 29 十月 2026 14:33:10 +0800
Subject: [PATCH] feat(LIMS): 样品/实验/数据接口三页面增强

---
 src/views/lims/sampleManagement/index.vue |  238 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 221 insertions(+), 17 deletions(-)

diff --git a/src/views/lims/sampleManagement/index.vue b/src/views/lims/sampleManagement/index.vue
index e22c4ec..966a71e 100644
--- a/src/views/lims/sampleManagement/index.vue
+++ b/src/views/lims/sampleManagement/index.vue
@@ -38,6 +38,7 @@
       </div>
       <div>
         <el-button type="primary" @click="openForm('add')">鏂板鏍峰搧</el-button>
+        <el-button type="warning" plain @click="openOutStock()">鍑哄簱</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
       </div>
@@ -249,6 +250,93 @@
       </template>
     </el-dialog>
   </div>
+
+    <!-- ===== 鏍峰搧璇︽儏鎶藉眽锛氬嚭鍏ュ簱娴佹按 + 鐘舵�佸彉鏇村巻鍙� ===== -->
+    <el-drawer v-model="detailVisible" title="鏍峰搧璇︽儏" size="820px" destroy-on-close>
+      <div v-if="detailData.sample" style="padding: 0 12px">
+        <el-descriptions :column="3" border size="small" title="鍩烘湰淇℃伅">
+          <el-descriptions-item label="鏍峰搧缂栧彿">{{ detailData.sample.sampleCode }}</el-descriptions-item>
+          <el-descriptions-item label="鏍峰搧鍚嶇О">{{ detailData.sample.sampleName }}</el-descriptions-item>
+          <el-descriptions-item label="绫诲瀷">{{ detailData.sample.sampleType }}</el-descriptions-item>
+          <el-descriptions-item label="瑙勬牸">{{ detailData.sample.specification }}</el-descriptions-item>
+          <el-descriptions-item label="鏁伴噺">{{ detailData.sample.quantity }} {{ detailData.sample.unit }}</el-descriptions-item>
+          <el-descriptions-item label="褰撳墠鐘舵��">
+            <el-tag :type="statusTagType(detailData.sample.sampleStatus)" size="small">{{ statusText(detailData.sample.sampleStatus) }}</el-tag>
+          </el-descriptions-item>
+          <el-descriptions-item label="瀛樺偍浣嶇疆">{{ detailData.sample.storageLocation }}</el-descriptions-item>
+          <el-descriptions-item label="鍏ュ簱鏃ユ湡">{{ detailData.sample.inStockDate }}</el-descriptions-item>
+          <el-descriptions-item label="鏈夋晥鏈熻嚦">{{ detailData.sample.validityDate }}</el-descriptions-item>
+        </el-descriptions>
+
+        <el-divider content-position="left">鍑哄叆搴撴祦姘达紙{{ (detailData.stockRecords || []).length }} 鏉★級</el-divider>
+        <el-table :data="detailData.stockRecords || []" border size="small" max-height="300">
+          <el-table-column prop="operateTime" label="鏃堕棿" width="160" />
+          <el-table-column prop="recordType" label="绫诲瀷" width="80">
+            <template #default="{ row }">
+              <el-tag :type="row.recordType === 'in' ? 'success' : 'warning'" size="small">{{ recordTypeText(row.recordType) }}</el-tag>
+            </template>
+          </el-table-column>
+          <el-table-column prop="quantity" label="鏁伴噺" width="90" />
+          <el-table-column label="鐘舵�佸彉鍖�" width="150">
+            <template #default="{ row }">{{ statusText(row.beforeStatus) }} 鈫� {{ statusText(row.afterStatus) }}</template>
+          </el-table-column>
+          <el-table-column prop="operator" label="缁忔墜浜�" width="100" />
+          <el-table-column prop="recipient" label="棰嗙敤鏂�" width="110" show-overflow-tooltip />
+          <el-table-column prop="purpose" label="浜嬬敱" show-overflow-tooltip />
+        </el-table>
+
+        <el-divider content-position="left">鐘舵�佸彉鏇村巻鍙诧紙{{ (detailData.statusLogs || []).length }} 鏉★級</el-divider>
+        <el-timeline v-if="(detailData.statusLogs || []).length">
+          <el-timeline-item
+            v-for="log in detailData.statusLogs"
+            :key="log.id"
+            :timestamp="log.operateTime"
+            placement="top"
+          >
+            <div>{{ statusText(log.fromStatus) }} <b>鈫�</b> {{ statusText(log.toStatus) }}</div>
+            <div style="color: #909399; font-size: 12px">{{ log.changeReason || "鈥�" }}銆�鎿嶄綔浜猴細{{ log.operator || "鈥�" }}</div>
+          </el-timeline-item>
+        </el-timeline>
+        <el-empty v-else description="鏆傛棤鐘舵�佸彉鏇磋褰�" :image-size="60" />
+      </div>
+    </el-drawer>
+
+    <!-- ===== 鏍峰搧鍑哄簱寮圭獥 ===== -->
+    <el-dialog v-model="outStockVisible" title="鏍峰搧鍑哄簱" width="560px">
+      <el-form :model="outForm" label-position="top">
+        <el-form-item label="鏍峰搧">
+          <el-input :model-value="outForm.sampleName + '锛�' + outForm.sampleCode + '锛岀幇鏈� ' + (outForm.stock ?? 0) + (outForm.unit || '') + '锛�'" disabled />
+        </el-form-item>
+        <el-row :gutter="16">
+          <el-col :span="12">
+            <el-form-item label="鍑哄簱鏁伴噺">
+              <el-input-number v-model="outForm.quantity" :precision="4" :min="0.0001" :max="outForm.stock || 999999" style="width: 100%" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="棰嗙敤鏂�/鎺ユ敹浜�">
+              <el-input v-model="outForm.recipient" placeholder="璇疯緭鍏�" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-form-item label="鍘诲悜 / 鏂板瓨鍌ㄤ綅缃�">
+          <el-input v-model="outForm.toLocation" placeholder="濡傦細妫�娴嬪 A / 瀹㈡埛鐜板満" />
+        </el-form-item>
+        <el-form-item label="鍑哄簱浜嬬敱">
+          <el-input v-model="outForm.purpose" placeholder="濡傦細閫佹銆佺暀鏍疯浆绉汇�侀攢姣佸墠澶勭悊" />
+        </el-form-item>
+        <el-form-item label="鍏宠仈瀹為獙缂栧彿锛堝彲閫夛級">
+          <el-input v-model="outForm.relatedExperiment" placeholder="璇疯緭鍏�" />
+        </el-form-item>
+        <el-form-item label="澶囨敞">
+          <el-input v-model="outForm.remark" type="textarea" :rows="2" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <el-button @click="outStockVisible = false">鍙栨秷</el-button>
+        <el-button type="primary" @click="submitOutStock">纭鍑哄簱</el-button>
+      </template>
+    </el-dialog>
 </template>
 
 <script setup>
@@ -261,8 +349,9 @@
   listSample,
   updateSample,
 } from "@/api/lims/sample.js";
-import { ElMessageBox } from "element-plus";
+import { ElMessage, ElMessageBox } from "element-plus";
 import { userListNoPage } from "@/api/system/user.js";
+import { getSampleDetail, outStockSample } from "@/api/lims/sample";
 import useUserStore from "@/store/modules/user";
 const { proxy } = getCurrentInstance();
 const userStore = useUserStore();
@@ -328,22 +417,36 @@
     width: 100,
   },
   {
-    dataType: "action",
-    label: "鎿嶄綔",
-    align: "center",
-    fixed: 'right',
-    operation: [
-      {
-        name: "缂栬緫",
-        type: "text",
-        clickFun: (row) => {
-          openForm("edit", row);
-        },
-        disabled: (row) => {
-          return row.maintainer !== userStore.nickName
-        }
-      },
-    ],
+        dataType: "action",
+        label: "鎿嶄綔",
+        align: "center",
+        fixed: 'right',
+        operation: [
+          {
+            name: "璇︽儏",
+            type: "text",
+            clickFun: (row) => {
+              openDetail(row);
+            },
+          },
+          {
+            name: "鍑哄簱",
+            type: "text",
+            clickFun: (row) => {
+              openOutStock(row);
+            },
+          },
+          {
+            name: "缂栬緫",
+            type: "text",
+            clickFun: (row) => {
+              openForm("edit", row);
+            },
+            disabled: (row) => {
+              return row.maintainer !== userStore.nickName
+            }
+          },
+        ],
   },
 ]);
 const tableData = ref([]);
@@ -531,6 +634,107 @@
   return `${year}-${month}-${day}`;
 }
 
+// ==================== 绗簩鎵归渶姹傦細璇︽儏 / 鍑哄簱 ====================
+const detailVisible = ref(false);
+const detailData = ref({ sample: null, stockRecords: [], statusLogs: [] });
+const outStockVisible = ref(false);
+const outForm = ref({ sampleId: null, sampleCode: "", sampleName: "", stock: 0, unit: "", quantity: null });
+
+const STATUS_MAP = {
+  inStock: "鍦ㄥ簱",
+  outStock: "鍑哄簱",
+  testing: "妫�娴嬩腑",
+  destroyed: "宸查攢姣�",
+};
+const RECORD_TYPE_MAP = {
+  in: "鍏ュ簱",
+  out: "鍑哄簱",
+  destroy: "閿�姣�",
+  return: "閫�搴�",
+  transfer: "杞Щ",
+};
+const statusText = (s) => STATUS_MAP[s] || s || "鈥�";
+const recordTypeText = (t) => RECORD_TYPE_MAP[t] || t || "鈥�";
+const statusTagType = (s) => {
+  if (s === "inStock") return "success";
+  if (s === "testing") return "warning";
+  if (s === "destroyed") return "danger";
+  return "info";
+};
+
+// 鎵撳紑璇︽儏鎶藉眽
+const openDetail = (row) => {
+  detailData.value = { sample: null, stockRecords: [], statusLogs: [] };
+  detailVisible.value = true;
+  getSampleDetail(row.id).then((res) => {
+    detailData.value = res.data || { sample: null, stockRecords: [], statusLogs: [] };
+  });
+};
+
+// 鎵撳紑鍑哄簱寮圭獥锛堜笉浼� row 鏃剁敤琛ㄦ牸閫変腑琛岋級
+const openOutStock = (row) => {
+  let target = row;
+  if (!target) {
+    if (!selectedRows.value.length) {
+      ElMessage.warning("璇峰厛閫夋嫨瑕佸嚭搴撶殑鏍峰搧");
+      return;
+    }
+    if (selectedRows.value.length > 1) {
+      ElMessage.warning("涓�娆″彧鑳藉嚭搴撲竴涓牱鍝侊紝璇峰彧閫変竴鏉�");
+      return;
+    }
+    target = selectedRows.value[0];
+  }
+  if (target.sampleStatus === "destroyed") {
+    ElMessage.warning("鏍峰搧宸查攢姣侊紝涓嶈兘鍑哄簱");
+    return;
+  }
+  if (target.sampleStatus === "outStock") {
+    ElMessage.warning("鏍峰搧宸叉槸鍑哄簱鐘舵��");
+    return;
+  }
+  outForm.value = {
+    sampleId: target.id,
+    sampleCode: target.sampleCode,
+    sampleName: target.sampleName,
+    stock: Number(target.quantity || 0),
+    unit: target.unit || "",
+    quantity: null,
+    recipient: "",
+    toLocation: "",
+    purpose: "",
+    relatedExperiment: "",
+    remark: "",
+  };
+  outStockVisible.value = true;
+};
+
+// 鎻愪氦鍑哄簱
+const submitOutStock = () => {
+  const f = outForm.value;
+  if (!f.quantity || f.quantity <= 0) {
+    ElMessage.warning("璇疯緭鍏ュ嚭搴撴暟閲�");
+    return;
+  }
+  if (f.quantity > f.stock) {
+    ElMessage.warning("鍑哄簱鏁伴噺瓒呰繃褰撳墠搴撳瓨锛堢幇鏈� " + f.stock + (f.unit || "") + "锛�");
+    return;
+  }
+  outStockSample({
+    sampleId: f.sampleId,
+    quantity: f.quantity,
+    recipient: f.recipient,
+    toLocation: f.toLocation,
+    purpose: f.purpose,
+    relatedExperiment: f.relatedExperiment,
+    remark: f.remark,
+  }).then((res) => {
+    ElMessage.success(res.msg || "鍑哄簱鎴愬姛");
+    outStockVisible.value = false;
+    getList();
+  });
+};
+
 onMounted(() => {
   getList();
 });

--
Gitblit v1.9.3