Merge pull request 'main' (#18) from main into prod

Reviewed-on: #18
This commit is contained in:
charles 2025-08-20 16:09:11 +08:00
commit 88877fa6f7
4 changed files with 155 additions and 35 deletions

View File

@ -40,7 +40,10 @@ 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':
find_sql = """SELECT * FROM user_publish_product_category WHERE domain_name = '%s' AND del_flg = '0' ORDER BY priority;""" % domain_name if ns.get('first_level_id'):
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,
@ -64,7 +67,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

View File

@ -200,4 +200,23 @@ 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
})
} }

View File

@ -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="openTalk" v-for="(product, index) in third.product_list" <div @click="goSearch(product)" 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,12 +120,63 @@ 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);

View File

@ -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 typeList" :key="category.id" <span v-for="category in firstCategories" :key="category.id"
:class="['category-tag', { active: selectedCategory === category.value }]" :class="['category-tag', { active: activeFirstId === category.id }]"
@click="selectCategory(category.value)"> @click="selectFirstCategory(category.id)">
{{ category.label }} {{ category.product_category || category.label }}
</span> </span>
</div> </div>
</div> </div>
<div class="category-section"> <div class="category-section" v-if="secondCategories.length > 0">
<div class="category-title">所属品类</div> <div class="category-title">所属品类</div>
<div class="category-tags"> <div class="category-tags">
<span v-for="category in typeList" :key="category.id" <span v-for="category in secondCategories" :key="category.id"
:class="['category-tag', { active: selectedCategory === category.value }]" :class="['category-tag', { active: activeSecondId === category.id }]"
@click="selectCategory(category.value)"> @click="selectSecondCategory(category.id)">
{{ category.label }} {{ category.product_category || category.label }}
</span> </span>
</div> </div>
</div> </div>
@ -87,7 +87,7 @@
</template> </template>
<script> <script>
import { reqGetProductCategorySearch, reqGetSupplyAndDemandSquareList, reqCompanyCategorySearch } from '@/api/ncmatch' import { reqGetSupplyAndDemandSquareList, reqCompanyCategorySearch, reqSupplyAndDemandFirstCategory } from '@/api/ncmatch'
import { mapGetters, mapState } from 'vuex' import { mapGetters, mapState } from 'vuex'
export default { export default {
name: 'supplyAndDemandSquare', name: 'supplyAndDemandSquare',
@ -100,12 +100,19 @@ 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() {
@ -136,16 +143,28 @@ 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()
}) })
}) })
@ -166,26 +185,54 @@ export default {
return res return res
}) })
}, },
selectCategory(categoryId) { //
if (categoryId === this.selectedCategory) return; selectFirstCategory(id) {
this.selectedCategory = categoryId if (id === this.activeFirstId) return
this.initData(this.selectedCategory) this.activeFirstId = id
//
this.activeSecondId = null
this.selectedCategory = id
//
this.loadSecondCategories(id)
this.initData()
}, },
init_product_category(product_category) { //
return reqGetProductCategorySearch({ url_link: window.location.href, to_page: 'show' }).then(res => { selectSecondCategory(id) {
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) {
let list = [] this.$message.success('获取一级分类成功')
for (let item of res.data) { this.firstCategories = Array.isArray(res.data) ? res.data : []
if (item.parentid === null) { if (this.firstCategories.length > 0) {
list.push({ this.activeFirstId = this.firstCategories[0].id
label: item.product_category, this.selectedCategory = this.activeFirstId
value: item.id this.activeSecondId = null
}) //
} return this.loadSecondCategories(this.activeFirstId)
} else {
this.activeFirstId = null
this.activeSecondId = null
this.selectedCategory = ''
this.secondCategories = []
} }
this.selectedCategory = list[0].value }
this.typeList = list return res
})
},
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
}) })