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/buyer/index.vue |   89 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 77 insertions(+), 12 deletions(-)

diff --git a/src/views/tradeManage/buyer/index.vue b/src/views/tradeManage/buyer/index.vue
index 84e7ce4..a483ff1 100644
--- a/src/views/tradeManage/buyer/index.vue
+++ b/src/views/tradeManage/buyer/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.status" placeholder="鍏ㄩ儴" style="width: 100%">
@@ -57,8 +73,8 @@
         <!-- 绗笁琛岋細鎿嶄綔鎸夐挳锛堝彸瀵归綈锛� -->
         <div class="form-row actions">
           <el-form-item class="row-actions">
-            <el-button type="primary" @click="handleSearch" :icon="Search">鏌ヨ</el-button>
-            <el-button @click="reset" :icon="Refresh">閲嶇疆</el-button>
+            <el-button type="primary" @click="handleSearch" icon="Search">鏌ヨ</el-button>
+            <el-button @click="reset" icon="Refresh">閲嶇疆</el-button>
           </el-form-item>
         </div>
       </el-form>
@@ -290,6 +306,8 @@
 const router = useRouter()
 const userStore = useUserInfo()
 
+const areaIdTreeRef=ref()
+
 // 鐘舵�侀�夐」锛堟洿鏂颁负鏂扮殑宸ヤ綔娴佺▼鐘舵�侊級
 const statusOptions = [
   { label: '鍏ㄩ儴', value: '' },
@@ -310,9 +328,10 @@
 const query = reactive({
   productName: '',
   industry: '',
-  unitProject: '',
+  unitProject: [],
   productType: '',
   productSubType: '',
+  importantDistrictIdList: [],
   orderNo: '',
   status: '',
   dateRange: [],
@@ -360,6 +379,25 @@
   return 'currency'
 }
 
+
+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 getIndustryOptions = async () => {
   try {
@@ -400,14 +438,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
   }
 }
 
@@ -556,12 +620,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.getBuyerOrderPageWithProductConditions : orderApi.getBuyerOrderPage
 
   const res = (await apiMethod(payload)) as any

--
Gitblit v1.8.0