hldy_yunwei_vue/src/views/iot/tplink/camera/index.vue

286 lines
7.1 KiB
Vue

<!--
<template>
<a-row class="p-2" type="flex" :gutter="10">
<a-col :xl="4" :lg="24" :md="24" style="margin-bottom: 10px">
<CameraLeftTree ref="leftTree" @select="onTreeSelect" @rootTreeData="onRootTreeData" />
</a-col>
<a-col :xl="20" :lg="24" :md="24" style="margin-bottom: 10px">
<div v-show="cameraData != null">
<CameraInfoList :data="cameraData" />
</div>
<div v-show="cameraData == null" style="padding-top: 40px">
<a-empty description="请选择区域" />
</div>
</a-col>
</a-row>
</template>
<script lang="ts" name="iot-nuIotCameraInfo" setup>
import { ref } from 'vue';
import { useDesign } from '/@/hooks/web/useDesign';
import CameraLeftTree from './components/CameraLeftTree.vue'
import CameraInfoList from './components/CameraInfoList.vue';
// 给子组件定义一个ref变量
const leftTree = ref();
// 当前选中的区域信息
const cameraData = ref({});
const rootTreeData = ref<any[]>([]);
// 左侧树选择后触发
function onTreeSelect(data) {
cameraData.value = data;
}
// 左侧树rootTreeData触发
function onRootTreeData(data) {
rootTreeData.value = data;
}
</script>
<style lang="less" scoped>
.p-2{
height: calc(100vh - 120px);
}
</style>
-->
<template>
<a-spin :spinning="confirmLoading">
<div class="p-2">
<!--引用表格-->
<BasicTable @register="registerTable">
<!--插槽:table标题-->
<template #tableTitle>
<a-button type="primary" preIcon="ant-design:sync-outlined" @click="handleSync"> 拉取设备</a-button>
<a-button type="primary" preIcon="ant-design:sync-outlined" @click="handleSyncStatus"> 更新状态</a-button>
<a-button type="primary" preIcon="ant-design:setting-outlined" @click="handleConfig"> 配置管理</a-button>
</template>
<!--操作栏-->
<template #action="{ record }">
<TableAction :actions="getTableAction(record)"/>
</template>
<template v-slot:bodyCell="{ column, record, index, text }">
</template>
</BasicTable>
<!-- 表单区域 -->
<CameraPreviewModal ref="previewModal"></CameraPreviewModal>
<CameraPictureConfigModal ref="cameraPictureConfigModal"></CameraPictureConfigModal>
<DrawerModal ref="registerDrawer" @success="handleSuccess" />
</div>
</a-spin>
</template>
<script lang="ts" name="iot-nuIotCameraInfo" setup>
import {ref, reactive, createVNode, h, onMounted, watch, unref,nextTick} from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns, searchFormSchema } from './camera.data';
import {getImageCommon, getDeviceDetails, list, syncAllDevices,syncDevicesStatus} from './camera.api';
import { useUserStore } from '/@/store/modules/user';
// import { useDrawer } from "@/components/Drawer";
import CameraPreviewModal from './components/CameraPreviewModal.vue'
import DrawerModal from './components/DrawerModal.vue'
import CameraPictureConfigModal from './components/CameraPictureConfigModal.vue';
//注册drawer
// const [registerDrawer, { openDrawer }] = useDrawer();
const formRef = ref();
const queryParam = reactive<any>({});
const registerModal = ref();
const previewModal = ref();
const deviceModal = ref();
const registerDrawer = ref();
const cameraPictureConfigModal = ref();
const userStore = useUserStore();
const confirmLoading = ref<boolean>(false);
//注册table数据
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '监控设备',
api: list,
columns,
canResize: false,
showIndexColumn: true,
formConfig: {
// labelWidth: 200,
schemas: searchFormSchema,
},
actionColumn: {
width: 180,
fixed: 'right',
},
beforeFetch: async (params) => {
queryParam.routeType = 'camera';
return Object.assign(params, queryParam);
},
},
});
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
const labelCol = reactive({
xs:24,
sm:4,
xl:6,
xxl:4
});
const wrapperCol = reactive({
xs: 24,
sm: 20,
});
/**
* 编辑
*/
function handleEdit(record: Recordable) {
// openDrawer(true, {
// record,
// isUpdate: true,
// showFooter: true,
// tenantSaas: false,
// });
registerDrawer.value.disableSubmit = false;
registerDrawer.value.edit(record);
}
function handleConfig(){
registerDrawer.value.disableSubmit = false;
registerDrawer.value.configEdit();
}
/**
* 预览
*/
function handlePreview(record: Recordable) {
if (record.deviceIndex == null) {
return
}
// getDeviceDetails({
// "deviceIndex": record.deviceIndex
// }).then(res => {
record.streamType = 1;
previewModal.value.disableSubmit = true;
previewModal.value.edit(record);
// }).catch(res=>{
// reload();
// });
}
/**
* 成功回调
*/
function handleSuccess() {
reload();
}
/**
* 画面配置
*/
function handlePicConfig(record) {
if (record.deviceIndex == null) {
return
}
// getDeviceDetails({
// "deviceIndex": record.deviceIndex
// }).then(res => {
var params = {
deviceIndex: record.deviceIndex,
deviceName: record.deviceName,
parentId: record.parentId,
multitrans: record.multitrans,
projectId: record.projectId,
regionId: record.regionId,
ip: record.ip
}
// nextTick(()=>{
cameraPictureConfigModal.value.disableSubmit = true;
cameraPictureConfigModal.value.edit(params);
// })
// }).catch(res=>{
// reload();
// });
}
/**
* 操作栏
*/
function getTableAction(record) {
return [
{
label: '画面配置',
onClick: handlePicConfig.bind(null, record),
ifShow: record.deviceType == 'SURVEILLANCECAMERA'
},
{
label: '编辑',
onClick: handleEdit.bind(null, record),
},
{
label: '预览',
onClick: handlePreview.bind(null, record),
ifShow: record.deviceType == 'SURVEILLANCECAMERA'
},
];
}
/**
* 同步设备
*/
async function handleSync(){
confirmLoading.value = true;
//摄像头、录像机
await syncAllDevices({deviceType: "SURVEILLANCECAMERA,NETWORKVIDEORECORDER"}).then((res) => {
confirmLoading.value = false;
reload();
});
}
/**
* 更新状态
*/
async function handleSyncStatus(){
confirmLoading.value = true;
await syncDevicesStatus({deviceType: "SURVEILLANCECAMERA,NETWORKVIDEORECORDER"}).then((res) => {
confirmLoading.value = false;
reload();
});
}
</script>
<style lang="less" scoped>
.jeecg-basic-table-form-container {
padding: 0;
.table-page-search-submitButtons {
display: block;
margin-bottom: 24px;
white-space: nowrap;
}
.query-group-cust{
min-width: 100px !important;
}
.query-group-split-cust{
width: 30px;
display: inline-block;
text-align: center
}
.ant-form-item:not(.ant-form-item-with-help){
margin-bottom: 16px;
height: 32px;
}
:deep(.ant-picker),:deep(.ant-input-number){
width: 100%;
}
}
.p-2{
height: calc(100vh - 120px);
}
</style>