@hzab/list-render 0.0.10 → 0.0.12

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.
@@ -0,0 +1,413 @@
1
+ {
2
+ "form": {
3
+ "labelCol": 6,
4
+ "wrapperCol": 12
5
+ },
6
+ "schema": {
7
+ "type": "object",
8
+ "properties": {
9
+ "parentId": {
10
+ "type": "string",
11
+ "title": "上级菜单",
12
+ "x-decorator": "FormItem",
13
+ "x-component": "TreeSelect",
14
+ "x-validator": [],
15
+ "x-component-props": {
16
+ "virtual": true,
17
+ "allowClear": true,
18
+ "showSearch": true
19
+ },
20
+ "x-decorator-props": {},
21
+ "x-reactions": {
22
+ "dependencies": [
23
+ {
24
+ "property": "value",
25
+ "type": "any"
26
+ }
27
+ ],
28
+ "fulfill": {
29
+ "run": "fetchMenuTree($self);"
30
+ }
31
+ },
32
+ "name": "parentId",
33
+ "x-designable-id": "i012z5nbd5z",
34
+ "x-index": 0,
35
+ "inTable": false
36
+ },
37
+ "menuType": {
38
+ "type": "string | number",
39
+ "title": "菜单类型",
40
+ "x-decorator": "FormItem",
41
+ "x-component": "Radio.Group",
42
+ "enum": [
43
+ {
44
+ "children": [],
45
+ "label": "目录",
46
+ "value": "M"
47
+ },
48
+ {
49
+ "children": [],
50
+ "label": "菜单",
51
+ "value": "C"
52
+ },
53
+ {
54
+ "children": [],
55
+ "label": "按钮",
56
+ "value": "F"
57
+ }
58
+ ],
59
+ "x-validator": [],
60
+ "x-component-props": {},
61
+ "x-decorator-props": {},
62
+ "name": "menuType",
63
+ "default": "M",
64
+ "x-designable-id": "5gkoosg4b2k",
65
+ "x-index": 1,
66
+ "inTable": false
67
+ },
68
+ "menuName": {
69
+ "type": "string",
70
+ "title": "菜单名称",
71
+ "x-decorator": "FormItem",
72
+ "x-component": "Input",
73
+ "x-validator": [],
74
+ "x-component-props": {},
75
+ "x-decorator-props": {},
76
+ "name": "menuName",
77
+ "required": true,
78
+ "x-designable-id": "erhrbrarqx1",
79
+ "x-index": 2
80
+ },
81
+ "icon": {
82
+ "title": "菜单图标",
83
+ "x-decorator": "FormItem",
84
+ "x-component": "IconSelect",
85
+ "x-validator": [],
86
+ "x-component-props": {},
87
+ "x-decorator-props": {},
88
+ "name": "icon",
89
+ "x-designable-id": "60d4sdrm3qs",
90
+ "x-index": 3,
91
+ "x-reactions": {
92
+ "dependencies": [
93
+ {
94
+ "property": "value",
95
+ "type": "string | number",
96
+ "source": "menuType",
97
+ "name": "menuType"
98
+ }
99
+ ],
100
+ "fulfill": {
101
+ "state": {
102
+ "visible": "{{$deps.menuType === \"M\" || $deps.menuType === \"C\"}}"
103
+ }
104
+ }
105
+ }
106
+ },
107
+ "perms": {
108
+ "type": "string",
109
+ "title": "权限字符",
110
+ "x-decorator": "FormItem",
111
+ "x-component": "Input",
112
+ "x-validator": [],
113
+ "x-component-props": {},
114
+ "x-decorator-props": {},
115
+ "name": "perms",
116
+ "required": true,
117
+ "x-designable-id": "xzy6veht5hc",
118
+ "x-index": 4,
119
+ "x-reactions": {
120
+ "dependencies": [
121
+ {
122
+ "property": "value",
123
+ "type": "string | number",
124
+ "source": "menuType",
125
+ "name": "menuType"
126
+ }
127
+ ],
128
+ "fulfill": {
129
+ "state": {
130
+ "visible": "{{$deps.menuType === \"C\" || $deps.menuType === \"F\"}}"
131
+ }
132
+ }
133
+ }
134
+ },
135
+ "orderNum": {
136
+ "type": "number",
137
+ "title": "显示顺序",
138
+ "x-decorator": "FormItem",
139
+ "x-component": "NumberPicker",
140
+ "x-validator": [],
141
+ "x-component-props": {
142
+ "min": 0
143
+ },
144
+ "x-decorator-props": {},
145
+ "name": "orderNum",
146
+ "required": true,
147
+ "x-designable-id": "i80818uuteh",
148
+ "x-index": 5,
149
+ "default": 0
150
+ },
151
+ "path": {
152
+ "type": "string",
153
+ "title": "路由地址",
154
+ "x-decorator": "FormItem",
155
+ "x-component": "Input",
156
+ "x-validator": [],
157
+ "x-component-props": {},
158
+ "x-decorator-props": {},
159
+ "name": "path",
160
+ "x-designable-id": "o0v8c0vfqjk",
161
+ "x-index": 6,
162
+ "required": true,
163
+ "x-reactions": {
164
+ "dependencies": [
165
+ {
166
+ "property": "value",
167
+ "type": "string | number",
168
+ "source": "menuType",
169
+ "name": "menuType"
170
+ }
171
+ ],
172
+ "fulfill": {
173
+ "state": {
174
+ "visible": "{{$deps.menuType === \"M\" || $deps.menuType === \"C\"}}"
175
+ }
176
+ }
177
+ },
178
+ "inTable": false
179
+ },
180
+ "component": {
181
+ "type": "string",
182
+ "title": "组件路径",
183
+ "x-decorator": "FormItem",
184
+ "x-component": "Input",
185
+ "x-validator": [],
186
+ "x-component-props": {},
187
+ "x-decorator-props": {},
188
+ "name": "component",
189
+ "x-designable-id": "zehls3l7dll",
190
+ "x-index": 7,
191
+ "x-reactions": {
192
+ "dependencies": [
193
+ {
194
+ "property": "value",
195
+ "type": "string | number",
196
+ "source": "menuType",
197
+ "name": "menuType"
198
+ }
199
+ ],
200
+ "fulfill": {
201
+ "state": {
202
+ "visible": "{{$deps.menuType === \"C\"}}"
203
+ }
204
+ }
205
+ }
206
+ },
207
+ "uri": {
208
+ "type": "string",
209
+ "title": "接口地址",
210
+ "x-decorator": "FormItem",
211
+ "x-component": "Input",
212
+ "x-validator": [],
213
+ "x-component-props": {},
214
+ "x-decorator-props": {},
215
+ "name": "uri",
216
+ "x-designable-id": "ulom9944kd8",
217
+ "x-index": 8,
218
+ "x-reactions": {
219
+ "dependencies": [
220
+ {
221
+ "property": "value",
222
+ "type": "string | number",
223
+ "source": "menuType",
224
+ "name": "menuType"
225
+ }
226
+ ],
227
+ "fulfill": {
228
+ "state": {
229
+ "visible": "{{$deps.menuType === \"C\" || $deps.menuType === \"F\"}}"
230
+ }
231
+ }
232
+ }
233
+ },
234
+ "methodType": {
235
+ "title": "接口类型",
236
+ "x-decorator": "FormItem",
237
+ "x-component": "Select",
238
+ "x-validator": [],
239
+ "x-component-props": {},
240
+ "x-decorator-props": {},
241
+ "name": "methodType",
242
+ "enum": [
243
+ {
244
+ "children": [],
245
+ "label": "GET",
246
+ "value": "GET"
247
+ },
248
+ {
249
+ "children": [],
250
+ "label": "POST",
251
+ "value": "POST"
252
+ },
253
+ {
254
+ "children": [],
255
+ "label": "PUT",
256
+ "value": "PUT"
257
+ },
258
+ {
259
+ "children": [],
260
+ "label": "DELETE",
261
+ "value": "DELETE"
262
+ }
263
+ ],
264
+ "x-designable-id": "xmz4afzft5x",
265
+ "x-index": 9,
266
+ "x-reactions": {
267
+ "dependencies": [
268
+ {
269
+ "property": "value",
270
+ "type": "string | number",
271
+ "source": "menuType",
272
+ "name": "menuType"
273
+ }
274
+ ],
275
+ "fulfill": {
276
+ "state": {
277
+ "visible": "{{$deps.menuType === \"F\"}}"
278
+ }
279
+ }
280
+ }
281
+ },
282
+ "isApp": {
283
+ "type": "string | number",
284
+ "title": "Radio Group",
285
+ "x-decorator": "FormItem",
286
+ "x-component": "Radio.Group",
287
+ "enum": [
288
+ {
289
+ "children": [],
290
+ "label": "PC",
291
+ "value": 2
292
+ },
293
+ {
294
+ "children": [],
295
+ "label": "APP",
296
+ "value": 1
297
+ }
298
+ ],
299
+ "x-validator": [],
300
+ "x-component-props": {},
301
+ "x-decorator-props": {},
302
+ "name": "isApp",
303
+ "default": 2,
304
+ "x-designable-id": "qhc88vi0ktu",
305
+ "x-index": 10
306
+ },
307
+ "visible": {
308
+ "type": "string | number",
309
+ "title": "显示状态",
310
+ "x-decorator": "FormItem",
311
+ "x-component": "Radio.Group",
312
+ "enum": [
313
+ {
314
+ "children": [],
315
+ "label": "显示",
316
+ "value": "0"
317
+ },
318
+ {
319
+ "children": [],
320
+ "label": "隐藏",
321
+ "value": "1"
322
+ }
323
+ ],
324
+ "x-validator": [],
325
+ "x-component-props": {},
326
+ "x-decorator-props": {},
327
+ "name": "visible",
328
+ "default": "0",
329
+ "x-designable-id": "flai9y0hhzq",
330
+ "x-index": 11,
331
+ "x-reactions": {
332
+ "dependencies": [
333
+ {
334
+ "property": "value",
335
+ "type": "string | number",
336
+ "source": "menuType",
337
+ "name": "menuType"
338
+ }
339
+ ],
340
+ "fulfill": {
341
+ "state": {
342
+ "visible": "{{$deps.menuType === \"M\" || $deps.menuType === \"C\"}}"
343
+ }
344
+ }
345
+ },
346
+ "inTable": false
347
+ },
348
+ "status": {
349
+ "type": "string | number",
350
+ "title": "菜单状态",
351
+ "x-decorator": "FormItem",
352
+ "x-component": "Radio.Group",
353
+ "enum": [
354
+ {
355
+ "children": [],
356
+ "label": "正常",
357
+ "value": "0"
358
+ },
359
+ {
360
+ "children": [],
361
+ "label": "停用",
362
+ "value": "1"
363
+ }
364
+ ],
365
+ "x-validator": [],
366
+ "x-component-props": {},
367
+ "x-decorator-props": {},
368
+ "name": "status",
369
+ "default": "0",
370
+ "x-designable-id": "nbs8lv4pcoe",
371
+ "x-index": 12,
372
+ "x-reactions": {
373
+ "dependencies": [
374
+ {
375
+ "property": "value",
376
+ "type": "string | number",
377
+ "source": "menuType",
378
+ "name": "menuType"
379
+ }
380
+ ]
381
+ }
382
+ },
383
+ "text": {
384
+ "type": "string",
385
+ "title": "Text",
386
+ "x-decorator": "FormItem",
387
+ "x-component": "Text",
388
+ "x-validator": [],
389
+ "x-component-props": {},
390
+ "x-decorator-props": {},
391
+ "name": "text",
392
+ "x-designable-id": "33hm1r4yfe912",
393
+ "x-index": 13
394
+ },
395
+ "createTime": {
396
+ "type": "string",
397
+ "title": "创建时间",
398
+ "x-decorator": "FormItem",
399
+ "x-component": "DatePicker",
400
+ "x-validator": [],
401
+ "x-component-props": {
402
+ "showNow": true
403
+ },
404
+ "x-decorator-props": {},
405
+ "name": "createTime",
406
+ "x-display": "none",
407
+ "x-designable-id": "33hm1r4yfe9",
408
+ "x-index": 14
409
+ }
410
+ },
411
+ "x-designable-id": "ol2kvilayx8"
412
+ }
413
+ }
@@ -0,0 +1,3 @@
1
+ const Routes: any = [{ path: "/", component: "pages/index" }];
2
+
3
+ export { Routes };
@@ -0,0 +1,16 @@
1
+ declare module "*.svg";
2
+ declare module "*.png";
3
+ declare module "*.jpg";
4
+ declare module "*.jpeg";
5
+ declare module "*.gif";
6
+ declare module "*.bmp";
7
+ declare module "*.tiff";
8
+ declare module "*.js";
9
+ declare module "@";
10
+ declare module "@/*";
11
+ declare module "@config";
12
+ declare module "@hzab/list-render";
13
+
14
+ interface Window {
15
+ $_navigate?: Function;
16
+ }
package/lib/data-model.js CHANGED
@@ -1 +1 @@
1
- import _ from"lodash";import axios from"axios";class DataModel{constructor(t){const{ctx:e,query:s,createApi:i,createMap:a,getApi:r,getMap:o,getListApi:h,getListMap:n,getListFunc:p,updateApi:l,updateMap:c,deleteApi:d,multipleDeleteApi:g,axios:u,axiosConf:m}=t;this.ctx=e||{},this.query=s||{},this.axios=u||axios,this.axiosConf=m||{},this.createApi=i,this.createMap=a,this.getApi=r,this.getMap=o,this.getListApi=h,this.getListMap=n,this.getListFunc=p,this.updateApi=l,this.updateMap=c,this.deleteApi=d,this.multipleDeleteApi=g}getApiUrl(t,e,s=this.ctx){if(!t)throw new Error("Error getApiUrl api 不能为空",t,e,s);let i=t;const a=_.merge({},e,s);return _.each(a,((t,e)=>{_.isString(t)&&_.isNumber(t)&&!_.isBoolean(t)||(i=i.replace(`:${e}`,t))})),i}get(t={},e={}){let s=_.merge({},this.query,t);return s=_.pickBy(s,(t=>!_.isNil(t)&&""!==t)),new Promise(((t,i)=>{const a=this.getApiUrl(this.getApi,s,e);this.axios.get(a,{...this.axiosConf,params:s}).then((e=>{this.handleRes(e,(e=>{this.getMap&&(e=this.getMap(e)),t(e)}),i)})).catch((t=>this.errorHandler(t,i)))}))}async getList(t,e){let s=_.merge({},this.query,t);s=_.pickBy(s,(t=>!_.isNil(t)&&""!==t));let i=null;if(this.getListFunc)i=await this.getListFunc(s);else{const a=new Promise(((i,a)=>{const r=this.getApiUrl(this.getListApi,t,e);this.axios.get(r,{...this.axiosConf,params:s}).then((t=>{this.handleRes(t,(t=>{this.getListMap&&(t.list=t.list.map((t=>this.getListMap(t)))),i(t)}),a)})).catch((t=>this.errorHandler(t,a)))}));i=await a}return i}create(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.createApi,t,e),r={...this.axiosConf};t instanceof FormData&&(r.headers={"Content-Type":"multipart/form-data"}),this.axios.post(a,t,r).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}update(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.updateApi,t,e),r={...this.axiosConf};t instanceof FormData&&(r.headers={"Content-Type":"multipart/form-data"}),this.axios.put(a,t,r).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}delete(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.deleteApi,t,e);this.axios.delete(a,{...this.axiosConf,...t}).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}multipleDelete(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.multipleDeleteApi,t,e);this.axios.delete(a,{...this.axiosConf,...t}).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}handleRes(t,e,s){if("object"!=typeof t)return void s(new Error("response not object"));let i=t;i.data&&i.data.data&&"number"==typeof i.data?.code&&(i=i.data);const{code:a,message:r,data:o,msg:h}=i;if(200===a){let t=o??{};_.isObject(t)&&void 0===t.message&&(t._message=r||h),e(t)}else{const e=new Error(r||h);e.code=a,e.response=t,e._message=r||h,s(e)}}errorHandler(t,e){const s=t.response||t;if(s){const t=s.data&&(s.data.message||s.data.msg)||s.msg,i=new Error(t||s.statusText||"未知错误");return i.code=s.status,i.response=s,t&&(i._message=t),e(i)}return e(t)}}export{axios};export default DataModel;
1
+ import _ from"lodash";import axios from"axios";const _$Temp={};class DataModel{constructor(t){const{ctx:e,query:s,createApi:i,createMap:a,getApi:r,getMap:o,getListApi:n,getListMap:h,getListFunc:p,updateApi:l,updateMap:c,deleteApi:d,multipleDeleteApi:g,axios:u,axiosConf:m}=t;this.ctx=e||{},this.query=s||{},this.axios=u||_$Temp.axios||axios,this.axiosConf=m||{},this.createApi=i,this.createMap=a,this.getApi=r,this.getMap=o,this.getListApi=n,this.getListMap=h,this.getListFunc=p,this.updateApi=l,this.updateMap=c,this.deleteApi=d,this.multipleDeleteApi=g}getApiUrl(t,e,s=this.ctx){if(!t)throw new Error("Error api 不能为空",t,e,s);let i=t;const a=_.merge({},e,s);return _.each(a,((t,e)=>{_.isString(t)&&_.isNumber(t)&&!_.isBoolean(t)||(i=i.replace(`:${e}`,t))})),i}get(t={},e={}){let s=_.merge({},this.query,t);return s=_.pickBy(s,(t=>!_.isNil(t)&&""!==t)),new Promise(((t,i)=>{const a=this.getApiUrl(this.getApi,s,e);this.axios.get(a,{...this.axiosConf,params:s}).then((e=>{this.handleRes(e,(e=>{this.getMap&&(e=this.getMap(e)),t(e)}),i)})).catch((t=>this.errorHandler(t,i)))}))}async getList(t,e){let s=_.merge({},this.query,t);s=_.pickBy(s,(t=>!_.isNil(t)&&""!==t));let i=null;if(this.getListFunc)i=await this.getListFunc(s);else{const a=new Promise(((i,a)=>{const r=this.getApiUrl(this.getListApi,t,e);this.axios.get(r,{...this.axiosConf,params:s}).then((t=>{this.handleRes(t,(t=>{this.getListMap&&(t.list=t.list.map((t=>this.getListMap(t)))),i(t)}),a)})).catch((t=>this.errorHandler(t,a)))}));i=await a}return i}create(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.createApi,t,e),r={...this.axiosConf};t instanceof FormData&&(r.headers={"Content-Type":"multipart/form-data"}),this.axios.post(a,t,r).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}update(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.updateApi,t,e),r={...this.axiosConf};t instanceof FormData&&(r.headers={"Content-Type":"multipart/form-data"}),this.axios.put(a,t,r).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}delete(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.deleteApi,t,e);this.axios.delete(a,{...this.axiosConf,...t}).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}multipleDelete(t,e){return new Promise(((s,i)=>{const a=this.getApiUrl(this.multipleDeleteApi,t,e);this.axios.delete(a,{...this.axiosConf,...t}).then((t=>{this.handleRes(t,s,i)})).catch((t=>this.errorHandler(t,i)))}))}handleRes(t,e,s){if("object"!=typeof t)return void s(new Error("response not object"));let i=t;i.data&&i.headers&&i.request&&"number"==typeof i.data?.code&&(i=i.data);const{code:a,message:r,data:o,msg:n}=i;if(200===a){let t=o??{};_.isObject(t)&&void 0===t.message&&(t._message=r||n),e(t)}else{const e=new Error(r||n);e.code=a,e.response=t,e._message=r||n,s(e)}}errorHandler(t,e){const s=t.response||t;if(s){const t=s.data&&(s.data.message||s.data.msg)||s.msg,i=new Error(t||s.statusText||"未知错误");return i.code=s.status,i.response=s,t&&(i._message=t),e(i)}return e(t)}}function setDefaultAxios(t){t&&(_$Temp.axios=t)}export{axios,DataModel,setDefaultAxios};export default DataModel;