@hzab/list-render 1.12.5 → 1.12.6

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,293 +0,0 @@
1
- # 表单联动
2
-
3
- - 通过 配置响应器 实现
4
-
5
- #### 表单项显隐
6
-
7
- 1. Schema JSON 配置页面
8
- 2. 选中需要控制显隐的表单项
9
- 3. 点击属性配置 -> 字段属性 -> 配置响应器
10
- 4. 按需选择依赖字段 menuType(需要监听的字段,可根据该字段的值改变显隐状态)
11
- 5. 属性响应器 -> 显示/隐藏 -> 输入框中输入 $deps.menuType === 'C' ($deps 表示表单中的字段,$deps.menuType 表示监听 menuType 表单项,如果 menuType 的值为 'C' 时展示当前表单项,否时隐藏当前表单项(perms))
12
-
13
- - test.schema.json
14
-
15
- ```JSON
16
- {
17
- "form": {
18
- "labelCol": 6,
19
- "wrapperCol": 12
20
- },
21
- "schema": {
22
- "type": "object",
23
- "properties": {
24
- "menuType": {
25
- "type": "string | number",
26
- "title": "菜单类型",
27
- "x-decorator": "FormItem",
28
- "x-component": "Radio.Group",
29
- "enum": [
30
- {
31
- "children": [],
32
- "label": "目录",
33
- "value": "M"
34
- },
35
- {
36
- "children": [],
37
- "label": "菜单",
38
- "value": "C"
39
- },
40
- {
41
- "children": [],
42
- "label": "按钮",
43
- "value": "F"
44
- }
45
- ],
46
- "x-validator": [],
47
- "x-component-props": {},
48
- "x-decorator-props": {},
49
- "name": "menuType",
50
- "default": "M",
51
- "x-designable-id": "5gkoosg4b2k",
52
- "x-index": 0,
53
- "inTable": false
54
- },
55
- "perms": {
56
- "type": "string",
57
- "title": "权限字符",
58
- "x-decorator": "FormItem",
59
- "x-component": "Input",
60
- "x-validator": [],
61
- "x-component-props": {},
62
- "x-decorator-props": {},
63
- "name": "perms",
64
- "required": true,
65
- "x-designable-id": "xzy6veht5hc",
66
- "x-index": 1,
67
- "x-reactions": {
68
- "dependencies": [
69
- {
70
- "property": "value",
71
- "type": "string | number",
72
- "source": "menuType",
73
- "name": "menuType"
74
- }
75
- ],
76
- "fulfill": {
77
- "state": {
78
- "visible": "{{$deps.menuType === \"C\"}}"
79
- }
80
- }
81
- }
82
- }
83
- },
84
- "x-designable-id": "ivyw5onkhz8"
85
- }
86
- }
87
- ```
88
-
89
- #### 表单项数据
90
-
91
- ##### 根据其他表单项改变当前表单项数值
92
-
93
- ```JSON
94
- {
95
- "form": {},
96
- "schema": {
97
- "type": "object",
98
- "properties": {
99
- "test": {
100
- "type": "string",
101
- "title": "test",
102
- "x-decorator": "FormItem",
103
- "x-component": "Input",
104
- "x-validator": [],
105
- "x-component-props": {},
106
- "x-decorator-props": {},
107
- "x-reactions": {},
108
- "x-designable-id": "1zlm9bu3fpg",
109
- "x-index": 0,
110
- "name": "test",
111
- "x-display": "visible"
112
- },
113
- "watch": {
114
- "type": "string",
115
- "title": "watch",
116
- "x-decorator": "FormItem",
117
- "x-component": "Input",
118
- "x-validator": [],
119
- "x-component-props": {},
120
- "x-decorator-props": {},
121
- "name": "watch",
122
- "x-reactions": {
123
- "dependencies": [
124
- {
125
- "property": "value",
126
- "type": "string",
127
- "source": "test",
128
- "name": "test"
129
- }
130
- ],
131
- "fulfill": {
132
- "state": {
133
- "value": "{{$deps.test + 10}}"
134
- }
135
- }
136
- },
137
- "x-designable-id": "ri912mmvcz2",
138
- "x-index": 1
139
- }
140
- },
141
- "x-designable-id": "ldzb3lu81dx"
142
- }
143
- }
144
- ```
145
-
146
- ##### 根据其他表单项改变当前 select 数据
147
-
148
- ```JSX
149
- // RemoteData
150
- import listSchema from "./list.schema.json";
151
-
152
- const schemaScope = {
153
- // 动态获取 select 数据
154
- fetchSelectOptions(field, query) {
155
- field.loading = true;
156
- fetch(
157
- `//some.domain/getSomething?test=${query.test}`
158
- )
159
- .then((response) => response.json())
160
- .then(
161
- ({ data }) => {
162
- // field 目标组件的 配置参数
163
- console.log("fetchSelectOptions field", field);
164
- // 通过 select 可直接通过 field.dataSource 进行选项数据的配置
165
- field.dataSource = data;
166
- field.loading = false;
167
- },
168
- () => {
169
- field.loading = false;
170
- }
171
- );
172
- },
173
- // 动态获取 treeSelect 数据
174
- fetchMenuTree(field, query) {
175
- field.loading = true;
176
- fetch(
177
- `//some.domain/getSomething?test=${query.test}`
178
- )
179
- .then((response) => response.json())
180
- .then(
181
- ({ data }) => {
182
- // field 目标组件的 配置参数
183
- console.log("fetchMenuTree field", field);
184
- // 通过 field.component[1] 可以动态配置目标组件的 props
185
- console.log("fetchMenuTree field.component[1]", field.component[1]);
186
- // 树选择器 数据源,需要通过 field.component[1] 进行配置
187
- field.component[1].treeData = data;
188
- field.loading = false;
189
- },
190
- () => {
191
- field.loading = false;
192
- }
193
- );
194
- },
195
- };
196
-
197
- function RemoteData() {
198
- const listDM = useMemo(
199
- () =>
200
- new DataModule({
201
- getListApi: "/api/v1/user/list",
202
- getApi: "/api/v1/user/list/:id",
203
- createApi: "/api/v1/user/list",
204
- updateApi: "/api/v1/user/list/:id",
205
- deleteApi: "/api/v1/user/list/:id",
206
- }),
207
- []
208
- );
209
- return (
210
- <ListRender model={listDM} schema={listSchema} schemaScope={schemaScope} />
211
- );
212
- }
213
-
214
- export default RemoteData;
215
-
216
- ```
217
-
218
- ```JSON
219
- {
220
- "form": {
221
- "labelCol": 6,
222
- "wrapperCol": 12
223
- },
224
- "schema": {
225
- "type": "object",
226
- "properties": {
227
- "test": {
228
- "type": "string",
229
- "title": "test",
230
- "x-decorator": "FormItem",
231
- "x-component": "Input",
232
- "x-validator": [],
233
- "x-component-props": {},
234
- "x-decorator-props": {},
235
- "x-reactions": {},
236
- "x-designable-id": "1zlm9bu3fpg",
237
- "x-index": 0,
238
- "name": "test",
239
- "x-display": "visible"
240
- },
241
- "watch": {
242
- "title": "watch",
243
- "x-decorator": "FormItem",
244
- "x-component": "Select",
245
- "x-validator": [],
246
- "x-component-props": {},
247
- "x-decorator-props": {},
248
- "name": "watch",
249
- "x-designable-id": "jvjf7fkpke9",
250
- "x-index": 1,
251
- "x-reactions": {
252
- "dependencies": [
253
- {
254
- "property": "value",
255
- "type": "string",
256
- "source": "test",
257
- "name": "test"
258
- }
259
- ],
260
- "fulfill": {
261
- "run": "$effect(() => {\n try {\n fetchSelectOptions && fetchSelectOptions($self, { test: $deps.test })\n } catch (e) {}\n}, [$deps.test])\n"
262
- }
263
- }
264
- },
265
- "treeSelect": {
266
- "title": "TreeSelect",
267
- "x-decorator": "FormItem",
268
- "x-component": "TreeSelect",
269
- "x-validator": [],
270
- "x-component-props": {},
271
- "x-decorator-props": {},
272
- "x-designable-id": "303l866v0lj",
273
- "x-index": 2,
274
- "name": "treeSelect",
275
- "x-reactions": {
276
- "dependencies": [
277
- {
278
- "property": "value",
279
- "type": "string",
280
- "source": "test",
281
- "name": "test"
282
- }
283
- ],
284
- "fulfill": {
285
- "run": "$effect(() => {\r\n try {\r\n fetchMenuTree && fetchMenuTree($self, { test: $deps.test })\r\n } catch (e) {}\r\n}, [$deps.test])\r\n"
286
- }
287
- }
288
- }
289
- },
290
- "x-designable-id": "ldzb3lu81dx"
291
- }
292
- }
293
- ```
@@ -1,124 +0,0 @@
1
- # 远程数据源
2
-
3
- #### select 数据源
4
-
5
- - RemoteData.jsx
6
-
7
- ```JSX
8
- // RemoteData
9
- import listSchema from "./list.schema.json";
10
-
11
- const schemaScope = {
12
- // 动态获取 select 数据
13
- fetchSelectOptions(field, query) {
14
- field.loading = true;
15
- fetch(
16
- `//some.domain/getSomething?test=${query.test}`
17
- )
18
- .then((response) => response.json())
19
- .then(
20
- ({ data }) => {
21
- // field 目标组件的 配置参数
22
- console.log("fetchSelectOptions field", field);
23
- // 通过 select 可直接通过 field.dataSource 进行选项数据的配置
24
- field.dataSource = data;
25
- field.loading = false;
26
- },
27
- () => {
28
- field.loading = false;
29
- }
30
- );
31
- },
32
- // 动态获取 treeSelect 数据
33
- fetchMenuTree(field, query) {
34
- field.loading = true;
35
- fetch(
36
- `//some.domain/getSomething?test=${query.test}`
37
- )
38
- .then((response) => response.json())
39
- .then(
40
- ({ data }) => {
41
- // field 目标组件的 配置参数
42
- console.log("fetchMenuTree field", field);
43
- // 通过 field.component[1] 可以动态配置目标组件的 props
44
- console.log("fetchMenuTree field.component[1]", field.component[1]);
45
- // 树选择器 数据源,需要通过 field.component[1] 进行配置
46
- field.component[1].treeData = data;
47
- field.loading = false;
48
- },
49
- () => {
50
- field.loading = false;
51
- }
52
- );
53
- },
54
- };
55
-
56
- function RemoteData() {
57
- const listDM = useMemo(
58
- () =>
59
- new DataModule({
60
- getListApi: "/api/v1/user/list",
61
- getApi: "/api/v1/user/list/:id",
62
- createApi: "/api/v1/user/list",
63
- updateApi: "/api/v1/user/list/:id",
64
- deleteApi: "/api/v1/user/list/:id",
65
- }),
66
- []
67
- );
68
- return (
69
- <ListRender model={listDM} schema={listSchema} schemaScope={schemaScope} />
70
- );
71
- }
72
-
73
- export default RemoteData;
74
-
75
- ```
76
-
77
- - list.schema.json
78
-
79
- ```JSON
80
- {
81
- "form": {},
82
- "schema": {
83
- "type": "object",
84
- "properties": {
85
- "parentId": {
86
- "type": "string",
87
- "title": "上级菜单",
88
- "x-decorator": "FormItem",
89
- "x-component": "TreeSelect",
90
- "x-validator": [],
91
- "x-component-props": {},
92
- "x-decorator-props": {},
93
- "x-reactions": {
94
- "fulfill": {
95
- "run": "try {fetchMenuTree && fetchMenuTree($self);}catch(e){}"
96
- }
97
- },
98
- "name": "parentId",
99
- "x-designable-id": "i012z5nbd5z",
100
- "x-index": 0
101
- },
102
- "select": {
103
- "title": "select",
104
- "x-decorator": "FormItem",
105
- "x-component": "Select",
106
- "x-validator": [],
107
- "x-component-props": {},
108
- "x-decorator-props": {},
109
- "name": "select",
110
- "x-designable-id": "jvjf7fkpke9",
111
- "x-index": 1,
112
- "x-reactions": {
113
- "dependencies": [],
114
- "fulfill": {
115
- "run": "$effect(() => {\n try {\n fetchSelectOptions && fetchSelectOptions($self);\n } catch (e) {}\n}, [])\n"
116
- }
117
- }
118
- }
119
- },
120
- "x-designable-id": "ldzb3lu81dx"
121
- }
122
- }
123
-
124
- ```
package/docs/table.md DELETED
@@ -1,86 +0,0 @@
1
- # 表格相关
2
-
3
- ## query 相关
4
-
5
- #### 设置过滤项
6
-
7
- ```JSX
8
- <ListRender
9
- schema={schema}
10
- model={listDM}
11
- // 字段为 search 的 query
12
- search="模糊搜索"
13
- // 传入 schema 中所需表单项的 name
14
- filters={["userId"]}
15
- />
16
- ```
17
-
18
- #### 开启重置按钮
19
-
20
- ```JSX
21
- <ListRender
22
- schema={schema}
23
- model={listDM}
24
- // 字段为 search 的 query
25
- search="模糊搜索"
26
- // 传入 schema 中所需表单项的 name
27
- filters={["userId"]}
28
- queryConf={{
29
- hasReset: true
30
- }}
31
- />
32
- ```
33
-
34
- ## 顶部操作栏(新增按钮附近)
35
-
36
- #### 新增按钮右侧添加其他组件
37
-
38
- - 使用 Slots 实现
39
-
40
- ```JSX
41
- const Slots = {
42
- headerActionSuffix() {
43
- return (<div>headerActionPrefix</div>)
44
- },
45
- };
46
-
47
- <ListRender schema={schema} model={listDM} Slots={Slots} />
48
- ```
49
-
50
- ## table 相关
51
-
52
- #### 手动发起请求
53
-
54
- ```JSX
55
-
56
- // 手动发起请求
57
- useEffect(() => {
58
- // 重置 pageNum 为1,并发起请求
59
- listRef.current?.onSearch();
60
- // 请求当前页数据
61
- listRef.current?.getList();
62
- }, []);
63
-
64
- <ListRender
65
- ref={listRef}
66
- schema={schema}
67
- model={listDM}
68
- // 关闭自动发起请求
69
- closeAutoRequest={false}
70
- />
71
- ```
72
-
73
- #### 编辑按钮左侧添加组件
74
-
75
- ```JSX
76
- const Slots = {
77
- actionPrefixSlot(props) {
78
- const { text, record, index, onEdit, onDel } = props;
79
- return (<div>actionPrefixSlot</div>)
80
- },
81
- };
82
-
83
- <ListRender schema={schema} model={listDM} Slots={Slots} />
84
- ```
85
-
86
- ## 新增、编辑表单相关