|
|
|
@ -20,15 +20,22 @@
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :lg="20" :xs="24" v-loading="loading">
|
|
|
|
|
<el-divider content-position="left">物料类型</el-divider>
|
|
|
|
|
<el-form ref="parentStructureBomFormRef" label-width="120px">
|
|
|
|
|
<el-divider content-position="left">父物料类型</el-divider>
|
|
|
|
|
<el-form ref="parentStructureBomFormRef" label-width="120px" :model="parentForm">
|
|
|
|
|
<el-row>
|
|
|
|
|
<el-form-item label="父级物料类型">
|
|
|
|
|
{{ parentParentMaterialTypeName }}
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="物料类型">
|
|
|
|
|
{{ parentMaterialTypeName }}
|
|
|
|
|
<el-form-item label='父物料类型' prop='parentId' :model="parentForm">
|
|
|
|
|
<el-select v-model="parentForm.parentId" placeholder="请选择" style="width:260px"
|
|
|
|
|
:disabled="parentMaterialTypeDisabled" >
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in materialTypeOptions"
|
|
|
|
|
:key="item.matrialTypeId"
|
|
|
|
|
:label="item.matrialTypeName"
|
|
|
|
|
:value="item.matrialTypeId"
|
|
|
|
|
:disabled="item.activeFlag == '0' || item.matrialTypeId === form.parentId"
|
|
|
|
|
></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -36,27 +43,27 @@
|
|
|
|
|
|
|
|
|
|
<el-divider content-position="left">子级物料类型</el-divider>
|
|
|
|
|
|
|
|
|
|
<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="materialTypeCode" label-width="120px">
|
|
|
|
|
<el-input v-model="queryParams.materialTypeCode" placeholder="请输入物料类型编号" clearable
|
|
|
|
|
@keyup.enter="handleQuery"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="物料类型名称" prop="materialTypeName" label-width="120px">
|
|
|
|
|
<el-input v-model="queryParams.materialTypeName" 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>
|
|
|
|
|
<!-- <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="materialTypeCode" label-width="120px">-->
|
|
|
|
|
<!-- <el-input v-model="queryParams.materialTypeCode" placeholder="请输入物料类型编号" clearable-->
|
|
|
|
|
<!-- @keyup.enter="handleQuery"/>-->
|
|
|
|
|
<!-- </el-form-item>-->
|
|
|
|
|
<!-- <el-form-item label="物料类型名称" prop="materialTypeName" label-width="120px">-->
|
|
|
|
|
<!-- <el-input v-model="queryParams.materialTypeName" 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="hover">
|
|
|
|
|
<template #header>
|
|
|
|
@ -66,20 +73,20 @@
|
|
|
|
|
@click="handleAdd()">新增
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
<el-button v-has-permi="['mes:baseStructureBom:edit']" type="success" plain :disabled="single"
|
|
|
|
|
icon="Edit" @click="handleUpdate()">
|
|
|
|
|
修改
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<!-- <el-col :span="1.5">-->
|
|
|
|
|
<!-- <el-button v-has-permi="['mes:baseStructureBom:edit']" type="success" plain :disabled="single"-->
|
|
|
|
|
<!-- icon="Edit" @click="handleUpdate()">-->
|
|
|
|
|
<!-- 修改-->
|
|
|
|
|
<!-- </el-button>-->
|
|
|
|
|
<!-- </el-col>-->
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
<el-button v-has-permi="['mes:baseStructureBom:remove']" type="danger" plain :disabled="multiple"
|
|
|
|
|
icon="Delete" @click="handleDelete()">
|
|
|
|
|
删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true"
|
|
|
|
|
@query-table="getList"></right-toolbar>
|
|
|
|
|
<!-- <right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true"-->
|
|
|
|
|
<!-- @query-table="getList"></right-toolbar>-->
|
|
|
|
|
</el-row>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
@ -104,12 +111,12 @@
|
|
|
|
|
|
|
|
|
|
<el-table-column label="操作" fixed="right" width="180" class-name="small-padding fixed-width">
|
|
|
|
|
<template #default="scope">
|
|
|
|
|
<el-tooltip content="修改" placement="top">
|
|
|
|
|
<el-button v-hasPermi="['mes:baseStructureBom:edit']" link type="primary" icon="Edit"
|
|
|
|
|
@click="handleUpdate(scope.row)"></el-button>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
<!-- <el-tooltip content="修改" placement="top">-->
|
|
|
|
|
<!-- <el-button v-hasPermi="['mes:baseStructureBom:edit']" link type="primary" icon="Edit"-->
|
|
|
|
|
<!-- @click="handleUpdate(scope.row)"></el-button>-->
|
|
|
|
|
<!-- </el-tooltip>-->
|
|
|
|
|
<el-tooltip content="删除" placement="top">
|
|
|
|
|
<el-button v-hasPermi="['mes:baseStructureBom:remove']" link type="primary" icon="Delete"
|
|
|
|
|
<el-button v-hasPermi="['mes:baseStructureBom:remove']" link type="danger" icon="Delete"
|
|
|
|
|
@click="handleDelete(scope.row)"></el-button>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</template>
|
|
|
|
@ -168,10 +175,16 @@ import {
|
|
|
|
|
addBaseStructureBom,
|
|
|
|
|
updateBaseStructureBom, getMaterialTypeList
|
|
|
|
|
} from "@/api/mes/baseStructureBom";
|
|
|
|
|
import {BaseStructureBomVO, BaseStructureBomTreeVO,BaseStructureBomQuery, BaseStructureBomForm} from '@/api/mes/baseStructureBom/types';
|
|
|
|
|
import {
|
|
|
|
|
BaseStructureBomVO,
|
|
|
|
|
BaseStructureBomTreeVO,
|
|
|
|
|
BaseStructureBomQuery,
|
|
|
|
|
BaseStructureBomForm
|
|
|
|
|
} from '@/api/mes/baseStructureBom/types';
|
|
|
|
|
import {BaseMaterialTypeVO} from '@/api/mes/baseMaterialType/types';
|
|
|
|
|
import {to} from 'await-to-js';
|
|
|
|
|
import {nextTick} from "vue";
|
|
|
|
|
import {MaterialBomVO} from "@/api/mes/materialBom/types";
|
|
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
const {proxy} = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
@ -191,6 +204,9 @@ const structureBomOptions = ref<BaseStructureBomTreeVO[]>([]);
|
|
|
|
|
const materialTypeOptions = ref<BaseMaterialTypeVO[]>([]);
|
|
|
|
|
const parentMaterialTypeName = ref('');
|
|
|
|
|
const parentParentMaterialTypeName = ref('');
|
|
|
|
|
const focusKeyNode = ref<BaseStructureBomVO>;
|
|
|
|
|
const parentMaterialTypeDisabled = ref(true);
|
|
|
|
|
|
|
|
|
|
// 列显隐信息
|
|
|
|
|
const columns = ref<FieldOption[]>([
|
|
|
|
|
{key: 0, label: `BOM结构编号`, visible: true, children: []},
|
|
|
|
@ -200,6 +216,8 @@ const columns = ref<FieldOption[]>([
|
|
|
|
|
{key: 4, label: `更新时间`, visible: true, children: []}
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const parentStructureBomFormRef = ref<ElTreeInstance>();
|
|
|
|
|
const structureBomTreeRef = ref<ElTreeInstance>();
|
|
|
|
|
const queryFormRef = ref<ElFormInstance>();
|
|
|
|
|
const structureBomFormRef = ref<ElFormInstance>();
|
|
|
|
@ -224,8 +242,24 @@ const initFormData: BaseStructureBomForm = {
|
|
|
|
|
remark: undefined,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const initParentFormData: BaseStructureBomForm = {
|
|
|
|
|
structureBomId: undefined,
|
|
|
|
|
parentId: undefined,
|
|
|
|
|
materialTypeId: undefined,
|
|
|
|
|
materialTypeName: undefined,
|
|
|
|
|
structureBomDesc: undefined,
|
|
|
|
|
structureBomVersion: undefined,
|
|
|
|
|
ancestors: undefined,
|
|
|
|
|
level: undefined,
|
|
|
|
|
topFlag: undefined,
|
|
|
|
|
activeFlag: '1',
|
|
|
|
|
remark: undefined,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const data = reactive<PageData<BaseStructureBomForm, BaseStructureBomQuery>>({
|
|
|
|
|
form: {...initFormData},
|
|
|
|
|
parentForm: {...initParentFormData},
|
|
|
|
|
queryParams: {
|
|
|
|
|
structureBomId: undefined,
|
|
|
|
|
parentId: undefined,
|
|
|
|
@ -247,7 +281,7 @@ const data = reactive<PageData<BaseStructureBomForm, BaseStructureBomQuery>>({
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const {queryParams, form, rules} = toRefs(data);
|
|
|
|
|
const {queryParams, form, rules, parentForm} = toRefs(data);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 通过条件过滤节点 */
|
|
|
|
@ -269,32 +303,47 @@ watchEffect(
|
|
|
|
|
const getTreeSelect = async () => {
|
|
|
|
|
treeLoading.value = true;
|
|
|
|
|
loading.value = true;
|
|
|
|
|
|
|
|
|
|
const res = await structureBomTreeSelect();
|
|
|
|
|
// structureBomOptions.value = res.data;
|
|
|
|
|
structureBomOptions.value = [];
|
|
|
|
|
const virtualTopNodeId = -1;
|
|
|
|
|
const initialTree: BaseStructureBomTreeVO = {
|
|
|
|
|
id: 1,
|
|
|
|
|
id: virtualTopNodeId,
|
|
|
|
|
parentId: -1,
|
|
|
|
|
materialTypeId: 0,
|
|
|
|
|
label: "制造BOM结构",
|
|
|
|
|
children: res.data
|
|
|
|
|
};
|
|
|
|
|
structureBomOptions.value.push(initialTree);
|
|
|
|
|
console.log(structureBomOptions);
|
|
|
|
|
if (queryParams.value.parentId === null || queryParams.value.parentId === undefined) {
|
|
|
|
|
const topStructureBom = structureBomOptions.value.find(item => item.parentId === -1);
|
|
|
|
|
if (topStructureBom != null){
|
|
|
|
|
parentMaterialTypeName.value = topStructureBom.label;
|
|
|
|
|
// if (queryParams.value.parentId === null || queryParams.value.parentId === undefined) {
|
|
|
|
|
// const topStructureBom = structureBomOptions.value.find(item => item.parentId === -1);
|
|
|
|
|
// if (topStructureBom != null){
|
|
|
|
|
// parentMaterialTypeName.value = topStructureBom.label;
|
|
|
|
|
// }
|
|
|
|
|
// queryParams.value.parentId = 1;
|
|
|
|
|
// parentParentMaterialTypeName.value = "顶级";
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// alert(JSON.stringify(focusKeyNode.value))
|
|
|
|
|
if (!focusKeyNode.value) {//如果之前没有focus
|
|
|
|
|
focusKeyNode.value = {id: virtualTopNodeId};
|
|
|
|
|
} else {
|
|
|
|
|
const allIds = structureBomOptions.value.flatMap(item => getAllIds(item));
|
|
|
|
|
if (!allIds || allIds.length <= 0) {
|
|
|
|
|
focusKeyNode.value = {id: virtualTopNodeId};
|
|
|
|
|
}
|
|
|
|
|
queryParams.value.parentId = 1;
|
|
|
|
|
parentParentMaterialTypeName.value = "顶级";
|
|
|
|
|
// console.log(JSON.stringify(materialBomOptions.value))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextTick(function () {
|
|
|
|
|
structureBomTreeRef.value?.setCurrentKey(queryParams.value.parentId, true);
|
|
|
|
|
handleQuery();
|
|
|
|
|
structureBomTreeRef.value?.setCurrentKey(focusKeyNode.value.id, true);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
treeLoading.value = false;
|
|
|
|
|
loading.value = false;
|
|
|
|
|
handleNodeClick(focusKeyNode.value);
|
|
|
|
|
|
|
|
|
|
// const dd = {"id":"1","parentId":-1,"label":"dd"};
|
|
|
|
|
// alert(materialTypeOptions.value[0])
|
|
|
|
|
// materialTypeOptions.value[0].children.push(dd);
|
|
|
|
@ -313,19 +362,46 @@ const getList = async () => {
|
|
|
|
|
|
|
|
|
|
/** 节点单击事件 */
|
|
|
|
|
const handleNodeClick = (data: BaseStructureBomTreeVO) => {
|
|
|
|
|
structureBomList.value = [];
|
|
|
|
|
parentMaterialTypeDisabled.value = true;
|
|
|
|
|
resetParentForm();
|
|
|
|
|
resetQueryParams();
|
|
|
|
|
focusKeyNode.value = data;
|
|
|
|
|
// alert(JSON.stringify(focusKeyNode.value))
|
|
|
|
|
if (data.id && data.id != 0 && data.id != -1) {
|
|
|
|
|
parentForm.value.parentId = data.id;//是当前节点的materialTypeId
|
|
|
|
|
queryParams.value.parentId = data.id;
|
|
|
|
|
parentMaterialTypeName.value = data.label;
|
|
|
|
|
if (data.parentId === -1) {
|
|
|
|
|
parentParentMaterialTypeName.value = "顶级";
|
|
|
|
|
} else if (data.parentId === 1) {
|
|
|
|
|
parentParentMaterialTypeName.value = "制造BOM结构";
|
|
|
|
|
} else {
|
|
|
|
|
const findMaterialType = materialTypeOptions.value.find(item => item.matrialTypeId === data.parentId);
|
|
|
|
|
parentParentMaterialTypeName.value = findMaterialType.matrialTypeName;
|
|
|
|
|
handleQuery();
|
|
|
|
|
}
|
|
|
|
|
parentMaterialTypeDisabled.value = focusKeyNode.value.id != -1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (data.parentId === -1) {
|
|
|
|
|
// parentParentMaterialTypeName.value = "顶级";
|
|
|
|
|
// } else if (data.parentId === 1) {
|
|
|
|
|
// parentParentMaterialTypeName.value = "制造BOM结构";
|
|
|
|
|
// } else {
|
|
|
|
|
// const findMaterialType = materialTypeOptions.value.find(item => item.matrialTypeId === data.parentId);
|
|
|
|
|
// if(findMaterialType){
|
|
|
|
|
// parentParentMaterialTypeName.value = findMaterialType.matrialTypeName;
|
|
|
|
|
// }else{
|
|
|
|
|
// parentParentMaterialTypeName.value = undefined;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 重置父级表单
|
|
|
|
|
*/
|
|
|
|
|
const resetParentForm = () => {
|
|
|
|
|
parentStructureBomFormRef.value?.resetFields();
|
|
|
|
|
parentStructureBomFormRef.value?.clearValidate();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const resetQueryParams = () => {
|
|
|
|
|
queryParams.value.parentId = undefined;//materialtypeid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleQuery();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
|
const handleQuery = () => {
|
|
|
|
@ -348,12 +424,12 @@ const handleDelete = async (row?: BaseStructureBomVO) => {
|
|
|
|
|
const [err] = await to(proxy?.$modal.confirm('是否确认删除BOM结构编号为"' + structureBomIds + '"的数据项?') as any);
|
|
|
|
|
if (!err) {
|
|
|
|
|
await delBaseStructureBom(structureBomIds)
|
|
|
|
|
await getTreeSelect();
|
|
|
|
|
handleQuery();
|
|
|
|
|
proxy?.$modal.msgSuccess('删除成功');
|
|
|
|
|
await getTreeSelect();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 选择条数 */
|
|
|
|
|
const handleSelectionChange = (selection: BaseStructureBomVO[]) => {
|
|
|
|
|
ids.value = selection.map((item) => item.structureBomId);
|
|
|
|
@ -387,12 +463,19 @@ const cancel = () => {
|
|
|
|
|
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
|
const handleAdd = async () => {
|
|
|
|
|
if (!parentForm.value.parentId) {
|
|
|
|
|
proxy?.$modal.msgWarning('请先选择父物料类型');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
reset();
|
|
|
|
|
await initMaterialTypeData();
|
|
|
|
|
const findMaterialType = materialTypeOptions.value.find(item => item.matrialTypeId === parentForm.value.parentId);
|
|
|
|
|
parentMaterialTypeName.value = findMaterialType.matrialTypeName;
|
|
|
|
|
form.value.parentId = parentForm.value.parentId;
|
|
|
|
|
// alert(JSON.stringify(data))
|
|
|
|
|
dialog.visible = true;
|
|
|
|
|
dialog.title = '新增';
|
|
|
|
|
await initMaterialTypeData();
|
|
|
|
|
form.value.parentId = queryParams.value.parentId;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
|
@ -422,7 +505,6 @@ const submitForm = () => {
|
|
|
|
|
form.value.structureBomId ? await updateBaseStructureBom(form.value) : await addBaseStructureBom(form.value);
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
|
await getTreeSelect();
|
|
|
|
|
handleQuery();
|
|
|
|
|
dialog.visible = false;
|
|
|
|
|
submitLoading.value = false;
|
|
|
|
|
} catch {
|
|
|
|
@ -459,6 +541,26 @@ onMounted(() => {
|
|
|
|
|
initMaterialTypeData();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const getAllIds = (obj) => {
|
|
|
|
|
let ids = [];
|
|
|
|
|
|
|
|
|
|
// 如果当前对象有 id,并且与之前focus的id相同,则收集
|
|
|
|
|
// console.log(JSON.stringify(obj))
|
|
|
|
|
if (obj.id !== undefined && obj.id === focusKeyNode.value.id) {
|
|
|
|
|
ids.push(obj.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果有 children,递归遍历
|
|
|
|
|
if (obj.children && Array.isArray(obj.children)) {
|
|
|
|
|
obj.children.forEach(child => {
|
|
|
|
|
ids = ids.concat(getAllIds(child)); // 递归获取子级 id
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// async function handleDeptChange(value: number | string) {
|
|
|
|
|
// const response = await optionselect(value);
|
|
|
|
|
// materialTypeOptions.value = response.data;
|
|
|
|
|