@hzab/list-render 0.0.12 → 0.0.13
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.
- package/CHANGELOG +32 -0
- package/README.md +0 -1
- package/lib/index.js +1 -1
- package/package.json +2 -3
- package/src/index.less +0 -3
- package/example/app.tsx +0 -19
- package/example/components/anbao-router/index.tsx +0 -47
- package/example/index.less +0 -3
- package/example/index.tsx +0 -8
- package/example/pages/index/grid-empty.schema.json +0 -201
- package/example/pages/index/grid.schema.json +0 -94
- package/example/pages/index/index.less +0 -5
- package/example/pages/index/index.tsx +0 -72
- package/example/pages/index/test.schema.json +0 -413
- package/example/router.ts +0 -3
- package/example/typings.d.ts +0 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzab/list-render",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib",
|
|
6
6
|
"scripts": {
|
|
@@ -12,8 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"lib",
|
|
15
|
-
"src"
|
|
16
|
-
"example"
|
|
15
|
+
"src"
|
|
17
16
|
],
|
|
18
17
|
"keywords": [],
|
|
19
18
|
"author": "CaiYansong",
|
package/src/index.less
CHANGED
package/example/app.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect } from "react";
|
|
2
|
-
import { HashRouter, useRoutes, useNavigate, useLocation } from "react-router-dom";
|
|
3
|
-
import { syncRouter } from "@/components/anbao-router";
|
|
4
|
-
|
|
5
|
-
import { Routes } from "./router";
|
|
6
|
-
|
|
7
|
-
const Main = () => useRoutes(syncRouter(Routes));
|
|
8
|
-
|
|
9
|
-
const App = () => {
|
|
10
|
-
return (
|
|
11
|
-
<>
|
|
12
|
-
<HashRouter>
|
|
13
|
-
<Main />
|
|
14
|
-
</HashRouter>
|
|
15
|
-
</>
|
|
16
|
-
);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default App;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Suspense, lazy } from "react";
|
|
2
|
-
import { Navigate } from "react-router-dom";
|
|
3
|
-
|
|
4
|
-
// 路由守卫方法
|
|
5
|
-
const syncRouter = (routeList: any) => {
|
|
6
|
-
let RouteTable: any = [];
|
|
7
|
-
routeList.map((item: any) => {
|
|
8
|
-
const routeObj = { ...item };
|
|
9
|
-
if (routeObj.path === undefined) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (routeObj.redirect) {
|
|
13
|
-
routeObj.element = <Navigate to={routeObj.redirect} replace={true} />;
|
|
14
|
-
}
|
|
15
|
-
if (routeObj.component) {
|
|
16
|
-
const Module = lazy(() => import("@/" + routeObj.component));
|
|
17
|
-
//TODO 页面loading
|
|
18
|
-
routeObj.element = (
|
|
19
|
-
<Suspense fallback={<></>}>
|
|
20
|
-
<Module />
|
|
21
|
-
</Suspense>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
if (routeObj.children) {
|
|
25
|
-
routeObj.children = syncRouter(item.children);
|
|
26
|
-
}
|
|
27
|
-
RouteTable.push(routeObj);
|
|
28
|
-
});
|
|
29
|
-
return RouteTable;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// 判断用户权限
|
|
33
|
-
const btnHasAuthority = (params: any) => {
|
|
34
|
-
let permission = false;
|
|
35
|
-
const userAuth = JSON.parse(window.sessionStorage.getItem("userAuthInfo") || "[]");
|
|
36
|
-
if (userAuth.indexOf(params) != -1) {
|
|
37
|
-
permission = true;
|
|
38
|
-
}
|
|
39
|
-
return permission;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// 按钮权限判断方法
|
|
43
|
-
const Access: any = (props: any) => {
|
|
44
|
-
return props.accessible ? props.children : null;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export { syncRouter, btnHasAuthority, Access };
|
package/example/index.less
DELETED
package/example/index.tsx
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"form": {
|
|
3
|
-
"labelCol": 6,
|
|
4
|
-
"wrapperCol": 12,
|
|
5
|
-
"style": {
|
|
6
|
-
"backgroundColor": "rgba(255,255,255,1)",
|
|
7
|
-
"width": "inherit"
|
|
8
|
-
},
|
|
9
|
-
"wrapperWidth": "inherit",
|
|
10
|
-
"feedbackLayout": null,
|
|
11
|
-
"bordered": true
|
|
12
|
-
},
|
|
13
|
-
"schema": {
|
|
14
|
-
"type": "object",
|
|
15
|
-
"properties": {
|
|
16
|
-
"06pny7e3bsi": {
|
|
17
|
-
"type": "void",
|
|
18
|
-
"x-component": "FormGrid",
|
|
19
|
-
"x-validator": [],
|
|
20
|
-
"x-component-props": {},
|
|
21
|
-
"x-designable-id": "06pny7e3bsi",
|
|
22
|
-
"x-index": 0,
|
|
23
|
-
"properties": {
|
|
24
|
-
"hcczyqc3nth": {
|
|
25
|
-
"type": "void",
|
|
26
|
-
"x-component": "FormGrid.GridColumn",
|
|
27
|
-
"x-validator": [],
|
|
28
|
-
"x-component-props": {},
|
|
29
|
-
"x-designable-id": "hcczyqc3nth",
|
|
30
|
-
"x-index": 0,
|
|
31
|
-
"properties": {
|
|
32
|
-
"name": {
|
|
33
|
-
"type": "string",
|
|
34
|
-
"title": "部门",
|
|
35
|
-
"x-decorator": "FormItem",
|
|
36
|
-
"x-component": "Input",
|
|
37
|
-
"x-validator": [],
|
|
38
|
-
"x-component-props": {
|
|
39
|
-
"placeholder": "请输入"
|
|
40
|
-
},
|
|
41
|
-
"x-decorator-props": {
|
|
42
|
-
"labelCol": null,
|
|
43
|
-
"labelWidth": "100px",
|
|
44
|
-
"wrapperWidth": "200px"
|
|
45
|
-
},
|
|
46
|
-
"x-designable-id": "bjdoighzdby",
|
|
47
|
-
"x-index": 0,
|
|
48
|
-
"name": "name"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
"xpspz1ka2tc": {
|
|
53
|
-
"type": "void",
|
|
54
|
-
"x-component": "FormGrid.GridColumn",
|
|
55
|
-
"x-validator": [],
|
|
56
|
-
"x-component-props": {},
|
|
57
|
-
"x-designable-id": "xpspz1ka2tc",
|
|
58
|
-
"x-index": 1,
|
|
59
|
-
"properties": {
|
|
60
|
-
"phone": {
|
|
61
|
-
"type": "string",
|
|
62
|
-
"title": "部门电话",
|
|
63
|
-
"x-decorator": "FormItem",
|
|
64
|
-
"x-component": "Input",
|
|
65
|
-
"x-validator": "number",
|
|
66
|
-
"x-component-props": {
|
|
67
|
-
"placeholder": "请输入"
|
|
68
|
-
},
|
|
69
|
-
"x-decorator-props": {
|
|
70
|
-
"labelCol": null,
|
|
71
|
-
"labelWidth": "100px",
|
|
72
|
-
"wrapperWidth": "200px"
|
|
73
|
-
},
|
|
74
|
-
"x-designable-id": "r1tiqra28bj",
|
|
75
|
-
"x-index": 0,
|
|
76
|
-
"name": "phone"
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
"zttstloy925": {
|
|
81
|
-
"type": "void",
|
|
82
|
-
"x-component": "FormGrid.GridColumn",
|
|
83
|
-
"x-validator": [],
|
|
84
|
-
"x-component-props": {},
|
|
85
|
-
"x-designable-id": "zttstloy925",
|
|
86
|
-
"x-index": 2,
|
|
87
|
-
"properties": {
|
|
88
|
-
"personCount": {
|
|
89
|
-
"type": "string",
|
|
90
|
-
"title": "部门人数",
|
|
91
|
-
"x-decorator": "FormItem",
|
|
92
|
-
"x-component": "Input",
|
|
93
|
-
"x-validator": "number",
|
|
94
|
-
"x-component-props": {
|
|
95
|
-
"placeholder": "请输入"
|
|
96
|
-
},
|
|
97
|
-
"x-decorator-props": {
|
|
98
|
-
"labelCol": null,
|
|
99
|
-
"labelWidth": "100px",
|
|
100
|
-
"wrapperWidth": "200px"
|
|
101
|
-
},
|
|
102
|
-
"x-designable-id": "kkgj015gds0",
|
|
103
|
-
"x-index": 0,
|
|
104
|
-
"name": "personCount"
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
"huf62mybhch": {
|
|
111
|
-
"type": "void",
|
|
112
|
-
"x-component": "FormGrid",
|
|
113
|
-
"x-validator": [],
|
|
114
|
-
"x-component-props": {},
|
|
115
|
-
"x-designable-id": "huf62mybhch",
|
|
116
|
-
"x-index": 1,
|
|
117
|
-
"properties": {
|
|
118
|
-
"y9qxn9ncxjn": {
|
|
119
|
-
"type": "void",
|
|
120
|
-
"x-component": "FormGrid.GridColumn",
|
|
121
|
-
"x-validator": [],
|
|
122
|
-
"x-component-props": {},
|
|
123
|
-
"x-designable-id": "y9qxn9ncxjn",
|
|
124
|
-
"x-index": 0,
|
|
125
|
-
"properties": {
|
|
126
|
-
"managerName": {
|
|
127
|
-
"type": "string",
|
|
128
|
-
"title": "负责人姓名",
|
|
129
|
-
"x-decorator": "FormItem",
|
|
130
|
-
"x-component": "Input",
|
|
131
|
-
"x-validator": [],
|
|
132
|
-
"x-component-props": {
|
|
133
|
-
"placeholder": "请输入"
|
|
134
|
-
},
|
|
135
|
-
"x-decorator-props": {
|
|
136
|
-
"labelCol": null,
|
|
137
|
-
"labelWidth": "100px",
|
|
138
|
-
"wrapperWidth": "200px"
|
|
139
|
-
},
|
|
140
|
-
"x-designable-id": "sipvij59cy2",
|
|
141
|
-
"x-index": 0,
|
|
142
|
-
"name": "managerName"
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
"4y62v6gt28k": {
|
|
147
|
-
"type": "void",
|
|
148
|
-
"x-component": "FormGrid.GridColumn",
|
|
149
|
-
"x-validator": [],
|
|
150
|
-
"x-component-props": {},
|
|
151
|
-
"x-designable-id": "4y62v6gt28k",
|
|
152
|
-
"x-index": 1,
|
|
153
|
-
"properties": {
|
|
154
|
-
"managerPhone": {
|
|
155
|
-
"type": "string",
|
|
156
|
-
"title": "联系方式",
|
|
157
|
-
"x-decorator": "FormItem",
|
|
158
|
-
"x-component": "Input",
|
|
159
|
-
"x-validator": "number",
|
|
160
|
-
"x-component-props": {
|
|
161
|
-
"placeholder": "请输入"
|
|
162
|
-
},
|
|
163
|
-
"x-decorator-props": {
|
|
164
|
-
"labelCol": null,
|
|
165
|
-
"labelWidth": "100px",
|
|
166
|
-
"wrapperWidth": "200px"
|
|
167
|
-
},
|
|
168
|
-
"x-designable-id": "plp3jrejyqe",
|
|
169
|
-
"x-index": 0,
|
|
170
|
-
"name": "managerPhone"
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
"1laypd415kh": {
|
|
175
|
-
"type": "void",
|
|
176
|
-
"x-component": "FormGrid.GridColumn",
|
|
177
|
-
"x-validator": [],
|
|
178
|
-
"x-component-props": {},
|
|
179
|
-
"x-designable-id": "1laypd415kh",
|
|
180
|
-
"x-index": 2
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
"remark": {
|
|
185
|
-
"type": "string",
|
|
186
|
-
"title": "备注",
|
|
187
|
-
"x-decorator": "FormItem",
|
|
188
|
-
"x-component": "Input.TextArea",
|
|
189
|
-
"x-validator": [],
|
|
190
|
-
"x-component-props": {},
|
|
191
|
-
"x-decorator-props": {
|
|
192
|
-
"labelWidth": "100px"
|
|
193
|
-
},
|
|
194
|
-
"x-designable-id": "bu40azwavly",
|
|
195
|
-
"x-index": 2,
|
|
196
|
-
"name": "remark"
|
|
197
|
-
}
|
|
198
|
-
},
|
|
199
|
-
"x-designable-id": "7j5r2paneta"
|
|
200
|
-
}
|
|
201
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"form": {
|
|
3
|
-
"labelCol": 6,
|
|
4
|
-
"wrapperCol": 12
|
|
5
|
-
},
|
|
6
|
-
"schema": {
|
|
7
|
-
"type": "object",
|
|
8
|
-
"properties": {
|
|
9
|
-
"n021si0md2k": {
|
|
10
|
-
"type": "void",
|
|
11
|
-
"x-component": "FormGrid",
|
|
12
|
-
"x-validator": [],
|
|
13
|
-
"x-component-props": {},
|
|
14
|
-
"x-designable-id": "n021si0md2k",
|
|
15
|
-
"x-index": 0,
|
|
16
|
-
"properties": {
|
|
17
|
-
"vtc56grqoq7": {
|
|
18
|
-
"type": "void",
|
|
19
|
-
"x-component": "FormGrid.GridColumn",
|
|
20
|
-
"x-designable-id": "vtc56grqoq7",
|
|
21
|
-
"x-index": 0,
|
|
22
|
-
"properties": {
|
|
23
|
-
"a": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"title": "a",
|
|
26
|
-
"x-decorator": "FormItem",
|
|
27
|
-
"x-component": "Input",
|
|
28
|
-
"x-validator": [],
|
|
29
|
-
"x-component-props": {},
|
|
30
|
-
"x-decorator-props": {},
|
|
31
|
-
"name": "a",
|
|
32
|
-
"x-designable-id": "ku66vyflkkq",
|
|
33
|
-
"x-index": 0
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
"hz6wmpqt5v9": {
|
|
38
|
-
"type": "void",
|
|
39
|
-
"x-component": "FormGrid.GridColumn",
|
|
40
|
-
"x-designable-id": "hz6wmpqt5v9",
|
|
41
|
-
"x-index": 1,
|
|
42
|
-
"properties": {
|
|
43
|
-
"b": {
|
|
44
|
-
"type": "string",
|
|
45
|
-
"title": "b",
|
|
46
|
-
"x-decorator": "FormItem",
|
|
47
|
-
"x-component": "Input",
|
|
48
|
-
"x-validator": [],
|
|
49
|
-
"x-component-props": {},
|
|
50
|
-
"x-decorator-props": {},
|
|
51
|
-
"name": "b",
|
|
52
|
-
"x-designable-id": "yxvv27p9cmm",
|
|
53
|
-
"x-index": 0
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"5pzldy9jksd": {
|
|
58
|
-
"type": "void",
|
|
59
|
-
"x-component": "FormGrid.GridColumn",
|
|
60
|
-
"x-designable-id": "5pzldy9jksd",
|
|
61
|
-
"x-index": 2,
|
|
62
|
-
"properties": {
|
|
63
|
-
"c": {
|
|
64
|
-
"type": "string",
|
|
65
|
-
"title": "c",
|
|
66
|
-
"x-decorator": "FormItem",
|
|
67
|
-
"x-component": "Input",
|
|
68
|
-
"x-validator": [],
|
|
69
|
-
"x-component-props": {},
|
|
70
|
-
"x-decorator-props": {},
|
|
71
|
-
"name": "c",
|
|
72
|
-
"x-designable-id": "621l8qog1wn",
|
|
73
|
-
"x-index": 0
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"createTime": {
|
|
80
|
-
"type": "string",
|
|
81
|
-
"title": "date",
|
|
82
|
-
"x-decorator": "FormItem",
|
|
83
|
-
"x-component": "DatePicker",
|
|
84
|
-
"x-validator": [],
|
|
85
|
-
"x-component-props": {},
|
|
86
|
-
"x-decorator-props": {},
|
|
87
|
-
"name": "createTime",
|
|
88
|
-
"x-designable-id": "iuge27ui3t7",
|
|
89
|
-
"x-index": 1
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
"x-designable-id": "f0ub742w09r"
|
|
93
|
-
}
|
|
94
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo } from "react";
|
|
2
|
-
|
|
3
|
-
import ListRender, { DataModel } from "@hzab/list-render";
|
|
4
|
-
|
|
5
|
-
import testSchema from "./test.schema.json";
|
|
6
|
-
import gridSchema from "./grid.schema.json";
|
|
7
|
-
|
|
8
|
-
import "./index.less";
|
|
9
|
-
|
|
10
|
-
const Index: any = () => {
|
|
11
|
-
const listDM = useMemo(
|
|
12
|
-
() =>
|
|
13
|
-
new DataModel({
|
|
14
|
-
getListApi: "/api/v1/userinfo",
|
|
15
|
-
getListFunc(query) {
|
|
16
|
-
console.log("query", query);
|
|
17
|
-
|
|
18
|
-
return new Promise((resolve) => {
|
|
19
|
-
resolve({
|
|
20
|
-
list: [{ id: 1, menuName: "name", parentId: "parentId", a: "a", b: "b", createTime: Date.now() }],
|
|
21
|
-
pagination: { total: 1, current: 1 },
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
},
|
|
25
|
-
createApi: "/api/v1/userinfo",
|
|
26
|
-
getApi: "/api/v1/userinfo/:id",
|
|
27
|
-
updateApi: "/api/v1/userinfo/:id",
|
|
28
|
-
deleteApi: "/api/v1/userinfo/:id",
|
|
29
|
-
}),
|
|
30
|
-
[],
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<div className="index">
|
|
35
|
-
1
|
|
36
|
-
<ListRender
|
|
37
|
-
filters={["menuName"]}
|
|
38
|
-
model={listDM}
|
|
39
|
-
schema={testSchema}
|
|
40
|
-
fetchOnEdit={false}
|
|
41
|
-
schemaScope={{
|
|
42
|
-
fetchMenuTree(field) {
|
|
43
|
-
// field 目标组件的 配置参数
|
|
44
|
-
console.log("fetchMenuTree field", field);
|
|
45
|
-
// 通过 field.component[1] 可以动态配置目标组件的 props
|
|
46
|
-
console.log("fetchMenuTree field.component[1]", field.component[1]);
|
|
47
|
-
// 树选择器 数据源
|
|
48
|
-
field.component[1].treeData = [{ value: 1, label: 1 }];
|
|
49
|
-
},
|
|
50
|
-
}}
|
|
51
|
-
/>
|
|
52
|
-
<ListRender
|
|
53
|
-
filters={["a"]}
|
|
54
|
-
model={listDM}
|
|
55
|
-
schema={gridSchema}
|
|
56
|
-
fetchOnEdit={false}
|
|
57
|
-
schemaScope={{
|
|
58
|
-
fetchMenuTree(field) {
|
|
59
|
-
// field 目标组件的 配置参数
|
|
60
|
-
console.log("fetchMenuTree field", field);
|
|
61
|
-
// 通过 field.component[1] 可以动态配置目标组件的 props
|
|
62
|
-
console.log("fetchMenuTree field.component[1]", field.component[1]);
|
|
63
|
-
// 树选择器 数据源
|
|
64
|
-
field.component[1].treeData = [{ value: 1, label: 1 }];
|
|
65
|
-
},
|
|
66
|
-
}}
|
|
67
|
-
/>
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
export default Index;
|