| | |
| | | buildLocSavePayload, |
| | | buildLocSearchParams, |
| | | createLocSearchState, |
| | | filterLocAreaOptionsByWarehouse, |
| | | getLocPaginationKey, |
| | | getLocStatusOptions, |
| | | getLocUseStatusOptions, |
| | |
| | | |
| | | const reportTitle = LOC_REPORT_TITLE |
| | | const reportQueryParams = computed(() => buildLocSearchParams(searchForm.value)) |
| | | const filteredSearchAreaOptions = computed(() => |
| | | filterLocAreaOptionsByWarehouse(areaOptions.value, searchForm.value.warehouseId) |
| | | ) |
| | | |
| | | const searchItems = computed(() => [ |
| | | { |
| | | label: '关键字', |
| | | key: 'condition', |
| | | function createInputSearchItem(label, key, placeholder) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入库位号/容器编码/备注' |
| | | } |
| | | }, |
| | | { |
| | | label: '仓库', |
| | | key: 'warehouseId', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | filterable: true, |
| | | options: warehouseOptions.value |
| | | } |
| | | }, |
| | | { |
| | | label: '库区', |
| | | key: 'areaId', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | filterable: true, |
| | | options: areaOptions.value.filter((item) => { |
| | | if (!searchForm.value.warehouseId) { |
| | | return true |
| | | } |
| | | if (item?.warehouseId === undefined || item?.warehouseId === null) { |
| | | return true |
| | | } |
| | | return Number(item.warehouseId) === Number(searchForm.value.warehouseId) |
| | | }) |
| | | } |
| | | }, |
| | | { |
| | | label: '库位号', |
| | | key: 'code', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入库位号' |
| | | } |
| | | }, |
| | | { |
| | | label: '使用状态', |
| | | key: 'useStatus', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | filterable: true, |
| | | options: getLocUseStatusOptions() |
| | | } |
| | | }, |
| | | { |
| | | label: '排', |
| | | key: 'row', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入排' |
| | | } |
| | | }, |
| | | { |
| | | label: '列', |
| | | key: 'col', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入列' |
| | | } |
| | | }, |
| | | { |
| | | label: '层', |
| | | key: 'lev', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入层' |
| | | } |
| | | }, |
| | | { |
| | | label: '巷道', |
| | | key: 'channel', |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder: '请输入巷道' |
| | | } |
| | | }, |
| | | { |
| | | label: '状态', |
| | | key: 'status', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | options: getLocStatusOptions() |
| | | } |
| | | }, |
| | | { |
| | | label: '容器编码', |
| | | key: 'barcode', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入容器编码' |
| | | } |
| | | }, |
| | | { |
| | | label: '备注', |
| | | key: 'memo', |
| | | type: 'input', |
| | | props: { |
| | | clearable: true, |
| | | placeholder: '请输入备注' |
| | | placeholder |
| | | } |
| | | } |
| | | } |
| | | |
| | | function createNumberSearchItem(label, key, placeholder) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'number', |
| | | props: { |
| | | min: 0, |
| | | controlsPosition: 'right', |
| | | placeholder |
| | | } |
| | | } |
| | | } |
| | | |
| | | function createSelectSearchItem(label, key, options, extraProps = {}) { |
| | | return { |
| | | label, |
| | | key, |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | ...extraProps, |
| | | options |
| | | } |
| | | } |
| | | } |
| | | |
| | | const searchItems = computed(() => [ |
| | | createInputSearchItem('关键字', 'condition', '请输入库位号/容器编码/备注'), |
| | | createSelectSearchItem('仓库', 'warehouseId', warehouseOptions.value, { filterable: true }), |
| | | createSelectSearchItem('库区', 'areaId', filteredSearchAreaOptions.value, { filterable: true }), |
| | | createInputSearchItem('库位号', 'code', '请输入库位号'), |
| | | createSelectSearchItem('使用状态', 'useStatus', getLocUseStatusOptions(), { filterable: true }), |
| | | createNumberSearchItem('排', 'row', '请输入排'), |
| | | createNumberSearchItem('列', 'col', '请输入列'), |
| | | createNumberSearchItem('层', 'lev', '请输入层'), |
| | | createNumberSearchItem('巷道', 'channel', '请输入巷道'), |
| | | createSelectSearchItem('状态', 'status', getLocStatusOptions()), |
| | | createInputSearchItem('容器编码', 'barcode', '请输入容器编码'), |
| | | createInputSearchItem('备注', 'memo', '请输入备注') |
| | | ]) |
| | | |
| | | async function fetchLocDetailById(id) { |
| | | return guardRequestWithMessage(fetchGetLocDetail(id), {}, { |
| | | timeoutMessage: '库位详情加载超时,已停止等待' |
| | | }) |
| | | } |
| | | |
| | | async function openDetail(row) { |
| | | detailDrawerVisible.value = true |
| | | detailLoading.value = true |
| | | try { |
| | | const detail = await guardRequestWithMessage(fetchGetLocDetail(row.id), {}, { |
| | | timeoutMessage: '库位详情加载超时,已停止等待' |
| | | }) |
| | | detailData.value = normalizeLocListRow(detail) |
| | | detailData.value = normalizeLocListRow(await fetchLocDetailById(row.id)) |
| | | } catch (error) { |
| | | detailDrawerVisible.value = false |
| | | detailData.value = {} |
| | |
| | | |
| | | async function openEditDialog(row) { |
| | | try { |
| | | const detail = await guardRequestWithMessage(fetchGetLocDetail(row.id), {}, { |
| | | timeoutMessage: '库位详情加载超时,已停止等待' |
| | | }) |
| | | showDialog('edit', detail) |
| | | showDialog('edit', await fetchLocDetailById(row.id)) |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || '获取库位详情失败') |
| | | } |
| | |
| | | }) |
| | | ) |
| | | |
| | | async function loadWarehouseOptions() { |
| | | const response = await guardRequestWithMessage(fetchWarehouseList(), [], { |
| | | timeoutMessage: '仓库选项加载超时,已停止等待' |
| | | }) |
| | | warehouseOptions.value = resolveLocWarehouseOptions(defaultResponseAdapter(response).records) |
| | | } |
| | | |
| | | async function loadAreaOptions() { |
| | | const response = await guardRequestWithMessage(fetchWarehouseAreasList(), [], { |
| | | timeoutMessage: '库区选项加载超时,已停止等待' |
| | | }) |
| | | areaOptions.value = resolveLocAreaOptions(defaultResponseAdapter(response).records) |
| | | } |
| | | |
| | | async function loadLocTypeOptions() { |
| | | const response = await guardRequestWithMessage(fetchLocTypeList(), [], { |
| | | timeoutMessage: '库位类型选项加载超时,已停止等待' |
| | | }) |
| | | locTypeOptions.value = resolveLocTypeOptions(defaultResponseAdapter(response).records) |
| | | async function loadOptions(requestFn, resolver, targetRef, timeoutMessage) { |
| | | const response = await guardRequestWithMessage(requestFn(), [], { timeoutMessage }) |
| | | targetRef.value = resolver(defaultResponseAdapter(response).records) |
| | | } |
| | | |
| | | function handleSearch(params) { |
| | |
| | | } |
| | | |
| | | onMounted(async () => { |
| | | await Promise.all([loadWarehouseOptions(), loadAreaOptions(), loadLocTypeOptions()]) |
| | | await Promise.all([ |
| | | loadOptions(fetchWarehouseList, resolveLocWarehouseOptions, warehouseOptions, '仓库选项加载超时,已停止等待'), |
| | | loadOptions(fetchWarehouseAreasList, resolveLocAreaOptions, areaOptions, '库区选项加载超时,已停止等待'), |
| | | loadOptions(fetchLocTypeList, resolveLocTypeOptions, locTypeOptions, '库位类型选项加载超时,已停止等待') |
| | | ]) |
| | | }) |
| | | </script> |