fix: bug#10782
This commit is contained in:
parent
cb035bce38
commit
96c6b69aef
|
@ -109,3 +109,28 @@ export const onlyMessage = (msg: string, type: 'success' | 'error' | 'warning' =
|
|||
key: type
|
||||
})
|
||||
}
|
||||
|
||||
export interface SearchItemData {
|
||||
column: any;
|
||||
value: any;
|
||||
termType: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
export const handleParamsToString = (terms:SearchItemData[] = []) => {
|
||||
const _terms: any[] = [
|
||||
{ terms: [null,null,null]},
|
||||
{ terms: [null,null,null]}
|
||||
]
|
||||
let termsIndex = 0
|
||||
let termsStar = 0
|
||||
terms.forEach((item, index) => {
|
||||
if (index > 2) {
|
||||
termsIndex = 1
|
||||
termsStar = 4
|
||||
}
|
||||
_terms[termsIndex].terms[index - termsStar ] = item
|
||||
})
|
||||
|
||||
return JSON.stringify({ terms: _terms})
|
||||
}
|
|
@ -118,6 +118,16 @@ export const postStream = function(url: string, data={}, params = {}) {
|
|||
})
|
||||
}
|
||||
|
||||
const showNotification = ( message: string, description: string, key?: string, show: boolean = true ) => {
|
||||
if (show) {
|
||||
Notification.error({
|
||||
key,
|
||||
message,
|
||||
description
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 异常拦截处理器
|
||||
* @param {Object} error
|
||||
|
@ -128,44 +138,19 @@ const errorHandler = (error: any) => {
|
|||
const data = error.response.data
|
||||
const status = error.response.status
|
||||
if (status === 403) {
|
||||
Notification.error({
|
||||
key: '403',
|
||||
message: 'Forbidden',
|
||||
description: (data.message + '').substr(0, 90)
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
name: 'Exception403'
|
||||
})
|
||||
}, 0)
|
||||
showNotification( 'Forbidden', (data.message + '').substr(0, 90), '403')
|
||||
} else if (status === 500) {
|
||||
Notification.error({
|
||||
key: '500',
|
||||
message: 'Server Side Error',
|
||||
description: (data.message + '').substr(0, 90)
|
||||
})
|
||||
showNotification( 'Server Side Error', (data.message + '').substr(0, 90), '500')
|
||||
} else if (status === 400) {
|
||||
Notification.error({
|
||||
key: '400',
|
||||
message: 'Request Error',
|
||||
description: (data.message + '').substr(0, 90)
|
||||
})
|
||||
showNotification( 'Request Error', (data.message + '').substr(0, 90), '400')
|
||||
} else if (status === 401) {
|
||||
Notification.error({
|
||||
key: '401',
|
||||
message: 'Unauthorized',
|
||||
description: '用户未登录'
|
||||
})
|
||||
showNotification( 'Unauthorized', '用户未登录', '401')
|
||||
setTimeout(() => {
|
||||
location.href = `/#${LoginPath}`
|
||||
}, 0)
|
||||
}
|
||||
} else if (error.response === undefined) {
|
||||
Notification.error({
|
||||
message: error.message,
|
||||
description: (error.stack + '').substr(0, 90)
|
||||
})
|
||||
showNotification( error.message, (error.stack + '').substr(0, 90), undefined)
|
||||
}
|
||||
return Promise.reject(error)
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ import {
|
|||
getProtocolDetail,
|
||||
} from '@/api/device/product';
|
||||
import { message } from 'jetlinks-ui-components';
|
||||
import { getImage } from '@/utils/comm';
|
||||
import { getImage, handleParamsToString } from '@/utils/comm'
|
||||
import encodeQuery from '@/utils/encodeQuery';
|
||||
import { useMenuStore } from '@/store/menu';
|
||||
|
||||
|
@ -286,7 +286,7 @@ const jumpDevice = () => {
|
|||
{},
|
||||
{
|
||||
target: 'device-instance',
|
||||
q: JSON.stringify({ terms: [{ terms: [{ searchParams }] }] }),
|
||||
q: handleParamsToString([searchParams]),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
|
|
@ -188,11 +188,18 @@ const handOptionByColumn = (option: any) => {
|
|||
}
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
if (!props.value.error && props.value.column) { // 新增不查找option
|
||||
watch(() => [columnOptions.value, paramsValue.column], () => {
|
||||
if (paramsValue.column) {
|
||||
const option = getOption(columnOptions.value, paramsValue.column, 'id')
|
||||
if (option) {
|
||||
if (option && Object.keys(option).length) {
|
||||
handOptionByColumn(option)
|
||||
if (props.value.error) {
|
||||
emit('update:value', {
|
||||
...props.value,
|
||||
error: false
|
||||
})
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
} else {
|
||||
emit('update:value', {
|
||||
...props.value,
|
||||
|
@ -203,6 +210,12 @@ watchEffect(() => {
|
|||
}
|
||||
})
|
||||
|
||||
watchEffect(() => {
|
||||
if (!props.value.error && props.value.column) { // 新增不查找option
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
const showDouble = computed(() => {
|
||||
const isRange = paramsValue.termType ? arrayParamsKey.includes(paramsValue.termType) : false
|
||||
return isRange
|
||||
|
|
|
@ -213,7 +213,7 @@ const rules = [
|
|||
return Promise.reject(new Error('请选择操作符'))
|
||||
}
|
||||
|
||||
if (v.value === undefined) {
|
||||
if (v.value.value === undefined) {
|
||||
return Promise.reject(new Error('请选择或输入参数值'))
|
||||
} else {
|
||||
if (
|
||||
|
|
|
@ -81,6 +81,7 @@ import { ContextKey } from './util'
|
|||
import { useSceneStore } from 'store/scene'
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { Form } from 'jetlinks-ui-components'
|
||||
import { pick } from 'lodash-es'
|
||||
|
||||
const sceneStore = useSceneStore()
|
||||
const { data: formModel } = storeToRefs(sceneStore)
|
||||
|
@ -187,11 +188,18 @@ const handOptionByColumn = (option: any) => {
|
|||
}
|
||||
}
|
||||
|
||||
watchEffect(() => {
|
||||
if (!props.value.error && props.value.column) { // 新增不查找option
|
||||
watch(() => [columnOptions.value, paramsValue.column], () => {
|
||||
if (paramsValue.column) {
|
||||
const option = getOption(columnOptions.value, paramsValue.column, 'column')
|
||||
if (option) {
|
||||
if (option && Object.keys(option).length) {
|
||||
handOptionByColumn(option)
|
||||
if (props.value.error) {
|
||||
emit('update:value', {
|
||||
...props.value,
|
||||
error: false
|
||||
})
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
} else {
|
||||
emit('update:value', {
|
||||
...props.value,
|
||||
|
@ -200,7 +208,7 @@ watchEffect(() => {
|
|||
formItemContext.onFieldChange()
|
||||
}
|
||||
}
|
||||
})
|
||||
}, { immediate: true, deep: true })
|
||||
|
||||
const showDouble = computed(() => {
|
||||
const isRange = paramsValue.termType ? arrayParamsKey.includes(paramsValue.termType) : false
|
||||
|
@ -225,15 +233,17 @@ const mouseout = () => {
|
|||
}
|
||||
|
||||
const columnSelect = (option: any) => {
|
||||
paramsValue.termType = 'eq'
|
||||
const termTypes = option.termTypes
|
||||
paramsValue.termType = termTypes?.length ? termTypes[0].id : 'eq'
|
||||
paramsValue.value = {
|
||||
source: tabsOptions.value[0].key,
|
||||
value: undefined
|
||||
}
|
||||
emit('update:value', { ...paramsValue })
|
||||
formItemContext.onFieldChange()
|
||||
handOptionByColumn(option)
|
||||
formModel.value.options!.when[props.whenName].terms[props.termsName].terms[props.name][0] = option.name
|
||||
formModel.value.options!.when[props.whenName].terms[props.termsName].terms[props.name][1] = paramsValue.termType
|
||||
emit('update:value', { ...paramsValue })
|
||||
formItemContext.onFieldChange()
|
||||
}
|
||||
|
||||
const termsTypeSelect = (e: { key: string, name: string }) => {
|
||||
|
@ -242,9 +252,9 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
|
|||
source: tabsOptions.value[0].key,
|
||||
value: value
|
||||
}
|
||||
formModel.value.options!.when[props.whenName].terms[props.termsName].terms[props.name][1] = e.name
|
||||
emit('update:value', { ...paramsValue })
|
||||
formItemContext.onFieldChange()
|
||||
formModel.value.options!.when[props.whenName].terms[props.termsName].terms[props.name][1] = e.name
|
||||
}
|
||||
|
||||
const valueSelect = (_: any, label: string, labelObj: Record<number, any>) => {
|
||||
|
@ -277,7 +287,7 @@ const onDelete = () => {
|
|||
}
|
||||
|
||||
nextTick(() => {
|
||||
Object.assign(paramsValue, props.value)
|
||||
Object.assign(paramsValue, pick(props.value, ['column', 'options', 'termType', 'terms', 'type', 'value']))
|
||||
})
|
||||
|
||||
</script>
|
||||
|
|
|
@ -120,7 +120,7 @@ const rules = [
|
|||
return Promise.reject(new Error('请选择操作符'));
|
||||
}
|
||||
|
||||
if (v.value === undefined) {
|
||||
if (!v.value?.value) {
|
||||
return Promise.reject(new Error('请选择或输入参数值'));
|
||||
} else {
|
||||
if (
|
||||
|
|
|
@ -311,7 +311,7 @@ const getActions = (
|
|||
},
|
||||
icon: 'LikeOutlined',
|
||||
popConfirm: {
|
||||
title: '',
|
||||
title: '确认手动触发?',
|
||||
onConfirm: async () => {
|
||||
const resp = await _execute(data.id);
|
||||
if (resp.status === 200) {
|
||||
|
|
|
@ -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#f2e62df4054e513df39e3355592d95e356438328"
|
||||
integrity sha512-vfQ8g8nEJueDkHCVcg9WeWDDjnPklyigbobB1CQArfHLd5O4x6vLFWvF69k0yqytCvIOXB13CzhLtMnv68pC5w==
|
||||
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#147926716787ac22464b5ce81180ce43a93e40cc"
|
||||
integrity sha512-guypzc4QurKHfVoDrCo28Bx721kbTx8/W9r8jROWINI0J11ZTRi5bMmqK/2783Jg4kI0s4wZBWebRbIHBgoCyA==
|
||||
dependencies:
|
||||
"@vueuse/core" "^9.12.0"
|
||||
ant-design-vue "^3.2.15"
|
||||
|
|
Loading…
Reference in New Issue