From d9ac1d456cf0cf7c75621c7a60c863d1f39a3b9c Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Mon, 8 May 2023 18:01:19 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E5=9C=BA=E6=99=AF?= =?UTF-8?q?=E8=81=94=E5=8A=A8-=E6=89=A7=E8=A1=8C=E5=8A=A8=E4=BD=9C?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scene/Save/action/ListItem/CheckItem.vue | 41 +++++-------------- src/views/rule-engine/Scene/Save/util.ts | 2 +- vite.config.ts | 2 +- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/views/rule-engine/Scene/Save/action/ListItem/CheckItem.vue b/src/views/rule-engine/Scene/Save/action/ListItem/CheckItem.vue index 981c7909..0c4d836d 100644 --- a/src/views/rule-engine/Scene/Save/action/ListItem/CheckItem.vue +++ b/src/views/rule-engine/Scene/Save/action/ListItem/CheckItem.vue @@ -36,11 +36,11 @@ const sub = ref() const rules = [{ validator(_: any, v?: ActionsType) { - console.log('validator',v) if (v?.executor === 'device') { if( !v.device?.productId || // 产品已删除 - !v.device?.selectorValues // 设备已删除 + !v.device?.selectorValues || // 设备已删除 + (v.device.source === 'upper' && !v.device?.upperKey) ) { return Promise.reject(new Error('该数据已发生变更,请重新配置')) } @@ -73,14 +73,16 @@ const checkDeviceDelete = async () => { return } } - + console.log(item!.source, props.name) if (item!.source === 'upper') { // 如果是按变量,校验上一个设备输出的产品id if (props.name === 0) { + _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.upperKey = undefined formTouchOff() return } else { const prevItem = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name - 1].device if (prevItem?.productId !== item?.productId) { + _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].device!.upperKey = undefined formTouchOff() return } @@ -116,41 +118,18 @@ const check = () => { } } -const checkPrevData = (data: any) => { - console.log(data) - const _executor = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor - if (_executor === 'device' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.device) { // 设备输出,并且有值 - // 校验内置参数 - // 按变量时,需校验产品id是否一致 - - } else if (_executor === 'notify' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.notify) { - // 校验内置参数 - } -} - -const subscribe = (newName: number, oldName: number) => { +const subscribe = () => { + // 订阅上一个action const _key = EventSubscribeKeys({ branch: props.branchesName, branchGroup: props.thenName, - action: props.name - 1 + action: props.name }) - if (sub.value) { - const oldKey = EventSubscribeKeys({ - branch: props.branchesName, - branchGroup: props.thenName, - action: oldName - 1 - }) - - sub.value.unSubscribe(oldKey, checkPrevData) - } - - sub.value = EventEmitter.subscribe(_key, checkPrevData) + sub.value = EventEmitter.subscribe(_key, check) } -watch(() => props.name, (newName, oldName) => { - // subscribe(newName, oldName || 0) -}, { immediate: true }) +subscribe() check() diff --git a/src/views/rule-engine/Scene/Save/util.ts b/src/views/rule-engine/Scene/Save/util.ts index c35fb190..e213d944 100644 --- a/src/views/rule-engine/Scene/Save/util.ts +++ b/src/views/rule-engine/Scene/Save/util.ts @@ -76,7 +76,7 @@ export const EventSubscribeKeys = (params: Params): string[] => { keys.push(DeviceEmitterKey) } - for (let i = 0; i <= params.action; i++) { + for (let i = 0; i <= params.action - 1; i++) { let key = sceneStore.data.branches?.[params.branch].then[params.branchGroup].actions[i]?.key if (!key) { const _b = `branches_${params.branch}` // branchesName diff --git a/vite.config.ts b/vite.config.ts index 8aae6161..4f292d21 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -92,7 +92,7 @@ export default defineConfig(({ mode}) => { proxy: { [env.VITE_APP_BASE_API]: { - // target: 'http://192.168.32.70:8844', + // target: 'http://192.168.32.226:8844', // target: 'http://192.168.32.244:8881', target: 'http://120.77.179.54:8844', // 120测试 // target: 'http://192.168.33.46:8844', // 本地开发环境