完善
This commit is contained in:
@@ -44,4 +44,26 @@ export function userbyid(id: string | number) {
|
|||||||
url: `/user/getById/${id}`,
|
url: `/user/getById/${id}`,
|
||||||
method: 'get',
|
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,
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -116,9 +116,28 @@
|
|||||||
align="center"
|
align="center"
|
||||||
>
|
>
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<el-tag :type="getStatusType(row.goodsStatus)" size="small">
|
<el-button
|
||||||
|
:type="getStatusType(row.goodsStatus)"
|
||||||
|
link
|
||||||
|
@click="handleStatusClick(row)"
|
||||||
|
>
|
||||||
{{ getStatusText(row.goodsStatus) }}
|
{{ getStatusText(row.goodsStatus) }}
|
||||||
</el-tag>
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="标准流程"
|
||||||
|
width="150"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button
|
||||||
|
:type="getFlowButtonType(row)"
|
||||||
|
link
|
||||||
|
@click="openFlowSelectDialog(row)"
|
||||||
|
>
|
||||||
|
{{ getFlowButtonText(row) }}
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
@@ -127,11 +146,8 @@
|
|||||||
min-width="150"
|
min-width="150"
|
||||||
:formatter="formatCell"
|
:formatter="formatCell"
|
||||||
/>
|
/>
|
||||||
<el-table-column label="操作" width="240" fixed="right">
|
<el-table-column label="操作" width="180" fixed="right">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button type="warning" link @click="openFlowSelectDialog(scope.row)">
|
|
||||||
选择标准
|
|
||||||
</el-button>
|
|
||||||
<el-button type="primary" link @click="handleEdit(scope.row)">编辑</el-button>
|
<el-button type="primary" link @click="handleEdit(scope.row)">编辑</el-button>
|
||||||
<el-button type="danger" link @click="handleDelete(scope.row)">删除</el-button>
|
<el-button type="danger" link @click="handleDelete(scope.row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
@@ -408,6 +424,79 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 样品流程状态列表弹窗 -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="flowStatusDialogVisible"
|
||||||
|
:title="flowStatusDialogTitle"
|
||||||
|
width="1200px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
>
|
||||||
|
<el-table
|
||||||
|
:data="flowStatusTableData"
|
||||||
|
stripe
|
||||||
|
border
|
||||||
|
style="width: 100%"
|
||||||
|
v-loading="flowStatusLoading"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
type="index"
|
||||||
|
label="序号"
|
||||||
|
width="60"
|
||||||
|
:index="(index: number) => index + 1"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="islandName"
|
||||||
|
label="功能岛名称"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="devName"
|
||||||
|
label="设备名称"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="paramName"
|
||||||
|
label="参数名称"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="paramValue"
|
||||||
|
label="参数值"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="status"
|
||||||
|
label="状态"
|
||||||
|
width="100"
|
||||||
|
align="center"
|
||||||
|
>
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="getFlowStatusType(row.status)" size="small">
|
||||||
|
{{ getFlowStatusText(row.status) }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
prop="createTime"
|
||||||
|
label="执行时间"
|
||||||
|
width="180"
|
||||||
|
:formatter="formatDateTime"
|
||||||
|
/>
|
||||||
|
</el-table>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="flowStatusDialogVisible = false">
|
||||||
|
关闭
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -426,6 +515,11 @@ import {
|
|||||||
import { flowInfolist, flowInfobyid } from '@/api/tb/flowinfo'
|
import { flowInfolist, flowInfobyid } from '@/api/tb/flowinfo'
|
||||||
import { dictypeadd, dictypelist } from '@/api/system/dictype'
|
import { dictypeadd, dictypelist } from '@/api/system/dictype'
|
||||||
import { dicdataadd, dicdatadel, dicdatabydicid } from '@/api/system/dicdata'
|
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 {
|
interface GoodsInfoItem {
|
||||||
id?: number | string
|
id?: number | string
|
||||||
@@ -528,6 +622,13 @@ const tempSelectedFlowId = ref<number | string | null>(null)
|
|||||||
const tempSelectedFlowName = ref('')
|
const tempSelectedFlowName = ref('')
|
||||||
const currentBoundFlowName = ref('')
|
const currentBoundFlowName = ref('')
|
||||||
|
|
||||||
|
// 样品流程状态列表相关
|
||||||
|
const flowStatusDialogVisible = ref(false)
|
||||||
|
const flowStatusDialogTitle = ref('样品流程状态列表')
|
||||||
|
const flowStatusLoading = ref(false)
|
||||||
|
const flowStatusTableData = ref<any[]>([])
|
||||||
|
const currentGoodsForStatus = ref<GoodsInfoItem | null>(null)
|
||||||
|
|
||||||
// 获取序号
|
// 获取序号
|
||||||
const getIndex = (index: number) => {
|
const getIndex = (index: number) => {
|
||||||
return (pagination.pageNum - 1) * pagination.pageSize + index + 1
|
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) => {
|
const getStatusType = (status: number | null | undefined) => {
|
||||||
if (status === 0) return 'primary' // 待处理 - 蓝色
|
if (status === 0) return 'primary' // 待处理 - 蓝色
|
||||||
if (status === 1) return 'success' // 处理成功 - 绿色
|
if (status === 1) return 'success' // 处理成功 - 绿色
|
||||||
@@ -569,6 +670,73 @@ const getStatusText = (status: number | null | undefined) => {
|
|||||||
return '未知'
|
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 () => {
|
const loadGoodsTypeOptions = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -667,7 +835,31 @@ const getGoodsInfoList = async () => {
|
|||||||
const totalValue =
|
const totalValue =
|
||||||
data.total ?? data.count ?? data.totalCount ?? records.length ?? 0
|
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
|
total.value = Number(totalValue) || 0
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取样品信息列表失败:', error)
|
console.error('获取样品信息列表失败:', error)
|
||||||
@@ -1003,6 +1195,21 @@ const handleFlowSelectSave = async () => {
|
|||||||
|
|
||||||
if (res.code === '0' || res.code === 0) {
|
if (res.code === '0' || res.code === 0) {
|
||||||
ElMessage.success('标准流程绑定成功')
|
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
|
flowSelectDialogVisible.value = false
|
||||||
tempSelectedFlowId.value = null
|
tempSelectedFlowId.value = null
|
||||||
tempSelectedFlowName.value = ''
|
tempSelectedFlowName.value = ''
|
||||||
@@ -1216,6 +1423,118 @@ const handleSelectOptionsDialogClose = () => {
|
|||||||
selectOptionsList.value = []
|
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(() => {
|
onMounted(() => {
|
||||||
loadGoodsTypeOptions().then(() => {
|
loadGoodsTypeOptions().then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user