337 lines
8.8 KiB
JavaScript
337 lines
8.8 KiB
JavaScript
// 台风列表
|
|
import { mapMutations, mapGetters } from 'vuex'
|
|
|
|
import {
|
|
getTaskListData,
|
|
} from '@/api/task'
|
|
import PicturesUpload from '../pictures-upload/index.vue'
|
|
import RightSlide from '@/components/RightSlide.vue'
|
|
import LeftSlide from '@/components/LeftSlide.vue'
|
|
import {
|
|
payloadList,
|
|
payloadRemove,
|
|
getPayloadEnableList,
|
|
payloadSave,
|
|
payloadUpdate,
|
|
uavRemove,
|
|
uavList,
|
|
getUavEnableList,
|
|
uavSave,
|
|
uavUpdate
|
|
} from '@/api/device'
|
|
let taskListResource = []
|
|
export default {
|
|
name: 'TwinSituation',
|
|
props: {
|
|
visible: Boolean,
|
|
sceneComplete: Boolean,
|
|
},
|
|
components: {
|
|
PicturesUpload,
|
|
RightSlide,
|
|
LeftSlide,
|
|
},
|
|
data() {
|
|
return {
|
|
visibleLocale: false,
|
|
deviceData: [
|
|
// {
|
|
// name: '无人机1',
|
|
// num: 'M3127',
|
|
// location: '112.3423242,45.2312324'
|
|
// }
|
|
],
|
|
device: {
|
|
visible: false,
|
|
title: '新增',
|
|
form: {
|
|
type: 'SAR'
|
|
},
|
|
rules: {
|
|
name1: [
|
|
{ required: true, message: '请输入无人机名称', trigger: 'blur' }
|
|
],
|
|
name2: [
|
|
{ required: true, message: '请输入雷达名称', trigger: 'blur' }
|
|
],
|
|
ip1: [
|
|
{ required: true, message: '请输入无人机Ip', trigger: 'blur' }
|
|
],
|
|
ip2: [
|
|
{ required: true, message: '请输入雷达Ip', trigger: 'blur' }
|
|
],
|
|
code: [
|
|
{ required: true, message: '请输入无人机码', trigger: 'blur' }
|
|
],
|
|
}
|
|
},
|
|
queryForm: {
|
|
type: 'uav'
|
|
},
|
|
deviceTypes: [
|
|
{
|
|
label: '无人机',
|
|
value: 'uav'
|
|
},
|
|
{
|
|
label: '雷达',
|
|
value: 'payload'
|
|
},
|
|
],
|
|
deviceMap: {
|
|
payload: '雷达',
|
|
uav: '无人机'
|
|
},
|
|
isShowTable: false
|
|
}
|
|
},
|
|
computed: {
|
|
},
|
|
watch: {
|
|
visible: {
|
|
handler: function (nv) {
|
|
if (nv) {
|
|
this.visibleLocale = nv
|
|
}
|
|
},
|
|
immediate: true,
|
|
},
|
|
visibleLocale(nv) {
|
|
if (!nv) {
|
|
this.$emit('update:visible', false)
|
|
}
|
|
},
|
|
'queryForm.type': {
|
|
handler: function (nv) {
|
|
if (nv === 'payload') {
|
|
this.payloadPage()
|
|
} else {
|
|
this.uavPage()
|
|
}
|
|
this.isShowTable = false
|
|
this.$nextTick(() => {
|
|
this.isShowTable = true
|
|
})
|
|
},
|
|
immediate: true,
|
|
},
|
|
},
|
|
created() {
|
|
},
|
|
mounted() {
|
|
},
|
|
beforeDestroy() {
|
|
},
|
|
methods: {
|
|
payloadPage() {
|
|
payloadList().then(res => {
|
|
if (res.data.code === 200) {
|
|
this.deviceData = res.data.data
|
|
} else {
|
|
this.$message.error(res.data.msg || '请求失败')
|
|
}
|
|
}).catch(err => {
|
|
this.$message.error(err.msg || '请求失败')
|
|
})
|
|
},
|
|
uavPage() {
|
|
uavList().then(res => {
|
|
if (res.data.code === 200) {
|
|
this.deviceData = res.data.data
|
|
} else {
|
|
this.$message.error(res.data.msg || '请求失败')
|
|
}
|
|
}).catch(err => {
|
|
this.$message.error(err.msg || '请求失败')
|
|
})
|
|
},
|
|
addDevice() {
|
|
this.device.visible = true
|
|
this.device.title = `新增${this.deviceMap[this.queryForm.type]}`
|
|
if (this.queryForm.type === 'uav') {
|
|
this.device.form = {
|
|
id: '',
|
|
name1: '',
|
|
code: '',
|
|
ip1: ''
|
|
}
|
|
} else {
|
|
this.device.form = {
|
|
id: '',
|
|
name2: '',
|
|
type: '',
|
|
ip2: ''
|
|
}
|
|
}
|
|
},
|
|
editDevice(row) {
|
|
this.device.visible = true
|
|
this.device.title = `编辑${this.deviceMap[this.queryForm.type]}`
|
|
if (this.queryForm.type === 'uav') {
|
|
this.device.form = {
|
|
id: row.id,
|
|
name1: row.name,
|
|
code: row.code,
|
|
ip1: row.ip
|
|
}
|
|
} else {
|
|
this.device.form = {
|
|
id: row.id,
|
|
name2: row.name,
|
|
type: row.type,
|
|
ip2: row.ip
|
|
}
|
|
}
|
|
},
|
|
close() {
|
|
this.$refs.form.resetFields()
|
|
this.device.visible = false
|
|
},
|
|
async submitDevice() {
|
|
const valid = await this.$refs.form.validate()
|
|
if (!valid) return
|
|
const form = {}
|
|
if (this.queryForm.type === 'uav') {
|
|
form.name = this.device.form.name1
|
|
form.ip = this.device.form.ip1
|
|
form.code = this.device.form.code
|
|
if (this.device.form.id) {
|
|
form.id = this.device.form.id
|
|
uavUpdate(form).then(res => {
|
|
if (res.data.code === 200) {
|
|
this.uavPage()
|
|
this.close()
|
|
}
|
|
})
|
|
} else {
|
|
uavSave(form).then(res => {
|
|
if (res.data.code === 200) {
|
|
this.uavPage()
|
|
this.close()
|
|
}
|
|
})
|
|
}
|
|
|
|
} else {
|
|
form.name = this.device.form.name2
|
|
form.ip = this.device.form.ip2
|
|
form.type = this.device.form.type
|
|
if (this.device.form.id) {
|
|
form.id = this.device.form.id
|
|
payloadUpdate(form).then(res => {
|
|
if (res.data.code === 200) {
|
|
this.payloadPage()
|
|
this.close()
|
|
}
|
|
})
|
|
} else {
|
|
payloadSave(form).then(res => {
|
|
if (res.data.code === 200) {
|
|
this.payloadPage()
|
|
this.close()
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
async deleteDevice(row) {
|
|
const bool = await this.$confirm(`确认要永久删除该${this.deviceMap[this.queryForm.type]}吗?`, '提示', {
|
|
customClass: 'confirm-light',
|
|
confirmButtonText: '确定',
|
|
cancelButtonText: '取消',
|
|
type: 'warning'
|
|
})
|
|
if (!bool) return;
|
|
if (this.queryForm.type === 'uav') {
|
|
uavRemove([row.id]).then(res => {
|
|
this.$message.success('删除成功')
|
|
this.uavPage()
|
|
})
|
|
} else {
|
|
payloadRemove([row.id]).then(res => {
|
|
this.$message.success('删除成功')
|
|
this.payloadPage()
|
|
})
|
|
}
|
|
},
|
|
//#region 无人机详情代码
|
|
resourceClick(info) {
|
|
console.log('点击的信息', info)
|
|
this.detailInfo.visible = false
|
|
|
|
// 直接显示详细信息窗口,跳过中间步骤
|
|
this.detailUav.id = info.id
|
|
this.detailUav.basicsInfo.name = info.name
|
|
this.detailUav.baseInfo.longitude = info.lon
|
|
this.detailUav.baseInfo.latitude = info.lat
|
|
this.detailUav.baseInfo.flyHeight = info.flyHeight
|
|
this.detailUav.visible = true
|
|
|
|
// TODO 测试
|
|
// this.resourceClickTest(info)
|
|
getTaskListData({ payloadId: info.id }).then(res => {
|
|
if (res.data.code === 200) {
|
|
console.log('任务详情----------------', res.data.data)
|
|
let tasklist = res.data.data
|
|
this.detailInfo.jobId = undefined
|
|
if (tasklist.length > 0) {
|
|
// 有正在执行的任务
|
|
// 判断当前任务是否显示
|
|
let findIndex = -1
|
|
taskListResource.forEach((item, index) => {
|
|
if (item.status === 1) {
|
|
item.uavList.forEach(uav => {
|
|
let find = uav.payloadList.find(payload => payload.payloadId === info.id)
|
|
if (find) {
|
|
findIndex = index
|
|
}
|
|
})
|
|
}
|
|
})
|
|
if (findIndex > -1) {
|
|
this.detailInfo.jobId = this.taskList.data[findIndex].id
|
|
if (!this.taskList.data[findIndex].check) {
|
|
// 打开任务信息
|
|
this.toggleTaskSceneShow(this.taskList.data[findIndex], findIndex)
|
|
}
|
|
}
|
|
} else {
|
|
// 没有正在执行的任务
|
|
}
|
|
|
|
this.detailInfo.baseInfo = JSON.parse(JSON.stringify(info))
|
|
this.detailInfo.taskList = tasklist
|
|
let pictureList = []
|
|
tasklist.forEach((item, index) => {
|
|
item.uavList.forEach(child => {
|
|
child.payloadList.forEach(loader => {
|
|
if (loader.payloadId === info.id) {
|
|
loader.imageList.forEach(pic => {
|
|
pictureList.push(Object.assign({
|
|
jobId: item.id,
|
|
url: window.config.imagePath + pic.relativePath,
|
|
taskName: item.name,
|
|
uavName: child.uavName,
|
|
uavId: child.uavId,
|
|
payloadId: loader.payloadId,
|
|
loaderName: loader.payloadName,
|
|
status: item.status + '',
|
|
}, pic))
|
|
})
|
|
}
|
|
|
|
})
|
|
})
|
|
})
|
|
this.detailInfo.pictureList = pictureList
|
|
//this.detailInfo.visible = true
|
|
} else {
|
|
this.$message.error(res.data.message)
|
|
}
|
|
})
|
|
},
|
|
}
|
|
}
|