add(mes): 工序信息关联产线和用户功能

- 新增关联产线和用户的功能按钮和对话框
- 实现关联产线和关联用户的选择、添加、删除功能
- 新增相关的 API 接口和类型定义
master
zch 5 days ago
parent 0e5b330304
commit 114dfbe134

@ -45,7 +45,19 @@ export const addBaseProcessInfo = (data: BaseProcessInfoForm) => {
*/
export const updateBaseProcessInfo = (data: BaseProcessInfoForm) => {
return request({
url: '/mes/baseProcessInfo',
url: '/mes/baseProcessInfo/edit',
method: 'put',
data: data
});
};
/**
*
* @param data
*/
export const updateBaseProcessInfoUser = (data: BaseProcessInfoForm) => {
return request({
url: '/mes/baseProcessInfo/editUser',
method: 'put',
data: data
});

@ -69,6 +69,11 @@ export interface BaseProcessInfoVO {
*/
updateTime: string;
prodBaseProcessProdlineVoList?: ProdBaseProcessProdLine[];
prodBaseProcessUserVoList?: ProdBaseProcessUser[];
prodBaseProcessProdlineBoList?: ProdBaseProcessProdLine[];
prodBaseProcessUserBoList?: ProdBaseProcessUser[];
}
export interface BaseProcessInfoForm extends BaseEntity {
@ -116,6 +121,11 @@ export interface BaseProcessInfoForm extends BaseEntity {
productionTimeHours?: number;
productionTimeMinutes?: number;
prodBaseProcessProdlineVoList?: ProdBaseProcessProdLine[];
prodBaseProcessUserVoList?: ProdBaseProcessUser[];
prodBaseProcessProdlineBoList?: ProdBaseProcessProdLine[];
prodBaseProcessUserBoList?: ProdBaseProcessUser[];
}
export interface BaseProcessInfoQuery extends PageQuery {
@ -159,7 +169,80 @@ export interface BaseProcessInfoQuery extends PageQuery {
*
*/
params?: any;
prodBaseProcessProdlineV0List?: ProdBaseProcessProdLine[];
prodBaseProcessUserV0List?: ProdBaseProcessUser[];
prodBaseProcessProdlineBoList?: ProdBaseProcessProdLine[];
prodBaseProcessUserBoList?: ProdBaseProcessUser[];
}
export interface ProdBaseProcessProdLine {
/**
* ID
*/
processId: string | number;
/**
* 线ID
*/
prodLineId: string | number;
/**
*
*/
tenantId: string | number;
/**
*
*/
createBy: string;
/**
*
*/
createTime: string;
}
export interface ProdBaseProcessUser {
/**
* ID
*/
processId: string | number;
/**
* ID
*/
userId: string | number;
/**
*
*/
tenantId: string | number;
/**
*
*/
userName: string;
/**
*
*/
createBy: string;
/**
*
*/
createTime: string;
}

@ -0,0 +1,77 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProdBaseProcessProdLineVO, ProdBaseProcessProdLineForm, ProdBaseProcessProdLineQuery } from '@/api/mes/prodBaseProcessProdLine/types';
/**
* 线
* @param query
* @returns {*}
*/
export const listProdBaseProcessProdLine = (query?: ProdBaseProcessProdLineQuery): AxiosPromise<ProdBaseProcessProdLineVO[]> => {
return request({
url: '/mes/prodBaseProcessProdLine/list',
method: 'get',
params: query
});
};
/**
* 线
* @param processId
*/
export const getProdBaseProcessProdLine = (processId: string | number): AxiosPromise<ProdBaseProcessProdLineVO> => {
return request({
url: '/mes/prodBaseProcessProdLine/' + processId,
method: 'get'
});
};
/**
* 线
* @param data
*/
export const addProdBaseProcessProdLine = (data: ProdBaseProcessProdLineForm) => {
return request({
url: '/mes/prodBaseProcessProdLine',
method: 'post',
data: data
});
};
/**
* 线
* @param data
*/
export const updateProdBaseProcessProdLine = (data: ProdBaseProcessProdLineForm) => {
return request({
url: '/mes/prodBaseProcessProdLine',
method: 'put',
data: data
});
};
/**
* 线
* @param processId
*/
export const delProdBaseProcessProdLine = (processId: string | number | Array<string | number>) => {
return request({
url: '/mes/prodBaseProcessProdLine/' + processId,
method: 'delete'
});
};
/**
* 线
* @param query
* @returns {*}
*/
export function getProdBaseProcessProdLineList (query) {
return request({
url: '/mes/prodBaseProcessProdLine/getProdBaseProcessProdLineList',
method: 'get',
params: query
});
};

@ -0,0 +1,65 @@
export interface ProdBaseProcessProdLineVO {
/**
* ID
*/
processId: string | number;
/**
* 线ID
*/
prodLineId: string | number;
/**
*
*/
tenantId: string | number;
/**
*
*/
createBy: string;
/**
*
*/
createTime: string;
}
export interface ProdBaseProcessProdLineForm extends BaseEntity {
/**
* ID
*/
processId?: string | number;
/**
* 线ID
*/
prodLineId?: string | number;
prodLines?: string[];
}
export interface ProdBaseProcessProdLineQuery extends PageQuery {
/**
* ID
*/
processId?: string | number;
/**
* 线ID
*/
prodLineId?: string | number;
/**
*
*/
params?: any;
}

@ -0,0 +1,77 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ProdBaseProcessUserVO, ProdBaseProcessUserForm, ProdBaseProcessUserQuery } from '@/api/mes/prodBaseProcessUser/types';
/**
*
* @param query
* @returns {*}
*/
export const listProdBaseProcessUser = (query?: ProdBaseProcessUserQuery): AxiosPromise<ProdBaseProcessUserVO[]> => {
return request({
url: '/mes/prodBaseProcessUser/list',
method: 'get',
params: query
});
};
/**
*
* @param processId
*/
export const getProdBaseProcessUser = (processId: string | number): AxiosPromise<ProdBaseProcessUserVO> => {
return request({
url: '/mes/prodBaseProcessUser/' + processId,
method: 'get'
});
};
/**
*
* @param data
*/
export const addProdBaseProcessUser = (data: ProdBaseProcessUserForm) => {
return request({
url: '/mes/prodBaseProcessUser',
method: 'post',
data: data
});
};
/**
*
* @param data
*/
export const updateProdBaseProcessUser = (data: ProdBaseProcessUserForm) => {
return request({
url: '/mes/prodBaseProcessUser',
method: 'put',
data: data
});
};
/**
*
* @param processId
*/
export const delProdBaseProcessUser = (processId: string | number | Array<string | number>) => {
return request({
url: '/mes/prodBaseProcessUser/' + processId,
method: 'delete'
});
};
/**
*
* @param query
* @returns {*}
*/
export function getProdBaseProcessUserList (query) {
return request({
url: '/mes/prodBaseProcessUser/getProdBaseProcessUserList',
method: 'get',
params: query
});
};

@ -0,0 +1,79 @@
export interface ProdBaseProcessUserVO {
/**
* ID
*/
processId: string | number;
/**
* ID
*/
userId: string | number;
/**
*
*/
tenantId: string | number;
/**
*
*/
userName: string;
/**
*
*/
createBy: string;
/**
*
*/
createTime: string;
}
export interface ProdBaseProcessUserForm extends BaseEntity {
/**
* ID
*/
processId?: string | number;
/**
* ID
*/
userId?: string | number;
/**
*
*/
userName?: string;
users?: string[];
}
export interface ProdBaseProcessUserQuery extends PageQuery {
/**
* ID
*/
processId?: string | number;
/**
* ID
*/
userId?: string | number;
/**
*
*/
userName?: string;
/**
*
*/
params?: any;
}

@ -78,12 +78,27 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<!-- <el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['mes:baseProcessInfo:edit']"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['mes:baseProcessInfo:remove']"></el-button>
</el-tooltip>
</el-tooltip>-->
<el-button
size="small"
type="text"
icon="el-icon-circle-plus"
@click="handleProdLineUpdate(scope.row)"
>关联产线
</el-button>
<el-button
size="small"
type="text"
icon="el-icon-s-check"
v-if="scope.row.processType !== '3'"
@click="handleUserUpdate(scope.row)"
>关联人员
</el-button>
</template>
</el-table-column>
</el-table>
@ -143,12 +158,125 @@
</div>
</template>
</el-dialog>
<!-- 关联产线对话框 -->
<el-dialog :title="dialog.title" v-model="prodLineOpen" width="700px" append-to-body>
<el-form ref="baseProcessInfoFormRef" :model="form" label-width="100px">
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-form-item label="工序编号" prop="processCode">
<el-input v-model="form.processCode" placeholder="请输入工序编号" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="工序名称" prop="processName">
<el-input v-model="form.processName" placeholder="请输入工序名称" disabled />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="center">工序关联产线信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-button type="primary" icon="el-icon-plus" size="small" @click="handleAddProdLine">线</el-button>
</el-col>
<el-col :span="12">
<el-button type="danger" icon="el-icon-delete" size="small" @click="handleDeleteProdLine"></el-button>
</el-col>
</el-row>
<el-table :data="prodBaseProcessProdlineBoList" :row-class-name="rowProdBaseProcessProdlineIndex"
@selection-change="handleProdLineSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" />
<el-table-column label="关联产线" align="center" prop="prodLineId">
<template #default="scope">
<el-select v-model="scope.row.prodLineId" placeholder="请选择关联产线" clearable>
<el-option
v-for="item in prodLineList"
:key="item.prodLineId"
:label="item.prodLineName"
:value="item.prodLineId"
:disabled="prodBaseProcessProdlineBoList.some(i =>i.prodLineId === item.prodLineId)"
></el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitProdLineForm"> </el-button>
<el-button @click="cancelProdLine"> </el-button>
</div>
</template>
</el-dialog>
<!-- 关联人员对话框 -->
<el-dialog :title="dialog.title" v-model="userOpen" width="700px" append-to-body>
<el-form ref="baseProcessInfoFormRef" :model="form" label-width="100px">
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-form-item label="工序编号" prop="processCode">
<el-input v-model="form.processCode" placeholder="请输入工序编号" disabled />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="工序名称" prop="processName">
<el-input v-model="form.processName" placeholder="请输入工序名称" disabled />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="center">工序关联人员信息</el-divider>
<el-row :gutter="10" class="mb8">
<el-col :span="12">
<el-button type="primary" icon="el-icon-plus" size="small" @click="handleAddUser"></el-button>
</el-col>
<el-col :span="12">
<el-button type="danger" icon="el-icon-delete" size="small" @click="handleDeleteUser"></el-button>
</el-col>
</el-row>
<el-table :data="prodBaseProcessUserBoList" :row-class-name="rowProdBaseProcessUserIndex"
@selection-change="handleUserSelectionChange">
<el-table-column type="selection" width="50" align="center" />
<el-table-column label="序号" align="center" prop="index" />
<el-table-column label="name" align="center" prop="userName" />
<el-table-column label="关联人员" align="center" prop="userId">
<template #default="scope">
<el-select v-model="scope.row.userId" filterable placeholder="请选择关联人员" clearable @change="handleSelectUser(scope.row)">
<el-option
v-for="item in userList"
:key="item.userId"
:label="item.userName"
:value="item.userId"
:disabled="prodBaseProcessUserBoList.some(i =>i.userId === item.userId)"
></el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitUserForm"> </el-button>
<el-button @click="cancelUser"> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name="BaseProcessInfo" lang="ts">
import { listBaseProcessInfo, getBaseProcessInfo, delBaseProcessInfo, addBaseProcessInfo, updateBaseProcessInfo } from '@/api/mes/baseProcessInfo';
import { BaseProcessInfoVO, BaseProcessInfoQuery, BaseProcessInfoForm } from '@/api/mes/baseProcessInfo/types';
import {
listBaseProcessInfo,
getBaseProcessInfo,
delBaseProcessInfo,
addBaseProcessInfo,
updateBaseProcessInfo,
updateBaseProcessInfoUser
} from '@/api/mes/baseProcessInfo';
import { getProdLineList } from '@/api/mes/baseProdLineInfo';
import { getUserList } from '@/api/system/user';
import { BaseProcessInfoVO, BaseProcessInfoQuery, BaseProcessInfoForm, ProdBaseProcessProdLine, ProdBaseProcessUser } from '@/api/mes/baseProcessInfo/types';
import {error} from "echarts/types/src/util/log";
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { active_flag, process_type } = toRefs<any>(proxy?.useDict('active_flag', 'process_type'));
@ -162,6 +290,19 @@ const single = ref(true);
const multiple = ref(true);
const total = ref(0);
//
const prodLineOpen = ref(false);//线
const userOpen = ref(false);//
const prodLineList = ref([]);//
const userList = ref([]);//
const chekedProdLineList = ref<any[]>([]);
const chekedUserList = ref<any[]>([]);
const prodBaseProcessProdlineBoList = ref<any[]>([]);
const prodBaseProcessUserBoList = ref<any[]>([]);
const queryFormRef = ref<ElFormInstance>();
const baseProcessInfoFormRef = ref<ElFormInstance>();
@ -200,6 +341,11 @@ const initFormData: BaseProcessInfoForm = {
productionTimeDays: 0,
productionTimeHours: 0,
productionTimeMinutes: 0,
/* prodBaseProcessProdlineVoList: [],
prodBaseProcessUserVoList: [],*/
prodBaseProcessProdlineBoList: [],
prodBaseProcessUserBoList: []
}
const data = reactive<PageData<BaseProcessInfoForm, BaseProcessInfoQuery>>({
form: {...initFormData},
@ -268,6 +414,16 @@ const cancel = () => {
reset();
dialog.visible = false;
}
const cancelUser = () => {
reset();
userOpen.value = false;
prodBaseProcessUserBoList.value = [];
}
const cancelProdLine = () => {
reset();
prodLineOpen.value = false;
prodBaseProcessProdlineBoList.value = [];
}
/** 表单重置 */
const reset = () => {
@ -325,10 +481,50 @@ const submitForm = () => {
}
proxy?.$modal.msgSuccess("操作成功");
dialog.visible = false;
chekedProdLineList.value = [];
form.value.prodBaseProcessProdlineBoList = [];
prodBaseProcessProdlineBoList.value = [];
await getList();
}
});
}
const submitUserForm = () => {
baseProcessInfoFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
form.value.prodBaseProcessUserBoList = prodBaseProcessUserBoList.value;
await updateBaseProcessInfoUser(form.value).finally(() => buttonLoading.value = false);
proxy?.$modal.msgSuccess("操作成功");
userOpen.value = false;
chekedUserList.value = [];
form.value.prodBaseProcessUserBoList = [];
prodBaseProcessProdlineBoList.value = [];
await getList();
}
});
}
const submitProdLineForm = () => {
baseProcessInfoFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
form.value.prodBaseProcessProdlineBoList = prodBaseProcessProdlineBoList.value;
convertToSeconds();
if (form.value.processId) {
await updateBaseProcessInfo(form.value).finally(() => buttonLoading.value = false);
}
proxy?.$modal.msgSuccess("操作成功");
prodLineOpen.value = false;
chekedProdLineList.value = [];
form.value.prodBaseProcessProdlineBoList = [];
prodBaseProcessProdlineBoList.value = [];
await getList();
}
});
}
/** 删除按钮操作 */
const handleDelete = async (row?: BaseProcessInfoVO) => {
@ -346,7 +542,154 @@ const handleExport = () => {
}, `baseProcessInfo_${new Date().getTime()}.xlsx`)
}
//线
const handleProdLineUpdate = async (row?: BaseProcessInfoVO) => {
reset();
const _processId = row?.processId || ids.value[0]
const res = await getBaseProcessInfo(_processId);
form.value = res.data;
prodLineOpen.value = true;
prodBaseProcessProdlineBoList.value = res.data.prodBaseProcessProdlineVoList.map((item, index) => ({
...item,
index: index + 1 // index
}));
dialog.title = "关联产线";
}
const getLineList = async () => {
const res = await getProdLineList(null);//
prodLineList.value = res.data;
}
//
const handleUserUpdate = async (row?: BaseProcessInfoVO) => {
reset();
const _processId = row?.processId || ids.value[0]
const res = await getBaseProcessInfo(_processId);
form.value = res.data;
userOpen.value = true;
prodBaseProcessUserBoList.value = res.data.prodBaseProcessUserVoList.map((item, index) => ({
...item,
index: index + 1 // index
}));
dialog.title = "关联用户";
}
const getUsersList = async () => {
const res = await getUserList(null);//
userList.value = res.data;
}
// 线
const handleAddProdLine = () => {
return prodBaseProcessProdlineBoList.value.push({
prodLineId: null,
processId: form.value.processId, // processId
index: prodBaseProcessProdlineBoList.value.length + 1,
});
}
// 线
const handleDeleteProdLine = () => {
if (chekedProdLineList.value.length === 0) {
proxy?.$modal.msgError("请先选择要删除的工序关联产线数据");
} else {
prodBaseProcessProdlineBoList.value = prodBaseProcessProdlineBoList.value
.filter(item => !chekedProdLineList.value.includes(item.prodLineId))
.map((item, index) => ({
...item,
index: index + 1 // index
}));
}
}
// 线
const handleProdLineSelectionChange = (selection) => {
chekedProdLineList.value = selection.map(item => item.prodLineId);
}
//
const handleAddUser = () => {
prodBaseProcessUserBoList.value.push({
userId: null,
processId: form.value.processId, // processId
index: prodBaseProcessUserBoList.value.length + 1,
userName: null,
});
}
//
const handleDeleteUser = () => {
if (chekedUserList.value.length === 0) {
proxy?.$modal.msgError("请先选择要删除的工序关联人员数据");
} else {
prodBaseProcessUserBoList.value = prodBaseProcessUserBoList.value
.filter(item => !chekedUserList.value.includes(item.userId))
.map((item, index) => ({
...item,
index: index + 1 // index
}));
}
}
const handleUserSelectionChange = (selection) => {
chekedUserList.value = selection.map(item => item.userId);
}
//
/*
const handleSelectUser = (row) => {
const selectedUser = userList.value.find(user => user.userId === row.userId);
if (selectedUser) {
row.userName = selectedUser.userName;
} else {
row.userName = null;
}
}
*/
const handleSelectUser = (row) => {
const selectedUser = userList.value.find(user => user.userId === row.userId);
console.log(selectedUser);
if (selectedUser) {
row.userName = selectedUser.userName;
// prodBaseProcessUserBoList userName
const userIndex = prodBaseProcessUserBoList.value.findIndex(user => user.userId === row.userId);
if (userIndex !== -1) {
prodBaseProcessUserBoList.value[userIndex].userName = selectedUser.userName;
}
} else {
row.userName = null;
}
}
const rowProdBaseProcessProdlineIndex = ({ row, rowIndex }: { row: any; rowIndex: number }): string => {
//
if (row.someCondition) {
return 'custom-class';
}
return '';
}
const rowProdBaseProcessUserIndex = ({ row, rowIndex }: { row: any; rowIndex: number }): string => {
//
if (row.someCondition) {
return 'custom-class';
}
return '';
}
onMounted(() => {
getUsersList();
getLineList();
getList();
});
</script>

Loading…
Cancel
Save