From 07f9f8657d057a38792c3822acc9b08d83478967 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 07 五月 2026 14:23:10 +0800
Subject: [PATCH] 合并代码
---
src/views/financialManagement/revenueManagement/index.vue | 445 +++++++++++++++++++-----------------------------------
1 files changed, 158 insertions(+), 287 deletions(-)
diff --git a/src/views/financialManagement/revenueManagement/index.vue b/src/views/financialManagement/revenueManagement/index.vue
index 12abfe3..bcef5b6 100644
--- a/src/views/financialManagement/revenueManagement/index.vue
+++ b/src/views/financialManagement/revenueManagement/index.vue
@@ -3,22 +3,22 @@
<el-form :model="filters" :inline="true">
<el-form-item label="鏀跺叆鏃ユ湡:">
<el-date-picker v-model="filters.entryDate" value-format="YYYY-MM-DD" format="YYYY-MM-DD" type="daterange"
- placeholder="璇烽�夋嫨" clearable @change="changeDaterange" />
+ placeholder="璇烽�夋嫨" clearable @change="changeDaterange"/>
</el-form-item>
<el-form-item label="鏀舵鏂瑰紡:">
<el-select
- v-model="filters.incomeMethod"
- placeholder="璇烽�夋嫨"
- clearable
- style="width: 200px;"
- >
- <el-option
- v-for="item in payment_methods"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- />
- </el-select>
+ v-model="filters.incomeMethodLabel"
+ placeholder="璇烽�夋嫨"
+ clearable
+ style="width: 200px;"
+ >
+ <el-option
+ v-for="item in incomeMethodOptions"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="getTableData">鎼滅储</el-button>
@@ -29,46 +29,51 @@
<div class="actions">
<div></div>
<div>
- <el-button type="primary" @click="add" icon="Plus"> 鏂板 </el-button>
+ <el-button type="primary" @click="add" icon="Plus"> 鏂板</el-button>
<el-button @click="handleOut" icon="download">瀵煎嚭</el-button>
<el-button
- type="danger"
- icon="Delete"
- :disabled="multipleList.length <= 0 || hasBusinessIdInSelection"
- @click="handleBatchDelete"
+ type="danger"
+ icon="Delete"
+ :disabled="multipleList.length <= 0 || hasBusinessIdInSelection"
+ @click="handleBatchDelete"
>
鎵归噺鍒犻櫎
</el-button>
</div>
</div>
<PIMTable
- rowKey="id"
- isSelection
- :column="columns"
- :tableData="dataList"
- :page="{
+ rowKey="id"
+ isSelection
+ :column="columns"
+ :tableData="dataList"
+ :page="{
current: pagination.currentPage,
size: pagination.pageSize,
total: pagination.total,
}"
- :isShowSummary="true"
- :summaryMethod="summarizeMainTable"
- @selection-change="handleSelectionChange"
- @pagination="changePage"
+ :isShowSummary="true"
+ :summaryMethod="summarizeMainTable"
+ @selection-change="handleSelectionChange"
+ @pagination="changePage"
>
+ <template #incomeMethodSlot="{ row }">
+ <el-tag>
+ {{ getIncomeMethodLabel(row) }}
+ </el-tag>
+ </template>
<template #operation="{ row }">
- <el-button
- type="primary"
- link
- :disabled="!!row.businessId"
- @click="edit(row.id)"
+ <el-button
+ type="primary"
+ link
+ :disabled="!!row.businessId"
+ @click="edit(row.id)"
>
缂栬緫
</el-button>
<el-button
- type="primary"
- link
- @click="openFilesFormDia(row)"
+ type="primary"
+ link
+ @click="openFilesFormDia(row)"
>
闄勪欢
</el-button>
@@ -76,27 +81,16 @@
</PIMTable>
</div>
<Modal ref="modalRef" @success="getTableData"></Modal>
- <FileListDialog
- ref="fileListRef"
- v-model="fileListDialogVisible"
- :show-upload-button="true"
- :show-delete-button="true"
- :upload-method="handleUpload"
- :delete-method="handleFileDelete"
- />
+ <FileListDialog v-if="fileListDialogVisible" :record-id="currentRecordId" record-type="account_income" v-model:visible="fileListDialogVisible"/>
</div>
</template>
<script setup>
-import { usePaginationApi } from "@/hooks/usePaginationApi";
-import { listPage, delAccountIncome, fileListPage, fileAdd, fileDel } from "@/api/financialManagement/revenueManagement";
-import { onMounted, getCurrentInstance, ref, computed } from "vue";
-import Modal from "./Modal.vue";
-import { ElMessageBox, ElMessage } from "element-plus";
+import {usePaginationApi} from "@/hooks/usePaginationApi";
+import {listPage, delAccountIncome} from "@/api/financialManagement/revenueManagement";
+import {onMounted, getCurrentInstance, ref, computed} from "vue";
+import {ElMessageBox, ElMessage} from "element-plus";
import dayjs from "dayjs";
-import FileListDialog from "@/components/Dialog/FileListDialog.vue";
-import request from "@/utils/request";
-import { getToken } from "@/utils/auth";
defineOptions({
name: "鏀跺叆绠$悊",
@@ -104,14 +98,27 @@
// 琛ㄦ牸澶氶�夋閫変腑椤�
const multipleList = ref([]);
-const { proxy } = getCurrentInstance();
+const {proxy} = getCurrentInstance();
const modalRef = ref();
-const { payment_methods } = proxy.useDict("payment_methods");
-const { income_types } = proxy.useDict("income_types");
+const {payment_methods} = proxy.useDict("payment_methods");
+const {receipt_payment_type} = proxy.useDict("receipt_payment_type");
+const {income_types} = proxy.useDict("income_types");
const fileListRef = ref(null);
const fileListDialogVisible = ref(false);
-const currentFileRow = ref(null);
-const accountType = ref('鏀跺叆');
+const currentRecordId = ref(0);
+
+const incomeMethodOptions = computed(() => {
+ const merged = [...(payment_methods.value || []), ...(receipt_payment_type.value || [])];
+ const uniqueMap = new Map();
+ merged.forEach((item) => {
+ const label = item?.label;
+ if (!label) return;
+ if (!uniqueMap.has(label)) {
+ uniqueMap.set(label, {label, value: label});
+ }
+ });
+ return Array.from(uniqueMap.values());
+});
const {
filters,
@@ -122,91 +129,99 @@
resetFilters,
onCurrentChange,
} = usePaginationApi(
- listPage,
- {
- incomeMethod: undefined,
- entryDate: undefined,
- },
- [
+ listPage,
{
- label: "鏀跺叆鏃ユ湡",
- prop: "incomeDate",
+ incomeMethodLabel: undefined,
+ entryDate: undefined,
},
- {
- label: "鏀跺叆绫诲瀷",
- prop: "incomeType",
- dataType: "tag",
- formatData: (params) => {
- if (income_types.value.find((m) => m.value == params)) {
- return income_types.value.find((m) => m.value == params).label;
- } else {
- return null
- }
+ [
+ {
+ label: "鏀跺叆鏃ユ湡",
+ prop: "incomeDate",
},
- },
- {
- label: "瀹㈡埛鍚嶇О",
- prop: "customerName",
- width: '200'
-
- },
- {
- label: "鏀跺叆閲戦",
- prop: "incomeMoney",
-
- },
- {
- label: "鏀跺叆鎻忚堪",
- prop: "incomeDescribed",
-
- },
- {
- label: "鏀舵鏂瑰紡",
- prop: "incomeMethod",
- align: 'center',
- width: '100',
- dataType: "tag",
- formatData: (params) => {
- if (payment_methods.value.find((m) => m.value == params)) {
- return payment_methods.value.find((m) => m.value == params).label;
- } else {
- return null
- }
+ {
+ label: "鏀跺叆绫诲瀷",
+ prop: "incomeType",
+ dataType: "tag",
+ formatData: (params) => {
+ if (income_types.value.find((m) => m.value == params)) {
+ return income_types.value.find((m) => m.value == params).label;
+ } else {
+ return null
+ }
+ },
},
- },
- {
- label: "鍙戠エ鍙风爜",
- prop: "invoiceNumber",
+ {
+ label: "瀹㈡埛鍚嶇О",
+ prop: "customerName",
+ width: '200'
- },
- {
- label: "澶囨敞",
- prop: "note",
+ },
+ {
+ label: "鏀跺叆閲戦",
+ prop: "incomeMoney",
- },
- {
- label: "褰曞叆浜�",
- prop: "inputUser",
- },
- {
- label: "褰曞叆鏃ユ湡",
- prop: "inputTime",
+ },
+ {
+ label: "鏀跺叆鎻忚堪",
+ prop: "incomeDescribed",
- },
+ },
+ {
+ label: "鏀舵鏂瑰紡",
+ prop: "incomeMethodLabel",
+ align: 'center',
+ width: '100',
+ dataType: "slot",
+ slot: "incomeMethodSlot",
+ },
+ {
+ label: "鍙戠エ鍙风爜",
+ prop: "invoiceNumber",
+
+ },
+ {
+ label: "澶囨敞",
+ prop: "note",
+
+ },
+ {
+ label: "褰曞叆浜�",
+ prop: "inputUser",
+ },
+ {
+ label: "褰曞叆鏃ユ湡",
+ prop: "inputTime",
+
+ },
+ {
+ fixed: "right",
+ label: "鎿嶄綔",
+ dataType: "slot",
+ slot: "operation",
+ align: "center",
+ width: "160px",
+ },
+ ],
+ undefined,
{
- fixed: "right",
- label: "鎿嶄綔",
- dataType: "slot",
- slot: "operation",
- align: "center",
- width: "160px",
- },
- ]
+ incomeMethodLabel: (value) => ({
+ incomeMethodLabel: value || undefined,
+ }),
+ }
);
// 琛ㄦ牸鍚堣锛氭敹鍏ラ噾棰�
const summarizeMainTable = (param) => {
return proxy.summarizeTable(param, ["incomeMoney"]);
+};
+
+const getIncomeMethodLabel = (row) => {
+ const methodValue = row?.incomeMethod;
+ const dictList = String(row?.businessType) === "1"
+ ? receipt_payment_type.value
+ : payment_methods.value;
+ return dictList.find((item) => item.value == methodValue)?.label || "--";
};
// 澶氶�夊悗鍋氫粈涔�
@@ -231,9 +246,9 @@
}
modalRef.value.loadForm(id);
};
-const changePage = ({ page, limit }) => {
+const changePage = ({page, limit}) => {
pagination.currentPage = page;
- pagination.pageSize = limit;
+ pagination.pageSize = limit;
onCurrentChange(page);
};
const deleteRow = (id) => {
@@ -255,13 +270,13 @@
return;
}
}
-
+
ElMessageBox.confirm("姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ暟鎹�, 鏄惁缁х画?", "鎻愮ず", {
confirmButtonText: "纭畾",
cancelButtonText: "鍙栨秷",
type: "warning",
}).then(async () => {
- const { code } = await delAccountIncome(id);
+ const {code} = await delAccountIncome(id);
if (code == 200) {
ElMessage({
type: "success",
@@ -278,13 +293,13 @@
proxy.$modal.msgWarning("璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁");
return;
}
-
+
// 妫�鏌ユ槸鍚︽湁 businessId
if (hasBusinessIdInSelection.value) {
proxy.$modal.msgWarning("閫変腑鐨勮褰曚腑鍖呭惈宸插叧鑱斾笟鍔$殑璁板綍锛屼笉鑳藉垹闄�");
return;
}
-
+
const ids = multipleList.value.map((item) => item.id);
deleteRow(ids);
};
@@ -308,162 +323,17 @@
cancelButtonText: "鍙栨秷",
type: "warning",
})
- .then(() => {
- proxy.download(`/account/accountIncome/export`, {}, "鏀跺叆鍙拌处.xlsx");
- })
- .catch(() => {
- proxy.$modal.msg("宸插彇娑�");
- });
+ .then(() => {
+ proxy.download(`/account/accountIncome/export`, {}, "鏀跺叆鍙拌处.xlsx");
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
};
// 鎵撳紑闄勪欢寮规
const openFilesFormDia = async (row) => {
- currentFileRow.value = row;
- accountType.value = '鏀跺叆';
- try {
- const res = await fileListPage({
- accountId: row.id,
- accountType: accountType.value,
- current: 1,
- size: 100
- });
- if (res.code === 200 && fileListRef.value) {
- // 灏嗘暟鎹浆鎹负 FileListDialog 闇�瑕佺殑鏍煎紡
- const fileList = (res.data?.records || []).map(item => ({
- name: item.name,
- url: item.url,
- id: item.id,
- ...item
- }));
- fileListRef.value.open(fileList);
- fileListDialogVisible.value = true;
- }
- } catch (error) {
- proxy.$modal.msgError("鑾峰彇闄勪欢鍒楄〃澶辫触");
- }
-};
-
-// 涓婁紶闄勪欢
-const handleUpload = async () => {
- if (!currentFileRow.value) {
- proxy.$modal.msgWarning("璇峰厛閫夋嫨鏁版嵁");
- return null;
- }
-
- 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);
-
- const uploadRes = await request({
- url: '/file/upload',
- method: 'post',
- data: formData,
- headers: {
- 'Content-Type': 'multipart/form-data',
- Authorization: `Bearer ${getToken()}`
- }
- });
-
- if (uploadRes.code === 200) {
- // 淇濆瓨闄勪欢淇℃伅
- const fileData = {
- accountId: currentFileRow.value.id,
- accountType: accountType.value,
- name: uploadRes.data.originalName || file.name,
- url: uploadRes.data.tempPath || uploadRes.data.url
- };
-
- const saveRes = await fileAdd(fileData);
- if (saveRes.code === 200) {
- proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
- // 閲嶆柊鍔犺浇鏂囦欢鍒楄〃
- const listRes = await fileListPage({
- accountId: currentFileRow.value.id,
- accountType: accountType.value,
- current: 1,
- size: 100
- });
- if (listRes.code === 200 && fileListRef.value) {
- const fileList = (listRes.data?.records || []).map(item => ({
- name: item.name,
- url: item.url,
- id: item.id,
- ...item
- }));
- fileListRef.value.setList(fileList);
- }
- // 杩斿洖鏂版枃浠朵俊鎭�
- resolve({
- name: fileData.name,
- url: fileData.url,
- id: saveRes.data?.id
- });
- } else {
- proxy.$modal.msgError(saveRes.msg || "鏂囦欢淇濆瓨澶辫触");
- resolve(null);
- }
- } else {
- proxy.$modal.msgError(uploadRes.msg || "鏂囦欢涓婁紶澶辫触");
- resolve(null);
- }
- } catch (error) {
- proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
- resolve(null);
- } finally {
- document.body.removeChild(input);
- }
- };
-
- document.body.appendChild(input);
- input.click();
- });
-};
-
-// 鍒犻櫎闄勪欢
-const handleFileDelete = async (row) => {
- try {
- const res = await fileDel([row.id]);
- if (res.code === 200) {
- proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
- // 閲嶆柊鍔犺浇鏂囦欢鍒楄〃
- if (currentFileRow.value && fileListRef.value) {
- const listRes = await fileListPage({
- accountId: currentFileRow.value.id,
- accountType: accountType.value,
- current: 1,
- size: 100
- });
- if (listRes.code === 200) {
- const fileList = (listRes.data?.records || []).map(item => ({
- name: item.name,
- url: item.url,
- id: item.id,
- ...item
- }));
- fileListRef.value.setList(fileList);
- }
- }
- return true; // 杩斿洖 true 琛ㄧず鍒犻櫎鎴愬姛锛岀粍浠朵細鏇存柊鍒楄〃
- } else {
- proxy.$modal.msgError(res.msg || "鍒犻櫎澶辫触");
- return false;
- }
- } catch (error) {
- proxy.$modal.msgError("鍒犻櫎澶辫触");
- return false;
- }
+ currentRecordId.value = row.id;
+ fileListDialogVisible.value = true;
};
onMounted(() => {
@@ -475,6 +345,7 @@
.table_list {
margin-top: unset;
}
+
.actions {
display: flex;
justify-content: space-between;
--
Gitblit v1.9.3