From 474c2a6516139ccbafecd5fc3d139ee9104ecfd5 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 31 三月 2026 17:28:21 +0800
Subject: [PATCH] 军泰伟业app 1.销售台账、采购台账选择产品逻辑修改 2.新增生产订单时将产品那边的图纸带过来 3.生产订单增加退料功能

---
 src/views/basicData/product/index.vue |   51 +++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/src/views/basicData/product/index.vue b/src/views/basicData/product/index.vue
index 62550ae..b887d9d 100644
--- a/src/views/basicData/product/index.vue
+++ b/src/views/basicData/product/index.vue
@@ -145,7 +145,7 @@
             :on-success="handleDrawingUploadSuccess"
             :on-remove="handleDrawingRemove"
             :before-upload="handleDrawingBeforeUpload"
-            :limit="1"
+            :limit="5"
             accept=".pdf,.jpg,.jpeg,.png,.dwg"
             list-type="picture-card"
           >
@@ -256,6 +256,11 @@
   {
     label: "鍗曚綅",
     prop: "unit",
+    minWidth: 100,
+  },
+  {
+    label: "宸ヨ壓璺嚎",
+    prop: "routeName",
     minWidth: 100,
   },
   {
@@ -385,7 +390,14 @@
     modelForm.value = { ...data };
     modelForm.value.tempFileIds = data.tempFileIds || [];
     modelForm.value.salesLedgerFiles = data.salesLedgerFiles || [];
-    if (data.drawingFile) {
+    // 澶勭悊鍥剧焊鏂囦欢鍙嶆樉
+    if (data.salesLedgerFiles && data.salesLedgerFiles.length > 0) {
+      drawingFileList.value = data.salesLedgerFiles.map(file => ({
+        id: file.id,  // 甯︿笂id鐢ㄤ簬鍒犻櫎鏃惰皟鐢ㄦ帴鍙�
+        name: file.name,
+        url: file.url
+      }));
+    } else if (data.drawingFile) {
       drawingFileList.value = [{
         name: data.drawingFile.split('/').pop(),
         url: data.drawingFile
@@ -397,7 +409,13 @@
 const submitModelForm = () => {
   modelFormRef.value.validate((valid) => {
     if (valid) {
-      addOrEditProductModel(modelForm.value).then((res) => {
+      // 鏋勫缓鎻愪氦鏁版嵁锛岀‘淇� routeId 涓虹┖鏃朵紶 null锛屽悓鏃舵竻绌� routeName
+      const submitData = {
+        ...modelForm.value,
+        routeId: modelForm.value.routeId || 0,
+        routeName: modelForm.value.routeId ? modelForm.value.routeName : null
+      };
+      addOrEditProductModel(submitData).then((res) => {
         proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
         closeModelDia();
         getModelList();
@@ -515,13 +533,14 @@
   console.log('涓婁紶鎴愬姛鍝嶅簲', response);
   console.log('response.data', response.data);
   if (response.code === 200) {
-    modelForm.value.tempFileIds = [response.data?.tempId];
-    modelForm.value.salesLedgerFiles = [{
+    // 鏀寔澶氭枃浠讹紝杩藉姞鍒版暟缁�
+    modelForm.value.tempFileIds.push(response.data?.tempId);
+    modelForm.value.salesLedgerFiles.push({
       tempId: response.data?.tempId,
       originalName: response.data?.originalName || file.name,
       tempPath: response.data?.tempPath,
       type: response.data?.type || 13
-    }];
+    });
     proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
   } else {
     proxy.$modal.msgError(response.msg || "涓婁紶澶辫触");
@@ -529,8 +548,24 @@
 };
 
 const handleDrawingRemove = (file) => {
-  modelForm.value.tempFileIds = [];
-  modelForm.value.salesLedgerFiles = [];
+  // 濡傛灉鏄紪杈戞ā寮忎笅宸插瓨鍦ㄧ殑鏂囦欢锛堝甫鏈塱d锛夛紝璋冪敤鍒犻櫎鎺ュ彛
+  if (file.id) {
+    delLedgerFile({ id: file.id }).then(res => {
+      if (res.code === 200) {
+        proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+      }
+    }).catch(err => {
+      console.error("鍒犻櫎鏂囦欢澶辫触锛�", err);
+    });
+  }
+  // 浠庢暟缁勪腑绉婚櫎瀵瑰簲鐨勬枃浠�
+  const index = modelForm.value.salesLedgerFiles.findIndex(item => 
+    item.tempId === file.response?.data?.tempId || item.tempId === file.tempId
+  );
+  if (index > -1) {
+    modelForm.value.tempFileIds.splice(index, 1);
+    modelForm.value.salesLedgerFiles.splice(index, 1);
+  }
 };
 
 onMounted(() => {

--
Gitblit v1.9.3