From 0a251e40e30e7c8a96d71b3b9b6c459d4dfa4b22 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 08 七月 2026 23:04:45 +0800
Subject: [PATCH] 暂存

---
 src/views/qualityManagement/rawMaterialInspection/index.vue |  148 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 105 insertions(+), 43 deletions(-)

diff --git a/src/views/qualityManagement/rawMaterialInspection/index.vue b/src/views/qualityManagement/rawMaterialInspection/index.vue
index 804fed2..346ae9b 100644
--- a/src/views/qualityManagement/rawMaterialInspection/index.vue
+++ b/src/views/qualityManagement/rawMaterialInspection/index.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <div class="search_form">
+    <div class="search_form mb20">
       <div>
         <span class="search_title">渚涘簲鍟嗭細</span>
         <el-input
@@ -40,8 +40,8 @@
     </div>
     <InspectionFormDia ref="inspectionFormDia" @close="handleQuery"></InspectionFormDia>
     <FormDia ref="formDia" @close="handleQuery"></FormDia>
-    <files-dia ref="filesDia" @close="handleQuery"></files-dia>
-    <el-dialog v-model="dialogFormVisible" title="缂栬緫妫�楠屽憳" width="70%"
+    <files-dia ref="filesDia"></files-dia>
+    <el-dialog v-model="dialogFormVisible" title="缂栬緫妫�楠屽憳" width="30%"
                @close="closeDia">
       <el-form :model="form" label-width="140px" label-position="top" :rules="rules" ref="formRef">
         <el-form-item label="妫�楠屽憳锛�" prop="checkName">
@@ -64,7 +64,7 @@
 
 <script setup>
 import {Search} from "@element-plus/icons-vue";
-import {onMounted, ref} from "vue";
+import {onMounted, ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
 import InspectionFormDia from "@/views/qualityManagement/rawMaterialInspection/components/inspectionFormDia.vue";
 import FormDia from "@/views/qualityManagement/rawMaterialInspection/components/formDia.vue";
 import {ElMessageBox} from "element-plus";
@@ -77,16 +77,14 @@
 import FilesDia from "@/views/qualityManagement/rawMaterialInspection/components/filesDia.vue";
 import dayjs from "dayjs";
 import {userListNoPage} from "@/api/system/user.js";
+import useUserStore from "@/store/modules/user";
 
 const data = reactive({
   searchForm: {
     supplier: "",
-    entryDate: [
-      dayjs().format("YYYY-MM-DD"),
-      dayjs().add(1, "day").format("YYYY-MM-DD"),
-    ], // 褰曞叆鏃ユ湡
-    entryDateStart: dayjs().format("YYYY-MM-DD"),
-    entryDateEnd: dayjs().add(1, "day").format("YYYY-MM-DD"),
+    entryDate: undefined, // 褰曞叆鏃ユ湡
+    entryDateStart: undefined,
+    entryDateEnd: undefined,
   },
   rules: {
     checkName: [{required: true, message: "璇烽�夋嫨", trigger: "change"}],
@@ -97,6 +95,11 @@
   {
     label: "妫�娴嬫棩鏈�",
     prop: "checkTime",
+    width: 120
+  },
+  {
+    label: "閲囪喘璁㈠崟鍙�",
+    prop: "purchaseContractNo",
     width: 120
   },
   {
@@ -121,9 +124,19 @@
     prop: "unit",
   },
   {
-    label: "鏁伴噺",
+    label: "鎬绘暟閲�",
     prop: "quantity",
-    width: 120
+    width: 100
+  },
+  {
+    label: "鍚堟牸鏁伴噺",
+    prop: "qualifiedQuantity",
+    width: 100
+  },
+  {
+    label: "涓嶅悎鏍兼暟閲�",
+    prop: "unqualifiedQuantity",
+    width: 100
   },
   {
     label: "妫�娴嬪崟浣�",
@@ -131,27 +144,43 @@
     width: 120
   },
   {
-    label: "妫�娴嬬粨鏋�",
-    prop: "checkResult",
+    label: "鍚堟牸鐜�",
+    prop: "passRate",
+    width: 100,
     dataType: "tag",
+    formatData: (params) => {
+      if (params == null || params === '') return '鈥�';
+      const n = Number(params);
+      if (Number.isNaN(n)) return '鈥�';
+      return `${n.toFixed(2)}%`;
+    },
     formatType: (params) => {
-      if (params === '涓嶅悎鏍�') {
-        return "danger";
-      } else if (params === '鍚堟牸') {
-        return "success";
-      } else {
-        return null;
-      }
+      if (params == null || params === '') return 'info';
+      const n = Number(params);
+      if (Number.isNaN(n)) return 'info';
+      if (n === 100) return 'success';
+      if (n >= 75) return 'primary';
+      if (n >= 50) return 'warning';
+      if (n >= 25) return 'danger';
+      return 'danger';
     },
   },
   {
     label: "鎻愪氦鐘舵��",
     prop: "inspectState",
+    dataType: "tag",
     formatData: (params) => {
       if (params) {
         return "宸叉彁浜�";
       } else {
         return "鏈彁浜�";
+      }
+    },
+    formatType: (params) => {
+      if (params) {
+        return "success";
+      } else {
+        return "info";
       }
     },
   },
@@ -160,7 +189,7 @@
     label: "鎿嶄綔",
     align: "center",
     fixed: "right",
-    width: 250,
+    width: 280,
     operation: [
       {
         name: "缂栬緫",
@@ -168,9 +197,22 @@
         clickFun: (row) => {
           openForm("edit", row);
         },
-        disabled: (row) => {
-          return row.inspectState;
-        }
+				disabled: (row) => {
+					// 宸叉彁浜ゅ垯绂佺敤
+					if (row.inspectState == 1) return true;
+					// 濡傛灉妫�楠屽憳鏈夊�硷紝鍙湁褰撳墠鐧诲綍鐢ㄦ埛鑳界紪杈�
+					if (row.checkName) {
+						return row.checkName !== userStore.nickName;
+					}
+					return false;
+				}
+      },
+      {
+        name: "鏌ョ湅",
+        type: "text",
+        clickFun: (row) => {
+          openForm("view", row);
+        },
       },
       {
         name: "闄勪欢",
@@ -185,6 +227,16 @@
         clickFun: (row) => {
           submit(row.id);
         },
+        loading: (row) => submitLoadingId.value === row.id,
+				disabled: (row) => {
+					// 宸叉彁浜ゅ垯绂佺敤
+					if (row.inspectState == 1) return true;
+					// 濡傛灉妫�楠屽憳鏈夊�硷紝鍙湁褰撳墠鐧诲綍鐢ㄦ埛鑳芥彁浜�
+					if (row.checkName) {
+						return row.checkName !== userStore.nickName;
+					}
+					return false;
+				}
       },
       {
         name: "鍒嗛厤妫�楠屽憳",
@@ -196,9 +248,9 @@
             proxy.$modal.msgError("妫�楠屽憳宸插瓨鍦�");
           }
         },
-        disabled: (row) => {
-          return row.inspectState;
-        }
+				disabled: (row) => {
+					return row.inspectState == 1 || row.checkName;
+				}
       },
       {
         name: "涓嬭浇",
@@ -206,6 +258,7 @@
         clickFun: (row) => {
           downLoadFile(row);
         },
+        loading: (row) => downloadLoadingId.value === row.id,
       },
     ],
   },
@@ -213,6 +266,8 @@
 const tableData = ref([]);
 const selectedRows = ref([]);
 const tableLoading = ref(false);
+const submitLoadingId = ref(null);
+const downloadLoadingId = ref(null);
 const userList = ref([]);
 const dialogFormVisible = ref(false);
 const form = ref({
@@ -228,6 +283,7 @@
 const filesDia = ref()
 const inspectionFormDia = ref()
 const {proxy} = getCurrentInstance()
+const userStore = useUserStore()
 const changeDaterange = (value) => {
   searchForm.value.entryDateStart = undefined;
   searchForm.value.entryDateEnd = undefined;
@@ -269,12 +325,6 @@
 const openForm = (type, row) => {
   nextTick(() => {
     formDia.value?.openDialog(type, row)
-  })
-};
-// 鎵撳紑鏂板妫�楠屽脊妗�
-const openInspectionForm = (type, row) => {
-  nextTick(() => {
-    inspectionFormDia.value?.openDialog(type, row)
   })
 };
 // 鎵撳紑闄勪欢寮规
@@ -323,12 +373,20 @@
       });
 };
 
-// 鎻愪环
+// 鎻愪氦
 const submit = async (id) => {
-  const res = await submitQualityInspect({id: id})
-  if (res.code === 200) {
-    proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
-    getList();
+  submitLoadingId.value = id;
+  try {
+    const res = await submitQualityInspect({ id });
+    if (res.code === 200) {
+      proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+      const row = tableData.value.find(item => item.id === id);
+      if (row) {
+        row.inspectState = 1;
+      }
+    }
+  } finally {
+    submitLoadingId.value = null;
   }
 }
 
@@ -359,8 +417,10 @@
   dialogFormVisible.value = true
 }
 
-const downLoadFile = (row) => {
-  downloadQualityInspect({ id: row.id }).then((blobData) => {
+const downLoadFile = async (row) => {
+  downloadLoadingId.value = row.id;
+  try {
+    const blobData = await downloadQualityInspect({ id: row.id });
     const blob = new Blob([blobData], {
       type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
     })
@@ -368,13 +428,15 @@
 
     const link = document.createElement('a')
     link.href = downloadUrl
-    link.download = '妫�楠屾姤鍛�.docx'
+    link.download = '鍘熸潗鏂欐楠屾姤鍛�.docx'
     document.body.appendChild(link)
     link.click()
 
     document.body.removeChild(link)
     window.URL.revokeObjectURL(downloadUrl)
-  })
+  } finally {
+    downloadLoadingId.value = null;
+  }
 };
 
 onMounted(() => {

--
Gitblit v1.9.3