From b55304ef7f8af1050f4b57c2cc4e3cb53fe2fda4 Mon Sep 17 00:00:00 2001 From: chenpingsen Date: Mon, 29 Jul 2024 17:03:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E7=85=A7=E6=98=8E=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=A4=9A=E9=80=89=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84=EF=BC=8C?= =?UTF-8?q?=E5=BC=95=E5=85=A5=E5=85=A8=E5=B1=80=E5=8F=98=E9=87=8FprojectId?= =?UTF-8?q?=EF=BC=8C=E9=83=A8=E5=88=86=E4=BA=A4=E4=BA=92=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hx-ai-intelligent/src/api/IlluminationInfo.ts | 6 +- hx-ai-intelligent/src/store/item.ts | 9 +- .../equipmentControl/lightingManage/indexs.vue | 37 +++++- .../lightingManage/lightPosition.ts | 3 + .../view/equipmentControl/lightingManage/tabs1.vue | 128 +++++++++++++-------- 5 files changed, 127 insertions(+), 56 deletions(-) create mode 100644 hx-ai-intelligent/src/view/equipmentControl/lightingManage/lightPosition.ts diff --git a/hx-ai-intelligent/src/api/IlluminationInfo.ts b/hx-ai-intelligent/src/api/IlluminationInfo.ts index 0a8015e..113f7fa 100644 --- a/hx-ai-intelligent/src/api/IlluminationInfo.ts +++ b/hx-ai-intelligent/src/api/IlluminationInfo.ts @@ -1,13 +1,13 @@ - // 照明系统及相关接口 export enum lightingManage { - // 主页 ======================================================== // 获得分区与线路 getArea = '/carbon-smart/IlluminationInfo/region', // 修改线路的可用/禁用状态 - setDisable = '/carbon-smart/IlluminationInfo/revisePanel', + setDisable = '/carbon-smart/IlluminationInfo/changePanelStatus', + // 获得设备 - 小灯泡 + getBulbs = '/carbon-smart/IlluminationInfo/getLightState', // 控制面板tab页 ================================================ diff --git a/hx-ai-intelligent/src/store/item.ts b/hx-ai-intelligent/src/store/item.ts index 2b518c4..f3c2b57 100644 --- a/hx-ai-intelligent/src/store/item.ts +++ b/hx-ai-intelligent/src/store/item.ts @@ -3,7 +3,14 @@ import { defineStore } from 'pinia'; export const items = defineStore({ id: 'items', state() { - return { list: [], count: 10 }; + return { + list: [], + count: 10, + // 当前项目ID + projectId: 'HLlmTZp8', + // 站点ID + siteId: undefined, + }; }, getters: { double: (state: any) => state.count * 2, diff --git a/hx-ai-intelligent/src/view/equipmentControl/lightingManage/indexs.vue b/hx-ai-intelligent/src/view/equipmentControl/lightingManage/indexs.vue index e03748d..39fafd4 100644 --- a/hx-ai-intelligent/src/view/equipmentControl/lightingManage/indexs.vue +++ b/hx-ai-intelligent/src/view/equipmentControl/lightingManage/indexs.vue @@ -3,9 +3,13 @@
- +
@@ -77,14 +81,20 @@ import { lightingManage } from '/@/api/IlluminationInfo'; // ICON import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons-vue'; + // 全局变量 + import { items } from '/@/store/item'; // 初始化 ======================================================= onMounted(() => { // 获得分区与线路的结构 getAllArea(); + // 获得俯视图中的小灯泡 + getBulbs(); }); + // 获得全局变量 + const state = items(); // 预加载flag,获得分区数据后,预加载抽屉,防止获取ref报错 const preload = ref(false); @@ -92,8 +102,11 @@ // 所有楼层的数据 const floorData = ref([]); + // 当前选择的楼层 + const thisFloor = ref(1); // 左上角分层切换 - const changeFloor = (area: any) => { + const changeFloor = (area: any, floor: number) => { + thisFloor.value = floor; // 重置数据 reset(); // 重置视图 @@ -220,7 +233,7 @@ // 获得所有分区 const getAllArea = () => { - http.get(lightingManage.getArea, { projectId: 'HLlmTZp8' }).then((res) => { + http.get(lightingManage.getArea, { projectId: state.projectId }).then((res) => { const data = res.data; floorData.value = data; /** 只在前端使用的变量 @@ -248,6 +261,20 @@ }); }; + // 设备业务 小灯泡 ============================================== + + const getBulbs = () => { + http + .get(lightingManage.getBulbs, { + floor: thisFloor.value, + projectId: state.projectId, + siteId: state.siteId, + }) + .then((res) => { + console.log(res); + }); + }; + // 抽屉业务 ===================================================== // 抽屉 - 当前选择的tab diff --git a/hx-ai-intelligent/src/view/equipmentControl/lightingManage/lightPosition.ts b/hx-ai-intelligent/src/view/equipmentControl/lightingManage/lightPosition.ts new file mode 100644 index 0000000..1991f66 --- /dev/null +++ b/hx-ai-intelligent/src/view/equipmentControl/lightingManage/lightPosition.ts @@ -0,0 +1,3 @@ +// 此文件只定义light(即俯视图小灯泡)的位置信息 +// 与显示状态和分组信息无关 +export const lightPosition = []; diff --git a/hx-ai-intelligent/src/view/equipmentControl/lightingManage/tabs1.vue b/hx-ai-intelligent/src/view/equipmentControl/lightingManage/tabs1.vue index 55d6756..203e8f1 100644 --- a/hx-ai-intelligent/src/view/equipmentControl/lightingManage/tabs1.vue +++ b/hx-ai-intelligent/src/view/equipmentControl/lightingManage/tabs1.vue @@ -50,7 +50,7 @@ class="openPlan" :class="{ enabled2: isPlanEnabled2, disabled2: !isPlanEnabled2 }" @click="togglePlan2"> - {{ isPlanEnabled2 ? '启用面板' : '禁用面板' }} + {{ isPlanEnabled2 ? '启用开关' : '禁用开关' }} { - // 默认选项 + // 分区初始化 setArea(); // 获得枚举 getEnum(['IlluminationMode', 'IlluminationScene']); @@ -267,11 +269,13 @@ controlScene.value = data.IlluminationScene; }); }; - // 以 1-1 作为默认回路 + // 分区初始化,以 1-1 作为默认回路 const setArea = () => { const data = props.treeData[0]; buttons2.value = data.childList; }; + // 全局变量 + const state = items(); // 与父组件的交互 =================================================================== @@ -279,11 +283,12 @@ // 分区结构(照明区域 > 照明回路) treeData: { type: Array, - default: [], + default: () => { + []; + }, }, }); - // 向上传递修改选择样式 - /** + /** 向上传递方法 * @method changeArea 用于控制俯视图的选中状态 * @method reset 用于重置按钮区 */ @@ -327,9 +332,9 @@ // 最近交互过的按钮id,用于禁用和启用 const handleButton = ref(''); - // 面板启用/禁用状态 + // 开关启用/禁用状态 const isPlanEnabled2 = ref(true); - // 面板启用/禁用切换事件 + // 开关启用/禁用切换事件 const togglePlan2 = () => { // 如果未交互任何按钮 if (handleButton.value == '') { @@ -340,7 +345,12 @@ let panel = +!btn.ctrlStatus; isLoading.value = true; http - .get(lightingManage.setDisable, { deviceGroup: btn.code, panel }) + .get(lightingManage.setDisable, { + deviceGroup: btn.code, + panel, + projectId: state.projectId, + siteId: state.siteId, + }) .then((res) => { if (res.msg === 'success') { // 确认成功后 - 按钮文本取反 - 按钮布尔值修改 - 关闭loading @@ -392,7 +402,7 @@ buttons2.value.forEach((item: any) => { item.selected = false; }); - // 全不选时,隐藏模式-场景按钮 + // 全不选时,隐藏 模式 与 场景 按钮 resetMode(); } emit('changeArea', arr); @@ -423,7 +433,7 @@ // 选择时反控俯视图 let level1 = selectedButton.value; let level2 = button.id; - // 单选模式,需将所有其他按钮设为false + // 单选模式,需将所有其他回路设为false if (singleSelection.value) { buttons2.value.forEach((item: any) => { item.selected = false; @@ -486,44 +496,64 @@ let before = data.scene.value; // 修改后的数据 let after = button4.value; - // 如果没有产生实质性的修改(修改前后相同,则跳出) - if (before === after) { - return message.info('未产生实际修改'); - // 产生了修改 - } else { - thisButton2.value.scene.value = after; - // 查询之前是否修改过 - const result = changeList.value.find((item: any, index: number) => { - 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; + // 如果是多选模式 + if (!singleSelection.value) { + buttons2.value.forEach((item: any) => { + // 查看当前回路,哪些被选中 + if (item.selected) { + changeScene(item, item.scene.value, after); + item.scene.value = after; } - // 如果未产生过修改 + }); + thisButton2.value.scene.value = after; + return message.info('已修改X项'); + // 如果是单选模式 + } else { + // 如果没有产生实质性的修改(修改前后相同,则跳出) + if (before === after) { + return message.info('未产生实际修改'); + // 产生了修改 + } else { + changeScene(data, before, after); + } + } + }; + /** 控制场景 - 按钮切换通用方法(单选 & 多选) + * @param button 当前被选中的回路(单选 & 多选) + * @param before 回路场景的初始值(撤回时需使用) + * @param after 回路场景被修改后的值 + */ + const changeScene = (button: any, before: number, after: number) => { + // 查询之前是否修改过 + const result = changeList.value.find((item: any, index: number) => { + item.index = index; + return item.deviceGroup == button.code; + }); + // 如果已产生过修改 + if (result) { + // 改回了原有的值,则从数组中移除 + if (after == result.before) { + changeList.value.splice(result.index, 1); + // 修改为新值,则只修改after } else { - changeList.value.push({ - // 回路 - deviceGroup: data.code, - deviceGroupName: data.name, - // 分区 - region: data.pcode, - regionName: '', - // 修改前 - before: before, - // 修改后 - scene: after, - }); + result.scene = after; + // 临时flag,用后移除 + delete result.index; } - console.log(changeList.value, 'changeList'); + // 如果未产生过修改 + } else { + changeList.value.push({ + // 回路 + deviceGroup: button.code, + deviceGroupName: button.name, + // 分区 + region: button.pcode, + regionName: '', + // 修改前 + before: before, + // 修改后 + scene: after, + }); } thisButton2.value.scene.value = after; }; @@ -559,7 +589,11 @@ } buttonLoading.value = true; http - .post(lightingManage.getChangeList, { infoList: changeList.value, projectId: 'HLlmTZp8' }) + .post(lightingManage.getChangeList, { + infoList: changeList.value, + projectId: state.projectId, + siteId: state.siteId, + }) .then((res) => { if (res.msg === 'success') { diffList.value = res.data;