From 0164129b95b3b490dd228fc328ef5d3c4b1adf82 Mon Sep 17 00:00:00 2001 From: hwj Date: Fri, 5 Jun 2026 18:23:20 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=A8=A1=E5=85=B7=E7=BB=84-?= =?UTF-8?q?=E7=BB=B4=E6=8A=A4-=E7=82=B9=E6=A3=80/=E4=BF=9D=E5=85=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/mold/taskManagement/index.ts | 5 + src/locales/en.ts | 1 + src/locales/zh-CN.ts | 1 + src/views/erp/mold/components/MoldList.vue | 4 +- .../erp/mold/components/MoldMaintainView.vue | 269 ++++++++++++------ src/views/mes/moldget/MoldGetForm.vue | 40 +-- src/views/mes/moldreturn/MoldReturnForm.vue | 40 +-- 7 files changed, 225 insertions(+), 135 deletions(-) diff --git a/src/api/mold/taskManagement/index.ts b/src/api/mold/taskManagement/index.ts index 4e71e197..0fa1a402 100644 --- a/src/api/mold/taskManagement/index.ts +++ b/src/api/mold/taskManagement/index.ts @@ -29,6 +29,11 @@ export const TaskManagementApi = { return await request.post({ url: `/mes/mold-task-management/createMoldTicket`, params: { id } }) }, + // 直接创建模具任务工单(点检/保养) + createMoldTicketDirect: async (data: any) => { + return await request.post({ url: `/mes/mold-task-management/createMoldTicketDirect`, data }) + }, + createTaskManagement: async (data: TaskManagementVO) => { return await request.post({ url: `/mes/mold-task-management/create`, data }) }, diff --git a/src/locales/en.ts b/src/locales/en.ts index 2a52f32f..b4f6e9ab 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -16,6 +16,7 @@ export default { ok: 'OK', save: 'Save', cancel: 'Cancel', + select: 'Select', close: 'Close', reload: 'Reload current', success: 'Success', diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index d5a48771..66ca0463 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -16,6 +16,7 @@ export default { ok: '确定', save: '保存', cancel: '取消', + select: '选择', close: '关闭', reload: '重新加载', success: '成功', diff --git a/src/views/erp/mold/components/MoldList.vue b/src/views/erp/mold/components/MoldList.vue index 39722a6d..7771c7dd 100644 --- a/src/views/erp/mold/components/MoldList.vue +++ b/src/views/erp/mold/components/MoldList.vue @@ -60,7 +60,7 @@ {{ t('MoldManagement.MoldListPage.edit') }} {{ t('MoldManagement.MoldListPage.delete') - }} + }} {{ t('MoldManagement.MoldListPage.pressureNetRecord') }} @@ -81,7 +81,7 @@ min-width="160" :formatter="dateFormatter" /> - + diff --git a/src/views/erp/mold/components/MoldMaintainView.vue b/src/views/erp/mold/components/MoldMaintainView.vue index 4add1da3..d84c0230 100644 --- a/src/views/erp/mold/components/MoldMaintainView.vue +++ b/src/views/erp/mold/components/MoldMaintainView.vue @@ -79,56 +79,15 @@ - - - - - - - - - - - - - - - - - - - - {{ dict.label }} - - + {{ t('common.select') }} + @@ -320,6 +279,79 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ +
@@ -328,12 +360,12 @@ import { ref, reactive, computed, watch } from 'vue' import { EditPen, RefreshRight, Search, Tools } from '@element-plus/icons-vue' import { MoldBrandApi, type MoldBrandVO } from '@/api/erp/mold' import { DeviceLedgerApi, type DeviceLedgerVO } from '@/api/mes/deviceledger' -import { TaskManagementApi, type TaskManagementVO } from '@/api/mold/taskManagement' +import { TaskManagementApi } from '@/api/mold/taskManagement' import { MoldRepairApi, type MoldRepairVO } from '@/api/mold/moldrepair' import { PlanMaintenanceApi } from '@/api/mold/planmaintenance' import { getSimpleUserList, type UserVO } from '@/api/system/user' -import { DICT_TYPE, getBoolDictOptions, getStrDictOptions } from '@/utils/dict' -import { Tooltip } from '@/components/Tooltip' +import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' +import { dateFormatter } from '@/utils/formatTime' defineOptions({ name: 'MoldMaintainView' }) @@ -359,9 +391,7 @@ const formRules = reactive({ // 点检/保养表单规则 name: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderName'), trigger: 'blur' }], taskType: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderTaskType'), trigger: 'change' }], - projectForm: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderProjectForm'), trigger: 'change' }], - dateRange: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderDateRange'), trigger: 'change' }], - enabled: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderEnabled'), trigger: 'change' }], + projectForm: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderProjectForm') }], // 维修表单规则 repairName: [{ required: true, message: t('MoldManagement.MoldRepair.validatorRepairNameRequired'), trigger: 'blur' }], requireDate: [{ required: true, message: t('MoldManagement.MoldRepair.validatorRequireDateRequired'), trigger: 'change' }], @@ -379,8 +409,6 @@ const formModel = computed(() => ({ name: taskFormData.name, taskType: taskFormData.taskType, projectForm: taskFormData.projectForm, - dateRange: taskFormData.dateRange, - enabled: taskFormData.enabled, repairName: repairFormData.repairName, requireDate: repairFormData.requireDate, faultLevel: repairFormData.faultLevel, @@ -399,11 +427,7 @@ const maintainFormData = reactive({ const taskFormData = reactive({ name: undefined as string | undefined, taskType: 1 as number, - projectForm: [] as string[], - dateRange: [] as string[], - cronExpression: undefined as string | undefined, - operableUsers: [] as string[], - enabled: true as boolean + projectForm: '' as string }) // 维修表单数据 @@ -465,10 +489,87 @@ const maintainTypes = computed(() => [ { value: 4, label: t('MoldManagement.MoldBrandPage.maintainTypeReplaceNet'), icon: RefreshRight } ]) -// 下拉选项 +// 项目表单下拉选项(用于旧逻辑兼容,不再使用 select 下拉展示) const planOptions = ref<{ id: number | string; planName: string }[]>([]) const users = ref([]) +// 项目表单弹框相关 +const projectFormDialogVisible = ref(false) +const projectFormLoading = ref(false) +const projectFormList = ref([]) +const projectFormTotal = ref(0) +const projectFormTableRef = ref() +const tempSelectedProjectForm = ref(null) // 弹框中临时选中的行 +const tempSelectedProjectFormId = ref('') // 弹框中 radio 绑定的 id +const selectedProjectFormId = ref('') // 已确认选中的 id +const selectedProjectFormName = ref('') // 已确认选中的名称 +const subjectListMap = ref>({}) +const subjectLoadingMap = ref>({}) + +const projectFormPageParams = reactive({ + pageNo: 1, + pageSize: 10 +}) + +const projectFormDisplayText = computed(() => { + return selectedProjectFormName.value || '' +}) + +const loadProjectFormList = async () => { + projectFormLoading.value = true + try { + const res = await PlanMaintenanceApi.getPlanMaintenancePage({ + pageNo: projectFormPageParams.pageNo, + pageSize: projectFormPageParams.pageSize + }) + projectFormList.value = res?.list ?? [] + projectFormTotal.value = res?.total ?? 0 + } finally { + projectFormLoading.value = false + } +} + +const openProjectFormDialog = async () => { + projectFormPageParams.pageNo = 1 + tempSelectedProjectForm.value = null + tempSelectedProjectFormId.value = selectedProjectFormId.value || '' + projectFormDialogVisible.value = true + await loadProjectFormList() +} + +const handleProjectFormRadioChange = (row: any) => { + tempSelectedProjectForm.value = row +} + +const confirmProjectFormSelection = () => { + if (!tempSelectedProjectForm.value) return + selectedProjectFormId.value = String(tempSelectedProjectForm.value.id) + selectedProjectFormName.value = tempSelectedProjectForm.value.planName ?? String(tempSelectedProjectForm.value.id) + taskFormData.projectForm = selectedProjectFormId.value + projectFormDialogVisible.value = false +} + +const ensureSubjectListLoaded = async (planId: number | string) => { + const key = String(planId) + if (!key) return + if (subjectListMap.value[key]) return + subjectLoadingMap.value[key] = true + try { + const res = await PlanMaintenanceApi.getSubjectList(planId) + const data = Array.isArray(res) ? res : res?.list ?? res ?? [] + subjectListMap.value[key] = (data ?? []) + } finally { + subjectLoadingMap.value[key] = false + } +} + +const handleProjectFormExpandChange = async (row: any, expandedRows: any[]) => { + const isExpanded = expandedRows.some((r) => String(r.id) === String(row.id)) + if (!isExpanded) return + if (row?.id === undefined || row?.id === null || row?.id === '') return + await ensureSubjectListLoaded(row.id) +} + const ensureUsersLoaded = async () => { if (users.value.length) return users.value = (await getSimpleUserList()) ?? [] @@ -506,20 +607,6 @@ const getImageList = (images?: string) => { .filter(Boolean) } -const parseIdsValue = (value: any): string[] => { - if (!value) return [] - if (Array.isArray(value)) return value.map((v) => String(v).trim()).filter(Boolean) - return String(value) - .split(',') - .map((v) => v.trim()) - .filter(Boolean) -} - -const toCommaSeparatedIds = (value: any): string | undefined => { - const ids = parseIdsValue(value) - return ids.length ? ids.join(',') : undefined -} - const initOptions = async () => { const [planRes, userRes] = await Promise.all([ PlanMaintenanceApi.getPlanMaintenancePage({}), @@ -558,27 +645,18 @@ const submitForm = async () => { try { if (isInspectOrMaintain.value) { // 提交点检/保养任务 - const [startDate, endDate] = Array.isArray(taskFormData.dateRange) ? taskFormData.dateRange : [] - const payload: TaskManagementVO = { + await TaskManagementApi.createMoldTicketDirect({ name: taskFormData.name, - taskType: taskFormData.taskType, + taskType: String(taskFormData.taskType), moldList: props.mold?.id ? String(props.mold.id) : undefined, - projectForm: toCommaSeparatedIds(taskFormData.projectForm), - startDate: startDate || undefined, - endDate: endDate || undefined, - cronExpression: taskFormData.cronExpression, - operableUsers: toCommaSeparatedIds(taskFormData.operableUsers), - enabled: taskFormData.enabled - } - await TaskManagementApi.createTaskManagement(payload) + projectForm: taskFormData.projectForm + }) message.success(t('common.createSuccess')) // 清空已提交的表单数据 taskFormData.name = undefined - taskFormData.projectForm = [] - taskFormData.dateRange = [] - taskFormData.cronExpression = undefined - taskFormData.operableUsers = [] - taskFormData.enabled = true + taskFormData.projectForm = '' + selectedProjectFormId.value = '' + selectedProjectFormName.value = '' } else if (isRepair.value) { // 提交维修单 const payload: any = { @@ -869,4 +947,9 @@ defineExpose({ open }) .mold-maintain-type-card__item.is-active .mold-maintain-type-card__label { color: var(--el-color-primary); } + +.project-form-dialog-content { + max-height: 500px; + overflow-y: auto; +} diff --git a/src/views/mes/moldget/MoldGetForm.vue b/src/views/mes/moldget/MoldGetForm.vue index 998dfc43..7652ed9a 100644 --- a/src/views/mes/moldget/MoldGetForm.vue +++ b/src/views/mes/moldget/MoldGetForm.vue @@ -211,31 +211,31 @@ const submitForm = async () => { .map((it: any) => [Number(it.productId ?? it.id), it]) ) - const selectedProductIds = (itemFormRef.value.selectedRows ?? []) - .map((it: any) => it?.id) - .filter((id: any) => id !== undefined && id !== null) - .map((id: any) => Number(id)) - .filter((id: any) => !Number.isNaN(id)) + const selectedRows = (itemFormRef.value.selectedRows ?? []) - formData.value.items = selectedProductIds.map((productId) => { - const existing = existingByProductId.get(productId) - if (existing) { + formData.value.items = selectedRows + .filter((it: any) => it && it.productId !== undefined && it.productId !== null) + .map((row: any) => { + const productId = Number(row.productId) + const existing = existingByProductId.get(productId) + if (existing) { + return { + id: row.id, + warehouseId: formData.value.warehouseId, + productId, + productPrice: existing.productPrice ?? 0, + count: existing.count ?? 1, + remark: existing.remark ?? null + } + } return { - id: existing.id, + id: row.id, warehouseId: formData.value.warehouseId, productId, - productPrice: existing.productPrice ?? 0, - count: existing.count ?? 1, - remark: existing.remark ?? null + productPrice: 0, + count: 1 } - } - return { - warehouseId: formData.value.warehouseId, - productId, - productPrice: 0, - count: 1 - } - }) + }) const data = formData.value as unknown as StockOutVO if (formType.value === 'create') { await StockOutApi.createStockOut(data) diff --git a/src/views/mes/moldreturn/MoldReturnForm.vue b/src/views/mes/moldreturn/MoldReturnForm.vue index a6a7383e..711c00f1 100644 --- a/src/views/mes/moldreturn/MoldReturnForm.vue +++ b/src/views/mes/moldreturn/MoldReturnForm.vue @@ -210,31 +210,31 @@ const submitForm = async () => { .map((it: any) => [Number(it.productId ?? it.id), it]) ) - const selectedProductIds = (itemFormRef.value.selectedRows ?? []) - .map((it: any) => it?.id) - .filter((id: any) => id !== undefined && id !== null) - .map((id: any) => Number(id)) - .filter((id: any) => !Number.isNaN(id)) + const selectedRows = (itemFormRef.value.selectedRows ?? []) - formData.value.items = selectedProductIds.map((productId) => { - const existing = existingByProductId.get(productId) - if (existing) { + formData.value.items = selectedRows + .filter((it: any) => it && it.productId !== undefined && it.productId !== null) + .map((row: any) => { + const productId = Number(row.productId) + const existing = existingByProductId.get(productId) + if (existing) { + return { + id: row.id, + warehouseId: formData.value.warehouseId, + productId, + productPrice: existing.productPrice ?? 0, + count: existing.count ?? 1, + remark: existing.remark ?? null + } + } return { - id: existing.id, + id: row.id, warehouseId: formData.value.warehouseId, productId, - productPrice: existing.productPrice ?? 0, - count: existing.count ?? 1, - remark: existing.remark ?? null + productPrice: 0, + count: 1 } - } - return { - warehouseId: formData.value.warehouseId, - productId, - productPrice: 0, - count: 1 - } - }) + }) const data = formData.value as unknown as StockInVO if (formType.value === 'create') { await StockInApi.createStockIn(data)