|
@@ -22,7 +22,7 @@
|
|
|
class="end-prop-title"
|
|
|
v-if="selection.cbOrder && selection.cbName"
|
|
|
>
|
|
|
- {{ selection.cbName + '(' + selection.cbOrder + ')' }}
|
|
|
+ {{ selection.area + ' - ' + selection.cbName + '(' + selection.cbOrder + ')' }}
|
|
|
</div>
|
|
|
<div v-if="universal">
|
|
|
<div class="end-prop-item" v-for="(item, index) in universal" :key="index" v-if="item.name">
|
|
@@ -35,7 +35,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getBoxDetailById } from "@/api/box";
|
|
|
+import { getBoxDetailById, detailAppratusDevice } from "@/api/box";
|
|
|
import { getRunState } from "@/api/box-debug";
|
|
|
import { currentUserName } from "@/utils/trace";
|
|
|
export default {
|
|
@@ -63,7 +63,9 @@ export default {
|
|
|
selection: {
|
|
|
id: undefined,
|
|
|
cbOrder: undefined,
|
|
|
- cbName: undefined
|
|
|
+ cbName: undefined,
|
|
|
+ area: undefined,
|
|
|
+ cbDeviceSeries: undefined
|
|
|
},
|
|
|
// 属性
|
|
|
universal: [],
|
|
@@ -92,15 +94,25 @@ export default {
|
|
|
const data = JSON.parse(res.result);
|
|
|
const end = data.end || {};
|
|
|
const standalone = end.standalone || [];
|
|
|
+ let selIndex = 0;
|
|
|
+
|
|
|
// 房间分组排序
|
|
|
+ const cbOrder = this.data.end_order || 0;
|
|
|
standalone.forEach((item, index) => {
|
|
|
- // 默认选中第一个
|
|
|
- item.selection = (index == 0);
|
|
|
+ // 计算默认选中的位置
|
|
|
+ if (item.cbOrder == cbOrder) {
|
|
|
+ item.selection = true;
|
|
|
+ selIndex = index;
|
|
|
+ } else {
|
|
|
+ item.selection = false;
|
|
|
+ }
|
|
|
+
|
|
|
// 房间名称放入数组,保证顺序
|
|
|
const areaIndex = this.areaList.findIndex((a) => a === item.area);
|
|
|
if (areaIndex < 0) {
|
|
|
this.areaList.push(item.area);
|
|
|
}
|
|
|
+
|
|
|
// 放入字典方便存取
|
|
|
let devices = this.areaMap[item.area];
|
|
|
if (!Array.isArray(devices) || !devices.length) {
|
|
@@ -110,12 +122,28 @@ export default {
|
|
|
this.areaMap[item.area] = devices;
|
|
|
});
|
|
|
|
|
|
- // 获取实时数据
|
|
|
- if (standalone.length > 0) {
|
|
|
- const first = standalone[0];
|
|
|
- this.selection.id = first.id;
|
|
|
- this.selection.cbOrder = first.cbOrder;
|
|
|
- this.selection.cbName = first.cbName;
|
|
|
+ // 计算已经选中的indexPath
|
|
|
+ for (let i = 0; i < this.areaList.length; i++) {
|
|
|
+ const area = this.areaList[i];
|
|
|
+ const deviceList = this.areaMap[area];
|
|
|
+ for (let j = 0; j < deviceList.length; j++) {
|
|
|
+ const device = deviceList[j];
|
|
|
+ if (device.cbOrder === cbOrder) {
|
|
|
+ this.lastIndexPath.section = i;
|
|
|
+ this.lastIndexPath.row = j;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取实时数据与设备详情
|
|
|
+ if (selIndex < standalone.length) {
|
|
|
+ const defSelection = standalone[selIndex];
|
|
|
+ this.selection.id = defSelection.id;
|
|
|
+ this.selection.cbOrder = defSelection.cbOrder;
|
|
|
+ this.selection.cbName = defSelection.cbName;
|
|
|
+ this.selection.area = defSelection.area;
|
|
|
+ this.selection.cbDeviceSeries = defSelection.cbDeviceSeries;
|
|
|
this.getRunState();
|
|
|
}
|
|
|
}
|
|
@@ -136,6 +164,18 @@ export default {
|
|
|
this.universal.push(element.read_io.universal || []);
|
|
|
}
|
|
|
}
|
|
|
+ this.getDeviceDetail(this.selection.cbDeviceSeries);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取设备详情接口
|
|
|
+ async getDeviceDetail(deviceId) {
|
|
|
+ const res = await detailAppratusDevice({
|
|
|
+ device_id: deviceId
|
|
|
+ });
|
|
|
+ if (res.code === 200) {
|
|
|
+ const result = res.result || {};
|
|
|
+ const deviceName = result.device_name || '';
|
|
|
+ this.universal.splice(0, 0, { name: '设备型号', value: deviceName });
|
|
|
}
|
|
|
},
|
|
|
// 点击
|
|
@@ -156,6 +196,8 @@ export default {
|
|
|
this.selection.id = device.id;
|
|
|
this.selection.cbOrder = device.cbOrder;
|
|
|
this.selection.cbName = device.cbName;
|
|
|
+ this.selection.area = device.area;
|
|
|
+ this.selection.cbDeviceSeries = device.cbDeviceSeries;
|
|
|
this.getRunState();
|
|
|
|
|
|
this.lastIndexPath.section = section;
|