fix: bug#15718

This commit is contained in:
XieYongHong 2023-07-11 11:10:09 +08:00
parent 035d311e07
commit 87709f67bb
2 changed files with 15 additions and 16 deletions

View File

@ -555,7 +555,6 @@ const onPropsCancel = () => {
const rules = [{
validator(_: any, v?: ActionsType) {
console.log('validator-action-item',v)
if (v?.executor === 'device') {
const _device = v.device!
if (

View File

@ -77,12 +77,13 @@ import type { TermsType } from '@/views/rule-engine/Scene/typings'
import DropdownButton from '../DropdownButton'
import { getOption } from '../DropdownButton/util'
import ParamsDropdown, { DoubleParamsDropdown } from '../ParamsDropdown'
import { inject } from 'vue'
import {inject, watch} from 'vue'
import { ContextKey, arrayParamsKey, timeTypeKeys } from './util'
import { useSceneStore } from 'store/scene'
import { storeToRefs } from 'pinia';
import { Form } from 'jetlinks-ui-components'
import { isArray, isObject, pick } from 'lodash-es'
import {cloneDeep} from "lodash";
const sceneStore = useSceneStore()
const { data: formModel } = storeToRefs(sceneStore)
@ -205,27 +206,25 @@ const handOptionByColumn = (option: any) => {
}
}
watch(() => [columnOptions.value, paramsValue.column], () => {
watch(() => JSON.stringify(columnOptions.value), () => {
if (paramsValue.column) {
const option = getOption(columnOptions.value, paramsValue.column, 'column')
const copyValue = props.value
if (option && Object.keys(option).length) {
handOptionByColumn(option)
if (props.value.error) {
emit('update:value', {
...props.value,
error: false
})
if (copyValue.error) {
copyValue.error = false
emit('update:value', copyValue)
formItemContext.onFieldChange()
}
} else {
emit('update:value', {
...props.value,
error: true
})
copyValue.error = true
emit('update:value', copyValue)
formItemContext.onFieldChange()
}
}
}, { immediate: true, deep: true })
}, { immediate: true })
const showDouble = computed(() => {
const isRange = paramsValue.termType ? arrayParamsKey.includes(paramsValue.termType) : false
@ -263,11 +262,11 @@ const columnSelect = (option: any) => {
let termTypeChange = false
//
const termTypes = option.termTypes
if (!termTypes.some((item: {id: string}) => paramsValue.termType === item.id)) { //
termTypeChange = true
paramsValue.termType = termTypes?.length ? termTypes[0].id : 'eq'
}
if (hasTypeChange) { //
paramsValue.termType = termTypes?.length ? termTypes[0].id : 'eq'
paramsValue.value = {
@ -292,7 +291,9 @@ const columnSelect = (option: any) => {
}
handOptionByColumn(option)
emit('update:value', { ...paramsValue })
nextTick(() => {
formItemContext.onFieldChange()
})
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][0] = option.name
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][1] = paramsValue.termType
}
@ -339,7 +340,6 @@ const valueSelect = (v: any, label: string, labelObj: Record<number, any>, optio
if (paramsValue.value?.source !== 'metric') {
delete newValues.value.metric
}
emit('update:value', { ...newValues })
formItemContext.onFieldChange()
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][2] = labelObj