From 8fb21c6343dcb703fb504fac6d5b2a0b7a584c36 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期六, 08 八月 2026 11:05:24 +0800
Subject: [PATCH] fix: 添加loading

---
 src/views/qualityManagement/rawMaterialInspection/components/formDia.vue |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue b/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
index 78ad910..7c5c0d7 100644
--- a/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
+++ b/src/views/qualityManagement/rawMaterialInspection/components/formDia.vue
@@ -14,6 +14,7 @@
                   v-model="form.supplier"
                   placeholder="璇烽�夋嫨"
                   clearable
+                  :disabled="supplierQuantityDisabled"
               >
                 <el-option
                     v-for="item in supplierList"
@@ -77,7 +78,7 @@
           <el-col :span="12">
             <el-form-item label="鏁伴噺锛�" prop="quantity">
               <el-input-number :step="0.01" :min="0" style="width: 100%" v-model="form.quantity" placeholder="璇疯緭鍏�"
-                               clearable :precision="2"/>
+                               clearable :precision="2" :disabled="supplierQuantityDisabled"/>
             </el-form-item>
           </el-col>
         </el-row>
@@ -135,7 +136,7 @@
       </PIMTable>
       <template #footer>
         <div class="dialog-footer">
-          <el-button type="primary" @click="submitForm">纭</el-button>
+          <el-button type="primary" :loading="submitting" @click="submitForm">纭</el-button>
           <el-button @click="closeDia">鍙栨秷</el-button>
         </div>
       </template>
@@ -144,7 +145,7 @@
 </template>
 
 <script setup>
-import {ref, reactive, toRefs, getCurrentInstance, nextTick} from "vue";
+import {ref, reactive, toRefs, computed, getCurrentInstance, nextTick} from "vue";
 import {getOptions} from "@/api/procurementManagement/procurementLedger.js";
 import {modelList, productTreeList} from "@/api/basicData/product.js";
 import {qualityInspectAdd, qualityInspectUpdate} from "@/api/qualityManagement/rawMaterialInspection.js";
@@ -156,6 +157,7 @@
 const emit = defineEmits(['close'])
 
 const dialogFormVisible = ref(false);
+const submitting = ref(false);
 const operationType = ref('')
 const data = reactive({
   form: {
@@ -219,6 +221,12 @@
 const testStandardOptions = ref([]); // 鎸囨爣閫夋嫨涓嬫媺妗嗘暟鎹�
 const modelOptions = ref([]);
 const userList = ref([]); // 妫�楠屽憳涓嬫媺鍒楄〃
+
+// 缂栬緫鏃讹細productMainId 鎴� purchaseLedgerId 浠讳竴鏈夊�煎垯渚涘簲鍟嗐�佹暟閲忕疆鐏�
+const supplierQuantityDisabled = computed(() => {
+  const v = form.value || {};
+  return !!(v.productMainId != null || v.purchaseLedgerId != null);
+});
 
 // 鎵撳紑寮规
 const openDialog = async (type, row) => {
@@ -375,6 +383,9 @@
 
 // 鎻愪氦浜у搧琛ㄥ崟
 const submitForm = () => {
+  if (submitting.value) {
+    return;
+  }
   proxy.$refs.formRef.validate(valid => {
     if (valid) {
       form.value.inspectType = 0
@@ -384,15 +395,20 @@
 				})
 			}
       const data = {...form.value, qualityInspectParams: tableData.value}
+      submitting.value = true;
       if (operationType.value === "add") {
         qualityInspectAdd(data).then(res => {
           proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
           closeDia();
+        }).catch(() => {}).finally(() => {
+          submitting.value = false;
         })
       } else {
         qualityInspectUpdate(data).then(res => {
           proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
           closeDia();
+        }).catch(() => {}).finally(() => {
+          submitting.value = false;
         })
       }
     }

--
Gitblit v1.9.3