add:空调/照明群控系统交互逻辑增补 接口修改
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 照明回路部分 -->
|
||||
<!-- 空调分组部分 -->
|
||||
<div>
|
||||
<div class="circuit-area">
|
||||
<div class="circuit-tab"></div>
|
||||
@@ -136,7 +136,7 @@
|
||||
title="刷新将会取消已作出的修改"
|
||||
ok-text="确定"
|
||||
cancel-text="取消"
|
||||
@confirm="refresh"
|
||||
@confirm="refresh(false)"
|
||||
@cancel="changeCancel">
|
||||
<button class="flushed">刷新</button>
|
||||
</a-popconfirm>
|
||||
@@ -186,7 +186,7 @@
|
||||
<div class="btn-item">
|
||||
<div class="left"> 亮度 </div>
|
||||
<div class="right">
|
||||
<!-- 由于数字0也会被判为false,故只判断undefined 和 null -->
|
||||
<!-- 数字0也会被判为false,故只判断undefined 和 null -->
|
||||
<span>{{
|
||||
item?.stateBefore?.brightness != undefined ? item.stateBefore.brightness : '--'
|
||||
}}</span>
|
||||
@@ -231,7 +231,7 @@
|
||||
title="此操作将提交以上修改内容"
|
||||
ok-text="确定"
|
||||
cancel-text="取消"
|
||||
@click="submitChangeList"
|
||||
@confirm="submitChangeList"
|
||||
@cancel="changeCancel">
|
||||
<button class="execute">执行</button>
|
||||
</a-popconfirm>
|
||||
@@ -320,7 +320,7 @@
|
||||
const togglePlan2 = () => {
|
||||
// 如果未交互任何按钮
|
||||
if (handleButton.value == '') {
|
||||
return message.info('请选择照明回路');
|
||||
return message.info('请选择空调分组');
|
||||
}
|
||||
// 获取最近交互过的按钮
|
||||
const btn: any = buttons2.value.find((button: any) => button.id === handleButton.value);
|
||||
@@ -399,7 +399,6 @@
|
||||
});
|
||||
// 照明回路的按钮切换
|
||||
const changeLine = (button: any) => {
|
||||
console.log(button, 'button2mmmm');
|
||||
// 存储一次按钮ID,用于禁用/启用交互
|
||||
handleButton.value = button.id;
|
||||
// 根据按钮状态,展示禁用/启用按钮文本
|
||||
@@ -482,7 +481,7 @@
|
||||
// 操作线路总数
|
||||
let sum = 0;
|
||||
// 没有这个选项的线路
|
||||
let nofind = 0;
|
||||
// let nofind = 0;
|
||||
// 修改无效的数量
|
||||
let checked = 0;
|
||||
// 可修改的数量
|
||||
@@ -515,19 +514,20 @@
|
||||
return (checked += 1);
|
||||
// 修改
|
||||
} else {
|
||||
alert(v.treePid + '---' + before + '---' + after);
|
||||
changed += 1;
|
||||
resetScene(item.childList);
|
||||
changeScene(v1, before, after);
|
||||
changeScene(v1, before, after, item);
|
||||
v1.executeStatus.value = 1;
|
||||
}
|
||||
// 不符合条件的全部重置
|
||||
} else {
|
||||
v1.executeStatus.value = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
alert(`共修改${sum}条,${checked}条无需修改,${nofind}条不具有该选项,${changed}条生效`);
|
||||
message.info(`共修改${sum}条数据,其中${checked}条无需修改,${changed}条修改有效`);
|
||||
// 如果是单选模式
|
||||
} else {
|
||||
// 如果按钮已经被选择
|
||||
@@ -565,15 +565,15 @@
|
||||
/** 控制场景 - 按钮切换通用方法(单选 & 多选)
|
||||
* @param button 当前被选中的场景(单选 & 多选)
|
||||
* @param before 当前回路场景的初始值(撤回时需使用)
|
||||
* @param after 修改后的值(修改时使用)
|
||||
* @param anyButton 多选时使用
|
||||
*/
|
||||
const changeScene = (button: any, before: string | undefined, after: string) => {
|
||||
console.log(changeList.value, 'vvvvvvvvvvvvvv-----', button, 'bbbbbbbb---------');
|
||||
const changeScene = (button: any, before: string | undefined, after: string, line = null) => {
|
||||
// 通过分组ID,查询之前是否修改过
|
||||
const result = changeList.value.find((item: any, index: number) => {
|
||||
item.index = index;
|
||||
return item.deviceGroup == button.treePid.split('_')[0];
|
||||
});
|
||||
console.log(result, 'rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr');
|
||||
// 如果已产生过修改
|
||||
if (result) {
|
||||
// 改回了原有的值,则从数组中移除
|
||||
@@ -587,12 +587,20 @@
|
||||
}
|
||||
// 如果未产生过修改
|
||||
} else {
|
||||
let nowButton;
|
||||
// 多选,则使用第四个参数
|
||||
if (line) {
|
||||
nowButton = line;
|
||||
// 如果是单选,则使用thisbotton2
|
||||
} else {
|
||||
nowButton = thisButton2.value;
|
||||
}
|
||||
changeList.value.push({
|
||||
// 回路
|
||||
deviceGroup: thisButton2.value.dataCode,
|
||||
deviceGroupName: thisButton2.value.name,
|
||||
deviceGroup: nowButton.dataCode,
|
||||
deviceGroupName: nowButton.name,
|
||||
// 分区
|
||||
region: thisButton2.value.treePid,
|
||||
region: nowButton.treePid,
|
||||
regionName: '',
|
||||
// 修改前
|
||||
before,
|
||||
@@ -608,7 +616,7 @@
|
||||
// 执行按钮loading
|
||||
const buttonLoading = ref(false);
|
||||
// 刷新
|
||||
const refresh = () => {
|
||||
const refresh = (reload = false) => {
|
||||
// 关闭执行弹窗
|
||||
executeVisible.value = false;
|
||||
// 设置当前选中的序列
|
||||
@@ -616,10 +624,12 @@
|
||||
// 重置选中样式 和 按钮选中状态
|
||||
emit('changeArea', ['1']);
|
||||
emit('reset');
|
||||
// 将所有修改改回
|
||||
changeList.value.forEach((item: any) => {
|
||||
resetChangeList(item);
|
||||
});
|
||||
// 如果是中途刷新(对应提交后刷新),需要将所有修改改回
|
||||
if (!reload) {
|
||||
changeList.value.forEach((item: any) => {
|
||||
resetChangeList(item);
|
||||
});
|
||||
}
|
||||
changeList.value = [];
|
||||
// 默认选择第一个楼层
|
||||
let data = props.treeData[0];
|
||||
@@ -644,6 +654,10 @@
|
||||
if (item.scene == v3.dataCode) {
|
||||
v3.executeStatus.value = 0;
|
||||
}
|
||||
if (!item.before) {
|
||||
console.log(item, '没有这个选项');
|
||||
v3.executeStatus.value = 0;
|
||||
}
|
||||
// 旧值选中
|
||||
if (item.before == v3.dataCode) {
|
||||
v3.executeStatus.value = 1;
|
||||
@@ -695,6 +709,7 @@
|
||||
const diffList = ref([]);
|
||||
//撤销
|
||||
const delBtn = (obj: any) => {
|
||||
console.log(obj, '当前选择的修改内容');
|
||||
// 将treeData对应回路的数据改回,数据以后端为准
|
||||
obj.scene = obj.stateAfter.scene.value;
|
||||
obj.before = obj.stateBefore.scene.value;
|
||||
@@ -722,9 +737,9 @@
|
||||
projectId: state.projectId,
|
||||
siteId: state.siteId,
|
||||
})
|
||||
.then((res) => {
|
||||
.then(() => {
|
||||
emit('reload');
|
||||
refresh();
|
||||
refresh(true);
|
||||
});
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user