commit
55bc7a390b
@ -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 => ({
|
||||
id: child.id,
|
||||
first_level_name: child.name // 修复:使用 child.name 而不是 child.third_level_name
|
||||
}));
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user