From b1d7deb1cb9be22edeb717fb2119a8bc2cf2f3af Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 23 三月 2026 15:11:24 +0800
Subject: [PATCH] 添加生成逻辑以支持标准和实际成本对比分析,优化数据结构和模板下载功能
---
src/views/costAccounting/stdVsActCostAnalysis/index.vue | 133 +++++++++++++++++++++++++++++++++----------
1 files changed, 101 insertions(+), 32 deletions(-)
diff --git a/src/views/costAccounting/stdVsActCostAnalysis/index.vue b/src/views/costAccounting/stdVsActCostAnalysis/index.vue
index e0da789..8fa9f16 100644
--- a/src/views/costAccounting/stdVsActCostAnalysis/index.vue
+++ b/src/views/costAccounting/stdVsActCostAnalysis/index.vue
@@ -271,35 +271,103 @@
const largeChartVisible = ref(false);
const currentChartOption = ref(null);
-const actualCostSource = ref([
- { month: "2026-01", category: "鐡风爾", costType: "鑳借�楁垚鏈�", actualCost: 182000 },
- { month: "2026-01", category: "鐡风爾", costType: "鐢熶骇鎴愭湰", actualCost: 465000 },
- { month: "2026-01", category: "姘存偿", costType: "鑳借�楁垚鏈�", actualCost: 138500 },
- { month: "2026-01", category: "姘存偿", costType: "鐢熶骇鎴愭湰", actualCost: 398000 },
- { month: "2026-02", category: "鐡风爾", costType: "鑳借�楁垚鏈�", actualCost: 191500 },
- { month: "2026-02", category: "鐡风爾", costType: "鐢熶骇鎴愭湰", actualCost: 472500 },
- { month: "2026-02", category: "姘存偿", costType: "鑳借�楁垚鏈�", actualCost: 142300 },
- { month: "2026-02", category: "姘存偿", costType: "鐢熶骇鎴愭湰", actualCost: 407000 },
- { month: "2026-03", category: "鐮傛祮", costType: "鑳借�楁垚鏈�", actualCost: 95800 },
- { month: "2026-03", category: "鐮傛祮", costType: "鐢熶骇鎴愭湰", actualCost: 265400 },
- { month: "2026-03", category: "鐡风爾", costType: "鑳借�楁垚鏈�", actualCost: 189800 },
- { month: "2026-03", category: "鐡风爾", costType: "鐢熶骇鎴愭湰", actualCost: 469900 },
-]);
+// ------------------------------
+// 鍋囨暟鎹細鐢ㄤ簬鍏堣仈璋冮〉闈㈡覆鏌�
+// ------------------------------
+const actualCostSource = ref([]);
+const standardCostSource = ref([]);
-const standardCostSource = ref([
- { month: "2026-01", category: "鐡风爾", costType: "鑳借�楁垚鏈�", standardCost: 176000 },
- { month: "2026-01", category: "鐡风爾", costType: "鐢熶骇鎴愭湰", standardCost: 452000 },
- { month: "2026-01", category: "姘存偿", costType: "鑳借�楁垚鏈�", standardCost: 136000 },
- { month: "2026-01", category: "姘存偿", costType: "鐢熶骇鎴愭湰", standardCost: 392000 },
- { month: "2026-02", category: "鐡风爾", costType: "鑳借�楁垚鏈�", standardCost: 186000 },
- { month: "2026-02", category: "鐡风爾", costType: "鐢熶骇鎴愭湰", standardCost: 458000 },
- { month: "2026-02", category: "姘存偿", costType: "鑳借�楁垚鏈�", standardCost: 139000 },
- { month: "2026-02", category: "姘存偿", costType: "鐢熶骇鎴愭湰", standardCost: 401000 },
- { month: "2026-03", category: "鐮傛祮", costType: "鑳借�楁垚鏈�", standardCost: 93000 },
- { month: "2026-03", category: "鐮傛祮", costType: "鐢熶骇鎴愭湰", standardCost: 259000 },
- { month: "2026-03", category: "鐡风爾", costType: "鑳借�楁垚鏈�", standardCost: 185000 },
- { month: "2026-03", category: "鐡风爾", costType: "鐢熶骇鎴愭湰", standardCost: 461000 },
-]);
+const fakeMonths = ["2026-01", "2026-02", "2026-03"];
+const fakeCategories = [
+ "绮夌叅鐏�",
+ "鐭崇伆",
+ "姘存偿",
+ "閾濈矇鑶�",
+ "鑴辨ā鍓�",
+ "鐭宠啅",
+ "鎵撳寘甯�",
+ "闃茶厫鍓傦紙鏉挎潗鐢級",
+ "姘у寲闀侊紙鏉挎潗鐢級",
+ "鍐锋尋涓濓紙鏉挎潗鐢級",
+ "鍗℃墸锛堟澘鏉愮敤锛�",
+ "鏉愭枡灏忚",
+ "姘�",
+ "鐢�",
+ "钂告苯",
+];
+
+const fakeCostType = (category) => (["姘�", "鐢�", "钂告苯"].includes(category) ? "鑳借�楁垚鏈�" : "鐢熶骇鎴愭湰");
+
+// 姣忎釜绫诲埆鐨勬爣鍑嗘垚鏈熀鍑嗗�硷紙浠呯敤浜庡亣鏁版嵁锛�
+const baseStandardCostByCategory = {
+ 绮夌叅鐏�: 98000,
+ 鐭崇伆: 52000,
+ 姘存偿: 175000,
+ 閾濈矇鑶�: 32000,
+ 鑴辨ā鍓�: 21000,
+ 鐭宠啅: 41000,
+ 鎵撳寘甯�: 14500,
+ "闃茶厫鍓傦紙鏉挎潗鐢級": 12500,
+ "姘у寲闀侊紙鏉挎潗鐢級": 22000,
+ "鍐锋尋涓濓紙鏉挎潗鐢級": 9800,
+ "鍗℃墸锛堟澘鏉愮敤锛�": 8600,
+ 鏉愭枡灏忚: 420000,
+ 姘�: 6800,
+ 鐢�: 26000,
+ 钂告苯: 52000,
+};
+
+// 鏈堜唤娉㈠姩绯绘暟锛堣鍥捐〃鐪嬭捣鏉ユ洿鈥滅湡瀹炩�濅竴浜涳級
+const monthFactorByMonth = {
+ "2026-01": 1.0,
+ "2026-02": 1.06,
+ "2026-03": 0.97,
+};
+
+// 瀹為檯鎴愭湰鐩稿鏍囧噯鎴愭湰鐨勫亸绉绘瘮渚嬶紙鐢ㄤ簬娴嬭瘯姝h礋宸紓灞曠ず锛�
+const diffRatioByCategory = {
+ 绮夌叅鐏�: 0.05,
+ 鐭崇伆: -0.01,
+ 姘存偿: 0.03,
+ 閾濈矇鑶�: 0.0,
+ 鑴辨ā鍓�: -0.04,
+ 鐭宠啅: 0.02,
+ 鎵撳寘甯�: -0.03,
+ "闃茶厫鍓傦紙鏉挎潗鐢級": 0.06,
+ "姘у寲闀侊紙鏉挎潗鐢級": -0.02,
+ "鍐锋尋涓濓紙鏉挎潗鐢級": 0.01,
+ "鍗℃墸锛堟澘鏉愮敤锛�": -0.05,
+ 鏉愭枡灏忚: 0.02,
+ 姘�: -0.01,
+ 鐢�: 0.04,
+ 钂告苯: -0.03,
+};
+
+const buildFakeSources = () => {
+ const stdRows = [];
+ const actRows = [];
+
+ for (const month of fakeMonths) {
+ const monthFactor = monthFactorByMonth[month] ?? 1;
+ const monthAdj = month === "2026-02" ? 0.005 : month === "2026-03" ? -0.006 : 0;
+
+ for (const category of fakeCategories) {
+ const costType = fakeCostType(category);
+ const base = baseStandardCostByCategory[category] ?? 0;
+ const standardCost = Math.round(base * monthFactor);
+ const diffRatio = (diffRatioByCategory[category] ?? 0) + monthAdj;
+ const actualCost = Math.round(standardCost * (1 + diffRatio));
+
+ stdRows.push({ month, category, costType, standardCost });
+ actRows.push({ month, category, costType, actualCost });
+ }
+ }
+
+ standardCostSource.value = stdRows;
+ actualCostSource.value = actRows;
+};
+
+buildFakeSources();
const categoryOptions = computed(() => {
const all = [...actualCostSource.value, ...standardCostSource.value];
@@ -614,10 +682,11 @@
const downloadTemplate = () => {
const sample = [
- { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "鐡风爾", 鎴愭湰绫诲瀷: "鏍囧噯鑳借�楁垚鏈�", 鏍囧噯鎴愭湰: 185000 },
- { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "鐡风爾", 鎴愭湰绫诲瀷: "鏍囧噯鐢熶骇鎴愭湰", 鏍囧噯鎴愭湰: 461000 },
- { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "姘存偿", 鎴愭湰绫诲瀷: "鏍囧噯鑳借�楁垚鏈�", 鏍囧噯鎴愭湰: 140000 },
- { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "姘存偿", 鎴愭湰绫诲瀷: "鏍囧噯鐢熶骇鎴愭湰", 鏍囧噯鎴愭湰: 405000 },
+ { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "绮夌叅鐏�", 鎴愭湰绫诲瀷: "鏍囧噯鐢熶骇鎴愭湰", 鏍囧噯鎴愭湰: 98000 },
+ { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "姘存偿", 鎴愭湰绫诲瀷: "鏍囧噯鐢熶骇鎴愭湰", 鏍囧噯鎴愭湰: 175000 },
+ { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "鐢�", 鎴愭湰绫诲瀷: "鏍囧噯鑳借�楁垚鏈�", 鏍囧噯鎴愭湰: 26000 },
+ { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "钂告苯", 鎴愭湰绫诲瀷: "鏍囧噯鑳借�楁垚鏈�", 鏍囧噯鎴愭湰: 52000 },
+ { 鏈堜唤: "2026-03", 浜у搧绫诲埆: "姘�", 鎴愭湰绫诲瀷: "鏍囧噯鑳借�楁垚鏈�", 鏍囧噯鎴愭湰: 6800 },
];
const ws = XLSX.utils.json_to_sheet(sample);
const wb = XLSX.utils.book_new();
--
Gitblit v1.9.3