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