feat(machine): 添加机台页面产线工序筛选功能
- 在机台页面搜索表单中新增所属产线和所属工序筛选项 - 调整搜索表单标签宽度从68px到80px - 优化产线和工序数据获取方式,使用下拉选项替代映射表 - 在用户机台页面表格中新增机台编码列 - 更新机台查询接口支持按产线ID和工序ID筛选 - 完善用户机台表单中的机台选择功能,支持按工序关联机台 - 重构部分VO类的注解导入顺序以符合规范
This commit is contained in:
parent
3ab61e87c2
commit
c183142e88
@ -1,13 +1,10 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.machine.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 机台主数据分页 Request VO")
|
||||
@Data
|
||||
@ -18,4 +15,10 @@ public class MachinePageReqVO extends PageParam {
|
||||
@Schema(description = "状态(1启用 2 未启用)", example = "1")
|
||||
private Integer enabledStatus;
|
||||
|
||||
|
||||
//产线,工序
|
||||
@Schema(description = "产线", example = "1")
|
||||
private String belgLineId;
|
||||
@Schema(description = "工序", example = "1")
|
||||
private String belgProcId;
|
||||
}
|
||||
@ -1,13 +1,10 @@
|
||||
package com.ningxia.yunxi.chemmes.module.biz.controller.admin.usermachine.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import com.ningxia.yunxi.chemmes.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static com.ningxia.yunxi.chemmes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 人员所属机台、班组配置分页 Request VO")
|
||||
@Data
|
||||
|
||||
@ -58,4 +58,5 @@ public class UserMachineDetailDO extends BaseDO {
|
||||
private String procName;
|
||||
private String procCd;
|
||||
private Integer procId;
|
||||
|
||||
}
|
||||
|
||||
@ -21,6 +21,8 @@ public interface MachineMapper extends BaseMapperX<MachineDO> {
|
||||
default PageResult<MachineDO> selectPage(MachinePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<MachineDO>()
|
||||
.eqIfPresent(MachineDO::getEnabledStatus, reqVO.getEnabledStatus())
|
||||
.eqIfPresent(MachineDO::getBelgProcId, reqVO.getBelgProcId())
|
||||
.eqIfPresent(MachineDO::getBelgLineId, reqVO.getBelgLineId())
|
||||
.and(reqVO.getKeyWord() != null, wrapper -> wrapper
|
||||
.like(MachineDO::getMachineName, reqVO.getKeyWord())
|
||||
.or()
|
||||
|
||||
@ -7,8 +7,6 @@ export {}
|
||||
declare global {
|
||||
const DICT_TYPE: typeof import('@/utils/dict')['DICT_TYPE']
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const ElMessage: typeof import('element-plus/es')['ElMessage']
|
||||
const ElMessageBox: typeof import('element-plus/es')['ElMessageBox']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApp: typeof import('vue')['createApp']
|
||||
const customRef: typeof import('vue')['customRef']
|
||||
|
||||
@ -6,8 +6,38 @@
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="所属产线" prop="belgLineId">
|
||||
<el-select
|
||||
v-model="queryParams.belgLineId"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in proLineOptions"
|
||||
:key="item.id"
|
||||
:label="item.proLineName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="所属工序" prop="belgProcId">
|
||||
<el-select
|
||||
v-model="queryParams.belgProcId"
|
||||
placeholder="请选择"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in procOptions"
|
||||
:key="item.id"
|
||||
:label="item.procName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="enabledStatus">
|
||||
<el-select
|
||||
v-model="queryParams.enabledStatus"
|
||||
@ -102,7 +132,7 @@ import * as ProLineApi from '@/api/biz/proline'
|
||||
import * as ProcApi from '@/api/biz/proc'
|
||||
import MachineForm from './MachineForm.vue'
|
||||
|
||||
defineOptions({ name: 'machine' })
|
||||
defineOptions({ name: 'Machine' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
@ -113,47 +143,34 @@ const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
belgLineId: undefined,
|
||||
belgProcId: undefined,
|
||||
enabledStatus: undefined,
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
// 产线名称映射
|
||||
const proLineMap = ref({})
|
||||
const loadProLineMap = async () => {
|
||||
// 产线列表
|
||||
const proLineOptions = ref([])
|
||||
// 工序列表
|
||||
const procOptions = ref([])
|
||||
|
||||
/** 获取产线列表 */
|
||||
const loadProLineOptions = async () => {
|
||||
try {
|
||||
const data = await ProLineApi.getProLineDropdown({})
|
||||
const map = {}
|
||||
data.forEach(item => {
|
||||
map[item.id] = item.proLineName
|
||||
})
|
||||
proLineMap.value = map
|
||||
proLineOptions.value = data || []
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// 工序名称映射
|
||||
const procMap = ref({})
|
||||
const loadProcMap = async () => {
|
||||
/** 获取工序列表 */
|
||||
const loadProcOptions = async () => {
|
||||
try {
|
||||
const data = await ProcApi.getProcDropdown({})
|
||||
const map = {}
|
||||
data.forEach(item => {
|
||||
map[item.id] = item.procName
|
||||
})
|
||||
procMap.value = map
|
||||
procOptions.value = data || []
|
||||
} catch {}
|
||||
}
|
||||
|
||||
// 获取产线名称
|
||||
const getProLineName = (id) => {
|
||||
return proLineMap.value[id] || id || '-'
|
||||
}
|
||||
|
||||
// 获取工序名称
|
||||
const getProcName = (id) => {
|
||||
return procMap.value[id] || id || '-'
|
||||
}
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
@ -213,9 +230,20 @@ const handleExport = async () => {
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
loadProLineMap()
|
||||
loadProcMap()
|
||||
onMounted(async () => {
|
||||
await Promise.all([loadProLineOptions(), loadProcOptions()])
|
||||
getList()
|
||||
})
|
||||
|
||||
// 获取产线名称
|
||||
const getProLineName = (id) => {
|
||||
const item = proLineOptions.value.find(p => p.id === id)
|
||||
return item ? item.proLineName : (id || '-')
|
||||
}
|
||||
|
||||
// 获取工序名称
|
||||
const getProcName = (id) => {
|
||||
const item = procOptions.value.find(p => p.id === id)
|
||||
return item ? item.procName : (id || '-')
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -92,10 +92,27 @@
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
|
||||
</el-table-column>
|
||||
<el-table-column label="机台编码" align="center" min-width="150px">
|
||||
<template #default="scope">
|
||||
<el-select
|
||||
v-model="scope.row.machineId"
|
||||
placeholder="请选择机台"
|
||||
class="!w-full"
|
||||
clearable
|
||||
@change="handleMachineChange(scope.row)"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in scope.row.machineOptions || []"
|
||||
:key="item.id"
|
||||
:label="item.machineCd + '(' + item.machineName + ')'"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="创建人" align="center" prop="creator" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter2" />
|
||||
<el-table-column label="操作" align="center" width="80px">
|
||||
<template #default="scope">
|
||||
<el-button link type="danger" size="small" @click="removeProc(scope.$index)">删除</el-button>
|
||||
@ -118,7 +135,8 @@ import * as UserMachineApi from '@/api/biz/usermachine'
|
||||
import * as SystemUserApi from '@/api/system/user'
|
||||
import * as ProLineApi from '@/api/biz/proline'
|
||||
import * as ProcApi from '@/api/biz/proc'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as MachineApi from '@/api/biz/machine'
|
||||
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
@ -163,7 +181,32 @@ const open = async (type: string, id?: number) => {
|
||||
try {
|
||||
const data = await UserMachineApi.getUserMachine(id)
|
||||
formData.value = data
|
||||
machineList.value = data.machineList || []
|
||||
// 处理回显数据,确保 proLineId 和 procId 正确赋值,并加载机台列表
|
||||
machineList.value = await Promise.all((data.machineList || []).map(async (item: any) => {
|
||||
const row = {
|
||||
...item,
|
||||
// 确保 proLineId 存在,用于下拉框回显
|
||||
proLineId: item.proLineId !== undefined ? item.proLineId : item.lineId,
|
||||
// 确保 procId 存在,用于下拉框回显
|
||||
procId: item.procId !== undefined ? item.procId : item.id,
|
||||
// 机台相关字段
|
||||
machineId: item.machineId,
|
||||
machineCd: item.machineCd,
|
||||
machineName: item.machineName,
|
||||
machineOptions: [], // 机台下拉选项
|
||||
}
|
||||
// 如果有工序ID,则加载机台列表
|
||||
if (row.procId) {
|
||||
try {
|
||||
const machineData = await MachineApi.getMachineDropdown({ procId: row.procId })
|
||||
row.machineOptions = machineData || []
|
||||
} catch (error) {
|
||||
console.error('加载机台列表失败:', error)
|
||||
row.machineOptions = []
|
||||
}
|
||||
}
|
||||
return row
|
||||
}))
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
@ -219,6 +262,10 @@ const addProc = () => {
|
||||
procId: undefined,
|
||||
procCd: undefined,
|
||||
procName: undefined,
|
||||
machineId: undefined,
|
||||
machineCd: undefined,
|
||||
machineName: undefined,
|
||||
machineOptions: [], // 机台下拉选项
|
||||
})
|
||||
}
|
||||
|
||||
@ -237,19 +284,47 @@ const handleProLineChange = (row: any) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleProcChange = (row: any) => {
|
||||
const handleProcChange = async (row: any) => {
|
||||
// 清空机台选择
|
||||
row.machineId = undefined
|
||||
row.machineCd = undefined
|
||||
row.machineName = undefined
|
||||
row.machineOptions = []
|
||||
|
||||
if (row.procId) {
|
||||
const proc = procOptions.value.find((p: any) => p.id === row.procId)
|
||||
if (proc) {
|
||||
row.procCd = proc.procCd
|
||||
row.procName = proc.procName
|
||||
}
|
||||
// 通过工序ID查询机台列表
|
||||
try {
|
||||
const data = await MachineApi.getMachineDropdown({ procId: row.procId })
|
||||
row.machineOptions = data || []
|
||||
} catch (error) {
|
||||
console.error('查询机台列表失败:', error)
|
||||
row.machineOptions = []
|
||||
}
|
||||
} else {
|
||||
row.procCd = undefined
|
||||
row.procName = undefined
|
||||
}
|
||||
}
|
||||
|
||||
// 机台变更处理
|
||||
const handleMachineChange = (row: any) => {
|
||||
if (row.machineId) {
|
||||
const machine = row.machineOptions?.find((m: any) => m.id === row.machineId)
|
||||
if (machine) {
|
||||
row.machineCd = machine.machineCd
|
||||
row.machineName = machine.machineName
|
||||
}
|
||||
} else {
|
||||
row.machineCd = undefined
|
||||
row.machineName = undefined
|
||||
}
|
||||
}
|
||||
|
||||
const removeProc = (index: number) => {
|
||||
machineList.value.splice(index, 1)
|
||||
}
|
||||
@ -306,6 +381,9 @@ const submitForm = async () => {
|
||||
procId: p.procId,
|
||||
procCd: p.procCd,
|
||||
procName: p.procName,
|
||||
machineId: p.machineId,
|
||||
machineCd: p.machineCd,
|
||||
machineName: p.machineName,
|
||||
})),
|
||||
} as unknown as UserMachineApi.UserMachineVO
|
||||
if (formType.value === 'create') {
|
||||
|
||||
@ -120,6 +120,7 @@
|
||||
<el-table-column label="序号" align="center" type="index" width="60px" />
|
||||
<el-table-column label="产线编码" align="center" prop="proLineCd" />
|
||||
<el-table-column label="工序编码" align="center" prop="procCd" />
|
||||
<el-table-column label="机台编码" align="center" prop="machineCd" />
|
||||
<el-table-column label="创建人" align="center" prop="creator" />
|
||||
<el-table-column label="创建时间" align="center" prop="createTime" :formatter="dateFormatter2" />
|
||||
</el-table>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user