UNPKG

hr-dynamic-form

Version:

dynamic form creator

47 lines (44 loc) 1.59 kB
import CustomInput from './custom-input/index.vue' import CustomSelect from './custom-select/index.vue' import { inputMerge } from '@/test-npm' // 新建自定义组件后在这里注册 const customComponents = { CustomInput, CustomSelect } // 新建自定义组建后,这里注册组件默认配置 const itemsConfig = function(hideList) { let list = [ inputMerge({ name: 'CustomInput', type: 'text', isQuery: true, autofocus: false, hideInTable: false, hideInExport: false, maxlength: 100, label: '文本框', setting: { prefixIcon: '', suffixIcon: '' }}), inputMerge({ name: 'CustomInput', type: 'number', isQuery: true, autofocus: false, hideInTable: false, hideInExport: false, min: 1, maxlength: 100, label: '数字框', setting: { prefixIcon: '', suffixIcon: '' }}) ] if (typeof hideList === 'string') { list = list.filter(item => item.name !== hideList) } else if (Object.prototype.toString.call(hideList) === '[object Array]' && hideList.length) { list = list.filter(item => !hideList.find(i => i === item.name)) } return list } // const filterConfig = (config) export const initCustomItems = function(hideList) { const list = [] if (!hideList || !hideList.length || !(hideList === 'CustomGroup1' || hideList.find && hideList.find(hide => hide === 'CustomGroup1'))) { list.push({ label: '业务组件库', name: 'CustomGroup1', list: [ ...itemsConfig(hideList) ] }) } return list } export default { ...customComponents }