| | |
| | | <template> |
| | | <el-dialog class="ztzf-page-view-dialog" v-model="visible" :title="titleEnum[dialogMode]" |
| | | :close-on-click-modal="false" width="80%"> |
| | | <div class="bodyBox"> |
| | | <div class="leftMap ztzf-cesium" id="mapContainer"></div> |
| | | <div class="rightInfo"> |
| | | <div class="detail-container" v-if="readonly"> |
| | | <el-dialog class="ztzf-page-map-view-dialog" v-model="visible" :show-close="false" |
| | | :close-on-click-modal="false"> |
| | | <div class="dialog-container"> |
| | | <div class="left-container"> |
| | | <div class="leftMap ztzf-cesium" id="mapContainer"></div> |
| | | </div> |
| | | |
| | | <div class="right-container"> |
| | | <div class="header"> |
| | | {{ titleEnum[dialogMode] }} |
| | | </div> |
| | | |
| | | <div class="dialog-container" v-if="readonly"> |
| | | <div class="detail-title">区域详情</div> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <el-form class="dialog-form" v-else ref="formRef" :model="formData" :rules="rules" :disabled="readonly" |
| | | label-width="100px"> |
| | | <el-row> |
| | | <el-col :span="24"> |
| | | <el-form-item label="区域名称" prop="areaName"> |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="formData.areaName" |
| | | maxlength="50" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="区域位置" prop="longitude"> |
| | | <div>{{ formatLocation(formData) }}</div> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="区域面积" prop="areaSize">{{ formData.areaSize || '-' }}k㎡</el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="区域类型" prop="areaType"> |
| | | <el-select class="ztzf-data-cockpit-select" popper-class="ztzf-data-cockpit-select-popper" |
| | | v-model="formData.areaType" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in dictObj.areaType" |
| | | :key="item.dictKey" |
| | | :label="item.dictValue" |
| | | :value="item.dictKey" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="响应机制" prop="responseMechanism"> |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="formData.responseMechanism" |
| | | maxlength="200" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="触发条件" prop="triggerCondition"> |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="formData.triggerCondition" |
| | | maxlength="200" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="管控级别" prop="controlLevel"> |
| | | <el-select class="ztzf-data-cockpit-select" popper-class="ztzf-data-cockpit-select-popper" |
| | | v-model="formData.controlLevel" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in dictObj.controlLevel" |
| | | :key="item.dictKey" |
| | | :label="item.dictValue" |
| | | :value="item.dictKey" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="可飞行时段" prop="flyDateStart"> |
| | | <el-date-picker |
| | | class="ztzf-data-cockpit-date-picker" |
| | | popper-class="ztzf-data-cockpit-date-picker-popper" |
| | | v-model="flyDateRange" |
| | | type="datetimerange" |
| | | range-separator="至" |
| | | start-placeholder="开始时间" |
| | | end-placeholder="结束时间" |
| | | value-format="YYYY-MM-DD HH:mm:ss" |
| | | clearable |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <el-form-item label="关联派出所" prop="policeStationId"> |
| | | <el-select class="ztzf-data-cockpit-select" popper-class="ztzf-data-cockpit-select-popper" |
| | | v-model="formData.policeStationId" placeholder="请选择" clearable> |
| | | <el-option |
| | | v-for="item in policeStationOptions" |
| | | :key="item.id" |
| | | :label="item.stationName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="24"> |
| | | <div> |
| | | <div> |
| | | 关联设备 |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="searchName" placeholder="请输入" |
| | | clearable></el-input> |
| | | </div> |
| | | <el-form-item prop="deviceIds" label-width="0"> |
| | | <el-table |
| | | class="ztzf-data-cockpit-table" |
| | | ref="deviceTableRef" |
| | | :data="deviceOptions.filter(item => item.deviceName.includes(searchName))" |
| | | row-key="id" |
| | | @selection-change="handleDeviceSelectionChange" |
| | | > |
| | | <el-table-column type="selection" width="55" :reserve-selection="true" /> |
| | | <el-table-column prop="deviceName" label="设备名称" /> |
| | | <el-table-column prop="deviceType" label="类型"> |
| | | <template v-slot="{ row }"> |
| | | {{ getDictLabel(row.deviceType, dictObj.deviceType) }} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-form-item> |
| | | label-width="96px"> |
| | | <el-form-item label="区域名称" prop="areaName"> |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="formData.areaName" maxlength="50" |
| | | placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="区域位置" prop="longitude"> |
| | | <div class="val">{{ formatLocation(formData) }}</div> |
| | | </el-form-item> |
| | | <el-form-item label="区域面积" prop="areaSize"> |
| | | <div class="val">{{ formData.areaSize || '-' }}k㎡</div> |
| | | </el-form-item> |
| | | <el-form-item label="区域类型" prop="areaType"> |
| | | <el-select class="ztzf-data-cockpit-select" popper-class="ztzf-data-cockpit-select-popper" |
| | | v-model="formData.areaType" placeholder="请选择" clearable> |
| | | <el-option v-for="item in dictObj.areaType" :key="item.dictKey" :label="item.dictValue" |
| | | :value="item.dictKey" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="响应机制" prop="responseMechanism"> |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="formData.responseMechanism" |
| | | maxlength="200" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="触发条件" prop="triggerCondition"> |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="formData.triggerCondition" |
| | | maxlength="200" placeholder="请输入" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="管控级别" prop="controlLevel"> |
| | | <el-select class="ztzf-data-cockpit-select" popper-class="ztzf-data-cockpit-select-popper" |
| | | v-model="formData.controlLevel" placeholder="请选择" clearable> |
| | | <el-option v-for="item in dictObj.controlLevel" :key="item.dictKey" :label="item.dictValue" |
| | | :value="item.dictKey" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="可飞行时段" prop="flyDateStart"> |
| | | <el-date-picker class="ztzf-data-cockpit-date-picker" |
| | | popper-class="ztzf-data-cockpit-date-picker-popper" v-model="flyDateRange" |
| | | type="datetimerange" range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" |
| | | value-format="YYYY-MM-DD HH:mm:ss" clearable /> |
| | | </el-form-item> |
| | | <el-form-item label="关联派出所" prop="policeStationId"> |
| | | <el-select class="ztzf-data-cockpit-select" popper-class="ztzf-data-cockpit-select-popper" |
| | | v-model="formData.policeStationId" placeholder="请选择" clearable> |
| | | <el-option v-for="item in policeStationOptions" :key="item.id" :label="item.stationName" |
| | | :value="item.id" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <div class="search-table-container"> |
| | | <div class="search-box"> |
| | | <div class="label"> |
| | | 关联设备 |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | |
| | | <el-input class="ztzf-data-cockpit-search-input" v-model="searchName" placeholder="请输入" |
| | | clearable></el-input> |
| | | </div> |
| | | |
| | | <el-form-item prop="deviceIds" label-width="0"> |
| | | <el-table class="ztzf-data-cockpit-table" ref="deviceTableRef" |
| | | :data="deviceOptions.filter(item => item.deviceName.includes(searchName))" row-key="id" |
| | | @selection-change="handleDeviceSelectionChange"> |
| | | <el-table-column type="selection" width="55" :reserve-selection="true" /> |
| | | <el-table-column prop="deviceName" label="设备名称" /> |
| | | <el-table-column prop="deviceType" label="类型"> |
| | | <template v-slot="{ row }"> |
| | | {{ getDictLabel(row.deviceType, dictObj.deviceType) }} |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | </el-form-item> |
| | | </div> |
| | | </el-form> |
| | | |
| | | <div class="footer"> |
| | | <el-button color="#2B2B4C" @click="handleCancel">{{ readonly ? '关闭' : '取消' }}</el-button> |
| | | <el-button color="#284FE3" v-if="!readonly" type="primary" :loading="submitting" |
| | | :disabled="submitting" @click="handleSubmit"> |
| | | 确定 |
| | | </el-button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <template #footer> |
| | | <el-button color="#2B2B4C" @click="handleCancel">{{ readonly ? '关闭' : '取消' }}</el-button> |
| | | <el-button color="#284FE3" v-if="!readonly" type="primary" :loading="submitting" :disabled="submitting" |
| | | @click="handleSubmit"> |
| | | 确定 |
| | | </el-button> |
| | | </template> |
| | | </el-dialog> |
| | | </template> |
| | | |
| | |
| | | const dialogMode = ref('add') // 弹框模式 |
| | | const submitting = ref(false) // 提交中 |
| | | const readonly = computed(() => dialogMode.value === 'view') |
| | | const titleEnum = ref({ edit: '编辑', view: '查看', add: '新增' }) |
| | | const titleEnum = ref({ edit: '编辑场景', view: '查看场景', add: '新增场景' }) |
| | | const flyDateRange = ref([]) // 飞行时间 |
| | | const deviceTableRef = ref(null) |
| | | const searchName = ref('') |
| | |
| | | } |
| | | |
| | | // 关闭弹框 |
| | | function handleCancel() { |
| | | function handleCancel () { |
| | | visible.value = false |
| | | } |
| | | |
| | | // 提交新增/编辑 |
| | | async function handleSubmit() { |
| | | async function handleSubmit () { |
| | | const isValid = await formRef.value?.validate().catch(() => false) |
| | | if (!isValid) return |
| | | submitting.value = true |
| | |
| | | ) |
| | | |
| | | // 加载详情 |
| | | async function loadDetail() { |
| | | async function loadDetail () { |
| | | if (!formData.value.id) return |
| | | const res = await fwAreaDivideDetailApi({ id: formData.value.id }) |
| | | formData.value = res?.data?.data ?? initForm() |
| | |
| | | } |
| | | |
| | | // 格式化区域位置 |
| | | function formatLocation(row) { |
| | | function formatLocation (row) { |
| | | if (row?.longitude == null || row?.latitude == null) return '' |
| | | return `${_.round(row.longitude, 6)}, ${_.round(row.latitude, 6)}` |
| | | } |
| | | |
| | | // 格式化可飞行时间段 |
| | | function formatFlyDate(row) { |
| | | function formatFlyDate (row) { |
| | | if (!row?.flyDateStart && !row?.flyDateEnd) return '' |
| | | return `${row.flyDateStart || '-'} ~ ${row.flyDateEnd || '-'}` |
| | | } |
| | | |
| | | // 初始化地图实例 |
| | | function initMap() { |
| | | function initMap () { |
| | | const publicCesiumInstance = new PublicCesium({ |
| | | dom: 'mapContainer', |
| | | flatMode: false, |
| | |
| | | } |
| | | |
| | | // 新增模式绘制 |
| | | function addPolygon() { |
| | | function addPolygon () { |
| | | drawPolygonExample = new DrawPolygon(viewer) |
| | | drawPolygonExample.initHandler(viewer) |
| | | drawPolygonExample.subscribe('getPolygonPositions', drawFinished) |
| | | } |
| | | |
| | | // 编辑面 |
| | | function editPolygon() { |
| | | function editPolygon () { |
| | | if (!formData.value?.geom) return |
| | | pointList = geomAnalysis(formData.value.geom) |
| | | drawPolygonExample?.destroy() |
| | |
| | | } |
| | | |
| | | // 查看面 |
| | | function viewPolygon() { |
| | | function viewPolygon () { |
| | | if (!formData.value?.geom) return |
| | | pointList = geomAnalysis(formData.value.geom) |
| | | const result = pointList.map(item => [item.longitude, item.latitude]).flat() |
| | |
| | | } |
| | | |
| | | // 获取派出所列表 |
| | | async function getPoliceStationList() { |
| | | async function getPoliceStationList () { |
| | | const res = await fwPoliceStationListApi() |
| | | policeStationOptions.value = res?.data?.data ?? [] |
| | | } |
| | | |
| | | // 获取设备列表 |
| | | async function getDeviceList() { |
| | | async function getDeviceList () { |
| | | if (deviceOptions.value.length) return |
| | | const res = await fwDeviceListApi({ isAreaSelect: 1, areaId: formData.value.id }) |
| | | deviceOptions.value = res?.data?.data ?? [] |
| | |
| | | } |
| | | |
| | | // 关联设备变更 |
| | | function handleDeviceSelectionChange(rows) { |
| | | function handleDeviceSelectionChange (rows) { |
| | | selectedDeviceRows.value = rows |
| | | const ids = rows.map(item => item.id) |
| | | formData.value.deviceIds = ids.join(',') |
| | | } |
| | | |
| | | // 同步选择状态 |
| | | function syncDeviceSelection() { |
| | | function syncDeviceSelection () { |
| | | if (!deviceTableRef.value) return |
| | | deviceTableRef.value.clearSelection() |
| | | const rows = [] |
| | |
| | | } |
| | | |
| | | // 打开弹框 |
| | | async function open({ mode, row } = {}) { |
| | | async function open ({ mode, row } = {}) { |
| | | dialogMode.value = mode || 'add' |
| | | formData.value = dialogMode.value === 'add' ? initForm() : row |
| | | selectedDeviceRows.value = [] |
| | |
| | | }) |
| | | </script> |
| | | |
| | | <style scoped lang="scss"> |
| | | .bodyBox { |
| | | display: flex; |
| | | height: 600px; |
| | | .leftMap { |
| | | width: 70%; |
| | | height: 100%; |
| | | } |
| | | .rightInfo { |
| | | width: 30%; |
| | | height: 100%; |
| | | overflow: auto; |
| | | |
| | | .ztzf-table-container, |
| | | .ztzf-table-content { |
| | | height: auto; |
| | | flex: none; |
| | | } |
| | | } |
| | | } |
| | | </style> |
| | | <style scoped lang="scss"></style> |