<template>
|
<div class="revise-log-page art-full-height">
|
<ArtSearchBar
|
v-model="searchForm"
|
:items="searchItems"
|
:showExpand="true"
|
@search="handleSearch"
|
@reset="handleReset"
|
/>
|
|
<ElCard class="art-table-card">
|
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData" />
|
|
<ArtTable
|
:loading="loading"
|
:data="data"
|
:columns="columns"
|
:pagination="pagination"
|
@pagination:size-change="handleSizeChange"
|
@pagination:current-change="handleCurrentChange"
|
/>
|
</ElCard>
|
|
<ReviseLogDetailDrawer
|
v-model:visible="detailDrawerVisible"
|
:loading="detailLoading"
|
:summary="detailData"
|
:item-loading="itemLoading"
|
:item-data="itemTableData"
|
:item-columns="itemColumns"
|
:item-pagination="itemPagination"
|
@item-size-change="handleItemSizeChange"
|
@item-current-change="handleItemCurrentChange"
|
/>
|
</div>
|
</template>
|
|
<script setup>
|
import { computed, reactive, ref } from 'vue'
|
import { ElMessage } from 'element-plus'
|
import { useTable } from '@/hooks/core/useTable'
|
import { useTableColumns } from '@/hooks/core/useTableColumns'
|
import { defaultResponseAdapter } from '@/utils/table/tableUtils'
|
import { guardRequestWithMessage } from '@/utils/sys/requestGuard'
|
import { fetchGetReviseLogDetail, fetchReviseLogPage } from '@/api/revise-log'
|
import { fetchReviseLogItemPage } from '@/api/revise-log-item'
|
import ReviseLogDetailDrawer from './modules/revise-log-detail-drawer.vue'
|
import { createReviseLogTableColumns } from './reviseLogTable.columns'
|
import {
|
buildReviseLogPageQueryParams,
|
buildReviseLogSearchParams,
|
createReviseLogSearchState,
|
getReviseLogPaginationKey,
|
getReviseLogStatusOptions,
|
getReviseLogTypeOptions,
|
normalizeReviseLogRow
|
} from './reviseLogPage.helpers'
|
import { createReviseLogItemDetailColumns } from '../revise-log-item/reviseLogItemTable.columns'
|
import { normalizeReviseLogItemRow } from '../revise-log-item/reviseLogItemPage.helpers'
|
|
defineOptions({ name: 'ReviseLog' })
|
|
const searchForm = ref(createReviseLogSearchState())
|
const detailDrawerVisible = ref(false)
|
const detailLoading = ref(false)
|
const detailData = ref({})
|
const itemLoading = ref(false)
|
const itemTableData = ref([])
|
const activeDetail = ref({})
|
const itemPagination = reactive({ current: 1, size: 20, total: 0 })
|
|
const searchItems = computed(() => [
|
{
|
label: '关键字',
|
key: 'condition',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入调整单号/库位/容器码' }
|
},
|
{
|
label: '调整单号',
|
key: 'reviseId',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入调整单ID' }
|
},
|
{
|
label: '调整编码',
|
key: 'reviseCode',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入调整单编码' }
|
},
|
{
|
label: '仓库ID',
|
key: 'warehouseId',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入仓库ID' }
|
},
|
{
|
label: '库区ID',
|
key: 'areaId',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入库区ID' }
|
},
|
{
|
label: '调整类型',
|
key: 'type',
|
type: 'select',
|
props: {
|
clearable: true,
|
options: getReviseLogTypeOptions().map((item) => ({ label: item.label, value: item.value }))
|
}
|
},
|
{
|
label: '容器码',
|
key: 'barcode',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入容器码' }
|
},
|
{
|
label: '库位状态',
|
key: 'useStatus',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入库位状态' }
|
},
|
{
|
label: '巷道',
|
key: 'channel',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入巷道' }
|
},
|
{
|
label: '排',
|
key: 'row',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入排' }
|
},
|
{
|
label: '列',
|
key: 'col',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入列' }
|
},
|
{
|
label: '层',
|
key: 'lev',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入层' }
|
},
|
{
|
label: '状态',
|
key: 'status',
|
type: 'select',
|
props: {
|
clearable: true,
|
options: getReviseLogStatusOptions().map((item) => ({ label: item.label, value: item.value }))
|
}
|
},
|
{
|
label: '备注',
|
key: 'memo',
|
type: 'input',
|
props: { clearable: true, placeholder: '请输入备注' }
|
},
|
{
|
label: '开始时间',
|
key: 'timeStart',
|
type: 'date',
|
props: { clearable: true, valueFormat: 'YYYY-MM-DD', type: 'date' }
|
},
|
{
|
label: '结束时间',
|
key: 'timeEnd',
|
type: 'date',
|
props: { clearable: true, valueFormat: 'YYYY-MM-DD', type: 'date' }
|
}
|
])
|
|
function updatePaginationState(target, response, fallbackCurrent, fallbackSize) {
|
target.total = Number(response?.total || 0)
|
target.current = Number(response?.current || fallbackCurrent || 1)
|
target.size = Number(response?.size || fallbackSize || target.size || 20)
|
}
|
|
async function openDetail(row) {
|
detailDrawerVisible.value = true
|
detailLoading.value = true
|
activeDetail.value = row || {}
|
itemTableData.value = []
|
itemPagination.current = 1
|
try {
|
detailData.value = normalizeReviseLogRow(
|
await guardRequestWithMessage(fetchGetReviseLogDetail(row.id), {}, {
|
timeoutMessage: '库位调整日志详情加载超时,已停止等待'
|
})
|
)
|
await loadItemData(row.id)
|
} catch (error) {
|
detailDrawerVisible.value = false
|
detailData.value = {}
|
ElMessage.error(error?.message || '获取库位调整日志详情失败')
|
} finally {
|
detailLoading.value = false
|
}
|
}
|
|
async function loadItemData(reviseLogId = activeDetail.value?.id) {
|
if (!reviseLogId) {
|
itemTableData.value = []
|
return
|
}
|
itemLoading.value = true
|
try {
|
const response = await guardRequestWithMessage(
|
fetchReviseLogItemPage({
|
reviseLogId,
|
current: itemPagination.current,
|
pageSize: itemPagination.size
|
}),
|
{ records: [], total: 0, current: itemPagination.current, size: itemPagination.size },
|
{ timeoutMessage: '库位调整日志明细加载超时,已停止等待' }
|
)
|
const normalized = defaultResponseAdapter(response)
|
itemTableData.value = Array.isArray(normalized?.records)
|
? normalized.records.map((record) => normalizeReviseLogItemRow(record))
|
: []
|
updatePaginationState(itemPagination, normalized, itemPagination.current, itemPagination.size)
|
} finally {
|
itemLoading.value = false
|
}
|
}
|
|
const { columns, columnChecks, data, loading, pagination, getData, replaceSearchParams, resetSearchParams, handleSizeChange, handleCurrentChange, refreshData } =
|
useTable({
|
core: {
|
apiFn: fetchReviseLogPage,
|
apiParams: buildReviseLogPageQueryParams(searchForm.value),
|
paginationKey: getReviseLogPaginationKey(),
|
columnsFactory: () => createReviseLogTableColumns({ handleView: openDetail })
|
},
|
transform: {
|
dataTransformer: (records) => (Array.isArray(records) ? records.map((item) => normalizeReviseLogRow(item)) : [])
|
}
|
})
|
|
const itemColumns = computed(() => createReviseLogItemDetailColumns())
|
|
function handleItemSizeChange(size) {
|
itemPagination.size = size
|
itemPagination.current = 1
|
loadItemData()
|
}
|
|
function handleItemCurrentChange(current) {
|
itemPagination.current = current
|
loadItemData()
|
}
|
|
function handleSearch(params) {
|
replaceSearchParams(buildReviseLogSearchParams(params))
|
getData()
|
}
|
|
function handleReset() {
|
Object.assign(searchForm.value, createReviseLogSearchState())
|
resetSearchParams()
|
}
|
</script>
|