@vue-start/pro 0.1.0 → 0.3.1

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/dist/index.d.ts CHANGED
@@ -1,77 +1,1144 @@
1
- import * as axios from 'axios';
2
- import { AxiosRequestConfig, AxiosResponse, AxiosInstance, AxiosInterceptorManager } from 'axios';
3
- import { Observable, Subject, BehaviorSubject } from 'rxjs';
4
1
  import * as vue from 'vue';
5
- import { App } from 'vue';
2
+ import { VNode, ExtractPropTypes, PropType } from 'vue';
3
+ import { Ref, UnwrapNestedRefs, ComputedRef } from '@vue/reactivity';
4
+ import { Subject } from 'rxjs';
5
+ import { IRequestActor } from '@vue-start/request';
6
6
 
7
- declare type ReqType = {
8
- body?: Record<string, any>;
9
- [key: string]: any;
7
+ declare type TDefaultValueType = "text" | "textarea" | "password" | "digit" | "date" | "dateRange" | "time" | "timeRange" | "select" | "treeSelect" | "checkbox" | "radio" | "slider" | "switch" | "rate" | "cascader";
8
+ declare type TValueType = TDefaultValueType | string;
9
+ declare type TOption = {
10
+ label?: string;
11
+ value: string | number;
12
+ disabled?: boolean;
13
+ };
14
+ declare type TOptions = TOption[];
15
+ declare type TColumn = {
16
+ title?: string | VNode;
17
+ dataIndex?: string | number;
18
+ valueType?: TValueType;
19
+ formValueType?: TValueType;
20
+ showProps?: Record<string, any>;
21
+ formItemProps?: {
22
+ name?: string;
23
+ label?: string;
24
+ };
25
+ formFieldProps?: Record<string, any>;
26
+ search?: boolean;
27
+ hideInTable?: boolean;
28
+ hideInForm?: boolean;
29
+ hideInDetail?: boolean;
30
+ searchSort?: boolean;
31
+ tableSort?: boolean;
32
+ formSort?: boolean;
33
+ descSort?: boolean;
34
+ extra?: {
35
+ desc?: any;
36
+ };
10
37
  };
38
+ declare type TColumns = TColumn[];
11
39
  /**
12
- * 两种模式
13
- * requestFromReq :开发时候创建的
14
- * requestConfig: 通过配置添加
40
+ * 发送事件对象
15
41
  */
16
- interface IRequestActor<TReq = any, TRes = any, TErr = any> {
17
- name: string;
18
- requestFromReq?: (req: TReq) => AxiosRequestConfig;
19
- requestConfig?: AxiosRequestConfig;
20
- label?: string;
21
- req?: TReq;
22
- res?: AxiosResponse<TRes>;
23
- err?: TErr;
24
- stage?: "DONE" | "FAILED" | "CANCEL";
25
- id?: string;
42
+ declare type TActionEvent = {
43
+ type: string;
44
+ payload?: any;
45
+ /**
46
+ * 发送事件源
47
+ * 公共组件(如:Curd)只处理source为undefined的事件
48
+ * 业务组件可以传入该参数覆盖之前的默认行为
49
+ */
50
+ source?: string;
26
51
  extra?: Record<string, any>;
52
+ };
53
+ /**
54
+ * 发送state对象
55
+ */
56
+ declare type TActionState = {
57
+ type: string;
58
+ payload: any;
59
+ extra?: Record<string, any>;
60
+ };
61
+ /**
62
+ * 组件Map
63
+ */
64
+ declare type TElementMap = Record<string, any>;
65
+ declare type BooleanObjType = {
66
+ [key: string]: boolean;
67
+ };
68
+ declare type BooleanRulesObjType = {
69
+ [key: string]: (record: any) => boolean;
70
+ };
71
+
72
+ /**
73
+ * 获取Column的valueType,默认"text"
74
+ * @param column
75
+ */
76
+ declare const getColumnValueType: (column: TColumn) => TValueType;
77
+ /**
78
+ *获取Column的FormItem name
79
+ * @param column
80
+ */
81
+ declare const getColumnFormItemName: (column: TColumn) => string | number | undefined;
82
+ /**
83
+ * 根据Column生成FormItem VNode
84
+ * formFieldProps中的slots参数会以v-slots的形式传递到FormItem的录入组件(子组件)中
85
+ * @param formElementMap
86
+ * @param column
87
+ * @param needRules
88
+ */
89
+ declare const getFormItemEl: (formElementMap: any, column: TColumn, needRules?: boolean | undefined) => VNode | null;
90
+ /**
91
+ * 根据Column生成Item VNode
92
+ * @param elementMap
93
+ * @param column
94
+ * @param value
95
+ */
96
+ declare const getItemEl: <T extends TColumn>(elementMap: any, column: T, value: any) => VNode | null;
97
+ interface IProModuleProvide {
98
+ columns: Ref<TColumns>;
99
+ getFormItemVNode: (column: TColumn, needRules: boolean | undefined) => VNode | null;
100
+ getItemVNode: (column: TColumn, value: any) => VNode | null;
101
+ elementMap: {
102
+ [key: string]: any;
103
+ };
104
+ formElementMap: {
105
+ [key: string]: any;
106
+ };
107
+ subject$: Subject<TActionEvent>;
108
+ sendEvent: (action: TActionEvent) => void;
109
+ state: UnwrapNestedRefs<Record<string, any>>;
110
+ dispatch: (action: TActionState) => void;
111
+ requests: IRequestOpts[];
112
+ sendRequest: (requestNameOrAction: string, ...params: any[]) => void;
27
113
  }
28
- declare const isPreRequestActor: (actor: IRequestActor) => boolean;
29
- declare const isCancelRequestActor: (actor: IRequestActor) => boolean;
30
- declare const isFailedRequestActor: (actor: IRequestActor) => boolean;
31
- declare const isDoneRequestActor: (actor: IRequestActor) => boolean;
32
- declare const createRequestActor: <TReq extends ReqType, TRes>(name: string, requestFromReq: ((req: TReq) => AxiosRequestConfig) | undefined, extra?: Pick<IRequestActor<TReq, TRes, any>, "label"> | undefined) => IRequestActor<TReq, TRes, any>;
33
- declare const cancelActorIfExists: (actor: any) => void;
34
- declare const isCancelActor: (actor: any) => any;
35
- declare const createRequestFactory: (client: AxiosInstance) => (actor: IRequestActor) => {
36
- (): Observable<AxiosResponse<any>>;
37
- clear(): void;
38
- config: AxiosRequestConfig;
39
- };
40
- declare const createRequestObservable: (actor$: Observable<IRequestActor>, client: AxiosInstance) => Observable<IRequestActor<any, any, any>>;
114
+ declare const useProModule: () => IProModuleProvide;
115
+ declare const provideProModule: (ctx: IProModuleProvide) => void;
116
+ interface IRequestOpts {
117
+ actor: IRequestActor;
118
+ /**
119
+ * 如果设置action,可以使用该值发起请求 住:要保证唯一性
120
+ * 设置该字段原因:因为actor中的name不友好,可以理解为一个备选方案
121
+ */
122
+ action?: string;
123
+ stateName?: string;
124
+ loadingName?: string;
125
+ convertParams?: (...params: any[]) => Record<string, any>;
126
+ convertData?: (actor: IRequestActor) => Record<string, any>;
127
+ onSuccess?: (actor?: IRequestActor) => void;
128
+ onFailed?: (actor?: IRequestActor) => void;
129
+ }
130
+ declare const RequestAction: {
131
+ Success: string;
132
+ Fail: string;
133
+ };
134
+ declare const proModuleProps: () => {
135
+ /**
136
+ * module状态
137
+ */
138
+ state: {
139
+ type: PropType<Record<string, any>>;
140
+ };
141
+ /**
142
+ * 配置(静态)
143
+ */
144
+ columns: {
145
+ type: PropType<TColumns>;
146
+ };
147
+ /**
148
+ * 配置(动态)
149
+ * columns动态属性兼容
150
+ */
151
+ columnState: {
152
+ type: PropType<Record<string, any>>;
153
+ };
154
+ /**
155
+ * 展示组件集
156
+ */
157
+ elementMap: {
158
+ type: PropType<TElementMap>;
159
+ };
160
+ /**
161
+ * 录入组件集
162
+ */
163
+ formElementMap: {
164
+ type: PropType<TElementMap>;
165
+ };
166
+ /**
167
+ * requests
168
+ */
169
+ requests: {
170
+ type: PropType<IRequestOpts[]>;
171
+ };
172
+ };
173
+ declare type ProModuleProps = Partial<ExtractPropTypes<ReturnType<typeof proModuleProps>>>;
174
+ declare const ProModule: vue.DefineComponent<Partial<ExtractPropTypes<{
175
+ /**
176
+ * module状态
177
+ */
178
+ state: {
179
+ type: PropType<Record<string, any>>;
180
+ };
181
+ /**
182
+ * 配置(静态)
183
+ */
184
+ columns: {
185
+ type: PropType<TColumns>;
186
+ };
187
+ /**
188
+ * 配置(动态)
189
+ * columns动态属性兼容
190
+ */
191
+ columnState: {
192
+ type: PropType<Record<string, any>>;
193
+ };
194
+ /**
195
+ * 展示组件集
196
+ */
197
+ elementMap: {
198
+ type: PropType<TElementMap>;
199
+ };
200
+ /**
201
+ * 录入组件集
202
+ */
203
+ formElementMap: {
204
+ type: PropType<TElementMap>;
205
+ };
206
+ /**
207
+ * requests
208
+ */
209
+ requests: {
210
+ type: PropType<IRequestOpts[]>;
211
+ };
212
+ }>>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<Partial<ExtractPropTypes<{
213
+ /**
214
+ * module状态
215
+ */
216
+ state: {
217
+ type: PropType<Record<string, any>>;
218
+ };
219
+ /**
220
+ * 配置(静态)
221
+ */
222
+ columns: {
223
+ type: PropType<TColumns>;
224
+ };
225
+ /**
226
+ * 配置(动态)
227
+ * columns动态属性兼容
228
+ */
229
+ columnState: {
230
+ type: PropType<Record<string, any>>;
231
+ };
232
+ /**
233
+ * 展示组件集
234
+ */
235
+ elementMap: {
236
+ type: PropType<TElementMap>;
237
+ };
238
+ /**
239
+ * 录入组件集
240
+ */
241
+ formElementMap: {
242
+ type: PropType<TElementMap>;
243
+ };
244
+ /**
245
+ * requests
246
+ */
247
+ requests: {
248
+ type: PropType<IRequestOpts[]>;
249
+ };
250
+ }>>>, {}>;
41
251
 
42
- declare type DispatchRequestType = (actor: IRequestActor, params?: IRequestActor["req"], extra?: IRequestActor["extra"]) => IRequestActor;
43
- declare type RequestProvideType = {
44
- client: AxiosInstance;
45
- requestSubject$: Subject<IRequestActor>;
46
- dispatchRequest: DispatchRequestType;
47
- };
48
- declare const useRequestProvide: () => RequestProvideType;
49
- declare type TRequestInterceptor = (request: AxiosInterceptorManager<AxiosRequestConfig>, response: AxiosInterceptorManager<AxiosResponse>) => void;
50
- declare const ContentTypeInterceptor: TRequestInterceptor;
51
- declare const createRequest: (options: AxiosRequestConfig, interceptors: TRequestInterceptor[]) => (app: App) => void;
252
+ declare const useModuleEvent: (cb: (action: TActionEvent) => void) => void;
52
253
 
53
- declare const isContentTypeMultipartFormData: (headers: any) => any;
54
- declare const isContentTypeFormURLEncoded: (headers: any) => any;
55
- declare const isContentTypeJSON: (headers: any) => any;
56
- declare const paramsSerializer: (params: any) => string;
57
- declare const transformRequest: (data: any, headers: any) => any;
58
- declare const transformResponse: (data: unknown, headers: {
59
- [k: string]: any;
60
- }) => any;
61
- declare const getRequestConfig: (actor: IRequestActor) => axios.AxiosRequestConfig;
62
- declare const toUrl: (actor: IRequestActor, baseUrl?: string) => string;
63
- declare const generateId: () => string;
254
+ declare const useDoneRequestActor: (actors: (IRequestActor | string)[], callback: (actor: IRequestActor) => void) => void;
255
+ declare const useFailedRequestActor: (actors: (IRequestActor | string)[], callback: (actor: IRequestActor) => void) => void;
256
+ declare const useComposeRequestActor: (actors: (IRequestActor | string)[], options: {
257
+ onStart?: ((actor: IRequestActor) => void) | undefined;
258
+ onSuccess?: ((actor: IRequestActor) => void) | undefined;
259
+ onFailed?: ((actor: IRequestActor) => void) | undefined;
260
+ onFinish?: ((actor: IRequestActor) => void) | undefined;
261
+ }, cancelWhileUnmount?: boolean | undefined) => void;
64
262
 
65
- interface IUseRequestOptions<TReq, TRes, TErr> {
66
- defaultLoading?: boolean;
67
- onSuccess?: (actor: IRequestActor<TReq, TRes, TErr>) => void;
68
- onFail?: (actor: IRequestActor<TReq, TRes, TErr>) => void;
69
- onFinish?: () => void;
263
+ interface IProTableProvideExtra extends Record<string, any> {
70
264
  }
71
- declare const useRequest: <TReq, TRes, TErr>(requestActor: IRequestActor<TReq, TRes, TErr>, options?: IUseRequestOptions<TReq, TRes, TErr> | undefined) => readonly [(params: TReq | undefined, options?: Pick<IUseRequestOptions<TReq, TRes, TErr>, "onSuccess" | "onFail"> | undefined) => void, BehaviorSubject<boolean>];
265
+ interface IProTableProvide extends IProTableProvideExtra {
266
+ columns: Ref<TTableColumns>;
267
+ }
268
+ declare const useProTable: () => IProTableProvide;
269
+ declare type TTableColumn = {
270
+ customRender?: (opt: {
271
+ value: any;
272
+ text: any;
273
+ record: Record<string, any>;
274
+ index: number;
275
+ column: TTableColumn;
276
+ }) => VNode;
277
+ fixed?: boolean | string;
278
+ } & TColumn;
279
+ declare type TTableColumns = TTableColumn[];
280
+ /**
281
+ * 单个操作描述
282
+ */
283
+ interface IOperateItem {
284
+ value: string | number;
285
+ label?: string | VNode;
286
+ element?: (record: Record<string, any>, item: IOperateItem) => VNode;
287
+ show?: boolean | ((record: Record<string, any>) => boolean);
288
+ disabled?: boolean | ((record: Record<string, any>) => boolean);
289
+ onClick?: (record: Record<string, any>) => void;
290
+ sort?: number;
291
+ }
292
+ /**
293
+ * 整个操作栏描述
294
+ */
295
+ interface ITableOperate {
296
+ column?: TColumn;
297
+ items?: IOperateItem[];
298
+ itemState?: {
299
+ [key: string]: Omit<IOperateItem, "value">;
300
+ };
301
+ }
302
+ declare const proTableProps: () => {
303
+ operate: {
304
+ type: PropType<ITableOperate>;
305
+ };
306
+ columnEmptyText: {
307
+ type: StringConstructor;
308
+ };
309
+ /**
310
+ * 公共column,会merge到columns item中
311
+ */
312
+ column: {
313
+ type: PropType<TTableColumn>;
314
+ };
315
+ columns: {
316
+ type: PropType<TTableColumns>;
317
+ };
318
+ columnState: {
319
+ type: PropType<Record<string, any>>;
320
+ };
321
+ /**
322
+ * 展示控件集合,readonly模式下使用这些组件渲染
323
+ */
324
+ elementMap: {
325
+ type: PropType<TElementMap>;
326
+ };
327
+ /**
328
+ * loading
329
+ */
330
+ loading: {
331
+ type: BooleanConstructor;
332
+ };
333
+ /**
334
+ * 序号
335
+ */
336
+ serialNumber: {
337
+ type: BooleanConstructor;
338
+ };
339
+ /**
340
+ * 分页
341
+ */
342
+ pagination: {
343
+ type: PropType<{
344
+ page?: number | undefined;
345
+ pageSize?: number | undefined;
346
+ }>;
347
+ };
348
+ /**
349
+ * provide传递
350
+ */
351
+ provideExtra: {
352
+ type: PropType<IProTableProvideExtra>;
353
+ };
354
+ };
355
+ declare type ProTableProps = Partial<ExtractPropTypes<ReturnType<typeof proTableProps>>>;
356
+ declare const ProTable: vue.DefineComponent<Partial<ExtractPropTypes<{
357
+ operate: {
358
+ type: PropType<ITableOperate>;
359
+ };
360
+ columnEmptyText: {
361
+ type: StringConstructor;
362
+ };
363
+ /**
364
+ * 公共column,会merge到columns item中
365
+ */
366
+ column: {
367
+ type: PropType<TTableColumn>;
368
+ };
369
+ columns: {
370
+ type: PropType<TTableColumns>;
371
+ };
372
+ columnState: {
373
+ type: PropType<Record<string, any>>;
374
+ };
375
+ /**
376
+ * 展示控件集合,readonly模式下使用这些组件渲染
377
+ */
378
+ elementMap: {
379
+ type: PropType<TElementMap>;
380
+ };
381
+ /**
382
+ * loading
383
+ */
384
+ loading: {
385
+ type: BooleanConstructor;
386
+ };
387
+ /**
388
+ * 序号
389
+ */
390
+ serialNumber: {
391
+ type: BooleanConstructor;
392
+ };
393
+ /**
394
+ * 分页
395
+ */
396
+ pagination: {
397
+ type: PropType<{
398
+ page?: number | undefined;
399
+ pageSize?: number | undefined;
400
+ }>;
401
+ };
402
+ /**
403
+ * provide传递
404
+ */
405
+ provideExtra: {
406
+ type: PropType<IProTableProvideExtra>;
407
+ };
408
+ }>>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<Partial<ExtractPropTypes<{
409
+ operate: {
410
+ type: PropType<ITableOperate>;
411
+ };
412
+ columnEmptyText: {
413
+ type: StringConstructor;
414
+ };
415
+ /**
416
+ * 公共column,会merge到columns item中
417
+ */
418
+ column: {
419
+ type: PropType<TTableColumn>;
420
+ };
421
+ columns: {
422
+ type: PropType<TTableColumns>;
423
+ };
424
+ columnState: {
425
+ type: PropType<Record<string, any>>;
426
+ };
427
+ /**
428
+ * 展示控件集合,readonly模式下使用这些组件渲染
429
+ */
430
+ elementMap: {
431
+ type: PropType<TElementMap>;
432
+ };
433
+ /**
434
+ * loading
435
+ */
436
+ loading: {
437
+ type: BooleanConstructor;
438
+ };
439
+ /**
440
+ * 序号
441
+ */
442
+ serialNumber: {
443
+ type: BooleanConstructor;
444
+ };
445
+ /**
446
+ * 分页
447
+ */
448
+ pagination: {
449
+ type: PropType<{
450
+ page?: number | undefined;
451
+ pageSize?: number | undefined;
452
+ }>;
453
+ };
454
+ /**
455
+ * provide传递
456
+ */
457
+ provideExtra: {
458
+ type: PropType<IProTableProvideExtra>;
459
+ };
460
+ }>>>, {}>;
461
+
462
+ declare const defaultPage: {
463
+ page: number;
464
+ pageSize: number;
465
+ };
466
+ interface IListData extends Record<string, any> {
467
+ total: number;
468
+ dataSource: Record<string, any>[];
469
+ }
470
+ interface ICurdState extends Record<string, any> {
471
+ listLoading?: boolean;
472
+ listData?: IListData;
473
+ mode?: ICurdCurrentMode;
474
+ detailLoading?: boolean;
475
+ detailData?: Record<string, any>;
476
+ operateLoading?: boolean;
477
+ addAction?: ICurdAddAction;
478
+ }
479
+ /**
480
+ * action:list,detail,add,edit,delete
481
+ */
482
+ interface ICurdOperateOpts extends Omit<IRequestOpts, "actor" | "action">, Omit<IOperateItem, "value"> {
483
+ action: ICurdAction;
484
+ actor?: IRequestActor;
485
+ }
486
+ declare type TCurdActionEvent = {
487
+ action: ICurdAction;
488
+ type: ICurdSubAction;
489
+ record?: Record<string, any>;
490
+ values?: Record<string, any>;
491
+ source?: TActionEvent["source"];
492
+ };
493
+ declare const proCurdProps: () => {
494
+ /**
495
+ * 列表 或 详情 的唯一标识
496
+ */
497
+ rowKey: {
498
+ type: StringConstructor;
499
+ default: string;
500
+ };
501
+ /**
502
+ * operates
503
+ */
504
+ operates: {
505
+ type: PropType<ICurdOperateOpts[]>;
506
+ };
507
+ /************************* 子组件props *******************************/
508
+ listProps: {
509
+ type: PropType<Record<string, any>>;
510
+ };
511
+ formProps: {
512
+ type: PropType<Record<string, any>>;
513
+ };
514
+ descProps: {
515
+ type: PropType<Record<string, any>>;
516
+ };
517
+ modalProps: {
518
+ type: PropType<Record<string, any>>;
519
+ };
520
+ };
521
+ declare type CurdProps = Partial<ExtractPropTypes<ReturnType<typeof proCurdProps>>>;
522
+ declare type ProCurdProps = CurdProps & Omit<ProModuleProps, "state" | "requests"> & {
523
+ curdState?: UnwrapNestedRefs<ICurdState>;
524
+ };
525
+ declare const ProCurd: vue.DefineComponent<ProCurdProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<ProCurdProps>, {}>;
526
+
527
+ interface IProCurdProvide {
528
+ rowKey: string;
529
+ curdState: UnwrapNestedRefs<ICurdState>;
530
+ formColumns: Ref<TColumns>;
531
+ descColumns: Ref<TColumns>;
532
+ tableColumns: Ref<TColumns>;
533
+ searchColumns: Ref<TColumns>;
534
+ sendCurdEvent: (event: TCurdActionEvent) => void;
535
+ getOperate: (action: ICurdAction) => ICurdOperateOpts | undefined;
536
+ refreshList: (extra?: Record<string, any>) => void;
537
+ /******************子组件参数*******************/
538
+ listProps?: ComputedRef<Record<string, any> | undefined>;
539
+ formProps?: ComputedRef<Record<string, any> | undefined>;
540
+ descProps?: ComputedRef<Record<string, any> | undefined>;
541
+ modalProps?: ComputedRef<Record<string, any> | undefined>;
542
+ }
543
+ declare const useProCurd: <T extends IProCurdProvide>() => T;
544
+ declare const provideProCurd: (ctx: IProCurdProvide) => void;
545
+ /************************************ 常量 *************************************/
546
+ /**
547
+ * curd 5种Action
548
+ */
549
+ declare enum CurdAction {
550
+ LIST = "LIST",
551
+ DETAIL = "DETAIL",
552
+ ADD = "ADD",
553
+ EDIT = "EDIT",
554
+ DELETE = "DELETE"
555
+ }
556
+ declare type ICurdAction = keyof typeof CurdAction;
557
+ /**
558
+ * 5种Action 的子事件
559
+ */
560
+ declare enum CurdSubAction {
561
+ EMIT = "EMIT",
562
+ EXECUTE = "EXECUTE",
563
+ PAGE = "PAGE",
564
+ SUCCESS = "SUCCESS",
565
+ FAIL = "FAIL"
566
+ }
567
+ declare type ICurdSubAction = keyof typeof CurdSubAction;
568
+ /**
569
+ * curd 操作模式
570
+ */
571
+ declare enum CurdCurrentMode {
572
+ ADD = "ADD",
573
+ EDIT = "EDIT",
574
+ DETAIL = "DETAIL"
575
+ }
576
+ declare type ICurdCurrentMode = keyof typeof CurdCurrentMode;
577
+ /**
578
+ * curd add 模式下 标记 "确定" "确定并继续" 触发
579
+ */
580
+ declare enum CurdAddAction {
581
+ NORMAL = "NORMAL",
582
+ CONTINUE = "CONTINUE"
583
+ }
584
+ declare type ICurdAddAction = keyof typeof CurdAddAction;
585
+
586
+ declare const modalCurdProps: () => {
587
+ defaultAddRecord: {
588
+ type: PropType<Record<string, any>>;
589
+ };
590
+ };
591
+ declare type ModalCurdProps = Partial<ExtractPropTypes<ReturnType<typeof modalCurdProps>>>;
592
+ declare type ProModalCurdProps = ModalCurdProps & ProCurdProps;
593
+ declare const ProModalCurd: vue.DefineComponent<ProModalCurdProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<ProModalCurdProps>, {}>;
594
+
595
+ declare const pageCurdProps: () => {
596
+ defaultAddRecord: {
597
+ type: PropType<Record<string, any>>;
598
+ };
599
+ routeBack: {
600
+ type: PropType<(action: ICurdAction) => void>;
601
+ };
602
+ };
603
+ declare type PageCurdProps = Partial<ExtractPropTypes<ReturnType<typeof pageCurdProps>>>;
604
+ declare type ProPageCurdProps = PageCurdProps & ProCurdProps;
605
+ declare const ProPageCurd: vue.DefineComponent<ProPageCurdProps, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<ProPageCurdProps>, {}>;
606
+
607
+ interface IProFormProvideExtra extends Record<string, any> {
608
+ }
609
+ interface IProFormProvide extends IProFormProvideExtra {
610
+ formState: UnwrapNestedRefs<Record<string, any>>;
611
+ showState: UnwrapNestedRefs<Record<string, any>>;
612
+ readonlyState: UnwrapNestedRefs<Record<string, any>>;
613
+ disableState: UnwrapNestedRefs<Record<string, any>>;
614
+ readonly: Ref<boolean | undefined>;
615
+ elementMap?: TElementMap;
616
+ formElementMap?: TElementMap;
617
+ columns: Ref<TColumns>;
618
+ }
619
+ declare const useProForm: () => IProFormProvide;
620
+ declare const proFormProps: () => {
621
+ /**
622
+ * 同 antd 或 element form中的model
623
+ */
624
+ model: {
625
+ type: PropType<Record<string, any>>;
626
+ };
627
+ /**
628
+ * 子组件是否只读样式
629
+ */
630
+ readonly: {
631
+ type: BooleanConstructor;
632
+ default: undefined;
633
+ };
634
+ /**
635
+ * FormComponent 根据此项来确定组件是否显示
636
+ * rules 根据rules中方法生成showState对象
637
+ */
638
+ showState: {
639
+ type: PropType<BooleanObjType>;
640
+ };
641
+ showStateRules: {
642
+ type: PropType<BooleanRulesObjType>;
643
+ };
644
+ /**
645
+ * 是否只读
646
+ */
647
+ readonlyState: {
648
+ type: PropType<BooleanObjType>;
649
+ };
650
+ readonlyStateRules: {
651
+ type: PropType<BooleanRulesObjType>;
652
+ };
653
+ /**
654
+ * 是否disabled
655
+ */
656
+ disableState: {
657
+ type: PropType<BooleanObjType>;
658
+ };
659
+ disableStateRules: {
660
+ type: PropType<BooleanRulesObjType>;
661
+ };
662
+ /**
663
+ *
664
+ */
665
+ columns: {
666
+ type: PropType<TColumns>;
667
+ };
668
+ columnState: {
669
+ type: PropType<Record<string, any>>;
670
+ };
671
+ /**
672
+ * 展示控件集合,readonly模式下使用这些组件渲染
673
+ */
674
+ elementMap: {
675
+ type: PropType<TElementMap>;
676
+ };
677
+ /**
678
+ * 录入控件集合
679
+ */
680
+ formElementMap: {
681
+ type: PropType<TElementMap>;
682
+ };
683
+ /**
684
+ * 是否启用rules验证
685
+ */
686
+ needRules: {
687
+ type: BooleanConstructor;
688
+ default: boolean;
689
+ };
690
+ /**
691
+ * provide传递
692
+ */
693
+ provideExtra: {
694
+ type: PropType<IProFormProvideExtra>;
695
+ };
696
+ };
697
+ declare type ProFormProps = Partial<ExtractPropTypes<ReturnType<typeof proFormProps>>>;
698
+ declare const ProForm: vue.DefineComponent<{
699
+ /**
700
+ * 同 antd 或 element form中的model
701
+ */
702
+ model: {
703
+ type: PropType<Record<string, any>>;
704
+ };
705
+ /**
706
+ * 子组件是否只读样式
707
+ */
708
+ readonly: {
709
+ type: BooleanConstructor;
710
+ default: undefined;
711
+ };
712
+ /**
713
+ * FormComponent 根据此项来确定组件是否显示
714
+ * rules 根据rules中方法生成showState对象
715
+ */
716
+ showState: {
717
+ type: PropType<BooleanObjType>;
718
+ };
719
+ showStateRules: {
720
+ type: PropType<BooleanRulesObjType>;
721
+ };
722
+ /**
723
+ * 是否只读
724
+ */
725
+ readonlyState: {
726
+ type: PropType<BooleanObjType>;
727
+ };
728
+ readonlyStateRules: {
729
+ type: PropType<BooleanRulesObjType>;
730
+ };
731
+ /**
732
+ * 是否disabled
733
+ */
734
+ disableState: {
735
+ type: PropType<BooleanObjType>;
736
+ };
737
+ disableStateRules: {
738
+ type: PropType<BooleanRulesObjType>;
739
+ };
740
+ /**
741
+ *
742
+ */
743
+ columns: {
744
+ type: PropType<TColumns>;
745
+ };
746
+ columnState: {
747
+ type: PropType<Record<string, any>>;
748
+ };
749
+ /**
750
+ * 展示控件集合,readonly模式下使用这些组件渲染
751
+ */
752
+ elementMap: {
753
+ type: PropType<TElementMap>;
754
+ };
755
+ /**
756
+ * 录入控件集合
757
+ */
758
+ formElementMap: {
759
+ type: PropType<TElementMap>;
760
+ };
761
+ /**
762
+ * 是否启用rules验证
763
+ */
764
+ needRules: {
765
+ type: BooleanConstructor;
766
+ default: boolean;
767
+ };
768
+ /**
769
+ * provide传递
770
+ */
771
+ provideExtra: {
772
+ type: PropType<IProFormProvideExtra>;
773
+ };
774
+ }, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
775
+ [key: string]: any;
776
+ }>[] | undefined, unknown, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, Record<string, any>, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<ExtractPropTypes<{
777
+ /**
778
+ * 同 antd 或 element form中的model
779
+ */
780
+ model: {
781
+ type: PropType<Record<string, any>>;
782
+ };
783
+ /**
784
+ * 子组件是否只读样式
785
+ */
786
+ readonly: {
787
+ type: BooleanConstructor;
788
+ default: undefined;
789
+ };
790
+ /**
791
+ * FormComponent 根据此项来确定组件是否显示
792
+ * rules 根据rules中方法生成showState对象
793
+ */
794
+ showState: {
795
+ type: PropType<BooleanObjType>;
796
+ };
797
+ showStateRules: {
798
+ type: PropType<BooleanRulesObjType>;
799
+ };
800
+ /**
801
+ * 是否只读
802
+ */
803
+ readonlyState: {
804
+ type: PropType<BooleanObjType>;
805
+ };
806
+ readonlyStateRules: {
807
+ type: PropType<BooleanRulesObjType>;
808
+ };
809
+ /**
810
+ * 是否disabled
811
+ */
812
+ disableState: {
813
+ type: PropType<BooleanObjType>;
814
+ };
815
+ disableStateRules: {
816
+ type: PropType<BooleanRulesObjType>;
817
+ };
818
+ /**
819
+ *
820
+ */
821
+ columns: {
822
+ type: PropType<TColumns>;
823
+ };
824
+ columnState: {
825
+ type: PropType<Record<string, any>>;
826
+ };
827
+ /**
828
+ * 展示控件集合,readonly模式下使用这些组件渲染
829
+ */
830
+ elementMap: {
831
+ type: PropType<TElementMap>;
832
+ };
833
+ /**
834
+ * 录入控件集合
835
+ */
836
+ formElementMap: {
837
+ type: PropType<TElementMap>;
838
+ };
839
+ /**
840
+ * 是否启用rules验证
841
+ */
842
+ needRules: {
843
+ type: BooleanConstructor;
844
+ default: boolean;
845
+ };
846
+ /**
847
+ * provide传递
848
+ */
849
+ provideExtra: {
850
+ type: PropType<IProFormProvideExtra>;
851
+ };
852
+ }>>, {
853
+ readonly: boolean;
854
+ needRules: boolean;
855
+ }>;
856
+
857
+ declare enum SearchMode {
858
+ AUTO = "AUTO",
859
+ MANUAL = "MANUAL"
860
+ }
861
+ declare type ISearchMode = keyof typeof SearchMode;
862
+ declare const proSearchFormProps: () => {
863
+ /**
864
+ * 需要监听的对象
865
+ */
866
+ model: {
867
+ type: PropType<Record<string, any>>;
868
+ required: boolean;
869
+ };
870
+ /**
871
+ * 初始化触发 onFinish
872
+ */
873
+ initEmit: {
874
+ type: BooleanConstructor;
875
+ default: boolean;
876
+ };
877
+ /**
878
+ * 模式 自动触发或者手动触发 onFinish
879
+ */
880
+ searchMode: {
881
+ type: PropType<"AUTO" | "MANUAL">;
882
+ default: SearchMode;
883
+ };
884
+ /**
885
+ * 配置 同ProForm中的columns
886
+ * 可以根据column中valueType计算出默认的debounceKeys
887
+ */
888
+ columns: {
889
+ type: PropType<TColumns>;
890
+ };
891
+ /**
892
+ * 需要debounce处理的字段
893
+ */
894
+ debounceKeys: {
895
+ type: PropType<string[]>;
896
+ };
897
+ debounceTime: {
898
+ type: NumberConstructor;
899
+ default: number;
900
+ };
901
+ };
902
+ declare type ProSearchFormProps = Partial<ExtractPropTypes<ReturnType<typeof proSearchFormProps>>>;
903
+ /**
904
+ * 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
905
+ * 针对传入的model(监听对象)做相应的finish(回调)处理
906
+ */
907
+ declare const ProSearchForm: vue.DefineComponent<Partial<ExtractPropTypes<{
908
+ /**
909
+ * 需要监听的对象
910
+ */
911
+ model: {
912
+ type: PropType<Record<string, any>>;
913
+ required: boolean;
914
+ };
915
+ /**
916
+ * 初始化触发 onFinish
917
+ */
918
+ initEmit: {
919
+ type: BooleanConstructor;
920
+ default: boolean;
921
+ };
922
+ /**
923
+ * 模式 自动触发或者手动触发 onFinish
924
+ */
925
+ searchMode: {
926
+ type: PropType<"AUTO" | "MANUAL">;
927
+ default: SearchMode;
928
+ };
929
+ /**
930
+ * 配置 同ProForm中的columns
931
+ * 可以根据column中valueType计算出默认的debounceKeys
932
+ */
933
+ columns: {
934
+ type: PropType<TColumns>;
935
+ };
936
+ /**
937
+ * 需要debounce处理的字段
938
+ */
939
+ debounceKeys: {
940
+ type: PropType<string[]>;
941
+ };
942
+ debounceTime: {
943
+ type: NumberConstructor;
944
+ default: number;
945
+ };
946
+ }>>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<Partial<ExtractPropTypes<{
947
+ /**
948
+ * 需要监听的对象
949
+ */
950
+ model: {
951
+ type: PropType<Record<string, any>>;
952
+ required: boolean;
953
+ };
954
+ /**
955
+ * 初始化触发 onFinish
956
+ */
957
+ initEmit: {
958
+ type: BooleanConstructor;
959
+ default: boolean;
960
+ };
961
+ /**
962
+ * 模式 自动触发或者手动触发 onFinish
963
+ */
964
+ searchMode: {
965
+ type: PropType<"AUTO" | "MANUAL">;
966
+ default: SearchMode;
967
+ };
968
+ /**
969
+ * 配置 同ProForm中的columns
970
+ * 可以根据column中valueType计算出默认的debounceKeys
971
+ */
972
+ columns: {
973
+ type: PropType<TColumns>;
974
+ };
975
+ /**
976
+ * 需要debounce处理的字段
977
+ */
978
+ debounceKeys: {
979
+ type: PropType<string[]>;
980
+ };
981
+ debounceTime: {
982
+ type: NumberConstructor;
983
+ default: number;
984
+ };
985
+ }>>>, {}>;
986
+
987
+ interface FormItemProps {
988
+ name?: string | number | (string | number)[];
989
+ }
990
+ declare const proFormItemProps: () => {
991
+ readonly: {
992
+ type: BooleanConstructor;
993
+ default: undefined;
994
+ };
995
+ fieldProps: {
996
+ type: ObjectConstructor;
997
+ };
998
+ showProps: {
999
+ type: ObjectConstructor;
1000
+ };
1001
+ slots: {
1002
+ type: ObjectConstructor;
1003
+ };
1004
+ };
1005
+ declare type ProFormItemProps = Partial<ExtractPropTypes<ReturnType<typeof proFormItemProps>>> & Record<string, any>;
1006
+ declare const createFormItemCompFn: <T extends FormItemProps>(FormItem: any, convertInputCompProps: (value: any, setValue: (v: any) => void, disabled: boolean | undefined) => Record<string, any>) => ({ InputComp, valueType, name }: {
1007
+ InputComp: any;
1008
+ valueType: TValueType;
1009
+ name?: string | undefined;
1010
+ }) => vue.DefineComponent<T & Partial<ExtractPropTypes<{
1011
+ readonly: {
1012
+ type: BooleanConstructor;
1013
+ default: undefined;
1014
+ };
1015
+ fieldProps: {
1016
+ type: ObjectConstructor;
1017
+ };
1018
+ showProps: {
1019
+ type: ObjectConstructor;
1020
+ };
1021
+ slots: {
1022
+ type: ObjectConstructor;
1023
+ };
1024
+ }>> & Record<string, any>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<T & Partial<ExtractPropTypes<{
1025
+ readonly: {
1026
+ type: BooleanConstructor;
1027
+ default: undefined;
1028
+ };
1029
+ fieldProps: {
1030
+ type: ObjectConstructor;
1031
+ };
1032
+ showProps: {
1033
+ type: ObjectConstructor;
1034
+ };
1035
+ slots: {
1036
+ type: ObjectConstructor;
1037
+ };
1038
+ }>> & Record<string, any> extends vue.ComponentPropsOptions<{
1039
+ [x: string]: unknown;
1040
+ }> ? ExtractPropTypes<T & Partial<ExtractPropTypes<{
1041
+ readonly: {
1042
+ type: BooleanConstructor;
1043
+ default: undefined;
1044
+ };
1045
+ fieldProps: {
1046
+ type: ObjectConstructor;
1047
+ };
1048
+ showProps: {
1049
+ type: ObjectConstructor;
1050
+ };
1051
+ slots: {
1052
+ type: ObjectConstructor;
1053
+ };
1054
+ }>> & Record<string, any>> : T & Partial<ExtractPropTypes<{
1055
+ readonly: {
1056
+ type: BooleanConstructor;
1057
+ default: undefined;
1058
+ };
1059
+ fieldProps: {
1060
+ type: ObjectConstructor;
1061
+ };
1062
+ showProps: {
1063
+ type: ObjectConstructor;
1064
+ };
1065
+ slots: {
1066
+ type: ObjectConstructor;
1067
+ };
1068
+ }>> & Record<string, any>>, vue.ExtractDefaultPropTypes<T & Partial<ExtractPropTypes<{
1069
+ readonly: {
1070
+ type: BooleanConstructor;
1071
+ default: undefined;
1072
+ };
1073
+ fieldProps: {
1074
+ type: ObjectConstructor;
1075
+ };
1076
+ showProps: {
1077
+ type: ObjectConstructor;
1078
+ };
1079
+ slots: {
1080
+ type: ObjectConstructor;
1081
+ };
1082
+ }>> & Record<string, any>>>;
1083
+
1084
+ interface IProFormListProvide {
1085
+ pathList: (string | number)[];
1086
+ }
1087
+ declare const useProFormList: () => IProFormListProvide;
1088
+ declare const proFormListProps: () => {
1089
+ rowKey: {
1090
+ type: StringConstructor;
1091
+ default: string;
1092
+ };
1093
+ name: {
1094
+ type: PropType<string | number | (string | number)[]>;
1095
+ required: boolean;
1096
+ };
1097
+ };
1098
+ declare type ProFormListProps = Partial<ExtractPropTypes<ReturnType<typeof proFormListProps>>>;
1099
+ declare const ProFormList: vue.DefineComponent<Partial<ExtractPropTypes<{
1100
+ rowKey: {
1101
+ type: StringConstructor;
1102
+ default: string;
1103
+ };
1104
+ name: {
1105
+ type: PropType<string | number | (string | number)[]>;
1106
+ required: boolean;
1107
+ };
1108
+ }>>, {}, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, vue.EmitsOptions, string, vue.VNodeProps & vue.AllowedComponentProps & vue.ComponentCustomProps, Readonly<Partial<ExtractPropTypes<{
1109
+ rowKey: {
1110
+ type: StringConstructor;
1111
+ default: string;
1112
+ };
1113
+ name: {
1114
+ type: PropType<string | number | (string | number)[]>;
1115
+ required: boolean;
1116
+ };
1117
+ }>>>, {}>;
1118
+
1119
+ /**
1120
+ * 剔除showState或showStateRules规则为!true的值
1121
+ * @param values
1122
+ * @param showState
1123
+ * @param showStateRules
1124
+ */
1125
+ declare const getValidValues: (values: Record<string, any>, showState?: BooleanObjType | undefined, showStateRules?: BooleanRulesObjType | undefined) => Record<string, any>;
1126
+ /**
1127
+ * string类型的path转为arr
1128
+ * @param path
1129
+ */
1130
+ declare const convertPathToList: (path: undefined | string | number | (string | number)[]) => undefined | (string | number)[];
1131
+ /**
1132
+ * 唯一id
1133
+ */
1134
+ declare const generateId: () => string;
72
1135
  /**
73
- * 直接发起请求
1136
+ * 将listState 中的数据通过id merge到 list item中
1137
+ * ps:数组会替换
1138
+ * @param list
1139
+ * @param listState
1140
+ * @param id
74
1141
  */
75
- declare const useDirectRequest: <TRequestActor extends IRequestActor<any, any, any>>(requestActor: TRequestActor, params: TRequestActor["req"] | (() => TRequestActor["req"]), deps: any | any[]) => (BehaviorSubject<boolean> | vue.UnwrapNestedRefs<TRequestActor["res"]> | ((nextParams?: TRequestActor["req"] | undefined) => void))[];
1142
+ declare const mergeStateToList: (list: Record<string, any>[], listState: Record<string, any>, id: string | number | ((item: Record<string, any>) => string | number)) => Record<string, any>[];
76
1143
 
77
- export { ContentTypeInterceptor, DispatchRequestType, IRequestActor, IUseRequestOptions, ReqType, RequestProvideType, TRequestInterceptor, cancelActorIfExists, createRequest, createRequestActor, createRequestFactory, createRequestObservable, generateId, getRequestConfig, isCancelActor, isCancelRequestActor, isContentTypeFormURLEncoded, isContentTypeJSON, isContentTypeMultipartFormData, isDoneRequestActor, isFailedRequestActor, isPreRequestActor, paramsSerializer, toUrl, transformRequest, transformResponse, useDirectRequest, useRequest, useRequestProvide };
1144
+ export { BooleanObjType, BooleanRulesObjType, CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, FormItemProps, ICurdAction, ICurdAddAction, ICurdCurrentMode, ICurdOperateOpts, ICurdState, ICurdSubAction, IListData, IOperateItem, IProCurdProvide, IProFormProvideExtra, IProModuleProvide, IProTableProvide, IProTableProvideExtra, IRequestOpts, ISearchMode, ITableOperate, ProCurd, ProCurdProps, ProForm, ProFormItemProps, ProFormList, ProFormListProps, ProFormProps, ProModalCurd, ProModalCurdProps, ProModule, ProModuleProps, ProPageCurd, ProPageCurdProps, ProSearchForm, ProSearchFormProps, ProTable, ProTableProps, RequestAction, SearchMode, TActionEvent, TActionState, TColumn, TColumns, TCurdActionEvent, TDefaultValueType, TElementMap, TOption, TOptions, TTableColumn, TTableColumns, TValueType, convertPathToList, createFormItemCompFn, defaultPage, generateId, getColumnFormItemName, getColumnValueType, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProModule, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };