From ec6c38cb3e586f97328208928fe67f30280ed5d6 Mon Sep 17 00:00:00 2001 From: wang_yp Date: Thu, 20 Jun 2024 23:21:43 +0800 Subject: [PATCH] push im model --- src/components/BTable.tsx | 1 - src/components/dilog/index.tsx | 2 +- src/components/form/select.tsx | 8 ++++---- src/hooks/mounted-status.ts | 12 ++++++++++++ src/model/userModel.ts | 1 - src/pages/card/card-list.tsx | 1 + src/store/baseStore.ts | 16 ++++++---------- 7 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 src/hooks/mounted-status.ts diff --git a/src/components/BTable.tsx b/src/components/BTable.tsx index fa24886..9946fca 100644 --- a/src/components/BTable.tsx +++ b/src/components/BTable.tsx @@ -37,7 +37,6 @@ const BTable = (props: any) => { rowSelection={rowSelection} columns={props.columns} dataSource={dataSource} - /> ); }; diff --git a/src/components/dilog/index.tsx b/src/components/dilog/index.tsx index 5e734a1..fdbedef 100644 --- a/src/components/dilog/index.tsx +++ b/src/components/dilog/index.tsx @@ -34,7 +34,7 @@ const Dilog = (props: DilogModel) => { document.documentElement.removeEventListener("click", onClick); document.documentElement.removeEventListener("keydown", handleKeyword); }; - }, [props.show]); + }, [props, props.show]); const handleClose = () => { showState(false); props.close(); diff --git a/src/components/form/select.tsx b/src/components/form/select.tsx index a2001b8..89c065c 100644 --- a/src/components/form/select.tsx +++ b/src/components/form/select.tsx @@ -4,19 +4,19 @@ import { useState } from "react"; export const FormSelect = (v: FormDatas) => { const [list] = useState([ { - value: 1, + value: "1", label: "卡片一", }, { - value: 2, + value: "2", label: "卡片二", }, { - value: 3, + value: "3", label: "卡片三", }, { - value: 4, + value: "4", label: "卡片四", }, ]); diff --git a/src/hooks/mounted-status.ts b/src/hooks/mounted-status.ts new file mode 100644 index 0000000..8c632c1 --- /dev/null +++ b/src/hooks/mounted-status.ts @@ -0,0 +1,12 @@ +import { useEffect, useRef } from "react" + +// 判断组件挂载状态 +export const useMountedStatus = () => { + const status = useRef(false) + useEffect(() => { + status.current = true; + return ()=>{ + status.current = false; + } + }) +} \ No newline at end of file diff --git a/src/model/userModel.ts b/src/model/userModel.ts index fa87635..ea7e7bc 100644 --- a/src/model/userModel.ts +++ b/src/model/userModel.ts @@ -20,5 +20,4 @@ export interface UserDataType { startTime: any; endTime: any; status: any; - } \ No newline at end of file diff --git a/src/pages/card/card-list.tsx b/src/pages/card/card-list.tsx index c68be86..bdc8d42 100644 --- a/src/pages/card/card-list.tsx +++ b/src/pages/card/card-list.tsx @@ -117,6 +117,7 @@ const CardPageList = (props) => { ] const onFinish = (values: any) => { + values.cardType = `${values.cardType}`; if (!id) { cardStore.add(values); } else { diff --git a/src/store/baseStore.ts b/src/store/baseStore.ts index e706eca..9ee4aef 100644 --- a/src/store/baseStore.ts +++ b/src/store/baseStore.ts @@ -35,8 +35,8 @@ class BaseStore implements BaseStoreInterface { this.getlist() } // 分页 - setPages(page: Pages) { - this.page = page + setPages(params: Pages) { + this.page = params this.getlist() } // 添加 @@ -54,15 +54,11 @@ class BaseStore implements BaseStoreInterface { // 获取列表 async getlist() { let res = await baseHttp.get(this.urlConfig.LIST, { - pageNum: this.page?.PageNum | 1, - pageSize: this.page?.PageSize | 20, - isSelf:0 + pageIndex: this.page?.PageNum ?? 1, + pageSize: this.page?.PageSize ?? 20, + isSelf: 0 }); - - this.page = { - PageNum: res.data?.pageNum, - PageSize: res.data?.pageSize - } + console.log(this.page?.PageNum) let data: Array = [] if (!res.data.records) { runInAction(() => {