mod: 优化文件目录
This commit is contained in:
parent
ccbec86556
commit
855e4ca41b
|
@ -1,13 +1,45 @@
|
|||
import Form from './src/Form.vue'
|
||||
import { ElForm } from 'element-plus'
|
||||
import { FormSchema, FormSetPropsType } from './src/types'
|
||||
import { FormSchema, FormSetProps } from './src/types'
|
||||
export {
|
||||
PlaceholderModel,
|
||||
ComponentNameEnum,
|
||||
ComponentName,
|
||||
InputComponentProps,
|
||||
AutocompleteComponentProps,
|
||||
InputNumberComponentProps,
|
||||
SelectOption,
|
||||
SelectComponentProps,
|
||||
SelectV2ComponentProps,
|
||||
CascaderComponentProps,
|
||||
SwitchComponentProps,
|
||||
RateComponentProps,
|
||||
ColorPickerComponentProps,
|
||||
TransferComponentProps,
|
||||
RadioOption,
|
||||
RadioGroupComponentProps,
|
||||
RadioButtonComponentProps,
|
||||
CheckboxOption,
|
||||
CheckboxGroupComponentProps,
|
||||
DividerComponentProps,
|
||||
DatePickerComponentProps,
|
||||
DateTimePickerComponentProps,
|
||||
TimePickerComponentProps,
|
||||
TimeSelectComponentProps,
|
||||
ColProps,
|
||||
FormSetProps,
|
||||
FormValueType,
|
||||
FormItemProps,
|
||||
FormSchema,
|
||||
FormProps
|
||||
} from './src/types'
|
||||
|
||||
export interface FormExpose {
|
||||
setValues: (data: Recordable) => void
|
||||
setProps: (props: Recordable) => void
|
||||
delSchema: (field: string) => void
|
||||
addSchema: (formSchema: FormSchema, index?: number) => void
|
||||
setSchema: (schemaProps: FormSetPropsType[]) => void
|
||||
setSchema: (schemaProps: FormSetProps[]) => void
|
||||
formModel: Recordable
|
||||
getElFormRef: () => ComponentRef<typeof ElForm>
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<script lang="tsx">
|
||||
import { PropType, defineComponent, ref, computed, unref, watch, onMounted } from 'vue'
|
||||
import { ElForm, ElFormItem, ElRow, ElCol, ElTooltip } from 'element-plus'
|
||||
import { componentMap } from './componentMap'
|
||||
import { componentMap } from './helper/componentMap'
|
||||
import { propTypes } from '@/utils/propTypes'
|
||||
import { getSlot } from '@/utils/tsxHelper'
|
||||
import {
|
||||
|
@ -22,7 +22,7 @@ import { FormProps } from './types'
|
|||
import { Icon } from '@/components/Icon'
|
||||
import {
|
||||
FormSchema,
|
||||
FormSetPropsType,
|
||||
FormSetProps,
|
||||
ComponentNameEnum,
|
||||
SelectComponentProps,
|
||||
RadioGroupComponentProps,
|
||||
|
@ -110,7 +110,7 @@ export default defineComponent({
|
|||
schema.push(formSchema)
|
||||
}
|
||||
|
||||
const setSchema = (schemaProps: FormSetPropsType[]) => {
|
||||
const setSchema = (schemaProps: FormSetProps[]) => {
|
||||
const { schema } = unref(getProps)
|
||||
for (const v of schema) {
|
||||
for (const item of schemaProps) {
|
||||
|
@ -297,22 +297,6 @@ export default defineComponent({
|
|||
)
|
||||
}
|
||||
|
||||
// 渲染options
|
||||
// const renderOptions = (item: FormSchema) => {
|
||||
// switch (item.component) {
|
||||
// case ComponentNameEnum.SELECT:
|
||||
// return renderSelectOptions(item)
|
||||
// case ComponentNameEnum.RADIO:
|
||||
// case 'RadioButton':
|
||||
// return renderRadioOptions(item)
|
||||
// case 'Checkbox':
|
||||
// case 'CheckboxButton':
|
||||
// return renderCheckboxOptions(item)
|
||||
// default:
|
||||
// break
|
||||
// }
|
||||
// }
|
||||
|
||||
// 过滤传入Form组件的属性
|
||||
const getFormBindValue = () => {
|
||||
// 避免在标签上出现多余的属性
|
||||
|
|
|
@ -20,7 +20,7 @@ import {
|
|||
} from 'element-plus'
|
||||
import { InputPassword } from '@/components/InputPassword'
|
||||
import { Editor } from '@/components/Editor'
|
||||
import { ComponentName } from './types'
|
||||
import { ComponentName } from '../types'
|
||||
|
||||
const componentMap: Recordable<Component, ComponentName> = {
|
||||
RadioGroup: ElRadioGroup,
|
|
@ -1,7 +1,7 @@
|
|||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { unref, type Slots } from 'vue'
|
||||
import { type Slots } from 'vue'
|
||||
import { getSlot } from '@/utils/tsxHelper'
|
||||
import { PlaceholderMoel, FormSchema, ComponentNameEnum, ColProps } from './types'
|
||||
import { PlaceholderModel, FormSchema, ComponentNameEnum, ColProps } from '../types'
|
||||
import { isFunction } from '@/utils/is'
|
||||
import { firstUpperCase, humpToDash } from '@/utils'
|
||||
|
||||
|
@ -13,7 +13,7 @@ const { t } = useI18n()
|
|||
* @returns 返回提示信息对象
|
||||
* @description 用于自动设置placeholder
|
||||
*/
|
||||
export const setTextPlaceholder = (schema: FormSchema): PlaceholderMoel => {
|
||||
export const setTextPlaceholder = (schema: FormSchema): PlaceholderModel => {
|
||||
const textMap = [
|
||||
ComponentNameEnum.INPUT,
|
||||
ComponentNameEnum.AUTOCOMPLETE,
|
|
@ -9,7 +9,7 @@ import {
|
|||
} from 'element-plus'
|
||||
import type { AxiosPromise } from 'axios'
|
||||
|
||||
export interface PlaceholderMoel {
|
||||
export interface PlaceholderModel {
|
||||
placeholder?: string
|
||||
startPlaceholder?: string
|
||||
endPlaceholder?: string
|
||||
|
@ -66,7 +66,7 @@ export interface InputComponentProps {
|
|||
suffixIcon?: string | JSX.Element
|
||||
type?: InputProps['type']
|
||||
rows?: number
|
||||
autosize?: boolean | { Pows?: numer; maxRows?: number }
|
||||
autosize?: boolean | { Pows?: number; maxRows?: number }
|
||||
autocomplete?: string
|
||||
name?: string
|
||||
readonly?: boolean
|
||||
|
@ -741,7 +741,7 @@ export interface ColProps {
|
|||
tag?: string
|
||||
}
|
||||
|
||||
export type FormSetPropsType = {
|
||||
export interface FormSetProps {
|
||||
field: string
|
||||
path: string
|
||||
value: any
|
||||
|
@ -749,7 +749,7 @@ export type FormSetPropsType = {
|
|||
|
||||
export type FormValueType = string | number | string[] | number[] | boolean | undefined | null
|
||||
|
||||
export type FormItemProps = {
|
||||
export interface FormItemProps {
|
||||
labelWidth?: string | number
|
||||
required?: boolean
|
||||
rules?: Recordable
|
||||
|
@ -827,11 +827,12 @@ export interface FormSchema {
|
|||
api?: <T = any>() => AxiosPromise<T>
|
||||
}
|
||||
|
||||
export type FormProps = {
|
||||
export interface FormProps {
|
||||
schema?: FormSchema[]
|
||||
isCol?: boolean
|
||||
model?: Recordable
|
||||
autoSetPlaceholder?: boolean
|
||||
isCustom?: boolean
|
||||
labelWidth?: string | number
|
||||
} & Recordable
|
||||
[key: string]: any
|
||||
}
|
|
@ -5,7 +5,7 @@ import { useI18n } from '@/hooks/web/useI18n'
|
|||
import { useIcon } from '@/hooks/web/useIcon'
|
||||
import { ContentWrap } from '@/components/ContentWrap'
|
||||
import { useAppStore } from '@/store/modules/app'
|
||||
import { SelectOption, RadioOption, CheckboxOption, FormSchema } from '@/components/Form/src/types'
|
||||
import { SelectOption, RadioOption, CheckboxOption, FormSchema } from '@/components/Form'
|
||||
import { useForm } from '@/hooks/web/useForm'
|
||||
import {
|
||||
ElOption,
|
||||
|
|
Loading…
Reference in New Issue