|
@@ -28,9 +28,7 @@
|
|
|
<WarningFilled v-if="isInvalid(data)" class="invalidCamera" style="color: red" />
|
|
<WarningFilled v-if="isInvalid(data)" class="invalidCamera" style="color: red" />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="cameraName">{{ node.label }}</div>
|
|
<div class="cameraName">{{ node.label }}</div>
|
|
|
- <Thumbnail :imageUrl="data.imageUrl" :code="data.code" position="right">
|
|
|
|
|
- <div class="mask"></div>
|
|
|
|
|
- </Thumbnail>
|
|
|
|
|
|
|
+ <div class="mask"></div>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</el-tree>
|
|
</el-tree>
|
|
@@ -51,10 +49,18 @@
|
|
|
batchSaveSensor2GroupApi,
|
|
batchSaveSensor2GroupApi,
|
|
|
deleteSensorFromGroupApi,
|
|
deleteSensorFromGroupApi,
|
|
|
queryDeviceListApi,
|
|
queryDeviceListApi,
|
|
|
|
|
+ querySensorGroupListApi,
|
|
|
saveSensor2GroupApi,
|
|
saveSensor2GroupApi,
|
|
|
|
|
+ updateSensorGroupApi,
|
|
|
} from '@/api/sensor-group';
|
|
} from '@/api/sensor-group';
|
|
|
- import type { DeviceListItem, SensorGroupView, SensorDeviceViewItem } from '@/api/sensor-group/type';
|
|
|
|
|
- import Thumbnail from '@/components/thumbnail/Thumbnail.vue';
|
|
|
|
|
|
|
+ import type {
|
|
|
|
|
+ DeviceListItem,
|
|
|
|
|
+ ProductionSensorGroup,
|
|
|
|
|
+ SensorGroupView,
|
|
|
|
|
+ SensorDeviceViewItem,
|
|
|
|
|
+ } from '@/api/sensor-group/type';
|
|
|
|
|
+ import { userGridType } from '@/store/modules/userGridType';
|
|
|
|
|
+ import { GridType } from '../../type';
|
|
|
|
|
|
|
|
enum CameraTreeNodeType {
|
|
enum CameraTreeNodeType {
|
|
|
group = 'group',
|
|
group = 'group',
|
|
@@ -85,8 +91,9 @@
|
|
|
// 已在分组中的设备 code(deviceNo),用于初始勾选
|
|
// 已在分组中的设备 code(deviceNo),用于初始勾选
|
|
|
const initialCheckedKeys = computed(() => groupSensors.value.map((s) => s.code));
|
|
const initialCheckedKeys = computed(() => groupSensors.value.map((s) => s.code));
|
|
|
|
|
|
|
|
- const { cameraInPlay, cameraGroupList } = storeToRefs(useCameraGroupList());
|
|
|
|
|
- const { restartPlay } = useCameraGroupList();
|
|
|
|
|
|
|
+ const { cameraInPlay, cameraGroupList, isPlaying, isPaused, playIntervalTime } = storeToRefs(useCameraGroupList());
|
|
|
|
|
+ const { restartPlay, setPlayGroup, groupStartPlay } = useCameraGroupList();
|
|
|
|
|
+ const { changeGridType } = userGridType();
|
|
|
|
|
|
|
|
function syncGroupSensors(newSensors: SensorDeviceViewItem[]) {
|
|
function syncGroupSensors(newSensors: SensorDeviceViewItem[]) {
|
|
|
const targetGroup = cameraGroupList.value.find((x: any) => x.id === props.cameraGroup.id) as
|
|
const targetGroup = cameraGroupList.value.find((x: any) => x.id === props.cameraGroup.id) as
|
|
@@ -96,6 +103,24 @@
|
|
|
targetGroup.details = newSensors;
|
|
targetGroup.details = newSensors;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ function normalizeSensorGroups(list: ProductionSensorGroup[]): SensorGroupView[] {
|
|
|
|
|
+ return (list || []).map((group) => {
|
|
|
|
|
+ const details: SensorDeviceViewItem[] = (group.details || []).map((detail) => ({
|
|
|
|
|
+ id: detail.sensorId,
|
|
|
|
|
+ code: detail.deviceNo,
|
|
|
|
|
+ name: detail.deviceName,
|
|
|
|
|
+ status: detail.status,
|
|
|
|
|
+ }));
|
|
|
|
|
+
|
|
|
|
|
+ return {
|
|
|
|
|
+ ...group,
|
|
|
|
|
+ isPaused: group.isPaused ?? 1,
|
|
|
|
|
+ details,
|
|
|
|
|
+ children: details,
|
|
|
|
|
+ } as any;
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
async function loadDeviceList(deviceName = '') {
|
|
async function loadDeviceList(deviceName = '') {
|
|
|
treeLoading.value = true;
|
|
treeLoading.value = true;
|
|
|
try {
|
|
try {
|
|
@@ -127,37 +152,64 @@
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (addedDeviceNoList.length === 1) {
|
|
if (addedDeviceNoList.length === 1) {
|
|
|
|
|
+ const addedDevice = deviceList.value.find((item) => item.deviceNo === addedDeviceNoList[0]);
|
|
|
await saveSensor2GroupApi({
|
|
await saveSensor2GroupApi({
|
|
|
groupId: props.cameraGroup.id,
|
|
groupId: props.cameraGroup.id,
|
|
|
deviceNo: addedDeviceNoList[0],
|
|
deviceNo: addedDeviceNoList[0],
|
|
|
orderNum: props.cameraGroup.details.length + 1,
|
|
orderNum: props.cameraGroup.details.length + 1,
|
|
|
|
|
+ deviceName: addedDevice?.deviceName || '',
|
|
|
|
|
+ status: addedDevice?.deviceStatus || '',
|
|
|
});
|
|
});
|
|
|
} else if (addedDeviceNoList.length > 1) {
|
|
} else if (addedDeviceNoList.length > 1) {
|
|
|
await batchSaveSensor2GroupApi({
|
|
await batchSaveSensor2GroupApi({
|
|
|
groupId: props.cameraGroup.id,
|
|
groupId: props.cameraGroup.id,
|
|
|
- deviceNoList: addedDeviceNoList,
|
|
|
|
|
|
|
+ deviceList: addedDeviceNoList.map((deviceNo) => {
|
|
|
|
|
+ const device = deviceList.value.find((item) => item.deviceNo === deviceNo);
|
|
|
|
|
+ return {
|
|
|
|
|
+ deviceNo,
|
|
|
|
|
+ deviceName: device?.deviceName || '',
|
|
|
|
|
+ status: device?.deviceStatus || '',
|
|
|
|
|
+ };
|
|
|
|
|
+ }),
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新本地状态
|
|
// 更新本地状态
|
|
|
- const newSensors: SensorDeviceViewItem[] = checkedNodes.map((n) => ({
|
|
|
|
|
- id: n.id,
|
|
|
|
|
- cameraGroupDetailId: n.id,
|
|
|
|
|
- code: n.code,
|
|
|
|
|
- name: n.name,
|
|
|
|
|
- url: '',
|
|
|
|
|
- imageUrl: n.imageUrl || '',
|
|
|
|
|
- status: n.disable ? 'offline' : 'online',
|
|
|
|
|
- }));
|
|
|
|
|
|
|
+ const newSensors: SensorDeviceViewItem[] = checkedNodes.map((n) => {
|
|
|
|
|
+ const device = deviceList.value.find((item) => item.deviceNo === n.code);
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: n.id,
|
|
|
|
|
+ code: n.code,
|
|
|
|
|
+ name: device?.deviceName || n.name,
|
|
|
|
|
+ status: device?.deviceStatus || '',
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
syncGroupSensors(newSensors);
|
|
syncGroupSensors(newSensors);
|
|
|
|
|
|
|
|
|
|
+ // 与初始化逻辑一致:保存后刷新分组列表并重置右侧播放数据
|
|
|
|
|
+ const latestGroupList = await querySensorGroupListApi();
|
|
|
|
|
+ cameraGroupList.value = normalizeSensorGroups(latestGroupList) as any;
|
|
|
|
|
+
|
|
|
|
|
+ const defaultGroup = cameraGroupList.value.find((x) => x.isDefault === 1) as unknown as SensorGroupView;
|
|
|
|
|
+ if (defaultGroup) {
|
|
|
|
|
+ await updateSensorGroupApi({
|
|
|
|
|
+ groupId: defaultGroup.id,
|
|
|
|
|
+ isDefault: 1,
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ isPlaying.value = true;
|
|
|
|
|
+ setPlayGroup({ ...(defaultGroup as any), children: defaultGroup.details } as any);
|
|
|
|
|
+ playIntervalTime.value = defaultGroup.refreshIntervalSec || 60;
|
|
|
|
|
+ isPaused.value = !defaultGroup.isPaused;
|
|
|
|
|
+ changeGridType(GridType.nineGrids);
|
|
|
|
|
+ groupStartPlay(playIntervalTime.value);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 移除已不在分组中的正在播放的传感器
|
|
// 移除已不在分组中的正在播放的传感器
|
|
|
cameraInPlay.value = cameraInPlay.value.map((x) => {
|
|
cameraInPlay.value = cameraInPlay.value.map((x) => {
|
|
|
const stillExists = newSensors.find((s) => s.id === x.id);
|
|
const stillExists = newSensors.find((s) => s.id === x.id);
|
|
|
- return stillExists
|
|
|
|
|
- ? x
|
|
|
|
|
- : { ...x, id: -Date.now(), cameraGroupDetailId: -Date.now(), name: '', code: '', url: '', imageUrl: '' };
|
|
|
|
|
|
|
+ return stillExists ? x : { ...x, id: -Date.now(), name: '', code: '' };
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
restartPlay();
|
|
restartPlay();
|
|
@@ -175,8 +227,6 @@
|
|
|
id: device.id,
|
|
id: device.id,
|
|
|
code: device.deviceNo || String(device.id),
|
|
code: device.deviceNo || String(device.id),
|
|
|
name: device.deviceName || device.deviceNo || `设备${String(device.id).slice(-3)}`,
|
|
name: device.deviceName || device.deviceNo || `设备${String(device.id).slice(-3)}`,
|
|
|
- url: '',
|
|
|
|
|
- imageUrl: device.imgUrl || '',
|
|
|
|
|
nodeType: CameraTreeNodeType.camera,
|
|
nodeType: CameraTreeNodeType.camera,
|
|
|
networkingState: device.deviceStatus === 'offline' ? 1 : 0,
|
|
networkingState: device.deviceStatus === 'offline' ? 1 : 0,
|
|
|
disable: device.deviceStatus === 'offline',
|
|
disable: device.deviceStatus === 'offline',
|