cc1-form 1.1.22 → 1.1.24

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,21 +1,4 @@
1
- /**
2
- * CurdOption 是 CurdConfig 的便捷类型别名,自动合并 CurdSearchDto 中的常用搜索字段(如 id、_id、status、createTime 等)
3
- *
4
- * @example
5
- * ```ts
6
- * // 使用 CurdOption 可省去手动声明常用搜索字段
7
- * const option: CurdOption<MyDto> = { ... }
8
- * ```
9
- */
10
- export type CurdOption<T = any> = CurdConfig<T & CurdSearchDto>;
11
- /** 下拉数据类型 */
12
- export type CurdSelectData = {
13
- [key: string]: any;
14
- /** 名称 */
15
- label: string;
16
- /** 值 */
17
- value: string;
18
- };
1
+ import TSys from "../../utils/TSys";
19
2
  /**
20
3
  * TCurd 组件的完整配置接口,用于声明搜索、表格、分页、表单、工具栏、API 等全部行为
21
4
  *
@@ -142,7 +125,7 @@ export interface CurdConfig<T = any> {
142
125
  */
143
126
  border: boolean;
144
127
  /**
145
- * 是否可多选
128
+ * 是否可多选 - 通过conf.table.selection.list获取已选数据
146
129
  */
147
130
  selectable: ((data: T) => boolean) | boolean;
148
131
  /**
@@ -179,6 +162,10 @@ export interface CurdConfig<T = any> {
179
162
  * 是否显示删除 - 默认显示
180
163
  */
181
164
  delete: ((data: T) => boolean) | boolean;
165
+ /**
166
+ * 是否显示查看 - 默认不显示
167
+ */
168
+ view: ((data: T) => boolean) | boolean;
182
169
  }>;
183
170
  /**
184
171
  * 工具栏配置
@@ -437,26 +424,13 @@ export interface CurdConfigColumn<T = any> {
437
424
  /**
438
425
  * 数据源
439
426
  * @example
440
- * //异步请求数据后调用方法覆盖数据源 示例
441
- * TForm.setOptionsData(
442
- * conf.option,
443
- * 'key',
444
- * [
445
- * {
446
- * label: 'label',
447
- * value: 'value'
448
- * }
449
- * ]
450
- * )
451
- *
427
+ * //异步请求数据后调用方法dataApi获取数据源,返回数据源后不再进行请求,如果返回false不进行更改之前的数据
428
+ * dataApi: async (param?: T) => {
429
+ * const res = await api.get(param)
430
+ * return res
431
+ * }
452
432
  */
453
- data: {
454
- [key: string]: any;
455
- /** 名称 */
456
- label: string;
457
- /** 值 */
458
- value: string;
459
- }[];
433
+ data: CurdSelectData[];
460
434
  /** 获取数据回调,如果传入,会在初始化、新增、编辑时调用,返回数据源后不再进行请求,如果返回false不进行更改之前的数据 */
461
435
  dataApi: (param?: T) => CurdSelectData[] | Promise<CurdSelectData[]> | boolean;
462
436
  /** 获取数据挂载配置 */
@@ -534,6 +508,44 @@ export interface CurdConfigColumn<T = any> {
534
508
  */
535
509
  inputClass: string;
536
510
  }>;
511
+ /**
512
+ * 单选按钮组属性 - 更多配置:https://element-plus.org/zh-CN/component/radio#radio-attributes
513
+ * 默认使用:
514
+ * @example
515
+ * <el-radio-group v-model="radio">
516
+ * <el-radio :value="3">Option A</el-radio>
517
+ * <el-radio :value="6">Option B</el-radio>
518
+ * <el-radio :value="9">Option C</el-radio>
519
+ * </el-radio-group>
520
+ */
521
+ radio?: Partial<{
522
+ [key: string]: any;
523
+ /**
524
+ * 事件
525
+ */
526
+ on: any;
527
+ /**
528
+ * 数据源
529
+ * @example
530
+ * //异步请求数据后调用方法dataApi获取数据源,返回数据源后不再进行请求,如果返回false不进行更改之前的数据
531
+ * dataApi: async (param?: T) => {
532
+ * const res = await api.get(param)
533
+ * return res
534
+ * }
535
+ */
536
+ data: CurdSelectData[];
537
+ /** 获取数据回调,如果传入,会在初始化、新增、编辑时调用,返回数据源后不再进行请求,如果返回false不进行更改之前的数据 */
538
+ dataApi: (param?: T) => CurdSelectData[] | Promise<CurdSelectData[]> | boolean;
539
+ /** 获取数据挂载配置 */
540
+ dataApiConfig: {
541
+ /** 是否只获取一次数据 - 默认为true */
542
+ once: boolean;
543
+ /** 是否在初始化时获取数据 - 默认为true */
544
+ init: boolean;
545
+ /** 是否在编辑或新增操作前获取数据 - 默认为true */
546
+ update: boolean;
547
+ };
548
+ }>;
537
549
  };
538
550
  /**
539
551
  * 新增编辑表单配置
@@ -680,9 +692,9 @@ export interface CurdConfigColumn<T = any> {
680
692
  */
681
693
  search?: ((data: T) => boolean) | boolean;
682
694
  /**
683
- * 新增编辑表单排序
695
+ * 表单显示(新增、编辑、查看)
684
696
  */
685
- form?: ((data: T) => boolean) | boolean;
697
+ form?: ((data: T, type: typeof TSys.EDialog.Insert | typeof TSys.EDialog.Update | typeof TSys.EDialog.View) => boolean) | boolean;
686
698
  };
687
699
  /**
688
700
  * 排序
@@ -746,4 +758,22 @@ interface CurdSearchDto {
746
758
  */
747
759
  parentId: string;
748
760
  }
761
+ /**
762
+ * CurdOption 是 CurdConfig 的便捷类型别名,自动合并 CurdSearchDto 中的常用搜索字段(如 id、_id、status、createTime 等)
763
+ *
764
+ * @example
765
+ * ```ts
766
+ * // 使用 CurdOption 可省去手动声明常用搜索字段
767
+ * const option: CurdOption<MyDto> = { ... }
768
+ * ```
769
+ */
770
+ export type CurdOption<T = any> = CurdConfig<T & CurdSearchDto>;
771
+ /** 下拉数据类型 */
772
+ export type CurdSelectData = {
773
+ [key: string]: any;
774
+ /** 名称 */
775
+ label: string;
776
+ /** 值 */
777
+ value: string;
778
+ };
749
779
  export {};
@@ -2,6 +2,8 @@ import { curdConf } from '.';
2
2
  import type { CurdConfig, CurdConfigColumn } from './indexType';
3
3
  import questionFilled from './icon/questionFilled.vue';
4
4
  import { ElInput, ElOption, ElSelect, ElSwitch, ElTableColumn } from 'element-plus';
5
+ import TSys from '../../utils/TSys';
6
+ declare const isFun: (fun: any, ...args: any[]) => any;
5
7
  type __VLS_Props = {
6
8
  conf: ReturnType<typeof curdConf>['conf'];
7
9
  columnList: CurdConfigColumn[];
@@ -29,6 +31,8 @@ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
29
31
  ElSelect: typeof ElSelect;
30
32
  ElSwitch: typeof ElSwitch;
31
33
  ElTableColumn: typeof ElTableColumn;
34
+ TSys: typeof TSys;
35
+ isFun: typeof isFun;
32
36
  self: typeof self;
33
37
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
34
38
  declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { App } from 'vue';
2
2
  import { type CurdConfig, type CurdConfigColumn, type CurdOption } from './components/TCurd/indexType';
3
+ import type { curdConfType } from './components/TCurd/index';
3
4
  import TColumn from './components/TCurd/com/form/column.vue';
4
5
  import TFormList from './components/TCurd/com/form/list.vue';
5
6
  import './components/TCurd/index.less';
@@ -45,7 +46,7 @@ export declare const install: (app: App, options?: {
45
46
  [key: string]: any;
46
47
  };
47
48
  }) => void;
48
- export { ArrUtil, ExcelUtil, TColumn, TCurd, TForm, TFormList, TFormI18n, TSys, TFile, TFormConfig, type CurdConfig, type CurdConfigColumn, type CurdOption };
49
+ export { ArrUtil, ExcelUtil, TColumn, TCurd, TForm, TFormList, TFormI18n, TSys, TFile, TFormConfig, type CurdConfig, type CurdConfigColumn, type CurdOption, type curdConfType };
49
50
  declare const _default: {
50
51
  install: (app: App, options?: {
51
52
  /**
@@ -285,6 +285,16 @@ export default class TFormConfig {
285
285
  update: boolean;
286
286
  };
287
287
  };
288
+ radio: {
289
+ data: never[];
290
+ dataPath: string;
291
+ dataApiConfig: {
292
+ once: boolean;
293
+ init: boolean;
294
+ create: boolean;
295
+ update: boolean;
296
+ };
297
+ };
288
298
  };
289
299
  };
290
300
  };
@@ -4,6 +4,7 @@ declare const curdI18n: {
4
4
  search: string;
5
5
  add: string;
6
6
  edit: string;
7
+ view: string;
7
8
  delete: string;
8
9
  export: string;
9
10
  exportSelect: string;
@@ -78,6 +79,7 @@ export default class TFormI18n {
78
79
  search: string;
79
80
  add: string;
80
81
  edit: string;
82
+ view: string;
81
83
  delete: string;
82
84
  export: string;
83
85
  exportSelect: string;
@@ -40,6 +40,7 @@ export default class TSys {
40
40
  static EDialog: {
41
41
  Insert: any;
42
42
  Update: any;
43
+ View: any;
43
44
  Remove: any;
44
45
  };
45
46
  /**
@@ -48,7 +49,7 @@ export default class TSys {
48
49
  * @param data 数据
49
50
  * @returns 是否显示
50
51
  */
51
- static isFun: (fun: any, data?: any) => any;
52
+ static isFun: (fun: any, ...args: any[]) => any;
52
53
  /**
53
54
  * 获取路由参数,自动获取query、params中的参数, 哪个有就返回哪个
54
55
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc1-form",
3
- "version": "1.1.22",
3
+ "version": "1.1.24",
4
4
  "description": "我来助你-表单组件库",
5
5
  "repository": {
6
6
  "type": "git",