fix : 修复标签管理递归函数
Showing
3 changed files
with
34 additions
and
27 deletions
| ... | @@ -116,7 +116,7 @@ const tableInfo = ref({ | ... | @@ -116,7 +116,7 @@ const tableInfo = ref({ |
| 116 | btns: [ | 116 | btns: [ |
| 117 | { | 117 | { |
| 118 | label: "编辑", value: "edit", click: (scope) => { | 118 | label: "编辑", value: "edit", click: (scope) => { |
| 119 | // console.log(drawerRef.value.drawerFormRef[0].ruleFormRef); | 119 | console.log(scope.row); |
| 120 | currentEditingGuid.value = scope.row.guid; | 120 | currentEditingGuid.value = scope.row.guid; |
| 121 | selectParentEdit(scope.row.guid); | 121 | selectParentEdit(scope.row.guid); |
| 122 | currTableInfo.value = scope.row; | 122 | currTableInfo.value = scope.row; |
| ... | @@ -387,7 +387,7 @@ const findStandardName = (guid: string) => { | ... | @@ -387,7 +387,7 @@ const findStandardName = (guid: string) => { |
| 387 | const item: any = classifyGradListData.value.find((item: any) => item.guid == guid); | 387 | const item: any = classifyGradListData.value.find((item: any) => item.guid == guid); |
| 388 | return item ? item.name : ''; | 388 | return item ? item.name : ''; |
| 389 | } | 389 | } |
| 390 | 390 | const tableRef = ref(null); // 表格的 ref | |
| 391 | // 获取分类树形列表 | 391 | // 获取分类树形列表 |
| 392 | const treeListParams = ref({ | 392 | const treeListParams = ref({ |
| 393 | pageIndex: 1, | 393 | pageIndex: 1, |
| ... | @@ -404,6 +404,7 @@ const getTreeListData = async () => { | ... | @@ -404,6 +404,7 @@ const getTreeListData = async () => { |
| 404 | classEditFormItems.value[2].options = treeListData.value; | 404 | classEditFormItems.value[2].options = treeListData.value; |
| 405 | shapeTreeListData.value = treeListData.value; | 405 | shapeTreeListData.value = treeListData.value; |
| 406 | tableInfo.value.loading = false; | 406 | tableInfo.value.loading = false; |
| 407 | |||
| 407 | } else { | 408 | } else { |
| 408 | proxy.$ElMessage.error(res.msg); | 409 | proxy.$ElMessage.error(res.msg); |
| 409 | } | 410 | } |
| ... | @@ -816,6 +817,11 @@ onMounted(() => { | ... | @@ -816,6 +817,11 @@ onMounted(() => { |
| 816 | }) | 817 | }) |
| 817 | 818 | ||
| 818 | const isExpand = ref<boolean>(router.currentRoute.value.query.isExpand == 'true'); | 819 | const isExpand = ref<boolean>(router.currentRoute.value.query.isExpand == 'true'); |
| 820 | const isExpand1 = ref<boolean>(true); | ||
| 821 | const expand = (item) => { | ||
| 822 | console.log(item); | ||
| 823 | isExpand1.value = item | ||
| 824 | } | ||
| 819 | 825 | ||
| 820 | </script> | 826 | </script> |
| 821 | 827 | ||
| ... | @@ -827,13 +833,13 @@ const isExpand = ref<boolean>(router.currentRoute.value.query.isExpand == 'true' | ... | @@ -827,13 +833,13 @@ const isExpand = ref<boolean>(router.currentRoute.value.query.isExpand == 'true' |
| 827 | <Form ref="formRef" :itemList="classStandardFormItems" formId="main-model-edit" col="col3" /> | 833 | <Form ref="formRef" :itemList="classStandardFormItems" formId="main-model-edit" col="col3" /> |
| 828 | </ContentWrap> | 834 | </ContentWrap> |
| 829 | <ContentWrap id="id-classStandard" class="detail-content" title="分类规则" description="" | 835 | <ContentWrap id="id-classStandard" class="detail-content" title="分类规则" description="" |
| 830 | style="margin-top:16px; height: calc(100% - 161px)"> | 836 | style="margin-top:16px; height: calc(100% - 161px)" :expandSwicth="true" :isExpand="isExpand1" @expand="expand"> |
| 831 | <div class="tools_btns"> | 837 | <div class="tools_btns"> |
| 832 | <el-button v-show="dataShowMethod == 'table'" type="primary" @click="newCreateClass">添加规则</el-button> | 838 | <el-button v-show="dataShowMethod == 'table'" type="primary" @click="newCreateClass">添加规则</el-button> |
| 833 | <!-- <el-button v-show="dataShowMethod == 'table'" @click="importClass">导入分类</el-button> --> | 839 | <!-- <el-button v-show="dataShowMethod == 'table'" @click="importClass">导入分类</el-button> --> |
| 834 | <el-button class="show-change-btn" @click="changeShowMethod">{{ '图形展示' }}</el-button> | 840 | <el-button class="show-change-btn" @click="changeShowMethod">{{ '图形展示' }}</el-button> |
| 835 | </div> | 841 | </div> |
| 836 | <Table v-show="dataShowMethod == 'table'" :tableInfo="tableInfo" /> | 842 | <Table v-show="dataShowMethod == 'table'" :tableInfo="tableInfo" :ref="tableRef" /> |
| 837 | <div ref="shapeMain" class="shape-main" v-show="dataShowMethod != 'table'"></div> | 843 | <div ref="shapeMain" class="shape-main" v-show="dataShowMethod != 'table'"></div> |
| 838 | <div v-if="showNodeDetails" class="node-details-popup" | 844 | <div v-if="showNodeDetails" class="node-details-popup" |
| 839 | :style="{ top: popupPosition.top + 'px', left: popupPosition.left + 'px' }"> | 845 | :style="{ top: popupPosition.top + 'px', left: popupPosition.left + 'px' }"> | ... | ... |
| ... | @@ -140,7 +140,7 @@ const tableInfo = ref({ | ... | @@ -140,7 +140,7 @@ const tableInfo = ref({ |
| 140 | console.log(scope); | 140 | console.log(scope); |
| 141 | filterDataGradeEdit(scope.row.dataGrade); | 141 | filterDataGradeEdit(scope.row.dataGrade); |
| 142 | newCreateGradeStandardDialogInfo.value.visible = true; | 142 | newCreateGradeStandardDialogInfo.value.visible = true; |
| 143 | newCreateGradeStandardDialogInfo.value.title = '编辑标准'; | 143 | newCreateGradeStandardDialogInfo.value.title = '编辑规则'; |
| 144 | newCreateGradeFormItems.value.forEach(item => { | 144 | newCreateGradeFormItems.value.forEach(item => { |
| 145 | item.default = scope.row[item.field]; | 145 | item.default = scope.row[item.field]; |
| 146 | }) | 146 | }) |
| ... | @@ -268,7 +268,7 @@ const newCreateGradeFormRules = ref({ | ... | @@ -268,7 +268,7 @@ const newCreateGradeFormRules = ref({ |
| 268 | const newCreateGradeStandardDialogInfo = ref({ | 268 | const newCreateGradeStandardDialogInfo = ref({ |
| 269 | visible: false, | 269 | visible: false, |
| 270 | size: 860, | 270 | size: 860, |
| 271 | title: "新增标准", | 271 | title: "新增规则", |
| 272 | type: "", | 272 | type: "", |
| 273 | formInfo: { | 273 | formInfo: { |
| 274 | id: "grade-form", | 274 | id: "grade-form", |
| ... | @@ -282,7 +282,7 @@ const newCreateGradeStandardDialogInfo = ref({ | ... | @@ -282,7 +282,7 @@ const newCreateGradeStandardDialogInfo = ref({ |
| 282 | }, | 282 | }, |
| 283 | submit: async (btn, info) => { | 283 | submit: async (btn, info) => { |
| 284 | newCreateGradeStandardDialogInfo.value.submitBtnLoading = true; | 284 | newCreateGradeStandardDialogInfo.value.submitBtnLoading = true; |
| 285 | if (newCreateGradeStandardDialogInfo.value.title === '编辑标准') { | 285 | if (newCreateGradeStandardDialogInfo.value.title === '编辑规则') { |
| 286 | const params = { | 286 | const params = { |
| 287 | ...info, | 287 | ...info, |
| 288 | guid: editClassifyGradeGuid.value, | 288 | guid: editClassifyGradeGuid.value, |
| ... | @@ -293,7 +293,7 @@ const newCreateGradeStandardDialogInfo = ref({ | ... | @@ -293,7 +293,7 @@ const newCreateGradeStandardDialogInfo = ref({ |
| 293 | if (res.code == proxy.$passCode) { | 293 | if (res.code == proxy.$passCode) { |
| 294 | proxy.$ElMessage({ | 294 | proxy.$ElMessage({ |
| 295 | type: 'success', | 295 | type: 'success', |
| 296 | message: '编辑标准成功' | 296 | message: '编辑规则成功' |
| 297 | }) | 297 | }) |
| 298 | getGradeListData(); | 298 | getGradeListData(); |
| 299 | newCreateGradeStandardDialogInfo.value.submitBtnLoading = false; | 299 | newCreateGradeStandardDialogInfo.value.submitBtnLoading = false; |
| ... | @@ -311,7 +311,7 @@ const newCreateGradeStandardDialogInfo = ref({ | ... | @@ -311,7 +311,7 @@ const newCreateGradeStandardDialogInfo = ref({ |
| 311 | if (res.code == proxy.$passCode) { | 311 | if (res.code == proxy.$passCode) { |
| 312 | proxy.$ElMessage({ | 312 | proxy.$ElMessage({ |
| 313 | type: 'success', | 313 | type: 'success', |
| 314 | message: '新增标准成功' | 314 | message: '新增规则成功' |
| 315 | }) | 315 | }) |
| 316 | getGradeListData(); | 316 | getGradeListData(); |
| 317 | newCreateGradeStandardDialogInfo.value.submitBtnLoading = false; | 317 | newCreateGradeStandardDialogInfo.value.submitBtnLoading = false; |
| ... | @@ -326,7 +326,7 @@ const newCreateGradeStandardDialogInfo = ref({ | ... | @@ -326,7 +326,7 @@ const newCreateGradeStandardDialogInfo = ref({ |
| 326 | 326 | ||
| 327 | const newStandard = () => { | 327 | const newStandard = () => { |
| 328 | filterDataGrade(); | 328 | filterDataGrade(); |
| 329 | newCreateGradeStandardDialogInfo.value.title = '新增标准'; | 329 | newCreateGradeStandardDialogInfo.value.title = '新增规则'; |
| 330 | newCreateGradeStandardDialogInfo.value.visible = true; | 330 | newCreateGradeStandardDialogInfo.value.visible = true; |
| 331 | newCreateGradeFormItems.value.forEach(item => item.default = ''); | 331 | newCreateGradeFormItems.value.forEach(item => item.default = ''); |
| 332 | } | 332 | } |
| ... | @@ -396,7 +396,7 @@ const cancel = () => { | ... | @@ -396,7 +396,7 @@ const cancel = () => { |
| 396 | <ContentWrap id="id-grade-info" title="分级规则" class="detail-content" description="" style="margin-top: 8px;"> | 396 | <ContentWrap id="id-grade-info" title="分级规则" class="detail-content" description="" style="margin-top: 8px;"> |
| 397 | <div class="content" v-loading="fullscreenLoading"> | 397 | <div class="content" v-loading="fullscreenLoading"> |
| 398 | <div class="table-top-btns"> | 398 | <div class="table-top-btns"> |
| 399 | <el-button type="primary" @click="newStandard">新增标准</el-button> | 399 | <el-button type="primary" @click="newStandard">新增规则</el-button> |
| 400 | <el-button @click="batchRemobe">批量删除</el-button> | 400 | <el-button @click="batchRemobe">批量删除</el-button> |
| 401 | </div> | 401 | </div> |
| 402 | <Table ref="tableRef" :tableInfo="tableInfo" @tableSelectionChange="onTableSelectChange" /> | 402 | <Table ref="tableRef" :tableInfo="tableInfo" @tableSelectionChange="onTableSelectChange" /> | ... | ... |
| ... | @@ -148,32 +148,33 @@ const findTopParentNode = (node: any) => { | ... | @@ -148,32 +148,33 @@ const findTopParentNode = (node: any) => { |
| 148 | if (!node) return; | 148 | if (!node) return; |
| 149 | 149 | ||
| 150 | // 判断是否为最后一层 | 150 | // 判断是否为最后一层 |
| 151 | if (node.childNodes.length === 0) { | 151 | isLastLayer.value = node.childNodes.length === 0; |
| 152 | isLastLayer.value = true; | 152 | if (isLastLayer.value) { |
| 153 | atGradeinfo.value = node.data; | 153 | atGradeinfo.value = node.data; |
| 154 | } else { | ||
| 155 | isLastLayer.value = false; | ||
| 156 | } | 154 | } |
| 157 | 155 | ||
| 158 | // 如果当前节点的父节点符合条件 | 156 | // 递归向上查找符合条件的祖先节点 |
| 159 | if (node.parent && node.parent.data.type === 'C') { | 157 | const findCParent = (currentNode: any): any => { |
| 160 | findNodeDetails.value = node.parent.data; | 158 | if (!currentNode?.parent) return null; // 没有父节点,停止递归 |
| 161 | return; // 停止递归 | 159 | if (currentNode.parent.data?.type === 'C') { |
| 160 | return currentNode.parent; // 找到符合条件的节点 | ||
| 162 | } | 161 | } |
| 162 | return findCParent(currentNode.parent); // 继续向上查找 | ||
| 163 | }; | ||
| 163 | 164 | ||
| 164 | // 如果当前节点的祖父节点符合条件 | 165 | // 查找最接近的符合条件的祖先节点 |
| 165 | if (node.parent?.parent && node.parent.parent.data.type === 'C') { | 166 | const topParent = findCParent(node); |
| 166 | findNodeDetails.value = node.parent.parent.data; | ||
| 167 | return; // 停止递归 | ||
| 168 | } | ||
| 169 | 167 | ||
| 170 | // 如果未找到,继续递归向上查找 | 168 | // 更新结果 |
| 171 | if (node.parent) { | 169 | if (topParent) { |
| 172 | findTopParentNode(node.parent); | 170 | findNodeDetails.value = topParent.data; |
| 173 | } | 171 | } |
| 174 | }; | 172 | }; |
| 175 | 173 | ||
| 174 | |||
| 175 | |||
| 176 | const nodeClick = (data, node) => { | 176 | const nodeClick = (data, node) => { |
| 177 | |||
| 177 | findTopParentNode(node); | 178 | findTopParentNode(node); |
| 178 | newCreateGradeFormItems.value[1].options = transformDataForTree([findNodeDetails.value]) | 179 | newCreateGradeFormItems.value[1].options = transformDataForTree([findNodeDetails.value]) |
| 179 | 180 | ... | ... |
-
Please register or sign in to post a comment