From 3ef6a3a2bac778e2a224d6e437305b9f71d3799c Mon Sep 17 00:00:00 2001 From: 曹睿 <360930172@qq.com> Date: 星期一, 07 七月 2025 15:30:23 +0800 Subject: [PATCH] feat: 【来票台账】添加附件上传 --- src/views/procurementManagement/procurementInvoiceLedger/index.vue | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 103 insertions(+), 14 deletions(-) diff --git a/src/views/procurementManagement/procurementInvoiceLedger/index.vue b/src/views/procurementManagement/procurementInvoiceLedger/index.vue index c0e11d6..bbbce7c 100644 --- a/src/views/procurementManagement/procurementInvoiceLedger/index.vue +++ b/src/views/procurementManagement/procurementInvoiceLedger/index.vue @@ -42,40 +42,64 @@ </el-form> <div class="table_list"> <PIMTable + rowKey="id" :column="columns" :tableLoading="loading" :tableData="dataList" :isSelection="true" + height="calc(100vh - 15em)" + :isShowSummary="true" + :summaryMethod="summarizeMainTable" :page="{ current: pagination.currentPage, size: pagination.pageSize, - total: pagination.total, + total: 0, }" - :handleSelectionChange="handleSelectionChange" - @pagination="onCurrentChange" + @selection-change="handleSelectionChange" + @pagination="changePage" > - <!-- <template #operation> - <el-button type="primary" text @click="handleEdit" size="small"> - 缂栬緫 - </el-button> - </template> --> + <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> </PIMTable> </div> + <Modal ref="modalRef" @uploadSuccess="uploadSuccess"></Modal> </div> </template> <script setup> import { ref, getCurrentInstance } from "vue"; import { usePaginationApi } from "@/hooks/usePaginationApi"; -import { Search } from "@element-plus/icons-vue"; -import { productRecordPage } from "@/api/procurementManagement/procurementInvoiceLedger.js"; +import { Files, Download, Search, Upload } from "@element-plus/icons-vue"; +import { + productRecordPage, + productUploadFile, +} from "@/api/procurementManagement/procurementInvoiceLedger.js"; import { onMounted } from "vue"; import { ElMessageBox } from "element-plus"; +import Modal from "./Modal/UploadModal.vue"; defineOptions({ name: "鏉ョエ鍙拌处", }); +const modalRef = ref(); const { proxy } = getCurrentInstance(); const multipleVal = ref([]); const { @@ -130,7 +154,7 @@ prop: "taxInclusiveTotalPrice", align: "center", formatData: (cell) => { - return parseFloat(cell).toFixed(2); + return cell ? parseFloat(cell).toFixed(2) : 0; }, }, { @@ -143,7 +167,7 @@ prop: "ticketsAmount", align: "center", formatData: (cell) => { - return parseFloat(cell).toFixed(2); + return cell ? parseFloat(cell).toFixed(2) : 0; }, }, { @@ -151,13 +175,21 @@ prop: "unTicketsPrice", align: "center", formatData: (cell) => { - return parseFloat(cell).toFixed(2); + return cell ? parseFloat(cell).toFixed(2) : 0; }, }, { label: "澧炲�肩◣", prop: "invoiceAmount", align: "center", + }, + { + label: "闄勪欢", + align: "center", + prop: "commonFiles", + dataType: "slot", + slot: "commonFilesRef", + width: 150, }, // { // fixed: "right", @@ -176,6 +208,23 @@ }), } ); + +// 涓昏〃鍚堣鏂规硶 +const summarizeMainTable = (param) => { + return proxy.summarizeTable( + param, + [ + "taxInclusiveTotalPrice", + "ticketsAmount", + "unTicketsPrice", + "invoiceAmount", + ], + { + ticketsNum: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁� + futureTickets: { noDecimal: true }, // 涓嶄繚鐣欏皬鏁� + } + ); +}; const handleSelectionChange = (val) => { multipleVal.value = val; @@ -196,7 +245,44 @@ }); }; -// const handleEdit = () => {}; +const handleFiles = (fileList) => { + fileList.forEach((e) => { + proxy.$download.name(e.url); + }); +}; + +const changePage = ({ page }) => { + pagination.currentPage = page; + onCurrentChange(page); +}; + +const handleCommand = (command, row) => { + switch (command) { + case "download": + handleFiles(row.commonFiles); + break; + case "upload": + console.log(row.commonFiles); + openModal(row.ticketRegistrationId); + break; + } +}; + +const openModal = (id) => { + modalRef.value.handleImport(id); +}; + +// 涓婁紶鎴愬姛鍚庡仛浠�涔� +const uploadSuccess = async (data) => { + const { code } = await productUploadFile({ + ticketRegistrationId: data.id, + tempFileIds: data.tempFileIds, + }); + if (code === 200) { + proxy.$modal.msgSuccess("鎻愪氦鎴愬姛"); + getTableData(); + } +}; onMounted(() => { getTableData(); @@ -207,4 +293,7 @@ .table_list { margin-top: unset; } +.tagBox { + margin-top: 4px; +} </style> -- Gitblit v1.9.3