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

main
黄伟杰 5 days ago
parent 4ee05ff904
commit 0164129b95

@ -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 })
},

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

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

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

@ -79,56 +79,15 @@
<el-input v-model="taskFormData.name" :placeholder="t('EquipmentManagement.TaskManagement.placeholderName')" />
</el-form-item>
<el-form-item :label="t('EquipmentManagement.TaskManagement.projectForm')" prop="projectForm">
<el-select
v-model="taskFormData.projectForm"
multiple
filterable
clearable
:placeholder="t('EquipmentManagement.TaskManagement.placeholderProjectForm')"
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 表达式"
<div class="flex items-center gap-2 w-full">
<el-input
v-model="projectFormDisplayText"
readonly
:placeholder="t('EquipmentManagement.TaskManagement.placeholderProjectForm')"
class="flex-1"
/>
</template>
<crontab v-model="taskFormData.cronExpression" />
</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-button @click="openProjectFormDialog">{{ t('common.select') }}</el-button>
</div>
</el-form-item>
</template>
@ -320,6 +279,79 @@
</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>
</template>
@ -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<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 () => {
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;
}
</style>

@ -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)

@ -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)

Loading…
Cancel
Save