From c80060b00e955db23ce15409b0fdfbe0672464a8 Mon Sep 17 00:00:00 2001 From: "bai.zixv" Date: Mon, 29 Jul 2024 15:57:42 +0800 Subject: [PATCH] feat(data-mapping): add new useage (#1403) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1403 Reviewed-by: sealday Co-authored-by: bai.zixv Co-committed-by: bai.zixv --- packages/core/components/src/code-mirror/index.tsx | 2 +- .../data-mapping/DataMapping.instruction.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/core/components/src/code-mirror/index.tsx b/packages/core/components/src/code-mirror/index.tsx index 6e2e6bf90..fe74cba62 100644 --- a/packages/core/components/src/code-mirror/index.tsx +++ b/packages/core/components/src/code-mirror/index.tsx @@ -3,7 +3,7 @@ import { connect } from '@tachybase/schema'; import Editor, { loader } from '@monaco-editor/react'; -loader.config({ paths: { vs: 'https://cdn.jsdelivr.net/npm/monaco-editor@0.50.0/min/vs' } }); +loader.config({ paths: { vs: 'https://unpkg.com/monaco-editor@0.50.0/min/vs' } }); export const CodeMirror = connect(({ value, onChange, ...otherProps }) => { return ( diff --git a/packages/plugins/@tachybase/plugin-workflow/src/server/features/data-mapping/DataMapping.instruction.ts b/packages/plugins/@tachybase/plugin-workflow/src/server/features/data-mapping/DataMapping.instruction.ts index 2ada84c9e..dd62a57fd 100644 --- a/packages/plugins/@tachybase/plugin-workflow/src/server/features/data-mapping/DataMapping.instruction.ts +++ b/packages/plugins/@tachybase/plugin-workflow/src/server/features/data-mapping/DataMapping.instruction.ts @@ -20,8 +20,17 @@ export class DataMappingInstruction extends Instruction { } case 1: { // 单数据源, 平铺为单对象; 忽略keyName - const source = sourceArray[0]['sourcePath']; - data = processor.getParsedValue(source, node.id); + const keyName = sourceArray[0]['keyName']; + const sourcePath = sourceArray[0]['sourcePath']; + const rawData = processor.getParsedValue(sourcePath, node.id); + // NOTE: 后来想了想, 发现还是统一用法比较好. 所以提供统一的用法, 同时保留原本的用法; 如果提供了keyName 就是统一的用法, 如果没有, 就是平铺. + if (keyName) { + data = { + [keyName]: rawData, + }; + } else { + data = rawData; + } break; } default: {