From b9271e9537308854e20d7e6c7af2c77d8475a288 Mon Sep 17 00:00:00 2001
From: p-honggang.li <p-honggang.li@pcitc.com>
Date: 星期六, 06 九月 2025 03:17:38 +0800
Subject: [PATCH] 修改审核页面,添加积分审核代办,积分审核已办,协议审核代办,协议审核代办,修改规则分页显示bug,修改订购问题BUG

---
 src/views/productManage/productPriceViewer/index.vue |  104 ++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 73 insertions(+), 31 deletions(-)

diff --git a/src/views/productManage/productPriceViewer/index.vue b/src/views/productManage/productPriceViewer/index.vue
index b1b9b8e..0a7690d 100644
--- a/src/views/productManage/productPriceViewer/index.vue
+++ b/src/views/productManage/productPriceViewer/index.vue
@@ -250,7 +250,7 @@
                       :controls="true" 
                       size="large"
                       class="quantity-input"
-                      @change="(value) => handleQuantityChange(suite.id, value?value:1)"
+                      @change="(value) => handleQuantityChange(suite.id,value?value:1)"
                     />
                   </td>
                   <td class="th-center">
@@ -337,7 +337,7 @@
     <div class="footer" v-if="showPricePanel">
      <el-button type="primary" @click="handleOrder">绔嬪嵆璁㈣喘</el-button>
     </div>
-    <div class="footer" v-else>
+    <div class="footer" v-if="showOrderPanel">
       <el-button @click="returnPricePanel">杩斿洖浠锋牸瀵规瘮</el-button>
       <el-button type="primary" @click="submitOrder">鎻愪氦鐢宠</el-button>
     </div>
@@ -353,10 +353,10 @@
 import productPricingApi from '@/api/productPricingApi'
 import cartApi from '@/api/cartApi'
 import orderApi from '@/api/orderApi'
-import { ShoppingCart, Coin, Money } from '@element-plus/icons-vue'
 import { useUserInfo } from '@/stores/modules/userInfo'
 import { queryUserDetail } from '@/api/userInfo'
 import productApi from '@/api/productApi'
+import workFlowApi from '@/api/workFlowApi'
 
 const route = useRoute()
 
@@ -393,7 +393,7 @@
 const showOrderStatus = ref(false)
 // 妯℃嫙鐢ㄦ埛淇℃伅锛堝疄闄呭簲浠庣敤鎴风姸鎬佽幏鍙栵級
 const userStore = useUserInfo()
-let currentUserId = computed(() => userStore.getUserId || userStore.getUserInfo?.userId)
+const currentUserId = computed(() => userStore.getUserId || userStore.getUserInfo?.userId)
 const currentUnitId = computed(() => userStore.getUnitId || userStore.getUserInfo?.unitId || '')
 
 onMounted(async () => {
@@ -402,7 +402,8 @@
       const res: any = await queryUserDetail()
       if (res?.code === 200 && res.data) {
         userStore.updateUserDetail(res.data)
-        currentUserId = res.data.userId || res.data.id
+        // currentUserId.value = res.data.id || res.data.userId
+        console.log(currentUserId.value)
         userInfo.value = res.data
       } else {
         ElMessage.error(res?.msg || '鏃犳硶鑾峰彇鐢ㄦ埛淇℃伅锛岃鍏堢櫥褰�')
@@ -416,7 +417,8 @@
   }else{
     userInfo.value = userStore.getUserInfos
   }
-  
+  // 鑾峰彇璁㈣喘淇℃伅
+  fetchProductData(currentProductId.value ? currentProductId.value : '')
 })
 type PriceTypeKey = 'POINTS' | 'CURRENCY' | 'AGREEMENT' | 'FREE'
 interface OrderSuite extends PriceItem {
@@ -637,7 +639,8 @@
 
   loading.value = true
   try {
-    const res: any = await productPricingApi.listByProductId(productId)
+    // 鍙煡璇㈠凡鍚敤鐨勫畾浠�
+    const res: any = await productPricingApi.listBycondition({ productId: productId,isActive: true })
     if (res?.code === 200) {
       const list = Array.isArray(res.data) ? res.data : []
       const mapped: PriceItem[] = list.map((it: any) => {
@@ -707,6 +710,13 @@
   } finally {
     loading.value = false
   }
+  // 淇敼activeTab  榛樿鍊�
+  if(priceList.value.length > 0){
+
+    activeTab.value =  groupedPriceData.value.hasOwnProperty('enterprise')  ? 'enterprise'
+        :  groupedPriceData.value.hasOwnProperty('project') ? 'project' : 'personal'
+  }
+
 }
 
 // 鐩戝惉浜у搧ID鍙樺寲
@@ -714,7 +724,7 @@
   if (newProductId) {
     fetchProductData(newProductId)
   }
-},{ immediate: true })
+})
 
 // 濂椾欢閫夋嫨澶勭悊
 const handleSuiteSelect = (suiteId: number, checked: any) => {
@@ -786,6 +796,21 @@
   }else{
      paymentType = '鍗忚'
   }
+     let processdefId: string = ''
+     const type = hasAGREEMENT ? 'trade_agreement' : 'trade_point';
+     // 鑾峰彇宸ヤ綔娴佸弬鏁�
+     const  wkParamsRes: any = await workFlowApi.getWorkFlowParams({
+      type: type,
+      unitId: '1',
+      businessKey: type
+    })
+  if(wkParamsRes?.code === 200 && wkParamsRes.data?.processTemplateId){
+    processdefId = wkParamsRes.data.processTemplateId
+  }else {
+    ElMessage.error('鑾峰彇宸ヤ綔娴佸弬鏁板け璐�!')
+    return
+  }
+
   // 缁勮鍒涘缓璁㈠崟鍙傛暟锛圕reateOrderDTO锛�
   const payload = {
     userId: currentUserId.value,
@@ -795,6 +820,7 @@
     providerId: productHeader.value.createUserId,
     paymentType: paymentType,
     buyerRemarks: '',
+    processdefId: processdefId,
     items: items.map(it => ({
       pricingId: it.id,
       productId: it.productId,
@@ -829,25 +855,35 @@
         applyTime: data.applyTime ? String(data.applyTime) : new Date().toLocaleString()
       }
       // 璋冪敤宸ヤ綔娴佹帴鍙e彂璧峰鎵规祦绋嬶紝鎷垮埌娴佺▼瀹炰緥ID鍚庡洖鍐欒鍗晈orkflow_id
-      try {
-        // 鏍规嵁鏄惁鍖呭惈鍗忚鏄庣粏锛岄厤缃笉鍚屾祦绋嬪畾涔変笌涓氬姟Key锛堝厛鐢ㄩ潤鎬佸�煎崰浣嶏級
-        const processdefId = hasAGREEMENT ? 'Process_Agreement_Static' : 'Process_Points_Static'
-        const businessKey = hasAGREEMENT ? 'agreement_biz_key' : 'points_biz_key'
-        const wfRes: any = await orderApi.startWorkflowAndComplete({
-          processdefId,
-          userid: String(currentUserId.value || ''),
-          businessKey
-        })
-        if (wfRes?.code === 200 && wfRes.data?.processinstId) {
-          await orderApi.updateWorkflowId(data.orderId, wfRes.data.processinstId)
-        }
-      } catch (e) {
-        console.warn('鍚姩宸ヤ綔娴佸け璐ユ垨鏇存柊workflow_id澶辫触', e)
-      }
+      // 鏀惧悗绔鐞�
+      // try {
+      //   // 鏍规嵁鏄惁鍖呭惈鍗忚鏄庣粏锛岄厤缃笉鍚屾祦绋嬪畾涔変笌涓氬姟Key锛堝厛鐢ㄩ潤鎬佸�煎崰浣嶏級
+      //   // const processdefId = hasAGREEMENT ? 'Process_Agreement_Static' : 'Process_Points_Static'
+      //   const businessKey = hasAGREEMENT ? 'agreement_biz_key' : 'points_biz_key'
+      //   const type = hasAGREEMENT ? 'trade_agreement' : 'trade_point';
+      //   // 鑾峰彇宸ヤ綔娴佸弬鏁�
+      //   const  wkParamsRes: any = await workFlowApi.getWorkFlowParams({
+      //     type: type,
+      //     unitId: '1'
+      //   })
+      //   if(wkParamsRes?.code === 200 && wkParamsRes.data?.processTemplateId){
+      //     const wfRes: any = await workFlowApi.startWorkflowAndComplete({
+      //       processdefId: wkParamsRes.data.processTemplateId,
+      //       userid: String(currentUserId.value || ''),
+      //       businessKey: businessKey
+      //     })
+      //     if (wfRes?.code === 200 && wfRes.data?.processinstId) {
+      //       await orderApi.updateWorkflowId(data.orderId, wfRes.data.processinstId)
+      //     }
+      //   }
+      //
+      // } catch (e) {
+      //   console.warn('鍚姩宸ヤ綔娴佸け璐ユ垨鏇存柊workflow_id澶辫触', e)
+      // }
 
       // 娓呯┖璐墿杞︼紙鍚庣 + 鏈湴鐘舵�侊級
       try {
-        const clearRes: any = await cartApi.clearCart(currentUserId.value, currentUnitId.value)
+        const clearRes: any = await cartApi.clearCart(currentUserId.value, currentUnitId.value,currentProductId.value ? currentProductId.value : '')
         if (clearRes?.code === 200) {
           cartItems.value = []
           orderSuites.value = []
@@ -900,7 +936,7 @@
 
 const removeFromCart = async (pricingId: string) => {
   try {
-    const res: any = await cartApi.removeFromCart(currentUserId.value, currentUnitId.value, pricingId)
+    const res: any = await cartApi.removeFromCart(currentUserId.value, currentUnitId.value, currentProductId.value? currentProductId.value : '',pricingId)
     if (res?.code === 200) {
       ElMessage.success('宸蹭粠璐墿杞︾Щ闄�')
     } else {
@@ -912,10 +948,16 @@
   }
 }
 
-const updateCartItem = async (pricingId: number, quantity: number, duration: number) => {
+const updateCartItem = async (pricingId: number, quantity: number | null, duration: number | null) => {
   try {
     // 杩欓噷闇�瑕佹牴鎹疄闄呮帴鍙h皟鏁达紝鍙兘闇�瑕佷紶閫掓洿澶氬弬鏁�
-    const res: any = await cartApi.updateCartItem(currentUserId.value, currentUnitId.value, pricingId, quantity)
+    let res: any = {}
+    if(quantity){
+      res = await cartApi.updateCartItem(currentUserId.value, currentUnitId.value, currentProductId.value? currentProductId.value : '', pricingId, quantity)
+    }
+    if(duration){
+      res = await cartApi.updateCartItemDuration(currentUserId.value, currentUnitId.value, currentProductId.value? currentProductId.value : '', pricingId, duration)
+    }
     if (res?.code === 200) {
       ElMessage.success('璐墿杞﹀凡鏇存柊')
     } else {
@@ -930,7 +972,7 @@
 const fetchCartItems = async () => {
   cartLoading.value = true
   try {
-    const res: any = await cartApi.getCartItems(currentUserId.value, currentUnitId.value)
+    const res: any = await cartApi.getCartItems(currentUserId.value, currentUnitId.value, currentProductId.value? currentProductId.value : '')
     if (res?.code === 200) {
       cartItems.value = res.data || []
       // 灏嗚喘鐗╄溅鏁版嵁杞崲涓鸿鍗曞浠舵牸寮�
@@ -972,7 +1014,7 @@
 // 澶勭悊鏁伴噺鍙樺寲
 const handleQuantityChange = async (pricingId: number, quantity: number) => {
   try {
-    await updateCartItem(pricingId, quantity, 1) // 鏆傛椂浼犻�掗粯璁uration涓�1
+    await updateCartItem(pricingId, quantity, null) // 鏆傛椂浼犻�掗粯璁uration涓�1
   } catch (error) {
     console.error('鏇存柊鏁伴噺澶辫触:', error)
   }
@@ -982,7 +1024,7 @@
 const handleDurationChange = async (pricingId: number, duration: number) => {
   try {
     // 杩欓噷鍙兘闇�瑕佹牴鎹疄闄呮帴鍙h皟鏁达紝浼犻�抎uration鍙傛暟
-    await updateCartItem(pricingId, 1, duration) // 鏆傛椂浼犻�掗粯璁uantity涓�1
+    await updateCartItem(pricingId, null, duration) // 鏆傛椂浼犻�掗粯璁uantity涓�1
   } catch (error) {
     console.error('鏇存柊骞撮檺澶辫触:', error)
   }
@@ -1453,7 +1495,7 @@
     white-space: nowrap; 
     overflow: hidden; 
     text-overflow: ellipsis;
-    line-height: 1;
+    line-height: 2;
   }
   .label { color:#606266; font-weight: 500; }
   .value { color:#303133; }

--
Gitblit v1.8.0