|
@@ -5,14 +5,14 @@
|
|
|
<img src="@/assets/image/common/close.png" style="cursor: pointer" alt="" @click="closeModal" />
|
|
<img src="@/assets/image/common/close.png" style="cursor: pointer" alt="" @click="closeModal" />
|
|
|
</div>
|
|
</div>
|
|
|
<div class="add-inspection-task-content">
|
|
<div class="add-inspection-task-content">
|
|
|
- <el-form ref="addTaskFormRef" :model="addTaskFrom" label-width="0.8rem" size="mini">
|
|
|
|
|
- <el-form-item label="任务名称">
|
|
|
|
|
|
|
+ <el-form ref="addTaskFormRef" :rules="rules" :model="addTaskFrom" label-width="0.8rem" size="mini">
|
|
|
|
|
+ <el-form-item label="任务名称" prop="securityPatrolName">
|
|
|
<el-input v-model="addTaskFrom.securityPatrolName" placeholder="请输入"></el-input>
|
|
<el-input v-model="addTaskFrom.securityPatrolName" placeholder="请输入"></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="任务内容">
|
|
<el-form-item label="任务内容">
|
|
|
<el-input type="textarea" rows="4" v-model="addTaskFrom.securityPatrolContext" placeholder="请输入"></el-input>
|
|
<el-input type="textarea" rows="4" v-model="addTaskFrom.securityPatrolContext" placeholder="请输入"></el-input>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="巡查点">
|
|
|
|
|
|
|
+ <el-form-item label="巡查点" prop="inspectionPoint">
|
|
|
<div v-for="(item, index) in addTaskFrom.inspectionPoint" :key="index" class="ins-point">
|
|
<div v-for="(item, index) in addTaskFrom.inspectionPoint" :key="index" class="ins-point">
|
|
|
<el-select v-model="item.value" placeholder="请选择巡查点" :popper-append-to-body="false" popper-class="u-popper-select" @change="onPointSelect">
|
|
<el-select v-model="item.value" placeholder="请选择巡查点" :popper-append-to-body="false" popper-class="u-popper-select" @change="onPointSelect">
|
|
|
<el-option :label="opt.devName" :value="opt.deviceCode" :disabled="opt.disabled" v-for="opt in inspectionOptions" :key="opt.deviceCode"></el-option>
|
|
<el-option :label="opt.devName" :value="opt.deviceCode" :disabled="opt.disabled" v-for="opt in inspectionOptions" :key="opt.deviceCode"></el-option>
|
|
@@ -21,9 +21,9 @@
|
|
|
<img src="@/assets/image/safety-inspection/add.png" alt="" v-if="isLastItem(index)" @click="addOption" />
|
|
<img src="@/assets/image/safety-inspection/add.png" alt="" v-if="isLastItem(index)" @click="addOption" />
|
|
|
</div>
|
|
</div>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="责任人">
|
|
|
|
|
|
|
+ <el-form-item label="责任人" prop="responsiblePerson">
|
|
|
<el-select v-model="addTaskFrom.responsiblePerson" placeholder="请选择责任人" style="width: 100%" :popper-append-to-body="false" popper-class="u-popper-select">
|
|
<el-select v-model="addTaskFrom.responsiblePerson" placeholder="请选择责任人" style="width: 100%" :popper-append-to-body="false" popper-class="u-popper-select">
|
|
|
- <el-option :label="p.name" :value="p.name" v-for="(p,i) in personList" :key="i"></el-option>
|
|
|
|
|
|
|
+ <el-option :label="p.name" :value="p.name" v-for="(p, i) in personList" :key="i"></el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
<el-form-item>
|
|
@@ -42,16 +42,16 @@
|
|
|
import 'mars3d/mars3d.css'
|
|
import 'mars3d/mars3d.css'
|
|
|
import * as mars3d from 'mars3d'
|
|
import * as mars3d from 'mars3d'
|
|
|
import Vue from 'vue'
|
|
import Vue from 'vue'
|
|
|
-import { toAddSecurityPatrol,endPatrol,startPatrol } from '@/api/securityPatrolApi'
|
|
|
|
|
|
|
+import { toAddSecurityPatrol, endPatrol, startPatrol } from '@/api/securityPatrolApi'
|
|
|
import moment from 'moment'
|
|
import moment from 'moment'
|
|
|
// 为了方便使用,绑定到原型链,在其他vue文件,直接this.mars3d 来使用
|
|
// 为了方便使用,绑定到原型链,在其他vue文件,直接this.mars3d 来使用
|
|
|
Vue.prototype.mars3d = mars3d
|
|
Vue.prototype.mars3d = mars3d
|
|
|
Vue.prototype.Cesium = mars3d.Cesium
|
|
Vue.prototype.Cesium = mars3d.Cesium
|
|
|
export default {
|
|
export default {
|
|
|
name: 'addInspectionTask',
|
|
name: 'addInspectionTask',
|
|
|
- props:{
|
|
|
|
|
- visible:Boolean,
|
|
|
|
|
- inspectionOptions:Array
|
|
|
|
|
|
|
+ props: {
|
|
|
|
|
+ visible: Boolean,
|
|
|
|
|
+ inspectionOptions: Array
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -61,55 +61,98 @@ export default {
|
|
|
inspectionPoint: [{ value: '' }],
|
|
inspectionPoint: [{ value: '' }],
|
|
|
responsiblePerson: ''
|
|
responsiblePerson: ''
|
|
|
},
|
|
},
|
|
|
- personList:[
|
|
|
|
|
|
|
+ rules: {
|
|
|
|
|
+ securityPatrolName: [{ required: true, message: '请输入任务名称', trigger: 'blur' }],
|
|
|
|
|
+ inspectionPoint: [{ required: true, validator: this.validateInspectionPoints, trigger: 'change' }],
|
|
|
|
|
+ responsiblePerson: [{ required: true, message: '请选择责任人', trigger: 'change' }]
|
|
|
|
|
+ },
|
|
|
|
|
+ personList: [
|
|
|
{
|
|
{
|
|
|
- name:'杨英'
|
|
|
|
|
|
|
+ name: '杨英'
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- name:'马刚'
|
|
|
|
|
|
|
+ name: '马刚'
|
|
|
},
|
|
},
|
|
|
{
|
|
{
|
|
|
- name:'谢智宇'
|
|
|
|
|
|
|
+ name: '谢智宇'
|
|
|
}
|
|
}
|
|
|
],
|
|
],
|
|
|
|
|
+ fieldErrors: {},
|
|
|
isPatrolling: false,
|
|
isPatrolling: false,
|
|
|
currentPatrolIndex: 0,
|
|
currentPatrolIndex: 0,
|
|
|
- currentTime:"",
|
|
|
|
|
|
|
+ currentTime: '',
|
|
|
patrolInterval: null,
|
|
patrolInterval: null,
|
|
|
- xcId:''
|
|
|
|
|
|
|
+ xcId: ''
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- watch:{
|
|
|
|
|
- visible(val){
|
|
|
|
|
- if(val){
|
|
|
|
|
- this.addTaskFrom={
|
|
|
|
|
- securityPatrolName: '',
|
|
|
|
|
- securityPatrolContext: '',
|
|
|
|
|
- inspectionPoint: [{ value: '' }],
|
|
|
|
|
- responsiblePerson: ''
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ visible(val) {
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ this.addTaskFrom = {
|
|
|
|
|
+ securityPatrolName: '',
|
|
|
|
|
+ securityPatrolContext: '',
|
|
|
|
|
+ inspectionPoint: [{ value: '' }],
|
|
|
|
|
+ responsiblePerson: ''
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
- mounted(){
|
|
|
|
|
- this.$globalEventBus.$on('closeVideoPlayAdd',()=>{
|
|
|
|
|
- this.stopPatrol()
|
|
|
|
|
- })
|
|
|
|
|
- this.$globalEventBus.$on('toPlayNextVideoAdd',()=>{
|
|
|
|
|
- this.goToNextPatrolPoint()
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ mounted() {
|
|
|
|
|
+ this.$globalEventBus.$on('closeVideoPlayAdd', () => {
|
|
|
|
|
+ this.stopPatrol()
|
|
|
|
|
+ })
|
|
|
|
|
+ this.$globalEventBus.$on('toPlayNextVideoAdd', () => {
|
|
|
|
|
+ this.goToNextPatrolPoint()
|
|
|
|
|
+ })
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- closeModal(){
|
|
|
|
|
|
|
+ // 验证巡查点
|
|
|
|
|
+ validateInspectionPoints(rule, value, callback) {
|
|
|
|
|
+ this.fieldErrors = {}
|
|
|
|
|
+ let isValid = true
|
|
|
|
|
+ let hasDuplicate = false
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否所有巡查点都已选择
|
|
|
|
|
+ this.addTaskFrom.inspectionPoint.forEach((item, index) => {
|
|
|
|
|
+ if (!item.value) {
|
|
|
|
|
+ isValid = false
|
|
|
|
|
+ this.$set(this.fieldErrors, index, '请选择巡查点')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 检查是否有重复选择
|
|
|
|
|
+ const selectedValues = this.addTaskFrom.inspectionPoint.map((item) => item.value).filter((v) => v)
|
|
|
|
|
+
|
|
|
|
|
+ const uniqueValues = new Set(selectedValues)
|
|
|
|
|
+ if (selectedValues.length !== uniqueValues.size) {
|
|
|
|
|
+ isValid = false
|
|
|
|
|
+ hasDuplicate = true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!isValid) {
|
|
|
|
|
+ if (hasDuplicate) {
|
|
|
|
|
+ callback(new Error('不能重复选择相同的巡查点'))
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback(new Error('请确保所有巡查点都已选择'))
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ callback()
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ closeModal() {
|
|
|
this.$emit('closeAddTask')
|
|
this.$emit('closeAddTask')
|
|
|
},
|
|
},
|
|
|
- toSave(){
|
|
|
|
|
- toAddSecurityPatrol(this.addTaskFrom).then((res)=>{
|
|
|
|
|
- if(res.data){
|
|
|
|
|
- this.$message.success('添加成功')
|
|
|
|
|
- this.closeModal()
|
|
|
|
|
- }else{
|
|
|
|
|
- this.$message.error('添加失败')
|
|
|
|
|
|
|
+ toSave() {
|
|
|
|
|
+ this.$refs.addTaskFormRef.validate((valid) => {
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ toAddSecurityPatrol(this.addTaskFrom).then((res) => {
|
|
|
|
|
+ if (res.data) {
|
|
|
|
|
+ this.$message.success('添加成功')
|
|
|
|
|
+ this.closeModal()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.$message.error('添加失败')
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
@@ -122,31 +165,40 @@ export default {
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
startInspection() {
|
|
startInspection() {
|
|
|
- startPatrol(this.addTaskFrom).then((res)=>{
|
|
|
|
|
- this.xcId = res.data.newSercurity.id
|
|
|
|
|
- })
|
|
|
|
|
- this.$emit('closeAddTask')
|
|
|
|
|
- this.currentTime = moment().format('YYYY-MM-DD HH:mm:ss');
|
|
|
|
|
- if (this.addTaskFrom.inspectionPoint === 0) {
|
|
|
|
|
- this.$message.warning('请先添加至少一个巡查点')
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
- this.addTaskFrom.inspectionPoint.forEach((item, index) => {
|
|
|
|
|
- this.fetchUrl(item).then((res) => {
|
|
|
|
|
- let url = ''
|
|
|
|
|
- if(res.code == 200){
|
|
|
|
|
- url = res.data.streamUrl
|
|
|
|
|
|
|
+ this.$refs.addTaskFormRef.validate((valid) => {
|
|
|
|
|
+ if (valid) {
|
|
|
|
|
+ startPatrol(this.addTaskFrom).then((res) => {
|
|
|
|
|
+ this.xcId = res.data.newSercurity.id
|
|
|
|
|
+ })
|
|
|
|
|
+ this.$emit('closeAddTask')
|
|
|
|
|
+ this.currentTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
|
|
|
|
+ if (this.addTaskFrom.inspectionPoint === 0) {
|
|
|
|
|
+ this.$message.warning('请先添加至少一个巡查点')
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
- this.$set(this.addTaskFrom.inspectionPoint[index], 'url', url)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ this.addTaskFrom.inspectionPoint.forEach((item, index) => {
|
|
|
|
|
+ this.fetchUrl(item).then((res) => {
|
|
|
|
|
+ let url = ''
|
|
|
|
|
+ if (res.code == 200) {
|
|
|
|
|
+ url = res.data.streamUrl
|
|
|
|
|
+ } else if (res.code == 400) {
|
|
|
|
|
+ this.$message.error(res.msg)
|
|
|
|
|
+ } else if (res.code == 4001) {
|
|
|
|
|
+ this.$message.warning('设备离线')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ this.$set(this.addTaskFrom.inspectionPoint[index], 'url', url)
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ this.isPatrolling = true
|
|
|
|
|
+ this.currentPatrolIndex = 0
|
|
|
|
|
+ this.goToNextPatrolPoint()
|
|
|
|
|
+ // 设置定时器,每20秒切换到下一个点
|
|
|
|
|
+ this.patrolInterval = setInterval(() => {
|
|
|
|
|
+ this.goToNextPatrolPoint()
|
|
|
|
|
+ }, 20000)
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
- this.isPatrolling = true
|
|
|
|
|
- this.currentPatrolIndex = 0
|
|
|
|
|
- this.goToNextPatrolPoint()
|
|
|
|
|
- // 设置定时器,每20秒切换到下一个点
|
|
|
|
|
- this.patrolInterval = setInterval(() => {
|
|
|
|
|
- this.goToNextPatrolPoint()
|
|
|
|
|
- }, 20000)
|
|
|
|
|
},
|
|
},
|
|
|
fetchUrl(item) {
|
|
fetchUrl(item) {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
@@ -173,23 +225,23 @@ export default {
|
|
|
if (this.currentPatrolIndex >= this.addTaskFrom.inspectionPoint.length) {
|
|
if (this.currentPatrolIndex >= this.addTaskFrom.inspectionPoint.length) {
|
|
|
const endTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
|
const endTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
|
|
this.stopPatrol()
|
|
this.stopPatrol()
|
|
|
- this.$globalEventBus.$emit('clickVideoPlay', { visible: false,type:'add' })
|
|
|
|
|
- endPatrol({id:this.xcId,endTime:endTime,startTime:this.currentTime}).then((res)=>{
|
|
|
|
|
|
|
+ this.$globalEventBus.$emit('clickVideoPlay', { visible: false, type: 'add' })
|
|
|
|
|
+ endPatrol({ id: this.xcId, endTime: endTime, startTime: this.currentTime }).then((res) => {
|
|
|
this.$emit('refreshData')
|
|
this.$emit('refreshData')
|
|
|
})
|
|
})
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- this.$globalEventBus.$emit('clickVideoPlay', { visible: false,type:"add" })
|
|
|
|
|
- setTimeout(()=>{
|
|
|
|
|
|
|
+ this.$globalEventBus.$emit('clickVideoPlay', { visible: false, type: 'add' })
|
|
|
|
|
+ setTimeout(() => {
|
|
|
const point = this.addTaskFrom.inspectionPoint[this.currentPatrolIndex]
|
|
const point = this.addTaskFrom.inspectionPoint[this.currentPatrolIndex]
|
|
|
this.flyToPoint(point)
|
|
this.flyToPoint(point)
|
|
|
// 播放视频
|
|
// 播放视频
|
|
|
this.playVideo(point)
|
|
this.playVideo(point)
|
|
|
this.currentPatrolIndex++
|
|
this.currentPatrolIndex++
|
|
|
- },100)
|
|
|
|
|
|
|
+ }, 100)
|
|
|
},
|
|
},
|
|
|
playVideo(point) {
|
|
playVideo(point) {
|
|
|
- this.$globalEventBus.$emit('clickVideoPlay', { point: point, visible: true ,type:'add'})
|
|
|
|
|
|
|
+ this.$globalEventBus.$emit('clickVideoPlay', { point: point, visible: true, type: 'add' })
|
|
|
},
|
|
},
|
|
|
stopPatrol() {
|
|
stopPatrol() {
|
|
|
this.isPatrolling = false
|
|
this.isPatrolling = false
|
|
@@ -214,12 +266,13 @@ export default {
|
|
|
removeOption(index) {
|
|
removeOption(index) {
|
|
|
if (this.addTaskFrom.inspectionPoint.length > 1) {
|
|
if (this.addTaskFrom.inspectionPoint.length > 1) {
|
|
|
this.addTaskFrom.inspectionPoint.splice(index, 1)
|
|
this.addTaskFrom.inspectionPoint.splice(index, 1)
|
|
|
|
|
+ this.$refs.addTaskFormRef.validateField('inspectionPoint');
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
destroyed() {
|
|
destroyed() {
|
|
|
this.stopPatrol()
|
|
this.stopPatrol()
|
|
|
- this.$globalEventBus.$off('closeVideoPlayAdd');
|
|
|
|
|
|
|
+ this.$globalEventBus.$off('closeVideoPlayAdd')
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
</script>
|
|
</script>
|
|
@@ -276,15 +329,15 @@ export default {
|
|
|
.ins-point:last-child {
|
|
.ins-point:last-child {
|
|
|
margin-bottom: 0;
|
|
margin-bottom: 0;
|
|
|
}
|
|
}
|
|
|
- :deep(.el-button){
|
|
|
|
|
- line-height:initial;
|
|
|
|
|
- background:rgba(79,159,255,0.8);
|
|
|
|
|
- padding:px-to-rem(3) px-to-rem(7);
|
|
|
|
|
|
|
+ :deep(.el-button) {
|
|
|
|
|
+ line-height: initial;
|
|
|
|
|
+ background: rgba(79, 159, 255, 0.8);
|
|
|
|
|
+ padding: px-to-rem(3) px-to-rem(7);
|
|
|
}
|
|
}
|
|
|
- .cancelBtn{
|
|
|
|
|
- border: 1px solid #4F9FFF;
|
|
|
|
|
- color:#FFF;
|
|
|
|
|
- background-color:transparent;
|
|
|
|
|
|
|
+ .cancelBtn {
|
|
|
|
|
+ border: 1px solid #4f9fff;
|
|
|
|
|
+ color: #fff;
|
|
|
|
|
+ background-color: transparent;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|