update: 优化场景联动-执行动作、过滤条件校验

This commit is contained in:
xieyonghong 2023-03-20 20:17:05 +08:00
parent d5876a0ed1
commit 8811173b66
12 changed files with 57 additions and 31 deletions

View File

@ -240,7 +240,7 @@ const save = async (step?: number) => {
optionsCache.value.action = typeData.action optionsCache.value.action = typeData.action
const _options = handleOptions(typeData.data); const _options = handleOptions(typeData.data);
const data = { const data = {
operator: typeData.data, operation: typeData.data,
selector: addModel.selector, selector: addModel.selector,
selectorValues: addModel.selectorValues, selectorValues: addModel.selectorValues,
productId: addModel.productId productId: addModel.productId

View File

@ -83,6 +83,7 @@ import { inject } from 'vue'
import { useSceneStore } from 'store/scene' import { useSceneStore } from 'store/scene'
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { flattenDeep, set } from 'lodash-es' import { flattenDeep, set } from 'lodash-es'
import { Form } from 'jetlinks-ui-components'
const sceneStore = useSceneStore() const sceneStore = useSceneStore()
const { data: formModel } = storeToRefs(sceneStore) const { data: formModel } = storeToRefs(sceneStore)
@ -152,7 +153,7 @@ const paramsValue = reactive<TermsType>({
termType: props.value.termType, termType: props.value.termType,
value: props.value.value value: props.value.value
}) })
const formItemContext = Form.useInjectFormItemContext()
const showDelete = ref(false) const showDelete = ref(false)
const columnOptions: any = inject('filter-params') // const columnOptions: any = inject('filter-params') //
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) //
@ -187,8 +188,18 @@ const handOptionByColumn = (option: any) => {
} }
watchEffect(() => { watchEffect(() => {
if (!props.value.error && props.value.column) { // option
const option = getOption(columnOptions.value, paramsValue.column, 'id') const option = getOption(columnOptions.value, paramsValue.column, 'id')
if (option) {
handOptionByColumn(option) handOptionByColumn(option)
} else {
emit('update:value', {
...props.value,
error: true
})
formItemContext.onFieldChange()
}
}
}) })
const showDouble = computed(() => { const showDouble = computed(() => {
@ -235,6 +246,7 @@ const columnSelect = (e: any) => {
) )
handleOptionsColumnsValue(termsColumns, _options) handleOptionsColumnsValue(termsColumns, _options)
emit('update:value', { ...paramsValue }) emit('update:value', { ...paramsValue })
formItemContext.onFieldChange()
} }
const termsTypeSelect = (e: { key: string }) => { const termsTypeSelect = (e: { key: string }) => {
@ -244,10 +256,12 @@ const termsTypeSelect = (e: { key: string }) => {
value: value value: value
} }
emit('update:value', { ...paramsValue }) emit('update:value', { ...paramsValue })
formItemContext.onFieldChange()
} }
const valueSelect = () => { const valueSelect = () => {
emit('update:value', { ...paramsValue }) emit('update:value', { ...paramsValue })
formItemContext.onFieldChange()
} }
const termAdd = () => { const termAdd = () => {

View File

@ -58,7 +58,7 @@ import { storeToRefs } from 'pinia'
import { useSceneStore } from 'store/scene' import { useSceneStore } from 'store/scene'
import DropdownButton from '../../components/DropdownButton' import DropdownButton from '../../components/DropdownButton'
import FilterItem from './FilterCondition.vue' import FilterItem from './FilterCondition.vue'
import { flattenDeep, isArray, set } from 'lodash-es' import { flattenDeep, isArray } from 'lodash-es'
import { provide } from 'vue' import { provide } from 'vue'
import { randomString } from '@/utils/utils' import { randomString } from '@/utils/utils'
import { useParams } from '@/views/rule-engine/Scene/Save/util' import { useParams } from '@/views/rule-engine/Scene/Save/util'
@ -172,7 +172,7 @@ const onDelete = () => {
const rules = [ const rules = [
{ {
validator(_: any, v?: Record<string, any>) { validator(_: any, v?: Record<string, any>) {
if (v !== undefined) { if (v !== undefined && !v.error) {
if (!Object.keys(v).length) { if (!Object.keys(v).length) {
return Promise.reject(new Error('该数据已发生变更,请重新配置')) return Promise.reject(new Error('该数据已发生变更,请重新配置'))
} }

View File

@ -234,7 +234,7 @@
@click="onType('device')" @click="onType('device')"
> >
<template v-if="data?.device?.selector === 'fixed'"> <template v-if="data?.device?.selector === 'fixed'">
<div> <div style='display: flex; align-items: center;'>
<AIcon <AIcon
:type=" :type="
typeIconMap[ typeIconMap[
@ -248,13 +248,16 @@
}}</span> }}</span>
<AIcon <AIcon
type="icon-mubiao" type="icon-mubiao"
style="padding-right: 2px" style="padding:0 4px"
/> />
<Ellipsis style='max-width: 200px;margin-right: 12px;'>
{{data?.options?.name}}
</Ellipsis>
<Ellipsis style='max-width: 400px;'>
{{data?.options?.properties}}
</Ellipsis>
{{ {{
`${data?.options?.name} ${ `${
data?.options?.properties
}
${
( (
isBoolean( isBoolean(
data?.options?.propertiesValue, data?.options?.propertiesValue,

View File

@ -9,7 +9,9 @@
<slot :label='label'> <slot :label='label'>
<div :class='dropdownButtonClass' > <div :class='dropdownButtonClass' >
<AIcon v-if='!!icon' :type='icon' /> <AIcon v-if='!!icon' :type='icon' />
<Ellipsis style='max-width: 220px;'>
{{ label }} {{ label }}
</Ellipsis>
</div> </div>
</slot> </slot>
</div> </div>

View File

@ -9,7 +9,9 @@
<slot :label='label'> <slot :label='label'>
<div class='dropdown-button value'> <div class='dropdown-button value'>
<AIcon v-if='!!icon' :type='icon' /> <AIcon v-if='!!icon' :type='icon' />
<Ellipsis style='max-width: 220px;'>
{{ label }} {{ label }}
</Ellipsis>
</div> </div>
</slot> </slot>
</div> </div>

View File

@ -141,10 +141,10 @@ const props = defineProps({
const emit = defineEmits<Emit>() const emit = defineEmits<Emit>()
const paramsValue = reactive<TermsType>({ const paramsValue = reactive<TermsType>({
column: props.value.column, column: props.value?.column,
type: props.value.type, type: props.value?.type,
termType: props.value.termType, termType: props.value?.termType,
value: props.value.value value: props.value?.value
}) })
const showDelete = ref(false) const showDelete = ref(false)
@ -187,8 +187,18 @@ const handOptionByColumn = (option: any) => {
} }
watchEffect(() => { watchEffect(() => {
if (!props.value.error && props.value.column) { // option
const option = getOption(columnOptions.value, paramsValue.column, 'column') const option = getOption(columnOptions.value, paramsValue.column, 'column')
if (option) {
handOptionByColumn(option) handOptionByColumn(option)
} else {
emit('update:value', {
...props.value,
error: true
})
formItemContext.onFieldChange()
}
}
}) })
const showDouble = computed(() => { const showDouble = computed(() => {
@ -257,7 +267,6 @@ const onDelete = () => {
nextTick(() => { nextTick(() => {
Object.assign(paramsValue, props.value) Object.assign(paramsValue, props.value)
formItemContext.onFieldChange()
}) })
</script> </script>

View File

@ -96,7 +96,7 @@ const branchesDeleteAll = () => {
watchEffect(() => { watchEffect(() => {
if (data.value.trigger?.device) { if (data.value.trigger?.device) {
queryColumn(data.value) queryColumn({ trigger: data.value.trigger })
} }
}) })

View File

@ -40,7 +40,6 @@
:termsName='name' :termsName='name'
:whenName='whenName' :whenName='whenName'
:branchName='branchName' :branchName='branchName'
@change='paramsChange'
/> />
</j-form-item> </j-form-item>
</div> </div>
@ -108,7 +107,7 @@ const props = defineProps({
const rules = [ const rules = [
{ {
validator(_: any, v: any) { validator(_: any, v: any) {
if (v !== undefined) { if (v !== undefined && !v.error) {
if (!Object.keys(v).length) { if (!Object.keys(v).length) {
return Promise.reject(new Error('该数据已发生变更,请重新配置')); return Promise.reject(new Error('该数据已发生变更,请重新配置'));
} }
@ -162,10 +161,6 @@ const onDelete = () => {
formModel.value.branches?.[props.branchName]?.when?.splice(props.name, 1) formModel.value.branches?.[props.branchName]?.when?.splice(props.name, 1)
} }
const paramsChange = () => {
}
const addTerms = () => { const addTerms = () => {
const terms = { const terms = {
type: 'and', type: 'and',

View File

@ -202,6 +202,7 @@ export type TermsType = {
options?: any[]; options?: any[];
terms?: TermsType[]; terms?: TermsType[];
key?: string; key?: string;
error?: boolean
}; };
export type PlatformRelation = { export type PlatformRelation = {

View File

@ -93,10 +93,10 @@ export default defineConfig(({ mode}) => {
// target: 'http://192.168.33.22:8800', // target: 'http://192.168.33.22:8800',
// target: 'http://192.168.32.244:8881', // target: 'http://192.168.32.244:8881',
// target: 'http://47.112.135.104:5096', // opcua // target: 'http://47.112.135.104:5096', // opcua
target: 'http://192.168.33.46:8844', // 120测试 target: 'http://120.77.179.54:8844', // 120测试
// target: 'http://47.108.63.174:8845', // 测试 // target: 'http://47.108.63.174:8845', // 测试
// target: 'http://120.77.179.54:8844', // target: 'http://120.77.179.54:8844',
ws: 'ws://192.168.33.46:8844', ws: 'ws://120.77.179.54:8844',
changeOrigin: true, changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '') rewrite: (path) => path.replace(/^\/api/, '')
} }

View File

@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3:
jetlinks-ui-components@^1.0.5: jetlinks-ui-components@^1.0.5:
version "1.0.5" version "1.0.5"
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#682711e0f69c141fff2c256db61a060c82539611" resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#1059095549559c679f9197df360e3ee2360eff44"
integrity sha512-rQxD/YlE+XSAG7BWIcFTtKrCQJXk5o+TUgejyuUT/baBThJB6xYt1k2dQEdXyiwpukYen5FzaoLpelSD9SUegw== integrity sha512-aK2ym5HF6DBsEnvrILGkzRkdPC+QSjrft3xK2DrDRqU5lZq0uqS55ksk88GoaFzGSgqznK+PPWZaYc0Lo2WH/A==
dependencies: dependencies:
"@vueuse/core" "^9.12.0" "@vueuse/core" "^9.12.0"
ant-design-vue "^3.2.15" ant-design-vue "^3.2.15"