Skip to content

Form 表单

TIP

Form 组件对应 GvForm。下方示例可直接交互,点击「显示代码」查看源码。

基础用法

API

Form Attributes

属性名说明类型默认值
ref-form设置form的ref属性string
form-list设置form的表单域listarray
divider设置form的分栏标题string检索分栏
is-divider设置是否默认自带分栏booleantrue
size设置form大小stringdefault
form-style设置form风格样式object{}
label-width设置label宽度(不带px的数字)number/string-
scroller设置是否开启滚动条booleantrue

Form Slots

插槽名说明
default设置form默认插槽,对于查询表单,插槽为 <GvSearchBar/> 按钮

Form Exposes

名称说明类型
model表单数据object
originFormList原始表单域listarray
setFormRef设置form的ref属性() => void

Form-Item Attributes

参数说明类型可选值默认值
type设置表单域的 type 属性string
label设置表单域的 label 属性string
value设置表单域的 value 属性any
field设置表单域的 field 字段属性string
hidden设置表单域是否隐藏booleantrue / falsefalse
keep设置表单域是否保持值在提交时不变booleantrue / falsetrue
format设置表单域的 format 格式属性array[0, 'isAny', 30]
disabled设置表单域的 disabled 属性booleantrue / falsefalse
readonly设置表单域的只读属性booleantrue / falsefalse
placeholder设置表单域的 placeholder 属性string
dateType设置表单域日期类型属性stringdate / datetime / daterange / year / month / weekdate
dicType设置表单域字典类型的字典类别string
filtercode设置表单域字典类型的过滤值属性(按 value 过滤)string
colspan设置表单域 colspan 占用列属性number1 / 2 / 3 / 4
disabledDateFunc设置表单域日期类型的禁用日期array
disabledDate设置表单域日期类型的禁用状态,参数为当前日期,返回 booleanFunction
editable设置表单域日期类型输入框是否可编辑booleantrue / falsetrue
multiple设置表单域字典类型是否可多选booleantrue / falsefalse
showLabel设置表单域字典类型的显示 labelstring
size设置表单域 size 属性stringmedium / small / mini
visible设置表单域是否可见booleantrue / falsetrue
actionstring
op设置查询条件是否恒等string= / likelike
upper设置当前查询条件转换为大写传给后台booleantrue / falsefalse
createRow设置是否创建新row,booleantrue / falsefalse
dicRemote设置表单域表选字典远程方法Function
cb设置表单域字典类型选中的回调方法Function
clear设置表单域字典类型清空的回调方法Function
rows设置表单域 textarea 的 rows 属性number
autosize设置表单域 textarea 自适应内容高度boolean | objectfalse
min设置 number 类型输入框的最小值number
max设置 number 类型输入框的最大值number
step设置 number 类型输入框的步长number1
precision设置 number 类型输入框的精度number0
blur设置表单域失去焦点的回调方法Function
focus设置表单域获取焦点的回调方法Function
suffixIcon设置表单域后缀图标属性string
prefixIcon设置表单域前缀图标属性string
change设置表单域改变的回调方法Function
defaultTime设置时间输入框默认能够选择的时间array
isreload设置表选字典是否使用缓存booleantrue / falsefalse
options设置级联字典的级联内容array
lazy设置级联字典cascader是否懒加载booleantrue / falsefalse
lazyLoad设置级联字典cascader懒加载方法Function
render自定义form样式Function

定义类型

typescript
// GvFormItem Props
interface FormItem {
  type?: string;
  label?: string;
  value?: any;
  field: string;
  hidden?: boolean;
  keep?: boolean;
  disabled?: boolean;
  format?: FormItemFormat;
  placeholder?: string;
  readonly?: boolean;
  dateType?: string;
  dicType?: string;
  filtercode?: string;
  colspan?: number;
  disabledDateFunc?: string[];
  disabledDate?: (data: Date) => boolean;
  editable?: boolean;
  multiple?: boolean;
  showLabel?: string[] | string;
  size?: string;
  visible?: boolean;
  action?: string;
  op?: string;
  upper?: boolean;
  createRow?: boolean;
  dicRemote?: Fn;
  cb?: (row: Recordable<any> | String, field: string, dicType: string) => void;
  clear?: (row: Recordable<any>, field: string, dicType: string) => void;
  rows?: number;
  autosize?: boolean;
  min?: number;
  max?: number;
  step?: number;
  precision?: number;
  blur?: (event: Event, value: any, field: string) => void;
  suffixIcon?: string;
  prefixIcon?: string;
  focus?: (event: Event, value: any, field: string) => void; /
  change?: (event: Event, value: any, field: string) => void;
  defaultTime?: Date;
  isreload?: boolean;
  options?: any[];
  lazy?: boolean;
  lazyLoad?: () => void;
  render?: (model: any, field: string) => any;
}