|
|
|
@ -16,35 +16,44 @@
|
|
|
|
|
highlight-current
|
|
|
|
|
default-expand-all
|
|
|
|
|
@node-click="handleNodeClick"
|
|
|
|
|
/>
|
|
|
|
|
>
|
|
|
|
|
<template #default="{ node, data }">
|
|
|
|
|
<el-tooltip :content="`${data.label}`">
|
|
|
|
|
<div class="custom-tree-node">
|
|
|
|
|
<span>{{ node.label }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
</template>
|
|
|
|
|
</el-tree>
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-col>
|
|
|
|
|
|
|
|
|
|
<el-col :lg="18" :xs="24" v-loading="loading">
|
|
|
|
|
<div>
|
|
|
|
|
<el-divider content-position="left">父级物料</el-divider>
|
|
|
|
|
<el-form ref="parentMaterialBomFormRef" label-width="120px" :model="parentForm">
|
|
|
|
|
<el-form ref="parentMaterialBomFormRef" label-width="120px" :model="parentForm" :rules="parentRules">
|
|
|
|
|
<el-row>
|
|
|
|
|
<el-form-item label='父物料ID' prop='parentId'>
|
|
|
|
|
<el-form-item label='父物料ID' prop='parentId' v-if="false">
|
|
|
|
|
<el-input v-model='parentForm.parentId' placeholder='' style="width:360px"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label='父物料类型ID' prop='parentMaterialTypeId'>
|
|
|
|
|
<el-form-item label='父物料类型ID' prop='parentMaterialTypeId' v-if="false">
|
|
|
|
|
<el-input v-model='parentForm.parentMaterialTypeId' placeholder='' style="width:360px"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label='父物料名称' prop='parentMaterialName'>
|
|
|
|
|
<el-input v-model='parentForm.parentMaterialName' placeholder='请点击检索物料'
|
|
|
|
|
@click='handleMaterialSelect(parentForm,SELECT_MATERIAL_MODEL.PARENT_SELECT)'
|
|
|
|
|
style="width:360px" @change="getList" suffix-icon="Search"/>
|
|
|
|
|
style="width:260px" @change="getList" suffix-icon="Search" readonly
|
|
|
|
|
:disabled="parentMaterialDisabled"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="父物料类型名称" prop='parentMaterialTypeName'>
|
|
|
|
|
<el-input v-model='parentForm.parentMaterialTypeName' placeholder='' style="width:360px" dsiabeld/>
|
|
|
|
|
<el-input v-model='parentForm.parentMaterialTypeName' placeholder='' style="width:260px" readonly/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label="BOM版本" prop='materialBomVersion' :model="parentForm">
|
|
|
|
|
<el-select v-model="parentForm.materialBomVersion"
|
|
|
|
|
placeholder="请选择" style="width:360px">
|
|
|
|
|
placeholder="请选择" style="width:200px">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in materialBomVersionOptions"
|
|
|
|
|
:key="item.materialBomVersion"
|
|
|
|
@ -55,13 +64,13 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label='父物料数量' prop='parentStandardAmount'>
|
|
|
|
|
<el-input-number v-model='parentForm.parentStandardAmount' :precision="2" :step="0.1"
|
|
|
|
|
<el-input-number v-model='parentForm.parentStandardAmount' :precision="2" :step="1"
|
|
|
|
|
placeholder='请输入父物料数量'
|
|
|
|
|
style="width:360px"/>
|
|
|
|
|
style="width:200px"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label='单位' prop='parentUnitId'>
|
|
|
|
|
<el-select v-model="parentForm.parentUnitId" placeholder="请选择" style="width:360px">
|
|
|
|
|
<el-select v-model="parentForm.parentUnitId" placeholder="请选择" style="width:200px">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in unitInfoOptions"
|
|
|
|
|
:key="item.unitId"
|
|
|
|
@ -110,15 +119,15 @@
|
|
|
|
|
prop="materialName" :show-overflow-tooltip="true">
|
|
|
|
|
<template #default='scope'>
|
|
|
|
|
<el-input v-model='scope.row.materialName' placeholder='请点击检索物料'
|
|
|
|
|
@click='handleMaterialSelect(scope.row,SELECT_MATERIAL_MODEL.CHILD_SELECT)' readonly/>
|
|
|
|
|
@click='handleMaterialSelect(scope.row,SELECT_MATERIAL_MODEL.CHILD_SELECT)'
|
|
|
|
|
suffix-icon="Search" readonly/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
<el-table-column v-if="columns[6].visible" key="standardAmount" label="子物料数量" align="center"
|
|
|
|
|
prop="standardAmount" :show-overflow-tooltip="true" width="200px">
|
|
|
|
|
prop="standardAmount" :show-overflow-tooltip="true" width="220px">
|
|
|
|
|
<template #default='scope'>
|
|
|
|
|
<el-input-number v-model='scope.row.standardAmount' :precision="2" :step="0.1"
|
|
|
|
|
placeholder='请输入数量'
|
|
|
|
|
style="width:180px"/>
|
|
|
|
|
<el-input-number v-model='scope.row.standardAmount' :precision="2" :step="1"
|
|
|
|
|
placeholder='请输入数量' style="width:180px"/>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
|
|
|
@ -191,12 +200,12 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label='子物料数量' prop='standardAmount'>
|
|
|
|
|
<el-input-number v-model='form.standardAmount' :precision="2" :step="0.1" placeholder='请输入子物料数量'
|
|
|
|
|
<el-input-number v-model='form.standardAmount' :precision="2" :step="1" placeholder='请输入子物料数量'
|
|
|
|
|
style="width:360px"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<el-form-item label='子物料单位' prop='unitId'>
|
|
|
|
|
<el-select v-model="form.unitId" placeholder="请选择单位">
|
|
|
|
|
<el-select v-model="form.unitId" placeholder="请选择单位" style="width:360px">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in unitInfoOptions"
|
|
|
|
|
:key="item.unitId"
|
|
|
|
@ -233,8 +242,8 @@
|
|
|
|
|
import {
|
|
|
|
|
materialBomTreeSelect,
|
|
|
|
|
listMaterialBomJoinStructure,
|
|
|
|
|
addBatchMaterialBom, updateMaterialBom, addMaterialBom, delMaterialBom,
|
|
|
|
|
getUnitInfoList, getMaterialBomVersionList, getParentMaterialBom
|
|
|
|
|
addBatchMaterialBom,
|
|
|
|
|
getUnitInfoList, getMaterialBomVersionList, getParentMaterialBom, deleteMaterialBoms
|
|
|
|
|
} from "@/api/mes/materialBom";
|
|
|
|
|
|
|
|
|
|
import {MaterialBomVO, MaterialBomForm, MaterialBomQuery} from '@/api/mes/materialBom/types';
|
|
|
|
@ -262,6 +271,7 @@ const submitLoading = ref(false);
|
|
|
|
|
const btnLoading = ref(false);
|
|
|
|
|
const showSearch = ref(true);
|
|
|
|
|
const selectedMaterialBoms = ref<MaterialBomVO[]>([]);
|
|
|
|
|
const toDeleteMaterialBoms = ref<MaterialBomVO[]>([]);
|
|
|
|
|
const single = ref(true);
|
|
|
|
|
const multiple = ref(true);
|
|
|
|
|
const total = ref(0);
|
|
|
|
@ -276,6 +286,8 @@ const unitInfoOptions = ref<BaseMeasurementUnitInfoVO[]>([]);
|
|
|
|
|
|
|
|
|
|
const focusKeyNode = ref<MaterialBomVO>;
|
|
|
|
|
|
|
|
|
|
const parentMaterialDisabled = ref(true);
|
|
|
|
|
|
|
|
|
|
const globalSelectMode = ref('');
|
|
|
|
|
const SELECT_MATERIAL_MODEL = ref({
|
|
|
|
|
PARENT_SELECT: '1',//父级物料选择
|
|
|
|
@ -309,7 +321,7 @@ const dialog = reactive<DialogOption>({
|
|
|
|
|
const initParentFormData: MaterialBomForm = {
|
|
|
|
|
materialBomId: undefined,
|
|
|
|
|
parentId: undefined,
|
|
|
|
|
parentStandardAmount: undefined,
|
|
|
|
|
parentStandardAmount: 1,
|
|
|
|
|
unitId: undefined,
|
|
|
|
|
parentUnitId: undefined,
|
|
|
|
|
materialId: undefined,
|
|
|
|
@ -381,7 +393,23 @@ const data = reactive<PageData<MaterialBomForm, MaterialBomQuery>>({
|
|
|
|
|
standardAmount: [
|
|
|
|
|
{required: true, message: "子物料数量不能为空", trigger: "blur"}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
parentRules: {
|
|
|
|
|
parentMaterialName: [
|
|
|
|
|
{required: true, message: "父物料名称不能为空", trigger: "blur"}
|
|
|
|
|
],
|
|
|
|
|
materialBomVersion: [
|
|
|
|
|
{required: true, message: "BOM版本不能为空", trigger: "blur"}
|
|
|
|
|
],
|
|
|
|
|
parentStandardAmount: [
|
|
|
|
|
{required: true, message: "父物料数量不能为空", trigger: "blur"}
|
|
|
|
|
],
|
|
|
|
|
parentUnitId: [
|
|
|
|
|
{required: true, message: "父物料单位不能为空", trigger: "blur"}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -395,7 +423,7 @@ const parentQueryParams = ref({
|
|
|
|
|
params: {}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const {queryParams, form, rules, parentForm} = toRefs(data);
|
|
|
|
|
const {queryParams, form, rules, parentForm, parentRules} = toRefs(data);
|
|
|
|
|
|
|
|
|
|
/** 通过条件过滤节点 */
|
|
|
|
|
const filterNode = (value: string, data: any) => {
|
|
|
|
@ -415,6 +443,7 @@ watchEffect(
|
|
|
|
|
/** 查询物料类型bom结构树下拉树结构 */
|
|
|
|
|
const getTreeSelect = async () => {
|
|
|
|
|
treeLoading.value = true;
|
|
|
|
|
loading.value = true;
|
|
|
|
|
const res = await materialBomTreeSelect();
|
|
|
|
|
materialBomOptions.value = [];
|
|
|
|
|
const virtualTopNodeId = -1;
|
|
|
|
@ -430,21 +459,38 @@ const getTreeSelect = async () => {
|
|
|
|
|
console.log(materialBomOptions);
|
|
|
|
|
|
|
|
|
|
// materialBomOptions.value = res.data;
|
|
|
|
|
|
|
|
|
|
if (!focusKeyNode.value) {//如果之前没有focus
|
|
|
|
|
focusKeyNode.value = {treeKey: virtualTopNodeId};
|
|
|
|
|
} else {
|
|
|
|
|
alert(23)
|
|
|
|
|
alert(focusKeyNode.value.treeKey)
|
|
|
|
|
console.log(JSON.stringify(materialBomOptions.value))
|
|
|
|
|
const clickNode = findObjectByTreeKey(materialBomOptions.value, focusKeyNode.value.treeKey)
|
|
|
|
|
if (!clickNode) {
|
|
|
|
|
focusKeyNode.value = undefined;
|
|
|
|
|
focusKeyNode.value = {treeKey: virtualTopNodeId};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (!allTreeKeys || allTreeKeys.length <= 0) {
|
|
|
|
|
// focusKeyNode.value = {
|
|
|
|
|
// treeKey: virtualTopNodeId,
|
|
|
|
|
// id: virtualTopNodeId
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// const focusKeyNodeIndex = JSON.stringify(materialBomOptions.value).indexOf(focusKeyNode.value.treeKey);
|
|
|
|
|
// if (focusKeyNodeIndex < 0) {
|
|
|
|
|
// focusKeyNode.value = {treeKey: virtualTopNodeId};
|
|
|
|
|
// }
|
|
|
|
|
// const focusKeyNodeIndex = materialBomOptions.value.findIndex((optionItem) => focusKeyNode.value.treeKey === optionItem.treeKey);//有嵌套children的,有可能找不到
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextTick(function () {
|
|
|
|
|
materialBomTreeRef.value?.setCurrentKey(focusKeyNode.value.treeKey, true);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
handleNodeClick(focusKeyNode.value);
|
|
|
|
|
loading.value = false;
|
|
|
|
|
treeLoading.value = false;
|
|
|
|
|
handleNodeClick(focusKeyNode.value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const dd = {"id":"1","parentId":-1,"label":"dd"};
|
|
|
|
|
// materialTypeOptions.value[0].children.push(dd);
|
|
|
|
|
};
|
|
|
|
@ -471,6 +517,7 @@ const resetQueryParams = () => {
|
|
|
|
|
/** 节点单击事件 */
|
|
|
|
|
const handleNodeClick = (data: MaterialBomVO) => {
|
|
|
|
|
materialBomList.value = [];
|
|
|
|
|
parentMaterialDisabled.value = true;
|
|
|
|
|
resetParentForm();
|
|
|
|
|
resetQueryParams();
|
|
|
|
|
resetParentQueryParams();
|
|
|
|
@ -489,6 +536,7 @@ const handleNodeClick = (data: MaterialBomVO) => {
|
|
|
|
|
queryParams.value.materialBomVersion = materialBomVersionOptions.value[0].materialBomVersion;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
parentMaterialDisabled.value = focusKeyNode.value.treeKey != -1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -520,20 +568,30 @@ const resetQuery = () => {
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
const handleDelete = async (row?: MaterialBomVO) => {
|
|
|
|
|
btnLoading.value = true;
|
|
|
|
|
const materialBomIds = [];
|
|
|
|
|
const toDeleteIndexes = [];
|
|
|
|
|
selectedMaterialBoms.value.forEach(item => {
|
|
|
|
|
if (item.materialBomId && item.materialBomId !== '') {
|
|
|
|
|
materialBomIds.push(item.materialBomId);
|
|
|
|
|
} else {
|
|
|
|
|
deleteReset(item);
|
|
|
|
|
}
|
|
|
|
|
// const index = materialBomList.value.findIndex((optionItem) => item.materialBomId === optionItem.materialBomId);
|
|
|
|
|
const index = materialBomList.value.indexOf(item);
|
|
|
|
|
toDeleteIndexes.push(parseInt(index + 1));
|
|
|
|
|
});
|
|
|
|
|
if (materialBomIds.length > 0) {
|
|
|
|
|
|
|
|
|
|
if (toDeleteIndexes.length > 0) {
|
|
|
|
|
try {
|
|
|
|
|
const [err] = await to(proxy?.$modal.confirm('是否确认删除生产BOM编号为"' + materialBomIds + '"的数据项?') as any);
|
|
|
|
|
const [err] = await to(proxy?.$modal.confirm('是否确认删除序号为"' + toDeleteIndexes + '"的数据项?') as any);
|
|
|
|
|
if (!err) {
|
|
|
|
|
await delMaterialBom(materialBomIds)
|
|
|
|
|
await getTreeSelect();
|
|
|
|
|
selectedMaterialBoms.value.forEach(item => {
|
|
|
|
|
if (item.materialBomId && item.materialBomId !== '') {
|
|
|
|
|
toDeleteMaterialBoms.value.push(item);
|
|
|
|
|
} else {
|
|
|
|
|
deleteReset(item);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// alert(JSON.stringify(toDeleteMaterialBoms.value))
|
|
|
|
|
if (toDeleteMaterialBoms.value.length > 0) {
|
|
|
|
|
await deleteMaterialBoms(toDeleteMaterialBoms.value)
|
|
|
|
|
await getTreeSelect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
proxy?.$modal.msgSuccess('删除成功');
|
|
|
|
|
}
|
|
|
|
|
} catch {
|
|
|
|
@ -548,6 +606,7 @@ const deleteReset = (item) => {
|
|
|
|
|
item.materialName = undefined;
|
|
|
|
|
item.materialBomVersion = undefined;
|
|
|
|
|
item.standardAmount = undefined;
|
|
|
|
|
item.unitId = undefined;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/** 选择条数 */
|
|
|
|
@ -706,55 +765,58 @@ const submitMaterialForm = () => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const submitBatchSaveMaterialBoms = async () => {
|
|
|
|
|
try {
|
|
|
|
|
btnLoading.value = true;
|
|
|
|
|
saveMaterialBomList.value = [];
|
|
|
|
|
for (let i = 0; i < materialBomList.value.length; i++) {
|
|
|
|
|
let item = materialBomList.value[i];
|
|
|
|
|
if (item.materialId) {
|
|
|
|
|
parentMaterialBomFormRef.value?.validate(async (valid: boolean) => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
try {
|
|
|
|
|
btnLoading.value = true;
|
|
|
|
|
saveMaterialBomList.value = [];
|
|
|
|
|
for (let i = 0; i < materialBomList.value.length; i++) {
|
|
|
|
|
let item = materialBomList.value[i];
|
|
|
|
|
if (item.materialId) {
|
|
|
|
|
|
|
|
|
|
if (!item.standardAmount) {
|
|
|
|
|
proxy?.$modal.msgWarning('序号为[' + i + 1 + '],请填写子物料数量');
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!item.unitId) {
|
|
|
|
|
proxy?.$modal.msgWarning('序号为[' + i + 1 + '],请选择单位');
|
|
|
|
|
if (!item.standardAmount) {
|
|
|
|
|
proxy?.$modal.msgWarning('序号为[' + (parseInt(i) + 1) + '],请填写子物料数量');
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!item.unitId) {
|
|
|
|
|
proxy?.$modal.msgWarning('序号为[' + (parseInt(i) + 1) + '],请选择单位');
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
item.parentId = parentForm.value.parentId;
|
|
|
|
|
item.parentUnitId = parentForm.value.parentUnitId;
|
|
|
|
|
item.materialBomVersion = parentForm.value.materialBomVersion;
|
|
|
|
|
item.parentStandardAmount = parentForm.value.parentStandardAmount;
|
|
|
|
|
item.parentMaterialTypeId = parentForm.value.parentMaterialTypeId;
|
|
|
|
|
saveMaterialBomList.value.push(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (saveMaterialBomList.value.length <= 0) {
|
|
|
|
|
proxy?.$modal.msgWarning('无可保存子级物料');
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await addBatchMaterialBom(saveMaterialBomList.value);
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
|
|
|
|
|
|
item.parentId = parentForm.value.parentId;
|
|
|
|
|
item.parentUnitId = parentForm.value.parentUnitId;
|
|
|
|
|
item.materialBomVersion = parentForm.value.materialBomVersion;
|
|
|
|
|
item.parentStandardAmount = parentForm.value.parentStandardAmount;
|
|
|
|
|
item.parentMaterialTypeId = parentForm.value.parentMaterialTypeId;
|
|
|
|
|
saveMaterialBomList.value.push(item);
|
|
|
|
|
focusKeyNode.value.treeKey = parentForm.value.parentId + "-" + parentForm.value.materialBomVersion;
|
|
|
|
|
focusKeyNode.value.materialBomVersion = parentForm.value.materialBomVersion;
|
|
|
|
|
focusKeyNode.value.parentUnitId = parentForm.value.parentUnitId;
|
|
|
|
|
focusKeyNode.value.parentStandardAmount = parentForm.value.parentStandardAmount;
|
|
|
|
|
|
|
|
|
|
resetParentQueryParams();
|
|
|
|
|
resetQueryParams();
|
|
|
|
|
resetParentForm();
|
|
|
|
|
await getTreeSelect();
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
proxy?.$modal.msgWarning(e);
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (saveMaterialBomList.value.length <= 0) {
|
|
|
|
|
proxy?.$modal.msgWarning('无可保存子级物料');
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
await addBatchMaterialBom(saveMaterialBomList.value);
|
|
|
|
|
proxy?.$modal.msgSuccess('操作成功');
|
|
|
|
|
|
|
|
|
|
focusKeyNode.value.treeKey = parentForm.value.parentId + "-" + parentForm.value.materialBomVersion;
|
|
|
|
|
focusKeyNode.value.materialBomVersion = parentForm.value.materialBomVersion;
|
|
|
|
|
focusKeyNode.value.parentUnitId = parentForm.value.parentUnitId;
|
|
|
|
|
focusKeyNode.value.parentStandardAmount = parentForm.value.parentStandardAmount;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await getTreeSelect();
|
|
|
|
|
resetParentQueryParams();
|
|
|
|
|
resetQueryParams();
|
|
|
|
|
resetParentForm();
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
proxy?.$modal.msgWarning(e);
|
|
|
|
|
btnLoading.value = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -790,6 +852,34 @@ const getParentMaterialBomInfo = async () => {
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const findObjectByTreeKey = (list, targetTreeKey) => {
|
|
|
|
|
for (const item of list) {
|
|
|
|
|
if (item.treeKey === targetTreeKey) return item;
|
|
|
|
|
if (item.children) {
|
|
|
|
|
const found = findObjectByTreeKey(item.children, targetTreeKey);
|
|
|
|
|
if (found) return found;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// const getClickNode = (obj) => {
|
|
|
|
|
// // 如果当前对象有 id,并且与之前focus的id相同,则收集
|
|
|
|
|
// // console.log(JSON.stringify(obj))
|
|
|
|
|
// if (obj.treeKey !== undefined && obj.treeKey === focusKeyNode.value.treeKey) {
|
|
|
|
|
// return obj;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// // 如果有 children,递归遍历
|
|
|
|
|
// if (obj.children && Array.isArray(obj.children)) {
|
|
|
|
|
// obj.children.forEach(child => {
|
|
|
|
|
// getClickNode(child); // 递归获取
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|
|
|
|
|