From c9e9f71e54e5ad207f7ca368021d833993880bf9 Mon Sep 17 00:00:00 2001 From: LiuJiaNan Date: Fri, 26 Apr 2024 11:03:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E7=94=9F=E4=BA=A7=E8=B4=B9?= =?UTF-8?q?=E7=94=A8=E6=8F=90=E5=8F=96=E5=92=8C=E4=BD=BF=E7=94=A8=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=90=88=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extraction_and_use/index.vue | 98 +++++++++---------- 1 file changed, 46 insertions(+), 52 deletions(-) diff --git a/src/views/security_investment/extraction_and_use/index.vue b/src/views/security_investment/extraction_and_use/index.vue index 2b0388b..d14b4c5 100644 --- a/src/views/security_investment/extraction_and_use/index.vue +++ b/src/views/security_investment/extraction_and_use/index.vue @@ -47,14 +47,16 @@ - + - + @@ -62,11 +64,13 @@ v-for="(item, index) in costItems" :key="index" :label="item" + prop="AMOUNT" > @@ -81,29 +85,29 @@
- - - - - - - - - - + + + + + + + + + + - - - - - - - + + + + + + +
@@ -121,13 +125,14 @@ import useListData from "@/assets/js/useListData.js"; import { getExtractionAndUseList, - setExtractionAndUseBatchDelete + setExtractionAndUseBatchDelete, } from "@/request/security_investment.js"; import { debounce } from "throttle-debounce"; import { ElMessage, ElMessageBox } from "element-plus"; import { ref } from "vue"; import Add from "./components/add.vue"; import { PRINT_STYLE } from "@/assets/js/constant.js"; +import { sumBy } from "lodash-es"; const yearList = (() => { const year = new Date().getFullYear(); @@ -147,17 +152,15 @@ const costItems = [ "应急管理、事故救援演练以及救援队伍建设", "安全标志及标识", "配备劳动防护用品", - "其它与安全生产直接相关的物品或者活动" + "其它与安全生产直接相关的物品或者活动", ]; -const total = await getExtractionAndUseList(); -console.log(total); const addDialogVisible = ref(false); const { list, searchForm, fnGetData, tableRef } = useListData( getExtractionAndUseList, { usePagination: false, defaultSearchForm: { - YEAR: new Date().getFullYear() + YEAR: new Date().getFullYear(), }, callbackFn: (list) => { for (let i = 0; i < list.length; i++) { @@ -170,7 +173,7 @@ const { list, searchForm, fnGetData, tableRef } = useListData( else list[i].TOTAL = list[i - 1].TOTAL - list[i].AMOUNT; } } - } + }, } ); const fnGetSummaries = ({ columns, data }) => { @@ -180,29 +183,20 @@ const fnGetSummaries = ({ columns, data }) => { sums[index] = "合计"; return; } - - // var arr = ref([5, 6, 7, 8, 9, 10, 11, 12, 13, 14]) - // if (arr.includes(index)) { - // sums[index] = total.allOutlayTotalList[index - 5].total; - // return; - // } - - if (index !== columns.length - 1) { - sums[index] = "--"; - return; - } - const values = data.map((item) => Number(item[column.property])); - if (!values.every((value) => isNaN(value))) { - sums[index] = values.reduce((prev, curr) => { - const value = Number(curr); - if (!isNaN(value)) { - return prev + curr; - } else { - return prev; - } - }, 0); - sums[index] = "--"; - } + if (!data.every((value) => isNaN(value[column.property]))) { + sums[index] = + sumBy(data, (item) => { + if (index === 3 && item.USE_TYPE === "1") + return item[column.property]; + else if ( + index > 4 && + index < columns.length - 1 && + column.label === item.TYPE + ) + return item[column.property]; + else if (index === columns.length - 1) return item[column.property]; + }) || "--"; + } else sums[index] = "--"; }); return sums; };