From d95092a4c95808b80459125635decf748ed3e397 Mon Sep 17 00:00:00 2001 From: Lxq <19852720163@163.com> Date: Mon, 19 Jan 2026 13:41:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rc_autoplc_front/src/api/system/user.ts | 22 ++ rc_autoplc_front/src/views/goods/index.vue | 335 ++++++++++++++++++++- 2 files changed, 349 insertions(+), 8 deletions(-) diff --git a/rc_autoplc_front/src/api/system/user.ts b/rc_autoplc_front/src/api/system/user.ts index 9c032ef..6ae1408 100644 --- a/rc_autoplc_front/src/api/system/user.ts +++ b/rc_autoplc_front/src/api/system/user.ts @@ -44,4 +44,26 @@ export function userbyid(id: string | number) { url: `/user/getById/${id}`, method: 'get', }) +} + +export function userlogin(username: string, password: string) { + return request({ + url: '/user/login', + method: 'post', + params: { + username, + password, + }, + }) +} + +export function userregister(username: string, password: string) { + return request({ + url: '/user/register', + method: 'post', + params: { + username, + password, + }, + }) } \ No newline at end of file diff --git a/rc_autoplc_front/src/views/goods/index.vue b/rc_autoplc_front/src/views/goods/index.vue index 59d28b5..f5df0d2 100644 --- a/rc_autoplc_front/src/views/goods/index.vue +++ b/rc_autoplc_front/src/views/goods/index.vue @@ -116,9 +116,28 @@ align="center" > + + + - + @@ -408,6 +424,79 @@ + + + + + + + + + + + + + + + + @@ -426,6 +515,11 @@ import { import { flowInfolist, flowInfobyid } from '@/api/tb/flowinfo' import { dictypeadd, dictypelist } from '@/api/system/dictype' import { dicdataadd, dicdatadel, dicdatabydicid } from '@/api/system/dicdata' +import { goodsFlowStatusselect } from '@/api/tb/goodsflowstatus' +import { islandInfobyid } from '@/api/tb/islandinfo' +import { devInfobyid } from '@/api/tb/devinfo' +import { stepInfolist } from '@/api/tb/stepinfo' +import { devparambyid } from '@/api/tb/devparam' interface GoodsInfoItem { id?: number | string @@ -528,6 +622,13 @@ const tempSelectedFlowId = ref(null) const tempSelectedFlowName = ref('') const currentBoundFlowName = ref('') +// 样品流程状态列表相关 +const flowStatusDialogVisible = ref(false) +const flowStatusDialogTitle = ref('样品流程状态列表') +const flowStatusLoading = ref(false) +const flowStatusTableData = ref([]) +const currentGoodsForStatus = ref(null) + // 获取序号 const getIndex = (index: number) => { return (pagination.pageNum - 1) * pagination.pageSize + index + 1 @@ -553,7 +654,7 @@ const formatDate = (_row: any, _column: any, value: any) => { } } -// 获取状态类型 +// 获取状态类型(用于按钮) const getStatusType = (status: number | null | undefined) => { if (status === 0) return 'primary' // 待处理 - 蓝色 if (status === 1) return 'success' // 处理成功 - 绿色 @@ -569,6 +670,73 @@ const getStatusText = (status: number | null | undefined) => { return '未知' } +// 获取标准流程按钮文本 +const getFlowButtonText = (row: GoodsInfoItem) => { + const flowId = (row as any).flowId + if (flowId === undefined || flowId === null || Number(flowId) === 0) { + return '未选择' + } + // 如果flowId存在,优先显示flowName + return row.flowName || '标准流程' +} + +// 获取标准流程按钮类型 +const getFlowButtonType = (row: GoodsInfoItem) => { + const flowId = (row as any).flowId + if (flowId === undefined || flowId === null || Number(flowId) === 0) { + return 'warning' // 橙色 + } + return 'success' // 绿色 +} + +// 样品状态点击事件处理 +const handleStatusClick = (row: GoodsInfoItem) => { + const status = row.goodsStatus + if (status === 0) { + // 待处理 - 显示提示 + ElMessage.info(`${row.goodsName || '该样品'}等待处理`) + } else if (status === 1 || status === 4) { + // 处理成功或处理失败 - 显示流程状态列表弹窗 + currentGoodsForStatus.value = row + flowStatusDialogTitle.value = `${row.goodsName || '样品'}流程状态列表` + flowStatusDialogVisible.value = true + getFlowStatusList(row) + } +} + +// 格式化日期时间(年月日时分秒) +const formatDateTime = (_row: any, _column: any, value: any) => { + if (!value) return '暂无' + try { + const date = new Date(value) + const year = date.getFullYear() + const month = String(date.getMonth() + 1).padStart(2, '0') + const day = String(date.getDate()).padStart(2, '0') + const hours = String(date.getHours()).padStart(2, '0') + const minutes = String(date.getMinutes()).padStart(2, '0') + const seconds = String(date.getSeconds()).padStart(2, '0') + return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}` + } catch (error) { + return value + } +} + +// 获取流程状态类型 +const getFlowStatusType = (status: number | null | undefined) => { + if (status === 0) return 'primary' + if (status === 1) return 'success' + if (status === 4) return 'danger' + return 'info' +} + +// 获取流程状态文本 +const getFlowStatusText = (status: number | null | undefined) => { + if (status === 0) return '待处理' + if (status === 1) return '处理成功' + if (status === 4) return '处理失败' + return '未知' +} + // 加载样品基质类型下拉框选项 const loadGoodsTypeOptions = async () => { try { @@ -667,7 +835,31 @@ const getGoodsInfoList = async () => { const totalValue = data.total ?? data.count ?? data.totalCount ?? records.length ?? 0 - tableData.value = records + // 对于有flowId但没有flowName的记录,获取flowName + const recordsWithFlowName = await Promise.all( + records.map(async (record: GoodsInfoItem) => { + const flowId = (record as any).flowId + if ( + flowId !== undefined && + flowId !== null && + Number(flowId) !== 0 && + !record.flowName + ) { + try { + const flowRes: any = await flowInfobyid(flowId) + if (flowRes.code === '0' || flowRes.code === 0) { + const flowData = flowRes.data || flowRes || {} + record.flowName = flowData.flowName || '' + } + } catch (error) { + console.error('获取标准流程名称失败:', error) + } + } + return record + }) + ) + + tableData.value = recordsWithFlowName total.value = Number(totalValue) || 0 } catch (error) { console.error('获取样品信息列表失败:', error) @@ -1003,6 +1195,21 @@ const handleFlowSelectSave = async () => { if (res.code === '0' || res.code === 0) { ElMessage.success('标准流程绑定成功') + + // 更新当前行的flowId和flowName + if (currentGoodsForFlow.value) { + currentGoodsForFlow.value.flowId = tempSelectedFlowId.value + currentGoodsForFlow.value.flowName = tempSelectedFlowName.value + // 同时更新tableData中对应的行 + const index = tableData.value.findIndex( + (item) => item.id === currentGoodsForFlow.value?.id + ) + if (index !== -1 && tableData.value[index]) { + tableData.value[index].flowId = tempSelectedFlowId.value + tableData.value[index].flowName = tempSelectedFlowName.value + } + } + flowSelectDialogVisible.value = false tempSelectedFlowId.value = null tempSelectedFlowName.value = '' @@ -1216,6 +1423,118 @@ const handleSelectOptionsDialogClose = () => { selectOptionsList.value = [] } +// 获取样品流程状态列表 +const getFlowStatusList = async (row: GoodsInfoItem) => { + if (!row.id) { + ElMessage.warning('缺少样品信息ID') + return + } + + try { + flowStatusLoading.value = true + // 调用goodsFlowStatusselect接口,传入goodsId + const res: any = await goodsFlowStatusselect({ goodsId: row.id }) + + const data = res?.data ?? res ?? {} + const records = Array.isArray(data) ? data : (data.records || data.list || data.rows || []) + + // 处理每条记录,查询功能岛名称、设备名称、参数名称和参数值 + const processedRecords = await Promise.all( + records.map(async (record: any, index: number) => { + const processedRecord = { ...record } + + // 查询功能岛名称 + if (record.islandId) { + try { + const islandRes: any = await islandInfobyid(record.islandId) + if (islandRes.code === '0' || islandRes.code === 0) { + const islandData = islandRes.data || islandRes || {} + processedRecord.islandName = islandData.islandName || '' + } + } catch (error) { + console.error('获取功能岛名称失败:', error) + processedRecord.islandName = '' + } + } else { + processedRecord.islandName = '' + } + + // 查询设备名称 + if (record.devId) { + try { + const devRes: any = await devInfobyid(record.devId) + if (devRes.code === '0' || devRes.code === 0) { + const devData = devRes.data || devRes || {} + processedRecord.devName = devData.devName || '' + } + } catch (error) { + console.error('获取设备名称失败:', error) + processedRecord.devName = '' + } + } else { + processedRecord.devName = '' + } + + // 查询参数名称和参数值(根据flowSort) + if (record.flowSort && row.flowId) { + try { + // 根据flowId和flowSort查询步骤信息 + const stepRes: any = await stepInfolist({ + flowId: row.flowId, + flowSort: record.flowSort, + }) + const stepData = stepRes?.data ?? stepRes ?? {} + const stepRecords = Array.isArray(stepData) ? stepData : (stepData.records || stepData.list || stepData.rows || []) + + if (stepRecords.length > 0) { + const stepInfo = stepRecords[0] + // 根据步骤信息中的paramId查询参数名称 + if (stepInfo.paramId) { + try { + const paramRes: any = await devparambyid(stepInfo.paramId) + if (paramRes.code === '0' || paramRes.code === 0) { + const paramData = paramRes.data || paramRes || {} + processedRecord.paramName = paramData.paramName || '' + } else { + processedRecord.paramName = '' + } + } catch (error) { + console.error('获取参数名称失败:', error) + processedRecord.paramName = '' + } + } else { + processedRecord.paramName = '' + } + // 参数值从流程状态记录中获取 + processedRecord.paramValue = record.paramValue || '' + } else { + processedRecord.paramName = '' + processedRecord.paramValue = record.paramValue || '' + } + } catch (error) { + console.error('获取参数信息失败:', error) + processedRecord.paramName = '' + processedRecord.paramValue = record.paramValue || '' + } + } else { + processedRecord.paramName = '' + processedRecord.paramValue = record.paramValue || '' + } + + return processedRecord + }) + ) + + flowStatusTableData.value = processedRecords + } catch (error) { + console.error('获取样品流程状态列表失败:', error) + ElMessage.error('获取样品流程状态列表失败') + flowStatusTableData.value = [] + } finally { + flowStatusLoading.value = false + } +} + // 初始化 onMounted(() => { loadGoodsTypeOptions().then(() => {