fix: bug#10922
This commit is contained in:
parent
1c0812f8d5
commit
dce719c9d3
|
@ -165,5 +165,6 @@ function syncTriggerClass(
|
|||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
word-break: break-all;
|
||||
white-space: normal;
|
||||
}
|
||||
</style>
|
|
@ -8,8 +8,8 @@ import { useSceneStore } from '@/store/scene';
|
|||
import { storeToRefs } from 'pinia';
|
||||
import { queryProductList } from '@/api/device/product'
|
||||
import { query as deviceQuery } from '@/api/device/instance'
|
||||
import { list as noticeConfigList } from '@/api/notice/config'
|
||||
import { list as noticeTemplateList } from '@/api/notice/template'
|
||||
import noticeConfig from '@/api/notice/config'
|
||||
import noticeTemplate from '@/api/notice/template'
|
||||
import { Form } from 'jetlinks-ui-components'
|
||||
const sceneStore = useSceneStore();
|
||||
const { data: _data } = storeToRefs(sceneStore);
|
||||
|
@ -72,13 +72,13 @@ const checkDeviceDelete = async () => {
|
|||
*/
|
||||
const checkNoticeDelete = async () => {
|
||||
const item = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].notify
|
||||
const configResp = await noticeConfigList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.notifierId }]}]})
|
||||
const configResp = await noticeConfig.list({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.notifierId }]}]})
|
||||
if (configResp.success && (configResp.result as any)?.total === 0) {
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].notify!.notifierId = ''
|
||||
formTouchOff()
|
||||
return
|
||||
}
|
||||
const templateResp = await noticeTemplateList({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.templateId }]}]})
|
||||
const templateResp = await noticeTemplate.list({ terms: [{ terms: [{ column: 'id', termType: 'eq', value: item!.templateId }]}]})
|
||||
if (templateResp.success && (templateResp.result as any)?.total === 0) {
|
||||
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name].notify!.templateId = ''
|
||||
formTouchOff()
|
||||
|
@ -88,9 +88,9 @@ const checkNoticeDelete = async () => {
|
|||
|
||||
nextTick(() => {
|
||||
const _executor = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.executor
|
||||
if (_executor === 'device') {
|
||||
if (_executor === 'device' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.device) {
|
||||
checkDeviceDelete()
|
||||
} else if (_executor === 'notify') {
|
||||
} else if (_executor === 'notify' && _data.value.branches![props.branchesName].then[props.thenName].actions[props.name]?.notify) {
|
||||
checkNoticeDelete
|
||||
}
|
||||
})
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
v-if='component === "select"'
|
||||
:value='selectValue'
|
||||
:options='options'
|
||||
:valueName='valueName'
|
||||
@click='menuSelect'
|
||||
/>
|
||||
<div style='min-width: 400px' v-else>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<template>
|
||||
<j-menu class='scene-dropdown-menus' @click='click' :selectedKeys='[myValue]'>
|
||||
<j-menu-item v-for='item in myOptions' :key='item.value' :title='item.label'>
|
||||
<Ellipsis >
|
||||
{{ item.label }}
|
||||
</Ellipsis>
|
||||
<div style='width: 280px' >
|
||||
<Ellipsis >
|
||||
{{ item.label }}
|
||||
</Ellipsis>
|
||||
</div>
|
||||
</j-menu-item>
|
||||
</j-menu>
|
||||
</template>
|
||||
|
@ -26,6 +28,10 @@ const props = defineProps({
|
|||
options: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
valueName: {
|
||||
type: String,
|
||||
default: 'value'
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -55,7 +61,7 @@ const handleBoolean = (key: string) => {
|
|||
|
||||
const click = (e: any) => {
|
||||
const _key = ['true', 'false'].includes(e.key) ? handleBoolean(e.key) : e.key
|
||||
const option = getOption(myOptions.value, _key)
|
||||
const option = getOption(myOptions.value, _key, props.valueName)
|
||||
myValue.value = _key
|
||||
emit('update:value', _key)
|
||||
emit('click', _key, {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { isEqual } from 'lodash-es'
|
||||
|
||||
export type DropdownButtonOptions = {
|
||||
label: string;
|
||||
value: string;
|
||||
|
@ -34,7 +36,7 @@ export const getOption = (data: any[], value?: string | number | boolean, key: s
|
|||
if (value === undefined && value === null) return option
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const item = data[i]
|
||||
if (item[key] === value) {
|
||||
if (isEqual(item[key], value)) {
|
||||
option = data[i]
|
||||
break
|
||||
} else if (item.children && item.children.length) {
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
<DropdownMenus
|
||||
v-if='(["metric", "upper"].includes(item.key) ? metricOptions : options).length'
|
||||
:options='["metric", "upper"].includes(item.key) ? metricOptions : options'
|
||||
:valueName='valueName'
|
||||
@click='onSelect'
|
||||
/>
|
||||
<div class='scene-select-empty' v-else>
|
||||
|
@ -84,6 +85,7 @@ import type { ValueType } from './typings'
|
|||
import { defaultSetting } from './typings'
|
||||
import { DropdownMenus, DropdownTimePicker} from '../DropdownButton'
|
||||
import { getOption } from '../DropdownButton/util'
|
||||
import { isArray } from 'lodash-es'
|
||||
|
||||
type Emit = {
|
||||
(e: 'update:value', data: ValueType): void
|
||||
|
@ -120,7 +122,7 @@ const tabsChange = (e: string) => {
|
|||
const treeSelect = (v: any, option: any) => {
|
||||
const node = option.node
|
||||
visible.value = false
|
||||
label.value = node.fullname || node.name
|
||||
label.value = node[props.labelName] || node.name
|
||||
emit('update:value', node[props.valueName])
|
||||
emit('select', node, label.value, { 0: label.value })
|
||||
}
|
||||
|
@ -133,7 +135,7 @@ const valueItemChange = (e: string) => {
|
|||
|
||||
const onSelect = (e: string, option: any) => {
|
||||
visible.value = false
|
||||
label.value = option.label
|
||||
label.value = option[props.labelName]
|
||||
emit('update:value', e)
|
||||
emit('select', e, label.value, { 0: label.value })
|
||||
}
|
||||
|
@ -150,14 +152,18 @@ const visibleChange = (v: boolean) => {
|
|||
}
|
||||
|
||||
watchEffect(() => {
|
||||
const _options = props.source === 'upper' ? props.metricOptions : props.options
|
||||
const _options = ['metric', 'upper'].includes(props.source) ? props.metricOptions : props.options
|
||||
const option = getOption(_options, props.value as string, props.valueName) // 回显label值
|
||||
myValue.value = props.value
|
||||
mySource.value = props.source
|
||||
if (option) {
|
||||
label.value = option[props.labelName] || option.name
|
||||
} else {
|
||||
label.value = props.value || props.placeholder
|
||||
let doubleNull = false
|
||||
if (isArray(props.value)) {
|
||||
doubleNull = !!props.value.filter(item => !!item).length
|
||||
}
|
||||
label.value = props.value && !doubleNull ? props.value : props.placeholder
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -154,14 +154,16 @@ const columnOptions: any = inject(ContextKey) //
|
|||
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // 条件值
|
||||
const valueOptions = ref<any[]>([]) // 默认手动输入下拉
|
||||
const metricOption = ref<any[]>([]) // 根据termType获取对应指标值
|
||||
const isMetric = ref<boolean>(false) // 是否为指标值
|
||||
const tabsOptions = ref<Array<TabsOption>>([{ label: '手动输入', key: 'manual', component: 'string' }])
|
||||
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin']
|
||||
let metricsCacheOption: any[] = [] // 缓存指标值
|
||||
const metricsCacheOption = ref<any[]>([]) // 缓存指标值
|
||||
|
||||
const handOptionByColumn = (option: any) => {
|
||||
if (option) {
|
||||
console.log(option)
|
||||
termTypeOptions.value = option.termTypes || []
|
||||
metricsCacheOption = option.metrics || []
|
||||
metricsCacheOption.value = option.metrics.map((item: any) => ({...item, label: item.name})) || []
|
||||
tabsOptions.value.length = 1
|
||||
tabsOptions.value[0].component = option.dataType
|
||||
|
||||
|
@ -169,6 +171,9 @@ const handOptionByColumn = (option: any) => {
|
|||
tabsOptions.value.push(
|
||||
{ label: '指标值', key: 'metric', component: 'select' }
|
||||
)
|
||||
isMetric.value = true
|
||||
} else {
|
||||
isMetric.value = false
|
||||
}
|
||||
|
||||
if (option.dataType === 'boolean') {
|
||||
|
@ -183,7 +188,7 @@ const handOptionByColumn = (option: any) => {
|
|||
}
|
||||
} else {
|
||||
termTypeOptions.value = []
|
||||
metricsCacheOption = []
|
||||
metricsCacheOption.value = []
|
||||
valueOptions.value = []
|
||||
}
|
||||
}
|
||||
|
@ -212,12 +217,12 @@ watch(() => [columnOptions.value, paramsValue.column], () => {
|
|||
|
||||
const showDouble = computed(() => {
|
||||
const isRange = paramsValue.termType ? arrayParamsKey.includes(paramsValue.termType) : false
|
||||
if (metricsCacheOption.length) {
|
||||
metricOption.value = metricsCacheOption.filter(item => isRange ? item.range : !item.range)
|
||||
if (metricsCacheOption.value.length) {
|
||||
metricOption.value = metricsCacheOption.value.filter(item => isRange ? item.range : !item.range)
|
||||
} else {
|
||||
metricOption.value = []
|
||||
}
|
||||
return isRange
|
||||
return isRange && !isMetric
|
||||
})
|
||||
|
||||
const mouseover = () => {
|
||||
|
@ -244,7 +249,6 @@ const columnSelect = (option: any) => {
|
|||
formItemContext.onFieldChange()
|
||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][0] = option.name
|
||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][1] = paramsValue.termType
|
||||
|
||||
}
|
||||
|
||||
const termsTypeSelect = (e: { key: string, name: string }) => {
|
||||
|
@ -261,6 +265,7 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
|
|||
|
||||
const valueSelect = (_: any, label: string, labelObj: Record<number, any>) => {
|
||||
emit('update:value', { ...paramsValue })
|
||||
console.log(labelObj)
|
||||
formItemContext.onFieldChange()
|
||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][2] = labelObj
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue