From d991871847391f150dd9c5aa9c871a96b75b7880 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 23 三月 2026 17:11:36 +0800
Subject: [PATCH] fix: 质量管理 可编辑

---
 src/views/qualityManagement/nonconformingManagement/components/formDia.vue |  199 ++++++++++++++++++++-
 src/api/consumablesLogistics/consumablesOutRecord.js                       |    9 +
 src/api/consumablesLogistics/consumablesInRecord.js                        |    9 +
 src/views/qualityManagement/rawMaterial/index.vue                          |   40 ++--
 src/views/consumablesLogistics/receiptManagement/Record.vue                |   97 ++++++++++
 src/views/qualityManagement/nonconformingManagement/index.vue              |   35 +++
 src/views/consumablesLogistics/dispatchLog/Record.vue                      |  104 +++++++++++
 7 files changed, 446 insertions(+), 47 deletions(-)

diff --git a/src/api/consumablesLogistics/consumablesInRecord.js b/src/api/consumablesLogistics/consumablesInRecord.js
index 8b39549..ad57e8c 100644
--- a/src/api/consumablesLogistics/consumablesInRecord.js
+++ b/src/api/consumablesLogistics/consumablesInRecord.js
@@ -17,6 +17,15 @@
     });
 };
 
+// 缂栬緫鑰楁潗鍏ュ簱锛堜粎鐢ㄤ簬鍙拌处缂栬緫锛�
+export const editStockInStock = (data) => {
+    return request({
+        url: "/consumablesInRecord/editStockInStock",
+        method: "post",
+        data,
+    });
+};
+
 export const batchDeleteConsumablesInRecords = (ids) => {
     return request({
         url: "/consumablesInRecord",
diff --git a/src/api/consumablesLogistics/consumablesOutRecord.js b/src/api/consumablesLogistics/consumablesOutRecord.js
index f401711..d49bfa8 100644
--- a/src/api/consumablesLogistics/consumablesOutRecord.js
+++ b/src/api/consumablesLogistics/consumablesOutRecord.js
@@ -17,3 +17,12 @@
         data: ids,
     });
 };
+
+// 缂栬緫鑰楁潗鍑哄簱锛堜粎鐢ㄤ簬鍙拌处缂栬緫锛�
+export const editStockOut = (data) => {
+    return request({
+        url: "/consumablesOutRecord/editStockOut",
+        method: "post",
+        data,
+    });
+};
diff --git a/src/views/consumablesLogistics/dispatchLog/Record.vue b/src/views/consumablesLogistics/dispatchLog/Record.vue
index b526972..ab73b46 100644
--- a/src/views/consumablesLogistics/dispatchLog/Record.vue
+++ b/src/views/consumablesLogistics/dispatchLog/Record.vue
@@ -28,7 +28,12 @@
 			</div>
 			<div>
 				<el-button @click="handleOut">瀵煎嚭</el-button>
-				<el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+				<el-button
+					type="danger"
+					plain
+					@click="handleDelete"
+					v-if="hasCDispatchCancel"
+				>鍒犻櫎</el-button>
 				<!-- <el-button type="primary" plain @click="handlePrint">鎵撳嵃</el-button> -->
 			</div>
 		</div>
@@ -86,6 +91,16 @@
 					prop="createBy"
 					show-overflow-tooltip
 				/>
+				<el-table-column label="鎿嶄綔" width="160" align="center">
+					<template #default="scope">
+						<el-button
+							v-if="hasCDispatchEdit"
+							type="primary"
+							size="mini"
+							@click="handleEdit(scope.row)"
+						>缂栬緫</el-button>
+					</template>
+				</el-table-column>
         <!-- <el-table-column label="鏉ユ簮"
                          prop="recordType"
                          show-overflow-tooltip>
@@ -105,21 +120,66 @@
 			/>
 		</div>
 	</div>
+
+	<el-dialog
+		title="缂栬緫鍑哄簱淇℃伅"
+		v-model="isShowEditModal"
+		width="600px"
+	>
+		<el-form
+			ref="editFormRef"
+			:model="editForm"
+			label-width="90px"
+		>
+			<el-form-item
+				label="鏁伴噺"
+				prop="qualitity"
+				:rules="[{ required: true, message: '璇疯緭鍏ユ暟閲�', trigger: ['blur', 'change'] }]"
+			>
+				<el-input-number
+					v-model="editForm.qualitity"
+					:min="0"
+					:step="1"
+					:precision="0"
+					controls-position="right"
+					style="width: 100%"
+					placeholder="璇疯緭鍏ユ暟閲�"
+				/>
+			</el-form-item>
+			<el-form-item
+				label="閲囪喘鍛�"
+				prop="purchaser"
+				:rules="[{ required: true, message: '璇疯緭鍏ラ噰璐憳', trigger: ['blur', 'change'] }]"
+			>
+				<el-input
+					v-model="editForm.purchaser"
+					placeholder="璇疯緭鍏ラ噰璐憳"
+				/>
+			</el-form-item>
+		</el-form>
+
+		<template #footer>
+			<el-button @click="closeEditModal">鍙栨秷</el-button>
+			<el-button type="primary" @click="handleEditSubmit">纭畾</el-button>
+		</template>
+	</el-dialog>
 </template>
 
 <script setup>
 import pagination from "@/components/PIMTable/Pagination.vue";
-import { ref, reactive, toRefs, getCurrentInstance } from "vue";
+import { ref, reactive, toRefs, getCurrentInstance, computed } from "vue";
 import { ElMessageBox } from "element-plus";
 import useUserStore from "@/store/modules/user";
 import { getCurrentDate } from "@/utils/index.js";
 import {
 	getConsumablesOutRecordPage,
 	delConsumablesOutRecord,
+	editStockOut,
 } from "@/api/consumablesLogistics/consumablesOutRecord.js";
 import {
   findAllQualifiedStockOutRecordTypeOptions, findAllUnQualifiedStockOutRecordTypeOptions,
 } from "@/api/basicData/enum.js";
+import { checkPermi } from "@/utils/permission.js";
 
 const userStore = useUserStore();
 const { proxy } = getCurrentInstance();
@@ -142,6 +202,46 @@
   }
 })
 
+const hasCDispatchEdit = computed(() => checkPermi(['c_dispatch_edit']));
+const hasCDispatchCancel = computed(() => checkPermi(['c_dispatch_cancel']));
+
+// 缂栬緫寮规鏁版嵁
+const isShowEditModal = ref(false);
+const editFormRef = ref();
+const editForm = reactive({
+	id: undefined,
+	qualitity: undefined,
+	purchaser: "",
+});
+
+const handleEdit = (row) => {
+	editForm.id = row.id;
+	editForm.qualitity = row.qualitity;
+	editForm.purchaser = row.purchaser ?? "";
+	isShowEditModal.value = true;
+};
+
+const closeEditModal = () => {
+	isShowEditModal.value = false;
+
+	editForm.id = undefined;
+	editForm.qualitity = undefined;
+	editForm.purchaser = "";
+
+	editFormRef.value?.clearValidate?.();
+};
+
+const handleEditSubmit = () => {
+	editFormRef.value?.validate?.((valid) => {
+		if (!valid) return;
+		editStockOut({ ...editForm }).then(() => {
+			closeEditModal();
+			proxy.$modal.msgSuccess("缂栬緫鎴愬姛");
+			getList();
+		});
+	});
+};
+
 // 鎵撳嵃鐩稿叧
 const printPreviewVisible = ref(false);
 const printData = ref([]);
diff --git a/src/views/consumablesLogistics/receiptManagement/Record.vue b/src/views/consumablesLogistics/receiptManagement/Record.vue
index 571a22a..018dbe2 100644
--- a/src/views/consumablesLogistics/receiptManagement/Record.vue
+++ b/src/views/consumablesLogistics/receiptManagement/Record.vue
@@ -34,7 +34,8 @@
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger"
                    plain
-                   @click="handleDelete">鍒犻櫎
+                   @click="handleDelete"
+                   v-if="hasCReceiptCancel">鍒犻櫎
         </el-button>
       </div>
     </div>
@@ -95,6 +96,18 @@
                        @click="handlePreview(scope.row)">瀵煎嚭杩囩鍗�</el-button>
           </template>
         </el-table-column> -->
+        <el-table-column label="鎿嶄綔"
+                         width="120"
+                         align="center">
+          <template #default="scope">
+            <el-button
+              v-if="hasCReceiptEdit"
+              type="primary"
+              size="mini"
+              @click="handleEdit(scope.row)"
+            >缂栬緫</el-button>
+          </template>
+        </el-table-column>
       </el-table>
       <div style="margin-top: 12px; display: flex; justify-content: flex-end;">
         <pagination v-show="total > 0"
@@ -106,6 +119,51 @@
       </div>
     </div>
   </div>
+
+  <el-dialog
+    v-model="isShowEditModal"
+    title="缂栬緫鍏ュ簱"
+    width="600"
+    @close="closeEditModal"
+  >
+    <el-form
+      label-width="100px"
+      :model="editForm"
+      label-position="top"
+      ref="editFormRef"
+    >
+      <el-form-item
+        label="鏁伴噺"
+        prop="qualitity"
+        :rules="[{ required: true, message: '璇疯緭鍏ユ暟閲�', trigger: ['blur', 'change'] }]"
+      >
+        <el-input-number
+          v-model="editForm.qualitity"
+          :min="0"
+          :step="1"
+          :precision="0"
+          controls-position="right"
+          style="width: 100%"
+          placeholder="璇疯緭鍏ユ暟閲�"
+        />
+      </el-form-item>
+
+      <el-form-item
+        label="閲囪喘鍛�"
+        prop="purchaser"
+        :rules="[{ required: true, message: '璇疯緭鍏ラ噰璐憳', trigger: ['blur', 'change'] }]"
+      >
+        <el-input v-model="editForm.purchaser" placeholder="璇疯緭鍏ラ噰璐憳" />
+      </el-form-item>
+    </el-form>
+
+    <template #footer>
+      <div class="dialog-footer">
+        <el-button type="primary" @click="handleEditSubmit">纭</el-button>
+        <el-button @click="closeEditModal">鍙栨秷</el-button>
+      </div>
+    </template>
+  </el-dialog>
 </template>
 
 <script setup>
@@ -116,15 +174,18 @@
   toRefs,
   onMounted,
   getCurrentInstance,
+  computed,
 } from "vue";
 import {ElMessageBox} from "element-plus";
 import {
   getConsumablesInRecordListPage,
   batchDeleteConsumablesInRecords,
+  editStockInStock,
 } from "@/api/consumablesLogistics/consumablesInRecord.js";
 import {
   findAllQualifiedStockInRecordTypeOptions, findAllUnQualifiedStockInRecordTypeOptions,
 } from "@/api/basicData/enum.js";
+import { checkPermi } from "@/utils/permission.js";
 
 const {proxy} = getCurrentInstance();
 
@@ -135,6 +196,9 @@
     default: '0'
   }
 })
+
+const hasCReceiptEdit = computed(() => checkPermi(['c_receipt_edit']));
+const hasCReceiptCancel = computed(() => checkPermi(['c_receipt_cancel']));
 
 const tableData = ref([]);
 const selectedRows = ref([]);
@@ -253,6 +317,37 @@
       });
 };
 
+// 缂栬緫鑰楁潗鍏ュ簱
+const isShowEditModal = ref(false);
+const editFormRef = ref(null);
+const editForm = ref({});
+
+const handleEdit = (row) => {
+  editForm.value = {
+    id: row.id,
+    qualitity: row.qualitity,
+    purchaser: row.purchaser,
+  };
+  isShowEditModal.value = true;
+};
+
+const closeEditModal = () => {
+  isShowEditModal.value = false;
+  editForm.value = {};
+  editFormRef.value?.clearValidate?.();
+};
+
+const handleEditSubmit = () => {
+  editFormRef.value?.validate?.((valid) => {
+    if (!valid) return;
+    editStockInStock(editForm.value).then(() => {
+      closeEditModal();
+      proxy.$modal.msgSuccess("缂栬緫鎴愬姛");
+      getList();
+    });
+  });
+};
+
 onMounted(() => {
   getList();
   fetchStockRecordTypeOptions();
diff --git a/src/views/qualityManagement/nonconformingManagement/components/formDia.vue b/src/views/qualityManagement/nonconformingManagement/components/formDia.vue
index e7340d7..d5836a2 100644
--- a/src/views/qualityManagement/nonconformingManagement/components/formDia.vue
+++ b/src/views/qualityManagement/nonconformingManagement/components/formDia.vue
@@ -11,6 +11,7 @@
           <el-col :span="12">
             <el-form-item label="浜у搧鍚嶇О锛�" prop="productId">
               <el-tree-select
+                  v-if="operationType !== 'edit'"
                   v-model="form.productId"
                   placeholder="璇烽�夋嫨"
                   clearable
@@ -18,7 +19,13 @@
                   @change="getModels"
                   :data="productOptions"
                   :render-after-expand="false"
-                  :disabled="operationType === 'edit'"
+                  style="width: 100%"
+              />
+              <!-- 缂栬緫鎬侊細涓嶄緷璧栦笅鎷夐�夐」鍥炴樉锛岀洿鎺ュ睍绀烘枃鏈� -->
+              <el-input
+                  v-else
+                  v-model="form.productName"
+                  disabled
                   style="width: 100%"
               />
             </el-form-item>
@@ -26,16 +33,28 @@
           <el-col :span="12">
             <el-form-item label="瑙勬牸鍨嬪彿锛�" prop="productModelId">
               <el-select
+                  v-if="operationType !== 'edit'"
                   v-model="form.productModelId"
                   placeholder="璇烽�夋嫨"
                   clearable
-                  :disabled="operationType === 'edit'"
                   filterable
                   readonly
                   @change="handleChangeModel"
               >
-                <el-option v-for="item in modelOptions" :key="item.id" :label="item.model" :value="item.id" />
+                <el-option
+                    v-for="item in modelOptions"
+                    :key="item.id"
+                    :label="item.model"
+                    :value="item.id"
+                />
               </el-select>
+              <!-- 缂栬緫鎬侊細涓嶅睍绀鸿鏍煎瀷鍙峰垪琛紝鐩存帴灞曠ず鏂囨湰 -->
+              <el-input
+                  v-else
+                  v-model="form.model"
+                  disabled
+                  style="width: 100%"
+              />
             </el-form-item>
           </el-col>
         </el-row>
@@ -187,7 +206,7 @@
   },
   rules: {
     checkTime: [{ required: true, message: "璇烽�夋嫨妫�娴嬫棩鏈�", trigger: "change" }],
-    checkUserName: [{ required: true, message: "璇烽�夋嫨妫�楠屽憳", trigger: "change" }],
+    checkName: [{ required: true, message: "璇烽�夋嫨妫�楠屽憳", trigger: "change" }],
     productId: [{ required: true, message: "璇烽�夋嫨浜у搧鍚嶇О", trigger: "change" }],
     productModelId: [{ required: true, message: "璇烽�夋嫨瑙勬牸鍨嬪彿", trigger: "change" }],
     batchNo: [{ required: true, message: "璇疯緭鍏ユ壒鍙�", trigger: "blur" }],
@@ -203,27 +222,114 @@
 const modelOptions = ref([])
 
 // 鎵撳紑寮规
-const openDialog = (type, row) => {
+const openDialog = async (type, row) => {
   operationType.value = type;
-  userListNoPage().then(res => {
-    userList.value = res.data || [];
-  })
   dialogFormVisible.value = true;
   form.value = {}
-  getProductOptions();
+
+  // 缂栬緫鎬佷笉鏍¢獙瑙勬牸鍨嬪彿锛坧rop 浠嶇粦瀹� productModelId锛屼絾缂栬緫鎬佹敼涓烘枃鏈睍绀猴級
+  data.rules.productModelId = [
+    {
+      required: type !== "edit",
+      message: "璇烽�夋嫨瑙勬牸鍨嬪彿",
+      trigger: "change",
+    },
+  ];
+
+  // 鍏堝姞杞戒笅鎷夐�夐」锛岀‘淇濈紪杈戞暟鎹彲浠ユ纭尮閰嶅洖鏄�
+  const userRes = await userListNoPage();
+  userList.value = userRes.data || [];
+
+  await getProductOptions();
+
   // 澶勭悊缁撴灉榛樿鈥滄姤搴熲�濓紝涓斾笉鍙�夋嫨鍏跺畠椤�
   form.value.dealResult = getScrapDealResultValue();
   if (operationType.value === 'edit') {
-    getQualityUnqualifiedInfo(row.id).then(res => {
-      const { inspectState, ...rest } = (res.data || {})
-      form.value = { ...rest, dealResult: getScrapDealResultValue() }
-    })
+    const fallback = row || {};
+    const res = await getQualityUnqualifiedInfo(fallback.id);
+    const { inspectState, ...rest } = res.data || {};
+
+    // 鍏堢敤鍒楄〃琛屾暟鎹妸鈥滃繀鍥炴樉瀛楁鈥濈洿鎺ュ~涓婏紝閬垮厤璇︽儏鎺ュ彛瀛楁鍚嶄笉涓�鑷村鑷村叏绌恒��
+    const productName = rest?.productName ?? fallback?.productName;
+    const modelName = rest?.model ?? fallback?.model;
+
+    const checkTypeValue = rest?.checkType ?? fallback?.checkType;
+    const checkNameValue =
+      rest?.checkName ??
+      rest?.checkUserName ??
+      fallback?.checkName ??
+      fallback?.checkUserName;
+
+    const productId =
+      rest?.productId ??
+      findProductIdByLabel(productOptions.value, productName);
+
+    // 鍏堝洖濉瓧娈碉紙productModelId 闇�瑕佷緷璧� modelOptions锛岀◢鍚庡啀琛ワ級
+    const normalizedProductId = normalizeProductIdByOptions(productId);
+
+    // 缂栬緫鎬佷骇鍝佸悕绉板睍绀哄彧灞曠ず label锛岄伩鍏嶆爲缁勪欢鍥炴樉渚濊禆 value 鍖归厤
+    const productNameLabel =
+      rest?.productName ??
+      fallback?.productName ??
+      findNodeById(productOptions.value, normalizedProductId) ??
+      productName;
+    form.value = {
+      ...rest,
+      productName: productNameLabel,
+      productId: normalizedProductId,
+      productModelId: rest?.productModelId ?? undefined,
+      model: rest?.model ?? fallback?.model,
+      unit: rest?.unit ?? fallback?.unit,
+      batchNo: rest?.batchNo ?? fallback?.batchNo ?? "",
+      checkType:
+        checkTypeValue === undefined || checkTypeValue === null
+          ? undefined
+          : Number(checkTypeValue),
+      checkName: checkNameValue ?? "",
+      checkTime: rest?.checkTime ?? fallback?.checkTime ?? "",
+      defectivePhenomena:
+        rest?.defectivePhenomena ?? fallback?.defectivePhenomena ?? "",
+      dealName: rest?.dealName ?? fallback?.dealName ?? "",
+      dealTime: rest?.dealTime ?? fallback?.dealTime ?? "",
+      dealResult: getScrapDealResultValue(),
+    };
+
+    // 瑙勬牸鍨嬪彿涓嬫媺闇�瑕佷緷璧� productId
+    await loadModelsForProductId(form.value.productId);
+
+    // 瑙勬牸鍨嬪彿鍥炴樉锛堝璇︽儏娌$粰 productModelId锛屽氨鐢� model 鍚嶇О鍙嶆煡锛�
+    if (!form.value.productModelId) {
+      form.value.productModelId = findModelIdByModel(
+        modelOptions.value,
+        modelName
+      );
+    }
+
+    // 鏍规嵁 productModelId 鍥炲~ model/unit
+    if (form.value.productModelId) {
+      form.value.productModelId = normalizeModelIdByOptions(form.value.productModelId);
+      handleChangeModel(form.value.productModelId);
+    } else if (modelName) {
+      // productModelId 浠嶇劧鎷夸笉鍒版椂锛岃嚦灏戜繚璇� model/unit 鏂囨湰鍥炴樉
+      const matched =
+        (modelOptions.value || []).find((m) => {
+          const model = String(m?.model ?? "");
+          const id = String(m?.id ?? "");
+          const target = String(modelName ?? "");
+          return model === target || id === target;
+        }) ?? null;
+      if (matched) {
+        form.value.model = matched.model ?? form.value.model;
+        form.value.unit = matched.unit ?? form.value.unit;
+      } else {
+        form.value.model = modelName;
+      }
+    }
   }
 }
-const getProductOptions = () => {
-  productTreeList().then((res) => {
-    productOptions.value = convertIdToValue(res);
-  });
+const getProductOptions = async () => {
+  const res = await productTreeList();
+  productOptions.value = convertIdToValue(res);
 };
 const getModels = (value) => {
   form.value.productName = findNodeById(productOptions.value, value);
@@ -236,9 +342,41 @@
   })
 };
 
+// 缂栬緫妯″紡/鎴栦换鎰忛渶瑕佹椂锛氬彧鎷夊彇瑙勬牸鍨嬪彿鍒楄〃锛屼笉娓呯┖宸插洖濉殑瀛楁
+const loadModelsForProductId = async (productId) => {
+  if (!productId) return;
+  const res = await modelList({ id: productId });
+  modelOptions.value = res || [];
+
+  // 璁╁崟浣�/鍨嬪彿绛夊瓧娈典繚鎸佷笌褰撳墠 productModelId 涓�鑷�
+  if (form.value.productModelId) {
+    form.value.productModelId = normalizeModelIdByOptions(form.value.productModelId);
+    handleChangeModel(form.value.productModelId);
+  }
+};
+
 const handleChangeModel = (value) => {
   form.value.model = modelOptions.value.find(item => item.id == value)?.model || '';
   form.value.unit = modelOptions.value.find(item => item.id == value)?.unit || '';
+};
+
+// 瑙e喅鍥炴樉鏃剁被鍨嬩笉涓�鑷村鑷� el-tree-select / el-select 鍙樉绀� value锛坕d锛�
+const normalizeProductIdByOptions = (productId) => {
+  if (productId === undefined || productId === null) return productId;
+  const target = String(productId);
+  const stack = Array.isArray(productOptions.value) ? [...productOptions.value] : [];
+  while (stack.length) {
+    const node = stack.shift();
+    if (node && String(node?.value ?? "") === target) return node?.value;
+    if (node?.children?.length) stack.push(...node.children);
+  }
+  return productId;
+};
+
+const normalizeModelIdByOptions = (modelId) => {
+  if (modelId === undefined || modelId === null) return modelId;
+  const target = String(modelId);
+  return (modelOptions.value || []).find((m) => String(m?.id ?? "") === target)?.id ?? modelId;
 };
 const findNodeById = (nodes, productId) => {
   for (let i = 0; i < nodes.length; i++) {
@@ -254,6 +392,33 @@
   }
   return null; // 娌℃湁鎵惧埌鑺傜偣锛岃繑鍥瀗ull
 };
+
+// 鏍规嵁鏍戣妭鐐� label 鍥炲~ value锛堢紪杈戝洖鏄惧厹搴曠敤锛�
+const findProductIdByLabel = (nodes, label) => {
+  const target = String(label ?? "");
+  if (!target) return undefined;
+
+  const stack = Array.isArray(nodes) ? [...nodes] : [];
+  while (stack.length) {
+    const node = stack.shift();
+    if (node && String(node?.label ?? "") === target) return node?.value;
+    if (node?.children?.length) stack.push(...node.children);
+  }
+  return undefined;
+};
+
+// 鏍规嵁瑙勬牸鍨嬪彿鍚嶇О鍙嶆煡 id锛堢紪杈戝洖鏄惧厹搴曠敤锛�
+const findModelIdByModel = (models, model) => {
+  const target = String(model ?? "");
+  if (!target) return undefined;
+  return (
+    (models || []).find((m) => {
+      const mModel = String(m?.model ?? "");
+      const mId = String(m?.id ?? "");
+      return mModel === target || mId === target;
+    })?.id
+  );
+};
 function convertIdToValue(data) {
   return data.map((item) => {
     const { id, children, ...rest } = item;
diff --git a/src/views/qualityManagement/nonconformingManagement/index.vue b/src/views/qualityManagement/nonconformingManagement/index.vue
index ba6c7a1..31424a0 100644
--- a/src/views/qualityManagement/nonconformingManagement/index.vue
+++ b/src/views/qualityManagement/nonconformingManagement/index.vue
@@ -37,7 +37,12 @@
       <div>
         <el-button type="primary" @click="openForm('add')">鏂板</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
-        <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+        <el-button
+            type="danger"
+            plain
+            @click="handleDelete"
+            v-if="hasNonconformingCancel"
+        >鍒犻櫎</el-button>
       </div>
     </div>
     <div class="table_list">
@@ -60,12 +65,13 @@
 
 <script setup>
 import { Search } from "@element-plus/icons-vue";
-import {onMounted, ref} from "vue";
+import { onMounted, ref, computed } from "vue";
 import FormDia from "@/views/qualityManagement/nonconformingManagement/components/formDia.vue";
 import {ElMessageBox} from "element-plus";
 import {qualityUnqualifiedDel, qualityUnqualifiedListPage} from "@/api/qualityManagement/nonconformingManagement.js";
 import InspectionFormDia from "@/views/qualityManagement/nonconformingManagement/components/inspectionFormDia.vue";
 import dayjs from "dayjs";
+import { checkPermi } from "@/utils/permission.js";
 
 const data = reactive({
   searchForm: {
@@ -78,6 +84,10 @@
   },
 });
 const { searchForm } = toRefs(data);
+
+const hasNonconformingEdit = computed(() => checkPermi(["nonconforming_edit"]));
+const hasNonconformingCancel = computed(() => checkPermi(["nonconforming_cancel"]));
+
 const tableColumn = ref([
   {
     label: "妫�娴嬫棩鏈�",
@@ -154,6 +164,23 @@
     prop: "dealTime",
     width: 120
   },
+  {
+    dataType: "action",
+    label: "鎿嶄綔",
+    align: "center",
+    fixed: "right",
+    width: 180,
+    operation: [
+      {
+        name: "缂栬緫",
+        type: "text",
+        showHide: (row) => hasNonconformingEdit.value,
+        clickFun: (row) => {
+          openForm("edit", row);
+        },
+      },
+    ],
+  },
 ]);
 const tableData = ref([]);
 const selectedRows = ref([]);
@@ -206,10 +233,6 @@
 
 // 鎵撳紑寮规
 const openForm = (type, row) => {
-  if (type !== 'add' && row?.inspectState === 1) {
-    proxy.$modal.msgWarning("宸插鐞嗙殑鏁版嵁涓嶈兘鍐嶇紪杈�");
-    return;
-  }
   nextTick(() => {
     formDia.value?.openDialog(type, row)
   })
diff --git a/src/views/qualityManagement/rawMaterial/index.vue b/src/views/qualityManagement/rawMaterial/index.vue
index b838b90..b770e0d 100644
--- a/src/views/qualityManagement/rawMaterial/index.vue
+++ b/src/views/qualityManagement/rawMaterial/index.vue
@@ -45,7 +45,7 @@
       <div>
         <el-button type="primary" @click="openForm('add')">鏂板</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
-        <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>
+        <el-button type="danger" plain @click="handleDelete" v-if="hasRawCancel">鍒犻櫎</el-button>
       </div>
     </div>
     <div class="table_list">
@@ -86,7 +86,7 @@
 </template>
 
 <script setup>
-import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
+import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick, computed} from "vue";
 import InspectionFormDia from "@/views/qualityManagement/rawMaterial/components/inspectionFormDia.vue";
 import FormDia from "@/views/qualityManagement/rawMaterial/components/formDia.vue";
 import {ElMessageBox} from "element-plus";
@@ -99,6 +99,7 @@
   findRawMaterialListPage,
   submitRawMaterial, updateCheckUserName,downloadRawMaterial
 } from "@/api/qualityManagement/rawMaterial.js";
+import { checkPermi } from "@/utils/permission.js";
 
 const data = reactive({
   searchForm: {
@@ -114,6 +115,8 @@
   },
 });
 const {searchForm, rules} = toRefs(data);
+
+const hasRawCancel = computed(() => checkPermi(["raw_cancel"]));
 const tableColumn = ref([
   {
     label: "妫�娴嬫棩鏈�",
@@ -190,11 +193,6 @@
         disabled: (row) => {
           // 宸叉彁浜ゅ垯绂佺敤
           if (row.inspectState == 1) return true;
-          // 濡傛灉妫�楠屽憳鏈夊�硷紝鍙湁褰撳墠鐧诲綍鐢ㄦ埛鑳界紪杈�
-          if (row.checkUserName) {
-            return row.checkUserName !== userStore.nickName;
-          }
-          return false;
         }
       },
       {
@@ -216,20 +214,20 @@
           return false;
         }
       },
-      {
-        name: "鍒嗛厤妫�楠屽憳",
-        type: "text",
-        clickFun: (row) => {
-          if (!row.checkUserName) {
-            open(row)
-          } else {
-            proxy.$modal.msgError("妫�楠屽憳宸插瓨鍦�");
-          }
-        },
-        disabled: (row) => {
-          return row.inspectState === 1 || row.checkUserName || row.checkUserName !== '';
-        }
-      },
+      // {
+      //   name: "鍒嗛厤妫�楠屽憳",
+      //   type: "text",
+      //   clickFun: (row) => {
+      //     if (!row.checkUserName) {
+      //       open(row)
+      //     } else {
+      //       proxy.$modal.msgError("妫�楠屽憳宸插瓨鍦�");
+      //     }
+      //   },
+      //   disabled: (row) => {
+      //     return row.inspectState === 1 || row.checkUserName || row.checkUserName !== '';
+      //   }
+      // },
       {
         name: "涓嬭浇",
         type: "text",

--
Gitblit v1.9.3