|
|
@ -50,7 +50,7 @@ |
|
|
|
class="openPlan" |
|
|
|
:class="{ enabled2: isPlanEnabled2, disabled2: !isPlanEnabled2 }" |
|
|
|
@click="togglePlan2"> |
|
|
|
{{ isPlanEnabled2 ? '启用面板' : '禁用面板' }} |
|
|
|
{{ isPlanEnabled2 ? '启用开关' : '禁用开关' }} |
|
|
|
</button> |
|
|
|
<a-switch |
|
|
|
v-model:checked="selectAllCheckbox" |
|
|
@ -248,11 +248,13 @@ |
|
|
|
import { http } from '/nerv-lib/util/http'; |
|
|
|
import { lightingManage } from '/@/api/IlluminationInfo'; |
|
|
|
import { getAllEnum } from '/@/api/index'; |
|
|
|
// 全局变量 |
|
|
|
import { items } from '/@/store/item'; |
|
|
|
|
|
|
|
// 初始化 ========================================================================= |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
// 默认选项 |
|
|
|
// 分区初始化 |
|
|
|
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,16 +496,38 @@ |
|
|
|
let before = data.scene.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) { |
|
|
|
return message.info('未产生实际修改'); |
|
|
|
// 产生了修改 |
|
|
|
} 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) => { |
|
|
|
item.index = index; |
|
|
|
return item.deviceGroup == data.code; |
|
|
|
return item.deviceGroup == button.code; |
|
|
|
}); |
|
|
|
// 如果已产生过修改 |
|
|
|
if (result) { |
|
|
@ -512,10 +544,10 @@ |
|
|
|
} else { |
|
|
|
changeList.value.push({ |
|
|
|
// 回路 |
|
|
|
deviceGroup: data.code, |
|
|
|
deviceGroupName: data.name, |
|
|
|
deviceGroup: button.code, |
|
|
|
deviceGroupName: button.name, |
|
|
|
// 分区 |
|
|
|
region: data.pcode, |
|
|
|
region: button.pcode, |
|
|
|
regionName: '', |
|
|
|
// 修改前 |
|
|
|
before: before, |
|
|
@ -523,8 +555,6 @@ |
|
|
|
scene: after, |
|
|
|
}); |
|
|
|
} |
|
|
|
console.log(changeList.value, 'changeList'); |
|
|
|
} |
|
|
|
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; |
|
|
|