hi-ucs/front/src/views/home/infrastructureApplication.vue

465 lines
12 KiB
Vue
Raw Normal View History

2022-11-21 10:51:54 +08:00
<!--
* @Author: Light
* @Date: 2022-11-18 11:53:43
* @LastEditors: Light
2022-11-24 15:52:18 +08:00
* @LastEditTime: 2022-11-24 15:43:35
2022-11-21 10:51:54 +08:00
* @Description: 告诉大家这是什么
-->
<template>
2022-11-23 10:40:25 +08:00
<div class="infrastructureApplication" v-if="showFlag">
2022-11-21 10:51:54 +08:00
<div class="top">
<a-list size="small" bordered :data-source="dataList.toBeApplied">
<template #renderItem="{ item }">
<a-list-item>
<div class="name">
<a-tooltip>
<template #title>{{ item.channelName }}</template>
{{ item.channelName }}
</a-tooltip>
</div>
2022-11-21 18:46:38 +08:00
<a-popconfirm
:title="'是否移出' + item.channelName + '?'"
ok-text="是"
cancel-text="否"
@confirm="delWillApplyCamera(item.id)"
>
2022-11-22 11:51:58 +08:00
<a-button type="link" danger style="padding: 0">移出</a-button>
2022-11-21 18:46:38 +08:00
</a-popconfirm>
2022-11-21 10:51:54 +08:00
</a-list-item>
</template>
<template #header>
<div class="title">待申请列表</div>
</template>
<template #footer>
2022-11-21 18:46:38 +08:00
<a-button type="primary" @click="apply">一键申请</a-button>
2022-11-21 10:51:54 +08:00
</template>
</a-list>
</div>
<div class="bottom">
2022-11-21 18:46:38 +08:00
<a-list size="small" bordered :data-source="dataList.requested">
2022-11-21 10:51:54 +08:00
<template #renderItem="{ item }">
<a-list-item>
2022-11-22 19:29:50 +08:00
<div class="name">
2022-11-21 10:51:54 +08:00
<a-tooltip>
2022-11-21 18:46:38 +08:00
<template #title>{{ item.cameraInfo.channelName }}</template>
{{ item.cameraInfo.channelName }}
2022-11-21 10:51:54 +08:00
</a-tooltip>
</div>
2022-11-22 19:29:50 +08:00
<a-tag
color="cyan"
style="margin-right: 0"
@click="selectItem(item)"
>
{{ item.approveStatus == '通过' ? '预览' : item.approveStatus }}
2022-11-22 11:51:58 +08:00
</a-tag>
2022-11-21 18:46:38 +08:00
<a-popconfirm
v-if="item.approveStatus == '通过'"
2022-11-22 11:51:58 +08:00
:title="'是否撤销' + item.cameraInfo.channelName + '?'"
2022-11-21 18:46:38 +08:00
ok-text="是"
cancel-text="否"
@confirm="deleteApply(item)"
>
2022-11-22 11:51:58 +08:00
<a-button type="link" danger style="padding: 0">撤销</a-button>
2022-11-21 18:46:38 +08:00
</a-popconfirm>
2022-11-22 11:51:58 +08:00
<a-button
v-else
type="link"
danger
@click="deleteApply(item)"
style="padding: 0"
>
撤销
2022-11-21 18:46:38 +08:00
</a-button>
2022-11-21 10:51:54 +08:00
</a-list-item>
</template>
<template #header>
2022-11-22 19:16:10 +08:00
<div class="title">
已申请列表
<a-button type="link" @click="goToApply">详情</a-button>
</div>
2022-11-21 10:51:54 +08:00
</template>
</a-list>
</div>
</div>
2022-11-21 18:46:38 +08:00
<a-modal
:width="800"
v-model:visible="visible"
2022-11-22 11:51:58 +08:00
title="撤销申请"
2022-11-21 18:46:38 +08:00
@ok="handleOk"
@cancel="clear"
>
2022-11-22 11:51:58 +08:00
<p>本次申请的视频监控包含以下{{ showArr.length }}是否撤销申请</p>
<a-table
:columns="columns"
:data-source="showArr"
:pagination="{
pageSize: 5,
}"
>
2022-11-21 18:46:38 +08:00
<template #bodyCell="{ column, text }">
<template v-if="column.dataIndex === 'name'">
<a>{{ text }}</a>
</template>
</template>
</a-table>
</a-modal>
2022-11-22 14:51:18 +08:00
<a-modal
v-if="dataList.selectItem.cameraInfo"
v-model:visible="showVisible"
:title="dataList.selectItem.cameraInfo.channelName"
:footer="null"
@cancel="clear"
>
2022-11-22 19:16:10 +08:00
<div style="width: 100%; display: flex; justify-content: center">
<div style="width: 100%; height: 100%; position: relative">
<div class="waterMark waterMark-left-top">
{{ userInfo.usernameShow }}
2022-11-22 16:22:56 +08:00
</div>
2022-11-22 19:16:10 +08:00
<div class="waterMark waterMark-right-top">
{{ userInfo.realNameShow }}
</div>
<div class="waterMark waterMark-left-bottom">
{{ userInfo.usernameShow }}
</div>
<div class="waterMark waterMark-right-bottom">
{{ userInfo.realNameShow }}
</div>
<h5-player :video-url="videoUrl"></h5-player>
</div>
</div>
2022-11-22 14:51:18 +08:00
</a-modal>
2022-11-21 10:51:54 +08:00
</template>
<script setup>
import {
willApplyCameraSelect,
willApplyCameraBatchInsert,
willApplyCameraBatchDelete,
2022-11-21 18:46:38 +08:00
getApplyCameraListXha,
delApplyCamera,
2022-11-21 10:51:54 +08:00
} from '@/api/home'
2022-11-23 10:40:25 +08:00
import { getUserInfo, getRole } from '@/api/user'
2022-11-21 18:46:38 +08:00
import { endProcess } from '@/api/personalCenter.js'
2022-11-21 10:51:54 +08:00
import { onBeforeUnmount, reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
import mybus from '@/myplugins/mybus'
2022-11-21 18:46:38 +08:00
import { useRouter } from 'vue-router'
2022-11-22 16:22:56 +08:00
import H5Player from '@/views/home/components/H5Player.vue'
2022-11-22 19:16:10 +08:00
import { getCameraLiveStream } from '@/api/file'
2022-11-22 14:51:18 +08:00
const dataList = reactive({ toBeApplied: [], requested: [], selectItem: {} })
const showVisible = ref(false)
2022-11-21 10:51:54 +08:00
// 待办
const addWacFlag = ref(true)
const delWacFlag = ref(true)
2022-11-21 18:46:38 +08:00
const delApply = ref(true)
const visible = ref(false)
const instanceId = ref('')
const showArr = ref({})
const columns = [
{
title: '名称',
dataIndex: 'channelName',
key: 'channelName',
},
{
title: '地址',
dataIndex: 'managementUnitName',
key: 'managementUnitName',
},
{
title: '类型',
dataIndex: 'cameraPointTypeName',
key: 'cameraPointTypeName',
ellipsis: true,
},
]
const router = useRouter()
2022-11-23 10:40:25 +08:00
const showFlag = ref(false)
getUserInfo().then((res) => {
if (res.data.data.superAdmin == '1') {
showFlag.value = true
} else {
res.data.data.roleIdList.map((val) => {
getRole(val).then((role) => {
if (role.data.data.name === '视频管理员') {
showFlag.value = true
}
})
})
}
})
2022-11-21 10:51:54 +08:00
const delWillApplyCamera = (id) => {
2022-11-22 11:51:58 +08:00
console.log('撤销===>', id)
2022-11-21 10:51:54 +08:00
if (delWacFlag.value) {
delWacFlag.value = false
willApplyCameraBatchDelete([id]).then((res) => {
if (res.data.code == 0) {
message.success('移出成功')
} else {
message.warning('移出失败')
}
init()
})
}
}
2022-11-21 18:46:38 +08:00
const apply = () => {
let obj = {
arr: [
{
checked: true,
delFlag: 0,
id: '1593084734789996545',
idtCameraChannel: '790582098133127168',
loading: false,
note1: '',
resourceId: '1522550195055828996',
2022-11-22 11:51:58 +08:00
resourceName: '视频监控列表',
2022-11-21 18:46:38 +08:00
type: '基础设施',
},
],
deptName: '西海岸新区工业和信息化局',
deptId: '732560225344761856',
}
dataList.toBeApplied.map((val) => {
val.type = '基础设施'
val.delFlag = 0
val.resourceId = val.channelId
val.resourceName = val.channelName
// obj.arr.push(val)
})
obj.arr[0].note1 = JSON.stringify(dataList.toBeApplied)
if (obj.arr.length > 0) {
console.log('一键申请===================>', obj)
localStorage.setItem('applyList', JSON.stringify([obj]))
router.push({
path: '/apply',
})
}
}
2022-11-22 11:51:58 +08:00
// 撤销已申请
2022-11-21 18:46:38 +08:00
const deleteApply = (item) => {
2022-11-22 11:51:58 +08:00
console.log('撤销========>', item)
2022-11-21 18:46:38 +08:00
if (delApply.value) {
delApply.value = false
switch (item.approveStatus) {
case '审核中':
visible.value = true
instanceId.value = item.instanceId
showArr.value = []
dataList.requested.map((val) => {
if (val.instanceId == item.instanceId) {
showArr.value.push(val.cameraInfo)
}
})
break
case '通过':
delApplyCamera([item.id]).then((res) => {
if (res.data.code == 0) {
2022-11-22 11:51:58 +08:00
message.success('撤销成功')
2022-11-21 18:46:38 +08:00
} else {
2022-11-22 11:51:58 +08:00
message.warning('撤销失败')
2022-11-21 18:46:38 +08:00
}
initApply()
})
break
}
}
}
2022-11-22 19:16:10 +08:00
const goToApply = () => {
router.push({
path: '/personalCenter',
query: {
type: 'apply',
},
})
}
2022-11-22 14:51:18 +08:00
const selectItem = (item) => {
if (item.approveStatus == '通过') {
dataList.selectItem = item
2022-11-22 19:16:10 +08:00
getVideoUrl(item.cameraInfo)
2022-11-22 14:51:18 +08:00
} else {
dataList.selectItem = {}
showVisible.value = false
}
}
2022-11-21 18:46:38 +08:00
const handleOk = () => {
2022-11-24 15:52:18 +08:00
console.log('id', instanceId.value)
2022-11-21 18:46:38 +08:00
endProcess({ instanceId: instanceId.value }).then((res) => {
if (res.data.code == 0) {
2022-11-22 11:51:58 +08:00
message.success('撤销成功')
2022-11-21 18:46:38 +08:00
} else {
2022-11-22 11:51:58 +08:00
message.warning('撤销失败')
2022-11-21 18:46:38 +08:00
}
initApply()
visible.value = false
})
}
const clear = () => {
2022-11-22 14:51:18 +08:00
console.log('清空')
2022-11-21 18:46:38 +08:00
instanceId.value = ''
showArr.value = []
visible.value = false
delApply.value = true
2022-11-22 14:51:18 +08:00
dataList.selectItem = {}
showVisible.value = false
2022-11-21 18:46:38 +08:00
}
2022-11-21 10:51:54 +08:00
const init = () => {
willApplyCameraSelect().then((res) => {
if (res.data.code == 0) {
dataList.toBeApplied = res.data.data
delWacFlag.value = true
addWacFlag.value = true
} else {
message.warning('查询失败')
dataList.toBeApplied = []
}
})
}
2022-11-21 18:46:38 +08:00
const initApply = () => {
getApplyCameraListXha().then((res) => {
if (res.data.code == 0) {
res.data.data.map((val) => {
val.cameraInfo = JSON.parse(val.cameraInfo)
})
dataList.requested = res.data.data
delApply.value = true
} else {
message.warning('查询失败')
dataList.requested = []
}
})
}
2022-11-21 10:51:54 +08:00
init()
2022-11-21 18:46:38 +08:00
initApply()
2022-11-22 16:22:56 +08:00
const videoUrl = ref('')
//获取视频控件所需播放地址
2022-11-22 19:16:10 +08:00
const getVideoUrl = (data) => {
let param = data
getCameraLiveStream(param).then((res) => {
2022-11-22 16:22:56 +08:00
//console.log('555555rrrrr',res)
2022-11-22 19:16:10 +08:00
if (res.data.data) {
videoUrl.value = res.data.data.url
2022-11-22 16:22:56 +08:00
}
2022-11-22 19:16:10 +08:00
showVisible.value = true
})
}
2022-11-21 10:51:54 +08:00
mybus.on('selectCamera', (obj) => {
// 判断最多10条
2022-11-21 18:46:38 +08:00
if (dataList.toBeApplied.length + dataList.requested.length >= 10) {
2022-11-22 11:51:58 +08:00
message.warning('最多只能申请10个视频监控')
2022-11-21 10:51:54 +08:00
return
}
// 判断是否已操作
let addFlag = true
dataList.toBeApplied.map((val) => {
if (addFlag && val.channelId == obj.channelId) {
addFlag = false
}
})
dataList.requested.map((val) => {
2022-11-22 10:57:30 +08:00
if (addFlag && val.cameraInfo.channelId == obj.channelId) {
2022-11-21 10:51:54 +08:00
addFlag = false
}
})
if (addWacFlag.value) {
if (addFlag) {
addWacFlag.value = false
willApplyCameraBatchInsert([obj]).then((res) => {
if (res.data.code == 0) {
message.success('移入成功')
} else {
message.warning('移入失败')
}
init()
})
} else {
2022-11-22 11:51:58 +08:00
message.warning('已申请该视频监控!')
2022-11-21 10:51:54 +08:00
}
}
})
onBeforeUnmount(() => {
mybus.off('selectCamera')
})
</script>
<style lang="less" scoped>
.infrastructureApplication {
background: #fff;
position: fixed;
top: 50%;
right: 0.16rem;
2022-11-22 11:51:58 +08:00
margin-top: -3.9rem;
2022-11-21 10:51:54 +08:00
.bottom {
2022-11-22 11:51:58 +08:00
margin-top: 20px;
2022-11-21 10:51:54 +08:00
}
.title {
font-size: 16px;
font-weight: 600;
}
.name {
2022-11-22 11:51:58 +08:00
width: 1.3rem;
2022-11-21 10:51:54 +08:00
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
word-break: break-all;
}
2022-11-22 11:51:58 +08:00
.top .name {
width: 1.8rem;
}
2022-11-21 10:51:54 +08:00
:deep(.ant-list-footer) {
display: flex;
justify-content: flex-end;
}
:deep(.ant-list-items) {
2022-11-21 18:46:38 +08:00
width: 2.5rem;
2022-11-22 11:51:58 +08:00
height: 3rem;
2022-11-21 10:51:54 +08:00
overflow-y: scroll;
}
2022-11-22 11:51:58 +08:00
:deep(.ant-list-item) {
padding: 5px 5px 5px 10px;
}
2022-11-21 10:51:54 +08:00
:deep(.ant-spin-nested-loading) {
2022-11-21 18:46:38 +08:00
width: 2.5rem;
2022-11-22 11:51:58 +08:00
height: 3rem;
2022-11-21 10:51:54 +08:00
}
2022-11-22 16:22:56 +08:00
2022-11-22 19:16:10 +08:00
.waterMark {
position: absolute;
z-index: 99999999;
color: #0058e1;
font-size: 22px;
font-weight: bold;
opacity: 0.4;
transform: rotate(-25deg);
width: 470px;
}
2022-11-22 16:22:56 +08:00
2022-11-22 19:16:10 +08:00
// 左上
.waterMark-left-top {
left: 50px;
top: 100px;
text-align: left;
}
2022-11-22 16:22:56 +08:00
2022-11-22 19:16:10 +08:00
// 右上
.waterMark-right-top {
right: 50px;
top: 100px;
text-align: right;
}
2022-11-22 16:22:56 +08:00
2022-11-22 19:16:10 +08:00
// 左下
.waterMark-left-bottom {
left: 50px;
bottom: 100px;
text-align: left;
}
2022-11-22 16:22:56 +08:00
2022-11-22 19:16:10 +08:00
// 右下
.waterMark-right-bottom {
right: 50px;
bottom: 100px;
text-align: right;
}
2022-11-21 10:51:54 +08:00
}
</style>