From 286697603580246889b06f437e7a738cf7e87d8b Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 14 五月 2026 15:52:34 +0800
Subject: [PATCH] Merge branch 'dev_NEW_pro' of http://114.132.189.42:9002/r/product-inventory-management into dev_NEW_pro

---
 src/views/financialManagement/voucher/index.vue |  107 ++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 96 insertions(+), 11 deletions(-)

diff --git a/src/views/financialManagement/voucher/index.vue b/src/views/financialManagement/voucher/index.vue
index 03c0856..1aa6f69 100644
--- a/src/views/financialManagement/voucher/index.vue
+++ b/src/views/financialManagement/voucher/index.vue
@@ -32,13 +32,13 @@
     <div class="table_list">
       <div class="actions">
         <div>
-          <el-statistic title="鍊熸柟鍚堣" :value="totalDebit" precision="2" prefix="楼" />
-          <el-statistic title="璐锋柟鍚堣" :value="totalCredit" precision="2" prefix="楼" style="margin-left: 30px;" />
+          <el-statistic title="鍊熸柟鍚堣" :value="totalDebit" :precision="2" prefix="楼" />
+          <el-statistic title="璐锋柟鍚堣" :value="totalCredit" :precision="2" prefix="楼" style="margin-left: 30px;" />
         </div>
         <div>
           <el-button type="primary" @click="add" icon="Plus">鏂板鍑瘉</el-button>
-          <el-button @click="handleImport" icon="Upload">瀵煎叆</el-button>
-          <el-button @click="handleOut" icon="Download">瀵煎嚭</el-button>
+          <!-- <el-button @click="handleImport" icon="Upload">瀵煎叆</el-button> -->
+          <!-- <el-button @click="handleOut" icon="Download">瀵煎嚭</el-button> -->
         </div>
       </div>
       <PIMTable
@@ -84,6 +84,11 @@
               <span class="label">鍑瘉瀛楋細</span>
               <el-select v-model="form.voucherPrefix" :disabled="isViewMode" style="width: 70px;">
                 <el-option label="璁�" value="璁�" />
+                <el-option label="鐜�" value="鐜�" />
+                <el-option label="閾�" value="閾�" />
+                <el-option label="杞�" value="杞�" />
+                <el-option label="鏀�" value="鏀�" />
+                <el-option label="浠�" value="浠�" />
               </el-select>
               <el-input v-model="form.voucherNum" :disabled="isViewMode" style="width: 60px;" />
               <span class="label" style="margin-left: 5px;">鍙�</span>
@@ -96,7 +101,6 @@
               <span class="label">闄勪欢锛�</span>
               <el-input-number v-model="form.attachmentCount" :disabled="isViewMode" :min="0" :controls="false" style="width: 60px;" />
               <span class="label" style="margin-left: 5px;">寮�</span>
-              <el-button type="primary" link :disabled="isViewMode" style="margin-left: 10px;">涓婁紶鏂囦欢</el-button>
             </div>
           </div>
           <div class="voucher-table">
@@ -153,12 +157,12 @@
                       @change="(val) => handleSubjectChange(val, rowIndex)"
                       @focus="selectRow(rowIndex)"
                     />
-                    <div class="subject-name">{{ entry.subjectName }}</div>
+                    <!-- <div class="subject-name">{{ entry.subjectName }}</div> -->
                   </td>
                   <!-- 鍊熸柟11鍒� -->
                   <template v-if="editingCell.row === rowIndex && editingCell.type === 'debit'">
                     <td colspan="11" class="debit-input-cell">
-                      <el-input-number ref="amountInputRef" v-model="entry.debit" :disabled="isViewMode" :min="0" :precision="2" :controls="false" size="small" @blur="finishEdit" class="full-width-input" />
+                      <el-input-number ref="amountInputRef" v-model="entry.debit" :disabled="isViewMode" :min="0" :precision="2" :controls="false" :value-on-clear="undefined" size="small" @blur="finishEdit" class="full-width-input" />
                     </td>
                   </template>
                   <template v-else>
@@ -169,7 +173,7 @@
                   <!-- 璐锋柟11鍒� -->
                   <template v-if="editingCell.row === rowIndex && editingCell.type === 'credit'">
                     <td colspan="11" class="credit-input-cell">
-                      <el-input-number ref="amountInputRef" v-model="entry.credit" :disabled="isViewMode" :min="0" :precision="2" :controls="false" size="small" @blur="finishEdit" class="full-width-input" />
+                      <el-input-number ref="amountInputRef" v-model="entry.credit" :disabled="isViewMode" :min="0" :precision="2" :controls="false" :value-on-clear="undefined" size="small" @blur="finishEdit" class="full-width-input" />
                     </td>
                   </template>
                   <template v-else>
@@ -217,7 +221,36 @@
               </el-select>
             </div>
           </div>
+          <!-- 缂栬緫妯″紡锛氫娇鐢� AttachmentUploadFile 涓婁紶缁勪欢 -->
+          <div class="voucher-attachment-upload" v-if="!isViewMode">
+            <div class="attachment-label">闄勪欢涓婁紶锛�</div>
+            <AttachmentUploadFile
+              v-model:fileList="form.attachments"
+              :disabled="isViewMode"
+              :limit="10"
+              :fileSize="50"
+              buttonText="鐐瑰嚮涓婁紶闄勪欢"
+              @change="handleAttachmentChange"
+            />
+          </div>
         </el-form>
+        <!-- 鏌ョ湅妯″紡锛氬睍绀洪檮浠跺垪琛紙鏀惧湪 el-form 澶栭潰锛岄伩鍏嶈 disabled锛� -->
+        <div class="voucher-attachment-upload" v-if="isViewMode && form.attachments?.length">
+          <div class="attachment-label">闄勪欢鍒楄〃锛�</div>
+          <el-table :data="form.attachments" border class="attachment-table">
+            <el-table-column label="闄勪欢鍚嶇О" show-overflow-tooltip>
+              <template #default="scope">
+                {{ scope.row.originalFilename || scope.row.name || scope.row.fileName || '鏈懡鍚嶆枃浠�' }}
+              </template>
+            </el-table-column>
+            <el-table-column fixed="right" label="鎿嶄綔" width="150" align="center">
+              <template #default="scope">
+                <el-button link type="primary" size="small" @click="previewFile(scope.row)">棰勮</el-button>
+                <el-button link type="primary" size="small" @click="downloadFile(scope.row)">涓嬭浇</el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
       </div>
       <template #footer>
         <div>
@@ -226,6 +259,8 @@
         </div>
       </template>
     </FormDialog>
+    <!-- 鏂囦欢棰勮缁勪欢 -->
+    <FilePreview ref="filePreviewRef" />
   </div>
 </template>
 
@@ -233,6 +268,10 @@
 import { ref, reactive, onMounted, computed, nextTick } from "vue";
 import { ElMessage, ElMessageBox } from "element-plus";
 import FormDialog from "@/components/Dialog/FormDialog.vue";
+import AttachmentUploadFile from "@/components/AttachmentUpload/file/index.vue";
+import FileList from "@/components/Dialog/FileList.vue";
+import FilePreview from "@/components/filePreview/index.vue";
+import download from "@/plugins/download.js";
 import useUserStore from "@/store/modules/user";
 import { userListNoPageByTenantId } from "@/api/system/user";
 import { listAccountSubject } from "@/api/financialManagement/accountSubject";
@@ -284,6 +323,7 @@
 const isEdit = ref(false);
 const currentId = ref(null);
 const isViewMode = computed(() => dialogMode.value === "view");
+const filePreviewRef = ref(null);
 
 const fallbackSubjectTree = [
   { subjectCode: "1001", subjectName: "搴撳瓨鐜伴噾", balanceDirection: "鍊熸柟", children: [] },
@@ -326,8 +366,8 @@
   subjectName: "",
   balanceDirection: "",
   summary: "",
-  debit: 0,
-  credit: 0,
+  debit: undefined,
+  credit: undefined,
 });
 
 const createDefaultForm = () => ({
@@ -336,6 +376,7 @@
   voucherNum: "",
   voucherDate: "",
   attachmentCount: 0,
+  attachments: [],
   entries: [createEmptyEntry(), createEmptyEntry()],
   creator: getDefaultCreator(),
   remark: "",
@@ -490,6 +531,31 @@
   form.entries.push(createEmptyEntry());
 };
 
+const handleAttachmentChange = (fileList) => {
+  form.attachmentCount = fileList?.length || 0;
+};
+
+// 浣跨敤椤圭洰灏佽鐨� filePreview 缁勪欢棰勮鏂囦欢
+const previewFile = (row) => {
+  const url = row.previewURL || row.previewUrl || row.url;
+  if (url && filePreviewRef.value) {
+    filePreviewRef.value.open(url);
+  } else {
+    ElMessage.warning('鏂囦欢鍦板潃鏃犳晥锛屾棤娉曢瑙�');
+  }
+};
+
+// 浣跨敤椤圭洰灏佽鐨� download 鎻掍欢涓嬭浇鏂囦欢
+const downloadFile = (row) => {
+  const url = row.downloadURL || row.downloadUrl || row.url;
+  if (url) {
+    const filename = row.originalFilename || row.name || row.fileName || 'download';
+    download.byUrl(url, filename);
+  } else {
+    ElMessage.warning('鏂囦欢鍦板潃鏃犳晥锛屾棤娉曚笅杞�');
+  }
+};
+
 const selectRow = (index) => {
   selectedRowIndex.value = index;
 };
@@ -589,10 +655,13 @@
     const { data } = await getVoucherDetail(row.id);
     const detail = data || row;
     const parts = (detail.voucherNo || "").split("-");
-    Object.assign(form, createDefaultForm(), detail, {
+    const attachments = detail.storageBlobVOList || detail.storageBlobDTOs || detail.attachments || [];
+    Object.assign(form, createDefaultForm(), {
+      ...detail,
       voucherPrefix: parts[0] || "璁�",
       voucherNum: parts[1] || "",
       creator: detail.creator || getDefaultCreator(),
+      attachments,
       entries:
         detail.entries?.map(item => ({
           subjectCode: item.subjectCode || "",
@@ -696,6 +765,7 @@
         remark: form.remark,
         debit: totalDebitEntry.value,
         credit: totalCreditEntry.value,
+        storageBlobDTOs: form.attachments || [],
         entries: validEntries.map(entry => ({
           subjectCode: entry.subjectCode,
           subjectName: entry.subjectName,
@@ -801,6 +871,21 @@
   }
 }
 
+.voucher-attachment-upload {
+  margin-top: 15px;
+  padding: 0 10px;
+
+  .attachment-label {
+    font-size: 14px;
+    color: #606266;
+    margin-bottom: 10px;
+  }
+
+  .attachment-table {
+    border-radius: 4px;
+  }
+}
+
 .voucher-table {
   border: 1px solid #dcdfe6;
   border-right: none;

--
Gitblit v1.9.3