You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
263 lines
7.5 KiB
263 lines
7.5 KiB
<template>
|
|
<div class="lighting-box">
|
|
<div class="lighting-img-box">
|
|
<!-- 左上角,区域切换 -->
|
|
<div class="btn-box">
|
|
<button class="btn-item" @click=changeFloor(1)>1F</button>
|
|
<button class="btn-item" @click=changeFloor(2)>2F</button>
|
|
</div>
|
|
<!-- 楼层区域 -->
|
|
<div class="area">
|
|
<div
|
|
v-for="(item, index) in treeData"
|
|
:class="computedClass(item.id)"
|
|
@click="changeThisArea([item])"
|
|
:key="index">
|
|
<div v-for="(v, i) in item.children" :key="i" class="light-group">
|
|
<div class="group-shadow" @click.stop="changeThisArea([item, v])">
|
|
<div :class="computedClass(v.id)" class="shadow-box"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- 照明设备 -->
|
|
<div class="lights">
|
|
<light v-for="(item, index) in bulbs"
|
|
:key="index"
|
|
:styleObject="item.styleText"
|
|
:type="item.type"
|
|
:visible="item.visible">
|
|
</light>
|
|
</div>
|
|
</div>
|
|
<!-- 右侧抽屉的触发按钮 -->
|
|
<div class="drawer-box-in" v-if="!visible" @click="toggleDrawer">
|
|
<double-left-outlined class="drawer-icon" style="color: white" />
|
|
</div>
|
|
<!-- 左侧抽屉的关闭按钮 -->
|
|
<div class="drawer-box-out" v-if="visible" @click="toggleDrawer">
|
|
<double-right-outlined class="drawer-icon" style="color: white;" />
|
|
</div>
|
|
<!-- 右侧抽屉 -->
|
|
<a-drawer
|
|
v-model:visible="visible"
|
|
class="drawer-item"
|
|
width="496"
|
|
placement="right"
|
|
:body-style="{ background: 'rgba(0, 0, 0)', opacity: 0.8 }"
|
|
:closable="false"
|
|
id="drawer"
|
|
:maskStyle="{ 'background-color': 'rgba(0, 0, 0, 0)' }">
|
|
<a-tabs v-model:activeKey="activeKey">
|
|
<a-tab-pane key="1" tab="控制面板">
|
|
<tabs1 @changeArea="changeArea" :treeData="treeData" :nowArea="nowArea"></tabs1>
|
|
</a-tab-pane>
|
|
<a-tab-pane key="2" tab="计划列表" force-render>
|
|
<tabs2></tabs2>
|
|
</a-tab-pane>
|
|
<a-tab-pane key="3" tab="日志">
|
|
<tabs3></tabs3>
|
|
</a-tab-pane>
|
|
</a-tabs>
|
|
</a-drawer>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { ref, onMounted } from 'vue';
|
|
// 组件
|
|
import light from './light.vue';
|
|
import tabs1 from './tabs1.vue'
|
|
import tabs2 from './tabs2.vue'
|
|
import tabs3 from './tabs3.vue'
|
|
// 请求
|
|
import { http } from '/nerv-lib/util/http';
|
|
import { lightingManage } from '/@/api/IlluminationInfo';
|
|
// ICON
|
|
import {
|
|
DoubleLeftOutlined,
|
|
DoubleRightOutlined
|
|
} from '@ant-design/icons-vue';
|
|
|
|
// 类声明 =======================================================
|
|
|
|
interface items {
|
|
id: string,
|
|
|
|
}
|
|
|
|
// 初始化 =======================================================
|
|
|
|
onMounted(() => {
|
|
http.post(lightingManage.getArea, { floor: '1', siteId: '10000001' }).then(res => {
|
|
const data = res.data
|
|
/** 由前端创建的,只在前端使用的变量
|
|
* @param id 用于判断样式和层级的前端属性
|
|
* @param selected 用于表示是否选中的前端属性
|
|
*/
|
|
data.forEach((item, index) => {
|
|
if (index == 0) {
|
|
item.selected = true
|
|
} else {
|
|
item.selected = false
|
|
}
|
|
item.id = String(index + 1)
|
|
item.children = []
|
|
// deviceGroup后端返回了对象,此处转化为数组
|
|
let i = 1;
|
|
for (let obj in item.deviceGroup) {
|
|
item.deviceGroup[obj].selected = false
|
|
item.deviceGroup[obj].id = String((index + 1) + '-' + i++)
|
|
item.children.push(item.deviceGroup[obj])
|
|
}
|
|
})
|
|
treeData.value = data
|
|
})
|
|
})
|
|
|
|
// 分层业务 =====================================================
|
|
|
|
// 左上角分层切换
|
|
const changeFloor = (area: number) => {
|
|
if (area == 1) {
|
|
console.log('1F')
|
|
} else if (area == 2) {
|
|
console.log('2F')
|
|
}
|
|
}
|
|
|
|
// 分区业务 =====================================================
|
|
|
|
// 分区结构树
|
|
const treeData = ref([])
|
|
// 当前选中的分区id
|
|
const nowArea = ref('1')
|
|
// 当前选中的分区序号 - 用于样式渲染
|
|
const area = ref(['1'])
|
|
// 线路内小灯泡 - 此处位置需前端写死
|
|
const bulbs = ref([
|
|
{
|
|
styleText: { left: '180px', bottom: '200px' },
|
|
area: 1,
|
|
type: 1,
|
|
visible: true
|
|
},
|
|
{
|
|
styleText: { left: '230px', bottom: '125px' },
|
|
area: 1,
|
|
type: 2,
|
|
visible: true
|
|
},
|
|
{
|
|
styleText: { left: '320px', bottom: '140px' },
|
|
area: 1,
|
|
type: 3,
|
|
visible: true
|
|
},
|
|
{
|
|
styleText: { left: '245px', bottom: '230px' },
|
|
area: 1,
|
|
type: 3,
|
|
visible: true
|
|
},
|
|
{
|
|
styleText: { left: '405px', bottom: '230px' },
|
|
area: 2,
|
|
type: 3,
|
|
visible: true
|
|
},
|
|
{
|
|
styleText: { left: '460px', bottom: '180px' },
|
|
area: 2,
|
|
type: 3,
|
|
visible: true
|
|
},
|
|
{
|
|
styleText: { left: '360px', bottom: '275px' },
|
|
area: 2,
|
|
type: 3,
|
|
visible: true
|
|
},
|
|
{
|
|
styleText: { left: '715px', bottom: '320px' },
|
|
area: 3,
|
|
type: 1,
|
|
visible: true
|
|
},
|
|
])
|
|
// 由子组件控制的分区与线路切换
|
|
const changeArea = (result: any) => {
|
|
console.log(result,'changeArea')
|
|
// 数组
|
|
if (Array.isArray(result)) {
|
|
area.value = result
|
|
// 不是数组
|
|
} else {
|
|
area.value.length = 0
|
|
area.value[0] = String(result)
|
|
}
|
|
}
|
|
// 由当前组件控制的分区切换
|
|
const changeThisArea = (result: any) => {
|
|
console.log(result, 'changeThisArea')
|
|
// 修改前,将所有选项置空
|
|
reset()
|
|
let level1 = result[0];
|
|
area.value.length = 0
|
|
if (result.length === 1) {
|
|
result[0].selected = true
|
|
area.value.push(result[0].id)
|
|
} else if (result.length === 2) {
|
|
// 如果没有分区,默认选择第一个
|
|
if (!level1) {
|
|
level1 = treeData.value[0]
|
|
}
|
|
// 选中状态都设为true
|
|
level1.selected = result[1].selected = true
|
|
area.value.splice(0, 0, level1.id, result[1].id)
|
|
}
|
|
nowArea.value = level1.id
|
|
}
|
|
// 重置分区树所有当前选项
|
|
const reset = () => {
|
|
treeData.value.forEach(item => {
|
|
item.selected = false
|
|
item.children.forEach(i => {
|
|
i.selected = false
|
|
})
|
|
})
|
|
}
|
|
// 俯视图分区选中计算函数
|
|
const computedClass = (string: string) => {
|
|
if (area.value.indexOf(string) != -1) {
|
|
return `isActive area-item area${string}`
|
|
} else {
|
|
return `area-item area${string}`
|
|
}
|
|
}
|
|
|
|
// 抽屉业务 =====================================================
|
|
|
|
// 抽屉 - 当前选择的tab
|
|
let activeKey = ref('1');
|
|
// 抽屉 - 打开状态
|
|
let visible = ref(false);
|
|
// 抽屉 - 开关事件
|
|
const toggleDrawer = () => {
|
|
visible.value = !visible.value;
|
|
};
|
|
|
|
</script>
|
|
<style lang="less" scoped>
|
|
@import "./index.less";
|
|
// 当前选中分区的样式
|
|
.isActive {
|
|
border: 3px solid white !important;
|
|
}
|
|
// 抽屉顶部tab按钮样式
|
|
:deep(.ant-tabs-tab-btn) {
|
|
color: white;
|
|
}
|
|
</style>
|
|
|