chore: add base props type & update props define
This commit is contained in:
parent
ac68cb94d2
commit
5ee4b35efc
|
@ -1,5 +1,5 @@
|
|||
import { ExtractPropTypes } from "vue";
|
||||
import { ViewType, EnumType } from './types';
|
||||
import { ViewType, EnumType, Type } from './types';
|
||||
|
||||
/**
|
||||
* 下拉列表属性
|
||||
|
@ -8,47 +8,35 @@ export const comboListProps = {
|
|||
/**
|
||||
* 组件标识
|
||||
*/
|
||||
id: String,
|
||||
id: Type(String),
|
||||
/**
|
||||
* 可选,是否禁用
|
||||
* 默认为false
|
||||
*/
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
disabled: Type({ default: false, type: Boolean }),
|
||||
/**
|
||||
* 可选,是否只读
|
||||
* 默认为false
|
||||
*/
|
||||
readonly: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
readonly: Type({ default: false, type: Boolean }),
|
||||
/**
|
||||
* 最大输入长度
|
||||
*/
|
||||
maxLength: Number,
|
||||
maxLength: Type(Number),
|
||||
/**
|
||||
* 占位符
|
||||
*/
|
||||
placeholder: String,
|
||||
placeholder: Type(String),
|
||||
/**
|
||||
* 可选,是否启用清空
|
||||
* 默认启用
|
||||
*/
|
||||
enableClear: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
enableClear: Type({ default: true, type: Boolean }),
|
||||
/**
|
||||
* 可选,鼠标悬停时是否显示控件值
|
||||
* 默认显示
|
||||
*/
|
||||
enableTitle: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
enableTitle: Type({ default: true, type: Boolean }),
|
||||
/**
|
||||
* 可选,下拉列表值展示方式
|
||||
* 支持text | tag,即文本或标签,默认为ViewType.Text,即文本方式
|
||||
|
@ -57,17 +45,20 @@ export const comboListProps = {
|
|||
/**
|
||||
* 可选,字段映射
|
||||
*/
|
||||
mapFields: Object,
|
||||
mapFields: Type(Object),
|
||||
/**
|
||||
* 下拉数据源
|
||||
*/
|
||||
data: Array,
|
||||
idField: {
|
||||
type: String,
|
||||
default: 'id'
|
||||
},
|
||||
valueField: {
|
||||
|
||||
}
|
||||
data: Type(Array),
|
||||
/**
|
||||
* 可选,数据源id字段
|
||||
* 默认为id
|
||||
*/
|
||||
idField: Type({ default: 'id', type: String }),
|
||||
/**
|
||||
* 可选,数据源值字段
|
||||
* 默认为id
|
||||
*/
|
||||
valueField: Type({ default: 'id', type: String })
|
||||
};
|
||||
export type ComboListProps = ExtractPropTypes<typeof comboListProps>;
|
|
@ -1,4 +1,4 @@
|
|||
import Constructor, { } from 'vue';
|
||||
import { Prop } from 'vue';
|
||||
/**
|
||||
* 下拉列表展现方式
|
||||
*/
|
||||
|
@ -7,7 +7,15 @@ export enum ViewType {
|
|||
Tag = 'tag'
|
||||
};
|
||||
/**
|
||||
* 枚举类型属性描述
|
||||
* 原始类型
|
||||
* @param options options
|
||||
* @returns
|
||||
*/
|
||||
export function Type<T, D>(options: Prop<T, D>) {
|
||||
return options;
|
||||
}
|
||||
/**
|
||||
* 枚举类型
|
||||
* @param defaultValue 默认值
|
||||
* @param enumType 枚举类型
|
||||
* @returns
|
||||
|
|
Loading…
Reference in New Issue