指定时间拍照

wp1.0
fanluyan 1 year ago
parent 818214d10d
commit fa46e54a1d

@ -69,6 +69,7 @@
<h3>操作项</h3>
<div class="buttonGroup">
<takePicButton></takePicButton>
<takeVideoButton></takeVideoButton>
<deviceInfoButton></deviceInfoButton>
@ -89,6 +90,7 @@
<el-button type="primary" @click="handleuploadPic" v-if="roleUser == 0">
上传图片</el-button
>
<takeTimePicButton v-if="roleUser == 0"></takeTimePicButton>
<!-- <el-button type="primary" @click="handleTakePic" :loading="picLoading"
>主动拍照
</el-button> -->
@ -144,6 +146,7 @@
<script>
import EventBus from "@/utils/event-bus";
import takePicButton from "./takePicButton.vue";
import takeTimePicButton from "./takeTimePicButton.vue";
import takeVideoButton from "./takeVideoButton.vue";
import deviceInfoButton from "./deviceInfoButton.vue";
import scheduleButton from "./scheduleButton.vue";
@ -161,6 +164,7 @@ import {
export default {
components: {
takePicButton,
takeTimePicButton,
takeVideoButton,
deviceInfoButton,
scheduleButton,

@ -0,0 +1,324 @@
<template>
<!-- <el-button type="primary" @click="handleTakePic" :loading="picLoading"
>主动拍照
</el-button> -->
<div>
<el-dropdown trigger="click" @command="handleCommandpic">
<el-button type="primary" :loading="picLoading">
指定时间拍照<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown" class="picdropStyle">
<el-dropdown-item
:command="item.channelid"
v-for="(item, index) in channelIdList"
:key="index"
>{{
item.alias !== null && item.alias !== ""
? item.alias
: item.channelname
}}</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
<el-dialog
class="timeDialog"
title="拍照时间"
:visible.sync="dialogFormVisible"
width="380px"
>
<el-form :model="form">
<el-form-item label="拍照时间:">
<el-date-picker
v-model="form.startTime"
type="datetime"
placeholder="选择日期时间"
>
</el-date-picker>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false"> </el-button>
<el-button type="primary" @click="confirmClick"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
getTermStatus,
setTermCamera,
getTakePicStatusJoggle,
getTakePicPhotoStatusJoggle,
} from "@/utils/api/index";
export default {
data() {
return {
picLoading: false,
statusTimer: null,
statusNum: 0,
picPimer: null,
picNum: 0,
pzchannelId: "",
dialogFormVisible: false,
form: {
startTime: "",
},
timestamp: "",
};
},
watch: {
termId: {
handler(newVal, oldVal) {
console.log("我改变了");
clearInterval(this.statusTimer);
this.statusTimer = null;
this.statusNum = 0;
clearInterval(this.picPimer);
this.picPimer = null;
this.picNum = 0;
this.picLoading = false;
},
deep: true,
immediate: true,
},
},
mounted() {
console.log(this.channelIdList);
console.log("我是主动拍照");
},
computed: {
termId() {
return this.$store.state.termId;
},
channelIdList() {
return this.$store.state.channelIdList;
},
},
methods: {
handleCommandpic(command) {
// --act=capture --cmdid=XY-SIMULATOR-0016 --channel=1 --preset=255 --scheduleTime=1704110700 --clientid=5 --reqid=TS
console.log(command);
this.dialogFormVisible = true;
this.pzchannelId = command;
},
confirmClick() {
console.log(this.pzchannelId);
console.log(this.form.startTime.getTime() / 1000);
this.timestamp = this.form.startTime.getTime() / 1000;
this.dialogFormVisible = false;
this.picLoading = true;
getTermStatus({ termId: this.termId }).then((res) => {
console.log(res);
if (res.data.isonline) {
let params = [
{
name: "act",
value: "capture",
},
{
name: "channel",
value: this.pzchannelId,
},
{
name: "preset",
value: 255,
},
{
name: "scheduleTime",
value: this.timestamp,
},
{
name: "type",
value: 0,
},
];
this.setTermFn(params);
} else {
this.picLoading = false;
this.$message({
duration: 1500,
showClose: true,
message: "装置下线,发送指令失败",
type: "error",
});
}
});
},
handleTakePic() {},
//
setTermFn(val) {
setTermCamera({
termId: this.termId,
list: val,
})
.then((res) => {
console.log(res);
this.getTakePicStatus(res.data);
clearInterval(this.statusTimer);
this.statusTimer = null;
this.statusTimer = window.setInterval(() => {
this.getTakePicStatus(res.data);
this.statusNum++;
}, 5000);
})
.catch((err) => {});
},
//
getTakePicStatus(val) {
console.log(val);
getTakePicStatusJoggle({
requestid: val.requestId,
termId: this.termId,
photoTime: new Date(val.date).getTime(),
})
.then((res) => {
console.log(res);
//res.data 0 1 2
// if (
// res.data.cmaStatus == 0 &&
// res.data.picStatus == false &&
// this.statusNum >= 5
// ) {
// //
// this.clearFn();
// this.$message({
// duration: 1500,
// showClose: true,
// message: "true",
// type: "warning",
// });
// } else if (res.data.cmaStatus == 1) {
// this.clearFn();
// this.$message({
// duration: 1500,
// showClose: true,
// message: "cmaStatus1",
// type: "success",
// });
// clearInterval(this.picPimer);
// this.picPimer = null;
// this.picPimer = window.setInterval(() => {
// this.newPicApi(val);
// this.picNum++;
// }, 8000);
// return;
// } else if (res.data.picStatus == true) {
// this.clearFn();
// this.$message({
// duration: 1500,
// showClose: true,
// message: "",
// type: "success",
// });
// clearInterval(this.picPimer);
// this.picPimer = null;
// this.picPimer = window.setInterval(() => {
// this.newPicApi(val);
// this.picNum++;
// }, 2000);
// return;
// }
if (res.data.cmaStatus != 1 && this.statusNum >= 5) {
this.clearFn();
this.$message({
duration: 1500,
showClose: true,
message: "下发指令超时,请重试!",
type: "warning",
});
} else if (res.data.cmaStatus == 1 || res.data.picStatus == true) {
this.clearFn();
this.$message({
duration: 1500,
showClose: true,
message: "下发指令成功!",
type: "success",
});
this.newPicApi(val);
clearInterval(this.picPimer);
this.picPimer = null;
this.picPimer = window.setInterval(() => {
this.newPicApi(val);
this.picNum++;
}, 8000);
}
})
.catch((err) => {
console.log(err); //
});
},
//
newPicApi(val) {
getTakePicPhotoStatusJoggle({
requestid: val.requestId,
termId: this.termId,
photoTime: new Date(val.date).getTime(),
}).then((res) => {
console.log(res.data);
console.log(this.picNum);
if (res.data == true && this.picNum < 10) {
// console.log(this.$parent.$parent);
this.$parent.$parent.getPhotoList(
-1,
new Date(val.date).getTime(),
this.termId
); // id termid
this.$message({
duration: 1500,
showClose: true,
message: "已返回最新图片!",
type: "success",
});
clearInterval(this.picPimer);
this.picPimer = null;
this.picNum = 0;
console.log("返回最新图片");
} else if (res.data == false && this.picNum > 10) {
clearInterval(this.picPimer);
this.picPimer = null;
this.picNum = 0;
}
});
},
clearFn() {
clearInterval(this.statusTimer);
this.statusTimer = null;
this.statusNum = 0;
this.picLoading = false;
},
},
destroyed() {
console.log("离开了");
clearInterval(this.statusTimer);
this.statusTimer = null;
this.statusNum = 0;
},
beforeRouteLeave(to, from, next) {
//
next();
console.log("7777777777777777777777777");
},
};
</script>
<style lang="less">
.timeDialog {
.el-date-editor.el-input,
.el-date-editor.el-input__inner {
width: 256px;
}
.el-dialog__footer {
.dialog-footer {
.el-button {
width: 80px !important;
margin-bottom: 0px !important;
}
.el-button + .el-button {
margin-left: 10px !important;
}
}
}
}
</style>
Loading…
Cancel
Save