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; };