| | |
| | | </el-form-item> |
| | | <el-form-item label="关联派出所" prop="policeStationId"> |
| | | <el-select class="command-select" popper-class="command-select-popper" |
| | | v-model="formData.policeStationId" placeholder="请选择" clearable> |
| | | v-model="formData.policeStationId" placeholder="请选择" clearable filterable remote |
| | | :remote-method="handlePoliceStationSearch" :loading="policeStationLoading"> |
| | | <el-option v-for="item in policeStationOptions" :key="item.id" :label="item.stationName" |
| | | :value="item.id" /> |
| | | </el-select> |
| | |
| | | const searchName = ref('') |
| | | const selectedDeviceRows = ref([]) |
| | | const policeStationOptions = ref([]) // 关联派出所 |
| | | const policeStationAllOptions = ref([]) |
| | | const policeStationLoading = ref(false) |
| | | const policeStationSearchTimer = ref(null) |
| | | const policeStationSearchKeyword = ref('') |
| | | const deviceOptions = ref([]) // 关联设备 |
| | | const dictObj = inject('dictObj') |
| | | const mapRef = ref(null) |
| | |
| | | if (deviceListTimer) { |
| | | clearTimeout(deviceListTimer) |
| | | deviceListTimer = null |
| | | } |
| | | if (policeStationSearchTimer.value) { |
| | | clearTimeout(policeStationSearchTimer.value) |
| | | policeStationSearchTimer.value = null |
| | | } |
| | | viewEntity && viewer?.entities?.remove(viewEntity) |
| | | viewEntity = null |
| | |
| | | } |
| | | |
| | | // 获取派出所列表 |
| | | async function getPoliceStationList () { |
| | | async function getPoliceStationList (keyword = '') { |
| | | if (!visible.value) return |
| | | const res = await fwPoliceStationListApi() |
| | | policeStationOptions.value = res?.data?.data ?? [] |
| | | await nextTick() |
| | | const matched = policeStationOptions.value.find( |
| | | item => String(item.id) === String(formData.value.policeStationId) |
| | | ) |
| | | if (!matched) { |
| | | formData.value.policeStationId = '' |
| | | policeStationLoading.value = true |
| | | try { |
| | | const res = await fwPoliceStationListApi({ |
| | | stationName: keyword || undefined, |
| | | }) |
| | | const list = res?.data?.data ?? [] |
| | | policeStationOptions.value = list |
| | | if (!keyword) { |
| | | policeStationAllOptions.value = list |
| | | } |
| | | await nextTick() |
| | | if (!keyword) { |
| | | const matched = policeStationOptions.value.find( |
| | | item => String(item.id) === String(formData.value.policeStationId) |
| | | ) |
| | | if (!matched) { |
| | | formData.value.policeStationId = '' |
| | | } |
| | | } |
| | | } finally { |
| | | policeStationLoading.value = false |
| | | } |
| | | } |
| | | |
| | | function handlePoliceStationSearch (query) { |
| | | policeStationSearchKeyword.value = (query || '').trim() |
| | | if (!policeStationSearchKeyword.value) { |
| | | policeStationOptions.value = [...policeStationAllOptions.value] |
| | | return |
| | | } |
| | | if (policeStationSearchTimer.value) { |
| | | clearTimeout(policeStationSearchTimer.value) |
| | | } |
| | | policeStationSearchTimer.value = setTimeout(() => { |
| | | policeStationSearchTimer.value = null |
| | | void getPoliceStationList(policeStationSearchKeyword.value) |
| | | }, 300) |
| | | } |
| | | |
| | | // 获取设备列表 |
| | |
| | | selectedDeviceRows.value = [] |
| | | deviceOptions.value = [] |
| | | policeStationOptions.value = [] |
| | | policeStationAllOptions.value = [] |
| | | policeStationSearchKeyword.value = '' |
| | | if (policeStationSearchTimer.value) { |
| | | clearTimeout(policeStationSearchTimer.value) |
| | | policeStationSearchTimer.value = null |
| | | } |
| | | shapeList.value = [] |
| | | activeShapeId.value = null |
| | | activeAreaType.value = '' |
| | |
| | | clearTimeout(deviceListTimer) |
| | | deviceListTimer = null |
| | | } |
| | | if (policeStationSearchTimer.value) { |
| | | clearTimeout(policeStationSearchTimer.value) |
| | | policeStationSearchTimer.value = null |
| | | } |
| | | hideTypePanel() |
| | | }) |
| | | |