fix: 优化场景联动

This commit is contained in:
xieyonghong 2023-04-10 09:42:47 +08:00
parent f87bef89c3
commit 9fc1a55def
8 changed files with 351 additions and 329 deletions

View File

@ -1,7 +1,7 @@
import server from '@/utils/request';
// 当前登录用户权限信息
export const getMe_api = () => server.get(`/authorize/me`);
export const getMe_api = () => server.get<{ user: any, [key : string]: any }>(`/authorize/me`);
// 设置登录用户选择的页面
export const setView_api = (data:object) => server.patch(`/user/settings/view/user`, data);
// 当前登录用户选择的页面

View File

@ -10,7 +10,7 @@ export const config = () => server.get(`/authorize/captcha/config`)
*
* @returns
*/
export const code = () => server.get(`/authorize/captcha/image?width=130&height=30`)
export const code = () => server.get<{ base64: string, key: string }>(`/authorize/captcha/image?width=130&height=30`)
/**
*
@ -57,3 +57,7 @@ export const userDetail = () => server.get<any>('/user/detail')
* 退
*/
export const loginout_api = () => server.get<any>('/user-token/reset')
export const getOAuth2 = (params: any) => server.get<any>('/oauth2/authorize', params)
export const initApplication = (clientId: string | number) => server.get<{name: string}>(`/application/${clientId}/info`)

View File

@ -110,8 +110,6 @@ const jump = (item: any) => {
path = item.path
}
console.log(item, history.state)
console.log(path)
// jumpPage(slotProps.route.path)
router.push(path)
}
@ -119,8 +117,7 @@ const jump = (item: any) => {
const breadcrumb = computed(() =>
{
const paths = router.currentRoute.value.name as string
console.log(router.currentRoute)
console.log(route)
const metas = findRouteMeta(paths)
return metas.map((item, index) => {
return {

View File

@ -4,6 +4,7 @@ export const AccountCenterBindPath = '/account/center/bind'
export const InitLicense = '/init-license'
export const NotificationSubscriptionCode = 'account/NotificationSubscription'
export const NotificationRecordCode = 'account/NotificationRecord'
export const OauthPath = '/oauth'
export const AccountMenu = {
path: '/account',
@ -70,6 +71,13 @@ export default [
{
path: InitLicense,
component: () => import('@/views/system/License/index.vue')
},
{
path: OauthPath,
meta: {
title: '授权页'
},
component: () => import('@/views/oauth/index.vue')
}
]

View File

@ -348,6 +348,7 @@ const termAdd = () => {
}
const onDelete = () => {
const key = formModel.value.branches?.[props.branchName]?.then?.[props.thenName]?.actions?.[props.actionName].terms?.[props.termsName].terms?.[props.name].key
formModel.value.branches?.[props.branchName]?.then?.[props.thenName]?.actions?.[props.actionName].terms?.[props.termsName].terms?.splice(props.name, 1)
const _options = formModel.value.branches![props.branchName].then[props.thenName].actions[props.name].options
const termsColumns = _options?.termsColumns || []

View File

@ -107,8 +107,11 @@ const onKeys: string[] = EventSubscribeKeys({
action: props.actionName
})
const handleRequest = () => {
columnRequest()
const handleRequest = (e: any) => {
const hasDelete = 'isDelete' in e
if (!hasDelete) {
columnRequest()
}
}
EventEmitter.subscribe(onKeys, handleRequest)

View File

@ -6,328 +6,328 @@
>
<div class="actions-item">
<CheckItem v-bind='props'>
<div class="item-options-warp">
<div class="item-options-type" @click="onAdd">
<img
style="width: 18px"
:src="
iconMap.get(
data?.executor === 'alarm'
? data?.alarm?.mode
: data?.executor,
)
"
/>
</div>
<div
class="item-options-content"
v-if="data?.executor === 'alarm'"
>
<template v-if="data?.alarm?.mode === 'trigger'">
满足条件后将触发<j-button
style="padding: 0"
type="link"
@click.stop="triggerVisible = true"
>关联此场景的告警</j-button
>
</template>
<template v-else>
满足条件后将解除<j-button
style="padding: 0"
type="link"
@click.stop="triggerVisible = true"
>关联此场景的告警</j-button
>
</template>
</div>
<div
class="item-options-content"
v-else-if="data?.executor === 'notify'"
@click="onType('notify')"
>
<template v-if="data?.notify?.notifyType === 'dingTalk'">
<template
v-if="options?.provider === 'dingTalkRobotWebHook'"
>
<div>
通过<span class="notify-text-highlight"
>群机器人消息</span
>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template v-else>
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
钉钉
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}</span>
<span class="notify-text-highlight">{{
options?.orgName || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
</template>
<template v-else-if="data?.notify?.notifyType === 'weixin'">
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
微信
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}</span>
<span class="notify-text-highlight">{{
options?.orgName || ''
}}</span>
<span class="notify-text-highlight">{{
options?.tagName || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template v-else-if="data?.notify?.notifyType === 'email'">
<div style="display: flex;">
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
邮件
</span>
<span class="notify-text-highlight">
<Ellipsis style='max-width: 400px;'>
{{
<div class="item-options-warp">
<div class="item-options-type" @click="onAdd">
<img
style="width: 18px"
:src="
iconMap.get(
data?.executor === 'alarm'
? data?.alarm?.mode
: data?.executor,
)
"
/>
</div>
<div
class="item-options-content"
v-if="data?.executor === 'alarm'"
>
<template v-if="data?.alarm?.mode === 'trigger'">
满足条件后将触发<j-button
style="padding: 0"
type="link"
@click.stop="triggerVisible = true"
>关联此场景的告警</j-button
>
</template>
<template v-else>
满足条件后将解除<j-button
style="padding: 0"
type="link"
@click.stop="triggerVisible = true"
>关联此场景的告警</j-button
>
</template>
</div>
<div
class="item-options-content"
v-else-if="data?.executor === 'notify'"
@click="onType('notify')"
>
<template v-if="data?.notify?.notifyType === 'dingTalk'">
<template
v-if="options?.provider === 'dingTalkRobotWebHook'"
>
<div>
通过<span class="notify-text-highlight"
>群机器人消息</span
>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template v-else>
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
钉钉
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}</span>
<span class="notify-text-highlight">{{
options?.orgName || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
</template>
<template v-else-if="data?.notify?.notifyType === 'weixin'">
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
微信
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}
</Ellipsis>
</span>
发送
<span class="notify-text-highlight">
}}</span>
<span class="notify-text-highlight">{{
options?.orgName || ''
}}</span>
<span class="notify-text-highlight">{{
options?.tagName || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template v-else-if="data?.notify?.notifyType === 'email'">
<div style="display: flex;">
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
邮件
</span>
<span class="notify-text-highlight">
<Ellipsis style='max-width: 400px;'>
{{
options?.templateName ||
data?.notify?.templateId
}}
options?.sendTo || ''
}}
</Ellipsis>
</span>
</div>
</template>
<template v-else-if="data?.notify?.notifyType === 'voice'">
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template v-else-if="data?.notify?.notifyType === 'voice'">
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
语音
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template v-else-if="data?.notify?.notifyType === 'sms'">
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
短信
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template
v-else-if="data?.notify?.notifyType === 'webhook'"
>
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
webhook
</span>
发送
<span>{{
options?.templateName ||
data?.notify?.templateId
}}</span>
</div>
</template>
</div>
<div
class="item-options-content"
v-else-if="data?.executor === 'delay'"
@click="onType('delay')"
>
{{ options?.name }}
</div>
<div
class="item-options-content"
v-else-if="data?.executor === 'device'"
@click="onType('device')"
>
<template v-if="['fixed', 'context'].includes(data?.device?.selector)">
<div style='display: flex; align-items: center;'>
<AIcon
:type="
typeIconMap[
data?.device?.message?.messageType ||
'INVOKE_FUNCTION'
]
"
/>
<span style="padding-left: 4px">{{
data?.options?.type
}}</span>
<AIcon
type="icon-mubiao"
style="padding:0 4px"
/>
<Ellipsis style='max-width: 200px;margin-right: 12px;'>
{{data?.options?.name}}
</Ellipsis>
<Ellipsis style='max-width: 400px;'>
{{data?.options?.propertiesName}}
</Ellipsis>
<span v-if='!isBoolean(data?.options?.propertiesValue) && data?.options?.propertiesValue'> </span>
<Ellipsis style='max-width: 200px;'>
{{
`${
(
isBoolean(
data?.options?.propertiesValue,
)
"
/>
语音
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template v-else-if="data?.notify?.notifyType === 'sms'">
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
短信
</span>
<span class="notify-text-highlight">{{
options?.sendTo || ''
}}</span>
发送
<span class="notify-text-highlight">
{{
options?.templateName ||
data?.notify?.templateId
}}
</span>
</div>
</template>
<template
v-else-if="data?.notify?.notifyType === 'webhook'"
>
<div>
通过
<span class="notify-text-highlight">
<img
style="width: 18px"
:src="
itemNotifyIconMap.get(
data?.notify?.notifyType,
)
"
/>
webhook
</span>
发送
<span>{{
options?.templateName ||
data?.notify?.templateId
}}</span>
</div>
</template>
</div>
<div
class="item-options-content"
v-else-if="data?.executor === 'delay'"
@click="onType('delay')"
>
{{ options?.name }}
</div>
<div
class="item-options-content"
v-else-if="data?.executor === 'device'"
@click="onType('device')"
>
<template v-if="['fixed', 'context'].includes(data?.device?.selector)">
<div style='display: flex; align-items: center;'>
<AIcon
:type="
typeIconMap[
data?.device?.message?.messageType ||
'INVOKE_FUNCTION'
]
"
/>
<span style="padding-left: 4px">{{
data?.options?.type
}}</span>
<AIcon
type="icon-mubiao"
style="padding:0 4px"
/>
<Ellipsis style='max-width: 200px;margin-right: 12px;'>
{{data?.options?.name}}
</Ellipsis>
<Ellipsis style='max-width: 400px;'>
{{data?.options?.propertiesName}}
</Ellipsis>
<span v-if='!isBoolean(data?.options?.propertiesValue) && data?.options?.propertiesValue'> </span>
<Ellipsis style='max-width: 200px;'>
{{
`${
(
isBoolean(
data?.options?.propertiesValue,
)
? true
: data?.options?.propertiesValue
)
? `${data?.options?.propertiesValue}`
: ''
}`
}}
</Ellipsis>
? true
: data?.options?.propertiesValue
)
? `${data?.options?.propertiesValue}`
: ''
}`
}}
</Ellipsis>
</div>
</template>
<template v-else-if="data?.device?.selector === 'tag'">
<div>
<AIcon
:type="
typeIconMap[
data?.device?.message?.messageType ||
'INVOKE_FUNCTION'
]
"
/>
{{ data?.options?.type }}
<span>{{ data?.options?.tagName }}</span>
{{ data?.options?.productName }}
{{ data?.options?.propertiesName }}
</div>
</template>
<template v-else-if="data?.device?.selector === 'relation'">
<div>
<AIcon
:type="
typeIconMap[
data?.device?.message?.messageType ||
'INVOKE_FUNCTION'
]
"
/>
{{ data?.options?.type }}<span>{{
data?.options?.triggerName
}}</span
>具有相同 {{ data?.options?.relationName }}{{
data?.options?.productName
}}设备的
{{ data?.options?.propertiesName }}
</div>
</template>
</div>
<j-button v-else @click="onAdd">点击配置执行动作</j-button>
</div>
<div class="item-number">{{ name + 1 }}</div>
<j-popconfirm title="确认删除?" @confirm="onDelete" placement="topRight" :overlayStyle='{minWidth: "190px"}'>
<div class="item-delete">
<AIcon type="DeleteOutlined" />
</div>
</j-popconfirm>
</div>
</template>
<template v-else-if="data?.device?.selector === 'tag'">
<div>
<AIcon
:type="
typeIconMap[
data?.device?.message?.messageType ||
'INVOKE_FUNCTION'
]
"
/>
{{ data?.options?.type }}
<span>{{ data?.options?.tagName }}</span>
{{ data?.options?.productName }}
{{ data?.options?.propertiesName }}
</div>
</template>
<template v-else-if="data?.device?.selector === 'relation'">
<div>
<AIcon
:type="
typeIconMap[
data?.device?.message?.messageType ||
'INVOKE_FUNCTION'
]
"
/>
{{ data?.options?.type }}<span>{{
data?.options?.triggerName
}}</span
>具有相同 {{ data?.options?.relationName }}{{
data?.options?.productName
}}设备的
{{ data?.options?.propertiesName }}
</div>
</template>
</div>
<j-button v-else @click="onAdd">点击配置执行动作</j-button>
</div>
<div class="item-number">{{ name + 1 }}</div>
<j-popconfirm title="确认删除?" @confirm="onDelete" placement="topRight" :overlayStyle='{minWidth: "190px"}'>
<div class="item-delete">
<AIcon type="DeleteOutlined" />
</div>
</j-popconfirm>
</CheckItem>
</div>
</j-form-item>
@ -461,11 +461,14 @@ const termsOptions = computed(() => {
});
const onDelete = () => {
const key = _data.value.branches![props.branchesName].then[props.thenName].actions[props.name].key
EventEmitter.emit(key!, { isDelete: true })
if (props.name !== 0 && !props.parallel) { // options.termsColumnsterms
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name - 1].options!.termsColumns = []
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name - 1].options!.terms = []
_data.value.branches![props.branchesName].then[props.thenName].actions[props.name - 1].terms = []
}
emit('delete');
};

View File

@ -68,6 +68,8 @@ export const EventEmitterKeys = (params: Params): string => {
* @constructor
*/
export const EventSubscribeKeys = (params: Params): string[] => {
const sceneStore = useSceneStore()
let keys: string[] = []
if (params.action === 0) {
@ -75,10 +77,14 @@ export const EventSubscribeKeys = (params: Params): string[] => {
}
for (let i = 0; i <= params.action; i++) {
const _b = `branches_${params.branch}` // branchesName
const _t = `then_${params.branchGroup}` // thenName
const _a = `then_${i}` // actionName
keys.push(`${_b}_${_t}_${_a}`)
let key = sceneStore.data.branches?.[params.branch].then[params.branchGroup].actions[i]?.key
if (!key) {
const _b = `branches_${params.branch}` // branchesName
const _t = `then_${params.branchGroup}` // thenName
const _a = `then_${i}` // actionName
key = `${_b}_${_t}_${_a}`
}
keys.push(key)
}
return keys