| | |
| | | :loading="autoRunLoading" |
| | | @click="handleToggleAutoRun(true)" |
| | | > |
| | | 自动下发任务 |
| | | {{ t('pages.task.buttons.autoRun') }} |
| | | </ElButton> |
| | | <ElButton |
| | | v-else |
| | |
| | | :loading="autoRunLoading" |
| | | @click="handleToggleAutoRun(false)" |
| | | > |
| | | 暂停自动下发 |
| | | {{ t('pages.task.buttons.pauseAutoRun') }} |
| | | </ElButton> |
| | | </ElSpace> |
| | | </template> |
| | |
| | | <script setup> |
| | | import { ElMessage } from 'element-plus' |
| | | import { computed, h, onMounted, onUnmounted, reactive, ref } from 'vue' |
| | | import { useI18n } from 'vue-i18n' |
| | | import { useTableColumns } from '@/hooks/core/useTableColumns' |
| | | import { guardRequestWithMessage } from '@/utils/sys/requestGuard' |
| | | import { |
| | |
| | | } from './taskPage.helpers' |
| | | |
| | | defineOptions({ name: 'Task' }) |
| | | const { t } = useI18n() |
| | | |
| | | const loading = ref(false) |
| | | const tableData = ref([]) |
| | |
| | | |
| | | const searchItems = computed(() => [ |
| | | { |
| | | label: '关键字', |
| | | label: t('pages.task.search.condition'), |
| | | key: 'condition', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: '请输入任务号/库位/托盘码' } |
| | | props: { clearable: true, placeholder: t('pages.task.placeholder.condition') } |
| | | }, |
| | | { |
| | | label: '任务号', |
| | | label: t('pages.task.search.taskCode'), |
| | | key: 'taskCode', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: '请输入任务号' } |
| | | props: { clearable: true, placeholder: t('pages.task.placeholder.taskCode') } |
| | | }, |
| | | { |
| | | label: '源库位', |
| | | label: t('pages.task.search.orgLoc'), |
| | | key: 'orgLoc', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: '请输入源库位' } |
| | | props: { clearable: true, placeholder: t('pages.task.placeholder.orgLoc') } |
| | | }, |
| | | { |
| | | label: '目标库位', |
| | | label: t('pages.task.search.targLoc'), |
| | | key: 'targLoc', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: '请输入目标库位' } |
| | | props: { clearable: true, placeholder: t('pages.task.placeholder.targLoc') } |
| | | }, |
| | | { |
| | | label: '托盘码', |
| | | label: t('pages.task.search.barcode'), |
| | | key: 'barcode', |
| | | type: 'input', |
| | | props: { clearable: true, placeholder: '请输入托盘码' } |
| | | props: { clearable: true, placeholder: t('pages.task.placeholder.barcode') } |
| | | } |
| | | ]) |
| | | |
| | | const detailColumns = computed(() => [ |
| | | { |
| | | type: 'globalIndex', |
| | | label: '序号', |
| | | label: t('table.index'), |
| | | width: 72, |
| | | align: 'center' |
| | | }, |
| | | { |
| | | prop: 'orderTypeLabel', |
| | | label: '单据类型', |
| | | label: t('pages.orders.delivery.detail.type'), |
| | | minWidth: 120, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'wkTypeLabel', |
| | | label: '业务类型', |
| | | label: t('pages.orders.delivery.detail.wkType'), |
| | | minWidth: 120, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'platWorkCode', |
| | | label: '工单号', |
| | | label: t('pages.orders.transfer.detail.relatedCode'), |
| | | minWidth: 150, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'platItemId', |
| | | label: '行号', |
| | | label: t('pages.orders.delivery.table.platItemId'), |
| | | minWidth: 100, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'matnrCode', |
| | | label: '物料编码', |
| | | label: t('pages.orders.delivery.table.matnrCode'), |
| | | minWidth: 150, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'maktx', |
| | | label: '物料名称', |
| | | label: t('pages.orders.delivery.table.maktx'), |
| | | minWidth: 220, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'batch', |
| | | label: '批次', |
| | | label: t('table.batch'), |
| | | minWidth: 140, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'unit', |
| | | label: '单位', |
| | | label: t('table.unit'), |
| | | width: 100 |
| | | }, |
| | | { |
| | | prop: 'anfme', |
| | | label: '数量', |
| | | label: t('pages.orders.delivery.table.anfme'), |
| | | width: 100, |
| | | align: 'right' |
| | | }, |
| | | { |
| | | prop: 'updateByText', |
| | | label: '更新人', |
| | | label: t('pages.orders.delivery.detail.updateBy'), |
| | | minWidth: 120, |
| | | showOverflowTooltip: true |
| | | }, |
| | | { |
| | | prop: 'updateTimeText', |
| | | label: '更新时间', |
| | | label: t('pages.orders.delivery.detail.updateTime'), |
| | | minWidth: 180, |
| | | showOverflowTooltip: true |
| | | } |
| | |
| | | } |
| | | |
| | | if (action.key === 'complete') { |
| | | await confirmTaskAction(`确定完成任务 ${row.taskCode || ''} 吗?`) |
| | | await confirmTaskAction(t('pages.task.messages.completeConfirm', { code: row.taskCode || '' })) |
| | | await fetchCompleteTask(row.id) |
| | | ElMessage.success('任务完成成功') |
| | | ElMessage.success(t('pages.task.messages.completeSuccess')) |
| | | } else if (action.key === 'remove') { |
| | | await confirmTaskAction(`确定取消任务 ${row.taskCode || ''} 吗?`) |
| | | await confirmTaskAction(t('pages.task.messages.removeConfirm', { code: row.taskCode || '' })) |
| | | await fetchRemoveTask(row.id) |
| | | ElMessage.success('任务取消成功') |
| | | ElMessage.success(t('pages.task.messages.removeSuccess')) |
| | | } else if (action.key === 'check') { |
| | | await confirmTaskAction(`确定执行盘点出库任务 ${row.taskCode || ''} 吗?`) |
| | | await confirmTaskAction(t('pages.task.messages.checkConfirm', { code: row.taskCode || '' })) |
| | | await fetchCheckTask(row.id) |
| | | ElMessage.success('盘点出库成功') |
| | | ElMessage.success(t('pages.task.messages.checkSuccess')) |
| | | } else if (action.key === 'pick') { |
| | | await confirmTaskAction(`确定执行拣料出库任务 ${row.taskCode || ''} 吗?`) |
| | | await confirmTaskAction(t('pages.task.messages.pickConfirm', { code: row.taskCode || '' })) |
| | | await fetchPickTask(row.id) |
| | | ElMessage.success('拣料出库成功') |
| | | ElMessage.success(t('pages.task.messages.pickSuccess')) |
| | | } else if (action.key === 'top') { |
| | | await fetchTopTask(row.id) |
| | | ElMessage.success('任务置顶成功') |
| | | ElMessage.success(t('pages.task.messages.topSuccess')) |
| | | } |
| | | |
| | | await loadPageData() |
| | |
| | | if (error === 'cancel') { |
| | | return |
| | | } |
| | | ElMessage.error(error?.message || '任务操作失败') |
| | | ElMessage.error(error?.message || t('pages.task.messages.actionFailed')) |
| | | } |
| | | } |
| | | |
| | |
| | | current: pagination.current, |
| | | size: pagination.size |
| | | }, |
| | | { timeoutMessage: '任务列表加载超时,已停止等待' } |
| | | { timeoutMessage: t('pages.task.messages.listTimeout') } |
| | | ) |
| | | tableData.value = Array.isArray(response?.records) |
| | | ? response.records.map((record) => normalizeTaskRow(record)) |
| | |
| | | autoRunLoading.value = true |
| | | try { |
| | | const response = await guardRequestWithMessage(fetchTaskAutoRunFlag(), { val: false }, { |
| | | timeoutMessage: '自动下发配置加载超时,已停止等待' |
| | | timeoutMessage: t('pages.task.messages.autoRunTimeout') |
| | | }) |
| | | const rawValue = response?.val |
| | | autoRunEnabled.value = |
| | |
| | | try { |
| | | await fetchUpdateTaskAutoRunFlag(enabled) |
| | | autoRunEnabled.value = enabled |
| | | ElMessage.success(enabled ? '已开启自动下发任务' : '已暂停自动下发任务') |
| | | ElMessage.success(enabled ? t('pages.task.messages.autoRunOnSuccess') : t('pages.task.messages.autoRunOffSuccess')) |
| | | } catch (error) { |
| | | ElMessage.error(error?.message || '自动下发配置更新失败') |
| | | ElMessage.error(error?.message || t('pages.task.messages.autoRunUpdateFailed')) |
| | | } finally { |
| | | autoRunLoading.value = false |
| | | } |
| | |
| | | current: detailPagination.current, |
| | | size: detailPagination.size |
| | | }, |
| | | { timeoutMessage: '任务明细加载超时,已停止等待' } |
| | | { timeoutMessage: t('pages.task.messages.itemsTimeout') } |
| | | ) |
| | | |
| | | detailData.value = normalizeTaskRow(activeTaskRow.value) |
| | |
| | | updatePaginationState(detailPagination, taskItemResponse, detailPagination.current, detailPagination.size) |
| | | } catch (error) { |
| | | detailTableData.value = [] |
| | | ElMessage.error(error?.message || '任务明细加载失败') |
| | | ElMessage.error(error?.message || t('pages.task.messages.detailLoadFailed')) |
| | | } finally { |
| | | detailLoading.value = false |
| | | } |