| | |
| | | import ListExportPrint from '@/components/biz/list-export-print/index.vue' |
| | | import { defaultResponseAdapter } from '@/utils/table/tableUtils' |
| | | import { guardRequestWithMessage } from '@/utils/sys/requestGuard' |
| | | import { fetchBasStationPage } from '@/api/bas-station' |
| | | import { fetchBasStationOptionPage } from '@/api/bas-station' |
| | | import { fetchWarehouseAreasList } from '@/api/warehouse-areas' |
| | | import { fetchDictDataPage } from '@/api/system-manage' |
| | | import { |
| | |
| | | const deviceOptions = ref([]) |
| | | const areaOptions = ref([]) |
| | | const stationOptions = ref([]) |
| | | const stationOptionsLoaded = ref(false) |
| | | const stationOptionsLoading = ref(null) |
| | | const detailDrawerVisible = ref(false) |
| | | const detailLoading = ref(false) |
| | | const detailData = ref({}) |
| | |
| | | } |
| | | } |
| | | |
| | | function openInitDialog(record = null) { |
| | | async function ensureStationOptions() { |
| | | if (stationOptionsLoaded.value) { |
| | | return |
| | | } |
| | | |
| | | if (stationOptionsLoading.value) { |
| | | await stationOptionsLoading.value |
| | | return |
| | | } |
| | | |
| | | stationOptionsLoading.value = (async () => { |
| | | const response = await guardRequestWithMessage( |
| | | fetchBasStationOptionPage( |
| | | { |
| | | current: 1, |
| | | pageSize: 100 |
| | | }, |
| | | { |
| | | showErrorMessage: false |
| | | } |
| | | ), |
| | | { records: [] }, |
| | | { |
| | | timeoutMessage: '站点列表加载超时,已停止等待' |
| | | } |
| | | ) |
| | | stationOptions.value = buildSelectOptions(defaultResponseAdapter(response).records, ['stationName', 'name']) |
| | | stationOptionsLoaded.value = true |
| | | })() |
| | | |
| | | try { |
| | | await stationOptionsLoading.value |
| | | } finally { |
| | | stationOptionsLoading.value = null |
| | | } |
| | | } |
| | | |
| | | async function openInitDialog(record = null) { |
| | | await ensureStationOptions() |
| | | currentInitData.value = record ? createInitRecordFromRow(record) : buildDeviceSiteInitModel() |
| | | initDialogVisible.value = true |
| | | } |
| | |
| | | areaOptions.value = resolveDeviceSiteAreaOptions(defaultResponseAdapter(response).records) |
| | | } |
| | | |
| | | async function loadStationOptions() { |
| | | const response = await guardRequestWithMessage( |
| | | fetchBasStationPage({ |
| | | current: 1, |
| | | pageSize: 500 |
| | | }, { |
| | | showErrorMessage: false |
| | | }), |
| | | { records: [] }, |
| | | { |
| | | timeoutMessage: '站点列表加载超时,已停止等待' |
| | | } |
| | | ) |
| | | stationOptions.value = buildSelectOptions(defaultResponseAdapter(response).records, ['stationName', 'name']) |
| | | } |
| | | |
| | | onMounted(async () => { |
| | | await Promise.all([loadTypeOptions(), loadDeviceOptions(), loadAreaOptions(), loadStationOptions()]) |
| | | await Promise.all([loadTypeOptions(), loadDeviceOptions(), loadAreaOptions()]) |
| | | }) |
| | | </script> |