From dfa7374765f5aac045bc3338aac2aa2a91ce6763 Mon Sep 17 00:00:00 2001 From: lion <120344285@qq.com> Date: Wed, 26 Feb 2025 11:19:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A1=A3=E6=A1=88=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/home/index.js | 79 ++++++++++++++++++++++++++------------ src/views/record/index.vue | 54 +++++++++++++++++++++++--- vue.config.js | 2 +- 3 files changed, 105 insertions(+), 30 deletions(-) diff --git a/src/api/home/index.js b/src/api/home/index.js index 017ab85..3cf2032 100644 --- a/src/api/home/index.js +++ b/src/api/home/index.js @@ -1,25 +1,56 @@ -import request from "@/utils/request"; - -export function home(params){ - return request({ - method:'get', - url:'/api/chart', - params - }) -} - -export function yearChart(params){ - return request({ - method:'get', - url:'/api/fill-datas-total-chart', - params - }) -} - -export function fillChart(params){ - return request({ - method:'get', - url:'/api/fill-datas-chart', - params - }) +import request from "@/utils/request"; + +function customParamsSerializer(params) { + let result = ''; + for (let key in params) { + if (params.hasOwnProperty(key)) { + if (Array.isArray(params[key])) { + params[key].forEach((item, index) => { + if (item.key) { + result += + `${key}[${index}][key]=${item.key}&${key}[${index}][op]=${item.op}&${key}[${index}][value]=${item.value}&`; + + } else { + result += `${key}[${index}]=${item}&` + } + }); + } else { + result += `${key}=${params[key]}&`; + } + } + } + return result.slice(0, -1); +} + +export function home(params) { + return request({ + method: 'get', + url: '/api/chart', + params + }) +} + +export function yearChart(params) { + return request({ + method: 'get', + url: '/api/fill-datas-total-chart', + params + }) +} + +export function fillChart(params) { + return request({ + method: 'get', + url: '/api/fill-datas-chart', + params + }) +} + +export function catalogTotal(params) { + return request({ + method: 'get', + url: '/api/admin/other/catalog-total', + params, + paramsSerializer: customParamsSerializer + }) } diff --git a/src/views/record/index.vue b/src/views/record/index.vue index a1151ef..830be1c 100644 --- a/src/views/record/index.vue +++ b/src/views/record/index.vue @@ -194,7 +194,11 @@ import { index, destroy - } from "@/api/system/baseForm.js" + } from "@/api/system/baseForm.js" + import { + catalogTotal + } from "@/api/home/index.js" + import state from '@/store/modules/user.js' export default { components: { @@ -490,11 +494,15 @@ clickIn(i) { if (i.children && i.children.length > 0) { this.historyList.push(this.showData); - this.showData = i.children; this.menuName.push(i.name) this.select.catalog_name = ' / ' + this.menuName.join(" / ") - console.log(this.historyList); + console.log(this.historyList); + let totalId = [] + this.showData.map(item=>{ + totalId.push(item.id) + }) + this.getCatalogTotal(totalId.join(',')) } else { this.select.catalog_id = i.id this.menuName.push(i.name) @@ -517,7 +525,8 @@ this.menuName.splice(this.menuName.length - 1, 1) this.select.catalog_name = ' / ' + this.menuName.join(" / ") this.hasMenu = true - }, + }, + async getCatalogList(pid) { const res = await index({ page_size: 999, @@ -533,9 +542,44 @@ let pList = this.base.findNodesById(this.catalogList, pid) console.log("pList", pList) this.catalogChildren = pList[0].children - this.showData = this.catalogChildren + this.showData = this.catalogChildren + let totalId = [] + this.showData.map(item=>{ + totalId.push(item.id) + }) + this.getCatalogTotal(totalId.join(',')) } } + }, + async getCatalogTotal(ids){ + const res = await catalogTotal({ + ids:ids + }) + let data = res.list + const updatedB = this.showData.map((item) => { + // 在数组 a 中查找匹配的 id + const matchedItem = data.find((aItem) => aItem.id == item.id); + + // 如果找到匹配项,则将 records_total 和 sub_records_total 添加到当前项 + if (matchedItem) { + return { + ...item, + records_total: matchedItem.records_total, + sub_records_total: matchedItem.sub_records_total + }; + }else{ + return { + ...item, + records_total: 0, + sub_records_total: 0 + }; + } + + // 如果没有找到匹配项,则返回原项 + return item; + }); + this.showData = updatedB + console.log("this.showData",this.showData) }, async getAreaList() { const res = await index({ diff --git a/vue.config.js b/vue.config.js index c82404e..5201527 100644 --- a/vue.config.js +++ b/vue.config.js @@ -25,7 +25,7 @@ module.exports = { * Detail: https://cli.vuejs.org/config/#publicpath */ publicPath: process.env.ENV === 'staging' ? '/admin_test' : '/admin', - outputDir: '/Users/mac/Documents/朗业/2024/s-四世同堂-档案/sstt_dangan/public/admin_test', + outputDir: '/Users/mac/Documents/朗业/2024/s-四世同堂-档案/sstt_dangan/public/admin', assetsDir: 'static', css: { loaderOptions: { // 向 CSS 相关的 loader 传递选项