Compare commits
No commits in common. "88877fa6f71b2af512a56173e4e5b746f1b22fa4" and "e69209938d0d1ec4d06d3c2ab34b1da332c9101c" have entirely different histories.
88877fa6f7
...
e69209938d
@ -40,10 +40,7 @@ async def product_category_search(ns={}):
|
|||||||
async with db.sqlorContext('kboss') as sor:
|
async with db.sqlorContext('kboss') as sor:
|
||||||
# 首页不登录 通过域名筛选
|
# 首页不登录 通过域名筛选
|
||||||
if to_page == 'show':
|
if to_page == 'show':
|
||||||
if ns.get('first_level_id'):
|
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND del_flg = '0' ORDER BY priority;""" % domain_name
|
||||||
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND del_flg = '0' AND parentid = '%s' ORDER BY priority;""" % (domain_name, ns.get('first_level_id'))
|
|
||||||
else:
|
|
||||||
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND del_flg = '0' AND parentid is NULL ORDER BY priority;""" % domain_name
|
|
||||||
result = await sor.sqlExe(find_sql, {})
|
result = await sor.sqlExe(find_sql, {})
|
||||||
return {
|
return {
|
||||||
'status': True,
|
'status': True,
|
||||||
@ -67,7 +64,7 @@ async def product_category_search(ns={}):
|
|||||||
orgid = user_list[0]['orgid']
|
orgid = user_list[0]['orgid']
|
||||||
user_role = await get_user_role({'userid': userid, 'sor': sor})
|
user_role = await get_user_role({'userid': userid, 'sor': sor})
|
||||||
try:
|
try:
|
||||||
if user_role == '客户' or user_role == '管理员':
|
if user_role == '客户' or user_role == '管理员':
|
||||||
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND permission = '1' AND del_flg = '0' ORDER BY priority;""" % domain_name
|
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND permission = '1' AND del_flg = '0' ORDER BY priority;""" % domain_name
|
||||||
else:
|
else:
|
||||||
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND del_flg = '0' ORDER BY priority;""" % domain_name
|
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND del_flg = '0' ORDER BY priority;""" % domain_name
|
||||||
|
|||||||
@ -200,23 +200,4 @@ export function reqHomepageCategoryTreeDelete(data){
|
|||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
//供需一级分类
|
|
||||||
export function reqSupplyAndDemandFirstCategory(data){
|
|
||||||
return request({
|
|
||||||
url: '/product/product_category_search.dspy',
|
|
||||||
method: 'post',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//供需二级分类
|
|
||||||
export function reqSupplyAndDemandSecondCategory(data){
|
|
||||||
return request({
|
|
||||||
url: '/product/supply_and_demand_first_category.dspy',
|
|
||||||
method: 'post',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@
|
|||||||
<!-- 如果有四级菜单(product_list),直接显示所有四级菜单项 -->
|
<!-- 如果有四级菜单(product_list),直接显示所有四级菜单项 -->
|
||||||
<div v-if="third.product_list && third.product_list.length > 0"
|
<div v-if="third.product_list && third.product_list.length > 0"
|
||||||
class="product-grid">
|
class="product-grid">
|
||||||
<div @click="goSearch(product)" v-for="(product, index) in third.product_list"
|
<div @click="openTalk" v-for="(product, index) in third.product_list"
|
||||||
:key="product.id"
|
:key="product.id"
|
||||||
class="product-tag">
|
class="product-tag">
|
||||||
{{ product.first_level_name }}
|
{{ product.first_level_name }}
|
||||||
@ -120,63 +120,12 @@ export default {
|
|||||||
hideTimer: null,
|
hideTimer: null,
|
||||||
categories: [],
|
categories: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
keyword: '',
|
|
||||||
publish_type: '',
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getCategories();
|
this.getCategories();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
performFormalSearch(keyword, type) {
|
|
||||||
console.log('=== 执行正式搜索开始 ===');
|
|
||||||
console.log('搜索参数:', { keyword, type });
|
|
||||||
console.log('当前路由:', this.$route.path);
|
|
||||||
console.log('事件总线实例:', eventBus);
|
|
||||||
|
|
||||||
reqSearch({
|
|
||||||
url_link: window.location.href,
|
|
||||||
keyword: keyword,
|
|
||||||
publish_type: type,
|
|
||||||
display_page: 'list', // 正式搜索使用 list
|
|
||||||
current_page: 1,
|
|
||||||
page_size: 8
|
|
||||||
}).then(res => {
|
|
||||||
console.log('正式搜索结果:', res);
|
|
||||||
|
|
||||||
// 准备发送事件数据
|
|
||||||
const eventData = {
|
|
||||||
type: type,
|
|
||||||
keyword: keyword,
|
|
||||||
data: res.data
|
|
||||||
};
|
|
||||||
console.log('准备发送事件数据:', eventData);
|
|
||||||
|
|
||||||
// 通过事件总线触发搜索事件,让兄弟组件处理结果
|
|
||||||
try {
|
|
||||||
eventBus.$emit('search', eventData);
|
|
||||||
console.log('事件总线事件发送成功');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('事件总线事件发送失败:', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('正式搜索完成,已触发搜索事件');
|
|
||||||
|
|
||||||
}).catch(error => {
|
|
||||||
console.error('正式搜索失败:', error);
|
|
||||||
this.$message.error('搜索失败,请重试');
|
|
||||||
});
|
|
||||||
},
|
|
||||||
goSearch(product) {
|
|
||||||
this.keyword = 'A800';
|
|
||||||
this.publish_type ='1';
|
|
||||||
this.$router.push({
|
|
||||||
path: '/ncmatch/search',
|
|
||||||
|
|
||||||
})
|
|
||||||
this.performFormalSearch(this.keyword, this.publish_type);
|
|
||||||
},
|
|
||||||
|
|
||||||
async openTalk() {
|
async openTalk() {
|
||||||
await this.hideProductList('quick')
|
await this.hideProductList('quick')
|
||||||
this.$store.commit('setShowTalk', true);
|
this.$store.commit('setShowTalk', true);
|
||||||
|
|||||||
@ -35,21 +35,21 @@
|
|||||||
<div class="category-section">
|
<div class="category-section">
|
||||||
<div class="category-title">所属类别</div>
|
<div class="category-title">所属类别</div>
|
||||||
<div class="category-tags">
|
<div class="category-tags">
|
||||||
<span v-for="category in firstCategories" :key="category.id"
|
<span v-for="category in typeList" :key="category.id"
|
||||||
:class="['category-tag', { active: activeFirstId === category.id }]"
|
:class="['category-tag', { active: selectedCategory === category.value }]"
|
||||||
@click="selectFirstCategory(category.id)">
|
@click="selectCategory(category.value)">
|
||||||
{{ category.product_category || category.label }}
|
{{ category.label }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="category-section" v-if="secondCategories.length > 0">
|
<div class="category-section">
|
||||||
<div class="category-title">所属品类</div>
|
<div class="category-title">所属品类</div>
|
||||||
<div class="category-tags">
|
<div class="category-tags">
|
||||||
<span v-for="category in secondCategories" :key="category.id"
|
<span v-for="category in typeList" :key="category.id"
|
||||||
:class="['category-tag', { active: activeSecondId === category.id }]"
|
:class="['category-tag', { active: selectedCategory === category.value }]"
|
||||||
@click="selectSecondCategory(category.id)">
|
@click="selectCategory(category.value)">
|
||||||
{{ category.product_category || category.label }}
|
{{ category.label }}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -87,7 +87,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { reqGetSupplyAndDemandSquareList, reqCompanyCategorySearch, reqSupplyAndDemandFirstCategory } from '@/api/ncmatch'
|
import { reqGetProductCategorySearch, reqGetSupplyAndDemandSquareList, reqCompanyCategorySearch } from '@/api/ncmatch'
|
||||||
import { mapGetters, mapState } from 'vuex'
|
import { mapGetters, mapState } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
name: 'supplyAndDemandSquare',
|
name: 'supplyAndDemandSquare',
|
||||||
@ -100,19 +100,12 @@ export default {
|
|||||||
current_page: 1,
|
current_page: 1,
|
||||||
typeList: [],
|
typeList: [],
|
||||||
publish_type: '1', // 默认选中商品
|
publish_type: '1', // 默认选中商品
|
||||||
selectedCategory: '', // 兼容旧逻辑,最终请求用这个字段
|
selectedCategory: '', // 默认选中项
|
||||||
selectedCompanies: [], // 默认选中项,改为数组支持多选
|
selectedCompanies: [], // 默认选中项,改为数组支持多选
|
||||||
categories: [],
|
categories: [],
|
||||||
companies: [],
|
companies: [],
|
||||||
productList: [],
|
productList: [],
|
||||||
detailVisible: false,
|
detailVisible: false
|
||||||
oneLevelCategory:[],
|
|
||||||
twoLevelCategory:[],
|
|
||||||
// 新增:一二级分类数据与高亮状态(平级数组)
|
|
||||||
firstCategories: [],
|
|
||||||
secondCategories: [],
|
|
||||||
activeFirstId: null,
|
|
||||||
activeSecondId: null,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@ -143,28 +136,16 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getOneLevelCategory(){
|
|
||||||
// reqSupplyAndDemandFirstCategory({url_link:window.location.href}).then(res=>{
|
|
||||||
// if(res.status){
|
|
||||||
// this.oneLevelCategory=res.data
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
},
|
|
||||||
getTwoLevelCategory(){
|
|
||||||
// reqSupplyAndDemandSecondCategory({url_link:window.location.href}).then(res=>{
|
|
||||||
// if(res.status){
|
|
||||||
// this.twoLevelCategory=res.data
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
},
|
|
||||||
handleCurrentChange(val) {
|
handleCurrentChange(val) {
|
||||||
this.current_page = val
|
this.current_page = val
|
||||||
this.initData()
|
this.initData()
|
||||||
},
|
},
|
||||||
initAllData() {
|
initAllData() {
|
||||||
// 先获取一级分类,随后根据默认一级请求二级,再加载数据
|
// 先初始化产品类别,确保 selectedCategory 设置完成
|
||||||
this.init_product_category().then(() => {
|
this.init_product_category().then(() => {
|
||||||
|
// 然后初始化公司类别
|
||||||
this.init_company_category().then(() => {
|
this.init_company_category().then(() => {
|
||||||
|
// 最后调用 initData
|
||||||
this.initData()
|
this.initData()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@ -185,54 +166,26 @@ export default {
|
|||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 选中一级分类
|
selectCategory(categoryId) {
|
||||||
selectFirstCategory(id) {
|
if (categoryId === this.selectedCategory) return;
|
||||||
if (id === this.activeFirstId) return
|
this.selectedCategory = categoryId
|
||||||
this.activeFirstId = id
|
this.initData(this.selectedCategory)
|
||||||
// 切换一级时不自动高亮二级,置空
|
|
||||||
this.activeSecondId = null
|
|
||||||
this.selectedCategory = id
|
|
||||||
// 获取二级分类(平级数组)
|
|
||||||
this.loadSecondCategories(id)
|
|
||||||
this.initData()
|
|
||||||
},
|
},
|
||||||
// 选中二级分类
|
init_product_category(product_category) {
|
||||||
selectSecondCategory(id) {
|
return reqGetProductCategorySearch({ url_link: window.location.href, to_page: 'show' }).then(res => {
|
||||||
if (id === this.activeSecondId) return
|
|
||||||
this.activeSecondId = id
|
|
||||||
this.selectedCategory = id
|
|
||||||
this.initData()
|
|
||||||
},
|
|
||||||
init_product_category() {
|
|
||||||
// 获取一级分类(平级数组)
|
|
||||||
return reqSupplyAndDemandFirstCategory({to_page: 'show', url_link: window.location.href }).then(res => {
|
|
||||||
if (res.status) {
|
if (res.status) {
|
||||||
this.$message.success('获取一级分类成功')
|
let list = []
|
||||||
this.firstCategories = Array.isArray(res.data) ? res.data : []
|
for (let item of res.data) {
|
||||||
if (this.firstCategories.length > 0) {
|
if (item.parentid === null) {
|
||||||
this.activeFirstId = this.firstCategories[0].id
|
list.push({
|
||||||
this.selectedCategory = this.activeFirstId
|
label: item.product_category,
|
||||||
this.activeSecondId = null
|
value: item.id
|
||||||
// 立即拉取对应二级分类
|
})
|
||||||
return this.loadSecondCategories(this.activeFirstId)
|
}
|
||||||
} else {
|
|
||||||
this.activeFirstId = null
|
|
||||||
this.activeSecondId = null
|
|
||||||
this.selectedCategory = ''
|
|
||||||
this.secondCategories = []
|
|
||||||
}
|
}
|
||||||
}
|
this.selectedCategory = list[0].value
|
||||||
return res
|
this.typeList = list
|
||||||
})
|
|
||||||
},
|
|
||||||
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 {
|
|
||||||
this.secondCategories = []
|
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user