|
|
|
@ -26,10 +26,8 @@
|
|
|
|
@click="openMoldSelectDialog"
|
|
|
|
@click="openMoldSelectDialog"
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldOperate.productionLine')" prop="lineId">
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldOperate.productionLine')" prop="lineId" v-if="formData.operateType != null">
|
|
|
|
<el-select v-model="formData.lineId" filterable clearable :placeholder="t('MoldManagement.MoldOperate.placeholderProductionLine')" class="!w-full">
|
|
|
|
<el-input :model-value="displayLineName" readonly />
|
|
|
|
<el-option v-for="line in lineOptions" :key="line.id" :label="line.name" :value="line.id" />
|
|
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldOperate.operateTime')" prop="operateTime">
|
|
|
|
<el-form-item :label="t('MoldManagement.MoldOperate.operateTime')" prop="operateTime">
|
|
|
|
<el-date-picker
|
|
|
|
<el-date-picker
|
|
|
|
@ -113,7 +111,7 @@
|
|
|
|
import { MoldOperateApi } from '@/api/mes/moldoperate'
|
|
|
|
import { MoldOperateApi } from '@/api/mes/moldoperate'
|
|
|
|
import { MoldBrandApi, MoldVO } from '@/api/erp/mold'
|
|
|
|
import { MoldBrandApi, MoldVO } from '@/api/erp/mold'
|
|
|
|
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
|
|
|
|
import { DeviceLedgerApi, DeviceLedgerVO } from '@/api/mes/deviceledger'
|
|
|
|
import { OrganizationApi, OrganizationVO } from '@/api/mes/organization'
|
|
|
|
import { DeviceLineApi, DeviceLineTreeVO } from '@/api/mes/deviceline'
|
|
|
|
import { getSimpleUserList, type UserVO } from '@/api/system/user'
|
|
|
|
import { getSimpleUserList, type UserVO } from '@/api/system/user'
|
|
|
|
import TableSelectDialog from '@/components/TableSelectDialog/TableSelectDialog.vue'
|
|
|
|
import TableSelectDialog from '@/components/TableSelectDialog/TableSelectDialog.vue'
|
|
|
|
|
|
|
|
|
|
|
|
@ -123,7 +121,8 @@ defineOptions({ name: 'MoldOperateForm' })
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
|
|
|
|
|
|
|
const lineOptions = ref<OrganizationVO[]>([])
|
|
|
|
const deviceLineTree = ref<DeviceLineTreeVO[]>([])
|
|
|
|
|
|
|
|
const displayTopCategory = ref('')
|
|
|
|
const operatorOptions = ref<UserVO[]>([])
|
|
|
|
const operatorOptions = ref<UserVO[]>([])
|
|
|
|
const initializingOperateType = ref(false)
|
|
|
|
const initializingOperateType = ref(false)
|
|
|
|
|
|
|
|
|
|
|
|
@ -169,7 +168,6 @@ const validateMoldId = (_rule: any, value: any, callback: (error?: Error) => voi
|
|
|
|
const formRules = reactive({
|
|
|
|
const formRules = reactive({
|
|
|
|
operateType: [{ required: true, message: t('MoldManagement.MoldOperate.validatorOperateTypeRequired'), trigger: 'blur' }],
|
|
|
|
operateType: [{ required: true, message: t('MoldManagement.MoldOperate.validatorOperateTypeRequired'), trigger: 'blur' }],
|
|
|
|
deviceId: [{ required: true, message: t('MoldManagement.MoldOperate.validatorDeviceRequired'), trigger: 'change' }],
|
|
|
|
deviceId: [{ required: true, message: t('MoldManagement.MoldOperate.validatorDeviceRequired'), trigger: 'change' }],
|
|
|
|
lineId: [{ required: true, message: t('MoldManagement.MoldOperate.validatorProductionLineRequired'), trigger: 'change' }],
|
|
|
|
|
|
|
|
moldId: [{ required: true, validator: validateMoldId, trigger: 'change' }],
|
|
|
|
moldId: [{ required: true, validator: validateMoldId, trigger: 'change' }],
|
|
|
|
operateTime: [{ required: true, message: t('MoldManagement.MoldOperate.validatorOperateTimeRequired'), trigger: 'blur' }],
|
|
|
|
operateTime: [{ required: true, message: t('MoldManagement.MoldOperate.validatorOperateTimeRequired'), trigger: 'blur' }],
|
|
|
|
operatorId: [{ required: true, message: t('MoldManagement.MoldOperate.validatorOperatorRequired'), trigger: 'change' }],
|
|
|
|
operatorId: [{ required: true, message: t('MoldManagement.MoldOperate.validatorOperatorRequired'), trigger: 'change' }],
|
|
|
|
@ -265,6 +263,7 @@ const submitForm = async () => {
|
|
|
|
deviceId: raw.deviceId,
|
|
|
|
deviceId: raw.deviceId,
|
|
|
|
moldId: raw.moldId,
|
|
|
|
moldId: raw.moldId,
|
|
|
|
lineId: raw.lineId,
|
|
|
|
lineId: raw.lineId,
|
|
|
|
|
|
|
|
lineName: displayTopCategory.value, // 产线名称,用于列表显示
|
|
|
|
operateTime: raw.operateTime,
|
|
|
|
operateTime: raw.operateTime,
|
|
|
|
operatorId: raw.operatorId,
|
|
|
|
operatorId: raw.operatorId,
|
|
|
|
remark: raw.remark,
|
|
|
|
remark: raw.remark,
|
|
|
|
@ -292,12 +291,12 @@ const submitForm = async () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const ensureLineOptionsLoaded = async () => {
|
|
|
|
const ensureLineOptionsLoaded = async () => {
|
|
|
|
if (lineOptions.value.length) return
|
|
|
|
if (deviceLineTree.value.length) return
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const data = await OrganizationApi.getOrganizationList()
|
|
|
|
const data = await DeviceLineApi.getDeviceLineTree()
|
|
|
|
lineOptions.value = Array.isArray(data) ? data : []
|
|
|
|
deviceLineTree.value = Array.isArray(data) ? data : []
|
|
|
|
} catch {
|
|
|
|
} catch {
|
|
|
|
lineOptions.value = []
|
|
|
|
deviceLineTree.value = []
|
|
|
|
}
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
operatorOptions.value = (await getSimpleUserList()) ?? []
|
|
|
|
operatorOptions.value = (await getSimpleUserList()) ?? []
|
|
|
|
@ -347,6 +346,7 @@ const resetForm = () => {
|
|
|
|
selectedMoldRows.value = []
|
|
|
|
selectedMoldRows.value = []
|
|
|
|
ids.value = []
|
|
|
|
ids.value = []
|
|
|
|
moldIds.value = []
|
|
|
|
moldIds.value = []
|
|
|
|
|
|
|
|
displayTopCategory.value = ''
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
formRef.value?.resetFields()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const deviceColumns = [
|
|
|
|
const deviceColumns = [
|
|
|
|
@ -377,12 +377,42 @@ const fetchMoldBrandPage = async (params: Record<string, any>) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const selectedDeviceRows = ref<any[]>([])
|
|
|
|
const selectedDeviceRows = ref<any[]>([])
|
|
|
|
const selectedMoldRows = ref<any[]>([])
|
|
|
|
const selectedMoldRows = ref<any[]>([])
|
|
|
|
const handleDeviceSelectConfirm = (payload: { ids: (number | string)[]; rows: any[] }) => {
|
|
|
|
const handleDeviceSelectConfirm = async (payload: { ids: (number | string)[]; rows: any[] }) => {
|
|
|
|
const row = payload.rows[0]
|
|
|
|
const row = payload.rows[0]
|
|
|
|
if (row) {
|
|
|
|
if (row) {
|
|
|
|
selectedDeviceRows.value = [row]
|
|
|
|
selectedDeviceRows.value = [row]
|
|
|
|
formData.value.deviceId = Number(row.id)
|
|
|
|
const deviceId = Number(row.id)
|
|
|
|
ids.value = [Number(row.id)]
|
|
|
|
formData.value.deviceId = deviceId
|
|
|
|
|
|
|
|
ids.value = [deviceId]
|
|
|
|
|
|
|
|
// 选择设备后调详情接口获取完整的 deviceLine 字段(分页接口不返回该字段)
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const detail = await DeviceLedgerApi.getDeviceLedger(deviceId)
|
|
|
|
|
|
|
|
console.log('设备详情:', { detail, topCategoryName: detail?.topCategoryName, topCategoryId: detail?.topCategoryId, deviceLine: detail?.deviceLine })
|
|
|
|
|
|
|
|
if (detail?.deviceLine != null) {
|
|
|
|
|
|
|
|
formData.value.lineId = detail.deviceLine
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// 优先用后端返回的顶级分类名称
|
|
|
|
|
|
|
|
displayTopCategory.value = detail?.topCategoryName || ''
|
|
|
|
|
|
|
|
// fallback: 用产线树(DeviceLineTree)匹配,找到根节点名称
|
|
|
|
|
|
|
|
if (!displayTopCategory.value && detail?.deviceLine != null && deviceLineTree.value.length) {
|
|
|
|
|
|
|
|
const lineId = Number(detail.deviceLine)
|
|
|
|
|
|
|
|
console.log('fallback 匹配: deviceLine=', lineId, '产线树根数=', deviceLineTree.value.length)
|
|
|
|
|
|
|
|
// 检查每个顶层节点是否包含目标节点(自身或后代),返回根节点名称
|
|
|
|
|
|
|
|
const containsId = (nodes: DeviceLineTreeVO[] | undefined, id: number): boolean => {
|
|
|
|
|
|
|
|
if (!nodes) return false
|
|
|
|
|
|
|
|
return nodes.some((n) => n.id === id || containsId(n.children, id))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const root of deviceLineTree.value) {
|
|
|
|
|
|
|
|
if (root.id === lineId || containsId(root.children, lineId)) {
|
|
|
|
|
|
|
|
displayTopCategory.value = root.name
|
|
|
|
|
|
|
|
console.log('产线匹配成功:', root.name)
|
|
|
|
|
|
|
|
break
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.error('获取设备详情失败', e)
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
selectedDeviceRows.value = []
|
|
|
|
selectedDeviceRows.value = []
|
|
|
|
formData.value.deviceId = undefined
|
|
|
|
formData.value.deviceId = undefined
|
|
|
|
@ -481,6 +511,10 @@ const moldDisplayText = computed(() => {
|
|
|
|
return map.get(formData.value.moldId) || ''
|
|
|
|
return map.get(formData.value.moldId) || ''
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const displayLineName = computed(() => displayTopCategory.value)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const openCriticalComponentDialog = async () => {
|
|
|
|
const openCriticalComponentDialog = async () => {
|
|
|
|
searchParams.deviceCode=''
|
|
|
|
searchParams.deviceCode=''
|
|
|
|
|