feat:模具组-维护-点检/保养

main
黄伟杰 2 weeks ago
parent 4ee05ff904
commit 0164129b95

@ -29,6 +29,11 @@ export const TaskManagementApi = {
return await request.post({ url: `/mes/mold-task-management/createMoldTicket`, params: { id } }) 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) => { createTaskManagement: async (data: TaskManagementVO) => {
return await request.post({ url: `/mes/mold-task-management/create`, data }) return await request.post({ url: `/mes/mold-task-management/create`, data })
}, },

@ -16,6 +16,7 @@ export default {
ok: 'OK', ok: 'OK',
save: 'Save', save: 'Save',
cancel: 'Cancel', cancel: 'Cancel',
select: 'Select',
close: 'Close', close: 'Close',
reload: 'Reload current', reload: 'Reload current',
success: 'Success', success: 'Success',

@ -16,6 +16,7 @@ export default {
ok: '确定', ok: '确定',
save: '保存', save: '保存',
cancel: '取消', cancel: '取消',
select: '选择',
close: '关闭', close: '关闭',
reload: '重新加载', reload: '重新加载',
success: '成功', success: '成功',

@ -60,7 +60,7 @@
<el-button link type="primary" @click="openForm('update', scope.row.id)">{{ <el-button link type="primary" @click="openForm('update', scope.row.id)">{{
t('MoldManagement.MoldListPage.edit') }}</el-button> t('MoldManagement.MoldListPage.edit') }}</el-button>
<el-button link type="danger" @click="handleDelete(scope.row.id)">{{ t('MoldManagement.MoldListPage.delete') <el-button link type="danger" @click="handleDelete(scope.row.id)">{{ t('MoldManagement.MoldListPage.delete')
}}</el-button> }}</el-button>
<el-button link type="warning" @click="openPressureNetRecord(scope.row.id)">{{ <el-button link type="warning" @click="openPressureNetRecord(scope.row.id)">{{
t('MoldManagement.MoldListPage.pressureNetRecord') }}</el-button> t('MoldManagement.MoldListPage.pressureNetRecord') }}</el-button>
</template> </template>
@ -81,7 +81,7 @@
min-width="160" :formatter="dateFormatter" /> min-width="160" :formatter="dateFormatter" />
<el-table-column :label="t('MoldManagement.MoldListPage.createTime')" prop="createTime" min-width="160" <el-table-column :label="t('MoldManagement.MoldListPage.createTime')" prop="createTime" min-width="160"
:formatter="dateFormatter" /> :formatter="dateFormatter" />
<el-table-column :label="t('MoldManagement.MoldListPage.remark')" prop="remark" min-width="160"> <el-table-column :label="t('MoldManagement.MoldListPage.remark')" prop="remark" min-width="160">
<template #default="scope"> <template #default="scope">
{{ scope.row.remark || '-' }} {{ scope.row.remark || '-' }}
</template> </template>

@ -79,56 +79,15 @@
<el-input v-model="taskFormData.name" :placeholder="t('EquipmentManagement.TaskManagement.placeholderName')" /> <el-input v-model="taskFormData.name" :placeholder="t('EquipmentManagement.TaskManagement.placeholderName')" />
</el-form-item> </el-form-item>
<el-form-item :label="t('EquipmentManagement.TaskManagement.projectForm')" prop="projectForm"> <el-form-item :label="t('EquipmentManagement.TaskManagement.projectForm')" prop="projectForm">
<el-select <div class="flex items-center gap-2 w-full">
v-model="taskFormData.projectForm" <el-input
multiple v-model="projectFormDisplayText"
filterable readonly
clearable :placeholder="t('EquipmentManagement.TaskManagement.placeholderProjectForm')"
:placeholder="t('EquipmentManagement.TaskManagement.placeholderProjectForm')" class="flex-1"
class="!w-full"
>
<el-option v-for="item in planOptions" :key="String(item.id)" :label="item.planName" :value="String(item.id)" />
</el-select>
</el-form-item>
<el-form-item :label="t('EquipmentManagement.TaskManagement.dateRange')" prop="dateRange">
<el-date-picker
v-model="taskFormData.dateRange"
value-format="YYYY-MM-DD"
type="daterange"
:start-placeholder="t('EquipmentManagement.TaskManagement.placeholderStartDate')"
:end-placeholder="t('EquipmentManagement.TaskManagement.placeholderEndDate')"
class="!w-320px"
/>
</el-form-item>
<el-form-item :label="t('EquipmentManagement.TaskManagement.cronExpression')" prop="cronExpression">
<template #label>
<Tooltip
title="Cron 表达式"
message="可以通过AI生成AI提示词举例帮我生成一个周一早上 9 点执行的 Cron 表达式"
/> />
</template> <el-button @click="openProjectFormDialog">{{ t('common.select') }}</el-button>
<crontab v-model="taskFormData.cronExpression" /> </div>
</el-form-item>
<el-form-item :label="t('EquipmentManagement.TaskManagement.operableUsers')" prop="operableUsers">
<el-select
v-model="taskFormData.operableUsers"
multiple
filterable
clearable
:placeholder="t('EquipmentManagement.TaskManagement.placeholderOperableUsers')"
class="!w-full"
>
<el-option v-for="item in users" :key="String(item.id)" :label="item.nickname" :value="String(item.id)" />
</el-select>
</el-form-item>
<el-form-item :label="t('EquipmentManagement.TaskManagement.enabled')" prop="enabled">
<el-radio-group v-model="taskFormData.enabled">
<el-radio
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)" :key="String(dict.value)"
:label="dict.value">
{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item> </el-form-item>
</template> </template>
@ -320,6 +279,79 @@
</div> </div>
</div> </div>
</div> </div>
<!-- 项目表单选择弹框 -->
<Dialog v-model="projectFormDialogVisible" :title="t('EquipmentManagement.TaskManagement.projectForm')" width="1200px">
<div class="project-form-dialog-content">
<el-table
ref="projectFormTableRef"
v-loading="projectFormLoading"
:data="projectFormList"
row-key="id"
@expand-change="handleProjectFormExpandChange"
>
<el-table-column width="55" align="center">
<template #default="scope">
<el-radio
v-model="tempSelectedProjectFormId"
:value="String(scope.row.id)"
@change="handleProjectFormRadioChange(scope.row)"
/>
</template>
</el-table-column>
<el-table-column type="expand" width="48">
<template #default="scope">
<div class="p-12px">
<el-table
v-loading="subjectLoadingMap[String(scope.row.id)]"
:data="subjectListMap[String(scope.row.id)] ?? []"
:stripe="true"
:show-overflow-tooltip="true"
size="small"
>
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.index')" align="center" width="80">
<template #default="s2">
{{ s2.$index + 1 }}
</template>
</el-table-column>
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.subjectCode')" align="center" prop="subjectCode" />
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.subjectName')" align="center" prop="subjectName" />
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.inspectionMethod')" align="center" prop="inspectionMethod" width="120" />
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.judgmentCriteria')" align="center" prop="judgmentCriteria" />
</el-table>
</div>
</template>
</el-table-column>
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.index')" align="center" width="80">
<template #default="scope">
{{ (projectFormPageParams.pageNo - 1) * projectFormPageParams.pageSize + scope.$index + 1 }}
</template>
</el-table-column>
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.planName')" prop="planName" min-width="160" />
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.planType')" width="110">
<template #default="scope">
<el-tag effect="light" :type="scope.row.planType === 1 ? 'success' : 'primary'" size="small">
{{ scope.row.planType === 1 ? t('MoldManagement.MoldInspectionPlan.planTypeMaintain') : t('MoldManagement.MoldInspectionPlan.planTypeInspect') }}
</el-tag>
</template>
</el-table-column>
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.description')" prop="description" min-width="200" />
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.creatorName')" prop="creatorName" width="140" />
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.createTime')" prop="createTime" :formatter="dateFormatter" width="180" />
<el-table-column :label="t('MoldManagement.MoldInspectionPlan.updateTime')" prop="updateTime" :formatter="dateFormatter" width="180" />
</el-table>
<Pagination
:total="projectFormTotal"
v-model:page="projectFormPageParams.pageNo"
v-model:limit="projectFormPageParams.pageSize"
@pagination="loadProjectFormList"
/>
</div>
<template #footer>
<el-button @click="projectFormDialogVisible = false">{{ t('common.cancel') }}</el-button>
<el-button type="primary" @click="confirmProjectFormSelection">{{ t('common.ok') }}</el-button>
</template>
</Dialog>
</div> </div>
</template> </template>
@ -328,12 +360,12 @@ import { ref, reactive, computed, watch } from 'vue'
import { EditPen, RefreshRight, Search, Tools } from '@element-plus/icons-vue' import { EditPen, RefreshRight, Search, Tools } from '@element-plus/icons-vue'
import { MoldBrandApi, type MoldBrandVO } from '@/api/erp/mold' import { MoldBrandApi, type MoldBrandVO } from '@/api/erp/mold'
import { DeviceLedgerApi, type DeviceLedgerVO } from '@/api/mes/deviceledger' 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 { MoldRepairApi, type MoldRepairVO } from '@/api/mold/moldrepair'
import { PlanMaintenanceApi } from '@/api/mold/planmaintenance' import { PlanMaintenanceApi } from '@/api/mold/planmaintenance'
import { getSimpleUserList, type UserVO } from '@/api/system/user' import { getSimpleUserList, type UserVO } from '@/api/system/user'
import { DICT_TYPE, getBoolDictOptions, getStrDictOptions } from '@/utils/dict' import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
import { Tooltip } from '@/components/Tooltip' import { dateFormatter } from '@/utils/formatTime'
defineOptions({ name: 'MoldMaintainView' }) defineOptions({ name: 'MoldMaintainView' })
@ -359,9 +391,7 @@ const formRules = reactive({
// / // /
name: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderName'), trigger: 'blur' }], name: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderName'), trigger: 'blur' }],
taskType: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderTaskType'), trigger: 'change' }], taskType: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderTaskType'), trigger: 'change' }],
projectForm: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderProjectForm'), trigger: 'change' }], projectForm: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderProjectForm') }],
dateRange: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderDateRange'), trigger: 'change' }],
enabled: [{ required: true, message: t('EquipmentManagement.TaskManagement.placeholderEnabled'), trigger: 'change' }],
// //
repairName: [{ required: true, message: t('MoldManagement.MoldRepair.validatorRepairNameRequired'), trigger: 'blur' }], repairName: [{ required: true, message: t('MoldManagement.MoldRepair.validatorRepairNameRequired'), trigger: 'blur' }],
requireDate: [{ required: true, message: t('MoldManagement.MoldRepair.validatorRequireDateRequired'), trigger: 'change' }], requireDate: [{ required: true, message: t('MoldManagement.MoldRepair.validatorRequireDateRequired'), trigger: 'change' }],
@ -379,8 +409,6 @@ const formModel = computed(() => ({
name: taskFormData.name, name: taskFormData.name,
taskType: taskFormData.taskType, taskType: taskFormData.taskType,
projectForm: taskFormData.projectForm, projectForm: taskFormData.projectForm,
dateRange: taskFormData.dateRange,
enabled: taskFormData.enabled,
repairName: repairFormData.repairName, repairName: repairFormData.repairName,
requireDate: repairFormData.requireDate, requireDate: repairFormData.requireDate,
faultLevel: repairFormData.faultLevel, faultLevel: repairFormData.faultLevel,
@ -399,11 +427,7 @@ const maintainFormData = reactive({
const taskFormData = reactive({ const taskFormData = reactive({
name: undefined as string | undefined, name: undefined as string | undefined,
taskType: 1 as number, taskType: 1 as number,
projectForm: [] as string[], projectForm: '' as string
dateRange: [] as string[],
cronExpression: undefined as string | undefined,
operableUsers: [] as string[],
enabled: true as boolean
}) })
// //
@ -465,10 +489,87 @@ const maintainTypes = computed(() => [
{ value: 4, label: t('MoldManagement.MoldBrandPage.maintainTypeReplaceNet'), icon: RefreshRight } { value: 4, label: t('MoldManagement.MoldBrandPage.maintainTypeReplaceNet'), icon: RefreshRight }
]) ])
// // 使 select
const planOptions = ref<{ id: number | string; planName: string }[]>([]) const planOptions = ref<{ id: number | string; planName: string }[]>([])
const users = ref<UserVO[]>([]) const users = ref<UserVO[]>([])
//
const projectFormDialogVisible = ref(false)
const projectFormLoading = ref(false)
const projectFormList = ref<any[]>([])
const projectFormTotal = ref(0)
const projectFormTableRef = ref()
const tempSelectedProjectForm = ref<any>(null) //
const tempSelectedProjectFormId = ref<string>('') // radio id
const selectedProjectFormId = ref<string>('') // id
const selectedProjectFormName = ref<string>('') //
const subjectListMap = ref<Record<string, any[]>>({})
const subjectLoadingMap = ref<Record<string, boolean>>({})
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 () => { const ensureUsersLoaded = async () => {
if (users.value.length) return if (users.value.length) return
users.value = (await getSimpleUserList()) ?? [] users.value = (await getSimpleUserList()) ?? []
@ -506,20 +607,6 @@ const getImageList = (images?: string) => {
.filter(Boolean) .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 initOptions = async () => {
const [planRes, userRes] = await Promise.all([ const [planRes, userRes] = await Promise.all([
PlanMaintenanceApi.getPlanMaintenancePage({}), PlanMaintenanceApi.getPlanMaintenancePage({}),
@ -558,27 +645,18 @@ const submitForm = async () => {
try { try {
if (isInspectOrMaintain.value) { if (isInspectOrMaintain.value) {
// / // /
const [startDate, endDate] = Array.isArray(taskFormData.dateRange) ? taskFormData.dateRange : [] await TaskManagementApi.createMoldTicketDirect({
const payload: TaskManagementVO = {
name: taskFormData.name, name: taskFormData.name,
taskType: taskFormData.taskType, taskType: String(taskFormData.taskType),
moldList: props.mold?.id ? String(props.mold.id) : undefined, moldList: props.mold?.id ? String(props.mold.id) : undefined,
projectForm: toCommaSeparatedIds(taskFormData.projectForm), projectForm: taskFormData.projectForm
startDate: startDate || undefined, })
endDate: endDate || undefined,
cronExpression: taskFormData.cronExpression,
operableUsers: toCommaSeparatedIds(taskFormData.operableUsers),
enabled: taskFormData.enabled
}
await TaskManagementApi.createTaskManagement(payload)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
// //
taskFormData.name = undefined taskFormData.name = undefined
taskFormData.projectForm = [] taskFormData.projectForm = ''
taskFormData.dateRange = [] selectedProjectFormId.value = ''
taskFormData.cronExpression = undefined selectedProjectFormName.value = ''
taskFormData.operableUsers = []
taskFormData.enabled = true
} else if (isRepair.value) { } else if (isRepair.value) {
// //
const payload: any = { const payload: any = {
@ -869,4 +947,9 @@ defineExpose({ open })
.mold-maintain-type-card__item.is-active .mold-maintain-type-card__label { .mold-maintain-type-card__item.is-active .mold-maintain-type-card__label {
color: var(--el-color-primary); color: var(--el-color-primary);
} }
.project-form-dialog-content {
max-height: 500px;
overflow-y: auto;
}
</style> </style>

@ -211,31 +211,31 @@ const submitForm = async () => {
.map((it: any) => [Number(it.productId ?? it.id), it]) .map((it: any) => [Number(it.productId ?? it.id), it])
) )
const selectedProductIds = (itemFormRef.value.selectedRows ?? []) const selectedRows = (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))
formData.value.items = selectedProductIds.map((productId) => { formData.value.items = selectedRows
const existing = existingByProductId.get(productId) .filter((it: any) => it && it.productId !== undefined && it.productId !== null)
if (existing) { .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 { return {
id: existing.id, id: row.id,
warehouseId: formData.value.warehouseId, warehouseId: formData.value.warehouseId,
productId, productId,
productPrice: existing.productPrice ?? 0, productPrice: 0,
count: existing.count ?? 1, count: 1
remark: existing.remark ?? null
} }
} })
return {
warehouseId: formData.value.warehouseId,
productId,
productPrice: 0,
count: 1
}
})
const data = formData.value as unknown as StockOutVO const data = formData.value as unknown as StockOutVO
if (formType.value === 'create') { if (formType.value === 'create') {
await StockOutApi.createStockOut(data) await StockOutApi.createStockOut(data)

@ -210,31 +210,31 @@ const submitForm = async () => {
.map((it: any) => [Number(it.productId ?? it.id), it]) .map((it: any) => [Number(it.productId ?? it.id), it])
) )
const selectedProductIds = (itemFormRef.value.selectedRows ?? []) const selectedRows = (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))
formData.value.items = selectedProductIds.map((productId) => { formData.value.items = selectedRows
const existing = existingByProductId.get(productId) .filter((it: any) => it && it.productId !== undefined && it.productId !== null)
if (existing) { .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 { return {
id: existing.id, id: row.id,
warehouseId: formData.value.warehouseId, warehouseId: formData.value.warehouseId,
productId, productId,
productPrice: existing.productPrice ?? 0, productPrice: 0,
count: existing.count ?? 1, count: 1
remark: existing.remark ?? null
} }
} })
return {
warehouseId: formData.value.warehouseId,
productId,
productPrice: 0,
count: 1
}
})
const data = formData.value as unknown as StockInVO const data = formData.value as unknown as StockInVO
if (formType.value === 'create') { if (formType.value === 'create') {
await StockInApi.createStockIn(data) await StockInApi.createStockIn(data)

Loading…
Cancel
Save