@hw-component/table 1.9.34 → 1.9.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,14 +7,18 @@ import React, { useState } from "react";
7
7
  import type { AffixProps } from "antd/lib/affix";
8
8
  import GoTop from "../GoTop";
9
9
  import { useHTableConfigContext } from "@/components/TableConfig";
10
- export interface IPaginationProps extends PaginationProps {
10
+ export interface IPaginationProps extends Omit<PaginationProps, "showTotal"> {
11
11
  onPageChange?: (params: ParamsModal) => void;
12
12
  paginationStyle?: React.CSSProperties;
13
13
  affixProps?: AffixProps | false;
14
14
  goTop?: boolean;
15
15
  actionRender?: (tableInstance: HTableInstance) => React.ReactNode;
16
16
  table?: HTableInstance;
17
+ showTotal?: false | PaginationProps["showTotal"];
17
18
  }
19
+ const defaultShowTotal = (totalNum: number, [showCurrent, showCurrentEnd]) => {
20
+ return `第${showCurrent}-${showCurrentEnd}/总共${totalNum}条`;
21
+ };
18
22
  export default ({
19
23
  onPageChange,
20
24
  paginationStyle,
@@ -22,6 +26,7 @@ export default ({
22
26
  goTop,
23
27
  actionRender,
24
28
  table,
29
+ showTotal = defaultShowTotal,
25
30
  ...props
26
31
  }: IPaginationProps) => {
27
32
  const {
@@ -40,6 +45,7 @@ export default ({
40
45
  const pageTotal = Number.parseInt(total || "0", 10);
41
46
  const className = useClassName("hw-table-pagination");
42
47
  const [style, setStyle] = useState({});
48
+ const cuShowTotal = showTotal === false ? undefined : showTotal;
43
49
  if (!data) {
44
50
  return <></>;
45
51
  }
@@ -57,9 +63,7 @@ export default ({
57
63
  showQuickJumper={true}
58
64
  pageSize={pageSize}
59
65
  current={pageCurrent}
60
- showTotal={(totalNum, [showCurrent, showCurrentEnd]) => {
61
- return `第${showCurrent}-${showCurrentEnd}/总共${totalNum}条`;
62
- }}
66
+ showTotal={cuShowTotal}
63
67
  total={pageTotal}
64
68
  onChange={(pn, ps) => {
65
69
  tableOnPageChange({ size: ps, current: pn });
@@ -97,9 +101,7 @@ export default ({
97
101
  showQuickJumper={true}
98
102
  pageSize={pageSize}
99
103
  current={pageCurrent}
100
- showTotal={(totalNum, [showCurrent, showCurrentEnd]) => {
101
- return `第${showCurrent}-${showCurrentEnd}/总共${totalNum}条`;
102
- }}
104
+ showTotal={cuShowTotal}
103
105
  total={pageTotal}
104
106
  onChange={(pn, ps) => {
105
107
  tableOnPageChange({ size: ps, current: pn });
@@ -31,8 +31,8 @@ export default ({
31
31
  style,
32
32
  dataSource,
33
33
  reload,
34
- loading:propsLoading,
35
- error:propsError,
34
+ loading: propsLoading,
35
+ error: propsError,
36
36
  ...props
37
37
  }: HTableProps) => {
38
38
  const { run, loading, data, error, saveParams } = useReq({
@@ -72,8 +72,8 @@ export default ({
72
72
  selectedRowData,
73
73
  rowOnChange,
74
74
  data,
75
- error:propsError||error,
76
- loading:(propsLoading as boolean)||loading,
75
+ error: propsError || error,
76
+ loading: (propsLoading as boolean) || loading,
77
77
  allSelectChange,
78
78
  action,
79
79
  configData,
@@ -12,6 +12,7 @@ import type { AffixProps } from "antd/lib/affix";
12
12
  import type { OptionModal } from "./HTableBody";
13
13
  import { GetRowKey } from "rc-table/lib/interface";
14
14
  import type { DrawerProps } from "antd";
15
+ import type { IPaginationProps } from "@/components/HTablePagination";
15
16
 
16
17
  export interface RowObj {
17
18
  keys?: React.Key[];
@@ -76,7 +77,7 @@ export type HRowSelection = RowSelectionOuter &
76
77
  export interface HTableProps
77
78
  extends Omit<
78
79
  ProTableProps<any, any>,
79
- "request" | "dataSource" | "rowSelection"
80
+ "request" | "dataSource" | "rowSelection" | "pagination"
80
81
  > {
81
82
  request?: (params: ParamsModal) => Promise<ResultModal>;
82
83
  configData: ConfigDataModal;
@@ -112,6 +113,7 @@ export interface HTableProps
112
113
  labelWidth?: number;
113
114
  hideLabel?: boolean;
114
115
  options?: OptionModal | false;
116
+ pagination?: IPaginationProps;
115
117
  }
116
118
  interface ColCheckResultKeys {
117
119
  keys?: string[];
@@ -69,6 +69,10 @@ const linkRender = (config: ConfigItemModal, itemData: any) => {
69
69
  if (typeof href === "function") {
70
70
  hrefUrl = href(itemData);
71
71
  }
72
+ const relUrl=hrefUrl||tableVal;
73
+ if (!relUrl){
74
+ return "-"
75
+ }
72
76
  return (
73
77
  <Link
74
78
  href={hrefUrl || tableVal}
@@ -138,11 +138,6 @@ export default () => {
138
138
  onClick={() => {
139
139
  dialogTable.show({
140
140
  title: "3333",
141
- dataSource: [
142
- ...maker("第一页"),
143
- ...maker("第二页"),
144
- ...maker("第三页"),
145
- ],
146
141
  });
147
142
  }}
148
143
  >
@@ -152,6 +147,15 @@ export default () => {
152
147
  dialogTable={dialogTable}
153
148
  width={1200}
154
149
  configData={configData}
150
+ request={(value) => {
151
+ console.log(value);
152
+ return {
153
+ records: maker("第一页"),
154
+ size: 10,
155
+ current: 1,
156
+ total: "100",
157
+ };
158
+ }}
155
159
  tableProps={{
156
160
  headerTitle: (
157
161
  <div
@@ -1,4 +1,9 @@
1
- import {HTable, useHTable, HTableConfig, HTableHeaderSubBtn} from "@/components";
1
+ import {
2
+ HTable,
3
+ useHTable,
4
+ HTableConfig,
5
+ HTableHeaderSubBtn,
6
+ } from "@/components";
2
7
  import { Button, Card, Tooltip, Typography, Tag, Row } from "antd";
3
8
  import { HFormConfigProvider } from "@hw-component/form";
4
9
  import { SettingOutlined } from "@ant-design/icons";
@@ -169,7 +174,7 @@ export default () => {
169
174
  <HTable
170
175
  configData={configData}
171
176
  searchSpan={{
172
- span:24
177
+ span: 24,
173
178
  }}
174
179
  rowKey={(rowData, index) => {
175
180
  return index;
@@ -182,7 +187,7 @@ export default () => {
182
187
  },
183
188
  }}
184
189
  rowSelection={{
185
- allPageCheck:false
190
+ allPageCheck: false,
186
191
  }}
187
192
  affixProps={{
188
193
  target: () => document.querySelector(".body"),