From 83d5b2be8fdf0ac0b59cacf6b344c8815ab4d040 Mon Sep 17 00:00:00 2001
From: seatonwan9
Date: 星期二, 02 九月 2025 19:58:11 +0800
Subject: [PATCH] 提交源码

---
 src/views/tradeManage/buyer/index.vue |  362 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 232 insertions(+), 130 deletions(-)

diff --git a/src/views/tradeManage/buyer/index.vue b/src/views/tradeManage/buyer/index.vue
index dc072b9..51ea821 100644
--- a/src/views/tradeManage/buyer/index.vue
+++ b/src/views/tradeManage/buyer/index.vue
@@ -9,7 +9,7 @@
             <el-input v-model="query.productName" placeholder="璇疯緭鍏ヤ骇鍝佸悕绉�" clearable style="width: 100%" />
           </el-form-item>
           <el-form-item label="琛屼笟棰嗗煙" class="col-25">
-            <el-select v-model="query.industry" placeholder="璇烽�夋嫨琛屼笟棰嗗煙" clearable style="width: 100%">
+            <el-select v-model="query.industry" placeholder="璇烽�夋嫨琛屼笟棰嗗煙" clearable style="width: 100%" @change="handleIndustryChange">
               <el-option v-for="item in industryOptions" :key="item.value" :label="item.label" :value="item.value" />
             </el-select>
           </el-form-item>
@@ -31,15 +31,15 @@
             <el-input v-model="query.orderNo" placeholder="璇疯緭鍏ヨ鍗曠紪鍙�" clearable style="width: 100%" />
           </el-form-item>
           <el-form-item label="浜у搧绫诲瀷" class="col-25">
-            <el-select v-model="query.productType" placeholder="璇烽�夋嫨浜у搧绫诲瀷" clearable style="width: 100%">
+            <el-select v-model="query.productType" placeholder="璇烽�夋嫨浜у搧绫诲瀷" clearable style="width: 100%" @change="handleProductTypeChange">
               <el-option v-for="item in productTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
             </el-select>
           </el-form-item>
-          <el-form-item label="" class="col-17">
-            <el-select v-model="query.productSubType" placeholder="璇烽�夋嫨浜у搧绫诲瀷瀛愮骇" clearable style="width: 100%">
-              <el-option v-for="item in productSubTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
-            </el-select>
-          </el-form-item>
+<!--          <el-form-item label="" class="col-17">-->
+<!--            <el-select v-model="query.productSubType" placeholder="璇烽�夋嫨浜у搧绫诲瀷瀛愮骇" clearable style="width: 100%">-->
+<!--              <el-option v-for="item in productSubTypeOptions" :key="item.value" :label="item.label" :value="item.value" />-->
+<!--            </el-select>-->
+<!--          </el-form-item>-->
           <el-form-item label="鐢宠鏃堕棿" class="col-30">
             <el-date-picker
               v-model="query.dateRange"
@@ -74,9 +74,7 @@
               <template #default="{ row }">
                 <div v-if="row.isMainOrder" class="main-order-info">
                   <div class="order-header">
-                    <div class="order-item status-item">
-                      <el-tag :type="getStatusType(row.status)" size="small">{{ row.statusName }}</el-tag>
-                    </div>
+
                     <div class="order-item">
                       <span class="label">鐢宠鏃堕棿:</span>
                       <span class="value">{{ row.applyTime }}</span>
@@ -88,6 +86,9 @@
                     <div class="order-item">
                       <span class="label">渚涘簲鏂�:</span>
                       <span class="value">{{ row.supplySide }}</span>
+                    </div>
+                    <div class="order-item status-item">
+                      <el-tag :type="getStatusType(row.status)" size="small">{{ row.statusName }}</el-tag>
                     </div>
                   </div>
                 </div>
@@ -102,7 +103,7 @@
               </template>
             </el-table-column>
           </el-table-column>
-          
+
           <!-- 璐拱鏂瑰紡 -->
           <el-table-column label="璐拱鏂瑰紡" align="center">
             <el-table-column label="閿�鍞舰寮�/璐︽埛鏁伴噺" width="150">
@@ -136,7 +137,7 @@
               </template>
             </el-table-column>
           </el-table-column>
-          
+
           <!-- 鎬讳环 -->
           <el-table-column label="鎬讳环" align="center">
             <el-table-column label="鍗曚环" prop="unitPrice" width="90">
@@ -165,7 +166,7 @@
               </template>
             </el-table-column>
           </el-table-column>
-          
+
           <!-- 鏈熼檺(骞�) -->
           <el-table-column label="鏈熼檺(骞�)" align="center" width="80">
             <el-table-column label="" prop="period" width="80">
@@ -178,7 +179,7 @@
               </template>
             </el-table-column>
           </el-table-column>
-          
+
           <!-- 鎿嶄綔 -->
           <el-table-column label="鎿嶄綔" align="center" width="120" class="operation-column">
             <el-table-column label="" width="120">
@@ -189,56 +190,56 @@
                     <div class="action-item">
                       <div class="action-buttons">
                         <template v-for="action in getAvailableActions(row.parentOrder)" :key="action.type">
-                          <el-button 
+                          <el-button
                             v-if="action.type === ActionType.VIEW"
-                            type="primary" 
-                            link 
-                            size="small" 
+                            type="primary"
+                            link
+                            size="small"
                             @click="handleAction(action, row.parentOrder)"
                           >
                             鏌ョ湅
                           </el-button>
-                          <el-button 
+                          <el-button
                             v-else-if="action.type === ActionType.TRACK"
-                            type="primary" 
-                            link 
-                            size="small" 
+                            type="primary"
+                            link
+                            size="small"
                             @click="handleAction(action, row.parentOrder)"
                           >
                             杩借釜
                           </el-button>
-                          <el-button 
+                          <el-button
                             v-else-if="action.type === ActionType.UPLOAD_FILE"
-                            type="primary" 
-                            link 
-                            size="small" 
+                            type="primary"
+                            link
+                            size="small"
                             @click="handleAction(action, row.parentOrder)"
                           >
                             鎻愪氦鏂囦欢
                           </el-button>
-                          <el-button 
+                          <el-button
                             v-else-if="action.type === ActionType.CONFIRM_TRADE"
-                            type="primary" 
-                            link 
-                            size="small" 
+                            type="primary"
+                            link
+                            size="small"
                             @click="handleAction(action, row.parentOrder)"
                           >
                             浜ゆ槗纭
                           </el-button>
-                          <el-button 
+                          <el-button
                             v-else-if="action.type === ActionType.EVALUATE"
-                            type="primary" 
-                            link 
-                            size="small" 
+                            type="primary"
+                            link
+                            size="small"
                             @click="handleAction(action, row.parentOrder)"
                           >
                             璇勪环
                           </el-button>
-                          <el-button 
+                          <el-button
                             v-else-if="action.type === ActionType.CANCEL_ORDER"
-                            type="danger" 
-                            link 
-                            size="small" 
+                            type="danger"
+                            link
+                            size="small"
                             @click="handleAction(action, row.parentOrder)"
                           >
                             鍙栨秷璁㈠崟
@@ -267,12 +268,12 @@
         />
       </div>
     </el-card>
-    
+
     <!-- 璁㈠崟鐘舵�佸璇濇 -->
-    <ProductOrderStatusDialog 
-      v-model="orderStatusDialogVisible" 
-      :order-id="currentOrderId" 
-    />
+    <!-- <ProductOrderStatusDialog
+      v-model="orderStatusDialogVisible"
+      :order-id="currentOrderId"
+    /> -->
   </div>
 </template>
 
@@ -282,9 +283,11 @@
 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()
@@ -299,35 +302,11 @@
   { label: '宸茶瘎浠�', value: 'EVALUATED' },
 ]
 
-// 琛屼笟棰嗗煙閫夐」
-const industryOptions = [
-  { label: '寤虹瓚宸ョ▼', value: 'construction' },
-  { label: '浜ら�氬伐绋�', value: 'transportation' },
-  { label: '姘村埄宸ョ▼', value: 'water' },
-  { label: '鐢靛姏宸ョ▼', value: 'power' },
-]
-
-// 鍗曚綅宸ョ▼閫夐」
-const unitProjectOptions = [
-  { label: '鍦熷缓宸ョ▼', value: 'civil' },
-  { label: '瀹夎宸ョ▼', value: 'installation' },
-  { label: '瑁呴グ宸ョ▼', value: 'decoration' },
-]
-
-// 浜у搧绫诲瀷閫夐」
-const productTypeOptions = [
-  { label: '浼佷笟绉佹湁SaaS鐗堣鍙�', value: 'enterprise_private' },
-  { label: '浼佷笟鍏湁SaaS鐗堣鍙�', value: 'enterprise_public' },
-  { label: '椤圭洰鍏湁SaaS鐗堣鍙�', value: 'project_public' },
-  { label: '涓汉鍏湁SaaS鐗堣鍙�', value: 'personal_public' },
-]
-
-// 浜у搧绫诲瀷瀛愮骇閫夐」
-const productSubTypeOptions = [
-  { label: '鍩虹鐗�', value: 'basic' },
-  { label: '鏍囧噯鐗�', value: 'standard' },
-  { label: '楂樼骇鐗�', value: 'premium' },
-]
+// 鍔ㄦ�侀�夐」鏁版嵁
+const industryOptions = ref<any[]>([])
+const unitProjectOptions = ref<any[]>([])
+const productTypeOptions = ref<any[]>([])
+const productSubTypeOptions = ref<any[]>([])
 
 // 鏌ヨ鏉′欢
 const query = reactive({
@@ -380,6 +359,93 @@
   if (/(鍗忚|agreement)/i.test(s)) return 'agreement'
   if (/(鍏嶈垂|free)/i.test(s)) return 'free'
   return 'currency'
+}
+
+// 鑾峰彇琛屼笟棰嗗煙閫夐」
+const getIndustryOptions = async () => {
+  try {
+    const res = await productApi.getCategoryByParent({ parentCode: 'business_direction' })
+    if (res?.code === 200 && res.data) {
+      industryOptions.value = res.data.map((item: any) => ({
+        label: item.name,
+        value: item.id
+      }))
+    }
+  } catch (error) {
+    console.error('鑾峰彇琛屼笟棰嗗煙閫夐」澶辫触:', error)
+  }
+}
+
+// 鑾峰彇浜у搧绫诲瀷閫夐」
+const getProductTypeOptions = async () => {
+  try {
+      // product_type
+    const res = await productApi.getCategoryByParent({ parentCode: 'ProductTechnologyType' })
+    if (res?.code === 200 && res.data) {
+      productTypeOptions.value = res.data.map((item: any) => ({
+        label: item.name,
+        value: item.id
+      }))
+    }
+  } catch (error) {
+    console.error('鑾峰彇浜у搧绫诲瀷閫夐」澶辫触:', error)
+  }
+}
+
+// 鏍规嵁琛屼笟棰嗗煙鑾峰彇鍗曚綅宸ョ▼閫夐」
+const getUnitProjectOptions = async (industryCode: string) => {
+  if (!industryCode) {
+    unitProjectOptions.value = []
+    return
+  }
+  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
+      }))
+    }
+  } catch (error) {
+    console.error('鑾峰彇鍗曚綅宸ョ▼閫夐」澶辫触:', error)
+    unitProjectOptions.value = []
+  }
+}
+
+// 鏍规嵁浜у搧绫诲瀷鑾峰彇浜у搧瀛愮骇閫夐」
+const getProductSubTypeOptions = async (productTypeCode: string) => {
+  if (!productTypeCode) {
+    productSubTypeOptions.value = []
+    return
+  }
+  try {
+    const res = await productApi.getCategoryByParent({ parentId: productTypeCode })
+    if (res?.code === 200 && res.data) {
+      productSubTypeOptions.value = res.data.map((item: any) => ({
+        label: item.name,
+        value: item.id
+      }))
+    }
+  } catch (error) {
+    console.error('鑾峰彇浜у搧瀛愮骇閫夐」澶辫触:', error)
+    productSubTypeOptions.value = []
+  }
+}
+
+// 澶勭悊琛屼笟棰嗗煙鍙樺寲
+const handleIndustryChange = async (value: string) => {
+  // 娓呯┖鍗曚綅宸ョ▼閫夋嫨
+  query.unitProject = ''
+  // 鑾峰彇瀵瑰簲鐨勫崟浣嶅伐绋嬮�夐」
+  await getUnitProjectOptions(value)
+}
+
+// 澶勭悊浜у搧绫诲瀷鍙樺寲
+const handleProductTypeChange = async (value: string) => {
+  // 娓呯┖浜у搧瀛愮骇閫夋嫨
+  query.productSubType = ''
+  // 鑾峰彇瀵瑰簲鐨勪骇鍝佸瓙绾ч�夐」
+ //  await getProductSubTypeOptions(value)
 }
 
 // 鑾峰彇鐘舵�佺被鍨�
@@ -480,7 +546,7 @@
     pageSize: page.size,
     productName: query.productName || undefined,
     orderId: query.orderNo || undefined,
-    userId: userStore.getUserId ? Number(userStore.getUserId) : undefined,
+    userId: userStore.getUserId ? userStore.getUserId : undefined,
   }
   if (query.status) payload.orderStatus = statusUiToServer[query.status]
   if (Array.isArray(query.dateRange) && query.dateRange.length === 2) {
@@ -488,25 +554,23 @@
     payload.applyTimeEnd = query.dateRange[1]
   }
 
-  const res = (await orderApi.getBuyerOrderPage(payload)) as any
+  // 娣诲姞浜у搧鏉′欢鏌ヨ
+  if (query.industry) payload.industryId = query.industry
+  if (query.unitProject) payload.unitProjectId = query.unitProject
+  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 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 : []
   page.total = Number(pageData?.total || 0)
 
-  // 骞跺彂鑾峰彇姣忎釜璁㈠崟鐨勮鎯咃紙鐢ㄤ簬鏋勯�犲瓙璁㈠崟琛岋級
-  const detailsArr = await Promise.all(
-    list.map(async (order: any) => {
-      try {
-        const detailRes = (await orderApi.getOrderDetail(order.orderId)) as any
-        return detailRes?.data
-      } catch (e) {
-        return null
-      }
-    })
-  )
-
   const flatData: any[] = []
-  list.forEach((order: any, idx: number) => {
+  list.forEach((order: any) => {
     const uiStatus = statusServerToUi[order.orderStatus] || 'WAIT_UPLOAD'
     const mainRow: any = {
       id: order.orderId,
@@ -518,11 +582,10 @@
       status: uiStatus,
       statusName: order.orderStatus || '',
       orderStatus: StatusMapper.toUIStatus(order.orderStatus), // 杞崲涓烘爣鍑嗙姸鎬佹灇涓�
+      workFlowId: order.workflowId || ''
     }
-
-    const detail = detailsArr[idx]
-    const subOrders: any[] = Array.isArray(detail?.orderDetails)
-      ? detail.orderDetails.map((d: any, i: number) => ({
+    const subOrders: any[] = Array.isArray(order?.orderDetails)
+      ? order.orderDetails.map((d: any, i: number) => ({
           id: `${order.orderId}-${i + 1}`,
           isMainOrder: false,
           productName: order.productName || '',
@@ -560,6 +623,9 @@
     status: '',
     dateRange: [],
   })
+  // 娓呯┖鍔ㄦ�侀�夐」
+  unitProjectOptions.value = []
+  productSubTypeOptions.value = []
   page.current = 1
   handleSearch()
 }
@@ -569,7 +635,13 @@
 const toUpload = (row: any) => router.push({ name: 'tradeOrderUpload', params: { id: row.id } })
 const toConfirm = (row: any) => router.push({ name: 'tradeOrderConfirm', params: { id: row.id } })
 const toEvaluate = (row: any) => router.push({ name: 'tradeOrderEvaluate', params: { id: row.id } })
-const toTrack = (row: any) => router.push({ name: 'tradeTrack', params: { id: row.id } })
+const toTrack = (row: any) => {
+  if (!row.workFlowId) {
+    ElMessage.warning('璇ヨ鍗曟殏鏃犲伐浣滄祦淇℃伅')
+    return
+  }
+  router.push({ name: 'tradeTrack', params: { id: row.workFlowId } })
+}
 
 // 杩借釜璁㈠崟 - 鏄剧ず璁㈠崟鐘舵�佸璇濇
 const showOrderTrack = (row: any) => {
@@ -590,7 +662,8 @@
       toDetail(order)
       break
     case ActionType.TRACK:
-      showOrderTrack(order)
+      // showOrderTrack(order)
+      toTrack(order)
       break
     case ActionType.UPLOAD_FILE:
       toUpload(order)
@@ -618,9 +691,9 @@
       type: 'warning',
       confirmButtonClass: 'el-button--danger'
     })
-    
+
     const res = await orderApi.cancelOrder(order.id)
-    
+
     if (res && res.code === 200) {
       ElMessage.success('璁㈠崟鍙栨秷鎴愬姛')
       handleSearch() // 鍒锋柊鍒楄〃
@@ -635,7 +708,33 @@
   }
 }
 
-onMounted(handleSearch)
+onMounted(async ()=>{
+  // 鑾峰彇鐢ㄦ埛淇℃伅
+  if (!userStore.getUserId) {
+    try {
+      const res: any = await queryUserDetail()
+      if (res?.code === 200 && res.data) {
+        userStore.updateUserDetail(res.data)
+      } else {
+        ElMessage.error(res?.msg || '鏃犳硶鑾峰彇鐢ㄦ埛淇℃伅锛岃鍏堢櫥褰�')
+        return
+      }
+    } catch (e) {
+      console.error('鑾峰彇鐢ㄦ埛璇︽儏澶辫触:', e)
+      ElMessage.error('鑾峰彇鐢ㄦ埛淇℃伅澶辫触锛岃绋嶅悗閲嶈瘯')
+      return
+    }
+  }
+
+  // 鑾峰彇鍒濆閫夐」鏁版嵁
+  await Promise.all([
+    getIndustryOptions(),
+    getProductTypeOptions()
+  ])
+
+  // 鎵ц鎼滅储
+  handleSearch()
+})
 </script>
 
 <style scoped lang="scss">
@@ -670,7 +769,7 @@
       border-bottom: 2px solid #e4e7ed; // 涓庡垎闅旇涓�鑷寸殑涓嬭竟妗�
     }
   }
-  
+
   // 璋冩暣琛ㄥご楂樺害
   tr:first-child {
     th {
@@ -687,18 +786,18 @@
 
 .search-card {
   margin-bottom: 20px;
-  
+
   .query-form {
     .form-row {
       display: flex;
       gap: 0;
       width: 100%;
       margin-bottom: 8px;
-      
+
       &.actions {
         justify-content: flex-end;
       }
-      
+
       .el-form-item { margin-right: 0 !important; }
       > .el-form-item { padding-right: 8px; }
       > .el-form-item:last-child { padding-right: 0; }
@@ -712,7 +811,7 @@
     .el-form-item {
       margin-bottom: 16px;
       margin-right: 20px;
-      
+
       &:last-child {
         margin-right: 0;
       }
@@ -723,7 +822,7 @@
 .table-container {
   position: relative;
   z-index: 1;
-  
+
   .custom-table {
     // 琛ㄥご绗簩琛屾枃瀛楀ぇ灏忚皟鏁�
     .el-table__header-wrapper {
@@ -736,7 +835,7 @@
         }
       }
     }
-    
+
     // 纭繚琛ㄥご鎵�鏈夎鐨勬枃瀛楀ぇ灏忎竴鑷�
     .el-table__header {
       th {
@@ -746,23 +845,23 @@
         }
       }
     }
-    
+
     .el-table {
       position: relative;
       z-index: 1;
-      
+
       .main-order-row {
         background-color: #f8f9fa;
         font-weight: 600;
-        
+
         td {
           border-bottom: 2px solid #e4e7ed;
         }
       }
-      
+
       .sub-order-row {
         background-color: #ffffff;
-        
+
         td {
           border-bottom: 1px solid #ebeef5;
         }
@@ -779,20 +878,23 @@
     gap: 20px;
     align-items: center;
     overflow: hidden;
-    
+    .status-item{
+      flex-direction: row-reverse;
+    }
     .order-item {
       display: flex;
       align-items: center;
       gap: 8px;
       flex-shrink: 0;
-      
+      flex: 1;
+
       .label {
         color: #909399;
         font-size: 12px;
         min-width: 60px;
         flex-shrink: 0;
       }
-      
+
       .value {
         color: #303133;
         font-size: 12px;
@@ -807,22 +909,22 @@
 
 .price-info {
   font-size: 12px;
-  
+
   .price-points {
     color: #e6a23c;
     font-weight: 500;
   }
-  
+
   .price-currency {
     color: #67c23a;
     font-weight: 500;
   }
-  
+
   .price-agreement {
     color: #409eff;
     font-weight: 500;
   }
-  
+
   .price-free {
     color: #909399;
     font-style: italic;
@@ -834,7 +936,7 @@
   align-items: center;
   gap: 8px;
   font-size: 12px;
-  
+
   .permanent {
     color: #909399;
     font-size: 12px;
@@ -866,18 +968,18 @@
     display: flex;
     align-items: center;
     margin-bottom: 4px;
-    
+
     &:last-child {
       margin-bottom: 0;
     }
-    
+
     .label {
       color: #909399;
       font-size: 12px;
       min-width: 60px;
       flex-shrink: 0;
     }
-    
+
     .value {
       color: #303133;
       font-size: 12px;
@@ -898,7 +1000,7 @@
   color: #303133;
   text-align: center;
   line-height: 1.4;
-  
+
   .all-actions {
     display: flex;
     flex-direction: column;
@@ -906,10 +1008,10 @@
     justify-content: center;
     gap: 6px;
     width: 100%;
-    
+
     .action-item {
       width: 100%;
-      
+
       .action-buttons {
         display: flex;
         flex-direction: column;
@@ -917,7 +1019,7 @@
         align-items: center;
         justify-content: center;
         width: 100%;
-        
+
         .el-button {
           width: 100%;
           text-align: center;
@@ -929,7 +1031,7 @@
           height: auto;
           line-height: 1.2;
         }
-        
+
         .op-text {
           margin: 4px 0;
           text-align: center;
@@ -949,12 +1051,12 @@
   flex-wrap: wrap;
 }
 
-.op-text { 
-  color: #606266; 
+.op-text {
+  color: #606266;
   font-size: 12px;
 }
-.op-text.warning { 
-  color: #f59e0b; 
+.op-text.warning {
+  color: #f59e0b;
   font-size: 12px;
 }
 
@@ -975,11 +1077,11 @@
   .el-table__fixed-right {
     z-index: 2 !important;
   }
-  
+
   .el-table__fixed-right-patch {
     z-index: 2 !important;
   }
-  
+
   // 鎿嶄綔鍒楁牱寮忎紭鍖�
   .operation-column {
     .cell {

--
Gitblit v1.8.0