From 14363b1ae7cb0d730158ec8dfbee55a85b2fc09f Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 12 五月 2026 15:23:17 +0800
Subject: [PATCH] feat(financial): 实现财务模块数据接口联调
---
src/views/financialManagement/assets/intangibleAssets.vue | 157 +++++++++++++++++++++++++--------------------------
1 files changed, 77 insertions(+), 80 deletions(-)
diff --git a/src/views/financialManagement/assets/intangibleAssets.vue b/src/views/financialManagement/assets/intangibleAssets.vue
index 14dae55..649ec5b 100644
--- a/src/views/financialManagement/assets/intangibleAssets.vue
+++ b/src/views/financialManagement/assets/intangibleAssets.vue
@@ -182,6 +182,13 @@
import { ref, reactive, onMounted, computed } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import FormDialog from "@/components/Dialog/FormDialog.vue";
+import {
+ listIntangibleAssetPage,
+ addIntangibleAsset,
+ updateIntangibleAsset,
+ deleteIntangibleAsset,
+ amortizeIntangibleAsset,
+} from "@/api/financialManagement/intangibleAsset";
defineOptions({
name: "鏃犲舰璧勪骇",
@@ -203,13 +210,13 @@
const columns = [
{ label: "璧勪骇缂栧彿", prop: "assetCode", width: "130" },
{ label: "璧勪骇鍚嶇О", prop: "assetName", width: "150" },
- { label: "璧勪骇绫诲埆", prop: "category", slot: "category" },
+ { label: "璧勪骇绫诲埆", prop: "category", dataType: "slot", slot: "category" },
{ label: "璇佷功缂栧彿", prop: "certificateNo", width: "150" },
- { label: "璧勪骇鍘熷��", prop: "originalValue", slot: "originalValue" },
- { label: "绱鎽婇攢", prop: "accumulatedAmortization", slot: "accumulatedAmortization" },
- { label: "璧勪骇鍑�鍊�", prop: "netValue", slot: "netValue" },
- { label: "鐘舵��", prop: "status", slot: "status" },
- { label: "鎿嶄綔", prop: "operation", slot: "operation", width: "180", fixed: "right" },
+ { label: "璧勪骇鍘熷��", prop: "originalValue", dataType: "slot", slot: "originalValue" },
+ { label: "绱鎽婇攢", prop: "accumulatedAmortization", dataType: "slot", slot: "accumulatedAmortization" },
+ { label: "璧勪骇鍑�鍊�", prop: "netValue", dataType: "slot", slot: "netValue" },
+ { label: "鐘舵��", prop: "status", dataType: "slot", slot: "status" },
+ { label: "鎿嶄綔", prop: "operation", dataType: "slot", slot: "operation", width: "180", fixed: "right" },
];
const dataList = ref([]);
@@ -219,7 +226,7 @@
const isEdit = ref(false);
const currentId = ref(null);
-const form = reactive({
+const createDefaultForm = () => ({
assetCode: "",
assetName: "",
category: "",
@@ -236,6 +243,10 @@
remark: "",
});
+const form = reactive({
+ ...createDefaultForm(),
+});
+
const rules = {
assetName: [{ required: true, message: "璇疯緭鍏ヨ祫浜у悕绉�", trigger: "blur" }],
category: [{ required: true, message: "璇烽�夋嫨璧勪骇绫诲埆", trigger: "change" }],
@@ -243,13 +254,6 @@
originalValue: [{ required: true, message: "璇疯緭鍏ヨ祫浜у師鍊�", trigger: "blur" }],
amortizationPeriod: [{ required: true, message: "璇疯緭鍏ユ憡閿�骞撮檺", trigger: "blur" }],
};
-
-const mockData = [
- { id: 1, assetCode: "WX2024001", assetName: "ERP杞欢璁稿彲", category: "software", certificateNo: "SW-2023-001", acquisitionDate: "2023-01-01", originalValue: 50000, amortizationPeriod: 10, residualRate: 0, accumulatedAmortization: 5000, netValue: 45000, validityDate: "2033-01-01", status: "in_use", description: "浼佷笟璧勬簮璁″垝绠$悊绯荤粺", remark: "" },
- { id: 2, assetCode: "WX2024002", assetName: "鍙戞槑涓撳埄", category: "patent", certificateNo: "ZL202210123456.7", acquisitionDate: "2022-06-15", originalValue: 100000, amortizationPeriod: 20, residualRate: 0, accumulatedAmortization: 3750, netValue: 96250, validityDate: "2042-06-15", status: "in_use", description: "涓�绉嶆柊鍨嬬敓浜у伐鑹�", remark: "" },
- { id: 3, assetCode: "WX2024003", assetName: "鍟嗘爣鏉�", category: "trademark", certificateNo: "TM-2023-008", acquisitionDate: "2023-03-10", originalValue: 20000, amortizationPeriod: 10, residualRate: 0, accumulatedAmortization: 1500, netValue: 18500, validityDate: "2033-03-10", status: "in_use", description: "鍏徃鍝佺墝鍟嗘爣", remark: "" },
- { id: 4, assetCode: "WX2024004", assetName: "鍦熷湴浣跨敤鏉�", category: "land", certificateNo: "鍦熷浗鐢�(2023)绗�001鍙�", acquisitionDate: "2023-07-01", originalValue: 500000, amortizationPeriod: 50, residualRate: 0, accumulatedAmortization: 5000, netValue: 495000, validityDate: "2073-07-01", status: "in_use", description: "宸ヤ笟鐢ㄥ湴浣跨敤鏉�", remark: "" },
-];
const totalOriginalValue = computed(() => {
return dataList.value.reduce((sum, item) => sum + Number(item.originalValue), 0);
@@ -281,35 +285,44 @@
};
const getStatusLabel = (status) => {
- const map = { in_use: "鍦ㄧ敤", idle: "闂茬疆", amortized: "宸叉憡閿�瀹屾瘯" };
- return map[status] || status;
+ const key = String(status || "").toLowerCase();
+ const map = {
+ in_use: "鍦ㄧ敤",
+ idle: "闂茬疆",
+ expired: "宸插埌鏈�",
+ amortized: "宸叉憡閿�瀹屾瘯",
+ };
+ return map[key] || status;
};
const getStatusType = (status) => {
- const map = { in_use: "success", idle: "warning", amortized: "info" };
- return map[status] || "";
+ const key = String(status || "").toLowerCase();
+ const map = { in_use: "success", idle: "warning", expired: "warning", amortized: "info" };
+ return map[key] || "";
};
const calculateNetValue = () => {
- form.netValue = Number((form.originalValue - form.accumulatedAmortization).toFixed(2));
+ const originalValue = Number(form.originalValue || 0);
+ const accumulatedAmortization = Number(form.accumulatedAmortization || 0);
+ form.netValue = Number((originalValue - accumulatedAmortization).toFixed(2));
};
-const getTableData = () => {
- let result = [...mockData];
- if (filters.assetCode) {
- result = result.filter(item => item.assetCode.includes(filters.assetCode));
+// 鑱旇皟绾﹀畾锛氬垎椤靛弬鏁板浐瀹氫负 current/size锛岃繑鍥� data.records/data.total
+const getTableData = async () => {
+ try {
+ const { data } = await listIntangibleAssetPage({
+ current: pagination.currentPage,
+ size: pagination.pageSize,
+ assetCode: filters.assetCode,
+ assetName: filters.assetName,
+ category: filters.category,
+ status: filters.status,
+ });
+ dataList.value = data?.records || [];
+ pagination.total = Number(data?.total || 0);
+ } catch (error) {
+ // 鎻愮ず鐢卞叏灞�璇锋眰鎷︽埅鍣ㄥ鐞嗭紝杩欓噷浠呴槻姝㈡湭鎹曡幏寮傚父
}
- if (filters.assetName) {
- result = result.filter(item => item.assetName.includes(filters.assetName));
- }
- if (filters.category) {
- result = result.filter(item => item.category === filters.category);
- }
- if (filters.status) {
- result = result.filter(item => item.status === filters.status);
- }
- pagination.total = result.length;
- dataList.value = result.slice((pagination.currentPage - 1) * pagination.pageSize, pagination.currentPage * pagination.pageSize);
};
const resetFilters = () => {
@@ -327,24 +340,15 @@
getTableData();
};
+const buildAssetCode = () => `WX${Date.now().toString().slice(-10)}`;
+
const add = () => {
isEdit.value = false;
+ currentId.value = null;
dialogTitle.value = "鏂板鏃犲舰璧勪骇";
- Object.assign(form, {
- assetCode: "WX" + Date.now().toString().slice(-8),
- assetName: "",
- category: "",
- certificateNo: "",
+ Object.assign(form, createDefaultForm(), {
+ assetCode: buildAssetCode(),
acquisitionDate: new Date().toISOString().split('T')[0],
- originalValue: 0,
- amortizationPeriod: 10,
- residualRate: 0,
- accumulatedAmortization: 0,
- netValue: 0,
- validityDate: "",
- status: "in_use",
- description: "",
- remark: "",
});
dialogVisible.value = true;
};
@@ -353,7 +357,7 @@
isEdit.value = true;
currentId.value = row.id;
dialogTitle.value = "缂栬緫鏃犲舰璧勪骇";
- Object.assign(form, row);
+ Object.assign(form, createDefaultForm(), row);
dialogVisible.value = true;
};
@@ -366,13 +370,14 @@
confirmButtonText: "纭畾",
cancelButtonText: "鍙栨秷",
type: "warning",
- }).then(() => {
- const index = mockData.findIndex(item => item.id === row.id);
- if (index !== -1) {
- mockData.splice(index, 1);
+ }).then(async () => {
+ // 鑱旇皟绾﹀畾锛氬垹闄ゆ帴鍙d娇鐢� ids=1&ids=2
+ await deleteIntangibleAsset([row.id]);
+ if (dataList.value.length === 1 && pagination.currentPage > 1) {
+ pagination.currentPage -= 1;
}
ElMessage.success("鍒犻櫎鎴愬姛");
- getTableData();
+ await getTableData();
});
};
@@ -381,20 +386,10 @@
confirmButtonText: "纭",
cancelButtonText: "鍙栨秷",
type: "info",
- }).then(() => {
- mockData.forEach(item => {
- if (item.status === "in_use") {
- const monthlyAmortization = (item.originalValue * (1 - item.residualRate / 100)) / (item.amortizationPeriod * 12);
- item.accumulatedAmortization = Number((item.accumulatedAmortization + monthlyAmortization).toFixed(2));
- item.netValue = Number((item.originalValue - item.accumulatedAmortization).toFixed(2));
- if (item.netValue <= 0) {
- item.status = "amortized";
- item.netValue = 0;
- }
- }
- });
+ }).then(async () => {
+ await amortizeIntangibleAsset({});
ElMessage.success("鎽婇攢璁℃彁瀹屾垚");
- getTableData();
+ await getTableData();
});
};
@@ -403,22 +398,24 @@
};
const submitForm = () => {
- formRef.value.validate((valid) => {
+ formRef.value.validate(async valid => {
if (valid) {
- calculateNetValue();
- if (isEdit.value) {
- const index = mockData.findIndex(item => item.id === currentId.value);
- if (index !== -1) {
- mockData[index] = { ...mockData[index], ...form };
+ try {
+ calculateNetValue();
+ const payload = { ...form };
+ if (isEdit.value) {
+ payload.id = currentId.value;
+ await updateIntangibleAsset(payload);
+ ElMessage.success("缂栬緫鎴愬姛");
+ } else {
+ await addIntangibleAsset(payload);
+ ElMessage.success("鏂板鎴愬姛");
}
- ElMessage.success("缂栬緫鎴愬姛");
- } else {
- const newId = mockData.length > 0 ? Math.max(...mockData.map(item => item.id)) + 1 : 1;
- mockData.push({ id: newId, ...form });
- ElMessage.success("鏂板鎴愬姛");
+ dialogVisible.value = false;
+ await getTableData();
+ } catch (error) {
+ // 鎻愮ず鐢卞叏灞�璇锋眰鎷︽埅鍣ㄥ鐞嗭紝杩欓噷浠呴槻姝㈡湭鎹曡幏寮傚父
}
- dialogVisible.value = false;
- getTableData();
}
});
};
--
Gitblit v1.9.3