From 644f9b827ac28d39f32c626712d5c574fe9acbf1 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 16 十二月 2025 17:23:01 +0800
Subject: [PATCH] 1.海川开心-入库管理-成品入库添加一个删除功能

---
 src/views/salesManagement/invoiceLedger/index.vue |   58 +++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/src/views/salesManagement/invoiceLedger/index.vue b/src/views/salesManagement/invoiceLedger/index.vue
index 3e82e85..814b36f 100644
--- a/src/views/salesManagement/invoiceLedger/index.vue
+++ b/src/views/salesManagement/invoiceLedger/index.vue
@@ -42,7 +42,7 @@
         <el-table-column label="褰曞叆浜�" prop="invoicePerson" show-overflow-tooltip />
         <el-table-column label="褰曞叆鏃ユ湡" prop="createTime" show-overflow-tooltip :formatter="formatDate" width="180" />
         <el-table-column label="寮�绁ㄦ棩鏈�" prop="invoiceDate" show-overflow-tooltip width="120" />
-        <el-table-column label="鍙戠エ" prop="invoiceFileName" width="120" align="center" show-overflow-tooltip fixed="right">
+        <!-- <el-table-column label="鍙戠エ" prop="invoiceFileName" width="120" align="center" show-overflow-tooltip fixed="right">
           <template #default="scope">
             <el-button v-if="scope.row.invoiceFileName" text bg type="primary"
               @click="handleFile(scope.row.commonFiles)">
@@ -52,10 +52,11 @@
               涓婁紶
             </el-button>
           </template>
-        </el-table-column>
+        </el-table-column> -->
         <el-table-column fixed="right" label="鎿嶄綔" width="150" align="center">
           <template #default="scope">
             <el-button link type="primary" size="small" @click="openForm(scope.row)">缂栬緫</el-button>
+            <el-button link type="primary" size="small" @click="downLoadFile(scope.row)">闄勪欢</el-button>
             <el-button link type="primary" size="small" @click="delInvoiceLedger(scope.row)">鍒犻櫎</el-button>
           </template>
         </el-table-column>
@@ -107,7 +108,7 @@
             <el-form-item label="闄勪欢鏉愭枡锛�" prop="remark">
               <el-upload v-model:file-list="fileList" :action="upload.url" multiple ref="fileUpload" auto-upload
                 :headers="upload.headers" accept=".pdf" :limit="10" :before-upload="handleBeforeUpload"
-                :on-error="handleUploadError" :on-success="handleUploadSuccess" :on-remove="handleRemove">
+                :on-error="handleUploadError" :on-success="handleUploadSuccess">
                 <el-button type="primary">涓婁紶</el-button>
                 <template #tip>
                   <!--                  鏂囦欢鏍煎紡鏀寔 doc锛宒ocx锛寈ls锛寈lsx锛宲pt锛宲ptx锛宲df锛宼xt锛寈ml锛宩pg锛宩peg锛宲ng锛実if锛宐mp锛宺ar锛寊ip锛�7z-->
@@ -148,6 +149,7 @@
         </div>
       </template>
     </el-dialog>
+    <FileList ref="fileListRef" />
   </div>
 </template>
 
@@ -163,10 +165,11 @@
   commitFile,
   registrationProductPage,
   delInvoiceLedgerByRegProductId,
-} from "../../../api/salesManagement/invoiceLedger.js";
+} from "@/api/salesManagement/invoiceLedger.js";
 import useUserStore from "@/store/modules/user.js";
 import useFormData from "@/hooks/useFormData";
 import dayjs from "dayjs";
+import FileList from "./fileList.vue";
 
 const { proxy } = getCurrentInstance();
 const tableData = ref([]);
@@ -275,6 +278,10 @@
   invoiceLedgerProductInfo({ id: row.id }).then((res) => {
     form.value = { ...res.data };
     fileList.value = res.data.fileList;
+    // 淇濆瓨ticketRegistrationId鍒拌〃鍗曟暟鎹腑
+    if (row.ticketRegistrationId) {
+      form.value.ticketRegistrationId = row.ticketRegistrationId;
+    }
     if (!form.value.invoicePerson) {
       form.value.invoicePerson = userStore.nickName;
       // 绉婚櫎褰曞叆鏃ユ湡榛樿鍊艰缃紝鍙鐞嗚寖鍥存棩鏈熷瓧娈�
@@ -292,7 +299,6 @@
 };
 // 涓婁紶鍓嶆牎妫�
 function handleBeforeUpload(file) {
-  console.log("file", file);
   // 鏍℃鏂囦欢澶у皬
   if (file.size > 1024 * 1024 * 10) {
     proxy.$modal.msgError("涓婁紶鏂囦欢澶у皬涓嶈兘瓒呰繃10MB!");
@@ -304,6 +310,7 @@
     proxy.$modal.msgError("鏂囦欢鏍煎紡涓嶅尮閰�");
     return false;
   }
+  console.log('handleBeforeUpload');
   proxy.$modal.loading("姝e湪涓婁紶鏂囦欢锛岃绋嶅��...");
   return true;
 }
@@ -315,20 +322,27 @@
 // 涓婁紶鎴愬姛鍥炶皟
 function handleUploadSuccess(res, file, uploadFiles) {
   proxy.$modal.closeLoading();
+  console.log('handleUploadSuccess');
   if (res.code === 200) {
-    proxy.$refs["fileUpload"].handleRemove(file);
-    fileList.value.push(res.data);
     proxy.$modal.msgSuccess("涓婁紶鎴愬姛");
+    // 灏嗕笂浼犳垚鍔熺殑鏂囦欢淇℃伅娣诲姞鍒癴ileList涓�
+    const fileInfo = {
+      name: file.name,
+      url: res.data.url || file.response?.data?.url || file.url,
+      response: file.response
+    };
+    // 妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鏂囦欢锛岄伩鍏嶉噸澶嶆坊鍔�
+    const existingFileIndex = fileList.value.findIndex(f => f.name === fileInfo.name);
+    if (existingFileIndex === -1) {
+      fileList.value.push(fileInfo);
+    } else {
+      fileList.value[existingFileIndex] = fileInfo;
+    }
+    // 纭繚琛ㄥ崟鏁版嵁涓殑fileList涔熸洿鏂�
+    form.value.fileList = fileList.value;
   } else {
     proxy.$modal.msgError(res.msg);
     proxy.$refs.fileUpload.handleRemove(file);
-  }
-}
-// 绉婚櫎鏂囦欢
-function handleRemove(file) {
-  let index = fileList.value.findIndex((item) => item.url === file.url);
-  if (index > -1) {
-    fileList.value.splice(index, 1);
   }
 }
 // 鎻愪氦琛ㄥ崟
@@ -362,13 +376,6 @@
     .catch(() => {
       proxy.$modal.msg("宸插彇娑�");
     });
-};
-
-// 鎵撳紑闄勪欢涓婁紶寮圭獥
-const handleDownload = (val) => {
-  fileList.value = [];
-  uploadModal.value = true;
-  currentId.value = val.id;
 };
 
 // 纭鏂囦欢涓婁紶
@@ -434,6 +441,15 @@
   getList();
 };
 
+//闄勪欢鐩稿叧
+const fileListRef = ref(null)
+//鏌ョ湅闄勪欢
+const downLoadFile = (row) => {
+	invoiceLedgerProductInfo({ id: row.id }).then((res) => {
+		fileListRef.value.open(res.data.fileList)
+	});
+}
+
 onMounted(() => {
   // 璁剧疆寮�绁ㄦ棩鏈熻寖鍥撮粯璁ゅ�间负褰撳ぉ
   const today = dayjs().format('YYYY-MM-DD');

--
Gitblit v1.9.3