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
const _options = handleOptions(typeData.data);
const data = {
operator: typeData.data,
operation: typeData.data,
selector: addModel.selector,
selectorValues: addModel.selectorValues,
productId: addModel.productId

View File

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

View File

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

View File

@ -234,7 +234,7 @@
@click="onType('device')"
>
<template v-if="data?.device?.selector === 'fixed'">
<div>
<div style='display: flex; align-items: center;'>
<AIcon
:type="
typeIconMap[
@ -248,13 +248,16 @@
}}</span>
<AIcon
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(
data?.options?.propertiesValue,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -93,10 +93,10 @@ export default defineConfig(({ mode}) => {
// target: 'http://192.168.33.22:8800',
// target: 'http://192.168.32.244:8881',
// 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://120.77.179.54:8844',
ws: 'ws://192.168.33.46:8844',
ws: 'ws://120.77.179.54:8844',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '')
}

View File

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