fix: type

pull/38/head
xingyu 2023-10-11 09:47:35 +08:00
parent 8d280af271
commit 9abf0d8729
8 changed files with 31 additions and 35 deletions

View File

@ -5,7 +5,7 @@ import { useTabEmits, useTabProps, useTabSetup } from './useTabMixin'
export default defineComponent({ export default defineComponent({
name: 'YearUI', name: 'YearUI',
components: { Input, Radio, RadioGroup: Radio.Group }, components: { AInput: Input, Radio, RadioGroup: Radio.Group },
props: useTabProps({ props: useTabProps({
defaultValue: '*', defaultValue: '*',
}), }),
@ -35,9 +35,9 @@ export default defineComponent({
区间 区间
</Radio> </Radio>
<span> </span> <span> </span>
<Input v-model:value="valueRange.start" type="number" class="w80" v-bind="typeRangeAttrs" /> <AInput v-model:value="valueRange.start" type="number" class="w80" v-bind="typeRangeAttrs" />
<span> </span> <span> </span>
<Input v-model:value="valueRange.end" type="number" class="w80" v-bind="typeRangeAttrs" /> <AInput v-model:value="valueRange.end" type="number" class="w80" v-bind="typeRangeAttrs" />
<span> </span> <span> </span>
</div> </div>
<div class="item"> <div class="item">
@ -45,9 +45,9 @@ export default defineComponent({
循环 循环
</Radio> </Radio>
<span> </span> <span> </span>
<Input v-model:value="valueLoop.start" type="number" class="w80" v-bind="typeLoopAttrs" /> <AInput v-model:value="valueLoop.start" type="number" class="w80" v-bind="typeLoopAttrs" />
<span> 年开始间隔 </span> <span> 年开始间隔 </span>
<Input v-model:value="valueLoop.interval" type="number" class="w80" v-bind="typeLoopAttrs" /> <AInput v-model:value="valueLoop.interval" type="number" class="w80" v-bind="typeLoopAttrs" />
<span> </span> <span> </span>
</div> </div>
</RadioGroup> </RadioGroup>

View File

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { Ref } from 'vue' import type { Ref } from 'vue'
import { computed, nextTick, onMounted, reactive, ref, unref, useAttrs, watch } from 'vue' import { computed, nextTick, onMounted, reactive, ref, unref, useAttrs, watch } from 'vue'
import { Form, Row } from 'ant-design-vue' import { type FormProps as AntFormProps, Form, Row } from 'ant-design-vue'
import { useDebounceFn } from '@vueuse/core' import { useDebounceFn } from '@vueuse/core'
import { cloneDeep } from 'lodash-es' import { cloneDeep } from 'lodash-es'
import type { FormActionType, FormProps, FormSchema } from './types/form' import type { FormActionType, FormProps, FormSchema } from './types/form'
@ -19,7 +19,6 @@ import { useAutoFocus } from './hooks/useAutoFocus'
import { basicProps } from './props' import { basicProps } from './props'
import { dateUtil } from '@/utils/dateUtil' import { dateUtil } from '@/utils/dateUtil'
// import { cloneDeep } from 'lodash-es';
import { deepMerge } from '@/utils' import { deepMerge } from '@/utils'
import { useModalContext } from '@/components/Modal' import { useModalContext } from '@/components/Modal'
@ -43,14 +42,14 @@ const advanceState = reactive<AdvanceState>({
const defaultValueRef = ref<Recordable>({}) const defaultValueRef = ref<Recordable>({})
const isInitedDefaultRef = ref(false) const isInitedDefaultRef = ref(false)
const propsRef = ref<Partial<FormProps>>({}) const propsRef = ref<Partial<FormProps>>()
const schemaRef = ref<Nullable<FormSchema[]>>(null) const schemaRef = ref<Nullable<FormSchema[]>>(null)
const formElRef = ref<Nullable<FormActionType>>(null) const formElRef = ref<Nullable<FormActionType>>(null)
const { prefixCls } = useDesign('basic-form') const { prefixCls } = useDesign('basic-form')
// Get the basic configuration of the form // Get the basic configuration of the form
const getProps = computed((): FormProps => { const getProps = computed(() => {
return { ...props, ...unref(propsRef) } as FormProps return { ...props, ...unref(propsRef) } as FormProps
}) })
@ -72,7 +71,9 @@ const getRow = computed((): Recordable => {
} }
}) })
const getBindValue = computed(() => ({ ...attrs, ...props, ...unref(getProps) }) as Recordable) const getBindValue = computed(
() => ({ ...attrs, ...props, ...unref(getProps) }) as AntFormProps,
)
const getSchema = computed((): FormSchema[] => { const getSchema = computed((): FormSchema[] => {
const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any) const schemas: FormSchema[] = unref(schemaRef) || (unref(getProps).schemas as any)
@ -214,7 +215,7 @@ function setFormModel(key: string, value: any, schema: FormSchema) {
emit('field-value-change', key, value) emit('field-value-change', key, value)
// TODO autoLink=false // TODO autoLink=false
if (schema && schema.itemProps && !schema.itemProps.autoLink) if (schema && schema.itemProps && !schema.itemProps.autoLink)
validateFields([key]).catch((_) => {}) validateFields([key]).catch((_) => { })
} }
function handleEnterPress(e: KeyboardEvent) { function handleEnterPress(e: KeyboardEvent) {
@ -249,7 +250,7 @@ onMounted(() => {
emit('register', formActionType) emit('register', formActionType)
}) })
const getFormActionBindProps = computed((): Recordable => ({ ...getProps.value, ...advanceState })) const getFormActionBindProps = computed(() => ({ ...getProps.value, ...advanceState }) as InstanceType<typeof FormAction>['$props'])
</script> </script>
<template> <template>
@ -258,14 +259,9 @@ const getFormActionBindProps = computed((): Recordable => ({ ...getProps.value,
<slot name="formHeader" /> <slot name="formHeader" />
<template v-for="schema in getSchema" :key="schema.field"> <template v-for="schema in getSchema" :key="schema.field">
<FormItem <FormItem
:is-advanced="fieldsIsAdvancedMap[schema.field]" :is-advanced="fieldsIsAdvancedMap[schema.field]" :table-action="tableAction"
:table-action="tableAction" :form-action-type="formActionType as any" :schema="schema" :form-props="getProps"
:form-action-type="formActionType as any" :all-default-values="defaultValueRef" :form-model="formModel" :set-form-model="setFormModel"
:schema="schema"
:form-props="getProps"
:all-default-values="defaultValueRef"
:form-model="formModel"
:set-form-model="setFormModel"
> >
<template v-for="item in Object.keys($slots)" #[item]="data"> <template v-for="item in Object.keys($slots)" #[item]="data">
<slot :name="item" v-bind="data || {}" /> <slot :name="item" v-bind="data || {}" />

View File

@ -89,7 +89,7 @@ async function fetch() {
if (!isArray(result)) if (!isArray(result))
result = get(result, props.resultField) result = get(result, props.resultField)
treeData.value = (result as DataNode[]) || [] treeData.value = (result as (Recordable & { key: string | number })[]) || []
isFirstLoaded.value = true isFirstLoaded.value = true
emit('optionsChange', treeData.value) emit('optionsChange', treeData.value)
} }

View File

@ -17,7 +17,7 @@ export default defineComponent({
name: 'VFormCreate', name: 'VFormCreate',
components: { components: {
FormRender, FormRender,
Form, AntForm: Form,
Row, Row,
}, },
props: { props: {
@ -119,7 +119,7 @@ export default defineComponent({
<template> <template>
<div class="v-form-container"> <div class="v-form-container">
<Form ref="eFormModel" class="overflow-hidden" :model="formModel" v-bind="formModelProps"> <AntForm ref="eFormModel" class="overflow-hidden" :model="formModel" v-bind="formModelProps">
<Row> <Row>
<FormRender <FormRender
v-for="(schema, index) of noHiddenList" v-for="(schema, index) of noHiddenList"
@ -140,6 +140,6 @@ export default defineComponent({
</template> </template>
</FormRender> </FormRender>
</Row> </Row>
</Form> </AntForm>
</div> </div>
</template> </template>

View File

@ -26,7 +26,7 @@ const spinRef = ref<ElRef>(null)
const realHeightRef = ref(0) const realHeightRef = ref(0)
const minRealHeightRef = ref(0) const minRealHeightRef = ref(0)
const realHeight = ref(0); const realHeight = ref(0)
const stopElResizeFn: Fn = () => {} const stopElResizeFn: Fn = () => {}
@ -141,7 +141,7 @@ defineExpose({ scrollTop })
</script> </script>
<template> <template>
<ScrollContainer ref="wrapperRef" :scrollHeight="realHeight"> <ScrollContainer ref="wrapperRef" :scroll-height="realHeight">
<div ref="spinRef" v-loading="loading" :style="spinStyle" :loading-tip="loadingTip"> <div ref="spinRef" v-loading="loading" :style="spinStyle" :loading-tip="loadingTip">
<slot /> <slot />
</div> </div>

View File

@ -1,4 +1,4 @@
import type { FunctionalComponent, defineComponent } from 'vue' import type { defineComponent } from 'vue'
import { Popover } from 'ant-design-vue' import { Popover } from 'ant-design-vue'
import { h } from 'vue' import { h } from 'vue'
import type { ComponentType } from '../../types/componentType' import type { ComponentType } from '../../types/componentType'
@ -12,10 +12,8 @@ export interface ComponentProps {
getPopupContainer?: Fn getPopupContainer?: Fn
} }
export const CellComponent: FunctionalComponent = ( export function CellComponent({ component = 'Input', rule = true, ruleMessage, popoverOpen, getPopupContainer }: ComponentProps,
{ component = 'Input', rule = true, ruleMessage, popoverOpen, getPopupContainer }: ComponentProps, { attrs }) {
{ attrs },
) => {
const Comp = componentMap.get(component) as typeof defineComponent const Comp = componentMap.get(component) as typeof defineComponent
const DefaultComp = h(Comp, attrs) const DefaultComp = h(Comp, attrs)

View File

@ -273,8 +273,10 @@ function getUploadingImgName(name: string) {
<template> <template>
<div :class="prefixCls" :style="{ width: containerWidth }"> <div :class="prefixCls" :style="{ width: containerWidth }">
<ImgUpload v-if="showImageUpload" v-show="editorRef" :fullscreen="fullscreen" :disabled="disabled" <ImgUpload
@uploading="handleImageUploading" @done="handleDone" /> v-if="showImageUpload" v-show="editorRef" :fullscreen="fullscreen" :disabled="disabled"
@uploading="handleImageUploading" @done="handleDone"
/>
<textarea v-if="!initOptions.inline" :id="tinymceId" ref="elRef" :style="{ visibility: 'hidden' }" /> <textarea v-if="!initOptions.inline" :id="tinymceId" ref="elRef" :style="{ visibility: 'hidden' }" />
<slot v-else /> <slot v-else />
</div> </div>

View File

@ -1,5 +1,6 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, ref, useSlots, watch } from 'vue' import { computed, ref, useSlots, watch } from 'vue'
import type { MenuProps } from 'ant-design-vue'
import { Dropdown, InputSearch, Menu, MenuDivider } from 'ant-design-vue' import { Dropdown, InputSearch, Menu, MenuDivider } from 'ant-design-vue'
import { useDebounceFn } from '@vueuse/core' import { useDebounceFn } from '@vueuse/core'
import { ToolbarEnum } from '../types/tree' import { ToolbarEnum } from '../types/tree'
@ -108,8 +109,7 @@ const toolbarList = computed(() => {
return checkable ? retList : defaultToolbarList return checkable ? retList : defaultToolbarList
}) })
function handleMenuClick(e) { const handleMenuClick: MenuProps['onClick'] = ({ key }) => {
const { key } = e
switch (key) { switch (key) {
case ToolbarEnum.SELECT_ALL: case ToolbarEnum.SELECT_ALL:
props.checkAll?.(true) props.checkAll?.(true)