update add生产BOM信息

master
yinq 2 weeks ago
parent 7a72616e76
commit 8707eb35a8

@ -0,0 +1,77 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { MaterialBomVO, MaterialBomForm, MaterialBomQuery } from '@/api/mes/materialBom/types';
/**
* BOM
* @param query
* @returns {*}
*/
export const listMaterialBom = (query?: MaterialBomQuery): AxiosPromise<MaterialBomVO[]> => {
return request({
url: '/mes/materialBom/list',
method: 'get',
params: query
});
};
/**
* BOM
* @param materialBomId
*/
export const getMaterialBom = (materialBomId: string | number): AxiosPromise<MaterialBomVO> => {
return request({
url: '/mes/materialBom/' + materialBomId,
method: 'get'
});
};
/**
* BOM
* @param data
*/
export const addMaterialBom = (data: MaterialBomForm) => {
return request({
url: '/mes/materialBom',
method: 'post',
data: data
});
};
/**
* BOM
* @param data
*/
export const updateMaterialBom = (data: MaterialBomForm) => {
return request({
url: '/mes/materialBom',
method: 'put',
data: data
});
};
/**
* BOM
* @param materialBomId
*/
export const delMaterialBom = (materialBomId: string | number | Array<string | number>) => {
return request({
url: '/mes/materialBom/' + materialBomId,
method: 'delete'
});
};
/**
* BOM
* @param query
* @returns {*}
*/
export function getMaterialBomList(query) {
return request({
url: '/mes/materialBom/getMaterialBomList',
method: 'get',
params: query
});
};

@ -0,0 +1,280 @@
export interface MaterialBomVO {
/**
*
*/
materialBomId: string | number;
/**
*
*/
parentId: string | number;
/**
* ID
*/
materialId: string | number;
/**
*
*/
materialName: string;
/**
* bom
*/
materialBomDesc: string;
/**
* bom
*/
materialBomVersion: string;
/**
*
*/
ancestors: string;
/**
*
*/
standardAmount: number;
/**
* (1 0)
*/
topFlag: number;
/**
* (0 1 2)
*/
checkType: string;
/**
* ID
*/
projectId: string | number;
/**
* ()
*/
assembleTime: number;
/**
* 1ERP 2 3MES
*/
materialClassfication: string;
/**
*
*/
attachId: string | number;
/**
* 1 0
*/
activeFlag: string;
/**
*
*/
remark: string;
/**
*
*/
createDept: number;
/**
*
*/
createBy: number;
/**
*
*/
createTime: string;
/**
*
*/
updateBy: number;
/**
*
*/
updateTime: string;
/**
*
*/
children: MaterialBomVO[];
}
export interface MaterialBomForm extends BaseEntity {
/**
*
*/
materialBomId?: string | number;
/**
*
*/
parentId?: string | number;
/**
* ID
*/
materialId?: string | number;
/**
*
*/
materialName?: string;
/**
* bom
*/
materialBomDesc?: string;
/**
* bom
*/
materialBomVersion?: string;
/**
*
*/
ancestors?: string;
/**
*
*/
standardAmount?: number;
/**
* (1 0)
*/
topFlag?: number;
/**
* (0 1 2)
*/
checkType?: string;
/**
* ID
*/
projectId?: string | number;
/**
* ()
*/
assembleTime?: number;
/**
* 1ERP 2 3MES
*/
materialClassfication?: string;
/**
*
*/
attachId?: string | number;
/**
* 1 0
*/
activeFlag?: string;
/**
*
*/
remark?: string;
}
export interface MaterialBomQuery {
/**
*
*/
materialBomId?: string | number;
/**
*
*/
parentId?: string | number;
/**
* ID
*/
materialId?: string | number;
/**
*
*/
materialName?: string;
/**
* bom
*/
materialBomDesc?: string;
/**
* bom
*/
materialBomVersion?: string;
/**
*
*/
ancestors?: string;
/**
*
*/
standardAmount?: number;
/**
* (1 0)
*/
topFlag?: number;
/**
* (0 1 2)
*/
checkType?: string;
/**
* ID
*/
projectId?: string | number;
/**
* ()
*/
assembleTime?: number;
/**
* 1ERP 2 3MES
*/
materialClassfication?: string;
/**
*
*/
attachId?: string | number;
/**
* 1 0
*/
activeFlag?: string;
/**
*
*/
params?: any;
}

@ -0,0 +1,408 @@
<template>
<div class='p-2'>
<transition :enter-active-class='proxy?.animate.searchAnimate.enter'
:leave-active-class='proxy?.animate.searchAnimate.leave'>
<div v-show='showSearch' class='mb-[10px]'>
<el-card shadow='hover'>
<el-form ref='queryFormRef' :model='queryParams' :inline='true'>
<el-form-item label='物料名称' prop='materialName'>
<el-input v-model='queryParams.materialName' placeholder='请输入物料名称' clearable @keyup.enter='handleQuery' />
</el-form-item>
<!-- <el-form-item label='顶级标识' prop='topFlag'>-->
<!-- <el-input v-model='queryParams.topFlag' placeholder='请输入顶级标识' clearable-->
<!-- @keyup.enter='handleQuery' />-->
<!-- </el-form-item>-->
<!-- <el-form-item label='校验类型' prop='checkType'>-->
<!-- <el-select v-model='queryParams.checkType' placeholder='请选择校验类型' clearable>-->
<!-- <el-option v-for='dict in mes_check_type' :key='dict.value' :label='dict.label' :value='dict.value' />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label='激活标识' prop='activeFlag'>
<el-input v-model='queryParams.activeFlag' placeholder='请输入激活标识' clearable @keyup.enter='handleQuery' />
</el-form-item>
<el-form-item>
<el-button type='primary' icon='Search' @click='handleQuery'>搜索</el-button>
<el-button icon='Refresh' @click='resetQuery'>重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-card shadow='never'>
<template #header>
<el-row :gutter='10' class='mb8'>
<el-col :span='1.5'>
<el-button type='primary' plain icon='Plus' @click='handleAdd()' v-hasPermi="['mes:materialBom:add']">
</el-button>
</el-col>
<el-col :span='1.5'>
<el-button type='info' plain icon='Sort' @click='handleToggleExpandAll'>展开/折叠</el-button>
</el-col>
<right-toolbar v-model:showSearch='showSearch' @queryTable='getList'></right-toolbar>
</el-row>
</template>
<el-table
ref='materialBomTableRef'
v-loading='loading'
:data='materialBomList'
row-key='materialName'
:default-expand-all='isExpandAll'
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
>
<!-- <el-table-column label='主键标识' align='center' prop='materialBomId' />-->
<!-- <el-table-column label='父级标识' align='center' prop='parentId' />-->
<el-table-column label='物料ID' align='center' prop='materialId' />
<el-table-column label='物料名称' align='center' prop='materialName' />
<el-table-column label='bom说明' align='center' prop='materialBomDesc' />
<el-table-column label='bom版本' align='center' prop='materialBomVersion' />
<!-- <el-table-column label='祖级列表' align='center' prop='ancestors' />-->
<el-table-column label='标准数量' align='center' prop='standardAmount' />
<el-table-column label='顶级标识' align='center' prop='topFlag'>
<template #default='scope'>
<dict-tag :options='active_flag' :value='scope.row.topFlag' />
</template>
</el-table-column>
<el-table-column label='校验类型' align='center' prop='checkType'>
<template #default='scope'>
<dict-tag :options='mes_check_type' :value='scope.row.checkType' />
</template>
</el-table-column>
<!-- <el-table-column label='项目ID' align='center' prop='projectId' />-->
<!-- <el-table-column label='装配时长(秒)' align='center' prop='assembleTime' />-->
<el-table-column label='物料分类' align='center' prop='materialClassfication'>
<template #default='scope'>
<dict-tag :options='material_classfication' :value='scope.row.materialClassfication' />
</template>
</el-table-column>
<!-- <el-table-column label='附件信息' align='center' prop='attachId' />-->
<el-table-column label='激活标识' align='center' prop='activeFlag'>
<template #default='scope'>
<dict-tag :options='active_flag' :value='scope.row.activeFlag' />
</template>
</el-table-column>
<el-table-column label='备注' align='center' prop='remark' />
<!-- <el-table-column label='创建部门' align='center' prop='createDept' />-->
<!-- <el-table-column label='创建人' align='center' prop='createBy' />-->
<!-- <el-table-column label='创建时间' align='center' prop='createTime' width='180'>-->
<!-- <template #default='scope'>-->
<!-- <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label='更新人' align='center' prop='updateBy' />-->
<!-- <el-table-column label='更新时间' align='center' prop='updateTime' width='180'>-->
<!-- <template #default='scope'>-->
<!-- <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label='操作' align='center' class-name='small-padding fixed-width'>
<template #default='scope'>
<el-tooltip content='修改' placement='top'>
<el-button link type='primary' icon='Edit' @click='handleUpdate(scope.row)'
v-hasPermi="['mes:materialBom:edit']" />
</el-tooltip>
<el-tooltip content='新增' placement='top'>
<el-button link type='primary' icon='Plus' @click='handleAdd(scope.row)'
v-hasPermi="['mes:materialBom:add']" />
</el-tooltip>
<el-tooltip content='删除' placement='top'>
<el-button link type='primary' icon='Delete' @click='handleDelete(scope.row)'
v-hasPermi="['mes:materialBom:remove']" />
</el-tooltip>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 添加或修改物料BOM信息对话框 -->
<el-dialog :title='dialog.title' v-model='dialog.visible' width='500px' append-to-body>
<el-form ref='materialBomFormRef' :model='form' :rules='rules' label-width='80px'>
<el-form-item label='父级标识' prop='parentId'>
<el-tree-select
v-model='form.parentId'
:data='materialBomOptions'
:props="{ value: 'materialBomId', label: 'materialName', children: 'children' }"
value-key='materialBomId'
placeholder='请选择父级标识'
check-strictly
/>
</el-form-item>
<el-form-item label='物料ID' prop='materialId'>
<el-input v-model='form.materialId' placeholder='请输入物料ID' />
</el-form-item>
<el-form-item label='物料名称' prop='materialName'>
<el-input v-model='form.materialName' placeholder='请输入物料名称' />
</el-form-item>
<el-form-item label='bom说明' prop='materialBomDesc'>
<el-input v-model='form.materialBomDesc' placeholder='请输入bom说明' />
</el-form-item>
<el-form-item label='bom版本' prop='materialBomVersion'>
<el-input v-model='form.materialBomVersion' placeholder='请输入bom版本' />
</el-form-item>
<!-- <el-form-item label='祖级列表' prop='ancestors'>-->
<!-- <el-input v-model='form.ancestors' placeholder='请输入祖级列表' />-->
<!-- </el-form-item>-->
<el-form-item label='标准数量' prop='standardAmount'>
<el-input-number v-model='form.standardAmount' placeholder='请输入标准数量' />
</el-form-item>
<!-- <el-form-item label='顶级标识' prop='topFlag'>-->
<!-- <el-input v-model='form.topFlag' placeholder='请输入顶级标识' />-->
<!-- </el-form-item>-->
<el-form-item label='校验类型' prop='checkType'>
<el-radio-group v-model='form.checkType'>
<el-radio
v-for='dict in mes_check_type'
:key='dict.value'
:value='dict.value'
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<!-- <el-form-item label='项目ID' prop='projectId'>-->
<!-- <el-input v-model='form.projectId' placeholder='请输入项目ID' />-->
<!-- </el-form-item>-->
<!-- <el-form-item label='装配时长(秒)' prop='assembleTime'>-->
<!-- <el-input v-model='form.assembleTime' placeholder='请输入装配时长(秒)' />-->
<!-- </el-form-item>-->
<!-- <el-form-item label='物料分类' prop='materialClassfication'>-->
<!-- <el-radio-group v-model='form.materialClassfication'>-->
<!-- <el-radio-->
<!-- v-for='dict in material_classfication'-->
<!-- :key='dict.value'-->
<!-- :value='dict.value'-->
<!-- >{{ dict.label }}-->
<!-- </el-radio>-->
<!-- </el-radio-group>-->
<!-- </el-form-item>-->
<!-- <el-form-item label='附件信息' prop='attachId'>-->
<!-- <el-input v-model='form.attachId' placeholder='请输入附件信息' />-->
<!-- </el-form-item>-->
<el-form-item label='激活标识' prop='activeFlag'>
<el-radio-group v-model='form.activeFlag'>
<el-radio
v-for='dict in active_flag'
:key='dict.value'
:value='dict.value'
>{{ dict.label }}
</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label='备注' prop='remark'>
<el-input v-model='form.remark' placeholder='请输入备注' />
</el-form-item>
</el-form>
<template #footer>
<div class='dialog-footer'>
<el-button :loading='buttonLoading' type='primary' @click='submitForm'> </el-button>
<el-button @click='cancel'> </el-button>
</div>
</template>
</el-dialog>
</div>
</template>
<script setup name='MaterialBom' lang='ts'>
import {
listMaterialBom,
getMaterialBom,
delMaterialBom,
addMaterialBom,
updateMaterialBom
} from '@/api/mes/materialBom';
import { MaterialBomVO, MaterialBomQuery, MaterialBomForm } from '@/api/mes/materialBom/types';
type MaterialBomOption = {
materialBomId: number;
materialName: string;
children?: MaterialBomOption[];
}
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
;
const { mes_check_type, material_classfication, active_flag } = toRefs<any>(proxy?.useDict('mes_check_type', 'material_classfication', 'active_flag'));
const materialBomList = ref([]);
const materialBomOptions = ref<MaterialBomOption[]>([]);
const buttonLoading = ref(false);
const showSearch = ref(true);
const isExpandAll = ref(true);
const loading = ref(false);
const queryFormRef = ref<ElFormInstance>();
const materialBomFormRef = ref<ElFormInstance>();
const materialBomTableRef = ref<ElTableInstance>();
const dialog = reactive<DialogOption>({
visible: false,
title: ''
});
const initFormData: MaterialBomForm = {
materialBomId: undefined,
parentId: undefined,
materialId: undefined,
materialName: undefined,
materialBomDesc: undefined,
materialBomVersion: undefined,
ancestors: undefined,
standardAmount: undefined,
topFlag: undefined,
checkType: '1',
projectId: undefined,
assembleTime: undefined,
materialClassfication: undefined,
attachId: undefined,
activeFlag: '1',
remark: undefined
};
const data = reactive<PageData<MaterialBomForm, MaterialBomQuery>>({
form: { ...initFormData },
queryParams: {
materialBomId: undefined,
parentId: undefined,
materialId: undefined,
materialName: undefined,
materialBomDesc: undefined,
materialBomVersion: undefined,
ancestors: undefined,
standardAmount: undefined,
topFlag: undefined,
checkType: undefined,
projectId: undefined,
assembleTime: undefined,
materialClassfication: undefined,
attachId: undefined,
activeFlag: undefined,
params: {}
},
rules: {
materialBomId: [
{ required: true, message: '主键标识不能为空', trigger: 'blur' }
],
parentId: [
{ required: true, message: '父级标识不能为空', trigger: 'blur' }
],
materialId: [
{ required: true, message: '物料ID不能为空', trigger: 'blur' }
]
}
});
const { queryParams, form, rules } = toRefs(data);
/** 查询物料BOM信息列表 */
const getList = async () => {
loading.value = true;
const res = await listMaterialBom(queryParams.value);
const data = proxy?.handleTree<MaterialBomVO>(res.data, 'materialBomId', 'parentId');
if (data) {
materialBomList.value = data;
loading.value = false;
}
};
/** 查询物料BOM信息下拉树结构 */
const getTreeselect = async () => {
const res = await listMaterialBom();
materialBomOptions.value = [];
const data: MaterialBomOption = { materialBomId: 0, materialName: '顶级节点', children: [] };
data.children = proxy?.handleTree<MaterialBomOption>(res.data, 'materialBomId', 'parentId');
materialBomOptions.value.push(data);
};
//
const cancel = () => {
reset();
dialog.visible = false;
};
//
const reset = () => {
form.value = { ...initFormData };
materialBomFormRef.value?.resetFields();
};
/** 搜索按钮操作 */
const handleQuery = () => {
getList();
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
};
/** 新增按钮操作 */
const handleAdd = (row?: MaterialBomVO) => {
reset();
getTreeselect();
if (row != null && row.materialBomId) {
form.value.parentId = row.materialBomId;
} else {
form.value.parentId = 0;
}
dialog.visible = true;
dialog.title = '添加物料BOM信息';
};
/** 展开/折叠操作 */
const handleToggleExpandAll = () => {
isExpandAll.value = !isExpandAll.value;
toggleExpandAll(materialBomList.value, isExpandAll.value);
};
/** 展开/折叠操作 */
const toggleExpandAll = (data: MaterialBomVO[], status: boolean) => {
data.forEach((item) => {
materialBomTableRef.value?.toggleRowExpansion(item, status);
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status);
});
};
/** 修改按钮操作 */
const handleUpdate = async (row: MaterialBomVO) => {
reset();
await getTreeselect();
if (row != null) {
form.value.parentId = row.parentId;
}
const res = await getMaterialBom(row.materialBomId);
Object.assign(form.value, res.data);
dialog.visible = true;
dialog.title = '修改物料BOM信息';
};
/** 提交按钮 */
const submitForm = () => {
materialBomFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
buttonLoading.value = true;
if (form.value.materialBomId) {
await updateMaterialBom(form.value).finally(() => buttonLoading.value = false);
} else {
await addMaterialBom(form.value).finally(() => buttonLoading.value = false);
}
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
getList();
}
});
};
/** 删除按钮操作 */
const handleDelete = async (row: MaterialBomVO) => {
await proxy?.$modal.confirm('是否确认删除物料BOM信息编号为"' + row.materialBomId + '"的数据项?');
loading.value = true;
await delMaterialBom(row.materialBomId).finally(() => loading.value = false);
await getList();
proxy?.$modal.msgSuccess('删除成功');
};
onMounted(() => {
getList();
});
</script>

@ -169,7 +169,7 @@ const initFormData: DictDataForm = {
dictLabel: '',
dictValue: '',
cssClass: '',
listClass: 'primary',
listClass: 'default',
dictSort: 0,
remark: ''
};

Loading…
Cancel
Save