Browse Source

add:照明系统 提交数据功能

temp
chenpingsen 4 months ago
parent
commit
ab29f9152d
  1. 7
      hx-ai-intelligent/src/api/IlluminationInfo.ts
  2. 25
      hx-ai-intelligent/src/view/equipmentControl/lightingManage/indexs.vue
  3. 227
      hx-ai-intelligent/src/view/equipmentControl/lightingManage/tabs1.vue

7
hx-ai-intelligent/src/api/IlluminationInfo.ts

@ -9,6 +9,13 @@ export enum lightingManage {
// 修改线路的可用/禁用状态 // 修改线路的可用/禁用状态
setDisable = '/carbon-smart/IlluminationInfo/revisePanel', setDisable = '/carbon-smart/IlluminationInfo/revisePanel',
// 控制面板tab页 ================================================
// 获取当前修改的内容对比数据
getChangeList = '/carbon-smart/IlluminationInfo/getLightSceneChangeInfo',
// 提交当前修改
submitChangeList = '/carbon-smart/IlluminationInfo/changeLightScene',
// 计划列表tab页 ================================================ // 计划列表tab页 ================================================
// 获得计划列表tab页的表格数据 // 获得计划列表tab页的表格数据

25
hx-ai-intelligent/src/view/equipmentControl/lightingManage/indexs.vue

@ -42,6 +42,7 @@
v-model:visible="visible" v-model:visible="visible"
class="drawer-item" class="drawer-item"
width="496" width="496"
:forceRender="preload"
placement="right" placement="right"
:body-style="{ background: 'rgba(0, 0, 0)', opacity: 0.8 }" :body-style="{ background: 'rgba(0, 0, 0)', opacity: 0.8 }"
:closable="false" :closable="false"
@ -54,7 +55,6 @@
@changeArea="changeArea" @changeArea="changeArea"
@reset="reset" @reset="reset"
:treeData="treeData" :treeData="treeData"
:nowArea="nowArea"
></tabs1> ></tabs1>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="计划列表" force-render> <a-tab-pane key="2" tab="计划列表" force-render>
@ -93,6 +93,10 @@ onMounted(() => {
getAllArea() getAllArea()
}) })
// flagref
const preload = ref(false)
// ===================================================== // =====================================================
// //
@ -109,13 +113,12 @@ const changeFloor = (area: any) => {
treeData.value[0].selected = true treeData.value[0].selected = true
} }
// ===================================================== // =====================================================
// //
const treeData = ref([]) const treeData = ref([])
// id // -
const nowArea = ref('1')
// -
const area = ref(['1']) const area = ref(['1'])
// 线 - // 线 -
const bulbs = ref([ const bulbs = ref([
@ -182,15 +185,18 @@ const changeArea = (result: any) => {
} }
// //
const changeThisArea = (result: any) => { const changeThisArea = (result: any) => {
tabs1Ref.value.changeCancel()
console.log(result, 'changeThisArea') console.log(result, 'changeThisArea')
// //
reset() reset()
let level1 = result[0]; let level1 = result[0];
area.value.length = 0 area.value.length = 0
//
if (result.length === 1) { if (result.length === 1) {
result[0].selected = true result[0].selected = true
area.value.push(result[0].id) area.value.push(result[0].id)
//
tabs1Ref.value.changeArea(result[0])
// + 线
} else if (result.length === 2) { } else if (result.length === 2) {
// //
if (!level1) { if (!level1) {
@ -199,8 +205,10 @@ const changeThisArea = (result: any) => {
// true // true
level1.selected = result[1].selected = true level1.selected = result[1].selected = true
area.value.splice(0, 0, level1.id, result[1].id) area.value.splice(0, 0, level1.id, result[1].id)
//
tabs1Ref.value.changeArea(result[0])
tabs1Ref.value.changeLine(result[1])
} }
nowArea.value = level1.id
} }
// //
const reset = () => { const reset = () => {
@ -220,6 +228,7 @@ const computedClass = (string: string) => {
} }
} }
//
const getAllArea = () => { const getAllArea = () => {
http.get(lightingManage.getArea, { projectId: 'HLlmTZp8' }).then(res => { http.get(lightingManage.getArea, { projectId: 'HLlmTZp8' }).then(res => {
const data = res.data const data = res.data
@ -242,7 +251,10 @@ const getAllArea = () => {
}) })
}) })
}) })
// 线 1-1
treeData.value = data[0].childList treeData.value = data[0].childList
//
preload.value = true
}) })
} }
@ -256,6 +268,7 @@ let visible = ref(false);
const toggleDrawer = () => { const toggleDrawer = () => {
visible.value = !visible.value; visible.value = !visible.value;
}; };
// tab1
const tabs1Ref = ref() const tabs1Ref = ref()
</script> </script>

227
hx-ai-intelligent/src/view/equipmentControl/lightingManage/tabs1.vue

@ -13,7 +13,7 @@
<div class="area"> <div class="area">
<template v-if="!showAllButtonsArea"> <template v-if="!showAllButtonsArea">
<button v-for="(button, index) in limitedButtons1" :key="index" <button v-for="(button, index) in limitedButtons1" :key="index"
:class="{ btn: true, selected: button.selected }" @click="selectButton(button)"> :class="{ btn: true, selected: button.selected }" @click="changeArea(button)">
{{ button.name }} {{ button.name }}
</button> </button>
<div style="margin-top: 10px"> <div style="margin-top: 10px">
@ -22,7 +22,7 @@
</template> </template>
<template v-else> <template v-else>
<button v-for="(button, index) in props.treeData" :key="index" :class="{ btn: true, selected: button.selected }" <button v-for="(button, index) in props.treeData" :key="index" :class="{ btn: true, selected: button.selected }"
@click="selectButton(button)"> @click="changeArea(button)">
{{ button.name }} {{ button.name }}
</button> </button>
<div style="margin-top: 10px"> <div style="margin-top: 10px">
@ -53,7 +53,7 @@
<div class="btnArea"> <div class="btnArea">
<template v-if="!showAllButtons"> <template v-if="!showAllButtons">
<button v-for="(button, index) in limitedButtons2" :key="index" <button v-for="(button, index) in limitedButtons2" :key="index"
:class="{ btn: true, selected: button.selected }" class="zmhlbtn" @click="toggleSelection(button)"> :class="{ btn: true, selected: button.selected }" class="zmhlbtn" @click="changeLine(button)">
<stop-outlined v-if="button.ctrlStatus" /> <stop-outlined v-if="button.ctrlStatus" />
{{ button.name }} {{ button.name }}
</button> </button>
@ -63,7 +63,7 @@
</template> </template>
<template v-else> <template v-else>
<button v-for="(button, index) in buttons2" :key="index" <button v-for="(button, index) in buttons2" :key="index"
:class="{ btn: true, selected: button.selected }" class="zmhlbtn" @click="toggleSelection(button)"> :class="{ btn: true, selected: button.selected }" class="zmhlbtn" @click="changeLine(button)">
<stop-outlined v-if="button.ctrlStatus" /> <stop-outlined v-if="button.ctrlStatus" />
{{ button.name }} {{ button.name }}
</button> </button>
@ -91,26 +91,26 @@
</div> </div>
<!-- 控制场景部分 --> <!-- 控制场景部分 -->
<div> <div>
<div class="control-scene-area" v-show="thisButton2.mode.value == '3'"> <div class="control-scene-area" v-show="thisButton2.mode.value == 3">
<div class="control-scene-tab"></div> <div class="control-scene-tab"></div>
<span class="control-scene-text"> 控制场景 </span> <span class="control-scene-text"> 控制场景 </span>
</div> </div>
<!-- 控制场景按钮部分 --> <!-- 控制场景按钮部分 -->
<div class="control-scene-btn-area" v-show="thisButton2.mode.value == '3'"> <div class="control-scene-btn-area" v-show="thisButton2.mode.value == 3">
<button v-for="(button4, index) in controlScene" :key="index" <button v-for="(button4, index) in controlScene" :key="index"
:class="{ btn: true, selected: thisButton2.mode.value == button4.value }" @click="selectButton4(button4)"> :class="{ btn: true, selected: thisButton2.scene.value == button4.value }" @click="selectButton4(button4)">
{{ button4.label }} {{ button4.label }}
</button> </button>
</div> </div>
</div> </div>
<!-- 底部按钮区 --> <!-- 底部按钮区 -->
<div class="bottom"> <div class="bottom">
<a-popconfirm <a-popconfirm
title="刷新将会取消已作出的修改" title="刷新将会取消已作出的修改"
ok-text="确定" ok-text="确定"
cancel-text="取消" cancel-text="取消"
@confirm="changeConfirm" @confirm="changeConfirm"
@cancel="changeCancel" @cancel="changeCancel"
> >
<button class="flushed">刷新</button> <button class="flushed">刷新</button>
</a-popconfirm> </a-popconfirm>
@ -186,7 +186,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, computed, onMounted, watch } from 'vue'; import { ref, computed, onMounted } from 'vue';
import { import {
DownOutlined, DownOutlined,
UpOutlined, UpOutlined,
@ -201,47 +201,25 @@ import { getAllEnum } from '/@/api/index'
// ========================================================================= // =========================================================================
onMounted(() => { onMounted(() => {
// //
setArea(0) setArea()
// //
getEnum(['IlluminationMode', 'IlluminationScene']) getEnum(['IlluminationMode', 'IlluminationScene'])
}) })
//
//
const getEnum = (arr: any) => { const getEnum = (arr: any) => {
getAllEnum({ params: arr }).then(res => { getAllEnum({ params: arr }).then(res => {
const data = res.data const data = res.data
controlMode.value = data.IlluminationMode //
controlScene.value = data.IlluminationScene controlMode.value = data.IlluminationMode
//
controlScene.value = data.IlluminationScene
}) })
} }
// 线 // 1-1 线
const setArea = (isHandle: number) => { const setArea = () => {
const data = props.treeData.find((item: any) => { const data = props.treeData[0]
return item.id == props.nowArea
})
//
data.selected = true
//
selectedButton.value = props.nowArea
//
buttons2.value = data.childList buttons2.value = data.childList
//
if (isHandle) {
// 线childrenselectedtrue
const button2 = data.childList.find((item: any) => {
return item.selected == true
})
// 线
if (button2) {
thisButton2.value = button2;
console.log(button2,'2222222222')
} else {
resetMode()
}
}
} }
// =================================================================== // ===================================================================
@ -251,10 +229,6 @@ const props = defineProps({
treeData: { treeData: {
type: Array, type: Array,
default: [] default: []
},
// ID
nowArea: {
type: String,
} }
}); });
// //
@ -263,12 +237,6 @@ const props = defineProps({
* @method reset 用于重置按钮区 * @method reset 用于重置按钮区
*/ */
const emit = defineEmits(['changeArea','reset']); const emit = defineEmits(['changeArea','reset']);
//
watch(() => props.nowArea, () => {
setArea(1)
// 线
handleButton.value = ''
})
// ======================================================================= // =======================================================================
@ -283,15 +251,22 @@ const togglePlan = () => {
const showAllButtonsArea = ref(false); const showAllButtonsArea = ref(false);
// 1 // 1
const selectedButton = ref<string | undefined>('1'); const selectedButton = ref<string | undefined>('1');
// -
const selectButton = (button: any) => { //
const changeArea = (button: any) => {
// //
selectedButton.value = button.id; selectedButton.value = button.id;
initMenu(1) // 线
button.selected = true
buttons2.value = button.childList buttons2.value = button.childList
//
emit('reset')
//
button.selected = true
//
emit('changeArea', button.id); emit('changeArea', button.id);
// 线 -
resetMode() resetMode()
// -
handleButton.value = '' handleButton.value = ''
}; };
// 8 // 8
@ -335,7 +310,9 @@ const selectAll = () => {
button.selected = false; button.selected = false;
}); });
singleSelection.value = !singleSelection.value; singleSelection.value = !singleSelection.value;
// 线 -
resetMode() resetMode()
//
emit('changeArea', [selectedButton.value]) emit('changeArea', [selectedButton.value])
}; };
@ -346,7 +323,11 @@ const toggleAllSelection = () => {
let arr = [selectedButton.value] let arr = [selectedButton.value]
// //
if (selectAllCheckbox.value) { if (selectAllCheckbox.value) {
buttons2.value.forEach((item) => { buttons2.value.forEach((item, index) => {
// 线-
if (index == 0) {
thisButton2.value = item
}
item.selected = true; item.selected = true;
arr.push(item.id) arr.push(item.id)
}); });
@ -355,12 +336,24 @@ const toggleAllSelection = () => {
buttons2.value.forEach((item) => { buttons2.value.forEach((item) => {
item.selected = false; item.selected = false;
}); });
// -
resetMode()
} }
emit('changeArea', arr) emit('changeArea', arr)
}; };
// 线
const thisButton2 = ref({
code: '',
mode: {
value: -1
},
scene: {
value: -1
}
})
// //
const toggleSelection = (button: any) => { const changeLine = (button: any) => {
// ID/ // ID/
handleButton.value = button.id handleButton.value = button.id
// / // /
@ -373,13 +366,13 @@ const toggleSelection = (button: any) => {
// //
let level1 = selectedButton.value let level1 = selectedButton.value
let level2 = button.id let level2 = button.id
// false // false
if (singleSelection.value) { if (singleSelection.value) {
buttons2.value.forEach(item => { buttons2.value.forEach(item => {
item.selected = false; item.selected = false;
}); });
emit('changeArea', [level1, level2])
button.selected = !button.selected; button.selected = !button.selected;
emit('changeArea', [level1, level2])
} else { } else {
// //
button.selected = !button.selected; button.selected = !button.selected;
@ -396,7 +389,7 @@ const toggleSelection = (button: any) => {
// //
thisButton2.value = button thisButton2.value = button
} else { } else {
// //
resetMode() resetMode()
} }
console.log(thisButton2,'button') console.log(thisButton2,'button')
@ -411,28 +404,17 @@ const limitedButtons2 = computed(() => buttons2.value.slice(0, 8));
// ==================================================================== // ====================================================================
const thisButton2 = ref({
code: '',
mode: {
value: '0'
}
})
// - // -
const selectButton3 = (button3) => { const selectButton3 = (button3) => {
let checked = thisButton2.value.mode let checked = thisButton2.value.mode
console.log(button3.value,'---', checked.value) console.log(button3.value,'---', checked.value)
// //
if (checked.value === button3.value) { if (checked.value === button3.value) {
return return
} }
checked.value = button3.value checked.value = button3.value
selectedButton4.value = null; //
}; };
const diff = () => {
console.log(thisButton2)
}
// ===================================================================== // =====================================================================
// //
@ -443,13 +425,63 @@ const controlScene = ref([])
const selectedButton4 = ref(null); const selectedButton4 = ref(null);
// - // -
const selectButton4 = (button4) => { const selectButton4 = (button4) => {
selectedButton4.value = button4.label; // 线
const data = thisButton2.value
//
let before = data.scene.value
//
let after = button4.value
//
if (before === after) {
return
//
} else {
thisButton2.value.scene.value = after
//
const result = changeList.value.find((item, index) => {
item.index = index
return item.deviceGroup == data.code
})
//
if (result) {
//
if (after == result.before) {
changeList.value.splice(result.index, 1)
// after
} else {
result.scene = after
// flag
delete result.index
}
//
} else {
changeList.value.push({
// 线
deviceGroup: data.code,
deviceGroupName: data.name,
//
region: data.pcode,
regionName: '',
//
before: before,
//
scene: after
})
}
console.log(changeList.value, 'changeList')
}
thisButton2.value.scene.value = after
console.log(thisButton2,'222222')
console.log(button4,'44444')
}; };
// ======================================================================== // ========================================================================
//
const changeList: any = ref([])
// //
const submitArray = ref([]) const submitList = ref([])
const cxList = ref([ const cxList = ref([
{ {
id: '1', id: '1',
@ -489,7 +521,7 @@ const cxList = ref([
}, },
]); ]);
// //
const delBtn = (id: any) => { const delBtn = () => {
cxList.value.pop(); cxList.value.pop();
console.log(cxList.value.length); console.log(cxList.value.length);
@ -501,19 +533,6 @@ const delBtn = (id: any) => {
// ======================================================================== // ========================================================================
const isLoading = ref(false) const isLoading = ref(false)
// 5
const initMenu = (tier: number) => {
// 1 = -
if (tier == 1) {
emit('reset')
//
selectedButton4.value = null;
} else if (tier == 2) {
//
selectedButton4.value = null;
}
}
// //
const refresh = () => { const refresh = () => {
// //
@ -532,7 +551,16 @@ const refresh = () => {
// //
const executeVisible = ref<boolean>(false); const executeVisible = ref<boolean>(false);
const showModal = () => { const showModal = () => {
http.post(lightingManage.getChangeList, { infoList: changeList.value, projectId: 'HLlmTZp8' }).then(res => {
if (res.msg === 'success') {
isLoading.value = true
console.log(res)
} else {
isLoading.value = false
}
})
executeVisible.value = true; executeVisible.value = true;
}; };
// //
@ -549,13 +577,20 @@ const resetMode = () => {
thisButton2.value = { thisButton2.value = {
code: '', code: '',
mode: { mode: {
value: '0' value: -1
},
scene: {
value: -1
} }
} }
} }
//
defineExpose({ defineExpose({
changeCancel //
changeArea,
// 线
changeLine
}); });
</script> </script>

Loading…
Cancel
Save