123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- export interface Rules {
- trigger: string
- enum: string
- len?: number
- max?: number
- message: string
- min?: number
- pattern: string
- required: boolean
- type: string
- }
- export interface WidgetForm {
- list: any[]
- config: {
- size: '' | 'default' | 'small' | 'large'
- hideRequiredAsterisk: boolean
- labelWidth: number
- labelPosition: 'top' | 'right' | 'left'
- }
- }
- const rules: Rules = {
- trigger: 'blur',
- enum: '',
- len: undefined,
- max: undefined,
- message: '',
- min: undefined,
- pattern: '',
- required: false,
- type: 'any',
- }
- export const getWidgetForm = (): WidgetForm => ({
- list: [],
- config: {
- size: 'default',
- hideRequiredAsterisk: false,
- labelWidth: 100,
- labelPosition: 'right',
- },
- })
- export const basicComponents = [
- {
- label: '单行文本',
- type: 'input' as const,
- options: {
- width: '100%',
- defaultValue: '',
- placeholder: '',
- maxlength: null,
- prefix: '',
- suffix: '',
- prepend: '',
- append: '',
- disabled: false,
- clearable: false,
- readonly: false,
- rules,
- },
- },
- {
- label: '密码框',
- type: 'password' as const,
- options: {
- width: '100%',
- defaultValue: '',
- placeholder: '',
- maxlength: null,
- prefix: '',
- suffix: '',
- prepend: '',
- append: '',
- showPassword: true,
- disabled: false,
- clearable: false,
- readonly: false,
- rules,
- },
- },
- {
- label: '多行文本',
- type: 'textarea' as const,
- options: {
- width: '100%',
- defaultValue: '',
- placeholder: '',
- maxlength: null,
- rows: 4,
- autosize: false,
- showWordLimit: false,
- disabled: false,
- clearable: false,
- readonly: false,
- rules,
- },
- },
- {
- label: '计数器',
- type: 'number' as const,
- options: {
- width: '',
- defaultValue: 0,
- min: 0,
- max: 100,
- step: 1,
- disabled: false,
- rules,
- },
- },
- {
- label: '单选框组',
- type: 'radio' as const,
- options: {
- defaultValue: '',
- width: '',
- inline: true,
- remote: false,
- showLabel: true,
- remoteFunc:
- 'https://raw.githubusercontent.com/fuchengwei/vue-form-create/master/mock/mock.json',
- options: [
- {
- value: 'Option 1',
- label: 'Option 1',
- },
- {
- value: 'Option 2',
- label: 'Option 2',
- },
- {
- value: 'Option 3',
- label: 'Option 3',
- },
- ],
- remoteOptions: [],
- props: {
- value: 'value',
- label: 'label',
- },
- disabled: false,
- rules,
- },
- },
- {
- label: '多选框组',
- type: 'checkbox' as const,
- options: {
- defaultValue: [],
- width: '',
- inline: true,
- remote: false,
- showLabel: true,
- remoteFunc:
- 'https://raw.githubusercontent.com/fuchengwei/vue-form-create/master/mock/mock.json',
- options: [
- {
- label: 'Option 1',
- value: 'Option 1',
- },
- {
- label: 'Option 2',
- value: 'Option 2',
- },
- {
- label: 'Option 3',
- value: 'Option 3',
- },
- ],
- remoteOptions: [],
- props: {
- value: 'value',
- label: 'label',
- },
- disabled: false,
- rules,
- },
- },
- {
- label: '时间选择器',
- type: 'time' as const,
- options: {
- defaultValue: '',
- width: '',
- placeholder: '请选择时间',
- format: 'HH:mm:ss',
- valueFormat: 'HH:mm:ss',
- readonly: false,
- editable: true,
- clearable: true,
- disabled: false,
- rules,
- },
- },
- {
- label: '日期选择器',
- type: 'date' as const,
- options: {
- defaultValue: '',
- width: '',
- placeholder: '请选择时间',
- format: 'YYYY-MM-DD',
- readonly: false,
- editable: true,
- clearable: true,
- disabled: false,
- rules,
- },
- },
- {
- label: '评分',
- type: 'rate' as const,
- options: {
- defaultValue: 0,
- max: 5,
- allowHalf: false,
- disabled: false,
- rules,
- },
- },
- {
- label: '下拉选择框',
- type: 'select' as const,
- options: {
- defaultValue: '',
- width: '200px',
- multiple: false,
- placeholder: '',
- remote: false,
- showLabel: true,
- filterable: false,
- clearable: false,
- disabled: false,
- props: {
- label: 'label',
- value: 'value',
- },
- options: [
- {
- label: 'Option 1',
- value: 'Option 1',
- },
- {
- label: 'Option 2',
- value: 'Option 2',
- },
- {
- label: 'Option 3',
- value: 'Option 3',
- },
- ],
- remoteOptions: [],
- remoteFunc:
- 'https://raw.githubusercontent.com/fuchengwei/vue-form-create/master/mock/mock.json',
- rules,
- },
- },
- {
- label: '开关',
- type: 'switch' as const,
- options: {
- defaultValue: false,
- disabled: false,
- activeText: '',
- inactiveText: '',
- rules,
- },
- },
- {
- label: '滑块',
- type: 'slider' as const,
- options: {
- defaultValue: 0,
- width: '',
- min: 0,
- max: 100,
- step: 1,
- disabled: false,
- range: false,
- rules,
- },
- },
- {
- label: '文字',
- type: 'text' as const,
- options: {
- defaultValue: 'This is a text',
- },
- },
- ]
- export const basicFields = (basicComponents).map(i => i.type)
- export const advanceComponents = [
- {
- label: '图片',
- type: 'img-upload' as const,
- options: {
- defaultValue: [],
- name: 'file',
- action: 'http://example.com/upload',
- method: 'post',
- listType: 'text',
- accept: 'image/*',
- limit: 1,
- multiple: false,
- disabled: true,
- rules,
- },
- },
- {
- label: '下载',
- type: 'download' as const,
- labelWidth: 'auto',
- options: {
- defaultValue: '',
- name: 'file',
- },
- },
- {
- label: '级联选择器',
- type: 'cascader' as const,
- options: {
- defaultValue: [],
- width: '200px',
- placeholder: '',
- disabled: false,
- clearable: false,
- filterable: false,
- remote: true,
- remoteOptions: [],
- props: {
- label: 'label',
- value: 'value',
- children: 'children',
- },
- remoteFunc:
- 'https://raw.githubusercontent.com/fuchengwei/vue-form-create/master/mock/mock.json',
- rules,
- },
- },
- ]
- export const advanceFields = (advanceComponents).map(i => i.type)
- export const layoutComponents = [
- {
- label: '栅格布局',
- type: 'grid',
- columns: [
- {
- span: 12,
- list: [],
- },
- {
- span: 12,
- list: [],
- },
- ],
- options: {
- gutter: 0,
- align: 'initial',
- },
- },
- {
- label: '数据表格',
- type: 'table',
- columns: [
- { label: '名称', prop: 'name' },
- { label: '创建时间', prop: 'createTime' },
- ],
- options: {
- defaultValue: [],
- disabled: false,
- size: '',
- align: 'center',
- },
- },
- {
- label: '分割线',
- type: 'divider',
- options: {},
- },
- ]
- export const layoutFields = (layoutComponents).map(i => i.type)
|