@hw-component/table 1.7.3 → 1.7.4

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.
@@ -1,91 +1,99 @@
1
1
  import { HTable, useHTable, HTableConfig } from "@/components";
2
- import { Button, Card, Tooltip ,Typography,Tag,Row} from "antd";
2
+ import { Button, Card, Tooltip, Typography, Tag, Row } from "antd";
3
3
  import { HFormConfigProvider } from "@hw-component/form";
4
4
  import { SettingOutlined } from "@ant-design/icons";
5
5
  import ProTable from "@ant-design/pro-table";
6
- import {useRequest} from "ahooks";
6
+ import { useRequest } from "ahooks";
7
7
 
8
- const TagsComponent=({data,labelKey})=>{
9
- const len=data?.length;
10
- if (!len){
11
- return <>-</>
8
+ const TagsComponent = ({ data, labelKey }) => {
9
+ const len = data?.length;
10
+ if (!len) {
11
+ return <>-</>;
12
12
  }
13
- console.log(data)
14
- return <>
15
- {data?.map((item, index) => {
16
- const label="483607ad55fc115ae45219f661248a42b6c40a487f95469b39ee49420a2dc";
17
- console.log(label.length)
18
- return (
19
- <Tag key={index} style={{width:120}}>
13
+ console.log(data);
14
+ return (
15
+ <>
16
+ {data?.map((item, index) => {
17
+ const label =
18
+ "483607ad55fc115ae45219f661248a42b6c40a487f95469b39ee49420a2dc";
19
+ console.log(label.length);
20
+ return (
21
+ <Tag key={index} style={{ width: 120 }}>
20
22
  <Typography.Text ellipsis copyable>
21
23
  {label}
22
24
  </Typography.Text>
23
25
  </Tag>
24
- );
25
- })}
26
- </>
27
- }
26
+ );
27
+ })}
28
+ </>
29
+ );
30
+ };
28
31
 
29
- export const configData =[
32
+ export const configData = [
30
33
  {
31
- title: '报警联系人名称',
34
+ title: "报警联系人名称",
32
35
  width: 120,
33
- dataIndex: 'name',
36
+ dataIndex: "name",
34
37
  valueType: "copy",
35
38
  valueTypeProps: {
36
- ellipsis:{
37
- rows:1,
38
- tooltip:true
39
- }
40
- }
39
+ ellipsis: {
40
+ rows: 1,
41
+ tooltip: true,
42
+ },
43
+ },
41
44
  },
42
45
  {
43
- title:"短信接收手机号",
44
- dataIndex: 'mobileList',
46
+ title: "短信接收手机号",
47
+ dataIndex: "mobileList",
45
48
  width: 120,
46
- valueType:"tags",
47
- valueTypeProps:{
48
- fieldNames:{
49
- label:"name"
50
- }
51
- }
49
+ valueType: "tags",
50
+ valueTypeProps: {
51
+ fieldNames: {
52
+ label: "name",
53
+ },
54
+ },
52
55
  },
53
56
  {
54
- title:"邮箱",
55
- dataIndex: 'mailList',
56
- valueType:"tags",
57
+ title: "邮箱",
58
+ dataIndex: "mailList",
59
+ valueType: "tags",
57
60
  width: 120,
58
61
  },
59
62
  {
60
- title: '悠哉公众号openid',
61
- dataIndex: 'openidList',
63
+ title: "悠哉公众号openid",
64
+ dataIndex: "openidList",
62
65
  width: 300,
63
66
  render: (_: any, data) => {
64
67
  const { openidList } = data;
65
- return <TagsComponent data={openidList}/>
68
+ return <TagsComponent data={openidList} />;
66
69
  },
67
70
  },
68
71
  {
69
- title: '钉钉机器人',
70
- dataIndex: 'dingdingList',
72
+ title: "钉钉机器人",
73
+ dataIndex: "dingdingList",
71
74
  width: 300,
72
- render:(_: any, data)=>{
75
+ render: (_: any, data) => {
73
76
  const { dingdingList } = data;
74
- const newList=dingdingList?.filter((item)=>{
75
- return typeof item !== 'string'
77
+ const newList = dingdingList?.filter((item) => {
78
+ return typeof item !== "string";
76
79
  });
77
- return <TagsComponent data={newList} labelKey="webhook"/>
78
- }
80
+ return <TagsComponent data={newList} labelKey="webhook" />;
81
+ },
79
82
  },
80
83
  {
81
- title:"操作",
82
- width:120,
83
- align: 'center',
84
- dataIndex:"op",
85
- render: (_: any, data: TableItemModal,index:number,tableInstance:HTableInstance) => {
86
- return <div></div>
84
+ title: "操作",
85
+ width: 120,
86
+ align: "center",
87
+ dataIndex: "op",
88
+ render: (
89
+ _: any,
90
+ data: TableItemModal,
91
+ index: number,
92
+ tableInstance: HTableInstance
93
+ ) => {
94
+ return <div />;
95
+ },
87
96
  },
88
- }
89
97
  ];
90
98
  const Test = ({ name, selectedRowData }) => {
91
99
  console.log(selectedRowData);
@@ -93,24 +101,24 @@ const Test = ({ name, selectedRowData }) => {
93
101
  };
94
102
  export default () => {
95
103
  const hTable = useHTable();
96
- const {loading,data}=useRequest(()=>{
97
- const arrayData:any[] = [];
104
+ const { loading, data } = useRequest(() => {
105
+ const arrayData: any[] = [];
98
106
  for (let i = 0; i < 1; i = i + 1) {
99
107
  arrayData.push({
100
- "id": i,
101
- "name": "仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人",
102
- "mobileList": null,
103
- "mailList": null,
104
- "openidList": [
105
- "okSMy58P_PE9sQkAG03gkpiTk-hs"
106
- ],
107
- "dingdingList": [
108
+ id: i,
109
+ name: "仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人",
110
+ mobileList: null,
111
+ mailList: null,
112
+ openidList: ["okSMy58P_PE9sQkAG03gkpiTk-hs"],
113
+ dingdingList: [
108
114
  {
109
- "webhook": "https://oapi.dingtalk.com/robot/send?access_token=fa1483607ad55fc115ae45219f661248a42b6c40a487f95469b39ee49420a2dc",
110
- "secretkey": "SEC1603b7a13fec76f6ec9e1eedbd44279f61b4298142d42616a4a672c245a37f3d"
111
- }
115
+ webhook:
116
+ "https://oapi.dingtalk.com/robot/send?access_token=fa1483607ad55fc115ae45219f661248a42b6c40a487f95469b39ee49420a2dc",
117
+ secretkey:
118
+ "SEC1603b7a13fec76f6ec9e1eedbd44279f61b4298142d42616a4a672c245a37f3d",
119
+ },
112
120
  ],
113
- "notifyAll": 0
121
+ notifyAll: 0,
114
122
  });
115
123
  }
116
124
  return new Promise((resolve, reject) => {
@@ -130,101 +138,100 @@ export default () => {
130
138
  >
131
139
  获取
132
140
  </div>
133
- <ProTable
141
+ <ProTable
134
142
  columns={configData}
135
- scroll={{x:1000}}
143
+ scroll={{ x: 1000 }}
136
144
  loading={loading}
137
145
  dataSource={data}
138
- />
139
- <HTable
140
- configData={configData}
141
-
142
- rowKey={(data, index) => {
143
- return index;
144
- }}
145
- table={hTable}
146
- onReset={() => {
147
- hTable.form.setFieldsValue({
148
- name1: "ffff",
146
+ />
147
+ <HTable
148
+ configData={configData}
149
+ rowKey={(rowData, index) => {
150
+ return index;
151
+ }}
152
+ table={hTable}
153
+ onReset={() => {
154
+ hTable.form.setFieldsValue({
155
+ name1: "ffff",
156
+ });
157
+ }}
158
+ hideLabel={false}
159
+ labelWidth={88}
160
+ action={{
161
+ test: (params) => {
162
+ console.log(params, "lllll");
163
+ },
164
+ }}
165
+ rowSelection={false}
166
+ affixProps={{
167
+ target: () => document.querySelector(".body"),
168
+ }}
169
+ scroll={{
170
+ x: 1000,
171
+ }}
172
+ columnsState={{
173
+ persistenceKey: "test",
174
+ persistenceType: "localStorage",
175
+ }}
176
+ formInitValues={{
177
+ name2: 1,
178
+ }}
179
+ tableExtraRender={() => {
180
+ return <div>ffff</div>;
181
+ }}
182
+ headerTitle={
183
+ <Button
184
+ type={"primary"}
185
+ onClick={() => {
186
+ console.log(hTable.table.getColSettingKeys());
187
+ }}
188
+ >
189
+ 操作
190
+ </Button>
191
+ }
192
+ request={(params) => {
193
+ const { current = 1, size = "10" } = params;
194
+ const arrayData: any[] = [];
195
+ for (let i = 0; i < 1; i = i + 1) {
196
+ arrayData.push({
197
+ id: i,
198
+ name: "仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人",
199
+ mobileList: [{ name: "1" }, { name: "2" }],
200
+ mailList: null,
201
+ openidList: ["okSMy58P_PE9sQkAG03gkpiTk-hs"],
202
+ dingdingList: [
203
+ {
204
+ webhook:
205
+ "https://oapi.dingtalk.com/robot/send?access_token=fa1483607ad55fc115ae45219f661248a42b6c40a487f95469b39ee49420a2dc",
206
+ secretkey:
207
+ "SEC1603b7a13fec76f6ec9e1eedbd44279f61b4298142d42616a4a672c245a37f3d",
208
+ },
209
+ ],
210
+ notifyAll: 0,
149
211
  });
150
- }}
151
- hideLabel={false}
152
- labelWidth={88}
153
- action={{
154
- test: (params) => {
155
- console.log(params, "lllll");
156
- },
157
- }}
158
- rowSelection={false}
159
- affixProps={{
160
- target: () => document.querySelector(".body"),
161
- }}
162
- scroll={{
163
- x: 1000,
164
- }}
165
- columnsState={{
166
- persistenceKey: "test",
167
- persistenceType: "localStorage",
168
- }}
169
- formInitValues={{
170
- name2: 1,
171
- }}
172
- tableExtraRender={()=>{
173
- return <div>ffff</div>
174
- }}
175
- headerTitle={
176
- <Button
177
- type={"primary"}
178
- onClick={() => {
179
- console.log(hTable.table.getColSettingKeys());
180
- }}
181
- >
182
- 操作
183
- </Button>
184
212
  }
185
- request={(params) => {
186
- const { current = 1, size = "10" } = params;
187
- const arrayData:any[] = [];
188
- for (let i = 0; i < 1; i = i + 1) {
189
- arrayData.push({
190
- "id": i,
191
- "name": "仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人仙人",
192
- "mobileList": [{name:"1"},{name:"2"}],
193
- "mailList": null,
194
- "openidList": [
195
- "okSMy58P_PE9sQkAG03gkpiTk-hs"
196
- ],
197
- "dingdingList": [
198
- {
199
- "webhook": "https://oapi.dingtalk.com/robot/send?access_token=fa1483607ad55fc115ae45219f661248a42b6c40a487f95469b39ee49420a2dc",
200
- "secretkey": "SEC1603b7a13fec76f6ec9e1eedbd44279f61b4298142d42616a4a672c245a37f3d"
201
- }
202
- ],
203
- "notifyAll": 0
213
+ return new Promise((resolve, reject) => {
214
+ setTimeout(() => {
215
+ // reject(new Error("错误"));
216
+ resolve({
217
+ size: size,
218
+ current: current.toString(10),
219
+ total: "1000",
220
+ records: arrayData,
204
221
  });
205
- }
206
- return new Promise((resolve, reject) => {
207
- setTimeout(() => {
208
- // reject(new Error("错误"));
209
- resolve({
210
- size: size,
211
- current: current.toString(10),
212
- total: "1000",
213
- records: arrayData,
214
- });
215
- }, 2000);
216
- });
217
- }}
218
- options={{
219
- settingRender: () => {
220
- return (
221
- <Tooltip title="321312312312321">
222
- <SettingOutlined width={24} />
223
- </Tooltip>
224
- );
225
- },
226
- }}
227
- />
222
+ }, 2000);
223
+ });
224
+ }}
225
+ options={{
226
+ settingRender: () => {
227
+ return (
228
+ <Tooltip title="321312312312321">
229
+ <SettingOutlined width={24} />
230
+ </Tooltip>
231
+ );
232
+ },
233
+ }}
234
+ />
228
235
  </div>
229
236
  </HFormConfigProvider>
230
237
  );