fix: 修改bug

This commit is contained in:
100011797 2023-07-10 17:55:36 +08:00
parent a4aa193781
commit bd42cdd3fb
8 changed files with 244 additions and 26 deletions

View File

@ -2,7 +2,7 @@
<div class="card j-table-card-box">
<div
class="card-warp"
:class="{ active: active ? 'active' : '' }"
:class="{ active: active ? 'active' : '', 'disabled': disabled }"
@click="handleClick"
>
<div class="card-type" v-if="slots.type">
@ -140,6 +140,10 @@ const props = defineProps({
type: Boolean,
default: false,
},
disabled: {
type: Boolean,
default: false,
}
});
const getBackgroundColor = (code: string | number) => {
@ -160,6 +164,7 @@ const handleClick = () => {
.card {
width: 100%;
background-color: #fff;
.checked-icon {
position: absolute;
right: -22px;
@ -190,16 +195,20 @@ const handleClick = () => {
position: relative;
border: 1px solid #e6e6e6;
overflow: hidden;
cursor: pointer;
&:hover {
cursor: pointer;
box-shadow: 0 0 24px rgba(#000, 0.1);
.card-mask {
visibility: visible;
}
}
&.disabled {
filter: grayscale(100%);
cursor: not-allowed;
}
&.active {
position: relative;
border: 1px solid #2f54eb;

View File

@ -143,7 +143,6 @@
import ChannelApi from '@/api/media/channel';
import type { ActionsType } from '@/views/device/Instance/typings';
import { useMenuStore } from 'store/menu';
import { message } from 'jetlinks-ui-components';
import Save from './Save.vue';
import Live from './Live/index.vue';
import Tree from './Tree/index.vue';

View File

@ -33,7 +33,6 @@
</template>
<script setup lang="ts">
import { message } from 'jetlinks-ui-components';
import type { recordsItemType } from './typings';
import type { Dayjs } from 'dayjs';
import dayjs from 'dayjs';

View File

@ -0,0 +1,213 @@
<template>
<j-modal
visible
title="新增"
okText="确定"
cancelText="取消"
:width="1000"
@cancel="closeModal"
@ok="saveCorrelation"
>
<pro-search :columns="columns" @search="handleSearch" />
<div style="height: 500px; overflow-y: auto">
<JProTable
model="CARD"
:request="query"
:rowSelection="{
selectedRowKeys: _selectedRowKeys,
onSelectNone: onSelectChange,
// onChange: onChange,
}"
:gridColumns="[1, 1, 1]"
:defaultParams="{
sorts: [
{
name: 'createTime',
order: 'desc',
},
],
terms,
}"
:params="params"
>
<template #card="slotProps">
<CardBox
:value="slotProps"
:status="slotProps.state?.value"
:statusText="slotProps.state?.text"
:active="_selectedRowKeys.includes(slotProps.id)"
@click="handleClick"
:statusNames="{
started: 'processing',
disable: 'error',
}"
:disabled="slotProps.state?.value === 'disable'"
>
<template #type>
<span
><img
:height="16"
:src="
typeMap.get(slotProps.triggerType)?.icon
"
style="margin-right: 5px"
/>{{
typeMap.get(slotProps.triggerType)?.text
}}</span
>
</template>
<template #img>
<img
:src="typeMap.get(slotProps.triggerType)?.img"
/>
</template>
<template #content>
<Ellipsis style="width: calc(100% - 100px)">
<span style="font-size: 16px; font-weight: 600">
{{ slotProps.name }}
</span>
</Ellipsis>
<Ellipsis :lineClamp="2">
<div class="subTitle">
说明{{
slotProps?.description ||
typeMap.get(slotProps.triggerType)?.tip
}}
</div>
</Ellipsis>
</template>
</CardBox>
</template>
</JProTable>
</div>
</j-modal>
</template>
<script lang="ts" setup>
import { getImage, onlyMessage } from '@/utils/comm';
import { query } from '@/api/rule-engine/scene';
import { _execute } from '@/api/rule-engine/configuration';
const columns = [
{
title: '名称',
dataIndex: 'name',
key: 'name',
search: {
type: 'string',
},
},
{
title: '触发方式',
dataIndex: 'triggerType',
key: 'triggerType',
},
{
title: '状态',
dataIndex: 'state',
key: 'state',
search: {
type: 'select',
options: [
{
label: '正常',
value: 'started',
},
{
label: '禁用',
value: 'disable',
},
],
},
},
];
const props = defineProps({
data: {
type: Object,
default: () => {},
},
});
const terms = [
{
terms: [
{
column: 'id',
termType: 'alarm-bind-rule',
value: props.data?.id,
},
{
column: 'triggerType',
termType: 'eq',
value: props.data?.sceneTriggerType,
},
],
type: 'and',
},
];
const params = ref();
const typeMap = new Map();
typeMap.set('manual', {
text: '手动触发',
img: getImage('/scene/scene-hand.png'),
icon: getImage('/scene/trigger-type-icon/manual.png'),
tip: '适用于第三方平台向物联网平台下发指令控制设备',
});
const _selectedRowKeys = ref<string[]>([]);
const handleClick = (dt: any) => {
if(dt.state?.value === 'disable') {
return
}
if (_selectedRowKeys.value.includes(dt.id)) {
const _index = _selectedRowKeys.value.findIndex((i) => i === dt.id);
_selectedRowKeys.value.splice(_index, 1);
} else {
_selectedRowKeys.value = [..._selectedRowKeys.value, dt.id];
}
};
/**
* 取消选择事件
*/
const onSelectChange = () => {
_selectedRowKeys.value = [];
};
const handleSearch = (e: any) => {
params.value = e;
};
const emit = defineEmits(['close', 'save']);
/**
* 保存选中关联场景
*/
const saveCorrelation = async () => {
if (_selectedRowKeys.value.length > 0) {
const scene = _selectedRowKeys.value.map((i) => {
return { id: i };
});
_execute(scene).then((res) => {
if (res.status === 200) {
onlyMessage('操作成功');
emit('save');
} else {
onlyMessage('操作失败', 'error');
}
});
} else {
onlyMessage('请选择至少一条数据', 'error');
}
};
const closeModal = () => {
emit('close');
};
</script>
<style lang="less" scoped>
.subTitle {
color: rgba(0, 0, 0, 0.65);
font-size: 14px;
margin-top: 10px;
}
</style>

View File

@ -184,6 +184,7 @@
</FullPage>
</div>
</page-container>
<HandTrigger @save="onSave" @close="visible = false" v-if="visible" :data="current" />
</template>
<script lang="ts" setup>
@ -192,7 +193,6 @@ import {
_enable,
_disable,
remove,
_execute,
getScene,
} from '@/api/rule-engine/configuration';
import { queryLevel } from '@/api/rule-engine/config';
@ -201,6 +201,8 @@ import type { ActionsType } from '@/components/Table/index.vue';
import { getImage, onlyMessage } from '@/utils/comm';
import { useMenuStore } from '@/store/menu';
import encodeQuery from '@/utils/encodeQuery';
import HandTrigger from './HandTrigger/index.vue';
const params = ref<Record<string, any>>({});
let isAdd = ref<number>(0);
let title = ref<string>('');
@ -331,6 +333,9 @@ const columns = [
scopedSlots: true,
},
];
const visible = ref<boolean>(false);
const current = ref<any>({});
const map = {
product: '产品',
device: '设备',
@ -382,23 +387,9 @@ const getActions = (
? '未启用,不能手动触发'
: '手动触发',
},
popConfirm: {
title: '确定手动触发?',
onConfirm: async () => {
const scene = (data.scene || [])
.filter((item: any) => item?.triggerType === 'manual')
.map((i) => {
return { id: i?.id };
});
_execute(scene).then((res) => {
if (res.status === 200) {
onlyMessage('操作成功');
tableRef.value?.reload();
} else {
onlyMessage('操作失败', 'error');
}
});
},
onClick: () => {
visible.value = true;
current.value = data
},
icon: 'LikeOutlined',
},
@ -479,6 +470,10 @@ const getActions = (
(item) => item.key != 'tigger' || data.sceneTriggerType == 'manual',
);
};
const onSave = () => {
visible.value = false;
tableRef.value?.reload();
}
const add = () => {
menuStory.jumpPage('rule-engine/Alarm/Configuration/Save');
};

View File

@ -59,7 +59,6 @@ import { detail as configurationDetail } from '@/api/rule-engine/configuration';
import { useRoute } from 'vue-router';
import dayjs from 'dayjs';
import type { ActionsType } from '@/components/Table/index.vue';
import { message } from 'jetlinks-ui-components';
import { useAlarmStore } from '@/store/alarm';
import Info from './info.vue';
import { storeToRefs } from 'pinia';

View File

@ -260,7 +260,6 @@
<script setup lang="ts">
import PermissionButton from '@/components/PermissionButton/index.vue';
import { FormInstance } from 'ant-design-vue';
import { message } from 'jetlinks-ui-components';
import ChooseIconDialog from '../components/ChooseIconDialog.vue';
import PermissChoose from '../components/PermissChoose.vue';
import {

View File

@ -24,8 +24,13 @@
v-for="item in dataSource"
:key="item.provider"
class="custom"
:header="item.name"
>
<template #header>
<div>
{{ item.name }}
<span style="margin-left: 10px;" class="alert" v-if="item.provider === 'alarm'">注意接收人需要有告警配置页面查询权限才能收到告警类通知</span>
</div>
</template>
<div class="child">
<template
v-for="(child, index) in item.children"