fix: 优化场景联动-执行动作删除校验
This commit is contained in:
parent
07c249fdf4
commit
d9ac1d456c
|
@ -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()
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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', // 本地开发环境
|
||||
|
|
Loading…
Reference in New Issue