diff --git a/internal/vite-config/src/config/application.ts b/internal/vite-config/src/config/application.ts index 206c66a9..7ee5ef1d 100644 --- a/internal/vite-config/src/config/application.ts +++ b/internal/vite-config/src/config/application.ts @@ -63,8 +63,8 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) { cssTarget: 'chrome80', rollupOptions: { output: { - // 入口文件名(不能变,否则所有打包的 js hash 值全变了) - entryFileNames: 'index.js', + // 入口文件名 + entryFileNames: 'assets/entry/[name]-[hash].js', manualChunks: { vue: ['vue', 'pinia', 'vue-router'], antd: ['ant-design-vue', '@ant-design/icons-vue'], diff --git a/package.json b/package.json index 840649d0..84401323 100644 --- a/package.json +++ b/package.json @@ -107,9 +107,10 @@ "vue-router": "^4.3.2", "vue-types": "^5.1.1", "vuedraggable": "^4.1.0", - "vxe-table": "^4.6.3", - "vxe-table-plugin-export-xlsx": "^4.0.1", - "xe-utils": "^3.5.25", + "vxe-pc-ui": "^4.0.44", + "vxe-table": "^4.7.40", + "vxe-table-plugin-export-xlsx": "^4.0.4", + "xe-utils": "^3.5.28", "xlsx": "^0.18.5" }, "devDependencies": { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c8ca657d..ee8b1753 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -122,15 +122,18 @@ importers: vuedraggable: specifier: ^4.1.0 version: 4.1.0(vue@3.4.25(typescript@5.4.5)) + vxe-pc-ui: + specifier: ^4.0.44 + version: 4.0.44 vxe-table: - specifier: ^4.6.3 - version: 4.6.3(vue@3.4.25(typescript@5.4.5)) + specifier: ^4.7.40 + version: 4.7.40 vxe-table-plugin-export-xlsx: - specifier: ^4.0.1 - version: 4.0.1(vxe-table@4.6.3(vue@3.4.25(typescript@5.4.5))) + specifier: ^4.0.4 + version: 4.0.4(vxe-table@4.7.40) xe-utils: - specifier: ^3.5.25 - version: 3.5.25 + specifier: ^3.5.28 + version: 3.5.28 xlsx: specifier: ^0.18.5 version: 0.18.5 @@ -2005,6 +2008,9 @@ packages: '@vueuse/shared@10.9.0': resolution: {integrity: sha512-Uud2IWncmAfJvRaFYzv5OHDli+FbOzxiVEQdLCKQKLyhz94PIyFC3CHcH7EDMwIn8NPtD06+PNbC/PiO0LGLtw==} + '@vxe-ui/core@1.0.12': + resolution: {integrity: sha512-s79mQw6uYSbTVGBWbxrisHwJV1b770vZMT9XpY3khcFQhXNo25+PS3FLrNCSsBBJR0ZkBLOXDER/ft9DIqgFTw==} + '@zxcvbn-ts/core@3.0.4': resolution: {integrity: sha512-aQeiT0F09FuJaAqNrxynlAwZ2mW/1MdXakKWNmGM1Qp/VaY6CnB/GfnMS2T8gB2231Esp1/maCWd8vTG4OuShw==} @@ -3096,8 +3102,8 @@ packages: dom-serializer@2.0.0: resolution: {integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==} - dom-zindex@1.0.2: - resolution: {integrity: sha512-QceDZxPlvzhpg6e8szxNiKPUt5Y9SfFTe3nZy8og3JoPQPlAlzBzHa/lhDkhgeG3cjbKyQcuoic+wymF0o0d1Q==} + dom-zindex@1.0.4: + resolution: {integrity: sha512-PNk7u71TJ1C9Lwjjp5nNuQcVWuECFMmr9kZAwi2UbgWUM7jXdTCe4O4x5bhLUa07jpcZUVA5Du3ho7/FXzS9Ng==} domelementtype@1.3.1: resolution: {integrity: sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w==} @@ -7060,15 +7066,16 @@ packages: peerDependencies: vue: ^3.0.1 - vxe-table-plugin-export-xlsx@4.0.1: - resolution: {integrity: sha512-puUOUfptu5ciEiFqTlVni3twLICSbkl87uXOsjZzrEyXJHJS9dYu7ZTD7/DRMqyuWyU3Idg7AekfcdcslP4Y/A==} + vxe-pc-ui@4.0.44: + resolution: {integrity: sha512-wiauFMmSvEkVKa/AsKGb5CMi91Ojts+Ydcn+iespgl3xMBD01BR/CGzeCI478P3XAFBsiN4gWlgxHmGP5TR8UA==} + + vxe-table-plugin-export-xlsx@4.0.4: + resolution: {integrity: sha512-Og2ZcIWTV7msT1ddPT/spxJaP1T8wxs3Uuu1LO/3HL5Ugt9tShEY3FJ7YGic3j1Nk6ZZT+VsU+afgT5EzpcUJw==} peerDependencies: vxe-table: ^4.5.0 - vxe-table@4.6.3: - resolution: {integrity: sha512-71FOi0lFQbvs1dUIZPTDCLaSJkRjLHlBuNzWIR9RofBe4EvhX4OowrhaCCsCXXKCCGSlJRp6+/O2c71lEZY9PQ==} - peerDependencies: - vue: ^3.2.28 + vxe-table@4.7.40: + resolution: {integrity: sha512-y9VC3oLJgusxFj3xZ28G4gU+YClBuDIV8oM75Dx3doYJ7vanXZnSf70XJ+W5xEKflamUmjGre66XZ2b4XuqtMw==} w3c-hr-time@1.0.2: resolution: {integrity: sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==} @@ -7206,8 +7213,8 @@ packages: utf-8-validate: optional: true - xe-utils@3.5.25: - resolution: {integrity: sha512-d/ty5eo4hXtho/3195XAvqereIoSYJ+XfC52f3ZEPxTaCeyLFivDZTyX6gTdsR65ISH1Irvn85H0bSL60dUhSQ==} + xe-utils@3.5.28: + resolution: {integrity: sha512-oeLLJ0b54QdOSSgYQ9TiKW/xAGrc9r0weCA/5UfyGdm3n3js4cNOuuf9Tml7UwgBQpl4uWMbMwUZKLh2yqPF3A==} xlsx@0.18.5: resolution: {integrity: sha512-dmg3LCjBPHZnQp5/F/+nnTa+miPJxUXB6vtk42YjBBKayDNagxGEeIdWApkYPOf3Z3pm3k62Knjzp7lMeTEtFQ==} @@ -9228,6 +9235,11 @@ snapshots: - '@vue/composition-api' - vue + '@vxe-ui/core@1.0.12': + dependencies: + dom-zindex: 1.0.4 + xe-utils: 3.5.28 + '@zxcvbn-ts/core@3.0.4': dependencies: fastest-levenshtein: 1.0.16 @@ -10389,7 +10401,7 @@ snapshots: domhandler: 5.0.3 entities: 4.5.0 - dom-zindex@1.0.2: {} + dom-zindex@1.0.4: {} domelementtype@1.3.1: {} @@ -15005,15 +15017,17 @@ snapshots: sortablejs: 1.14.0 vue: 3.4.25(typescript@5.4.5) - vxe-table-plugin-export-xlsx@4.0.1(vxe-table@4.6.3(vue@3.4.25(typescript@5.4.5))): + vxe-pc-ui@4.0.44: dependencies: - vxe-table: 4.6.3(vue@3.4.25(typescript@5.4.5)) + '@vxe-ui/core': 1.0.12 - vxe-table@4.6.3(vue@3.4.25(typescript@5.4.5)): + vxe-table-plugin-export-xlsx@4.0.4(vxe-table@4.7.40): dependencies: - dom-zindex: 1.0.2 - vue: 3.4.25(typescript@5.4.5) - xe-utils: 3.5.25 + vxe-table: 4.7.40 + + vxe-table@4.7.40: + dependencies: + vxe-pc-ui: 4.0.44 w3c-hr-time@1.0.2: dependencies: @@ -15138,7 +15152,7 @@ snapshots: ws@8.16.0: {} - xe-utils@3.5.25: {} + xe-utils@3.5.28: {} xlsx@0.18.5: dependencies: diff --git a/src/components/Form/src/BasicForm.vue b/src/components/Form/src/BasicForm.vue index 13ce15db..63e942c9 100644 --- a/src/components/Form/src/BasicForm.vue +++ b/src/components/Form/src/BasicForm.vue @@ -54,7 +54,7 @@ import { useFormValues } from './hooks/useFormValues'; import useAdvanced from './hooks/useAdvanced'; - import { useFormEvents } from './hooks/useFormEvents'; + import { itemIsUploadComponent, useFormEvents } from './hooks/useFormEvents'; import { createFormContext } from './hooks/useFormContext'; import { useAutoFocus } from './hooks/useAutoFocus'; import { useModalContext } from '@/components/Modal'; @@ -64,7 +64,7 @@ import { useDesign } from '@/hooks/web/useDesign'; import { cloneDeep } from 'lodash-es'; import { TableActionType } from '@/components/Table'; - import { isFunction } from '@/utils/is'; + import { isArray, isFunction } from '@/utils/is'; defineOptions({ name: 'BasicForm' }); @@ -165,14 +165,17 @@ schema.defaultValue = def; } } + // handle upload type + if (defaultValue && itemIsUploadComponent(schema?.component)) { + if (isArray(defaultValue)) { + schema.defaultValue = defaultValue; + } else if (typeof defaultValue == 'string') { + schema.defaultValue = [defaultValue]; + } + } // handle schema.valueFormat - if ( - isHandleDefaultValue && - defaultValue && - component && - isFunction(valueFormat) - ) { + if (isHandleDefaultValue && defaultValue && component && isFunction(valueFormat)) { schema.defaultValue = valueFormat({ value: defaultValue, schema, diff --git a/src/components/Form/src/components/FormItem.vue b/src/components/Form/src/components/FormItem.vue index 4402796a..0fd6c374 100644 --- a/src/components/Form/src/components/FormItem.vue +++ b/src/components/Form/src/components/FormItem.vue @@ -287,11 +287,11 @@ const on = { [eventKey]: (...args: Nullable>[]) => { const [e] = args; - + const target = e ? e.target : null; let value = target ? (isCheck ? target.checked : target.value) : e; - if(isFunction(valueFormat)){ - value = valueFormat({...unref(getValues),value}); + if (isFunction(valueFormat)) { + value = valueFormat({ ...unref(getValues), value }); } props.setFormModel(field, value, props.schema); diff --git a/src/components/Form/src/helper.ts b/src/components/Form/src/helper.ts index 53d068fb..d1e9fbd0 100644 --- a/src/components/Form/src/helper.ts +++ b/src/components/Form/src/helper.ts @@ -31,8 +31,13 @@ export function createPlaceholderMessage(component: ComponentType) { const DATE_TYPE = ['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker']; +/** + * 上传组件 + */ +export const uploadItemType: ComponentType[] = ['Upload', 'ImageUpload']; + function genType() { - return [...DATE_TYPE, 'RangePicker',"TimeRangePicker"]; + return [...DATE_TYPE, 'RangePicker', 'TimeRangePicker']; } export function setComponentRuleType( @@ -45,7 +50,7 @@ export function setComponentRuleType( } if (['DatePicker', 'MonthPicker', 'WeekPicker', 'TimePicker'].includes(component)) { rule.type = valueFormat ? 'string' : 'object'; - } else if (['RangePicker', 'Upload', 'CheckboxGroup'].includes(component)) { + } else if (['RangePicker', 'CheckboxGroup'].includes(component)) { rule.type = 'array'; } else if (['InputNumber'].includes(component)) { rule.type = 'number'; diff --git a/src/components/Form/src/hooks/useFormEvents.ts b/src/components/Form/src/hooks/useFormEvents.ts index 150efa91..884a158b 100644 --- a/src/components/Form/src/hooks/useFormEvents.ts +++ b/src/components/Form/src/hooks/useFormEvents.ts @@ -4,10 +4,16 @@ import type { NamePath } from 'ant-design-vue/lib/form/interface'; import { unref, toRaw, nextTick } from 'vue'; import { isArray, isFunction, isObject, isString, isNil } from '@/utils/is'; import { deepMerge } from '@/utils'; -import { dateItemType, defaultValueComponents, isIncludeSimpleComponents } from '../helper'; +import { + dateItemType, + defaultValueComponents, + isIncludeSimpleComponents, + uploadItemType, +} from '../helper'; import { dateUtil } from '@/utils/dateUtil'; import { cloneDeep, has, uniqBy, get, set } from 'lodash-es'; import { error } from '@/utils/log'; +import { ComponentProps } from '../types'; interface UseFormActionContext { emit: EmitType; @@ -19,7 +25,12 @@ interface UseFormActionContext { schemaRef: Ref; handleFormValues: Fn; } - +/** + * @description: Is it upload + */ +export function itemIsUploadComponent(key: keyof ComponentProps) { + return uploadItemType.includes(key); +} function tryConstructArray(field: string, values: Recordable = {}): any[] | undefined { const pattern = /^\[(.+)\]$/; if (pattern.test(field)) { @@ -123,7 +134,20 @@ export function useFormEvents({ } } } - + // Adapt upload component + if (itemIsUploadComponent(schema?.component)) { + constructValue = get(value, key); + const fieldValue = constructValue || value; + if (fieldValue) { + if (isArray(fieldValue)) { + unref(formModel)[key] = fieldValue; + } else if (typeof fieldValue == 'string') { + unref(formModel)[key] = [fieldValue]; + } + } + validKeys.push(key); + return; + } // Adapt common component if (hasKey) { constructValue = get(value, key); diff --git a/src/components/Preview/src/functional.ts b/src/components/Preview/src/functional.ts index c3ee2bff..2d577f69 100644 --- a/src/components/Preview/src/functional.ts +++ b/src/components/Preview/src/functional.ts @@ -1,7 +1,7 @@ -import type { Options, Props } from './typing'; -import ImgPreview from './Functional.vue'; import { isClient } from '@/utils/is'; import { createVNode, render } from 'vue'; +import ImgPreview from './Functional.vue'; +import type { Options, Props } from './typing'; let instance: ReturnType | null = null; export function createImgPreview(options: Options) { @@ -10,8 +10,13 @@ export function createImgPreview(options: Options) { const container = document.createElement('div'); Object.assign(propsData, { show: true, index: 0, scaleStep: 100 }, options); - instance = createVNode(ImgPreview, propsData); - render(instance, container); - document.body.appendChild(container); + if (instance?.component) { + // 存在实例时,更新props + Object.assign(instance.component.props, propsData); + } else { + instance = createVNode(ImgPreview, propsData); + render(instance, container); + document.body.appendChild(container); + } return instance.component?.exposed; } diff --git a/src/components/SimpleMenu/src/components/MenuItem.vue b/src/components/SimpleMenu/src/components/MenuItem.vue index 27c97f43..c30e4667 100644 --- a/src/components/SimpleMenu/src/components/MenuItem.vue +++ b/src/components/SimpleMenu/src/components/MenuItem.vue @@ -17,11 +17,11 @@