diff --git a/src/api/mold/ticketManagement/index.ts b/src/api/mold/ticketManagement/index.ts index e85bc695..50ab32dc 100644 --- a/src/api/mold/ticketManagement/index.ts +++ b/src/api/mold/ticketManagement/index.ts @@ -54,6 +54,10 @@ export const TicketManagementApi = { return await request.put({ url: `/mes/mold-ticket-results/batchUpdate`, data }) }, + exportTicketManagement: async (params: any) => { + return await request.download({ url: `/mes/mold-ticket-management/export-excel`, params }) + }, + getInspectionByMoldId: async (params: { moldId: number; startTime?: string; endTime?: string }) => { return await request.get({ url: `/mes/mold-ticket-management/getInspectionByMoldId`, params }) }, diff --git a/src/locales/en.ts b/src/locales/en.ts index 81b7d0c5..11efe055 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -3828,6 +3828,7 @@ export default { operatorName: 'Operator', taskTime: 'Job Time', taskEndTime: 'Planned End Time', + taskTimeRange: 'Job Time', createTime: 'Create Time', index: 'Index', remark: 'Remark', @@ -3837,10 +3838,16 @@ export default { placeholderPlanType: 'Please select type', placeholderJobStatus: 'Please select job status', placeholderJobResult: 'Please select result', + placeholderOperatorName: 'Please select operator', + placeholderTaskTime: 'Please select job start time', + placeholderTaskEndTime: 'Please select job end time', query: 'Query', reset: 'Reset', cancelConfirm: 'Confirm cancel selected tasks?', cancelSuccess: 'Cancel task successful', + cancelOnlyUnworkedTip: 'Only unworked tickets can be canceled', + export: 'Export', + exportFilename: 'Mold Work Order Inquiry.xls', inspectResultTitlePrefix: 'Inspection Result-', inspectResultTitle: 'Inspection Result' }, diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 54c42029..99168640 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -2198,6 +2198,7 @@ export default { cancelReason: '取消原因', cancelConfirm: '确认取消选中的任务吗?', cancelSuccess: '取消任务成功', + cancelOnlyUnworkedTip: '只有未作业状态的工单才能取消任务', cancelFail: '取消任务失败', cancelOnlyUnworkedTip: '只有未作业状态的工单才能取消任务', selectAllDecisionError: '请先为所有待检测记录选择通过或不通过', @@ -3298,6 +3299,7 @@ export default { operatorName: '作业人', taskTime: '作业时间', taskEndTime: '计划结束作业时间', + taskTimeRange: '作业时间', createTime: '创建时间', index: '序号', remark: '备注', @@ -3307,10 +3309,16 @@ export default { placeholderPlanType: '请选择类型', placeholderJobStatus: '请选择作业状态', placeholderJobResult: '请选择结果', + placeholderOperatorName: '请选择作业人', + placeholderTaskTime: '请选择作业开始时间', + placeholderTaskEndTime: '请选择作业结束时间', query: '查询', reset: '重置', cancelConfirm: '确认取消选中的任务吗?', cancelSuccess: '取消任务成功', + cancelOnlyUnworkedTip: '只有未作业状态的工单才能取消任务', + export: '导出', + exportFilename: '模具工单查询.xls', inspectResultTitlePrefix: '检验结果-', inspectResultTitle: '检验结果' }, diff --git a/src/views/mold/workOrderInquiry/components/TicketResultDialog.vue b/src/views/mold/workOrderInquiry/components/TicketResultDialog.vue index 32d1f6cb..365c68e1 100644 --- a/src/views/mold/workOrderInquiry/components/TicketResultDialog.vue +++ b/src/views/mold/workOrderInquiry/components/TicketResultDialog.vue @@ -4,6 +4,17 @@
{{ t('common.back') }} {{ pageTitle }} +
+ + {{ t('MoldManagement.TicketResultDialog.save') }} + +
@@ -141,14 +152,8 @@ v-model:page-size="queryParams.pageSize" :background="true" :page-sizes="[10, 20, 30, 50, 100]" :pager-count="7" :total="total" class="mt-15px mb-15px flex justify-end" layout="total, sizes, prev, pager, next, jumper" @size-change="handleSizeChange" @current-change="handleCurrentChange" /> - - + @@ -386,9 +391,9 @@ const parseImages = (value: any): string[] => { color: var(--el-text-color-primary); } -.ticket-result-footer { +.ticket-result-actions { + margin-left: auto; display: flex; - justify-content: flex-end; gap: 12px; } diff --git a/src/views/mold/workOrderInquiry/index.vue b/src/views/mold/workOrderInquiry/index.vue index 3439990a..9ab5c258 100644 --- a/src/views/mold/workOrderInquiry/index.vue +++ b/src/views/mold/workOrderInquiry/index.vue @@ -41,6 +41,27 @@ + + + + + + + + @@ -54,13 +75,16 @@ {{ t('MoldManagement.MoldWorkOrderInquiry.query') }} + + {{ t('MoldManagement.MoldWorkOrderInquiry.export') }} +
- + {{ t('MoldManagement.MoldWorkOrderInquiry.cancelTask') }}
@@ -125,6 +149,7 @@ import { dateFormatter } from '@/utils/formatTime' import { getStrDictOptions } from '@/utils/dict' import { useDictStoreWithOut } from '@/store/modules/dict' import { TicketManagementApi, TicketManagementVO } from '@/api/mold/ticketManagement' +import { getSimpleUserList, UserVO } from '@/api/system/user' import TicketResultDialog from '@/views/mold/workOrderInquiry/components/TicketResultDialog.vue' const { t } = useI18n() @@ -139,8 +164,8 @@ const planTypeOptions = [ { label: t('MoldManagement.MoldWorkOrderInquiry.planTypeMaintain'), value: '2' } ] const jobResultOptions = [ - { label: t('MoldManagement.MoldWorkOrderInquiry.jobResultOk'), value: 'OK' }, - { label: t('MoldManagement.MoldWorkOrderInquiry.jobResultNg'), value: 'NG' } + { label: t('MoldManagement.MoldWorkOrderInquiry.jobResultOk'), value: '1' }, + { label: t('MoldManagement.MoldWorkOrderInquiry.jobResultNg'), value: '2' } ] const loading = ref(true) @@ -159,7 +184,10 @@ const updatePlanTableMaxHeight = async () => { planTableMaxHeight.value = Math.min(window.innerHeight, Math.max(240, Math.floor(availableHeight))) } const selectedIds = ref([]) +const selectedRows = ref([]) const cancelLoading = ref(false) +const exportLoading = ref(false) +const users = ref([]) const resultVisible = ref(false) const selectedResultRow = ref() const resultTitle = computed(() => { @@ -175,22 +203,36 @@ const queryParams = reactive({ pageSize: 10, planNo: undefined as string | undefined, planType: undefined as string | undefined, - jobStatus: undefined as string | undefined, - jobResult: undefined as string | undefined + jobStatus: '0' as string | undefined, + jobResult: undefined as string | undefined, + operator: undefined as string | undefined, + taskTimeRange: [] as string[] }) const queryFormRef = ref() const showAllFilters = ref(false) -const filterCount = 4 +const filterCount = 6 +const UNWORKED_JOB_STATUS = '0' +const CANCELED_JOB_STATUS = '4' + const toggleFilters = () => { showAllFilters.value = !showAllFilters.value updatePlanTableMaxHeight() } +const buildQueryParams = () => { + const { taskTimeRange, ...params } = queryParams + return { + ...params, + taskTime: taskTimeRange?.[0], + taskEndTime: taskTimeRange?.[1] + } +} + const getList = async () => { loading.value = true try { - const data = await TicketManagementApi.getTicketManagementPage(queryParams) + const data = await TicketManagementApi.getTicketManagementPage(buildQueryParams()) list.value = data.list total.value = data.total } finally { @@ -210,13 +252,22 @@ const resetQuery = () => { } const handleSelectionChange = (rows: TicketManagementVO[]) => { + selectedRows.value = rows selectedIds.value = rows .map((r) => r.id) .filter((id): id is number => typeof id === 'number') } +const isUnworkedTicket = (row?: TicketManagementVO) => String(row?.jobStatus ?? '') === UNWORKED_JOB_STATUS +const hasUncancelableSelection = computed(() => selectedRows.value.some((row) => !isUnworkedTicket(row))) +const isCancelDisabled = computed(() => !selectedIds.value.length || hasUncancelableSelection.value) + const handleBatchCancel = async () => { if (!selectedIds.value.length) return + if (hasUncancelableSelection.value) { + message.warning(t('MoldManagement.MoldWorkOrderInquiry.cancelOnlyUnworkedTip')) + return + } try { const { value } = await ElMessageBox.prompt('请输入取消原因', t('MoldManagement.MoldWorkOrderInquiry.cancelTask'), { confirmButtonText: t('common.ok'), @@ -227,11 +278,12 @@ const handleBatchCancel = async () => { cancelLoading.value = true await TicketManagementApi.batchUpdateTicketStatus({ ids: selectedIds.value.join(','), - jobStatus: '4', + jobStatus: CANCELED_JOB_STATUS, cancelReason: value }) message.success(t('MoldManagement.MoldWorkOrderInquiry.cancelSuccess')) selectedIds.value = [] + selectedRows.value = [] await getList() } catch { } finally { @@ -239,6 +291,23 @@ const handleBatchCancel = async () => { } } +const handleExport = async () => { + try { + await message.exportConfirm() + exportLoading.value = true + const params: any = { + ...buildQueryParams(), + ids: selectedIds.value.length ? selectedIds.value.join(',') : undefined + } + const data = await TicketManagementApi.exportTicketManagement(params) + const download = (await import('@/utils/download')).default + download.excel(data, t('MoldManagement.MoldWorkOrderInquiry.exportFilename')) + } catch { + } finally { + exportLoading.value = false + } +} + const handleRowClick = (row: TicketManagementVO, column: any) => { if (column?.type === 'selection') return if (!row?.id) return @@ -259,6 +328,7 @@ const handleResultSuccess = async () => { onMounted(async () => { await dictStore.setDictMap() + users.value = await getSimpleUserList() await getList() updatePlanTableMaxHeight() window.addEventListener("resize", updatePlanTableMaxHeight) @@ -268,3 +338,4 @@ onBeforeUnmount(() => { window.removeEventListener("resize", updatePlanTableMaxHeight) }) +