From b46d3fcc37e5eb76e77e5b7f1c0e7383af237d30 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 30 一月 2026 14:09:01 +0800
Subject: [PATCH] Merge branch 'dev_New' of http://114.132.189.42:9002/r/product-inventory-management into dev_New
---
src/views/procurementManagement/procurementInvoiceLedger/index.vue | 307 +++++++++++++++++++++++++++++++++++---------------
1 files changed, 214 insertions(+), 93 deletions(-)
diff --git a/src/views/procurementManagement/procurementInvoiceLedger/index.vue b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
index 7afd3d1..00ae65a 100644
--- a/src/views/procurementManagement/procurementInvoiceLedger/index.vue
+++ b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
@@ -47,49 +47,52 @@
:tableLoading="loading"
:tableData="dataList"
:isSelection="true"
- height="calc(100vh - 15em)"
+ height="calc(100vh - 19.5em)"
:isShowSummary="true"
:summaryMethod="summarizeMainTable"
:page="{
current: pagination.currentPage,
size: pagination.pageSize,
- total: 0,
+ total: pagination.total,
}"
@selection-change="handleSelectionChange"
@pagination="changePage"
>
- <template #commonFilesRef="{ row }">
- <el-dropdown @command="(command) => handleCommand(command, row)">
- <el-button link :icon="Files" type="danger"> 闄勪欢 </el-button>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item
- v-if="row.commonFiles.length !== 0"
- :icon="Download"
- command="download"
- >
- 涓嬭浇
- </el-dropdown-item>
- <el-dropdown-item :icon="Upload" command="upload">
- 涓婁紶
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </template>
<template #operation="{ row }">
<el-button
type="primary"
- text
- :icon="EditPen"
- @click="openEdit(row.id)"
+ link
+ @click="openEdit(row)"
>
缂栬緫
+ </el-button>
+ <el-button
+ type="primary"
+ link
+ @click="downLoadFile(row)"
+ >
+ 闄勪欢
+ </el-button>
+ <el-button
+ type="primary"
+ link
+ @click="handleDelete(row)"
+ >
+ 鍒犻櫎
</el-button>
</template>
</PIMTable>
</div>
- <UploadModal ref="modalRef" @uploadSuccess="uploadSuccess"></UploadModal>
+ <FileListDialog
+ ref="fileListRef"
+ v-model="fileListDialogVisible"
+ title="闄勪欢鍒楄〃"
+ :showUploadButton="true"
+ :showDeleteButton="true"
+ :deleteMethod="handleDeleteFile"
+ :uploadMethod="handleFileUpload"
+ :rulesRegulationsManagementId="currentRowId"
+ />
<EditModal ref="editmodalRef" @success="getTableData"></EditModal>
</div>
</template>
@@ -98,27 +101,30 @@
import { ref, getCurrentInstance } from "vue";
import { usePaginationApi } from "@/hooks/usePaginationApi";
import {
- Files,
- Download,
- Search,
- Upload,
- EditPen,
+ Search,
} from "@element-plus/icons-vue";
import {
- productRecordPage,
- productUploadFile,
+ delRegistration,
+ productRecordPage,
+ delCommonFile,
} from "@/api/procurementManagement/procurementInvoiceLedger.js";
+import request from "@/utils/request";
+import { getToken } from "@/utils/auth";
import { onMounted } from "vue";
import { ElMessageBox } from "element-plus";
-import UploadModal from "./Modal/UploadModal.vue";
import EditModal from "./Modal/EditModal.vue";
+import FileListDialog from '@/components/Dialog/FileListDialog.vue';
+import useUserStore from "@/store/modules/user.js";
+const userStore = useUserStore();
defineOptions({
name: "鏉ョエ鍙拌处",
});
-const modalRef = ref();
const editmodalRef = ref();
+const fileListRef = ref(null);
+const fileListDialogVisible = ref(false);
+const currentRowId = ref(null); // 褰撳墠鏌ョ湅闄勪欢鐨勮ID
const { proxy } = getCurrentInstance();
const multipleVal = ref([]);
@@ -142,45 +148,42 @@
{
label: "閲囪喘鍚堝悓鍙�",
prop: "purchaseContractNumber",
- align: "center",
width: 150,
},
{
label: "閿�鍞悎鍚屽彿",
prop: "salesContractNo",
- align: "center",
width: 150,
},
{
- label: "瀹㈡埛鍚嶇О",
- prop: "customerName",
- align: "center",
- width: 150,
+ label: "椤圭洰鍚嶇О",
+ prop: "projectName",
+ width: 240,
},
{
label: "渚涘簲鍟嗗悕绉�",
prop: "supplierName",
- align: "center",
width: 240,
+ },
+ {
+ label: "浜у搧澶х被",
+ prop: "productCategory",
+ width: 150,
},
{
label: "瑙勬牸鍨嬪彿",
prop: "specificationModel",
- align: "center",
width: 150,
},
{
label: "鍙戠エ鍙�",
prop: "invoiceNumber",
- align: "center",
-
width: 200,
},
{
label: "鍚堝悓閲戦(鍏�)",
prop: "taxInclusiveTotalPrice",
- align: "center",
- width: 120,
+ width: 200,
formatData: (cell) => {
return cell ? parseFloat(cell).toFixed(2) : 0;
},
@@ -188,14 +191,12 @@
{
label: "寮�绁ㄦ棩鏈�",
prop: "createdAt",
- align: "center",
- width: 100,
+ width: 110,
},
{
label: "寮�绁ㄩ噾棰�",
prop: "ticketsAmount",
- align: "center",
- width: 100,
+ width: 200,
formatData: (cell) => {
return cell ? parseFloat(cell).toFixed(2) : 0;
},
@@ -203,8 +204,7 @@
{
label: "涓嶅惈绋庨噾棰�",
prop: "unTicketsPrice",
- align: "center",
- width: 100,
+ width: 200,
formatData: (cell) => {
return cell ? parseFloat(cell).toFixed(2) : 0;
},
@@ -212,20 +212,16 @@
{
label: "澧炲�肩◣",
prop: "invoiceAmount",
- align: "center",
- width: 100,
+ width: 200,
},
{
- label: "闄勪欢",
- align: "center",
- prop: "commonFiles",
- dataType: "slot",
- slot: "commonFilesRef",
- width: 150,
+ label: "褰曞叆浜�",
+ prop: "issUer",
+ width: 200,
},
{
fixed: "right",
- width: 120,
+ width: 200,
label: "鎿嶄綔",
dataType: "slot",
slot: "operation",
@@ -277,49 +273,174 @@
});
};
-const handleFiles = (fileList) => {
- fileList.forEach((e) => {
- proxy.$download.name(e.url);
- });
-};
-
-const changePage = ({ page }) => {
+const changePage = ({ page, limit }) => {
pagination.currentPage = page;
+ pagination.pageSize = limit;
onCurrentChange(page);
};
-const handleCommand = (command, row) => {
- switch (command) {
- case "download":
- handleFiles(row.commonFiles);
- break;
- case "upload":
- console.log(row.commonFiles);
- openUoload(row.ticketRegistrationId);
- break;
+const downLoadFile = row => {
+ currentRowId.value = row.id;
+ if (fileListRef.value) {
+ fileListRef.value.open(row.commonFiles || []);
}
};
-const openUoload = (id) => {
- modalRef.value.handleImport(id);
-};
-
-const openEdit = (id) => {
- editmodalRef.value.open(id);
-};
-
-// 涓婁紶鎴愬姛鍚庡仛浠�涔�
-const uploadSuccess = async (data) => {
- const { code } = await productUploadFile({
- ticketRegistrationId: data.id,
- tempFileIds: data.tempFileIds,
+// 涓婁紶闄勪欢锛堣嚜瀹氫箟涓婁紶鏂规硶锛�
+const handleFileUpload = async () => {
+ if (!currentRowId.value) {
+ proxy.$modal.msgWarning("缂哄皯鐧昏ID锛屾棤娉曚繚瀛橀檮浠�");
+ return;
+ }
+
+ return new Promise((resolve) => {
+ // 鍒涘缓涓�涓殣钘忕殑鏂囦欢杈撳叆鍏冪礌
+ const input = document.createElement('input');
+ input.type = 'file';
+ input.style.display = 'none';
+ input.onchange = async (e) => {
+ const file = e.target.files[0];
+ if (!file) {
+ resolve(null);
+ return;
+ }
+
+ try {
+ // 浣跨敤 FormData 涓婁紶鏂囦欢
+ const formData = new FormData();
+ formData.append('file', file);
+ formData.append('type', '4'); // type 鍙傛暟锛岀敤鎴锋湭鎸囧畾鍏蜂綋鍊硷紝鍏堜紶绌哄瓧绗︿覆
+ formData.append('id', currentRowId.value); // 褰撳墠琛岀殑 id
+
+ const uploadRes = await request({
+ url: '/file/uploadByCommon',
+ method: 'post',
+ data: formData,
+ headers: {
+ 'Content-Type': 'multipart/form-data',
+ Authorization: `Bearer ${getToken()}`
+ }
+ });
+
+ if (uploadRes.code === 200) {
+ proxy.$modal.msgSuccess("闄勪欢涓婁紶鎴愬姛");
+
+ // 鍒锋柊鍒楄〃鑾峰彇鏈�鏂版暟鎹�
+ await new Promise((resolveRefresh) => {
+ // 璋冪敤 API 鑾峰彇鏈�鏂板垪琛ㄦ暟鎹�
+ productRecordPage({
+ ...filters,
+ current: pagination.currentPage,
+ size: pagination.pageSize
+ }).then(({ code, data }) => {
+ if (code === 200) {
+ // 鏇存柊鏁版嵁鍒楄〃
+ dataList.value = data.records;
+ pagination.total = data.total;
+
+ // 浠庡閮ㄦ暟鎹幏鍙� commonFiles
+ const currentRow = dataList.value.find(row => row.id === currentRowId.value);
+ if (currentRow && fileListRef.value) {
+ // 鍒锋柊闄勪欢鍒楄〃锛屼娇鐢ㄤ粠澶栭儴鑾峰彇鐨勬渶鏂� commonFiles
+ fileListRef.value.open(currentRow.commonFiles || []);
+ }
+ resolveRefresh();
+ } else {
+ resolveRefresh();
+ }
+ }).catch(() => {
+ resolveRefresh();
+ });
+ });
+
+ resolve({
+ name: uploadRes.data?.originalName || file.name,
+ url: uploadRes.data?.tempPath || uploadRes.data?.url,
+ id: uploadRes.data?.id
+ });
+ } else {
+ proxy.$modal.msgError(uploadRes.msg || "鏂囦欢涓婁紶澶辫触");
+ resolve(null);
+ }
+ } catch (error) {
+ console.error("闄勪欢涓婁紶澶辫触:", error);
+ proxy.$modal.msgError("闄勪欢涓婁紶澶辫触");
+ resolve(null);
+ } finally {
+ document.body.removeChild(input);
+ }
+ };
+
+ document.body.appendChild(input);
+ input.click();
});
- if (code === 200) {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- getTableData();
+};
+
+// 鍒犻櫎闄勪欢
+const handleDeleteFile = async (file) => {
+ try {
+ await delCommonFile([file.id]);
+ proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+
+ // 鍒锋柊鍒楄〃鑾峰彇鏈�鏂版暟鎹�
+ await new Promise((resolveRefresh) => {
+ // 璋冪敤 API 鑾峰彇鏈�鏂板垪琛ㄦ暟鎹�
+ productRecordPage({
+ ...filters,
+ current: pagination.currentPage,
+ size: pagination.pageSize
+ }).then(({ code, data }) => {
+ if (code === 200) {
+ // 鏇存柊鏁版嵁鍒楄〃
+ dataList.value = data.records;
+ pagination.total = data.total;
+
+ // 浠庡閮ㄦ暟鎹幏鍙� commonFiles
+ const currentRow = dataList.value.find(row => row.id === currentRowId.value);
+ if (currentRow && fileListRef.value) {
+ // 鍒锋柊闄勪欢鍒楄〃锛屼娇鐢ㄤ粠澶栭儴鑾峰彇鐨勬渶鏂� commonFiles
+ fileListRef.value.open(currentRow.commonFiles || []);
+ }
+ resolveRefresh();
+ } else {
+ resolveRefresh();
+ }
+ }).catch(() => {
+ resolveRefresh();
+ });
+ });
+
+ return true;
+ } catch (error) {
+ proxy.$modal.msgError("鍒犻櫎澶辫触");
+ return false;
}
};
+const openEdit = (row) => {
+ editmodalRef.value.open(row);
+};
+// 鍒犻櫎
+const handleDelete = (row) => {
+ let ids = [];
+ ids.push(row.id);
+ ElMessageBox.confirm("璇ュ紑绁ㄥ彴璐﹀皢琚垹闄�,鏄惁纭鍒犻櫎", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ loading.value = true;
+ delRegistration(ids).then((res) => {
+ getTableData();
+ });
+ loading.value = false;
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+
onMounted(() => {
getTableData();
});
--
Gitblit v1.9.3