Browse Source

fix:照明系统多选功能完善,引入全局变量projectId,部分交互逻辑修改

temp
chenpingsen 4 months ago
parent
commit
b55304ef7f
  1. 6
      hx-ai-intelligent/src/api/IlluminationInfo.ts
  2. 9
      hx-ai-intelligent/src/store/item.ts
  3. 37
      hx-ai-intelligent/src/view/equipmentControl/lightingManage/indexs.vue
  4. 3
      hx-ai-intelligent/src/view/equipmentControl/lightingManage/lightPosition.ts
  5. 72
      hx-ai-intelligent/src/view/equipmentControl/lightingManage/tabs1.vue

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

@ -1,13 +1,13 @@
// 照明系统及相关接口 // 照明系统及相关接口
export enum lightingManage { export enum lightingManage {
// 主页 ======================================================== // 主页 ========================================================
// 获得分区与线路 // 获得分区与线路
getArea = '/carbon-smart/IlluminationInfo/region', getArea = '/carbon-smart/IlluminationInfo/region',
// 修改线路的可用/禁用状态 // 修改线路的可用/禁用状态
setDisable = '/carbon-smart/IlluminationInfo/revisePanel', setDisable = '/carbon-smart/IlluminationInfo/changePanelStatus',
// 获得设备 - 小灯泡
getBulbs = '/carbon-smart/IlluminationInfo/getLightState',
// 控制面板tab页 ================================================ // 控制面板tab页 ================================================

9
hx-ai-intelligent/src/store/item.ts

@ -3,7 +3,14 @@ import { defineStore } from 'pinia';
export const items = defineStore({ export const items = defineStore({
id: 'items', id: 'items',
state() { state() {
return { list: [], count: 10 }; return {
list: [],
count: 10,
// 当前项目ID
projectId: 'HLlmTZp8',
// 站点ID
siteId: undefined,
};
}, },
getters: { getters: {
double: (state: any) => state.count * 2, double: (state: any) => state.count * 2,

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

@ -3,9 +3,13 @@
<div class="lighting-img-box"> <div class="lighting-img-box">
<!-- 左上角区域切换 --> <!-- 左上角区域切换 -->
<div class="btn-box"> <div class="btn-box">
<button v-for="item in floorData" class="btn-item" @click="changeFloor(item.childList)">{{ <button
item.name v-for="(item, index) in floorData"
}}</button> :key="index"
class="btn-item"
@click="changeFloor(item.childList, item.code)"
>{{ item.name }}</button
>
</div> </div>
<!-- 楼层区域 --> <!-- 楼层区域 -->
<div class="area"> <div class="area">
@ -77,14 +81,20 @@
import { lightingManage } from '/@/api/IlluminationInfo'; import { lightingManage } from '/@/api/IlluminationInfo';
// ICON // ICON
import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons-vue'; import { DoubleLeftOutlined, DoubleRightOutlined } from '@ant-design/icons-vue';
//
import { items } from '/@/store/item';
// ======================================================= // =======================================================
onMounted(() => { onMounted(() => {
// 线 // 线
getAllArea(); getAllArea();
//
getBulbs();
}); });
//
const state = items();
// flagref // flagref
const preload = ref(false); const preload = ref(false);
@ -92,8 +102,11 @@
// //
const floorData = ref([]); const floorData = ref([]);
//
const thisFloor = ref(1);
// //
const changeFloor = (area: any) => { const changeFloor = (area: any, floor: number) => {
thisFloor.value = floor;
// //
reset(); reset();
// //
@ -220,7 +233,7 @@
// //
const getAllArea = () => { const getAllArea = () => {
http.get(lightingManage.getArea, { projectId: 'HLlmTZp8' }).then((res) => { http.get(lightingManage.getArea, { projectId: state.projectId }).then((res) => {
const data = res.data; const data = res.data;
floorData.value = 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 // - tab

3
hx-ai-intelligent/src/view/equipmentControl/lightingManage/lightPosition.ts

@ -0,0 +1,3 @@
// 此文件只定义light(即俯视图小灯泡)的位置信息
// 与显示状态和分组信息无关
export const lightPosition = [];

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

@ -50,7 +50,7 @@
class="openPlan" class="openPlan"
:class="{ enabled2: isPlanEnabled2, disabled2: !isPlanEnabled2 }" :class="{ enabled2: isPlanEnabled2, disabled2: !isPlanEnabled2 }"
@click="togglePlan2"> @click="togglePlan2">
{{ isPlanEnabled2 ? '启用面板' : '禁用面板' }} {{ isPlanEnabled2 ? '启用开关' : '禁用开关' }}
</button> </button>
<a-switch <a-switch
v-model:checked="selectAllCheckbox" v-model:checked="selectAllCheckbox"
@ -248,11 +248,13 @@
import { http } from '/nerv-lib/util/http'; import { http } from '/nerv-lib/util/http';
import { lightingManage } from '/@/api/IlluminationInfo'; import { lightingManage } from '/@/api/IlluminationInfo';
import { getAllEnum } from '/@/api/index'; import { getAllEnum } from '/@/api/index';
//
import { items } from '/@/store/item';
// ========================================================================= // =========================================================================
onMounted(() => { onMounted(() => {
// //
setArea(); setArea();
// //
getEnum(['IlluminationMode', 'IlluminationScene']); getEnum(['IlluminationMode', 'IlluminationScene']);
@ -267,11 +269,13 @@
controlScene.value = data.IlluminationScene; controlScene.value = data.IlluminationScene;
}); });
}; };
// 1-1 // 1-1
const setArea = () => { const setArea = () => {
const data = props.treeData[0]; const data = props.treeData[0];
buttons2.value = data.childList; buttons2.value = data.childList;
}; };
//
const state = items();
// =================================================================== // ===================================================================
@ -279,11 +283,12 @@
// > // >
treeData: { treeData: {
type: Array, type: Array,
default: [], default: () => {
[];
},
}, },
}); });
// /**
/**
* @method changeArea 用于控制俯视图的选中状态 * @method changeArea 用于控制俯视图的选中状态
* @method reset 用于重置按钮区 * @method reset 用于重置按钮区
*/ */
@ -327,9 +332,9 @@
// id // id
const handleButton = ref(''); const handleButton = ref('');
// / // /
const isPlanEnabled2 = ref(true); const isPlanEnabled2 = ref(true);
// / // /
const togglePlan2 = () => { const togglePlan2 = () => {
// //
if (handleButton.value == '') { if (handleButton.value == '') {
@ -340,7 +345,12 @@
let panel = +!btn.ctrlStatus; let panel = +!btn.ctrlStatus;
isLoading.value = true; isLoading.value = true;
http http
.get(lightingManage.setDisable, { deviceGroup: btn.code, panel }) .get(lightingManage.setDisable, {
deviceGroup: btn.code,
panel,
projectId: state.projectId,
siteId: state.siteId,
})
.then((res) => { .then((res) => {
if (res.msg === 'success') { if (res.msg === 'success') {
// - - - loading // - - - loading
@ -392,7 +402,7 @@
buttons2.value.forEach((item: any) => { buttons2.value.forEach((item: any) => {
item.selected = false; item.selected = false;
}); });
// - //
resetMode(); resetMode();
} }
emit('changeArea', arr); emit('changeArea', arr);
@ -423,7 +433,7 @@
// //
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: any) => { buttons2.value.forEach((item: any) => {
item.selected = false; item.selected = false;
@ -486,16 +496,38 @@
let before = data.scene.value; let before = data.scene.value;
// //
let after = button4.value; let after = button4.value;
//
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) { if (before === after) {
return message.info('未产生实际修改'); return message.info('未产生实际修改');
// //
} else { } else {
thisButton2.value.scene.value = after; 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) => { const result = changeList.value.find((item: any, index: number) => {
item.index = index; item.index = index;
return item.deviceGroup == data.code; return item.deviceGroup == button.code;
}); });
// //
if (result) { if (result) {
@ -512,10 +544,10 @@
} else { } else {
changeList.value.push({ changeList.value.push({
// //
deviceGroup: data.code, deviceGroup: button.code,
deviceGroupName: data.name, deviceGroupName: button.name,
// //
region: data.pcode, region: button.pcode,
regionName: '', regionName: '',
// //
before: before, before: before,
@ -523,8 +555,6 @@
scene: after, scene: after,
}); });
} }
console.log(changeList.value, 'changeList');
}
thisButton2.value.scene.value = after; thisButton2.value.scene.value = after;
}; };
@ -559,7 +589,11 @@
} }
buttonLoading.value = true; buttonLoading.value = true;
http http
.post(lightingManage.getChangeList, { infoList: changeList.value, projectId: 'HLlmTZp8' }) .post(lightingManage.getChangeList, {
infoList: changeList.value,
projectId: state.projectId,
siteId: state.siteId,
})
.then((res) => { .then((res) => {
if (res.msg === 'success') { if (res.msg === 'success') {
diffList.value = res.data; diffList.value = res.data;

Loading…
Cancel
Save