| | |
| | | <ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData"> |
| | | <template #left> |
| | | <ElSpace wrap> |
| | | <ElButton v-auth="'add'" @click="showDialog('add')" v-ripple>新增库区</ElButton> |
| | | <ElButton v-auth="'add'" @click="openWarehouseAreasDialog('add')" v-ripple>新增库区</ElButton> |
| | | <ElButton |
| | | v-auth="'delete'" |
| | | type="danger" |
| | |
| | | const shipperOptions = ref([]) |
| | | const supplierOptions = ref([]) |
| | | const typeOptions = ref([]) |
| | | const companyOptionsLoaded = ref(false) |
| | | const companyOptionsLoading = ref(null) |
| | | let handleDeleteAction = null |
| | | |
| | | const searchItems = computed(() => [ |
| | |
| | | |
| | | async function openEditDialog(row) { |
| | | try { |
| | | await ensureCompanyOptions() |
| | | const detail = await guardRequestWithMessage(fetchWarehouseAreasDetail(row.id), {}, { |
| | | timeoutMessage: '库区详情加载超时,已停止等待' |
| | | }) |
| | |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || '获取库区详情失败') |
| | | } |
| | | } |
| | | |
| | | async function openWarehouseAreasDialog(type, record) { |
| | | await ensureCompanyOptions() |
| | | showDialog(type, record) |
| | | } |
| | | |
| | | const { columns, columnChecks, data, loading, pagination, getData, replaceSearchParams, resetSearchParams, handleSizeChange, handleCurrentChange, refreshData, refreshCreate, refreshUpdate, refreshRemove } = |
| | |
| | | resetSearchParams() |
| | | } |
| | | |
| | | async function ensureCompanyOptions() { |
| | | if (companyOptionsLoaded.value) { |
| | | return |
| | | } |
| | | |
| | | if (companyOptionsLoading.value) { |
| | | await companyOptionsLoading.value |
| | | return |
| | | } |
| | | |
| | | companyOptionsLoading.value = (async () => { |
| | | const records = await guardRequestWithMessage(fetchCompanysList(), [], { |
| | | timeoutMessage: '往来企业选项加载超时,已停止等待' |
| | | }) |
| | | const normalizedRecords = defaultResponseAdapter(records).records |
| | | shipperOptions.value = normalizedRecords |
| | | .filter((item) => item.type === 'shipper') |
| | | .map((item) => ({ |
| | | label: item.name || item.code || `货主 ${item.id}`, |
| | | value: item.id |
| | | })) |
| | | supplierOptions.value = normalizedRecords |
| | | .filter((item) => item.type === 'supplier') |
| | | .map((item) => ({ |
| | | label: item.name || item.code || `供应商 ${item.id}`, |
| | | value: item.id |
| | | })) |
| | | companyOptionsLoaded.value = true |
| | | })() |
| | | |
| | | try { |
| | | await companyOptionsLoading.value |
| | | } finally { |
| | | companyOptionsLoading.value = null |
| | | } |
| | | } |
| | | |
| | | async function loadWarehouseOptions() { |
| | | const records = await guardRequestWithMessage(fetchWarehouseList(), [], { |
| | | timeoutMessage: '仓库选项加载超时,已停止等待' |
| | |
| | | label: item.name || item.code || `仓库 ${item.id}`, |
| | | value: item.id |
| | | })) |
| | | } |
| | | |
| | | async function loadCompanyOptions() { |
| | | const records = await guardRequestWithMessage(fetchCompanysList(), [], { |
| | | timeoutMessage: '往来企业选项加载超时,已停止等待' |
| | | }) |
| | | const normalizedRecords = defaultResponseAdapter(records).records |
| | | shipperOptions.value = normalizedRecords |
| | | .filter((item) => item.type === 'shipper') |
| | | .map((item) => ({ |
| | | label: item.name || item.code || `货主 ${item.id}`, |
| | | value: item.id |
| | | })) |
| | | supplierOptions.value = normalizedRecords |
| | | .filter((item) => item.type === 'supplier') |
| | | .map((item) => ({ |
| | | label: item.name || item.code || `供应商 ${item.id}`, |
| | | value: item.id |
| | | })) |
| | | } |
| | | |
| | | async function loadTypeOptions() { |
| | |
| | | } |
| | | |
| | | onMounted(async () => { |
| | | await Promise.all([loadWarehouseOptions(), loadCompanyOptions(), loadTypeOptions(), getData()]) |
| | | await Promise.all([loadWarehouseOptions(), loadTypeOptions(), getData()]) |
| | | }) |
| | | </script> |