mod: 优化文件目录

This commit is contained in:
kailong321200875 2023-06-05 13:42:18 +08:00
parent ccbec86556
commit 855e4ca41b
6 changed files with 49 additions and 32 deletions

View File

@ -1,13 +1,45 @@
import Form from './src/Form.vue' import Form from './src/Form.vue'
import { ElForm } from 'element-plus' 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 { export interface FormExpose {
setValues: (data: Recordable) => void setValues: (data: Recordable) => void
setProps: (props: Recordable) => void setProps: (props: Recordable) => void
delSchema: (field: string) => void delSchema: (field: string) => void
addSchema: (formSchema: FormSchema, index?: number) => void addSchema: (formSchema: FormSchema, index?: number) => void
setSchema: (schemaProps: FormSetPropsType[]) => void setSchema: (schemaProps: FormSetProps[]) => void
formModel: Recordable formModel: Recordable
getElFormRef: () => ComponentRef<typeof ElForm> getElFormRef: () => ComponentRef<typeof ElForm>
} }

View File

@ -1,7 +1,7 @@
<script lang="tsx"> <script lang="tsx">
import { PropType, defineComponent, ref, computed, unref, watch, onMounted } from 'vue' import { PropType, defineComponent, ref, computed, unref, watch, onMounted } from 'vue'
import { ElForm, ElFormItem, ElRow, ElCol, ElTooltip } from 'element-plus' import { ElForm, ElFormItem, ElRow, ElCol, ElTooltip } from 'element-plus'
import { componentMap } from './componentMap' import { componentMap } from './helper/componentMap'
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { getSlot } from '@/utils/tsxHelper' import { getSlot } from '@/utils/tsxHelper'
import { import {
@ -22,7 +22,7 @@ import { FormProps } from './types'
import { Icon } from '@/components/Icon' import { Icon } from '@/components/Icon'
import { import {
FormSchema, FormSchema,
FormSetPropsType, FormSetProps,
ComponentNameEnum, ComponentNameEnum,
SelectComponentProps, SelectComponentProps,
RadioGroupComponentProps, RadioGroupComponentProps,
@ -110,7 +110,7 @@ export default defineComponent({
schema.push(formSchema) schema.push(formSchema)
} }
const setSchema = (schemaProps: FormSetPropsType[]) => { const setSchema = (schemaProps: FormSetProps[]) => {
const { schema } = unref(getProps) const { schema } = unref(getProps)
for (const v of schema) { for (const v of schema) {
for (const item of schemaProps) { 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 // Form
const getFormBindValue = () => { const getFormBindValue = () => {
// //

View File

@ -20,7 +20,7 @@ import {
} from 'element-plus' } from 'element-plus'
import { InputPassword } from '@/components/InputPassword' import { InputPassword } from '@/components/InputPassword'
import { Editor } from '@/components/Editor' import { Editor } from '@/components/Editor'
import { ComponentName } from './types' import { ComponentName } from '../types'
const componentMap: Recordable<Component, ComponentName> = { const componentMap: Recordable<Component, ComponentName> = {
RadioGroup: ElRadioGroup, RadioGroup: ElRadioGroup,

View File

@ -1,7 +1,7 @@
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { unref, type Slots } from 'vue' import { type Slots } from 'vue'
import { getSlot } from '@/utils/tsxHelper' 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 { isFunction } from '@/utils/is'
import { firstUpperCase, humpToDash } from '@/utils' import { firstUpperCase, humpToDash } from '@/utils'
@ -13,7 +13,7 @@ const { t } = useI18n()
* @returns * @returns
* @description placeholder * @description placeholder
*/ */
export const setTextPlaceholder = (schema: FormSchema): PlaceholderMoel => { export const setTextPlaceholder = (schema: FormSchema): PlaceholderModel => {
const textMap = [ const textMap = [
ComponentNameEnum.INPUT, ComponentNameEnum.INPUT,
ComponentNameEnum.AUTOCOMPLETE, ComponentNameEnum.AUTOCOMPLETE,

View File

@ -9,7 +9,7 @@ import {
} from 'element-plus' } from 'element-plus'
import type { AxiosPromise } from 'axios' import type { AxiosPromise } from 'axios'
export interface PlaceholderMoel { export interface PlaceholderModel {
placeholder?: string placeholder?: string
startPlaceholder?: string startPlaceholder?: string
endPlaceholder?: string endPlaceholder?: string
@ -66,7 +66,7 @@ export interface InputComponentProps {
suffixIcon?: string | JSX.Element suffixIcon?: string | JSX.Element
type?: InputProps['type'] type?: InputProps['type']
rows?: number rows?: number
autosize?: boolean | { Pows?: numer; maxRows?: number } autosize?: boolean | { Pows?: number; maxRows?: number }
autocomplete?: string autocomplete?: string
name?: string name?: string
readonly?: boolean readonly?: boolean
@ -741,7 +741,7 @@ export interface ColProps {
tag?: string tag?: string
} }
export type FormSetPropsType = { export interface FormSetProps {
field: string field: string
path: string path: string
value: any value: any
@ -749,7 +749,7 @@ export type FormSetPropsType = {
export type FormValueType = string | number | string[] | number[] | boolean | undefined | null export type FormValueType = string | number | string[] | number[] | boolean | undefined | null
export type FormItemProps = { export interface FormItemProps {
labelWidth?: string | number labelWidth?: string | number
required?: boolean required?: boolean
rules?: Recordable rules?: Recordable
@ -827,11 +827,12 @@ export interface FormSchema {
api?: <T = any>() => AxiosPromise<T> api?: <T = any>() => AxiosPromise<T>
} }
export type FormProps = { export interface FormProps {
schema?: FormSchema[] schema?: FormSchema[]
isCol?: boolean isCol?: boolean
model?: Recordable model?: Recordable
autoSetPlaceholder?: boolean autoSetPlaceholder?: boolean
isCustom?: boolean isCustom?: boolean
labelWidth?: string | number labelWidth?: string | number
} & Recordable [key: string]: any
}

View File

@ -5,7 +5,7 @@ import { useI18n } from '@/hooks/web/useI18n'
import { useIcon } from '@/hooks/web/useIcon' import { useIcon } from '@/hooks/web/useIcon'
import { ContentWrap } from '@/components/ContentWrap' import { ContentWrap } from '@/components/ContentWrap'
import { useAppStore } from '@/store/modules/app' 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 { useForm } from '@/hooks/web/useForm'
import { import {
ElOption, ElOption,