From a27edc14f632e878ede9c7b16de10b01626e938b Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 25 三月 2026 14:39:08 +0800
Subject: [PATCH] fix: 检测提交后,管理员还能进行编辑

---
 src/pages/qualityManagement/rawMaterial/form.vue |   57 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 38 insertions(+), 19 deletions(-)

diff --git a/src/pages/qualityManagement/rawMaterial/form.vue b/src/pages/qualityManagement/rawMaterial/form.vue
index 3f84f70..7d54340 100644
--- a/src/pages/qualityManagement/rawMaterial/form.vue
+++ b/src/pages/qualityManagement/rawMaterial/form.vue
@@ -1,6 +1,6 @@
 <template>
   <view class="rm-form-page">
-    <PageHeader :title="operationType === 'add' ? '鏂板鍘熸枡妫�' : '缂栬緫鍘熸枡妫�'" @back="goBack" />
+    <PageHeader :title="operationType === 'add' ? '鏂板鍘熸枡妫�' : (operationType === 'detail' ? '鍘熸枡妫�楠岃鎯�' : '缂栬緫鍘熸枡妫�')" @back="goBack" />
 
     <scroll-view scroll-y class="content-scroll">
       <view class="section-card">
@@ -8,7 +8,11 @@
 
         <view class="form-row">
           <text class="form-label required">浜у搧鍚嶇О</text>
-          <view class="selector-trigger" @click="openProductSelector" :class="{ disabled: operationType === 'edit' }">
+          <view
+            class="selector-trigger"
+            @click="!isReadOnly && openProductSelector()"
+            :class="{ disabled: operationType === 'edit' || isReadOnly }"
+          >
             <text class="selector-text" :class="{ placeholder: !form.productName }">
               {{ form.productName || '璇烽�夋嫨浜у搧' }}
             </text>
@@ -28,12 +32,12 @@
 
         <view class="form-row">
           <text class="form-label required">鎵瑰彿</text>
-          <up-input v-model="form.batchNo" placeholder="璇疯緭鍏ユ壒鍙�" />
+          <up-input v-model="form.batchNo" :disabled="isReadOnly" placeholder="璇疯緭鍏ユ壒鍙�" />
         </view>
 
         <view class="form-row">
           <text class="form-label required">妫�楠岀被鍨�</text>
-          <view class="selector-trigger" @click="showCheckTypeSheet = true">
+          <view class="selector-trigger" @click="!isReadOnly && (showCheckTypeSheet = true)">
             <text class="selector-text" :class="{ placeholder: form.checkType === '' || form.checkType == null }">
               {{ checkTypeLabel }}
             </text>
@@ -43,7 +47,7 @@
 
         <view class="form-row">
           <text class="form-label required">妫�娴嬬粨鏋�</text>
-          <view class="selector-trigger" @click="showCheckResultSheet = true">
+          <view class="selector-trigger" @click="!isReadOnly && (showCheckResultSheet = true)">
             <text class="selector-text" :class="{ placeholder: form.checkResult === '' || form.checkResult == null }">
               {{ checkResultLabel }}
             </text>
@@ -53,12 +57,12 @@
 
         <view class="form-row">
           <text class="form-label required">妫�楠屽憳</text>
-          <up-input v-model="form.checkUserName" placeholder="璇疯緭鍏ユ楠屽憳" />
+          <up-input v-model="form.checkUserName" :disabled="isReadOnly" placeholder="璇疯緭鍏ユ楠屽憳" />
         </view>
 
         <view class="form-row">
           <text class="form-label required">妫�娴嬫棩鏈�</text>
-          <view class="selector-trigger" @click="openCheckDatePicker">
+          <view class="selector-trigger" @click="!isReadOnly && openCheckDatePicker()">
             <text class="selector-text" :class="{ placeholder: !form.checkTime }">
               {{ form.checkTime || '璇烽�夋嫨妫�娴嬫棩鏈�' }}
             </text>
@@ -70,36 +74,36 @@
       <view class="section-card">
         <view class="section-title row-between">
           <text>妫�娴嬮」鐩�</text>
-          <view class="btn-inline" @click="openItemSelector">娣诲姞妫�娴嬮」鐩�</view>
+          <view class="btn-inline" v-if="!isReadOnly" @click="openItemSelector">娣诲姞妫�娴嬮」鐩�</view>
         </view>
 
         <view v-if="inspectItems.length > 0">
           <view v-for="(it, idx) in inspectItems" :key="it.id || idx" class="item-card">
             <view class="item-head">
               <text class="item-name">{{ it.name }}</text>
-              <view class="item-del" @click="removeItem(it.id)">鍒犻櫎</view>
+              <view class="item-del" v-if="!isReadOnly" @click="removeItem(it.id)">鍒犻櫎</view>
             </view>
             <view class="item-row"><text class="l">鍗曚綅</text><text class="r">{{ it.unit || '-' }}</text></view>
             <view class="item-row"><text class="l">鏍囧噯鍊�</text><text class="r">{{ it.standardValue || '-' }}</text></view>
             <view class="item-row"><text class="l">鍐呮帶鍊�</text><text class="r">{{ it.internalControl || '-' }}</text></view>
             <view class="item-row input-row">
               <text class="l">鍖栭獙鍊�</text>
-              <up-input v-model="it.testValue" placeholder="璇疯緭鍏�" class="test-value-input" />
+              <up-input v-model="it.testValue" :disabled="isReadOnly" placeholder="璇疯緭鍏�" class="test-value-input" />
             </view>
           </view>
         </view>
-        <view v-else class="no-data">璇锋坊鍔犳娴嬮」鐩�</view>
+        <view v-else class="no-data">{{ isReadOnly ? '鏆傛棤妫�娴嬮」鐩�' : '璇锋坊鍔犳娴嬮」鐩�' }}</view>
       </view>
     </scroll-view>
 
-    <view class="bottom-bar">
+    <view class="bottom-bar" v-if="!isReadOnly">
       <view class="btn-submit" :class="{ disabled: submitLoading }" @click="handleSubmit">
         {{ submitLoading ? '鎻愪氦涓�...' : '淇濆瓨' }}
       </view>
     </view>
 
     <!-- 浜у搧閫夋嫨寮圭獥锛堝鐢� pageModel 鎺ュ彛锛� -->
-    <up-popup :show="showProductPopup" mode="bottom" @close="showProductPopup = false">
+    <up-popup :show="showProductPopup && !isReadOnly" mode="bottom" @close="showProductPopup = false">
       <view class="popup-wrap">
         <view class="popup-header">
           <text class="popup-title">閫夋嫨浜у搧</text>
@@ -123,7 +127,7 @@
     </up-popup>
 
     <!-- 妫�娴嬮」鐩�夋嫨寮圭獥锛堢畝鍖栵細浠庢娴嬮」缁存姢琛ㄩ噷閫夛級 -->
-    <up-popup :show="showItemPopup" mode="bottom" @close="showItemPopup = false">
+    <up-popup :show="showItemPopup && !isReadOnly" mode="bottom" @close="showItemPopup = false">
       <view class="popup-wrap">
         <view class="popup-header">
           <text class="popup-title">閫夋嫨妫�娴嬮」鐩�</text>
@@ -164,11 +168,23 @@
     </up-popup>
 
     <!-- 閫夋嫨鍣細妫�楠岀被鍨�/缁撴灉 -->
-    <up-action-sheet :actions="checkTypeActions" :show="showCheckTypeSheet" @close="showCheckTypeSheet = false" @select="onSelectCheckType" title="妫�楠岀被鍨�" />
-    <up-action-sheet :actions="checkResultActions" :show="showCheckResultSheet" @close="showCheckResultSheet = false" @select="onSelectCheckResult" title="妫�娴嬬粨鏋�" />
+    <up-action-sheet
+      :actions="checkTypeActions"
+      :show="showCheckTypeSheet && !isReadOnly"
+      @close="showCheckTypeSheet = false"
+      @select="onSelectCheckType"
+      title="妫�楠岀被鍨�"
+    />
+    <up-action-sheet
+      :actions="checkResultActions"
+      :show="showCheckResultSheet && !isReadOnly"
+      @close="showCheckResultSheet = false"
+      @select="onSelectCheckResult"
+      title="妫�娴嬬粨鏋�"
+    />
 
     <!-- 鏃ユ湡閫夋嫨 -->
-    <up-popup :show="showCheckDatePicker" mode="bottom" @close="showCheckDatePicker = false">
+    <up-popup :show="showCheckDatePicker && !isReadOnly" mode="bottom" @close="showCheckDatePicker = false">
       <up-datetime-picker :show="true" v-model="checkDateValue" mode="date" @confirm="onCheckDateConfirm" @cancel="showCheckDatePicker = false" />
     </up-popup>
   </view>
@@ -187,6 +203,7 @@
 const userStore = useUserStore()
 
 const operationType = ref('add')
+const isReadOnly = computed(() => operationType.value === 'detail')
 const submitLoading = ref(false)
 
 const form = reactive({
@@ -240,7 +257,7 @@
 const productList = ref([])
 const productLoading = ref(false)
 const openProductSelector = () => {
-  if (operationType.value === 'edit') return
+  if (operationType.value === 'edit' || isReadOnly.value) return
   showProductPopup.value = true
   if (productList.value.length === 0) loadProductList()
 }
@@ -270,6 +287,7 @@
 const selectedItemIds = ref(new Set())
 const isItemSelected = (id) => selectedItemIds.value.has(id)
 const openItemSelector = () => {
+  if (isReadOnly.value) return
   showItemPopup.value = true
   selectedItemIds.value = new Set(inspectItems.value.map(i => i.id))
   if (itemList.value.length === 0) loadItemList()
@@ -320,6 +338,7 @@
 }
 
 const handleSubmit = () => {
+  if (isReadOnly.value) return
   if (submitLoading.value) return
   const msg = validate()
   if (msg) {
@@ -343,7 +362,7 @@
 onLoad((options) => {
   operationType.value = options?.type || 'add'
   const id = options?.id
-  if (operationType.value === 'edit' && id) {
+  if ((operationType.value === 'edit' || operationType.value === 'detail') && id) {
     findRawMaterialDetail(id).then(res => {
       const d = res?.data || {}
       form.id = d.id

--
Gitblit v1.9.3