bugfix #19

Merged
charles merged 1 commits from main into prod 2025-08-20 16:22:19 +08:00
3 changed files with 46 additions and 11 deletions

View File

@ -23,9 +23,17 @@ export function buildDynamicStructure(data, parentId = null, currentLevel = 1) {
resultNode.second_level_name = node.name;
} else if (currentLevel === 3) {
resultNode.third_level_name = node.name;
// 使用后端自带的 source 字段(若存在)
if (node.source !== undefined) {
resultNode.source = node.source;
}
} else if (currentLevel === 4) {
// 第四级节点也需要保存name字段
resultNode.name = node.name;
// 使用后端自带的 source 字段(若存在)
if (node.source !== undefined) {
resultNode.source = node.source;
}
}
// 3. 递归处理子节点
@ -41,10 +49,17 @@ export function buildDynamicStructure(data, parentId = null, currentLevel = 1) {
// 第四级特殊处理为product_list
resultNode.product_list = children.map(child => ({
resultNode.product_list = children.map(child => {
const obj = {
id: child.id,
first_level_name: child.name // 修复:使用 child.name 而不是 child.third_level_name
}));
}
// 仅在后端提供时透传 source
if (child.source !== undefined) {
obj.source = child.source
}
return obj
});
}
}

View File

@ -105,9 +105,10 @@
</aside>
</template>
<script>
import { reqNcMatchMenu } from '@/api/ncmatch';
import { reqNcMatchMenu, reqSearch } from '@/api/ncmatch';
import { buildDynamicStructure } from './buildNcmatchTree';
import Talk from '@/views/homePage/dialog/talk/index.vue';
import eventBus from '@/utils/eventBus'
export default {
name: 'menuAside',
components: {
@ -168,13 +169,34 @@ export default {
});
},
goSearch(product) {
this.keyword = 'A800';
this.publish_type ='1';
this.$router.push({
path: '/ncmatch/search',
console.log("product",product);
if(product.source=='search'){
// search /ncmatchHome/search
const keywordFromItem = product && (product.first_level_name || product.product_name || product.second_level_name)
this.keyword = keywordFromItem || this.keyword || ''
this.publish_type = this.publish_type || '1'
this.$router.push({
path: '/ncmatchHome/search',
query: {
keyword: this.keyword,
publish_type: this.publish_type,
display_page: 'list',
current_page: 1,
page_size: 8
}
}).catch(err => {
if (err && err.name !== 'NavigationDuplicated') {
// ignore duplicate
// console.error(err)
}
})
this.performFormalSearch(this.keyword, this.publish_type);
}else{
this.openTalk()
}
},
async openTalk() {

View File

@ -207,7 +207,6 @@ export default {
//
return reqSupplyAndDemandFirstCategory({to_page: 'show', url_link: window.location.href }).then(res => {
if (res.status) {
this.$message.success('获取一级分类成功')
this.firstCategories = Array.isArray(res.data) ? res.data : []
if (this.firstCategories.length > 0) {
this.activeFirstId = this.firstCategories[0].id
@ -228,7 +227,6 @@ export default {
loadSecondCategories(firstId) {
// first_level_id /
return reqSupplyAndDemandFirstCategory({ to_page: 'show',url_link: window.location.href, first_level_id: firstId }).then(res => {
this.$message.success('获取二级级分类成功')
if (res.status) {
this.secondCategories = Array.isArray(res.data) ? res.data : []
} else {