Compare commits
No commits in common. "55bc7a390bd74b03b22add203f102f8a0b5251c2" and "88877fa6f71b2af512a56173e4e5b746f1b22fa4" have entirely different histories.
55bc7a390b
...
88877fa6f7
@ -23,17 +23,9 @@ export function buildDynamicStructure(data, parentId = null, currentLevel = 1) {
|
|||||||
resultNode.second_level_name = node.name;
|
resultNode.second_level_name = node.name;
|
||||||
} else if (currentLevel === 3) {
|
} else if (currentLevel === 3) {
|
||||||
resultNode.third_level_name = node.name;
|
resultNode.third_level_name = node.name;
|
||||||
// 使用后端自带的 source 字段(若存在)
|
|
||||||
if (node.source !== undefined) {
|
|
||||||
resultNode.source = node.source;
|
|
||||||
}
|
|
||||||
} else if (currentLevel === 4) {
|
} else if (currentLevel === 4) {
|
||||||
// 第四级节点也需要保存name字段
|
// 第四级节点也需要保存name字段
|
||||||
resultNode.name = node.name;
|
resultNode.name = node.name;
|
||||||
// 使用后端自带的 source 字段(若存在)
|
|
||||||
if (node.source !== undefined) {
|
|
||||||
resultNode.source = node.source;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 递归处理子节点
|
// 3. 递归处理子节点
|
||||||
@ -49,17 +41,10 @@ export function buildDynamicStructure(data, parentId = null, currentLevel = 1) {
|
|||||||
|
|
||||||
// 第四级特殊处理为product_list
|
// 第四级特殊处理为product_list
|
||||||
|
|
||||||
resultNode.product_list = children.map(child => {
|
resultNode.product_list = children.map(child => ({
|
||||||
const obj = {
|
id: child.id,
|
||||||
id: child.id,
|
first_level_name: child.name // 修复:使用 child.name 而不是 child.third_level_name
|
||||||
first_level_name: child.name // 修复:使用 child.name 而不是 child.third_level_name
|
}));
|
||||||
}
|
|
||||||
// 仅在后端提供时透传 source
|
|
||||||
if (child.source !== undefined) {
|
|
||||||
obj.source = child.source
|
|
||||||
}
|
|
||||||
return obj
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -105,10 +105,9 @@
|
|||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { reqNcMatchMenu, reqSearch } from '@/api/ncmatch';
|
import { reqNcMatchMenu } from '@/api/ncmatch';
|
||||||
import { buildDynamicStructure } from './buildNcmatchTree';
|
import { buildDynamicStructure } from './buildNcmatchTree';
|
||||||
import Talk from '@/views/homePage/dialog/talk/index.vue';
|
import Talk from '@/views/homePage/dialog/talk/index.vue';
|
||||||
import eventBus from '@/utils/eventBus'
|
|
||||||
export default {
|
export default {
|
||||||
name: 'menuAside',
|
name: 'menuAside',
|
||||||
components: {
|
components: {
|
||||||
@ -169,34 +168,13 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
goSearch(product) {
|
goSearch(product) {
|
||||||
console.log("product",product);
|
this.keyword = 'A800';
|
||||||
if(product.source=='search'){
|
this.publish_type ='1';
|
||||||
|
|
||||||
// 统一与 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({
|
this.$router.push({
|
||||||
path: '/ncmatchHome/search',
|
path: '/ncmatch/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);
|
this.performFormalSearch(this.keyword, this.publish_type);
|
||||||
}else{
|
|
||||||
this.openTalk()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
async openTalk() {
|
async openTalk() {
|
||||||
|
|||||||
@ -207,6 +207,7 @@ export default {
|
|||||||
// 获取一级分类(平级数组)
|
// 获取一级分类(平级数组)
|
||||||
return reqSupplyAndDemandFirstCategory({to_page: 'show', url_link: window.location.href }).then(res => {
|
return reqSupplyAndDemandFirstCategory({to_page: 'show', url_link: window.location.href }).then(res => {
|
||||||
if (res.status) {
|
if (res.status) {
|
||||||
|
this.$message.success('获取一级分类成功')
|
||||||
this.firstCategories = Array.isArray(res.data) ? res.data : []
|
this.firstCategories = Array.isArray(res.data) ? res.data : []
|
||||||
if (this.firstCategories.length > 0) {
|
if (this.firstCategories.length > 0) {
|
||||||
this.activeFirstId = this.firstCategories[0].id
|
this.activeFirstId = this.firstCategories[0].id
|
||||||
@ -227,6 +228,7 @@ export default {
|
|||||||
loadSecondCategories(firstId) {
|
loadSecondCategories(firstId) {
|
||||||
// 同一个接口,通过是否传 first_level_id 区分一级/二级
|
// 同一个接口,通过是否传 first_level_id 区分一级/二级
|
||||||
return reqSupplyAndDemandFirstCategory({ to_page: 'show',url_link: window.location.href, first_level_id: firstId }).then(res => {
|
return reqSupplyAndDemandFirstCategory({ to_page: 'show',url_link: window.location.href, first_level_id: firstId }).then(res => {
|
||||||
|
this.$message.success('获取二级级分类成功')
|
||||||
if (res.status) {
|
if (res.status) {
|
||||||
this.secondCategories = Array.isArray(res.data) ? res.data : []
|
this.secondCategories = Array.isArray(res.data) ? res.data : []
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user