From add86852b44af3dfb55c70c4d7b3ea9bb4fca227 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 15 四月 2026 17:41:20 +0800
Subject: [PATCH] 中兴实强 1.新增工艺路线的时候产品可以多选 2.绑定工艺路线时,可以删减工序并且每道工序可以多选报工人 3.报工列表展示报工人,非本订单报工人不可报工 其他

---
 src/views/productionManagement/processRoute/processRouteItem/index.vue |  299 ++++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 184 insertions(+), 115 deletions(-)

diff --git a/src/views/productionManagement/processRoute/processRouteItem/index.vue b/src/views/productionManagement/processRoute/processRouteItem/index.vue
index 18e21e8..213c6aa 100644
--- a/src/views/productionManagement/processRoute/processRouteItem/index.vue
+++ b/src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -82,10 +82,15 @@
       <el-table-column label="浜у搧鍚嶇О" prop="productName" min-width="160" />
       <el-table-column label="瑙勬牸鍚嶇О" prop="model" min-width="140" />
       <el-table-column label="鍗曚綅" prop="unit" width="100" />
+      <el-table-column label="鏄惁璐ㄦ" prop="isQuality" width="100">
+        <template #default="scope">
+          {{scope.row.isQuality ? "鏄�" : "鍚�"}}
+        </template>
+      </el-table-column>
       <el-table-column label="鎿嶄綔" align="center" fixed="right" width="150">
         <template #default="scope">
-          <el-button type="primary" link size="small" @click="handleEdit(scope.row)">缂栬緫</el-button>
-          <el-button type="danger" link size="small" @click="handleDelete(scope.row)">鍒犻櫎</el-button>
+          <el-button type="primary" link size="small" @click="handleEdit(scope.row)" :disabled="scope.row.isComplete">缂栬緫</el-button>
+          <el-button type="danger" link size="small" @click="handleDelete(scope.row)" :disabled="scope.row.isComplete">鍒犻櫎</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -130,14 +135,15 @@
                 {{ item.model }}
                 <!-- <span v-if="item.unit" class="product-unit">{{ item.unit }}</span> -->
               </div>
+              <el-tag type="primary" class="product-tag" v-if="item.isQuality">璐ㄦ</el-tag>
             </div>
             <div v-else class="product-info empty">鏆傛棤浜у搧淇℃伅</div>
           </div>
           
           <!-- 鎿嶄綔鎸夐挳 -->
           <div class="card-footer">
-            <el-button type="primary" link size="small" @click="handleEdit(item)">缂栬緫</el-button>
-            <el-button type="danger" link size="small" @click="handleDelete(item)">鍒犻櫎</el-button>
+            <el-button type="primary" link size="small" @click="handleEdit(item)" :disabled="item.isComplete">缂栬緫</el-button>
+            <el-button type="danger" link size="small" @click="handleDelete(item)" :disabled="item.isComplete">鍒犻櫎</el-button>
           </div>
         </div>
       </div>
@@ -173,27 +179,40 @@
           </el-select>
         </el-form-item>
 
-        <el-form-item label="浜у搧鍚嶇О" prop="productModelId">
+        <el-form-item label="浜у搧鍚嶇О" prop="selectedProducts">
           <el-button type="primary" @click="showProductSelectDialog = true">
-            {{ form.productName && form.model 
-              ? `${form.productName} - ${form.model}` 
-              : '閫夋嫨浜у搧' }}
+            {{ form.selectedProducts.length ? '閲嶆柊閫夋嫨浜у搧' : '閫夋嫨浜у搧' }}
           </el-button>
+          <div v-if="form.selectedProducts.length" class="selected-product-tags">
+            <el-tag
+              v-for="product in form.selectedProducts"
+              :key="product.id"
+              class="selected-product-tag"
+              type="info"
+              effect="plain"
+            >
+              {{ product.productName }} - {{ product.model }}
+            </el-tag>
+          </div>
         </el-form-item>
 
         <el-form-item label="鍗曚綅" prop="unit">
           <el-input 
               v-model="form.unit" 
-              :placeholder="form.productModelId ? '鏍规嵁閫夋嫨鐨勪骇鍝佽嚜鍔ㄥ甫鍑�' : '璇峰厛閫夋嫨浜у搧'" 
+              :placeholder="form.selectedProducts.length === 1 ? '鏍规嵁閫夋嫨鐨勪骇鍝佽嚜鍔ㄥ甫鍑�' : '澶氫釜浜у搧鏃朵笉灞曠ず鍗曚釜鍗曚綅'" 
               clearable 
               :disabled="true" 
           />
         </el-form-item>
+
+        <el-form-item label="鏄惁璐ㄦ" prop="isQuality">
+          <el-switch v-model="form.isQuality" :active-value="true" inactive-value="false"/>
+        </el-form-item>
       </el-form>
 
       <template #footer>
-        <el-button @click="closeDialog">鍙栨秷</el-button>
         <el-button type="primary" @click="handleSubmit" :loading="submitLoading">纭畾</el-button>
+        <el-button @click="closeDialog">鍙栨秷</el-button>
       </template>
     </el-dialog>
 
@@ -201,7 +220,6 @@
     <ProductSelectDialog
         v-model="showProductSelectDialog"
         @confirm="handleProductSelect"
-        single
     />
   </div>
 </template>
@@ -259,100 +277,128 @@
   routeId: routeId.value,
   processId: undefined,
   productModelId: undefined,
+  productModelIds: "",
+  selectedProducts: [],
   productName: "",
   model: "",
   unit: "",
+  isQuality: false,
 });
 
 const rules = {
   processId: [{ required: true, message: '璇烽�夋嫨宸ュ簭', trigger: 'change' }],
-  productModelId: [{ required: true, message: '璇烽�夋嫨浜у搧', trigger: 'change' }],
+  selectedProducts: [{
+    required: true,
+    validator: (_, value, callback) => {
+      if (Array.isArray(value) && value.length > 0) {
+        callback();
+        return;
+      }
+      callback(new Error('璇烽�夋嫨浜у搧'));
+    },
+    trigger: 'change',
+  }],
 };
 
-// 鏍规嵁宸ュ簭ID鑾峰彇宸ュ簭鍚嶇О
 const getProcessName = (processId) => {
   if (!processId) return '';
-  const process = processOptions.value.find(p => p.id === processId);
+  const process = processOptions.value.find((p) => p.id === processId);
   return process ? process.name : '';
 };
 
-// 鑾峰彇鍒楄〃
 const getList = () => {
   tableLoading.value = true;
   const listPromise =
-    pageType.value === "order"
+    pageType.value === 'order'
       ? findProductProcessRouteItemList({ orderId: orderId.value })
       : findProcessRouteItemList({ routeId: routeId.value });
 
   listPromise
-    .then(res => {
+    .then((res) => {
       tableData.value = res.data || [];
       tableLoading.value = false;
-      // 鍒楄〃鍔犺浇瀹屾垚鍚庡垵濮嬪寲鎷栨嫿鎺掑簭
       nextTick(() => {
         initSortable();
       });
     })
-    .catch(err => {
+    .catch((err) => {
       tableLoading.value = false;
-      console.error("鑾峰彇鍒楄〃澶辫触锛�", err);
-      proxy?.$modal?.msgError("鑾峰彇鍒楄〃澶辫触");
+      console.error('鑾峰彇鍒楄〃澶辫触:', err);
+      proxy?.$modal?.msgError('鑾峰彇鍒楄〃澶辫触');
     });
 };
 
-// 鑾峰彇宸ュ簭鍒楄〃
 const getProcessList = () => {
   processList({})
-    .then(res => {
+    .then((res) => {
       processOptions.value = res.data || [];
     })
-    .catch(err => {
-      console.error("鑾峰彇宸ュ簭澶辫触锛�", err);
+    .catch((err) => {
+      console.error('鑾峰彇宸ュ簭澶辫触:', err);
     });
 };
 
-// 鑾峰彇宸ヨ壓璺嚎璇︽儏锛堜粠璺敱鍙傛暟鑾峰彇锛�
 const getRouteInfo = () => {
   routeInfo.value = {
     processRouteCode: route.query.processRouteCode || '',
     productName: route.query.productName || '',
     model: route.query.model || '',
     bomNo: route.query.bomNo || '',
-    description: route.query.description || ''
+    description: route.query.description || '',
   };
 };
 
-// 鏂板
+const getEditSelectedProducts = (row) => {
+  const idList = String(row.productModelIds || row.productModelId || '')
+    .split(',')
+    .map((item) => item.trim())
+    .filter(Boolean);
+  const nameList = String(row.productName || '')
+    .split(',')
+    .map((item) => item.trim());
+  const modelList = String(row.model || '')
+    .split(',')
+    .map((item) => item.trim());
+
+  return idList.map((id, index) => ({
+    id: Number(id) || id,
+    productName: nameList[index] || row.productName || '',
+    model: modelList[index] || row.model || '',
+    unit: row.unit || '',
+  }));
+};
+
 const handleAdd = () => {
   operationType.value = 'add';
   resetForm();
   dialogVisible.value = true;
 };
 
-// 缂栬緫
 const handleEdit = (row) => {
   operationType.value = 'edit';
+  const selectedProducts = getEditSelectedProducts(row);
   form.value = {
     id: row.id,
     routeId: routeId.value,
     processId: row.processId,
     productModelId: row.productModelId,
-    productName: row.productName || "",
-    model: row.model || "",
-    unit: row.unit || "",
+    productModelIds: row.productModelIds || (row.productModelId ? String(row.productModelId) : ''),
+    selectedProducts,
+    productName: row.productName || '',
+    model: row.model || '',
+    unit: row.unit || '',
+    isQuality: row.isQuality,
   };
   dialogVisible.value = true;
 };
 
-// 鍒犻櫎
 const handleDelete = (row) => {
   ElMessageBox.confirm('纭鍒犻櫎璇ュ伐鑹鸿矾绾块」鐩紵', '鎻愮ず', {
     confirmButtonText: '纭',
     cancelButtonText: '鍙栨秷',
-    type: 'warning'
+    type: 'warning',
   })
     .then(() => {
-      // 鐢熶骇璁㈠崟涓嬩娇鐢� productProcessRoute 鐨勫垹闄ゆ帴鍙o紙璺敱鍚庢嫾鎺� id锛夛紝鍏跺畠鎯呭喌浣跨敤宸ヨ壓璺嚎椤圭洰鎵归噺鍒犻櫎鎺ュ彛
       const deletePromise =
         pageType.value === 'order'
           ? deleteRouteItem(row.id)
@@ -370,108 +416,115 @@
     .catch(() => {});
 };
 
-// 浜у搧閫夋嫨
 const handleProductSelect = (products) => {
   if (products && products.length > 0) {
-    const product = products[0];
-    form.value.productModelId = product.id;
-    form.value.productName = product.productName;
-    form.value.model = product.model;
-    form.value.unit = product.unit || "";
+    const firstProduct = products[0];
+    form.value.selectedProducts = products;
+    form.value.productModelIds = products.map((item) => item.id).join(',');
+    form.value.productModelId = products.length === 1 ? firstProduct.id : undefined;
+    form.value.productName = products.length === 1 ? firstProduct.productName : '';
+    form.value.model = products.length === 1 ? firstProduct.model : '';
+    form.value.unit = products.length === 1 ? (firstProduct.unit || '') : '';
     showProductSelectDialog.value = false;
-    // 瑙﹀彂琛ㄥ崟楠岃瘉
-    formRef.value?.validateField('productModelId');
+    formRef.value?.validateField('selectedProducts');
   }
 };
 
-// 鎻愪氦
 const handleSubmit = () => {
   formRef.value.validate((valid) => {
-    if (valid) {
-      submitLoading.value = true;
-      
-      if (operationType.value === 'add') {
-        // 鏂板锛氫紶鍗曚釜瀵硅薄锛屽寘鍚玠ragSort瀛楁
-        // dragSort = 褰撳墠鍒楄〃闀垮害 + 1锛岃〃绀烘柊澧炶褰曟帓鍦ㄦ渶鍚�
-        const dragSort = tableData.value.length + 1;
-        const isOrderPage = pageType.value === 'order';
-
-        const addPromise = isOrderPage
-          ? addRouteItem({
-              productOrderId: orderId.value,
-              productRouteId: routeId.value,
-              processId: form.value.processId,
-              productModelId: form.value.productModelId,
-              dragSort,
-            })
-          : addOrUpdateProcessRouteItem({
-              routeId: routeId.value,
-              processId: form.value.processId,
-              productModelId: form.value.productModelId,
-              dragSort,
-            });
-
-        addPromise
-          .then(() => {
-            proxy?.$modal?.msgSuccess('鏂板鎴愬姛');
-            closeDialog();
-            getList();
-          })
-          .catch(() => {
-            proxy?.$modal?.msgError('鏂板澶辫触');
-          })
-          .finally(() => {
-            submitLoading.value = false;
-          });
-      } else {
-        // 缂栬緫锛氱敓浜ц鍗曚笅浣跨敤 productProcessRoute/updateRouteItem锛屽叾瀹冩儏鍐典娇鐢ㄥ伐鑹鸿矾绾块」鐩洿鏂版帴鍙�
-        const isOrderPage = pageType.value === 'order';
-        
-        const updatePromise = isOrderPage
-          ? addOrUpdateProductProcessRouteItem({
-              id: form.value.id,
-              processId: form.value.processId,
-              productModelId: form.value.productModelId,
-            })
-          : addOrUpdateProcessRouteItem({
-              routeId: routeId.value,
-              processId: form.value.processId,
-              productModelId: form.value.productModelId,
-              id: form.value.id,
-            });
-
-        updatePromise
-          .then(() => {
-            proxy?.$modal?.msgSuccess('淇敼鎴愬姛');
-            closeDialog();
-            getList();
-          })
-          .catch(() => {
-            proxy?.$modal?.msgError('淇敼澶辫触');
-          })
-          .finally(() => {
-            submitLoading.value = false;
-          });
-      }
+    if (!valid) {
+      return;
     }
+
+    submitLoading.value = true;
+
+    if (operationType.value === 'add') {
+      const dragSort = tableData.value.length + 1;
+      const isOrderPage = pageType.value === 'order';
+
+      const addPromise = isOrderPage
+        ? addRouteItem({
+            productOrderId: orderId.value,
+            productRouteId: routeId.value,
+            processId: form.value.processId,
+            productModelId: form.value.productModelId,
+            productModelIds: form.value.productModelIds,
+            isQuality: form.value.isQuality,
+            dragSort,
+          })
+        : addOrUpdateProcessRouteItem({
+            routeId: routeId.value,
+            processId: form.value.processId,
+            productModelId: form.value.productModelId,
+            productModelIds: form.value.productModelIds,
+            isQuality: form.value.isQuality,
+            dragSort,
+          });
+
+      addPromise
+        .then(() => {
+          proxy?.$modal?.msgSuccess('鏂板鎴愬姛');
+          closeDialog();
+          getList();
+        })
+        .catch(() => {
+          proxy?.$modal?.msgError('鏂板澶辫触');
+        })
+        .finally(() => {
+          submitLoading.value = false;
+        });
+      return;
+    }
+
+    const isOrderPage = pageType.value === 'order';
+    const updatePromise = isOrderPage
+      ? addOrUpdateProductProcessRouteItem({
+          id: form.value.id,
+          processId: form.value.processId,
+          productModelId: form.value.productModelId,
+          productModelIds: form.value.productModelIds,
+          isQuality: form.value.isQuality,
+        })
+      : addOrUpdateProcessRouteItem({
+          routeId: routeId.value,
+          processId: form.value.processId,
+          productModelId: form.value.productModelId,
+          productModelIds: form.value.productModelIds,
+          id: form.value.id,
+          isQuality: form.value.isQuality,
+        });
+
+    updatePromise
+      .then(() => {
+        proxy?.$modal?.msgSuccess('淇敼鎴愬姛');
+        closeDialog();
+        getList();
+      })
+      .catch(() => {
+        proxy?.$modal?.msgError('淇敼澶辫触');
+      })
+      .finally(() => {
+        submitLoading.value = false;
+      });
   });
 };
 
-// 閲嶇疆琛ㄥ崟
 const resetForm = () => {
   form.value = {
     id: undefined,
     routeId: routeId.value,
     processId: undefined,
     productModelId: undefined,
-    productName: "",
-    model: "",
-    unit: "",
+    productModelIds: '',
+    selectedProducts: [],
+    productName: '',
+    model: '',
+    unit: '',
+    isQuality: false,
   };
   formRef.value?.resetFields();
 };
 
-// 鍏抽棴寮圭獥
 const closeDialog = () => {
   dialogVisible.value = false;
   resetForm();
@@ -733,6 +786,22 @@
   color: #409eff;
 }
 
+.product-tag {
+  margin: 10px 0;
+}
+
+.selected-product-tags {
+  display: flex;
+  flex-wrap: wrap;
+  gap: 8px;
+  margin-top: 10px;
+}
+
+.selected-product-tag {
+  max-width: 100%;
+}
+
+
 .card-footer {
   display: flex;
   justify-content: space-around;

--
Gitblit v1.9.3