feat: type抽离
This commit is contained in:
parent
a62929a8da
commit
8b4fa1aa21
|
@ -7,13 +7,14 @@ import { useWindowSize } from '@vueuse/core'
|
|||
import { useAppStore } from '@/store/modules/app'
|
||||
import { setCssVar } from '@/utils'
|
||||
import { useDesign } from '@/hooks/web/useDesign'
|
||||
import { ElementPlusSize } from '@/types/elementPlus'
|
||||
|
||||
const { variables } = useDesign()
|
||||
|
||||
const appStore = useAppStore()
|
||||
|
||||
const props = defineProps({
|
||||
size: propTypes.oneOf<ElememtPlusSize[]>(['default', 'small', 'large']).def('default')
|
||||
size: propTypes.oneOf<ElementPlusSize[]>(['default', 'small', 'large']).def('default')
|
||||
})
|
||||
|
||||
provide('configGlobal', props)
|
||||
|
|
|
@ -4,7 +4,7 @@ import { PropType, ref } from 'vue'
|
|||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useDesign } from '@/hooks/web/useDesign'
|
||||
import type { RouteLocationNormalizedLoaded } from 'vue-router'
|
||||
|
||||
import { contextMenuSchema } from '../../../types/contextMenu'
|
||||
const { getPrefixCls } = useDesign()
|
||||
|
||||
const prefixCls = getPrefixCls('context-menu')
|
||||
|
|
|
@ -4,6 +4,7 @@ import { useDesign } from '@/hooks/web/useDesign'
|
|||
import { propTypes } from '@/utils/propTypes'
|
||||
import { ref, unref, PropType, computed, useAttrs } from 'vue'
|
||||
import { useAppStore } from '@/store/modules/app'
|
||||
import { DescriptionsSchema } from '@/types/descriptions'
|
||||
|
||||
const appStore = useAppStore()
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Form from './src/Form.vue'
|
||||
import { ElForm } from 'element-plus'
|
||||
import { FormSchema, FormSetPropsType } from '@/types/form'
|
||||
|
||||
export interface FormExpose {
|
||||
setValues: (data: Recordable) => void
|
||||
|
|
|
@ -20,6 +20,7 @@ import { findIndex } from '@/utils'
|
|||
import { set } from 'lodash-es'
|
||||
import { FormProps } from './types'
|
||||
import { Icon } from '@/components/Icon'
|
||||
import { FormSchema, FormSetPropsType } from '@/types/form'
|
||||
|
||||
const { getPrefixCls } = useDesign()
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import {
|
|||
} from 'element-plus'
|
||||
import { InputPassword } from '@/components/InputPassword'
|
||||
import { Editor } from '@/components/Editor'
|
||||
import { ComponentName } from '@/types/components'
|
||||
|
||||
const componentMap: Recordable<Component, ComponentName> = {
|
||||
Radio: ElRadioGroup,
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { FormSchema } from '@/types/form'
|
||||
import { ElCheckbox, ElCheckboxButton } from 'element-plus'
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { FormSchema } from '@/types/form'
|
||||
import { ElRadio, ElRadioButton } from 'element-plus'
|
||||
import { defineComponent } from 'vue'
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import { ElOption, ElOptionGroup } from 'element-plus'
|
||||
import { getSlot } from '@/utils/tsxHelper'
|
||||
import { Slots } from 'vue'
|
||||
import { FormSchema } from '@/types/form'
|
||||
import { ComponentOptions } from '@/types/components'
|
||||
|
||||
export const useRenderSelect = (slots: Slots) => {
|
||||
// 渲染 select options
|
||||
|
|
|
@ -2,6 +2,7 @@ import { useI18n } from '@/hooks/web/useI18n'
|
|||
import type { Slots } from 'vue'
|
||||
import { getSlot } from '@/utils/tsxHelper'
|
||||
import { PlaceholderMoel } from './types'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { FormSchema } from '@/types/form'
|
||||
|
||||
export interface PlaceholderMoel {
|
||||
placeholder?: string
|
||||
startPlaceholder?: string
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
<script setup lang="ts">
|
||||
import { PropType } from 'vue'
|
||||
import { Highlight } from '@//components/Highlight'
|
||||
import { Highlight } from '@/components/Highlight'
|
||||
import { useDesign } from '@/hooks/web/useDesign'
|
||||
import { propTypes } from '@/utils/propTypes'
|
||||
import { TipSchema } from '@/types/infoTip';
|
||||
|
||||
const { getPrefixCls } = useDesign()
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { cloneDeep } from 'lodash-es'
|
|||
import { propTypes } from '@/utils/propTypes'
|
||||
import { useDesign } from '@/hooks/web/useDesign'
|
||||
import { isString } from '@/utils/is'
|
||||
import { QrcodeLogo } from '@/types/qrcode'
|
||||
|
||||
const props = defineProps({
|
||||
// img 或者 canvas,img不支持logo嵌套
|
||||
|
|
|
@ -7,6 +7,7 @@ import { useI18n } from '@/hooks/web/useI18n'
|
|||
import { useForm } from '@/hooks/web/useForm'
|
||||
import { findIndex } from '@/utils'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import { useAppStore } from '@/store/modules/app'
|
|||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { propTypes } from '@/utils/propTypes'
|
||||
import { useDesign } from '@/hooks/web/useDesign'
|
||||
import { ElementPlusSize } from '@/types/elementPlus'
|
||||
|
||||
const { getPrefixCls } = useDesign()
|
||||
|
||||
|
@ -20,7 +21,7 @@ const appStore = useAppStore()
|
|||
|
||||
const sizeMap = computed(() => appStore.sizeMap)
|
||||
|
||||
const setCurrentSize = (size: ElememtPlusSize) => {
|
||||
const setCurrentSize = (size: ElementPlusSize) => {
|
||||
appStore.setCurrentSize(size)
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Table from './src/Table.vue'
|
||||
import { ElTable } from 'element-plus'
|
||||
import { TableSetPropsType } from '@/types/table'
|
||||
|
||||
export interface TableExpose {
|
||||
setProps: (props: Recordable) => void
|
||||
|
|
|
@ -6,6 +6,7 @@ import { setIndex } from './helper'
|
|||
import { getSlot } from '@/utils/tsxHelper'
|
||||
import type { TableProps } from './types'
|
||||
import { set } from 'lodash-es'
|
||||
import { TableColumn, TableSlotDefault, Pagination, TableSetPropsType } from '../../../types/table'
|
||||
|
||||
export default defineComponent({
|
||||
name: 'Table',
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Pagination, TableColumn } from '@/types/table'
|
||||
|
||||
export type TableProps = {
|
||||
pageSize?: number
|
||||
currentPage?: number
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { useCache } from '@/hooks/web/useCache'
|
||||
import { ElementPlusSize } from '@/types/elementPlus'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
|
||||
|
@ -40,8 +41,8 @@ export interface AppState {
|
|||
title: string
|
||||
userInfo: string
|
||||
isDark: boolean
|
||||
currentSize: ElememtPlusSize
|
||||
sizeMap: ElememtPlusSize[]
|
||||
currentSize: ElementPlusSize
|
||||
sizeMap: ElementPlusSize[]
|
||||
mobile: boolean
|
||||
footer: boolean
|
||||
theme: ThemeTypes
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { useCache } from '@/hooks/web/useCache'
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn'
|
||||
import en from 'element-plus/es/locale/lang/en'
|
||||
import { LocaleDropdownType } from '@/types/localeDropdown'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { ConfigGlobalTypes } from '@/types/configGlobal'
|
||||
import { inject } from 'vue'
|
||||
|
||||
export const useConfigGlobal = () => {
|
||||
|
|
|
@ -4,6 +4,9 @@ import { findIndex } from '@/utils'
|
|||
import { useDictStoreWithOut } from '@/store/modules/dict'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import type { AxiosPromise } from 'axios'
|
||||
import { FormSchema } from '@/types/form'
|
||||
import { TableColumn } from '@/types/table'
|
||||
import { DescriptionsSchema } from '@/types/descriptions'
|
||||
|
||||
export type CrudSchema = Omit<TableColumn, 'children'> & {
|
||||
search?: CrudSearchParams
|
||||
|
|
|
@ -2,6 +2,7 @@ import type { Form, FormExpose } from '@/components/Form'
|
|||
import type { ElForm } from 'element-plus'
|
||||
import { ref, unref, nextTick } from 'vue'
|
||||
import type { FormProps } from '@/components/Form/src/types'
|
||||
import { FormSchema, FormSetPropsType } from '@/types/form'
|
||||
|
||||
export const useForm = (props?: FormProps) => {
|
||||
// From实例
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { h } from 'vue'
|
||||
import type { VNode } from 'vue'
|
||||
import { Icon } from '@/components/Icon'
|
||||
import { IconTypes } from '@/types/icon'
|
||||
|
||||
export const useIcon = (props: IconTypes): VNode => {
|
||||
return h(Icon, props)
|
||||
|
|
|
@ -4,6 +4,7 @@ import { ref, reactive, watch, computed, unref, nextTick } from 'vue'
|
|||
import { get } from 'lodash-es'
|
||||
import type { TableProps } from '@/components/Table/src/types'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { TableSetPropsType } from '@/types/table'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
@ -144,17 +145,13 @@ export const useTable = <T = any>(config?: UseTableConfig<T>) => {
|
|||
},
|
||||
// 与Search组件结合
|
||||
setSearchParams: (data: Recordable) => {
|
||||
tableObject.currentPage = 1
|
||||
tableObject.params = Object.assign(tableObject.params, {
|
||||
pageSize: tableObject.pageSize,
|
||||
pageIndex: 1,
|
||||
pageIndex: tableObject.currentPage,
|
||||
...data
|
||||
})
|
||||
// 页码不等于1时更新页码重新获取数据,页码等于1时重新获取数据
|
||||
if (tableObject.currentPage !== 1) {
|
||||
tableObject.currentPage = 1
|
||||
} else {
|
||||
methods.getList()
|
||||
}
|
||||
methods.getList()
|
||||
},
|
||||
// 删除数据
|
||||
delList: async (ids: string[] | number[], multiple: boolean, message = true) => {
|
||||
|
|
|
@ -5,6 +5,7 @@ import { appModules } from '@/config/app'
|
|||
import type { AppState, LayoutType, ThemeTypes } from '@/config/app'
|
||||
import { setCssVar, humpToUnderline } from '@/utils'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ElementPlusSize } from '@/types/elementPlus'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
|
||||
|
@ -72,10 +73,10 @@ export const useAppStore = defineStore({
|
|||
getIsDark(): boolean {
|
||||
return this.isDark
|
||||
},
|
||||
getCurrentSize(): ElememtPlusSize {
|
||||
getCurrentSize(): ElementPlusSize {
|
||||
return this.currentSize
|
||||
},
|
||||
getSizeMap(): ElememtPlusSize[] {
|
||||
getSizeMap(): ElementPlusSize[] {
|
||||
return this.sizeMap
|
||||
},
|
||||
getMobile(): boolean {
|
||||
|
@ -157,7 +158,7 @@ export const useAppStore = defineStore({
|
|||
}
|
||||
wsCache.set('isDark', this.isDark)
|
||||
},
|
||||
setCurrentSize(currentSize: ElememtPlusSize) {
|
||||
setCurrentSize(currentSize: ElementPlusSize) {
|
||||
this.currentSize = currentSize
|
||||
wsCache.set('currentSize', this.currentSize)
|
||||
},
|
||||
|
|
|
@ -3,6 +3,7 @@ import { store } from '../index'
|
|||
import { useCache } from '@/hooks/web/useCache'
|
||||
import { localeModules, elLocaleMap } from '@/config/locale'
|
||||
import type { LocaleState } from '@/config/locale'
|
||||
import { LocaleDropdownType } from '@/types/localeDropdown'
|
||||
|
||||
const { wsCache } = useCache()
|
||||
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
export type ComponentName =
|
||||
| 'Radio'
|
||||
| 'RadioButton'
|
||||
| 'Checkbox'
|
||||
| 'CheckboxButton'
|
||||
| 'Input'
|
||||
| 'Autocomplete'
|
||||
| 'InputNumber'
|
||||
| 'Select'
|
||||
| 'Cascader'
|
||||
| 'Switch'
|
||||
| 'Slider'
|
||||
| 'TimePicker'
|
||||
| 'DatePicker'
|
||||
| 'Rate'
|
||||
| 'ColorPicker'
|
||||
| 'Transfer'
|
||||
| 'Divider'
|
||||
| 'TimeSelect'
|
||||
| 'SelectV2'
|
||||
| 'InputPassword'
|
||||
| 'Editor'
|
||||
|
||||
export type ColProps = {
|
||||
span?: number
|
||||
xs?: number
|
||||
sm?: number
|
||||
md?: number
|
||||
lg?: number
|
||||
xl?: number
|
||||
tag?: string
|
||||
}
|
||||
|
||||
export type ComponentOptions = {
|
||||
label?: string
|
||||
value?: FormValueType
|
||||
disabled?: boolean
|
||||
key?: string | number
|
||||
children?: ComponentOptions[]
|
||||
options?: ComponentOptions[]
|
||||
} & Recordable
|
||||
|
||||
export type ComponentOptionsAlias = {
|
||||
labelField?: string
|
||||
valueField?: string
|
||||
}
|
||||
|
||||
export type ComponentProps = {
|
||||
optionsAlias?: ComponentOptionsAlias
|
||||
options?: ComponentOptions[]
|
||||
optionsSlot?: boolean
|
||||
} & Recordable
|
|
@ -0,0 +1,4 @@
|
|||
import { ElementPlusSize } from './elementPlus'
|
||||
export interface ConfigGlobalTypes {
|
||||
size?: ElementPlusSize
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export type contextMenuSchema = {
|
||||
disabled?: boolean
|
||||
divided?: boolean
|
||||
icon?: string
|
||||
label: string
|
||||
command?: (item: contextMenuSchema) => void
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
declare interface DescriptionsSchema {
|
||||
export interface DescriptionsSchema {
|
||||
span?: number // 占多少分
|
||||
field: string // 字段名
|
||||
label?: string // label名
|
|
@ -0,0 +1,3 @@
|
|||
export type ElementPlusSize = 'default' | 'small' | 'large'
|
||||
|
||||
export type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'
|
|
@ -0,0 +1,45 @@
|
|||
import type { CSSProperties } from 'vue'
|
||||
import { ColProps, ComponentProps, ComponentName } from '@/types/components'
|
||||
import { FormValueType, FormValueType } from '@/types/form'
|
||||
import type { AxiosPromise } from 'axios'
|
||||
|
||||
export type FormSetPropsType = {
|
||||
field: string
|
||||
path: string
|
||||
value: any
|
||||
}
|
||||
|
||||
export type FormValueType = string | number | string[] | number[] | boolean | undefined | null
|
||||
|
||||
export type FormItemProps = {
|
||||
labelWidth?: string | number
|
||||
required?: boolean
|
||||
rules?: Recordable
|
||||
error?: string
|
||||
showMessage?: boolean
|
||||
inlineMessage?: boolean
|
||||
style?: CSSProperties
|
||||
}
|
||||
|
||||
export type FormSchema = {
|
||||
// 唯一值
|
||||
field: string
|
||||
// 标题
|
||||
label?: string
|
||||
// 提示
|
||||
labelMessage?: string
|
||||
// col组件属性
|
||||
colProps?: ColProps
|
||||
// 表单组件属性,slots对应的是表单组件的插槽,规则:${field}-xxx,具体可以查看element-plus文档
|
||||
componentProps?: { slots?: Recordable } & ComponentProps
|
||||
// formItem组件属性
|
||||
formItemProps?: FormItemProps
|
||||
// 渲染的组件
|
||||
component?: ComponentName
|
||||
// 初始值
|
||||
value?: FormValueType
|
||||
// 是否隐藏
|
||||
hidden?: boolean
|
||||
// 远程加载下拉项
|
||||
api?: <T = any>() => AxiosPromise<T>
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
declare interface IconTypes {
|
||||
export interface IconTypes {
|
||||
size?: number
|
||||
color?: string
|
||||
icon: string
|
|
@ -1,4 +1,4 @@
|
|||
declare interface TipSchema {
|
||||
export interface TipSchema {
|
||||
label: string
|
||||
keys?: string[]
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
declare interface Language {
|
||||
export interface Language {
|
||||
el: Recordable
|
||||
name: string
|
||||
}
|
||||
|
||||
declare interface LocaleDropdownType {
|
||||
export interface LocaleDropdownType {
|
||||
lang: LocaleType
|
||||
name?: string
|
||||
elLocale?: Language
|
|
@ -1,4 +1,4 @@
|
|||
declare interface QrcodeLogo {
|
||||
export interface QrcodeLogo {
|
||||
src?: string
|
||||
logoSize?: number
|
||||
bgColor?: string
|
|
@ -1,16 +1,16 @@
|
|||
declare type TableColumn = {
|
||||
export type TableColumn = {
|
||||
field: string
|
||||
label?: string
|
||||
children?: TableColumn[]
|
||||
} & Recordable
|
||||
|
||||
declare type TableSlotDefault = {
|
||||
export type TableSlotDefault = {
|
||||
row: Recordable
|
||||
column: TableColumn
|
||||
$index: number
|
||||
} & Recordable
|
||||
|
||||
declare interface Pagination {
|
||||
export interface Pagination {
|
||||
small?: boolean
|
||||
background?: boolean
|
||||
pageSize?: number
|
||||
|
@ -29,7 +29,7 @@ declare interface Pagination {
|
|||
hideOnSinglePage?: boolean
|
||||
}
|
||||
|
||||
declare interface TableSetPropsType {
|
||||
export interface TableSetPropsType {
|
||||
field: string
|
||||
path: string
|
||||
value: any
|
|
@ -6,6 +6,7 @@ import { getUserListApi } from '@/api/login'
|
|||
import { UserType } from '@/api/login/types'
|
||||
import { ref, h } from 'vue'
|
||||
import { ElButton } from 'element-plus'
|
||||
import { TableColumn, TableSlotDefault } from '@/types/table'
|
||||
|
||||
interface Params {
|
||||
pageIndex?: number
|
||||
|
|
|
@ -6,6 +6,7 @@ import { getUserListApi } from '@/api/login'
|
|||
import { UserType } from '@/api/login/types'
|
||||
import { ref, h } from 'vue'
|
||||
import { ElButton } from 'element-plus'
|
||||
import { TableColumn, TableSlotDefault } from '@/types/table'
|
||||
|
||||
interface Params {
|
||||
pageIndex?: number
|
||||
|
|
|
@ -6,6 +6,7 @@ import { Form } from '@/components/Form'
|
|||
import { ElFormItem, ElInput, ElButton } from 'element-plus'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { useForm } from '@/hooks/web/useForm'
|
||||
import { DescriptionsSchema } from '@/types/descriptions'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { ref, reactive, unref } from 'vue'
|
|||
import { Form, FormExpose } from '@/components/Form'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { getDictOneApi } from '@/api/common'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -5,6 +5,8 @@ import { useI18n } from '@/hooks/web/useI18n'
|
|||
import { useIcon } from '@/hooks/web/useIcon'
|
||||
import { ContentWrap } from '@/components/ContentWrap'
|
||||
import { useAppStore } from '@/store/modules/app'
|
||||
import { FormSchema } from '@/types/form'
|
||||
import { ComponentOptions } from '@/types/components'
|
||||
|
||||
const appStore = useAppStore()
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { reactive, unref, ref } from 'vue'
|
|||
import { ElButton } from 'element-plus'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { getDictOneApi } from '@/api/common'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { reactive, unref, ref } from 'vue'
|
|||
import { ElButton } from 'element-plus'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { getDictOneApi } from '@/api/common'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { reactive, ref, unref } from 'vue'
|
|||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { ElButton } from 'element-plus'
|
||||
import { getDictOneApi } from '@/api/common'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { getTableListApi } from '@/api/table'
|
|||
import { TableData } from '@/api/table/types'
|
||||
import { ref, h } from 'vue'
|
||||
import { ElTag, ElButton } from 'element-plus'
|
||||
import { TableColumn, TableSlotDefault } from '@/types/table'
|
||||
|
||||
interface Params {
|
||||
pageIndex?: number
|
||||
|
|
|
@ -7,6 +7,7 @@ import { TableData } from '@/api/table/types'
|
|||
import { ref, h, reactive, unref } from 'vue'
|
||||
import { ElTag, ElButton } from 'element-plus'
|
||||
import { useTable } from '@/hooks/web/useTable'
|
||||
import { Pagination, TableColumn, TableSlotDefault } from '@/types/table'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import { TableData } from '@/api/table/types'
|
|||
import { ref, h, reactive, unref } from 'vue'
|
||||
import { ElTag, ElButton } from 'element-plus'
|
||||
import { useTable } from '@/hooks/web/useTable'
|
||||
import { Pagination, TableColumn, TableSlotDefault } from '@/types/table'
|
||||
|
||||
const { register, tableObject, methods, elTableRef } = useTable<TableData>({
|
||||
getListApi: getTableListApi,
|
||||
|
|
|
@ -12,6 +12,7 @@ import { h, ref, unref, reactive } from 'vue'
|
|||
import Write from './components/Write.vue'
|
||||
import Detail from './components/Detail.vue'
|
||||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
||||
import { TableColumn } from '@/types/table'
|
||||
|
||||
const { register, tableObject, methods } = useTable<TableData>({
|
||||
getListApi: getTableListApi,
|
||||
|
|
|
@ -4,6 +4,7 @@ import type { TableData } from '@/api/table/types'
|
|||
import { Descriptions } from '@/components/Descriptions'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { ElTag } from 'element-plus'
|
||||
import { DescriptionsSchema } from '@/types/descriptions'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import { useForm } from '@/hooks/web/useForm'
|
|||
import { PropType, reactive, watch } from 'vue'
|
||||
import { TableData } from '@/api/table/types'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import { h, reactive, ref } from 'vue'
|
|||
import { useRouter } from 'vue-router'
|
||||
import { useEmitt } from '@/hooks/web/useEmitt'
|
||||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
||||
import { TableColumn } from '@/types/table'
|
||||
|
||||
defineOptions({
|
||||
name: 'ExamplePage'
|
||||
|
|
|
@ -4,6 +4,7 @@ import type { TableData } from '@/api/table/types'
|
|||
import { Descriptions } from '@/components/Descriptions'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { ElTag } from 'element-plus'
|
||||
import { DescriptionsSchema } from '@/types/descriptions'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import { TableData } from '@/api/table/types'
|
|||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { IDomEditor } from '@wangeditor/editor'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ import { useRouter } from 'vue-router'
|
|||
import type { RouteLocationNormalizedLoaded, RouteRecordRaw } from 'vue-router'
|
||||
import { UserType } from '@/api/login/types'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import { useI18n } from '@/hooks/web/useI18n'
|
|||
import { useForm } from '@/hooks/web/useForm'
|
||||
import { ElButton, ElInput, FormRules } from 'element-plus'
|
||||
import { useValidator } from '@/hooks/web/useValidator'
|
||||
import { FormSchema } from '@/types/form'
|
||||
|
||||
const emit = defineEmits(['to-login'])
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import { h, ref, reactive } from 'vue'
|
|||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { getDictOneApi } from '@/api/common'
|
||||
import { TableColumn } from '@/types/table'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
declare interface ConfigGlobalTypes {
|
||||
size?: ElememtPlusSize
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
declare type contextMenuSchema = {
|
||||
disabled?: boolean
|
||||
divided?: boolean
|
||||
icon?: string
|
||||
label: string
|
||||
command?: (item: contextMenuSchema) => viod
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
import type { CSSProperties } from 'vue'
|
||||
|
||||
declare global {
|
||||
declare type ComponentName =
|
||||
| 'Radio'
|
||||
| 'RadioButton'
|
||||
| 'Checkbox'
|
||||
| 'CheckboxButton'
|
||||
| 'Input'
|
||||
| 'Autocomplete'
|
||||
| 'InputNumber'
|
||||
| 'Select'
|
||||
| 'Cascader'
|
||||
| 'Switch'
|
||||
| 'Slider'
|
||||
| 'TimePicker'
|
||||
| 'DatePicker'
|
||||
| 'Rate'
|
||||
| 'ColorPicker'
|
||||
| 'Transfer'
|
||||
| 'Divider'
|
||||
| 'TimeSelect'
|
||||
| 'SelectV2'
|
||||
| 'InputPassword'
|
||||
| 'Editor'
|
||||
|
||||
declare type ColProps = {
|
||||
span?: number
|
||||
xs?: number
|
||||
sm?: number
|
||||
md?: number
|
||||
lg?: number
|
||||
xl?: number
|
||||
tag?: string
|
||||
}
|
||||
|
||||
declare type FormValueType = string | number | string[] | number[] | boolean | undefined | null
|
||||
|
||||
declare type FormItemProps = {
|
||||
labelWidth?: string | number
|
||||
required?: boolean
|
||||
rules?: Recordable
|
||||
error?: string
|
||||
showMessage?: boolean
|
||||
inlineMessage?: boolean
|
||||
style?: CSSProperties
|
||||
}
|
||||
|
||||
declare type ComponentOptions = {
|
||||
label?: string
|
||||
value?: FormValueType
|
||||
disabled?: boolean
|
||||
key?: string | number
|
||||
children?: ComponentOptions[]
|
||||
options?: ComponentOptions[]
|
||||
} & Recordable
|
||||
|
||||
declare type ComponentOptionsAlias = {
|
||||
labelField?: string
|
||||
valueField?: string
|
||||
}
|
||||
|
||||
declare type ComponentProps = {
|
||||
optionsAlias?: ComponentOptionsAlias
|
||||
options?: ComponentOptions[]
|
||||
optionsSlot?: boolean
|
||||
} & Recordable
|
||||
|
||||
declare type FormSchema = {
|
||||
// 唯一值
|
||||
field: string
|
||||
// 标题
|
||||
label?: string
|
||||
// 提示
|
||||
labelMessage?: string
|
||||
// col组件属性
|
||||
colProps?: ColProps
|
||||
// 表单组件属性,slots对应的是表单组件的插槽,规则:${field}-xxx,具体可以查看element-plus文档
|
||||
componentProps?: { slots?: Recordable } & ComponentProps
|
||||
// formItem组件属性
|
||||
formItemProps?: FormItemProps
|
||||
// 渲染的组件
|
||||
component?: ComponentName
|
||||
// 初始值
|
||||
value?: FormValueType
|
||||
// 是否隐藏
|
||||
hidden?: boolean
|
||||
// 远程加载下拉项
|
||||
api?: <T = any>() => AxiosPromise<T>
|
||||
}
|
||||
|
||||
declare type FormSetPropsType = {
|
||||
field: string
|
||||
path: string
|
||||
value: any
|
||||
}
|
||||
}
|
|
@ -1,40 +1,39 @@
|
|||
declare interface Fn<T = any> {
|
||||
(...arg: T[]): T
|
||||
}
|
||||
|
||||
declare type Nullable<T> = T | null
|
||||
|
||||
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
|
||||
|
||||
declare type ElememtPlusSize = 'default' | 'small' | 'large'
|
||||
|
||||
declare type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'
|
||||
|
||||
declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
|
||||
|
||||
declare type ComponentRef<T> = InstanceType<T>
|
||||
|
||||
declare type LocaleType = 'zh-CN' | 'en'
|
||||
|
||||
declare type AxiosHeaders =
|
||||
| 'application/json'
|
||||
| 'application/x-www-form-urlencoded'
|
||||
| 'multipart/form-data'
|
||||
|
||||
declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
|
||||
|
||||
declare type AxiosResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
|
||||
|
||||
declare interface AxiosConfig {
|
||||
params?: any
|
||||
data?: any
|
||||
url?: string
|
||||
method?: AxiosMethod
|
||||
headersType?: string
|
||||
responseType?: AxiosResponseType
|
||||
}
|
||||
|
||||
declare interface IResponse<T = any> {
|
||||
code: string
|
||||
data: T extends any ? T : T & any
|
||||
import type { CSSProperties } from 'vue'
|
||||
declare global {
|
||||
declare interface Fn<T = any> {
|
||||
(...arg: T[]): T
|
||||
}
|
||||
|
||||
declare type Nullable<T> = T | null
|
||||
|
||||
declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
|
||||
|
||||
declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
|
||||
|
||||
declare type ComponentRef<T> = InstanceType<T>
|
||||
|
||||
declare type LocaleType = 'zh-CN' | 'en'
|
||||
|
||||
declare type AxiosHeaders =
|
||||
| 'application/json'
|
||||
| 'application/x-www-form-urlencoded'
|
||||
| 'multipart/form-data'
|
||||
|
||||
declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
|
||||
|
||||
declare type AxiosResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
|
||||
|
||||
declare interface AxiosConfig {
|
||||
params?: any
|
||||
data?: any
|
||||
url?: string
|
||||
method?: AxiosMethod
|
||||
headersType?: string
|
||||
responseType?: AxiosResponseType
|
||||
}
|
||||
|
||||
declare interface IResponse<T = any> {
|
||||
code: string
|
||||
data: T extends any ? T : T & any
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue