| | |
| | | :columns="publicTaskColumns" |
| | | :pagination="publicTaskPagination" |
| | | :can-submit="publicTaskCanSubmit" |
| | | :warning-text="publicTaskWarningText" |
| | | @size-change="handlePublicTaskSizeChange" |
| | | @current-change="handlePublicTaskCurrentChange" |
| | | @submit="handleSubmitPublicTask" |
| | |
| | | <script setup> |
| | | import { computed, reactive, ref } from 'vue' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { useI18n } from 'vue-i18n' |
| | | import { useUserStore } from '@/store/modules/user' |
| | | import { useTable } from '@/hooks/core/useTable' |
| | | import { usePrintExportPage } from '@/views/system/common/usePrintExportPage' |
| | |
| | | buildWaveReportMeta, |
| | | buildWaveSearchParams, |
| | | createWaveSearchState, |
| | | getWaveReportTitle, |
| | | normalizeWaveItemRow, |
| | | normalizeWaveRow, |
| | | WAVE_REPORT_STYLE |
| | |
| | | |
| | | defineOptions({ name: 'WaveOrder' }) |
| | | |
| | | const { t } = useI18n() |
| | | const userStore = useUserStore() |
| | | const reportTitle = '波次单报表' |
| | | const reportTitle = computed(() => getWaveReportTitle(t)) |
| | | const searchForm = ref(createWaveSearchState()) |
| | | const selectedRows = ref([]) |
| | | const detailDrawerVisible = ref(false) |
| | |
| | | }) |
| | | |
| | | const reportQueryParams = computed(() => buildWaveSearchParams(searchForm.value)) |
| | | const detailColumns = computed(() => createWaveDetailItemColumns()) |
| | | const publicTaskColumns = computed(() => createWavePreviewItemColumns()) |
| | | const detailColumns = computed(() => createWaveDetailItemColumns(t)) |
| | | const publicTaskColumns = computed(() => createWavePreviewItemColumns(t)) |
| | | const publicTaskCanSubmit = computed( |
| | | () => publicTaskRows.value.length > 0 && publicTaskRows.value.every((row) => row.stockLocsText && row.stockLocsText !== '[]') |
| | | ) |
| | | const publicTaskWarningText = computed(() => t('pages.orders.wave.messages.publicTaskWarning')) |
| | | const searchItems = computed(() => [ |
| | | { label: '关键字', key: 'condition', type: 'input', props: { clearable: true, placeholder: '请输入波次单号/备注' } }, |
| | | { label: '波次单号', key: 'code', type: 'input', props: { clearable: true, placeholder: '请输入波次单号' } }, |
| | | { |
| | | label: '波次类型', |
| | | key: 'type', |
| | | type: 'select', |
| | | props: { clearable: true, options: [{ label: '手动', value: 0 }, { label: '自动', value: 1 }] } |
| | | label: t('pages.orders.wave.search.condition'), |
| | | key: 'condition', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: t('pages.orders.wave.search.conditionPlaceholder') } |
| | | }, |
| | | { |
| | | label: '波次状态', |
| | | label: t('pages.orders.wave.search.code'), |
| | | key: 'code', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: t('pages.orders.wave.search.codePlaceholder') } |
| | | }, |
| | | { |
| | | label: t('pages.orders.wave.search.type'), |
| | | key: 'type', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | options: [ |
| | | { label: t('pages.orders.wave.status.type.0'), value: 0 }, |
| | | { label: t('pages.orders.wave.status.type.1'), value: 1 } |
| | | ] |
| | | } |
| | | }, |
| | | { |
| | | label: t('pages.orders.wave.search.exceStatus'), |
| | | key: 'exceStatus', |
| | | type: 'select', |
| | | props: { |
| | | clearable: true, |
| | | options: [ |
| | | { label: '等待执行', value: 0 }, |
| | | { label: '正在执行', value: 1 }, |
| | | { label: '暂停执行', value: 2 }, |
| | | { label: '执行完成', value: 3 } |
| | | { label: t('pages.orders.wave.status.exceStatus.0'), value: 0 }, |
| | | { label: t('pages.orders.wave.status.exceStatus.1'), value: 1 }, |
| | | { label: t('pages.orders.wave.status.exceStatus.2'), value: 2 }, |
| | | { label: t('pages.orders.wave.status.exceStatus.3'), value: 3 } |
| | | ] |
| | | } |
| | | }, |
| | | { |
| | | label: '状态', |
| | | label: t('pages.orders.wave.search.status'), |
| | | key: 'status', |
| | | type: 'select', |
| | | props: { clearable: true, options: [{ label: '正常', value: 1 }, { label: '禁用', value: 0 }] } |
| | | props: { |
| | | clearable: true, |
| | | options: [ |
| | | { label: t('common.status.normal'), value: 1 }, |
| | | { label: t('common.status.disabled'), value: 0 } |
| | | ] |
| | | } |
| | | }, |
| | | { label: '备注', key: 'memo', type: 'input', props: { clearable: true, placeholder: '请输入备注' } }, |
| | | { label: '开始时间', key: 'timeStart', type: 'date', props: { clearable: true, type: 'date', valueFormat: 'YYYY-MM-DD' } }, |
| | | { label: '结束时间', key: 'timeEnd', type: 'date', props: { clearable: true, type: 'date', valueFormat: 'YYYY-MM-DD' } } |
| | | { |
| | | label: t('pages.orders.wave.search.memo'), |
| | | key: 'memo', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: t('pages.orders.wave.search.memoPlaceholder') } |
| | | }, |
| | | { label: t('pages.orders.wave.search.timeStart'), key: 'timeStart', type: 'date', props: { clearable: true, type: 'date', valueFormat: 'YYYY-MM-DD' } }, |
| | | { label: t('pages.orders.wave.search.timeEnd'), key: 'timeEnd', type: 'date', props: { clearable: true, type: 'date', valueFormat: 'YYYY-MM-DD' } } |
| | | ]) |
| | | |
| | | function updatePaginationState(target, response, fallbackCurrent, fallbackSize) { |
| | |
| | | } |
| | | |
| | | async function openPublicTask(row) { |
| | | publicTaskWave.value = normalizeWaveRow(row) |
| | | publicTaskWave.value = normalizeWaveRow(row, t) |
| | | publicTaskPagination.current = 1 |
| | | publicTaskDialogVisible.value = true |
| | | await loadPublicTaskResources() |
| | |
| | | } |
| | | if (action.key === 'pause') { |
| | | await fetchPauseWave(row.id) |
| | | ElMessage.success('波次已暂停') |
| | | ElMessage.success(t('pages.orders.wave.messages.pauseSuccess')) |
| | | await refreshData() |
| | | return |
| | | } |
| | | if (action.key === 'continue') { |
| | | await fetchContinueWave(row.id) |
| | | ElMessage.success('波次已继续') |
| | | ElMessage.success(t('pages.orders.wave.messages.continueSuccess')) |
| | | await refreshData() |
| | | return |
| | | } |
| | | if (action.key === 'stop') { |
| | | await ElMessageBox.confirm(`确定终止波次单 ${row.code || ''} 吗?`, '终止确认', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | await ElMessageBox.confirm(t('pages.orders.wave.messages.stopConfirm', { code: row.code || '' }), t('pages.orders.wave.messages.stopTitle'), { |
| | | confirmButtonText: t('common.confirm'), |
| | | cancelButtonText: t('common.cancel'), |
| | | type: 'warning' |
| | | }) |
| | | await fetchStopWave(row.id) |
| | | ElMessage.success('波次已终止') |
| | | ElMessage.success(t('pages.orders.wave.messages.stopSuccess')) |
| | | await refreshData() |
| | | } |
| | | } catch (error) { |
| | | if (error === 'cancel' || error?.message === 'cancel') return |
| | | ElMessage.error(error?.message || '波次操作失败') |
| | | ElMessage.error(error?.message || t('pages.orders.wave.messages.actionFailed')) |
| | | } |
| | | } |
| | | |
| | |
| | | core: { |
| | | apiFn: fetchWavePage, |
| | | apiParams: buildWavePageQueryParams(searchForm.value), |
| | | columnsFactory: () => createWaveTableColumns({ handleActionClick }) |
| | | columnsFactory: () => createWaveTableColumns({ handleActionClick, t }) |
| | | }, |
| | | transform: { |
| | | dataTransformer: (records) => (Array.isArray(records) ? records.map((item) => normalizeWaveRow(item)) : []) |
| | | dataTransformer: (records) => (Array.isArray(records) ? records.map((item) => normalizeWaveRow(item, t)) : []) |
| | | } |
| | | }) |
| | | |
| | |
| | | detailLoading.value = true |
| | | try { |
| | | const [detailResponse, previewResponse] = await Promise.all([ |
| | | guardRequestWithMessage(fetchGetWaveDetail(activeWaveId.value), {}, { timeoutMessage: '波次单详情加载超时,已停止等待' }), |
| | | guardRequestWithMessage(fetchGetWaveDetail(activeWaveId.value), {}, { timeoutMessage: t('pages.orders.wave.messages.detailTimeout') }), |
| | | guardRequestWithMessage( |
| | | fetchWavePreviewPage(buildWaveDetailQueryParams({ waveId: activeWaveId.value, current: detailPagination.current, pageSize: detailPagination.size })), |
| | | { records: [], total: 0, current: detailPagination.current, size: detailPagination.size }, |
| | | { timeoutMessage: '波次预览明细加载超时,已停止等待' } |
| | | { timeoutMessage: t('pages.orders.wave.messages.previewTimeout') } |
| | | ) |
| | | ]) |
| | | detailData.value = normalizeWaveRow(detailResponse) |
| | | detailTableData.value = Array.isArray(previewResponse?.records) ? previewResponse.records.map((item) => normalizeWaveItemRow(item)) : [] |
| | | detailData.value = normalizeWaveRow(detailResponse, t) |
| | | detailTableData.value = Array.isArray(previewResponse?.records) ? previewResponse.records.map((item) => normalizeWaveItemRow(item, t)) : [] |
| | | updatePaginationState(detailPagination, previewResponse, detailPagination.current, detailPagination.size) |
| | | } finally { |
| | | detailLoading.value = false |
| | |
| | | const previewResponse = await guardRequestWithMessage( |
| | | fetchWavePreviewPage(buildWaveDetailQueryParams({ waveId: publicTaskWave.value.id, current: publicTaskPagination.current, pageSize: publicTaskPagination.size })), |
| | | { records: [], total: 0, current: publicTaskPagination.current, size: publicTaskPagination.size }, |
| | | { timeoutMessage: '波次下发预览加载超时,已停止等待' } |
| | | { timeoutMessage: t('pages.orders.wave.messages.publicTaskTimeout') } |
| | | ) |
| | | publicTaskRows.value = Array.isArray(previewResponse?.records) ? previewResponse.records.map((item) => normalizeWaveItemRow(item)) : [] |
| | | publicTaskRows.value = Array.isArray(previewResponse?.records) ? previewResponse.records.map((item) => normalizeWaveItemRow(item, t)) : [] |
| | | updatePaginationState(publicTaskPagination, previewResponse, publicTaskPagination.current, publicTaskPagination.size) |
| | | } finally { |
| | | publicTaskLoading.value = false |
| | |
| | | }) |
| | | const result = defaultResponseAdapter(response) |
| | | if (result?.code !== 200 && result?.success !== true) { |
| | | throw new Error(result?.message || '波次下发失败') |
| | | throw new Error(result?.message || t('pages.orders.wave.messages.publicTaskFailed')) |
| | | } |
| | | ElMessage.success(result?.message || '波次已下发') |
| | | ElMessage.success(result?.message || t('pages.orders.wave.messages.publicTaskSuccess')) |
| | | publicTaskDialogVisible.value = false |
| | | await refreshData() |
| | | if (detailDrawerVisible.value && activeWaveId.value === publicTaskWave.value.id) { |
| | | await loadDetailResources() |
| | | } |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || '波次下发失败') |
| | | ElMessage.error(error?.message || t('pages.orders.wave.messages.publicTaskFailed')) |
| | | } finally { |
| | | publicTaskSubmitting.value = false |
| | | } |
| | |
| | | } |
| | | }), |
| | | resolvePrintRecords, |
| | | buildPreviewRows: (records) => buildWavePrintRows(records), |
| | | buildPreviewRows: (records) => buildWavePrintRows(records, t), |
| | | buildPreviewMeta: (rows) => { |
| | | const now = new Date() |
| | | return { |
| | | reportTitle, |
| | | reportTitle: reportTitle.value, |
| | | reportDate: now.toLocaleDateString('zh-CN'), |
| | | printedAt: now.toLocaleString('zh-CN', { hour12: false }), |
| | | operator: userStore.getUserInfo?.name || userStore.getUserInfo?.username || '', |
| | |
| | | buildWaveReportMeta({ |
| | | previewMeta: rawPreviewMeta.value, |
| | | count: previewRows.value.length, |
| | | orientation: rawPreviewMeta.value?.reportStyle?.orientation || WAVE_REPORT_STYLE.orientation |
| | | orientation: rawPreviewMeta.value?.reportStyle?.orientation || WAVE_REPORT_STYLE.orientation, |
| | | t |
| | | }) |
| | | ) |
| | | </script> |