Ver código fonte

Merge pull request #181 from kailong321200875/develop

Archer 2 anos atrás
pai
commit
e33e2569bb
60 arquivos alterados com 209 adições e 160 exclusões
  1. 2 1
      src/components/ConfigGlobal/src/ConfigGlobal.vue
  2. 1 1
      src/components/ContextMenu/src/ContextMenu.vue
  3. 1 0
      src/components/Descriptions/src/Descriptions.vue
  4. 1 0
      src/components/Form/index.ts
  5. 1 0
      src/components/Form/src/Form.vue
  6. 1 0
      src/components/Form/src/componentMap.ts
  7. 1 0
      src/components/Form/src/components/useRenderCheckbox.tsx
  8. 1 0
      src/components/Form/src/components/useRenderRadio.tsx
  9. 2 0
      src/components/Form/src/components/useRenderSelect.tsx
  10. 1 0
      src/components/Form/src/helper.ts
  11. 2 0
      src/components/Form/src/types.ts
  12. 2 1
      src/components/Infotip/src/Infotip.vue
  13. 1 0
      src/components/Qrcode/src/Qrcode.vue
  14. 1 0
      src/components/Search/src/Search.vue
  15. 2 1
      src/components/SizeDropdown/src/SizeDropdown.vue
  16. 1 0
      src/components/Table/index.ts
  17. 1 0
      src/components/Table/src/Table.vue
  18. 2 0
      src/components/Table/src/types.ts
  19. 1 0
      src/hooks/web/useConfigGlobal.ts
  20. 3 0
      src/hooks/web/useCrudSchemas.ts
  21. 1 0
      src/hooks/web/useForm.ts
  22. 1 0
      src/hooks/web/useIcon.ts
  23. 4 7
      src/hooks/web/useTable.ts
  24. 4 3
      src/store/modules/app.ts
  25. 1 0
      src/store/modules/locale.ts
  26. 52 0
      src/types/components.d.ts
  27. 4 0
      src/types/configGlobal.d.ts
  28. 7 0
      src/types/contextMenu.d.ts
  29. 1 1
      src/types/descriptions.d.ts
  30. 3 0
      src/types/elementPlus.d.ts
  31. 45 0
      src/types/form.d.ts
  32. 1 1
      src/types/icon.d.ts
  33. 1 1
      src/types/infoTip.d.ts
  34. 2 2
      src/types/localeDropdown.d.ts
  35. 1 1
      src/types/qrcode.d.ts
  36. 4 4
      src/types/table.d.ts
  37. 1 0
      src/views/Authorization/Role.vue
  38. 1 0
      src/views/Authorization/User.vue
  39. 1 0
      src/views/Components/Descriptions.vue
  40. 1 0
      src/views/Components/Dialog.vue
  41. 2 0
      src/views/Components/Form/DefaultForm.vue
  42. 1 0
      src/views/Components/Form/RefForm.vue
  43. 1 0
      src/views/Components/Form/UseFormDemo.vue
  44. 1 0
      src/views/Components/Search.vue
  45. 1 0
      src/views/Components/Table/DefaultTable.vue
  46. 1 0
      src/views/Components/Table/RefTable.vue
  47. 1 0
      src/views/Components/Table/UseTableDemo.vue
  48. 1 0
      src/views/Example/Dialog/ExampleDialog.vue
  49. 1 0
      src/views/Example/Dialog/components/Detail.vue
  50. 1 0
      src/views/Example/Dialog/components/Write.vue
  51. 1 0
      src/views/Example/Page/ExamplePage.vue
  52. 1 0
      src/views/Example/Page/components/Detail.vue
  53. 1 0
      src/views/Example/Page/components/Write.vue
  54. 1 0
      src/views/Login/components/LoginForm.vue
  55. 1 0
      src/views/Login/components/RegisterForm.vue
  56. 1 0
      src/views/hooks/useCrudSchemas.vue
  57. 0 3
      types/componentType/configGlobal.d.ts
  58. 0 7
      types/componentType/contextMenu.d.ts
  59. 0 97
      types/componentType/form.d.ts
  60. 28 29
      types/global.d.ts

+ 2 - 1
src/components/ConfigGlobal/src/ConfigGlobal.vue

@@ -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)

+ 1 - 1
src/components/ContextMenu/src/ContextMenu.vue

@@ -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')

+ 1 - 0
src/components/Descriptions/src/Descriptions.vue

@@ -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 - 0
src/components/Form/index.ts

@@ -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

+ 1 - 0
src/components/Form/src/Form.vue

@@ -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()
 

+ 1 - 0
src/components/Form/src/componentMap.ts

@@ -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 - 0
src/components/Form/src/components/useRenderCheckbox.tsx

@@ -1,3 +1,4 @@
+import { FormSchema } from '@/types/form'
 import { ElCheckbox, ElCheckboxButton } from 'element-plus'
 import { defineComponent } from 'vue'
 

+ 1 - 0
src/components/Form/src/components/useRenderRadio.tsx

@@ -1,3 +1,4 @@
+import { FormSchema } from '@/types/form'
 import { ElRadio, ElRadioButton } from 'element-plus'
 import { defineComponent } from 'vue'
 

+ 2 - 0
src/components/Form/src/components/useRenderSelect.tsx

@@ -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

+ 1 - 0
src/components/Form/src/helper.ts

@@ -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()
 

+ 2 - 0
src/components/Form/src/types.ts

@@ -1,3 +1,5 @@
+import { FormSchema } from '@/types/form'
+
 export interface PlaceholderMoel {
   placeholder?: string
   startPlaceholder?: string

+ 2 - 1
src/components/Infotip/src/Infotip.vue

@@ -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()
 

+ 1 - 0
src/components/Qrcode/src/Qrcode.vue

@@ -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嵌套

+ 1 - 0
src/components/Search/src/Search.vue

@@ -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()
 

+ 2 - 1
src/components/SizeDropdown/src/SizeDropdown.vue

@@ -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 - 0
src/components/Table/index.ts

@@ -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

+ 1 - 0
src/components/Table/src/Table.vue

@@ -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',

+ 2 - 0
src/components/Table/src/types.ts

@@ -1,3 +1,5 @@
+import { Pagination, TableColumn } from '@/types/table'
+
 export type TableProps = {
   pageSize?: number
   currentPage?: number

+ 1 - 0
src/hooks/web/useConfigGlobal.ts

@@ -1,3 +1,4 @@
+import { ConfigGlobalTypes } from '@/types/configGlobal'
 import { inject } from 'vue'
 
 export const useConfigGlobal = () => {

+ 3 - 0
src/hooks/web/useCrudSchemas.ts

@@ -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

+ 1 - 0
src/hooks/web/useForm.ts

@@ -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 - 0
src/hooks/web/useIcon.ts

@@ -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 - 7
src/hooks/web/useTable.ts

@@ -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) => {

+ 4 - 3
src/store/modules/app.ts

@@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
 import { store } from '../index'
 import { setCssVar, humpToUnderline } from '@/utils'
 import { ElMessage } from 'element-plus'
+import { ElementPlusSize } from '@/types/elementPlus'
 import { useCache } from '@/hooks/web/useCache'
 
 const { wsCache } = useCache()
@@ -169,10 +170,10 @@ export const useAppStore = defineStore('app', {
     getIsDark(): boolean {
       return this.isDark
     },
-    getCurrentSize(): ElememtPlusSize {
+    getCurrentSize(): ElementPlusSize {
       return this.currentSize
     },
-    getSizeMap(): ElememtPlusSize[] {
+    getSizeMap(): ElementPlusSize[] {
       return this.sizeMap
     },
     getMobile(): boolean {
@@ -254,7 +255,7 @@ export const useAppStore = defineStore('app', {
       }
       wsCache.set('isDark', this.isDark)
     },
-    setCurrentSize(currentSize: ElememtPlusSize) {
+    setCurrentSize(currentSize: ElementPlusSize) {
       this.currentSize = currentSize
       wsCache.set('currentSize', this.currentSize)
     },

+ 1 - 0
src/store/modules/locale.ts

@@ -3,6 +3,7 @@ import { store } from '../index'
 import zhCn from 'element-plus/es/locale/lang/zh-cn'
 import en from 'element-plus/es/locale/lang/en'
 import { useCache } from '@/hooks/web/useCache'
+import { LocaleDropdownType } from '@/types/localeDropdown'
 
 const { wsCache } = useCache()
 

+ 52 - 0
src/types/components.d.ts

@@ -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

+ 4 - 0
src/types/configGlobal.d.ts

@@ -0,0 +1,4 @@
+import { ElementPlusSize } from './elementPlus'
+export interface ConfigGlobalTypes {
+  size?: ElementPlusSize
+}

+ 7 - 0
src/types/contextMenu.d.ts

@@ -0,0 +1,7 @@
+export type contextMenuSchema = {
+  disabled?: boolean
+  divided?: boolean
+  icon?: string
+  label: string
+  command?: (item: contextMenuSchema) => void
+}

+ 1 - 1
types/componentType/descriptions.d.ts → src/types/descriptions.d.ts

@@ -1,4 +1,4 @@
-declare interface DescriptionsSchema {
+export interface DescriptionsSchema {
   span?: number // 占多少分
   field: string // 字段名
   label?: string // label名

+ 3 - 0
src/types/elementPlus.d.ts

@@ -0,0 +1,3 @@
+export type ElementPlusSize = 'default' | 'small' | 'large'
+
+export type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'

+ 45 - 0
src/types/form.d.ts

@@ -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 - 1
types/componentType/icon.d.ts → src/types/icon.d.ts

@@ -1,4 +1,4 @@
-declare interface IconTypes {
+export interface IconTypes {
   size?: number
   color?: string
   icon: string

+ 1 - 1
types/componentType/infotip.d.ts → src/types/infoTip.d.ts

@@ -1,4 +1,4 @@
-declare interface TipSchema {
+export interface TipSchema {
   label: string
   keys?: string[]
 }

+ 2 - 2
types/componentType/localeDropdown.d.ts → src/types/localeDropdown.d.ts

@@ -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 - 1
types/componentType/qrcode.d.ts → src/types/qrcode.d.ts

@@ -1,4 +1,4 @@
-declare interface QrcodeLogo {
+export interface QrcodeLogo {
   src?: string
   logoSize?: number
   bgColor?: string

+ 4 - 4
types/componentType/table.d.ts → src/types/table.d.ts

@@ -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

+ 1 - 0
src/views/Authorization/Role.vue

@@ -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

+ 1 - 0
src/views/Authorization/User.vue

@@ -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

+ 1 - 0
src/views/Components/Descriptions.vue

@@ -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()
 

+ 1 - 0
src/views/Components/Dialog.vue

@@ -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()
 

+ 2 - 0
src/views/Components/Form/DefaultForm.vue

@@ -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()
 

+ 1 - 0
src/views/Components/Form/RefForm.vue

@@ -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()
 

+ 1 - 0
src/views/Components/Form/UseFormDemo.vue

@@ -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()
 

+ 1 - 0
src/views/Components/Search.vue

@@ -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()
 

+ 1 - 0
src/views/Components/Table/DefaultTable.vue

@@ -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

+ 1 - 0
src/views/Components/Table/RefTable.vue

@@ -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()
 

+ 1 - 0
src/views/Components/Table/UseTableDemo.vue

@@ -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,

+ 1 - 0
src/views/Example/Dialog/ExampleDialog.vue

@@ -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,

+ 1 - 0
src/views/Example/Dialog/components/Detail.vue

@@ -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()
 

+ 1 - 0
src/views/Example/Dialog/components/Write.vue

@@ -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()
 

+ 1 - 0
src/views/Example/Page/ExamplePage.vue

@@ -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'

+ 1 - 0
src/views/Example/Page/components/Detail.vue

@@ -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()
 

+ 1 - 0
src/views/Example/Page/components/Write.vue

@@ -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()
 

+ 1 - 0
src/views/Login/components/LoginForm.vue

@@ -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()
 

+ 1 - 0
src/views/Login/components/RegisterForm.vue

@@ -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'])
 

+ 1 - 0
src/views/hooks/useCrudSchemas.vue

@@ -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()
 

+ 0 - 3
types/componentType/configGlobal.d.ts

@@ -1,3 +0,0 @@
-declare interface ConfigGlobalTypes {
-  size?: ElememtPlusSize
-}

+ 0 - 7
types/componentType/contextMenu.d.ts

@@ -1,7 +0,0 @@
-declare type contextMenuSchema = {
-  disabled?: boolean
-  divided?: boolean
-  icon?: string
-  label: string
-  command?: (item: contextMenuSchema) => viod
-}

+ 0 - 97
types/componentType/form.d.ts

@@ -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
-  }
-}

+ 28 - 29
types/global.d.ts

@@ -1,40 +1,39 @@
-declare interface Fn<T = any> {
-  (...arg: T[]): T
-}
-
-declare type Nullable<T> = T | null
+import type { CSSProperties } from 'vue'
+declare global {
+  declare interface Fn<T = any> {
+    (...arg: T[]): T
+  }
 
-declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
+  declare type Nullable<T> = T | null
 
-declare type ElememtPlusSize = 'default' | 'small' | 'large'
+  declare type ElRef<T extends HTMLElement = HTMLDivElement> = Nullable<T>
 
-declare type ElementPlusInfoType = 'success' | 'info' | 'warning' | 'danger'
+  declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
 
-declare type Recordable<T = any, K = string> = Record<K extends null | undefined ? string : K, T>
+  declare type ComponentRef<T> = InstanceType<T>
 
-declare type ComponentRef<T> = InstanceType<T>
+  declare type LocaleType = 'zh-CN' | 'en'
 
-declare type LocaleType = 'zh-CN' | 'en'
+  declare type AxiosHeaders =
+    | 'application/json'
+    | 'application/x-www-form-urlencoded'
+    | 'multipart/form-data'
 
-declare type AxiosHeaders =
-  | 'application/json'
-  | 'application/x-www-form-urlencoded'
-  | 'multipart/form-data'
+  declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
 
-declare type AxiosMethod = 'get' | 'post' | 'delete' | 'put'
+  declare type AxiosResponseType = 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
 
-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 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
+  declare interface IResponse<T = any> {
+    code: string
+    data: T extends any ? T : T & any
+  }
 }