<template>
|
<div class="all" ref="curPage">
|
<div class="general-set">
|
<div class="general-center" ref="left">
|
<div
|
class="menu-item"
|
:class="activePage == i ? 'menu-item-active' : ''"
|
@click="openRight(i)"
|
v-for="(item, i) in menuArr"
|
:key="i"
|
>
|
<span class="iconfont" :style="`font-size:${item.size}px;`">{{
|
item.icon
|
}}</span>
|
<span class="title">{{ item.name }}</span>
|
</div>
|
</div>
|
<div class="general-right">
|
<!-- <div class="lang" v-if="activePage == 0">
|
<div class="bar">
|
<span class="name">设备ID</span>
|
<span class="desc">{{ deviceInfo.server_id }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">设备型号</span>
|
<span class="desc">{{ deviceInfo.deviceModel }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">设备类型</span>
|
<span class="desc">{{ deviceInfo.deviceDesc }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">通道个数</span>
|
<span class="desc">{{ deviceInfo.channelCount }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">主控版本</span>
|
<span class="desc">{{ deviceInfo.masterVersion }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">web版本</span>
|
<span class="desc">{{ deviceInfo.webVersion }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">硬盘信息</span>
|
<span class="desc">{{ deviceInfo.disks }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">CPU</span>
|
<span class="desc">{{ deviceInfo.cpu }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">内存</span>
|
<span class="desc">{{ deviceInfo.memory }}</span>
|
</div>
|
<div class="bar">
|
<span class="name">运行时间</span>
|
<span class="desc">{{ deviceInfo.runningTime }}</span>
|
</div>
|
</div> -->
|
<div class="lang" v-if="activePage == 0">
|
<div class="min-dur">
|
<div class="title">抓拍前录像时长</div>
|
<div class="entity">
|
<div class="sec">{{ min_video_len }}s</div>
|
<div class="block">
|
<el-slider
|
v-model="fakeObj.min"
|
id="cut_min_duration"
|
:min="5 / 1.2"
|
:max="100"
|
:step="5 / 1.2"
|
@input="min_len = min_video_len"
|
show-stops
|
:show-tooltip="true"
|
:format-tooltip="formatTooltip"
|
></el-slider>
|
</div>
|
<el-input-number
|
v-model="min_len"
|
@change="fakeObj.min = +(min_len / 1.2)"
|
controls-position="right"
|
:min="5"
|
:step="5"
|
:max="120"
|
step-strictly
|
size="small"
|
></el-input-number
|
> s
|
</div>
|
</div>
|
<div class="min-dur">
|
<div class="title">抓拍后录像时长</div>
|
<div class="entity">
|
<div class="sec">{{ max_video_len }} s</div>
|
<div class="block">
|
<el-slider
|
v-model="fakeObj.max"
|
id="cut_max_duration"
|
:min="5 / 1.2"
|
@input="max_len = max_video_len"
|
:max="100"
|
:step="5 / 1.2"
|
show-stops
|
:format-tooltip="formatTooltip"
|
:show-tooltip="true"
|
></el-slider>
|
</div>
|
<el-input-number
|
v-model="max_len"
|
@change="fakeObj.max = +(max_len / 1.2)"
|
controls-position="right"
|
:min="5"
|
:step="5"
|
step-strictly
|
:max="120"
|
size="small"
|
></el-input-number
|
> s
|
</div>
|
</div>
|
|
<div class="save-btn" @click="submitAlarm">保存</div>
|
</div>
|
<div class="lang" v-if="activePage == 1">
|
<div class="title">事件声音</div>
|
<div class="bar-group">
|
<div
|
class="bar"
|
v-for="(item, i) in soundList"
|
:key="i"
|
@click="clickSound(item, i)"
|
ref="soundBar"
|
>
|
<div class="left-part">
|
<span
|
class="icon iconfont"
|
style="margin-right: 12px; color: dodgerblue"
|
></span
|
>
|
<span class="name">{{ item.name }}</span>
|
</div>
|
<div class="btns">
|
<span @click="togglePlay(item, i)">
|
<i
|
v-if="!item.isPlay"
|
class="el-icon-video-play"
|
style=""
|
></i>
|
<i v-else class="el-icon-video-pause"></i>
|
</span>
|
<span
|
class="icon iconfont"
|
style="cursor: pointer; color: indianred"
|
@click="removeSound(item)"
|
></span
|
>
|
</div>
|
</div>
|
</div>
|
<div v-if="showUpload" @click.stop>
|
<el-upload
|
class="upload-demo"
|
drag
|
action=""
|
:http-request="uploadSound"
|
:show-file-list="false"
|
>
|
<i class="el-icon-upload"></i>
|
<div class="el-upload__text">
|
事件声音文件拖到此处,或
|
<em>点击上传</em>
|
<br />仅支持mp3/wma等格式
|
</div>
|
</el-upload>
|
</div>
|
|
<div class="add-group">
|
<div class="add-btn">
|
<span class="icon iconfont" @click.stop="showUpload = !showUpload"
|
></span
|
>
|
</div>
|
</div>
|
</div>
|
|
<div class="self-setting" v-if="activePage == 2">
|
<div class="top-title">图标主题</div>
|
|
<div class="icon-bar" style="cursor: pointer" @click="selectIcons(0)">
|
<div class="bar-title">
|
<span class="title">扁平写实图标</span>
|
<span
|
class="icon iconfont"
|
style="color: #3d68e1; font-size: 18px"
|
v-show="activeIcons == 0"
|
></span
|
>
|
</div>
|
<div class="entity">
|
<div
|
class="entity-img"
|
v-for="(item, i) in realIconList"
|
:key="i"
|
>
|
<img :src="item.url" alt="" />
|
</div>
|
</div>
|
</div>
|
<div class="icon-bar" style="cursor: pointer" @click="selectIcons(1)">
|
<div class="bar-title">
|
<span class="title">扁平化图标</span>
|
<span
|
class="icon iconfont"
|
style="color: #3d68e1; font-size: 18px"
|
v-show="activeIcons == 1"
|
></span
|
>
|
</div>
|
<div class="entity">
|
<div
|
class="entity-img"
|
v-for="(item, i) in flatIconList"
|
:key="i"
|
>
|
<img :src="item.url" alt="" />
|
</div>
|
</div>
|
</div>
|
<div class="top-title">桌面背景主题</div>
|
<div class="bg-bar">
|
<div class="bg-list">
|
<div
|
class="bg-img"
|
:class="activeBg == i ? 'bg-list-active' : ''"
|
v-for="(item, i) in tableBGList"
|
:key="i"
|
@click="pickBg(item, i)"
|
>
|
<img :src="item.url" alt="" />
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
import { saveAlarmConfig, getDevInfo } from "@/api/system";
|
import { uploadSound, getSoundList, deleteSound } from "@/api/event";
|
|
export default {
|
data() {
|
return {
|
curPlayingIndex: null,
|
showUpload: false,
|
activeIcons: 0,
|
min_len: 0,
|
max_len: 0,
|
fakeObj: {
|
min: 0,
|
max: 0,
|
},
|
menuArr: [
|
// { name: "设备信息", icon: "\ue933" ,size:18},
|
{ name: "事件录像时长", icon: "\ue6f3", size: 20 },
|
{ name: "事件声音", icon: "\ue6e1", size: 16 },
|
{ name: "个性化设置", icon: "\ue756", size: 18 },
|
],
|
soundList: [],
|
activePage: 0,
|
eventAudio: new Audio(),
|
deviceInfo: {
|
cpu: "",
|
runningTime: "",
|
server_id: "",
|
deviceModel: "",
|
deviceDesc: "",
|
masterVersion: "",
|
channelCount: "",
|
webVersion: "",
|
disks: "",
|
memory: "",
|
activeBg: 0,
|
},
|
isPlay: false,
|
realIconList: [
|
{ url: "/images/settings/日志管理.png" },
|
{ url: "/images/settings/实时监控.png" },
|
{ url: "/images/settings/数据可视化.png" },
|
],
|
flatIconList: [
|
{ url: "/images/settings/数据推送.png" },
|
{ url: "/images/settings/数据栈配置.png" },
|
{ url: "/images/settings/系统设置.png" },
|
],
|
tableBGList: [
|
{ name: "background", url: "/images/settings/background.png" },
|
{ name: "message", url: "/images/settings/数据推送.png" },
|
{ name: "weather", url: "/images/settings/系统设置.png" },
|
],
|
};
|
},
|
mounted() {
|
this.getDeviceInfo();
|
this.getSounds();
|
let _this = this;
|
this.eventAudio.addEventListener("ended", () => {
|
if (_this.curPlayingIndex !== null && _this.soundList.length) {
|
_this.soundList[_this.curPlayingIndex].isPlay = false;
|
_this.curPlayingIndex = null;
|
}
|
});
|
const url = localStorage.getItem("backgroundPic");
|
if (url) {
|
const arr = url.split("/");
|
this.activeBg = this.tableBGList.findIndex((x) => {
|
return x.url.includes(arr[arr.length - 1]);
|
});
|
} else {
|
this.activeBg = 0;
|
}
|
const e = this.$refs.curPage;
|
e.addEventListener("click", (e) => {
|
if (this.showUpload) {
|
this.showUpload = false;
|
}
|
});
|
},
|
beforeDestroy() {
|
this.$refs.curPage.removeEventListener("click");
|
},
|
computed: {
|
min_video_len() {
|
return Math.round(this.fakeObj.min * 1.2);
|
},
|
max_video_len() {
|
return Math.round(this.fakeObj.max * 1.2);
|
},
|
},
|
methods: {
|
formatTooltip(v) {
|
return Math.round(v * 1.2);
|
},
|
pickBg(item, i) {
|
this.activeBg = i;
|
let message = "changeBackground?" + item.name;
|
window.parent.postMessage(
|
{
|
msg: message,
|
},
|
"*"
|
);
|
},
|
togglePlay(item, i) {
|
if (this.curPlayingIndex !== null) {
|
this.eventAudio.pause();
|
this.soundList[this.curPlayingIndex].isPlay = false;
|
if (this.curPlayingIndex === i) {
|
this.curPlayingIndex = null;
|
return;
|
}
|
}
|
this.curPlayingIndex = i;
|
this.eventAudio.src = "http://" + item.path;
|
if (item.isPlay) {
|
this.eventAudio.pause();
|
} else {
|
this.eventAudio.play();
|
}
|
item.isPlay = !item.isPlay;
|
},
|
getDeviceInfo() {
|
getDevInfo().then((res) => {
|
let info = res.data.deviceInfo;
|
let basic = res.data;
|
this.deviceInfo.cpu = info.cpu[0].modelName;
|
this.deviceInfo.runningTime = this.secondsFormat(info.host.uptime);
|
this.deviceInfo.server_id = basic.server_id;
|
this.deviceInfo.deviceModel = basic.deviceModel;
|
this.deviceInfo.deviceDesc = basic.deviceDesc;
|
this.deviceInfo.masterVersion = basic.masterVersion;
|
this.deviceInfo.channelCount = basic.channelCount;
|
this.deviceInfo.webVersion = "V2.0.0";
|
this.deviceInfo.disks = "( " + info.disk + ") ";
|
this.deviceInfo.memory =
|
(info.mem.total / 1024 / 1024 / 1024).toFixed(2) + "GB";
|
this.fakeObj.min = basic.min_video_len / 1.2;
|
this.fakeObj.max = basic.max_video_len / 1.2;
|
});
|
},
|
getSounds() {
|
getSoundList().then((res) => {
|
if (res.success) {
|
this.soundList = res.data;
|
this.soundList.forEach((x) => {
|
this.$set(x, "isPlay", false);
|
});
|
}
|
});
|
},
|
secondsFormat(s) {
|
var day = (s / (24 * 3600)) | 0;
|
var hour = ((s - day * 24 * 3600) / 3600) | 0;
|
var minute = ((s - day * 24 * 3600 - hour * 3600) / 60) | 0;
|
var second = s - day * 24 * 3600 - hour * 3600 - minute * 60;
|
return day + "天 " + hour + "小时 " + minute + "分 " + second + "秒";
|
},
|
uploadSound(params) {
|
let param = new FormData();
|
param.append("file", params.file);
|
uploadSound(param).then(
|
(res) => {
|
this.$message.success("上传成功");
|
this.showUpload = false;
|
this.getSounds();
|
},
|
(err) => {
|
this.$message.error("声音上传失败");
|
}
|
);
|
},
|
openRight(i) {
|
this.activePage = i;
|
},
|
selectIcons(i) {
|
this.activeIcons = i;
|
},
|
removeSound(item) {
|
this.$confirm("您是否确认删除事件声音", "删除事件声音", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning",
|
}).then(() => {
|
deleteSound({
|
id: item.id,
|
}).then(
|
(res) => {
|
if (res.success) {
|
this.getSounds();
|
this.$message({
|
type: "success",
|
message: "删除成功!",
|
});
|
this.showUpload = false;
|
}
|
},
|
(err) => {
|
this.$message.error(err.msg);
|
}
|
);
|
});
|
},
|
clickSound(item, i) {
|
this.$refs["soundBar"].forEach((x) => {
|
x.style.backgroundColor = "rgba(248, 248, 248, 1)";
|
});
|
this.$refs["soundBar"][i].style.backgroundColor =
|
"rgba(233, 233, 233, 1)";
|
},
|
submitAlarm() {
|
saveAlarmConfig({
|
min_video_len: this.min_video_len,
|
max_video_len: this.max_video_len,
|
}).then((res) => {
|
if (res && res.success) {
|
this.getDeviceInfo();
|
this.$notify({
|
type: "success",
|
message: "保存成功",
|
});
|
}
|
});
|
},
|
},
|
};
|
</script>
|
<style lang="scss">
|
.all {
|
width: 100%;
|
}
|
|
.general-set {
|
height: 100%;
|
display: flex;
|
flex-direction: row;
|
flex: 1;
|
flex-basis: auto;
|
box-sizing: border-box;
|
.general-center {
|
height: 100%;
|
width: 280px;
|
overflow: auto;
|
box-sizing: border-box;
|
flex-shrink: 0;
|
padding: 10px;
|
border-right: 5px solid #f8f8f8;
|
|
.menu-item {
|
background-color: #f8f8f8;
|
height: 50px;
|
margin-bottom: 10px;
|
border-radius: 10px;
|
line-height: 50px;
|
box-sizing: border-box;
|
font-size: 14px;
|
padding: 0 20px;
|
cursor: pointer;
|
display: flex;
|
.iconfont {
|
margin-right: 8px;
|
}
|
.title {
|
font-size: 15px;
|
}
|
}
|
.menu-item-active {
|
background-color: #3d68e1;
|
color: white;
|
}
|
.menu-item:hover {
|
background-color: #3d68e1;
|
color: white;
|
}
|
}
|
.general-right {
|
flex: 1;
|
flex-basis: auto;
|
overflow: auto;
|
box-sizing: border-box;
|
|
padding: 20px 40px;
|
.el-form-item.is-required:not(.is-no-asterisk)
|
> .el-form-item__label:before,
|
.el-form-item.is-required:not(.is-no-asterisk)
|
.el-form-item__label-wrap
|
> .el-form-item__label:before {
|
display: none;
|
}
|
.el-select {
|
width: 100%;
|
}
|
.el-form-item {
|
margin-bottom: 10px;
|
height: 50px;
|
background: #f8f8f8;
|
padding: 4px 20px;
|
-webkit-box-sizing: border-box;
|
box-sizing: border-box;
|
border-radius: 10px;
|
.el-form-item__label {
|
text-align: left;
|
line-height: 42px;
|
}
|
}
|
.el-form-item__content {
|
line-height: 40px;
|
position: relative;
|
font-size: 14px;
|
}
|
.ip-input-container {
|
max-width: none !important;
|
}
|
.lang {
|
position: relative;
|
height: calc(83% - 0px);
|
.title {
|
height: 35px;
|
line-height: 35px;
|
font-size: 16px;
|
text-align: left;
|
margin-bottom: 5px;
|
}
|
.bar-group {
|
overflow: auto;
|
height: 100%;
|
}
|
.bar {
|
height: 44px;
|
background-color: #f8f8f8;
|
border-radius: 10px;
|
line-height: 44px;
|
box-sizing: border-box;
|
padding: 0 30px 0 20px;
|
display: flex;
|
justify-content: space-between;
|
margin-bottom: 10px;
|
.left-part {
|
.icon {
|
color: rgba(191, 191, 191, 1);
|
font-size: 16px;
|
margin-right: 5px;
|
}
|
}
|
.name {
|
font-size: 15px;
|
}
|
.btns {
|
width: 50px;
|
display: flex;
|
justify-content: space-between;
|
color: rgba(191, 191, 191, 1);
|
.el-icon-video-pause {
|
cursor: pointer;
|
font-size: 23px;
|
vertical-align: middle;
|
color: #409eff;
|
}
|
.el-icon-video-play {
|
cursor: pointer;
|
font-size: 23px;
|
vertical-align: middle;
|
color: #409eff;
|
}
|
}
|
.desc {
|
font-size: 14px;
|
color: rgba(134, 134, 134, 1);
|
}
|
}
|
.bar:hover {
|
background-color: rgba(233, 233, 233, 1);
|
}
|
.add-group {
|
margin: 10px auto;
|
width: fit-content;
|
}
|
.upload-demo {
|
-webkit-transition: all 0.3s;
|
transition: all 0.5s;
|
position: absolute;
|
bottom: -40px;
|
left: calc(50% - 145px);
|
.el-upload-dragger {
|
width: 290px;
|
}
|
}
|
.add-btn {
|
height: 40px;
|
line-height: 40px;
|
margin: 0 auto;
|
cursor: pointer;
|
width: fit-content;
|
.icon {
|
font-size: 32px;
|
color: rgba(61, 104, 225, 1);
|
}
|
}
|
.min-dur {
|
box-sizing: border-box;
|
padding: 0 20px;
|
background-color: rgba(248, 248, 248, 1);
|
height: 105px;
|
margin-bottom: 20px;
|
border-radius: 15px;
|
.title {
|
height: 45px;
|
line-height: 45px;
|
|
text-align: left;
|
box-sizing: border-box;
|
padding: 0 6px;
|
font-size: 14px;
|
}
|
}
|
|
.min-dur:hover {
|
background-color: rgba(233, 233, 233, 1);
|
}
|
|
.entity {
|
display: flex;
|
align-items: center;
|
height: 30px;
|
|
.sec {
|
min-width: 30px;
|
line-height: 80px;
|
margin-right: 10px;
|
color: rgba(120, 120, 120, 1);
|
font-size: 14px;
|
}
|
.block {
|
flex: 1;
|
margin: 0 20px 0 6px;
|
}
|
.el-input-number--small {
|
width: 100px;
|
}
|
.el-input-number.is-controls-right .el-input__inner {
|
padding-left: 16px;
|
}
|
#cut_min_duration {
|
.el-slider__bar {
|
background-color: #3d68e1;
|
}
|
.el-slider__button-wrapper .el-tooltip {
|
width: 18px;
|
height: 18px;
|
border: 4px solid #3d68e1;
|
box-sizing: border-box;
|
}
|
}
|
|
#cut_max_duration {
|
.el-slider__bar {
|
background-color: #ff9e6e;
|
}
|
.el-slider__button-wrapper .el-tooltip {
|
width: 18px;
|
height: 18px;
|
border: 4px solid #ff9e6e;
|
box-sizing: border-box;
|
}
|
}
|
}
|
}
|
.save-btn {
|
background-color: #3d68e1;
|
width: 240px;
|
height: 40px;
|
margin: 0 auto;
|
border-radius: 10px;
|
color: #fff;
|
line-height: 40px;
|
cursor: pointer;
|
font-size: 14px;
|
margin-top: 20px;
|
}
|
.self-setting {
|
.top-title {
|
font-size: 16px;
|
height: 30px;
|
line-height: 30px;
|
margin-bottom: 10px;
|
}
|
.icon-bar:hover {
|
background-color: rgba(233, 233, 233, 1);
|
}
|
.icon-bar {
|
cursor: pointer;
|
background-color: rgba(248, 248, 248, 1);
|
box-sizing: border-box;
|
padding: 15px 25px;
|
border-radius: 12px;
|
margin-bottom: 12px;
|
.bar-title {
|
line-height: 20px;
|
height: 20px;
|
margin-bottom: 10px;
|
display: flex;
|
justify-content: space-between;
|
.title {
|
font-size: 14px;
|
}
|
}
|
.entity {
|
display: flex;
|
.entity-img {
|
background-color: rgba(248, 248, 248, 1);
|
width: 50px;
|
height: 50px;
|
margin-right: 10px;
|
img {
|
width: 50px;
|
height: 50px;
|
}
|
}
|
}
|
}
|
.bg-bar {
|
background-color: rgba(248, 248, 248, 1);
|
box-sizing: border-box;
|
padding: 15px 25px;
|
border-radius: 12px;
|
margin-bottom: 12px;
|
.bg-list {
|
display: flex;
|
.bg-img {
|
margin-right: 12px;
|
cursor: pointer;
|
// width: 120px;
|
height: 80px;
|
border: 2px solid transparent;
|
img {
|
border-radius: 5px;
|
height: 100%;
|
}
|
}
|
.bg-img:hover {
|
border: 2px solid yellow;
|
}
|
.bg-list-active {
|
border: 2px solid yellow;
|
}
|
}
|
}
|
}
|
}
|
}
|
</style>
|