From d71cad1e6ea2e92bf01c2901bf1d3b851773c954 Mon Sep 17 00:00:00 2001 From: lijisanxiong <1518062161@qq.com> Date: Thu, 31 Jul 2025 23:09:50 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E4=B8=8A=E4=BC=A0=E7=B1=BB=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=92=8C=E4=B8=8A=E4=BC=A0=E7=B1=BB=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=99=A8=E5=8F=82=E6=95=B0=20infoMap=EF=BC=88?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E6=98=A0=E5=B0=84=E8=A7=84=E5=88=99=E5=AD=97=E7=AC=A6=E4=B8=B2?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ibiz-file-upload/ibiz-file-upload.tsx | 1 + .../ibiz-image-cropping.tsx | 1 + .../ibiz-image-upload/ibiz-image-upload.tsx | 1 + src/editor/upload/upload-editor.controller.ts | 40 ++++++++++++ src/editor/upload/use/use-iview-upload.ts | 63 +++++++++++++++++-- 5 files changed, 101 insertions(+), 5 deletions(-) diff --git a/src/editor/upload/ibiz-file-upload/ibiz-file-upload.tsx b/src/editor/upload/ibiz-file-upload/ibiz-file-upload.tsx index 6c7d92e7..0b6bf859 100644 --- a/src/editor/upload/ibiz-file-upload/ibiz-file-upload.tsx +++ b/src/editor/upload/ibiz-file-upload/ibiz-file-upload.tsx @@ -21,6 +21,7 @@ import './ibiz-file-upload.scss'; * @editorparams {"name":"uploadparams","parameterType":"string","description":"上传参数,图片或文件上传时,用于计算上传路径"} * @editorparams {"name":"exportparams","parameterType":"string","description":"下载参数,图片或文件下载时,用于计算下载路径"} * @editorparams {"name":"osscat","parameterType":"string","description":"用于计算上传和下载路径的OSS参数"} + * @editorparams {"name":"infomap","parameterType":"string","description":"文件信息映射规则字符串,格式为'目标键:源键;目标键2:源键2'。示例:映射规则('size:filesize;ext:fileext'),源对象({filesize:'10000', fileext:'.gif'}),转换结果({size:'10000', ext:'.gif'})"} * @editorparams {"name":"readonly","parameterType":"boolean","defaultvalue":false,"description":"设置编辑器是否为只读态"} * @ignoreprops autoFocus | overflowMode * @ignoreemits blur | focus | enter | infoTextChange diff --git a/src/editor/upload/ibiz-image-cropping/ibiz-image-cropping.tsx b/src/editor/upload/ibiz-image-cropping/ibiz-image-cropping.tsx index 8b7f42de..d86a9d74 100644 --- a/src/editor/upload/ibiz-image-cropping/ibiz-image-cropping.tsx +++ b/src/editor/upload/ibiz-image-cropping/ibiz-image-cropping.tsx @@ -24,6 +24,7 @@ import './ibiz-image-cropping.scss'; * @editorparams {"name":"uploadparams","parameterType":"string","description":"上传参数,图片上传时,用于计算上传路径"} * @editorparams {"name":"exportparams","parameterType":"string","description":"下载参数,图片下载时,用于计算下载路径"} * @editorparams {"name":"osscat","parameterType":"string","description":"用于计算上传和下载路径的OSS参数"} + * @editorparams {"name":"infomap","parameterType":"string","description":"文件信息映射规则字符串,格式为'目标键:源键;目标键2:源键2'。示例:映射规则('size:filesize;ext:fileext'),源对象({filesize:'10000', fileext:'.gif'}),转换结果({size:'10000', ext:'.gif'})"} * @editorparams {"name":"readonly","parameterType":"boolean","defaultvalue":false,"description":"设置编辑器是否为只读态"} * @ignoreprops autoFocus | overflowMode * @ignoreemits blur | focus | enter | infoTextChange diff --git a/src/editor/upload/ibiz-image-upload/ibiz-image-upload.tsx b/src/editor/upload/ibiz-image-upload/ibiz-image-upload.tsx index d42fde9d..bba1affa 100644 --- a/src/editor/upload/ibiz-image-upload/ibiz-image-upload.tsx +++ b/src/editor/upload/ibiz-image-upload/ibiz-image-upload.tsx @@ -22,6 +22,7 @@ import { UploadEditorController } from '../upload-editor.controller'; * @editorparams {"name":"uploadparams","parameterType":"string","description":"上传参数,图片上传时,用于计算上传路径"} * @editorparams {"name":"exportparams","parameterType":"string","description":"下载参数,图片下载时,用于计算下载路径"} * @editorparams {"name":"osscat","parameterType":"string","description":"用于计算上传和下载路径的OSS参数"} + * @editorparams {"name":"infomap","parameterType":"string","description":"文件信息映射规则字符串,格式为'目标键:源键;目标键2:源键2'。示例:映射规则('size:filesize;ext:fileext'),源对象({filesize:'10000', fileext:'.gif'}),转换结果({size:'10000', ext:'.gif'})"} * @editorparams {"name":"readonly","parameterType":"boolean","defaultvalue":false,"description":"设置编辑器是否为只读态"} * @ignoreprops autoFocus | overflowMode * @ignoreemits blur | focus | enter | infoTextChange diff --git a/src/editor/upload/upload-editor.controller.ts b/src/editor/upload/upload-editor.controller.ts index 41b35d87..1a22fb41 100644 --- a/src/editor/upload/upload-editor.controller.ts +++ b/src/editor/upload/upload-editor.controller.ts @@ -42,6 +42,11 @@ export class UploadEditorController extends EditorController { */ public exportParams?: IParams; + /** + * 上传文件信息的映射规则字符串,格式为"目标键:源键;目标键2:源键2" + */ + public infoMap: string = ''; + /** * 自适应预览 * 只读状态下且配置了编辑器参数autoPreview ,加载完图片后自动调整大小达到预览态,且禁用图片hover工具栏 @@ -53,6 +58,8 @@ export class UploadEditorController extends EditorController { protected async onInit(): Promise { await super.onInit(); + this.infoMap = ibiz.config.uploadEditor.infoMap; + // 图片类型增加图片类型限制 if (this.model.editorType?.includes('PICTURE')) { this.accept = 'image/*'; @@ -83,6 +90,7 @@ export class UploadEditorController extends EditorController { uploadparams, exportparams, autopreview, + infomap, } = this.editorParams; if (isDrag) { this.isDrag = Boolean(isDrag); @@ -105,6 +113,9 @@ export class UploadEditorController extends EditorController { if (size) { this.size = Number(size); } + if (infomap) { + this.infoMap = infomap; + } if (uploadParams) { try { this.uploadParams = JSON.parse(uploadParams); @@ -147,4 +158,33 @@ export class UploadEditorController extends EditorController { } } } + + /** + * 根据配置的映射关系转换对象属性 + * 将源对象的指定属性,按照映射规则映射到新对象的目标属性 + * + * @param {IData} [_data={}] - 源数据对象,包含需要被映射的原始属性 + * @param {string} [infoMap=''] - 映射规则字符串,格式为"目标键:源键;目标键2:源键2" + * @returns {IData} 转换后的新对象,仅包含映射规则中定义的属性 + * + * @example + * // 源对象:{ filesize:'10000', fileext:'.gif', folder:'file' }; + * // 映射规则:'size:filesize;ext:fileext;folder:folder'; + * // 转换结果: { size:'10000', ext:'.gif', folder:'file' } + */ + transformInfoMap = (_data: IData = {}, infoMap = ''): IData => { + const result = {}; + const mappings = infoMap.split(';'); + mappings.forEach(mapping => { + const [targetKey, sourceKey] = mapping.split(':'); + if (!targetKey || !sourceKey) return; + + // 如果源对象中存在对应的属性,则添加到结果对象中 + if (Object.prototype.hasOwnProperty.call(_data, sourceKey)) { + Object.assign(result, { [targetKey]: _data[sourceKey] }); + } + }); + + return result; + }; } diff --git a/src/editor/upload/use/use-iview-upload.ts b/src/editor/upload/use/use-iview-upload.ts index e1cbbf40..5d679742 100644 --- a/src/editor/upload/use/use-iview-upload.ts +++ b/src/editor/upload/use/use-iview-upload.ts @@ -183,6 +183,46 @@ export function useIViewUpload( { immediate: true }, ); + /** + * 根据映射字符串从数据对象中提取指定字段 + * + * @param {IData} _data - 源数据对象,从中提取字段 + * @param {string} infoMap - 字段映射字符串,格式为"目标键:源键;目标键2:源键2" + * @returns {Object} 提取后的新对象,仅包含映射中指定的字段 + * @example + * // 源对象:{ filesize:'10000', fileext:'.gif', folder:'file' }; + * // 映射规则:'size:filesize;ext:fileext;folder:folder'; + * // 转换结果: { size:undefined, ext:undefined, folder:'file' } + */ + const extractFieldByMaping = (_data: IData = {}, infoMap = ''): IData => { + const result = {}; + const mappings = infoMap.split(';'); + mappings.forEach(mapping => { + // 遍历每个映射项,按冒号(":")分割并取第一个部分作为目标字段名 + const [targetKey] = mapping.split(':'); + if (!targetKey) return; + // 将保存需要的值重新合并到结果对象中 + Object.assign(result, { [targetKey]: _data[targetKey] }); + }); + return result; + }; + + /** + * 处理文件项数据 + * + * @param {IData} _file + * @return {*} {IData} + */ + const handleFileItem = (_file: IData): IData => { + const result = { + name: _file.name, + id: _file.id, + }; + if (c.infoMap) + Object.assign(result, extractFieldByMaping(_file, c.infoMap)); + return result; + }; + /** * 抛出值变更事件,根据files计算value * @@ -193,7 +233,7 @@ export function useIViewUpload( const _files = [...files.value, ...uploadCache.cacheFiles]; const value: string | null = _files.length > 0 - ? JSON.stringify(_files.map(file => ({ name: file.name, id: file.id }))) + ? JSON.stringify(_files.map(file => handleFileItem(file))) : null; uploadCache.cacheFiles = []; valueChange(value); @@ -217,15 +257,28 @@ export function useIViewUpload( return true; }; + /** + * 处理上传成功后返回的文件项数据 + * + * @param {IData} response + * @return {*} {IData} + */ + const handleRestFileItem = (response: IData): IData => { + const result = { + name: response.filename, + id: response.fileid, + }; + if (c.infoMap) + Object.assign(result, c.transformInfoMap(response, c.infoMap)); + return result; + }; + // 上传成功回调 const onSuccess = (response: IData) => { if (!response) { return; } - uploadCache.cacheFiles.push({ - name: response.filename, - id: response.fileid, - }); + uploadCache.cacheFiles.push(handleRestFileItem(response)); if (response.name.split('.').pop() === 'svg') { const blob = svgBlob.get(response.name); if (blob) { -- Gitee From 37230baa619033491136ffe82f16c84894bba908 Mon Sep 17 00:00:00 2001 From: lijisanxiong <1518062161@qq.com> Date: Thu, 31 Jul 2025 23:10:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat=EF=BC=9A=E6=96=B0=E5=A2=9E=E7=94=98?= =?UTF-8?q?=E7=89=B9=E5=9B=BE=E9=83=A8=E4=BB=B6=E5=8F=82=E6=95=B0=20unit?= =?UTF-8?q?=EF=BC=88=E6=A0=B9=E6=8D=AE=E8=AF=A5=E6=97=B6=E9=97=B4=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E5=91=88=E7=8E=B0=E5=8F=B3=E4=BE=A7=E7=94=98=E7=89=B9?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=A0=B7=E5=BC=8F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/control/gantt/gantt.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/control/gantt/gantt.tsx b/src/control/gantt/gantt.tsx index 7135a514..c8ef52fe 100644 --- a/src/control/gantt/gantt.tsx +++ b/src/control/gantt/gantt.tsx @@ -850,6 +850,7 @@ export const GanttControl = defineComponent({ leaf='_leaf' expand-key='_defaultExpand' locale={this.locale} + unit={this.c.state.unit} draggable={{ level: 'all', draggable: true }} allow-drop={this.allowDrop} allow-drag={this.allowDrag} -- Gitee From a3d9bef3e44bc8fcd5741d109a615ec361367652 Mon Sep 17 00:00:00 2001 From: lijisanxiong <1518062161@qq.com> Date: Thu, 31 Jul 2025 23:10:22 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat=EF=BC=9A=E6=9B=B4=E6=96=B0CHANGELOG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96d7d8c9..7b2f0be7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ ## [Unreleased] +### Added + +- 新增全局上传类编辑器配置和上传类编辑器参数 infoMap(上传文件信息的映射规则字符串) +- 新增甘特图部件参数 unit(根据该时间单位呈现右侧甘特页面样式) + ## Fixed - 修复分页搜索视图引擎设置搜索栏placeholder时因为无搜索栏而报错的问题 -- Gitee