From a2c8b4dd1135a9ee592589cac92f9c42debf88e4 Mon Sep 17 00:00:00 2001 From: ywyonui Date: Wed, 9 Jul 2025 18:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8B=E8=BD=BD=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/base/server.ts | 6 +- .../BasicListLayout/hooks/useLayout.ts | 106 +++++++++--------- .../view/routine/JiaoXueZiYuan/indexList.vue | 91 ++++++++++++++- 3 files changed, 143 insertions(+), 60 deletions(-) diff --git a/src/api/base/server.ts b/src/api/base/server.ts index c6dc6e0..7c9fd8d 100644 --- a/src/api/base/server.ts +++ b/src/api/base/server.ts @@ -122,7 +122,11 @@ export const typesFindTreeApi = async () => { // 获取资源分页 export const resourcesFindPageApi = async (params: any) => { - return await get("/api/resources/findPage", params); + return await get("/api/resources/findPage", params); +}; +// 获取资源分页 +export const resourcesAddNumByTypeApi = async (params: any) => { + return await post("/api/resources/addNumByType", params); }; diff --git a/src/components/BasicListLayout/hooks/useLayout.ts b/src/components/BasicListLayout/hooks/useLayout.ts index b55d0b7..af1e122 100644 --- a/src/components/BasicListLayout/hooks/useLayout.ts +++ b/src/components/BasicListLayout/hooks/useLayout.ts @@ -1,64 +1,64 @@ -import {isFunction} from "lodash"; -import {Ref} from "vue"; -import {hideLoading, showLoading} from "@/utils/uniapp"; +import { isFunction } from "lodash"; +import { Ref } from "vue"; +import { hideLoading, showLoading } from "@/utils/uniapp"; import type { - LayoutCallback, - LayoutOptions, - PagingRefInterface, - UseLayoutInterfaceReturn + LayoutCallback, + LayoutOptions, + PagingRefInterface, + UseLayoutInterfaceReturn } from "@/components/BasicListLayout/type/useLayout"; export function useLayout(options: LayoutOptions): UseLayoutInterfaceReturn { - let methods: Ref + let methods: Ref - async function requestApi(pageNo: number, pageSize: number) { - if (isFunction(options.api)) { - try { - let params = Object.assign({}, { - rows: pageSize, - page: pageNo - }, options.param) - const result = await options.api(params) - await nextTick() - if (methods.value) { - // @ts-ignore - await methods.value.complete(result[options.resultKey || 'rows']) - } - } catch (err) { - console.log('err', err) - if (methods.value) { - await methods.value.complete(false); - } - } + async function requestApi(pageNo: number, pageSize: number) { + if (isFunction(options.api)) { + try { + let params = Object.assign({}, { + rows: pageSize, + page: pageNo + }, options.param) + const result = await options.api(params) + await nextTick() + if (methods.value) { + // @ts-ignore + await methods.value.complete(result[options.resultKey || 'rows']) } - } - - if (!options.query) { - options.query = requestApi - } - - const register = (callback: LayoutCallback, pagingRef: Ref) => { - methods = pagingRef - callback(options) - } - return [register, - { - reload: async (isLoading: boolean = false) => { - if (isLoading) { - showLoading({title: '加载中...'}) - } - await nextTick() - if (methods.value) { - await methods.value.reload(false) - } - hideLoading() - }, - setParam: (param: any) => { - options.param = Object.assign({}, options.param, param) - } + } catch (err) { + console.log('err', err) + if (methods.value) { + await methods.value.complete(false); } - ] + } + } + } + + if (!options.query) { + options.query = requestApi + } + + const register = (callback: LayoutCallback, pagingRef: Ref) => { + methods = pagingRef + callback(options) + } + return [register, + { + reload: async (isLoading: boolean = false) => { + if (isLoading) { + showLoading({ title: '加载中...' }) + } + await nextTick() + if (methods.value) { + await methods.value.reload(false) + } + hideLoading() + }, + setParam: (param: any) => { + options.param = Object.assign({}, options.param, param) + } + } + ] } \ No newline at end of file diff --git a/src/pages/view/routine/JiaoXueZiYuan/indexList.vue b/src/pages/view/routine/JiaoXueZiYuan/indexList.vue index 5cf4005..b1651f4 100644 --- a/src/pages/view/routine/JiaoXueZiYuan/indexList.vue +++ b/src/pages/view/routine/JiaoXueZiYuan/indexList.vue @@ -17,7 +17,7 @@