Commit 16263a37933ab960636996de5a909fb0264871e9
Merge branch 'main' into 'main_dev'
Main See merge request yunteng/thingskit-front!1456
Showing
26 changed files
with
284 additions
and
60 deletions
| 1 | -import { DeviceInfoItemType, DeviceTypeItem, PageParams, ScriptTestParams } from './model'; | 1 | +import { | 
| 2 | + DeviceInfoItemType, | ||
| 3 | + DeviceTypeItem, | ||
| 4 | + PageParams, | ||
| 5 | + QueryItemType, | ||
| 6 | + ScriptTestParams, | ||
| 7 | +} from './model'; | ||
| 2 | import { TBPaginationResult } from '/#/axios'; | 8 | import { TBPaginationResult } from '/#/axios'; | 
| 3 | import { ScriptLanguageEnum } from '/@/enums/scriptEnum'; | 9 | import { ScriptLanguageEnum } from '/@/enums/scriptEnum'; | 
| 4 | import { defHttp } from '/@/utils/http/axios'; | 10 | import { defHttp } from '/@/utils/http/axios'; | 
| @@ -6,7 +12,7 @@ import { defHttp } from '/@/utils/http/axios'; | @@ -6,7 +12,7 @@ import { defHttp } from '/@/utils/http/axios'; | ||
| 6 | enum Api { | 12 | enum Api { | 
| 7 | GET_DEVICE_INFOS = '/tenant/deviceInfos', | 13 | GET_DEVICE_INFOS = '/tenant/deviceInfos', | 
| 8 | GET_DEVICE_TYPE = '/device/types', | 14 | GET_DEVICE_TYPE = '/device/types', | 
| 9 | - TENANT_QUEUE = '/tenant/queues', | 15 | + QUEUE = '/queues', | 
| 10 | TEST_SCRIPT = '/ruleChain/testScript', | 16 | TEST_SCRIPT = '/ruleChain/testScript', | 
| 11 | } | 17 | } | 
| 12 | 18 | ||
| @@ -39,10 +45,10 @@ export const getDeviceTypes = () => { | @@ -39,10 +45,10 @@ export const getDeviceTypes = () => { | ||
| 39 | ); | 45 | ); | 
| 40 | }; | 46 | }; | 
| 41 | 47 | ||
| 42 | -export const getTenantQueue = (params: Recordable) => { | ||
| 43 | - return defHttp.get<string[]>( | 48 | +export const getQueue = (params: Recordable) => { | 
| 49 | + return defHttp.get<TBPaginationResult<QueryItemType>>( | ||
| 44 | { | 50 | { | 
| 45 | - url: Api.TENANT_QUEUE, | 51 | + url: Api.QUEUE, | 
| 46 | params, | 52 | params, | 
| 47 | }, | 53 | }, | 
| 48 | { joinPrefix: false } | 54 | { joinPrefix: false } | 
| @@ -62,3 +62,31 @@ export interface ScriptTestParams { | @@ -62,3 +62,31 @@ export interface ScriptTestParams { | ||
| 62 | scriptType?: string; | 62 | scriptType?: string; | 
| 63 | needMetadataAndMsgType?: boolean; | 63 | needMetadataAndMsgType?: boolean; | 
| 64 | } | 64 | } | 
| 65 | + | ||
| 66 | +export interface QueryItemType { | ||
| 67 | + id: Id; | ||
| 68 | + createdTime: number; | ||
| 69 | + additionalInfo: any; | ||
| 70 | + tenantId: Id; | ||
| 71 | + name: string; | ||
| 72 | + topic: string; | ||
| 73 | + pollInterval: number; | ||
| 74 | + partitions: number; | ||
| 75 | + consumerPerPartition: boolean; | ||
| 76 | + packProcessingTimeout: number; | ||
| 77 | + submitStrategy: SubmitStrategy; | ||
| 78 | + processingStrategy: ProcessingStrategy; | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +export interface SubmitStrategy { | ||
| 82 | + type: string; | ||
| 83 | + batchSize: number; | ||
| 84 | +} | ||
| 85 | + | ||
| 86 | +export interface ProcessingStrategy { | ||
| 87 | + type: string; | ||
| 88 | + retries: number; | ||
| 89 | + failurePercentage: number; | ||
| 90 | + pauseBetweenRetries: number; | ||
| 91 | + maxPauseBetweenRetries: number; | ||
| 92 | +} | 
| @@ -16,6 +16,7 @@ import { DeviceProfileDetail } from '/@/api/device/model/deviceConfigModel'; | @@ -16,6 +16,7 @@ import { DeviceProfileDetail } from '/@/api/device/model/deviceConfigModel'; | ||
| 16 | import { getDeviceProfileOtaPackages, getOtaPackageInfo } from '/@/api/ota'; | 16 | import { getDeviceProfileOtaPackages, getOtaPackageInfo } from '/@/api/ota'; | 
| 17 | import { QueryDeviceProfileOtaPackagesType } from '/@/api/ota/model'; | 17 | import { QueryDeviceProfileOtaPackagesType } from '/@/api/ota/model'; | 
| 18 | import { OTAPackageType } from '/@/enums/otaEnum'; | 18 | import { OTAPackageType } from '/@/enums/otaEnum'; | 
| 19 | +import { createPickerSearch } from '/@/utils/pickerSearch'; | ||
| 19 | 20 | ||
| 20 | useComponentRegister('JSONEditor', JSONEditor); | 21 | useComponentRegister('JSONEditor', JSONEditor); | 
| 21 | useComponentRegister('LockControlGroup', LockControlGroup); | 22 | useComponentRegister('LockControlGroup', LockControlGroup); | 
| @@ -176,10 +177,8 @@ export const step1Schemas: FormSchema[] = [ | @@ -176,10 +177,8 @@ export const step1Schemas: FormSchema[] = [ | ||
| 176 | }); | 177 | }); | 
| 177 | } | 178 | } | 
| 178 | }, | 179 | }, | 
| 179 | - showSearch: true, | ||
| 180 | placeholder: '请选择产品', | 180 | placeholder: '请选择产品', | 
| 181 | - filterOption: (inputValue: string, option: Record<'label' | 'value', string>) => | ||
| 182 | - option.label.includes(inputValue), | 181 | + ...createPickerSearch(), | 
| 183 | }, | 182 | }, | 
| 184 | }; | 183 | }; | 
| 185 | }, | 184 | }, | 
| @@ -364,6 +363,7 @@ export const step1Schemas: FormSchema[] = [ | @@ -364,6 +363,7 @@ export const step1Schemas: FormSchema[] = [ | ||
| 364 | result && setFieldsValue({ sensorOrganizationId: result?.organizationId }); | 363 | result && setFieldsValue({ sensorOrganizationId: result?.organizationId }); | 
| 365 | } | 364 | } | 
| 366 | }, | 365 | }, | 
| 366 | + ...createPickerSearch(), | ||
| 367 | }; | 367 | }; | 
| 368 | }, | 368 | }, | 
| 369 | }, | 369 | }, | 
| @@ -15,6 +15,8 @@ export enum AssignToCustomerFieldsNameEnum { | @@ -15,6 +15,8 @@ export enum AssignToCustomerFieldsNameEnum { | ||
| 15 | export enum ClearAlarmFieldsEnum { | 15 | export enum ClearAlarmFieldsEnum { | 
| 16 | ALARM_TYPE = 'alarmType', | 16 | ALARM_TYPE = 'alarmType', | 
| 17 | ALARM_DETAILS_BUILD_JS = 'alarmDetailsBuildJs', | 17 | ALARM_DETAILS_BUILD_JS = 'alarmDetailsBuildJs', | 
| 18 | + ALARM_DETAILS_BUILD_TBEL = 'alarmDetailsBuildTbel', | ||
| 19 | + SCRIPT_LANG = 'scriptLang', | ||
| 18 | } | 20 | } | 
| 19 | 21 | ||
| 20 | export enum ClearAlarmFieldsNameEnum { | 22 | export enum ClearAlarmFieldsNameEnum { | 
| 1 | import { ClearAlarmFieldsEnum, ClearAlarmFieldsNameEnum } from '../../../enum/formField/action'; | 1 | import { ClearAlarmFieldsEnum, ClearAlarmFieldsNameEnum } from '../../../enum/formField/action'; | 
| 2 | -import { JavascriptEditorWithTestModal } from '../../../src/components/JavaScriptFilterModal'; | 2 | +import { | 
| 3 | + JavascriptEditorWithTestModal, | ||
| 4 | + ScriptEditorValueType, | ||
| 5 | +} from '../../../src/components/JavaScriptFilterModal'; | ||
| 6 | +import { DefaultNodeConfig } from '../../../types/node'; | ||
| 3 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 7 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 4 | import { useI18n } from '/@/hooks/web/useI18n'; | 8 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| 5 | 9 | ||
| @@ -7,6 +11,17 @@ const { t } = useI18n(); | @@ -7,6 +11,17 @@ const { t } = useI18n(); | ||
| 7 | 11 | ||
| 8 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 12 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 
| 9 | 13 | ||
| 14 | +export interface FormFieldsValue { | ||
| 15 | + [ClearAlarmFieldsEnum.ALARM_DETAILS_BUILD_JS]: ScriptEditorValueType; | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +export interface NodeConfigValue extends DefaultNodeConfig { | ||
| 19 | + alarmDetailsBuildJs: string; | ||
| 20 | + alarmDetailsBuildTbel: string; | ||
| 21 | + alarmType: string; | ||
| 22 | + scriptLang: string; | ||
| 23 | +} | ||
| 24 | + | ||
| 10 | export const formSchemas: FormSchema[] = [ | 25 | export const formSchemas: FormSchema[] = [ | 
| 11 | { | 26 | { | 
| 12 | field: ClearAlarmFieldsEnum.ALARM_DETAILS_BUILD_JS, | 27 | field: ClearAlarmFieldsEnum.ALARM_DETAILS_BUILD_JS, | 
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | - import { formSchemas } from './create.config'; | 4 | + import { NodeConfigValue, FormFieldsValue, formSchemas } from './create.config'; | 
| 5 | import { NodeData } from '../../../types/node'; | 5 | import { NodeData } from '../../../types/node'; | 
| 6 | 6 | ||
| 7 | defineProps<{ | 7 | defineProps<{ | 
| @@ -15,13 +15,29 @@ | @@ -15,13 +15,29 @@ | ||
| 15 | 15 | ||
| 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 
| 17 | await validate(); | 17 | await validate(); | 
| 18 | - const value = getFieldsValue() || {}; | ||
| 19 | - return value; | 18 | + const value = (getFieldsValue() || {}) as FormFieldsValue; | 
| 19 | + const { alarmDetailsBuildJs, ...restParams } = value; | ||
| 20 | + const { scriptLang, jsScript, tbelScript } = alarmDetailsBuildJs || {}; | ||
| 21 | + | ||
| 22 | + return { | ||
| 23 | + ...restParams, | ||
| 24 | + scriptLang, | ||
| 25 | + alarmDetailsBuildJs: jsScript, | ||
| 26 | + alarmDetailsBuildTbel: tbelScript, | ||
| 27 | + }; | ||
| 20 | }; | 28 | }; | 
| 21 | 29 | ||
| 22 | - const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value) => { | 30 | + const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value: NodeConfigValue) => { | 
| 23 | resetFields(); | 31 | resetFields(); | 
| 24 | - setFieldsValue(value); | 32 | + const { alarmDetailsBuildJs, alarmDetailsBuildTbel, scriptLang } = value || {}; | 
| 33 | + setFieldsValue({ | ||
| 34 | + ...value, | ||
| 35 | + alarmDetailsBuildJs: { | ||
| 36 | + jsScript: alarmDetailsBuildJs, | ||
| 37 | + tbelScript: alarmDetailsBuildTbel, | ||
| 38 | + scriptLang, | ||
| 39 | + }, | ||
| 40 | + } as FormFieldsValue); | ||
| 25 | }; | 41 | }; | 
| 26 | 42 | ||
| 27 | defineExpose({ | 43 | defineExpose({ | 
| @@ -27,8 +27,11 @@ export const ClearAlarmConfig: NodeItemConfigType = { | @@ -27,8 +27,11 @@ export const ClearAlarmConfig: NodeItemConfigType = { | ||
| 27 | ruleChainNode: false, | 27 | ruleChainNode: false, | 
| 28 | defaultConfiguration: { | 28 | defaultConfiguration: { | 
| 29 | alarmType: 'General Alarm', | 29 | alarmType: 'General Alarm', | 
| 30 | + scriptLang: 'TBEL', | ||
| 30 | alarmDetailsBuildJs: | 31 | alarmDetailsBuildJs: | 
| 31 | 'var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n //remove prevAlarmDetails from metadata\n delete metadata.prevAlarmDetails;\n //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;', | 32 | 'var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n //remove prevAlarmDetails from metadata\n delete metadata.prevAlarmDetails;\n //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;', | 
| 33 | + alarmDetailsBuildTbel: | ||
| 34 | + "var details = {};\nif (metadata.prevAlarmDetails != null) {\n details = JSON.parse(metadata.prevAlarmDetails);\n //remove prevAlarmDetails from metadata\n metadata.remove('prevAlarmDetails');\n //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;", | ||
| 32 | }, | 35 | }, | 
| 33 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 36 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 
| 34 | configDirective: 'tbActionNodeClearAlarmConfig', | 37 | configDirective: 'tbActionNodeClearAlarmConfig', | 
| 1 | import { CreateAlarmFieldsEnum, CreateAlarmFieldsNameEnum } from '../../../enum/formField/action'; | 1 | import { CreateAlarmFieldsEnum, CreateAlarmFieldsNameEnum } from '../../../enum/formField/action'; | 
| 2 | -import { JavascriptEditorWithTestModal } from '../../../src/components/JavaScriptFilterModal'; | 2 | +import { | 
| 3 | + JavascriptEditorWithTestModal, | ||
| 4 | + ScriptEditorValueType, | ||
| 5 | +} from '../../../src/components/JavaScriptFilterModal'; | ||
| 6 | +import { DefaultNodeConfig } from '../../../types/node'; | ||
| 3 | import { findDictItemByCode } from '/@/api/system/dict'; | 7 | import { findDictItemByCode } from '/@/api/system/dict'; | 
| 4 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 8 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 5 | import { useI18n } from '/@/hooks/web/useI18n'; | 9 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| @@ -8,6 +12,16 @@ const { t } = useI18n(); | @@ -8,6 +12,16 @@ const { t } = useI18n(); | ||
| 8 | 12 | ||
| 9 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 13 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 
| 10 | 14 | ||
| 15 | +export interface FormFieldsValue { | ||
| 16 | + [CreateAlarmFieldsEnum.ALARM_DETAILS_BUILD_JS]: ScriptEditorValueType; | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +export interface NodeConfigValue extends DefaultNodeConfig { | ||
| 20 | + alarmDetailsBuildJs: string; | ||
| 21 | + alarmDetailsBuildTbel: string; | ||
| 22 | + scriptLang: string; | ||
| 23 | +} | ||
| 24 | + | ||
| 11 | export const formSchemas: FormSchema[] = [ | 25 | export const formSchemas: FormSchema[] = [ | 
| 12 | { | 26 | { | 
| 13 | field: CreateAlarmFieldsEnum.USE_MESSAGE_ALARM_DATA, | 27 | field: CreateAlarmFieldsEnum.USE_MESSAGE_ALARM_DATA, | 
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | - import { formSchemas } from './create.config'; | 4 | + import { FormFieldsValue, formSchemas, NodeConfigValue } from './create.config'; | 
| 5 | import { NodeData } from '../../../types/node'; | 5 | import { NodeData } from '../../../types/node'; | 
| 6 | 6 | ||
| 7 | defineProps<{ | 7 | defineProps<{ | 
| @@ -15,13 +15,28 @@ | @@ -15,13 +15,28 @@ | ||
| 15 | 15 | ||
| 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 
| 17 | await validate(); | 17 | await validate(); | 
| 18 | - const value = getFieldsValue() || {}; | ||
| 19 | - return value; | 18 | + const value = (getFieldsValue() || {}) as FormFieldsValue; | 
| 19 | + const { alarmDetailsBuildJs, ...resetParams } = value; | ||
| 20 | + const { scriptLang, tbelScript, jsScript } = alarmDetailsBuildJs; | ||
| 21 | + return { | ||
| 22 | + ...resetParams, | ||
| 23 | + alarmDetailsBuildJs: jsScript, | ||
| 24 | + alarmDetailsBuildTbel: tbelScript, | ||
| 25 | + scriptLang, | ||
| 26 | + } as NodeConfigValue; | ||
| 20 | }; | 27 | }; | 
| 21 | 28 | ||
| 22 | - const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value) => { | 29 | + const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value: NodeConfigValue) => { | 
| 23 | resetFields(); | 30 | resetFields(); | 
| 24 | - setFieldsValue(value); | 31 | + const { alarmDetailsBuildJs, alarmDetailsBuildTbel, scriptLang } = value; | 
| 32 | + setFieldsValue({ | ||
| 33 | + ...value, | ||
| 34 | + alarmDetailsBuildJs: { | ||
| 35 | + jsScript: alarmDetailsBuildJs, | ||
| 36 | + tbelScript: alarmDetailsBuildTbel, | ||
| 37 | + scriptLang, | ||
| 38 | + }, | ||
| 39 | + } as FormFieldsValue); | ||
| 25 | }; | 40 | }; | 
| 26 | 41 | ||
| 27 | defineExpose({ | 42 | defineExpose({ | 
| @@ -27,8 +27,11 @@ export const CreateAlarmConfig: NodeItemConfigType = { | @@ -27,8 +27,11 @@ export const CreateAlarmConfig: NodeItemConfigType = { | ||
| 27 | ruleChainNode: false, | 27 | ruleChainNode: false, | 
| 28 | defaultConfiguration: { | 28 | defaultConfiguration: { | 
| 29 | alarmType: 'General Alarm', | 29 | alarmType: 'General Alarm', | 
| 30 | + scriptLang: 'TBEL', | ||
| 30 | alarmDetailsBuildJs: | 31 | alarmDetailsBuildJs: | 
| 31 | 'var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n //remove prevAlarmDetails from metadata\n delete metadata.prevAlarmDetails;\n //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;', | 32 | 'var details = {};\nif (metadata.prevAlarmDetails) {\n details = JSON.parse(metadata.prevAlarmDetails);\n //remove prevAlarmDetails from metadata\n delete metadata.prevAlarmDetails;\n //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;', | 
| 33 | + alarmDetailsBuildTbel: | ||
| 34 | + "var details = {};\nif (metadata.prevAlarmDetails != null) {\n details = JSON.parse(metadata.prevAlarmDetails);\n //remove prevAlarmDetails from metadata\n metadata.remove('prevAlarmDetails');\n //now metadata is the same as it comes IN this rule node\n}\n\n\nreturn details;", | ||
| 32 | severity: 'CRITICAL', | 35 | severity: 'CRITICAL', | 
| 33 | propagate: false, | 36 | propagate: false, | 
| 34 | propagateToOwner: false, | 37 | propagateToOwner: false, | 
| 1 | import { EntityTypeEnum, EntityTypeNameEnum } from '../../../enum/form'; | 1 | import { EntityTypeEnum, EntityTypeNameEnum } from '../../../enum/form'; | 
| 2 | import { GeneratorFieldsEnum, GeneratorFieldsNameEnum } from '../../../enum/formField/action'; | 2 | import { GeneratorFieldsEnum, GeneratorFieldsNameEnum } from '../../../enum/formField/action'; | 
| 3 | -import { JavascriptEditorWithTestModal } from '../../../src/components/JavaScriptFilterModal'; | 3 | +import { | 
| 4 | + JavascriptEditorWithTestModal, | ||
| 5 | + ScriptEditorValueType, | ||
| 6 | +} from '../../../src/components/JavaScriptFilterModal'; | ||
| 7 | +import { DefaultNodeConfig } from '../../../types/node'; | ||
| 4 | import { getEntityIdSelect } from '../../Filter/CheckRelation/create.config'; | 8 | import { getEntityIdSelect } from '../../Filter/CheckRelation/create.config'; | 
| 5 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 9 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 6 | import { useI18n } from '/@/hooks/web/useI18n'; | 10 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| @@ -9,6 +13,12 @@ const { t } = useI18n(); | @@ -9,6 +13,12 @@ const { t } = useI18n(); | ||
| 9 | 13 | ||
| 10 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 14 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 
| 11 | 15 | ||
| 16 | +export interface FormFieldsValue { | ||
| 17 | + [GeneratorFieldsEnum.JS_SCRIPT]: ScriptEditorValueType; | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +export interface NodeConfigValue extends DefaultNodeConfig, ScriptEditorValueType {} | ||
| 21 | + | ||
| 12 | export const formSchemas: FormSchema[] = [ | 22 | export const formSchemas: FormSchema[] = [ | 
| 13 | { | 23 | { | 
| 14 | field: GeneratorFieldsEnum.MSG_COUNT, | 24 | field: GeneratorFieldsEnum.MSG_COUNT, | 
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | - import { formSchemas } from './create.config'; | 4 | + import { FormFieldsValue, formSchemas, NodeConfigValue } from './create.config'; | 
| 5 | import { NodeData } from '../../../types/node'; | 5 | import { NodeData } from '../../../types/node'; | 
| 6 | 6 | ||
| 7 | defineProps<{ | 7 | defineProps<{ | 
| @@ -15,13 +15,25 @@ | @@ -15,13 +15,25 @@ | ||
| 15 | 15 | ||
| 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 
| 17 | await validate(); | 17 | await validate(); | 
| 18 | - const value = getFieldsValue() || {}; | ||
| 19 | - return value; | 18 | + const value = (getFieldsValue() || {}) as FormFieldsValue; | 
| 19 | + const { jsScript, ...resetParams } = value; | ||
| 20 | + return { | ||
| 21 | + ...resetParams, | ||
| 22 | + ...jsScript, | ||
| 23 | + } as NodeConfigValue; | ||
| 20 | }; | 24 | }; | 
| 21 | 25 | ||
| 22 | - const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value) => { | 26 | + const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value: NodeConfigValue) => { | 
| 23 | resetFields(); | 27 | resetFields(); | 
| 24 | - setFieldsValue(value); | 28 | + const { jsScript, tbelScript, scriptLang } = value; | 
| 29 | + setFieldsValue({ | ||
| 30 | + ...value, | ||
| 31 | + jsScript: { | ||
| 32 | + jsScript, | ||
| 33 | + tbelScript, | ||
| 34 | + scriptLang, | ||
| 35 | + }, | ||
| 36 | + } as FormFieldsValue); | ||
| 25 | }; | 37 | }; | 
| 26 | 38 | ||
| 27 | defineExpose({ | 39 | defineExpose({ | 
| @@ -31,8 +31,11 @@ export const GeneratorConfig: NodeItemConfigType = { | @@ -31,8 +31,11 @@ export const GeneratorConfig: NodeItemConfigType = { | ||
| 31 | periodInSeconds: 1, | 31 | periodInSeconds: 1, | 
| 32 | originatorId: null, | 32 | originatorId: null, | 
| 33 | originatorType: null, | 33 | originatorType: null, | 
| 34 | + scriptLang: 'TBEL', | ||
| 34 | jsScript: | 35 | jsScript: | 
| 35 | 'var msg = { temp: 42, humidity: 77 };\nvar metadata = { data: 40 };\nvar msgType = "POST_TELEMETRY_REQUEST";\n\nreturn { msg: msg, metadata: metadata, msgType: msgType };', | 36 | 'var msg = { temp: 42, humidity: 77 };\nvar metadata = { data: 40 };\nvar msgType = "POST_TELEMETRY_REQUEST";\n\nreturn { msg: msg, metadata: metadata, msgType: msgType };', | 
| 37 | + tbelScript: | ||
| 38 | + 'var msg = { temp: 42, humidity: 77 };\nvar metadata = { data: 40 };\nvar msgType = "POST_TELEMETRY_REQUEST";\n\nreturn { msg: msg, metadata: metadata, msgType: msgType };', | ||
| 36 | }, | 39 | }, | 
| 37 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 40 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 
| 38 | configDirective: 'tbActionNodeGeneratorConfig', | 41 | configDirective: 'tbActionNodeGeneratorConfig', | 
| 1 | import { LogFieldsEnum, LogFieldsNameEnum } from '../../../enum/formField/action'; | 1 | import { LogFieldsEnum, LogFieldsNameEnum } from '../../../enum/formField/action'; | 
| 2 | -import { JavascriptEditorWithTestModal } from '../../../src/components/JavaScriptFilterModal'; | 2 | +import { | 
| 3 | + JavascriptEditorWithTestModal, | ||
| 4 | + ScriptEditorValueType, | ||
| 5 | +} from '../../../src/components/JavaScriptFilterModal'; | ||
| 6 | +import { DefaultNodeConfig } from '../../../types/node'; | ||
| 3 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 7 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 4 | import { useI18n } from '/@/hooks/web/useI18n'; | 8 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| 5 | const { t } = useI18n(); | 9 | const { t } = useI18n(); | 
| 6 | 10 | ||
| 7 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 11 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 
| 8 | 12 | ||
| 13 | +export interface FormFieldsValue { | ||
| 14 | + [LogFieldsEnum.JS_SCRIPT]: ScriptEditorValueType; | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +export interface NodeConfigValue extends DefaultNodeConfig, ScriptEditorValueType {} | ||
| 18 | + | ||
| 9 | export const formSchemas: FormSchema[] = [ | 19 | export const formSchemas: FormSchema[] = [ | 
| 10 | { | 20 | { | 
| 11 | field: LogFieldsEnum.JS_SCRIPT, | 21 | field: LogFieldsEnum.JS_SCRIPT, | 
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | - import { formSchemas } from './create.config'; | 4 | + import { FormFieldsValue, formSchemas, NodeConfigValue } from './create.config'; | 
| 5 | import { NodeData } from '../../../types/node'; | 5 | import { NodeData } from '../../../types/node'; | 
| 6 | 6 | ||
| 7 | defineProps<{ | 7 | defineProps<{ | 
| @@ -15,13 +15,25 @@ | @@ -15,13 +15,25 @@ | ||
| 15 | 15 | ||
| 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 
| 17 | await validate(); | 17 | await validate(); | 
| 18 | - const value = getFieldsValue() || {}; | ||
| 19 | - return value; | 18 | + const value = (getFieldsValue() || {}) as FormFieldsValue; | 
| 19 | + const { jsScript, ...resetParams } = value; | ||
| 20 | + return { | ||
| 21 | + ...resetParams, | ||
| 22 | + ...jsScript, | ||
| 23 | + } as NodeConfigValue; | ||
| 20 | }; | 24 | }; | 
| 21 | 25 | ||
| 22 | - const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value) => { | 26 | + const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value: NodeConfigValue) => { | 
| 23 | resetFields(); | 27 | resetFields(); | 
| 24 | - setFieldsValue(value); | 28 | + const { jsScript, tbelScript, scriptLang } = value; | 
| 29 | + setFieldsValue({ | ||
| 30 | + ...value, | ||
| 31 | + jsScript: { | ||
| 32 | + jsScript, | ||
| 33 | + tbelScript, | ||
| 34 | + scriptLang, | ||
| 35 | + }, | ||
| 36 | + } as FormFieldsValue); | ||
| 25 | }; | 37 | }; | 
| 26 | 38 | ||
| 27 | defineExpose({ | 39 | defineExpose({ | 
| @@ -26,8 +26,11 @@ export const LogConfig: NodeItemConfigType = { | @@ -26,8 +26,11 @@ export const LogConfig: NodeItemConfigType = { | ||
| 26 | customRelations: false, | 26 | customRelations: false, | 
| 27 | ruleChainNode: false, | 27 | ruleChainNode: false, | 
| 28 | defaultConfiguration: { | 28 | defaultConfiguration: { | 
| 29 | + scriptLang: 'TBEL', | ||
| 29 | jsScript: | 30 | jsScript: | 
| 30 | - "return 'Incoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);", | 31 | + "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);", | 
| 32 | + tbelScript: | ||
| 33 | + "return '\\nIncoming message:\\n' + JSON.stringify(msg) + '\\nIncoming metadata:\\n' + JSON.stringify(metadata);", | ||
| 31 | }, | 34 | }, | 
| 32 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 35 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 
| 33 | configDirective: 'tbActionNodeLogConfig', | 36 | configDirective: 'tbActionNodeLogConfig', | 
| 1 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 1 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 2 | import HelpMessage from './HelpMessage.vue'; | 2 | import HelpMessage from './HelpMessage.vue'; | 
| 3 | -import { JavascriptEditorWithTestModal } from '/@/views/rule/designer/src/components/JavaScriptFilterModal'; | 3 | +import { | 
| 4 | + JavascriptEditorWithTestModal, | ||
| 5 | + ScriptEditorValueType, | ||
| 6 | +} from '/@/views/rule/designer/src/components/JavaScriptFilterModal'; | ||
| 4 | import { ScriptFieldsEnum, ScriptFieldsNameEnum } from '../../../enum/formField/filter'; | 7 | import { ScriptFieldsEnum, ScriptFieldsNameEnum } from '../../../enum/formField/filter'; | 
| 5 | import { useI18n } from '/@/hooks/web/useI18n'; | 8 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| 6 | import { h } from 'vue'; | 9 | import { h } from 'vue'; | 
| 10 | +import { DefaultNodeConfig } from '../../../types/node'; | ||
| 7 | 11 | ||
| 8 | const { t } = useI18n(); | 12 | const { t } = useI18n(); | 
| 9 | 13 | ||
| 10 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 14 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 
| 11 | 15 | ||
| 16 | +export interface FormFieldsValue { | ||
| 17 | + [ScriptFieldsEnum.JS_SCRIPT]: ScriptEditorValueType; | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +export interface NodeConfigValue extends DefaultNodeConfig, ScriptEditorValueType {} | ||
| 21 | + | ||
| 12 | export const formSchemas: FormSchema[] = [ | 22 | export const formSchemas: FormSchema[] = [ | 
| 13 | { | 23 | { | 
| 14 | field: ScriptFieldsEnum.JS_SCRIPT, | 24 | field: ScriptFieldsEnum.JS_SCRIPT, | 
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | - import { formSchemas } from './create.config'; | 4 | + import { FormFieldsValue, formSchemas, NodeConfigValue } from './create.config'; | 
| 5 | import { NodeData } from '../../../types/node'; | 5 | import { NodeData } from '../../../types/node'; | 
| 6 | 6 | ||
| 7 | defineProps<{ | 7 | defineProps<{ | 
| @@ -15,13 +15,25 @@ | @@ -15,13 +15,25 @@ | ||
| 15 | 15 | ||
| 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 
| 17 | await validate(); | 17 | await validate(); | 
| 18 | - const value = getFieldsValue() || {}; | ||
| 19 | - return value; | 18 | + const value = (getFieldsValue() || {}) as FormFieldsValue; | 
| 19 | + const { jsScript, ...resetParams } = value; | ||
| 20 | + return { | ||
| 21 | + ...resetParams, | ||
| 22 | + ...jsScript, | ||
| 23 | + } as NodeConfigValue; | ||
| 20 | }; | 24 | }; | 
| 21 | 25 | ||
| 22 | - const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value) => { | 26 | + const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value: NodeConfigValue) => { | 
| 23 | resetFields(); | 27 | resetFields(); | 
| 24 | - setFieldsValue(value); | 28 | + const { jsScript, tbelScript, scriptLang } = value; | 
| 29 | + setFieldsValue({ | ||
| 30 | + ...value, | ||
| 31 | + jsScript: { | ||
| 32 | + jsScript, | ||
| 33 | + tbelScript, | ||
| 34 | + scriptLang, | ||
| 35 | + }, | ||
| 36 | + } as FormFieldsValue); | ||
| 25 | }; | 37 | }; | 
| 26 | 38 | ||
| 27 | defineExpose({ | 39 | defineExpose({ | 
| @@ -26,7 +26,9 @@ export const ScriptConfig: NodeItemConfigType = { | @@ -26,7 +26,9 @@ export const ScriptConfig: NodeItemConfigType = { | ||
| 26 | customRelations: false, | 26 | customRelations: false, | 
| 27 | ruleChainNode: false, | 27 | ruleChainNode: false, | 
| 28 | defaultConfiguration: { | 28 | defaultConfiguration: { | 
| 29 | + scriptLang: 'TBEL', | ||
| 29 | jsScript: 'return msg.temperature > 20;', | 30 | jsScript: 'return msg.temperature > 20;', | 
| 31 | + tbelScript: 'return msg.temperature > 20;', | ||
| 30 | }, | 32 | }, | 
| 31 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 33 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 
| 32 | configDirective: 'tbFilterNodeScriptConfig', | 34 | configDirective: 'tbFilterNodeScriptConfig', | 
| 1 | import { SwitchFieldsEnum, SwitchFieldsNameEnum } from '../../../enum/formField/filter'; | 1 | import { SwitchFieldsEnum, SwitchFieldsNameEnum } from '../../../enum/formField/filter'; | 
| 2 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 2 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 3 | -import { JavascriptEditorWithTestModal } from '/@/views/rule/designer/src/components/JavaScriptFilterModal'; | 3 | +import { | 
| 4 | + JavascriptEditorWithTestModal, | ||
| 5 | + ScriptEditorValueType, | ||
| 6 | +} from '/@/views/rule/designer/src/components/JavaScriptFilterModal'; | ||
| 4 | import { useI18n } from '/@/hooks/web/useI18n'; | 7 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| 8 | +import { DefaultNodeConfig } from '../../../types/node'; | ||
| 5 | 9 | ||
| 6 | const { t } = useI18n(); | 10 | const { t } = useI18n(); | 
| 7 | 11 | ||
| 8 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 12 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 
| 9 | 13 | ||
| 14 | +export interface FormFieldsValue { | ||
| 15 | + [SwitchFieldsEnum.JS_SCRIPT]: ScriptEditorValueType; | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +export interface NodeConfigValue extends DefaultNodeConfig, ScriptEditorValueType {} | ||
| 19 | + | ||
| 10 | export const formSchemas: FormSchema[] = [ | 20 | export const formSchemas: FormSchema[] = [ | 
| 11 | { | 21 | { | 
| 12 | field: SwitchFieldsEnum.JS_SCRIPT, | 22 | field: SwitchFieldsEnum.JS_SCRIPT, | 
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | - import { formSchemas } from './create.config'; | 4 | + import { FormFieldsValue, formSchemas, NodeConfigValue } from './create.config'; | 
| 5 | import { NodeData } from '../../../types/node'; | 5 | import { NodeData } from '../../../types/node'; | 
| 6 | 6 | ||
| 7 | defineProps<{ | 7 | defineProps<{ | 
| @@ -15,13 +15,25 @@ | @@ -15,13 +15,25 @@ | ||
| 15 | 15 | ||
| 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 
| 17 | await validate(); | 17 | await validate(); | 
| 18 | - const value = getFieldsValue() || {}; | ||
| 19 | - return value; | 18 | + const value = (getFieldsValue() || {}) as FormFieldsValue; | 
| 19 | + const { jsScript, ...resetParams } = value; | ||
| 20 | + return { | ||
| 21 | + ...resetParams, | ||
| 22 | + ...jsScript, | ||
| 23 | + } as NodeConfigValue; | ||
| 20 | }; | 24 | }; | 
| 21 | 25 | ||
| 22 | - const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value) => { | 26 | + const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value: NodeConfigValue) => { | 
| 23 | resetFields(); | 27 | resetFields(); | 
| 24 | - setFieldsValue(value); | 28 | + const { jsScript, tbelScript, scriptLang } = value; | 
| 29 | + setFieldsValue({ | ||
| 30 | + ...value, | ||
| 31 | + jsScript: { | ||
| 32 | + jsScript, | ||
| 33 | + tbelScript, | ||
| 34 | + scriptLang, | ||
| 35 | + }, | ||
| 36 | + } as FormFieldsValue); | ||
| 25 | }; | 37 | }; | 
| 26 | 38 | ||
| 27 | defineExpose({ | 39 | defineExpose({ | 
| @@ -26,8 +26,11 @@ export const SwitchConfig: NodeItemConfigType = { | @@ -26,8 +26,11 @@ export const SwitchConfig: NodeItemConfigType = { | ||
| 26 | customRelations: true, | 26 | customRelations: true, | 
| 27 | ruleChainNode: false, | 27 | ruleChainNode: false, | 
| 28 | defaultConfiguration: { | 28 | defaultConfiguration: { | 
| 29 | + scriptLang: 'TBEL', | ||
| 29 | jsScript: | 30 | jsScript: | 
| 30 | "function nextRelation(metadata, msg) {\n return ['one','nine'];\n}\nif(msgType === 'POST_TELEMETRY_REQUEST') {\n return ['two'];\n}\nreturn nextRelation(metadata, msg);", | 31 | "function nextRelation(metadata, msg) {\n return ['one','nine'];\n}\nif(msgType === 'POST_TELEMETRY_REQUEST') {\n return ['two'];\n}\nreturn nextRelation(metadata, msg);", | 
| 32 | + tbelScript: | ||
| 33 | + "function nextRelation(metadata, msg) {\n return ['one','nine'];\n}\nif(msgType == 'POST_TELEMETRY_REQUEST') {\n return ['two'];\n}\nreturn nextRelation(metadata, msg);", | ||
| 31 | }, | 34 | }, | 
| 32 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 35 | uiResources: ['static/rulenode/rulenode-core-config.js'], | 
| 33 | configDirective: 'tbFilterNodeSwitchConfig', | 36 | configDirective: 'tbFilterNodeSwitchConfig', | 
| 1 | import { CheckPointFieldsEnum, CheckPointFieldsNameEnum } from '../../../enum/formField/flow'; | 1 | import { CheckPointFieldsEnum, CheckPointFieldsNameEnum } from '../../../enum/formField/flow'; | 
| 2 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 2 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 3 | import ApiComplete from './ApiComplete.vue'; | 3 | import ApiComplete from './ApiComplete.vue'; | 
| 4 | -import { getTenantQueue } from '/@/api/ruleChainDesigner'; | 4 | +import { getQueue } from '/@/api/ruleChainDesigner'; | 
| 5 | 5 | ||
| 6 | import { useI18n } from '/@/hooks/web/useI18n'; | 6 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| 7 | 7 | ||
| @@ -23,10 +23,16 @@ export const formSchemas: FormSchema[] = [ | @@ -23,10 +23,16 @@ export const formSchemas: FormSchema[] = [ | ||
| 23 | placeholder: `请选择${t(CheckPointFieldsNameEnum.QUEUE_NAME)}`, | 23 | placeholder: `请选择${t(CheckPointFieldsNameEnum.QUEUE_NAME)}`, | 
| 24 | getPopupContainer: () => document.body, | 24 | getPopupContainer: () => document.body, | 
| 25 | api: async (params: Recordable) => { | 25 | api: async (params: Recordable) => { | 
| 26 | - const options = await getTenantQueue(params); | ||
| 27 | - return options.map((value) => ({ label: value, value })); | 26 | + const options = await getQueue(params); | 
| 27 | + return options.data.map((value) => ({ label: value.name, value: value.name })); | ||
| 28 | + }, | ||
| 29 | + params: { | ||
| 30 | + serviceType: 'TB_RULE_ENGINE', | ||
| 31 | + page: 0, | ||
| 32 | + pageSize: 10, | ||
| 33 | + sortProperty: 'name', | ||
| 34 | + sortOrder: 'ASC', | ||
| 28 | }, | 35 | }, | 
| 29 | - params: { serviceType: 'TB_RULE_ENGINE' }, | ||
| 30 | }; | 36 | }; | 
| 31 | }, | 37 | }, | 
| 32 | }, | 38 | }, | 
| 1 | import { ScriptFieldsEnum, ScriptFieldsNameEnum } from '../../../enum/formField/transformation'; | 1 | import { ScriptFieldsEnum, ScriptFieldsNameEnum } from '../../../enum/formField/transformation'; | 
| 2 | -import { JavascriptEditorWithTestModal } from '../../../src/components/JavaScriptFilterModal'; | 2 | +import { | 
| 3 | + JavascriptEditorWithTestModal, | ||
| 4 | + ScriptEditorValueType, | ||
| 5 | +} from '../../../src/components/JavaScriptFilterModal'; | ||
| 6 | +import { DefaultNodeConfig } from '../../../types/node'; | ||
| 3 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 7 | import { FormSchema, useComponentRegister } from '/@/components/Form'; | 
| 4 | import { useI18n } from '/@/hooks/web/useI18n'; | 8 | import { useI18n } from '/@/hooks/web/useI18n'; | 
| 5 | 9 | ||
| @@ -7,6 +11,12 @@ const { t } = useI18n(); | @@ -7,6 +11,12 @@ const { t } = useI18n(); | ||
| 7 | 11 | ||
| 8 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 12 | useComponentRegister('JavascriptEditorWithTestModal', JavascriptEditorWithTestModal); | 
| 9 | 13 | ||
| 14 | +export interface FormFieldsValue { | ||
| 15 | + [ScriptFieldsEnum.JS_SCRIPT]: ScriptEditorValueType; | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +export interface NodeConfigValue extends DefaultNodeConfig, ScriptEditorValueType {} | ||
| 19 | + | ||
| 10 | export const formSchemas: FormSchema[] = [ | 20 | export const formSchemas: FormSchema[] = [ | 
| 11 | { | 21 | { | 
| 12 | field: ScriptFieldsEnum.JS_SCRIPT, | 22 | field: ScriptFieldsEnum.JS_SCRIPT, | 
| 1 | <script lang="ts" setup> | 1 | <script lang="ts" setup> | 
| 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 2 | import type { CreateModalDefineExposeType } from '../../../types'; | 
| 3 | import { BasicForm, useForm } from '/@/components/Form'; | 3 | import { BasicForm, useForm } from '/@/components/Form'; | 
| 4 | - import { formSchemas } from './create.config'; | 4 | + import { FormFieldsValue, formSchemas, NodeConfigValue } from './create.config'; | 
| 5 | import { NodeData } from '../../../types/node'; | 5 | import { NodeData } from '../../../types/node'; | 
| 6 | - import { ScriptEditorValueType } from '/@/views/rule/designer/src/components/JavaScriptFilterModal'; | ||
| 7 | - import { ScriptFieldsEnum } from '../../../enum/formField/transformation'; | ||
| 8 | 6 | ||
| 9 | defineProps<{ | 7 | defineProps<{ | 
| 10 | config: NodeData; | 8 | config: NodeData; | 
| @@ -17,16 +15,25 @@ | @@ -17,16 +15,25 @@ | ||
| 17 | 15 | ||
| 18 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 16 | const getValue: CreateModalDefineExposeType['getFieldsValue'] = async () => { | 
| 19 | await validate(); | 17 | await validate(); | 
| 20 | - const value = getFieldsValue() || {}; | ||
| 21 | - const { scriptLang, jsScript, tbelScript } = (value || {})?.jsScript as ScriptEditorValueType; | ||
| 22 | - return { scriptLang, jsScript, tbelScript }; | 18 | + const value = (getFieldsValue() || {}) as FormFieldsValue; | 
| 19 | + const { jsScript, ...resetParams } = value; | ||
| 20 | + return { | ||
| 21 | + ...resetParams, | ||
| 22 | + ...jsScript, | ||
| 23 | + } as NodeConfigValue; | ||
| 23 | }; | 24 | }; | 
| 24 | 25 | ||
| 25 | - const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value) => { | 26 | + const setValue: CreateModalDefineExposeType['setFieldsValue'] = (value: NodeConfigValue) => { | 
| 26 | resetFields(); | 27 | resetFields(); | 
| 28 | + const { jsScript, tbelScript, scriptLang } = value; | ||
| 27 | setFieldsValue({ | 29 | setFieldsValue({ | 
| 28 | - [ScriptFieldsEnum.JS_SCRIPT]: value, | ||
| 29 | - }); | 30 | + ...value, | 
| 31 | + jsScript: { | ||
| 32 | + jsScript, | ||
| 33 | + tbelScript, | ||
| 34 | + scriptLang, | ||
| 35 | + }, | ||
| 36 | + } as FormFieldsValue); | ||
| 30 | }; | 37 | }; | 
| 31 | 38 | ||
| 32 | defineExpose({ | 39 | defineExpose({ | 
| @@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
| 58 | const getValue = computed<string>({ | 58 | const getValue = computed<string>({ | 
| 59 | get() { | 59 | get() { | 
| 60 | const { scriptLang, jsScript = '', tbelScript = '' } = props.value || {}; | 60 | const { scriptLang, jsScript = '', tbelScript = '' } = props.value || {}; | 
| 61 | - return scriptLang === ScriptLanguageEnum.JavaScript ? jsScript : tbelScript; | 61 | + return scriptLang === ScriptLanguageEnum.TBEL ? tbelScript : jsScript; | 
| 62 | }, | 62 | }, | 
| 63 | set(value) { | 63 | set(value) { | 
| 64 | const { jsScript, tbelScript } = props.value || {}; | 64 | const { jsScript, tbelScript } = props.value || {}; |