update: 场景联动集成执行动作

This commit is contained in:
xieyonghong 2023-03-15 11:40:20 +08:00
parent c830357640
commit 2f964837b9
3 changed files with 30 additions and 21 deletions

View File

@ -15,7 +15,6 @@
</AddButton>
</a-form-item>
<Terms />
<Action />
<AddModel v-if='visible' @cancel='visible = false' @save='save' :value='data.trigger.device' :options='data.options.trigger' />
</div>
</template>

View File

@ -49,9 +49,16 @@
</div>
</div>
<div class='actions-branches'>
<j-form-item></j-form-item>
<j-form-item
:name='["branches", name, "then"]'
:rules='rules'
>
<Action
:openShakeLimit="true"
:thenOptions='FormModel.branches[name].then'
/>
</j-form-item>
</div>
</div>
</div>
</template>
@ -62,6 +69,7 @@ import type { ActionBranchesProps } from '@/views/rule-engine/Scene/typings'
import TermsItem from './TermsItem.vue'
import { storeToRefs } from 'pinia';
import { useSceneStore } from 'store/scene'
import Action from '../../action/index.vue'
const sceneStore = useSceneStore()
const { data: FormModel } = storeToRefs(sceneStore)
@ -149,6 +157,18 @@ const optionsClass = computed(() => {
}
})
const rules = [{
validator(_: string, value: any) {
if (!value || (value && !value.length)) {
return Promise.reject('至少配置一个执行动作')
} else {
const isActions = value.some((item: any) => item.actions && item.actions.length)
return isActions ? Promise.resolve() : Promise.reject('至少配置一个执行动作');
}
return Promise.resolve();
}
}]
</script>
<style scoped lang='less'>

View File

@ -32,13 +32,13 @@
</div>
</template>
</template>
<j-form-item
v-else
:name='["branches", 0, "then"]'
:rules='rules'
>
</j-form-item>
<!-- <j-form-item-->
<!-- v-else-->
<!-- :name='["branches", 0, "then"]'-->
<!-- :rules='rules'-->
<!-- >-->
<!-- -->
<!-- </j-form-item>-->
</div>
</template>
@ -65,17 +65,7 @@ const change = (e: boolean) => {
open.value = e
}
const rules = [{
validator(_: string, value: any) {
if (!value || (value && !value.length)) {
return Promise.reject('至少配置一个执行动作')
} else {
const isActions = value.some((item: any) => item.actions && item.actions.length)
return isActions ? Promise.resolve() : Promise.reject('至少配置一个执行动作');
}
return Promise.resolve();
}
}]
const handleParamsData = (data: any[]): any[] => {
return data?.map(item => {