From b3fedd4221b807a07058be9d5d5d8ba8998adbcb Mon Sep 17 00:00:00 2001
From: Bang Hu <hu_bang@hotmail.com>
Date: 星期四, 11 九月 2025 21:35:31 +0800
Subject: [PATCH] Bug修改代码提交

---
 src/views/tradeManage/buyer/index.vue |  162 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 116 insertions(+), 46 deletions(-)

diff --git a/src/views/tradeManage/buyer/index.vue b/src/views/tradeManage/buyer/index.vue
index 51ea821..596a765 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>
@@ -138,28 +154,9 @@
             </el-table-column>
           </el-table-column>
 
-          <!-- 鎬讳环 -->
-          <el-table-column label="鎬讳环" align="center">
-            <el-table-column label="鍗曚环" prop="unitPrice" width="90">
-              <template #default="{ row }">
-                <div v-if="row.isSpacer" class="spacer-cell"></div>
-                <div v-else-if="!row.isMainOrder" class="price-info">
-                  <span v-if="row.priceType === 'points'" class="price-points">
-                    绉垎 {{ row.unitPrice }}
-                  </span>
-                  <span v-else-if="row.priceType === 'currency'" class="price-currency">
-                    璐у竵 {{ row.unitPrice }}
-                  </span>
-                  <span v-else-if="row.priceType === 'agreement'" class="price-agreement">
-                    鍗忚
-                  </span>
-                  <span v-else-if="row.priceType === 'free'" class="price-free">
-                    鍏嶈垂
-                  </span>
-                </div>
-              </template>
-            </el-table-column>
-            <el-table-column label="鏁伴噺" prop="quantity" width="50">
+          <!-- 鏁伴噺 -->
+          <el-table-column label="鏁伴噺" align="center" width="80">
+            <el-table-column label="" prop="quantity" width="80" align="center">
               <template #default="{ row }">
                 <div v-if="row.isSpacer" class="spacer-cell"></div>
                 <div v-else-if="!row.isMainOrder" class="quantity">{{ row.quantity }}</div>
@@ -169,7 +166,7 @@
 
           <!-- 鏈熼檺(骞�) -->
           <el-table-column label="鏈熼檺(骞�)" align="center" width="80">
-            <el-table-column label="" prop="period" width="80">
+            <el-table-column label="" prop="period" width="80" align="center">
               <template #default="{ row }">
                 <div v-if="row.isSpacer" class="spacer-cell"></div>
                 <div v-else-if="!row.isMainOrder" class="period-info">
@@ -227,7 +224,7 @@
                             浜ゆ槗纭
                           </el-button>
                           <el-button
-                            v-else-if="action.type === ActionType.EVALUATE"
+                            v-else-if="action.type === ActionType.EVALUATE && row.parentOrder.isEvaluate === '鏈瘎浠�'"
                             type="primary"
                             link
                             size="small"
@@ -280,17 +277,17 @@
 <script setup lang="ts">
 import { onMounted, reactive, ref } from 'vue'
 import { useRouter } from 'vue-router'
-import { Search, Refresh } from '@element-plus/icons-vue'
 import { ElMessage, ElMessageBox } from 'element-plus'
 import orderApi from '@/api/orderApi'
 import productApi from '@/api/productApi'
 import { useUserInfo } from '@/stores/modules/userInfo'
-import ProductOrderStatusDialog from '@/views/productManage/productOrderStatusDialog/index.vue'
 import { OrderWorkflowController, OrderStatus, ActionType, PageType, StatusMapper } from '@/utils/orderWorkflow'
 import { queryUserDetail } from '@/api/userInfo'
 
 const router = useRouter()
 const userStore = useUserInfo()
+
+const areaIdTreeRef=ref()
 
 // 鐘舵�侀�夐」锛堟洿鏂颁负鏂扮殑宸ヤ綔娴佺▼鐘舵�侊級
 const statusOptions = [
@@ -309,12 +306,25 @@
 const productSubTypeOptions = ref<any[]>([])
 
 // 鏌ヨ鏉′欢
-const query = reactive({
+type BuyerQuery = {
+  productName: string
+  industry: string
+  unitProject: string[]
+  productType: string
+  productSubType: string
+  importantDistrictIdList: string[]
+  orderNo: string
+  status: string
+  dateRange: string[]
+}
+
+const query = reactive<BuyerQuery>({
   productName: '',
   industry: '',
-  unitProject: '',
+  unitProject: [],
   productType: '',
   productSubType: '',
+  importantDistrictIdList: [],
   orderNo: '',
   status: '',
   dateRange: [],
@@ -345,6 +355,7 @@
   [OrderStatus.WAIT_CONFIRM]: 'WAIT_CONFIRM',
   [OrderStatus.COMPLETED]: 'COMPLETED',
   [OrderStatus.EVALUATED]: 'EVALUATED',
+  [OrderStatus.CANCELED]: 'CANCELED'
 }
 
 const formatDateTime = (val?: string) => {
@@ -359,6 +370,25 @@
   if (/(鍗忚|agreement)/i.test(s)) return 'agreement'
   if (/(鍏嶈垂|free)/i.test(s)) return 'free'
   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([])
 }
 
 // 鑾峰彇琛屼笟棰嗗煙閫夐」
@@ -401,14 +431,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
   }
 }
 
@@ -435,7 +491,8 @@
 // 澶勭悊琛屼笟棰嗗煙鍙樺寲
 const handleIndustryChange = async (value: string) => {
   // 娓呯┖鍗曚綅宸ョ▼閫夋嫨
-  query.unitProject = ''
+  query.unitProject = []
+  query.importantDistrictIdList = []
   // 鑾峰彇瀵瑰簲鐨勫崟浣嶅伐绋嬮�夐」
   await getUnitProjectOptions(value)
 }
@@ -456,6 +513,7 @@
     WAIT_CONFIRM: 'warning',
     COMPLETED: 'success',
     EVALUATED: 'success',
+    CANCELED: 'danger'
   }
   return statusMap[status] || 'info'
 }
@@ -478,7 +536,7 @@
     // 涓昏鍗曡锛屽悎骞舵墍鏈夊垪鏄剧ず璁㈠崟淇℃伅
     if (columnIndex === 0) { // 绗竴鍒楋紝鍚堝苟鎵�鏈夊垪
       return {
-        colspan: 8, // 鎬诲叡8鍒楋細璁㈠崟淇℃伅2鍒� + 璐拱鏂瑰紡2鍒� + 鎬讳环2鍒� + 鏈熼檺1鍒� + 鎿嶄綔1鍒�
+        colspan: 7, // 鎬诲叡7鍒楋細璁㈠崟淇℃伅2鍒� + 璐拱鏂瑰紡2鍒� + 鏁伴噺1鍒� + 鏈熼檺1鍒� + 鎿嶄綔1鍒�
         rowspan: 1
       }
     } else {
@@ -510,7 +568,7 @@
           }
         }
       }
-    } else if (columnIndex === 7) { // 鎿嶄綔鍒楋紙绗�8鍒楋級
+    } else if (columnIndex === 6) { // 鎿嶄綔鍒楋紙绗�7鍒楋級
       // 鎵惧埌褰撳墠瀛愯鍗曟墍灞炵殑涓昏鍗�
       const parentOrder = row.parentOrder
       if (parentOrder && parentOrder.subOrders) {
@@ -541,6 +599,7 @@
 
 // 鎼滅储澶勭悊锛堟帴鍏ョ湡瀹炲悗绔級
 const handleSearch = async () => {
+  const filterEvaluated = query.status === 'EVALUATED'
   const payload: any = {
     pageNum: page.current,
     pageSize: page.size,
@@ -548,7 +607,9 @@
     orderId: query.orderNo || undefined,
     userId: userStore.getUserId ? userStore.getUserId : undefined,
   }
-  if (query.status) payload.orderStatus = statusUiToServer[query.status]
+  if (query.status) {
+    payload.orderStatus = filterEvaluated ? OrderStatus.COMPLETED : statusUiToServer[query.status]
+  }
   if (Array.isArray(query.dateRange) && query.dateRange.length === 2) {
     payload.applyTimeStart = query.dateRange[0]
     payload.applyTimeEnd = query.dateRange[1]
@@ -556,17 +617,22 @@
 
   // 娣诲姞浜у搧鏉′欢鏌ヨ
   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
   const pageData = res?.data
-  const list: any[] = Array.isArray(pageData?.list) ? pageData.list : []
+  let list: any[] = Array.isArray(pageData?.list) ? pageData.list : []
+  // 鑻ョ瓫閫夆�滃凡璇勪环鈥濓紝鍏堜互宸插畬鎴愭煡璇紝鍐嶅湪鍓嶇鎸夊凡璇勪环杩囨护
+  if (filterEvaluated) {
+    list = list.filter((order: any) => order?.isEvaluate === '宸茶瘎浠�')
+  }
   page.total = Number(pageData?.total || 0)
 
   const flatData: any[] = []
@@ -582,7 +648,8 @@
       status: uiStatus,
       statusName: order.orderStatus || '',
       orderStatus: StatusMapper.toUIStatus(order.orderStatus), // 杞崲涓烘爣鍑嗙姸鎬佹灇涓�
-      workFlowId: order.workflowId || ''
+      workFlowId: order.workflowId || '',
+      isEvaluate: order.isEvaluate || ''
     }
     const subOrders: any[] = Array.isArray(order?.orderDetails)
       ? order.orderDetails.map((d: any, i: number) => ({
@@ -616,9 +683,10 @@
   Object.assign(query, {
     productName: '',
     industry: '',
-    unitProject: '',
+    unitProject: [],
     productType: '',
     productSubType: '',
+    importantDistrictIdList: [],
     orderNo: '',
     status: '',
     dateRange: [],
@@ -934,6 +1002,7 @@
 .period-info {
   display: flex;
   align-items: center;
+  justify-content: center;
   gap: 8px;
   font-size: 12px;
 
@@ -1064,6 +1133,7 @@
   font-size: 12px;
   color: #303133;
   font-weight: 500;
+  text-align: center;
 }
 
 .pagination-container {

--
Gitblit v1.8.0