From 349091f54dab47b15ca81613f02765490a2ce7d0 Mon Sep 17 00:00:00 2001
From: p-honggang.li <p-honggang.li@pcitc.com>
Date: 星期四, 11 九月 2025 10:50:36 +0800
Subject: [PATCH] 修改买家中心卖家中心产品类型等条件查询问题

---
 src/views/tradeManage/seller/index.vue |   85 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 73 insertions(+), 12 deletions(-)

diff --git a/src/views/tradeManage/seller/index.vue b/src/views/tradeManage/seller/index.vue
index b3dfeb3..8c4f3db 100644
--- a/src/views/tradeManage/seller/index.vue
+++ b/src/views/tradeManage/seller/index.vue
@@ -14,9 +14,25 @@
             </el-select>
           </el-form-item>
           <el-form-item label="" class="col-17">
-            <el-select v-model="query.unitProject" placeholder="璇烽�夋嫨鍗曚綅宸ョ▼" clearable style="width: 100%">
-              <el-option v-for="item in unitProjectOptions" :key="item.value" :label="item.label" :value="item.value" />
-            </el-select>
+<!--            <el-select v-model="query.unitProject" placeholder="璇烽�夋嫨鍗曚綅宸ョ▼" clearable style="width: 100%">-->
+<!--              <el-option v-for="item in unitProjectOptions" :key="item.value" :label="item.label" :value="item.value" />-->
+<!--            </el-select>-->
+            <el-tree-select
+                ref="areaIdTreeRef"
+                v-model="query.unitProject"
+                :data="unitProjectOptions"
+                placeholder="璇烽�夋嫨鍗曚綅宸ョ▼"
+                multiple
+                collapse-tags
+                collapse-tags-tooltip
+                clearable
+                :default-expand-all="true"
+                :render-after-expand="false"
+                show-checkbox
+                style="width: 170px;"
+                @change="importantAreaCh"
+                @clear="importantAreaClear"
+            />
           </el-form-item>
           <el-form-item label="浜у搧绫诲瀷" class="col-30">
             <el-select v-model="query.productType" placeholder="璇烽�夋嫨浜у搧绫诲瀷" clearable style="width: 100%" @change="handleProductTypeChange">
@@ -254,6 +270,7 @@
 
 const router = useRouter()
 const userStore = useUserInfo()
+const areaIdTreeRef=ref()
 
 // 鐘舵�侀�夐」锛堟洿鏂颁负鏂扮殑宸ヤ綔娴佺▼鐘舵�侊級
 const statusOptions = [
@@ -275,9 +292,10 @@
 const query = reactive({
   productName: '',
   industry: '',
-  unitProject: '',
+  unitProject: [],
   productType: '',
   productSubType: '',
+  importantDistrictIdList: [],
   orderNo: '',
   status: '',
   dateRange: [],
@@ -363,14 +381,40 @@
   try {
     const res = await productApi.getCategoryByParent({ parentId: industryCode })
     if (res?.code === 200 && res.data) {
-      unitProjectOptions.value = res.data.map((item: any) => ({
-        label: item.name,
-        value: item.id
-      }))
+      unitProjectOptions.value = handleIndustryData(res.data)
     }
   } catch (error) {
     console.error('鑾峰彇鍗曚綅宸ョ▼閫夐」澶辫触:', error)
     unitProjectOptions.value = []
+  }
+}
+
+const handleIndustryData=(list:any)=>{
+  if(list&& list.length>0){
+    let data=list.map((item:any)=>{
+      return {
+        label:item.name,
+        value:item.id,
+        parentId:item.parentId,
+        parentName:item.parentName,
+        children:item.childrenList?handleIndustryChildData(item,item.childrenList):[]
+      }
+    })
+    return data
+  }
+}
+const handleIndustryChildData=(parentItem:any,childList:any)=>{
+  if(childList&& childList.length>0){
+    let data=childList.map((item:any)=>{
+      return {
+        parentId:parentItem.id,
+        parentName:parentItem.name,
+        label:item.name,
+        value:item.id,
+        children:item.childrenList?handleIndustryChildData(item,item.childrenList):[]
+      }
+    })
+    return data
   }
 }
 
@@ -394,6 +438,24 @@
   }
 }
 
+const importantAreaCh=()=>{
+  let checkedKeys = areaIdTreeRef.value!.getCheckedNodes(false, true)
+  if(checkedKeys&&checkedKeys.length>0&& query.unitProject.length>0){
+    query.importantDistrictIdList=[]
+    checkedKeys.forEach((item:any)=>{
+      if(item.children&&item.children.length>0){
+        query.importantDistrictIdList.push(item.value)
+      }
+    })
+  }
+}
+
+const importantAreaClear=()=>{
+  query.unitProject = []
+  query.importantDistrictIdList = []
+  areaIdTreeRef.value.setCheckedKeys([])
+}
+
 // 澶勭悊琛屼笟棰嗗煙鍙樺寲
 const handleIndustryChange = async (value: string) => {
   // 娓呯┖鍗曚綅宸ョ▼閫夋嫨
@@ -409,8 +471,6 @@
   // 鑾峰彇瀵瑰簲鐨勪骇鍝佸瓙绾ч�夐」
  // await getProductSubTypeOptions(value)
 }
-
-
 
 // 鑾峰彇鐘舵�佺被鍨�
 const getStatusType = (status: string) => {
@@ -525,12 +585,13 @@
 
     // 娣诲姞浜у搧鏉′欢鏌ヨ
     if (query.industry) payload.industryId = query.industry
-    if (query.unitProject) payload.unitProjectId = query.unitProject
+    if (query.unitProject.length > 0) payload.unitProjectId = query.unitProject
+    if (query.importantDistrictIdList.length > 0) payload.importantDistrictId = query.importantDistrictIdList
     if (query.productType) payload.productTypeId = query.productType
     if (query.productSubType) payload.productSubTypeId = query.productSubType
 
     // 鏍规嵁鏄惁鏈変骇鍝佹潯浠堕�夋嫨涓嶅悓鐨凙PI
-    const hasProductConditions = query.industry || query.unitProject || query.productType || query.productSubType
+    const hasProductConditions = query.industry || query.unitProject.length > 0 || query.productType || query.productSubType
     const apiMethod = hasProductConditions ? orderApi.getSellerOrderPageWithProductConditions : orderApi.getSellerOrderPage
 
     const res = (await apiMethod(payload)) as any

--
Gitblit v1.8.0