From a4e7747ec17bdab96b3971dd631df63272aa49be Mon Sep 17 00:00:00 2001
From: Bang Hu <hu_bang@hotmail.com>
Date: 星期四, 28 八月 2025 12:52:18 +0800
Subject: [PATCH] 参考买家中心修改交易审批模块查询和订单操作选项功能逻辑

---
 src/views/approveManage/tradeApproval/list.vue |  241 +++++++++++++++++++++++++++++++++++------------
 1 files changed, 179 insertions(+), 62 deletions(-)

diff --git a/src/views/approveManage/tradeApproval/list.vue b/src/views/approveManage/tradeApproval/list.vue
index cc335ab..cd0dba7 100644
--- a/src/views/approveManage/tradeApproval/list.vue
+++ b/src/views/approveManage/tradeApproval/list.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,7 +31,7 @@
             <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>
@@ -74,9 +74,6 @@
               <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>
@@ -92,6 +89,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>
@@ -194,16 +194,7 @@
                       <div class="action-buttons">
                         <template v-for="action in getAvailableActions(row.parentOrder)" :key="action.type">
                           <el-button 
-                            v-if="action.type === ActionType.AUTHORIZE"
-                            type="primary" 
-                            link 
-                            size="small" 
-                            @click="handleAction(action, row.parentOrder)"
-                          >
-                            鎺堟潈
-                          </el-button>
-                          <el-button 
-                            v-else-if="action.type === ActionType.VIEW"
+                            v-if="action.type === ActionType.VIEW"
                             type="primary" 
                             link 
                             size="small" 
@@ -219,6 +210,15 @@
                             @click="handleAction(action, row.parentOrder)"
                           >
                             杩借釜
+                          </el-button>
+                          <el-button 
+                            v-else-if="action.type === ActionType.AUTHORIZE"
+                            type="primary" 
+                            link 
+                            size="small" 
+                            @click="handleAction(action, row.parentOrder)"
+                          >
+                            鎺堟潈
                           </el-button>
                         </template>
                       </div>
@@ -257,12 +257,15 @@
 import { onMounted, reactive, ref } from 'vue'
 import { useRouter } from 'vue-router'
 import { Search, Refresh } from '@element-plus/icons-vue'
-import { fetchApprovalPage } from '@/api/approvalManage'
+import { ElMessage } from 'element-plus'
+import { fetchApprovalPage, fetchApprovalPageWithProductConditions } from '@/api/approvalManage'
 import orderApi from '@/api/orderApi'
+import productApi from '@/api/productApi'
 import { authorizeApproval, fetchApprovalByOrderId } from '@/api/approvalManage'
 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()
@@ -277,35 +280,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({
@@ -359,6 +338,92 @@
   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 {
+    const res = await productApi.getCategoryByParent({ parentCode: 'product_type' })
+    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)
 }
 
 // 鑾峰彇鐘舵�佺被鍨�
@@ -465,8 +530,18 @@
     payload.applyTimeStart = query.dateRange[0]
     payload.applyTimeEnd = query.dateRange[1]
   }
+  
+  // 娣诲姞浜у搧鏉′欢鏌ヨ
+  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
 
-  const res = (await fetchApprovalPage(payload)) as any
+  // 鏍规嵁鏄惁鏈変骇鍝佹潯浠堕�夋嫨涓嶅悓鐨凙PI
+  const hasProductConditions = query.industry || query.unitProject || query.productType || query.productSubType
+  const apiMethod = hasProductConditions ? fetchApprovalPageWithProductConditions : fetchApprovalPage
+  
+  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)
@@ -483,20 +558,21 @@
     })
   )
 
-      const flatData: any[] = []
-    list.forEach((order: any, idx: number) => {
-      const uiStatus = statusServerToUi[order.orderStatus] || 'WAIT_UPLOAD'
-      const mainRow: any = {
-        id: order.orderId,
-        isMainOrder: true,
-        applyTime: formatDateTime(order.applyTime || ''),
-        orderNo: order.orderId,
-        demandSide: '',
-        supplySide: order.providerName || '',
-        status: uiStatus,
-        statusName: order.orderStatus || '',
-        orderStatus: StatusMapper.toUIStatus(order.orderStatus), // 杞崲涓烘爣鍑嗙姸鎬佹灇涓�
-      }
+  const flatData: any[] = []
+  list.forEach((order: any, idx: number) => {
+    const uiStatus = statusServerToUi[order.orderStatus] || 'WAIT_UPLOAD'
+    const mainRow: any = {
+      id: order.orderId,
+      isMainOrder: true,
+      applyTime: formatDateTime(order.applyTime || ''),
+      orderNo: order.orderId,
+      demandSide: '',
+      supplySide: order.providerName || '',
+      status: uiStatus,
+      statusName: order.orderStatus || '',
+      orderStatus: StatusMapper.toUIStatus(order.orderStatus), // 杞崲涓烘爣鍑嗙姸鎬佹灇涓�
+      workFlowId: order.workflowId || ''
+    }
 
     const detail = detailsArr[idx]
     const subOrders: any[] = Array.isArray(detail?.orderDetails)
@@ -539,6 +615,9 @@
     status: '',
     dateRange: [],
   })
+  // 娓呯┖鍔ㄦ�侀�夐」
+  unitProjectOptions.value = []
+  productSubTypeOptions.value = []
   page.current = 1
   handleSearch()
 }
@@ -547,6 +626,13 @@
 const toApprove = (row: any) => router.push({ name: 'tradeApproval', params: { id: row.id } })
 const toCheckFiles = (row: any) => router.push({ name: 'tradeCheckFiles', params: { id: row.id } })
 const toDetail = (row: any) => router.push({ name: 'tradeOrderDetail', 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) => {
@@ -567,7 +653,7 @@
       toDetail(order)
       break
     case ActionType.TRACK:
-      showOrderTrack(order)
+      toTrack(order)
       break
     case ActionType.AUTHORIZE:
       toAuthorize(order)
@@ -582,7 +668,33 @@
   router.push({ name: 'tradeAuthorization', params: { id: row.id } })
 }
 
-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">
@@ -742,6 +854,11 @@
         overflow: hidden;
         text-overflow: ellipsis;
       }
+      
+      &.status-item {
+        justify-content: flex-start;
+        margin-left: 0;
+      }
     }
   }
 }

--
Gitblit v1.8.0