update: 优化场景联动样式
This commit is contained in:
parent
995eca23cb
commit
a2a52aaf66
|
@ -1,13 +1,15 @@
|
|||
<template>
|
||||
<j-form-item
|
||||
:rules="actionRules"
|
||||
:name="['branches', 0, 'then']"
|
||||
>
|
||||
<Action
|
||||
:thenOptions="data.branches ? data?.branches[0].then : []"
|
||||
:name="0"
|
||||
/>
|
||||
</j-form-item>
|
||||
<div class='actions-branches-item'>
|
||||
<j-form-item
|
||||
:rules="actionRules"
|
||||
:name="['branches', 0, 'then']"
|
||||
>
|
||||
<Action
|
||||
:thenOptions="data.branches ? data?.branches[0].then : []"
|
||||
:name="0"
|
||||
/>
|
||||
</j-form-item>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name='SceneSaveManual'>
|
||||
|
@ -21,7 +23,6 @@ const { data } = storeToRefs(sceneStore);
|
|||
|
||||
const actionRules = [{
|
||||
validator(_: any, v?: BranchesThen[]) {
|
||||
console.log(_, v)
|
||||
if (!v || (v && !v.length) || (v && v.length && !v[0].actions.length)) {
|
||||
return Promise.reject('至少配置一个执行动作');
|
||||
}
|
||||
|
|
|
@ -14,15 +14,17 @@
|
|||
<Title :options='data.options.trigger' />
|
||||
</AddButton>
|
||||
</j-form-item>
|
||||
<j-form-item
|
||||
:rules="actionRules"
|
||||
:name="['branches', 0, 'then']"
|
||||
>
|
||||
<Action
|
||||
<div class='actions-branches-item' >
|
||||
<j-form-item
|
||||
:rules="actionRules"
|
||||
:name="['branches', 0, 'then']"
|
||||
>
|
||||
<Action
|
||||
:thenOptions="data.branches ? data?.branches[0].then : []"
|
||||
:name="0"
|
||||
/>
|
||||
</j-form-item>
|
||||
/>
|
||||
</j-form-item>
|
||||
</div>
|
||||
<AddModel
|
||||
v-if="visible"
|
||||
@cancel='visible = false'
|
||||
|
|
|
@ -32,6 +32,18 @@
|
|||
</div>
|
||||
</template>
|
||||
</template>
|
||||
<div v-else class='actions-branches-item'>
|
||||
<j-form-item
|
||||
:name='["branches", 0, "then"]'
|
||||
:rules='thenRules'
|
||||
>
|
||||
<Action
|
||||
:name='0'
|
||||
:openShakeLimit="true"
|
||||
:thenOptions='data.branches[0]?.then'
|
||||
/>
|
||||
</j-form-item>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -40,10 +52,11 @@ import { storeToRefs } from 'pinia';
|
|||
import { useSceneStore } from 'store/scene'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { provide } from 'vue'
|
||||
import { ContextKey, handleParamsData } from './util'
|
||||
import { ContextKey, handleParamsData, thenRules } from './util'
|
||||
import { getParseTerm } from '@/api/rule-engine/scene'
|
||||
import type { FormModelType } from '@/views/rule-engine/Scene/typings'
|
||||
import Branches from './Branches.vue'
|
||||
import Action from '../../action/index.vue'
|
||||
|
||||
const sceneStore = useSceneStore()
|
||||
const { data } = storeToRefs(sceneStore)
|
||||
|
@ -55,6 +68,11 @@ provide(ContextKey, columnOptions)
|
|||
|
||||
const change = (e: boolean) => {
|
||||
open.value = e
|
||||
if (!e) {
|
||||
data.value.branches!.length = 1
|
||||
} else {
|
||||
data.value.branches!.push(null as any)
|
||||
}
|
||||
}
|
||||
|
||||
const queryColumn = (dataModel: FormModelType) => {
|
||||
|
|
|
@ -106,6 +106,10 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.actions-branches-item {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.terms-params {
|
||||
|
@ -224,6 +228,9 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
.actions-branches-item {
|
||||
width: 75%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,4 +9,16 @@ export const handleParamsData = (data: any[], key: string = 'column'): any[] =>
|
|||
children: handleParamsData(item.children, key)
|
||||
}
|
||||
}) || []
|
||||
}
|
||||
}
|
||||
|
||||
export const thenRules = [{
|
||||
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();
|
||||
}
|
||||
}]
|
Loading…
Reference in New Issue