From bd125eecd57d2f4e559c6170d20157591300fe3d Mon Sep 17 00:00:00 2001
From: p-honggang.li <p-honggang.li@pcitc.com>
Date: 星期四, 04 九月 2025 20:57:44 +0800
Subject: [PATCH] 修改购物车等BUG

---
 src/api/productPricingApi.ts                         |    9 ++
 src/api/productApi.ts                                |   11 ++
 src/views/productManage/productPriceViewer/index.vue |   45 +++++++---
 src/views/approveManage/tradeApproval/approve.vue    |   39 +++++++++
 src/api/orderApi.ts                                  |    9 --
 src/views/approveManage/tradeApproval/list.vue       |   14 +-
 src/api/cartApi.ts                                   |   25 ++++--
 src/api/pointsApi.ts                                 |    2 
 src/api/workFlowApi.ts                               |   32 +++++++
 src/views/productManage/price/index.vue              |   15 +++
 src/stores/modules/userInfo.ts                       |    2 
 11 files changed, 157 insertions(+), 46 deletions(-)

diff --git a/src/api/cartApi.ts b/src/api/cartApi.ts
index 20cf968..55e853c 100644
--- a/src/api/cartApi.ts
+++ b/src/api/cartApi.ts
@@ -15,20 +15,29 @@
   },
 
   // 浠庤喘鐗╄溅绉婚櫎鍟嗗搧
-  removeFromCart(userId: string, unitId: string, pricingId: string): ApiPromise {
+  removeFromCart(userId: string, unitId: string, productId:string, pricingId: string): ApiPromise {
     return createAxios({
       url: `${baseUrl}/remove`,
       method: 'delete',
-      params: { userId, unitId, pricingId }
+      params: { userId, unitId, productId,pricingId }
     }) as ApiPromise
   },
 
   // 鏇存柊璐墿杞﹀晢鍝佹暟閲�
-  updateCartItem(userId: string, unitId: string, pricingId: number, quantity: number): ApiPromise {
+  updateCartItem(userId: string, unitId: string,productId: string, pricingId: number, quantity: number): ApiPromise {
     return createAxios({
       url: `${baseUrl}/update`,
       method: 'put',
-      params: { userId, unitId, pricingId, quantity }
+      params: { userId, unitId, productId,pricingId, quantity }
+    }) as ApiPromise
+  },
+
+  // 鏇存柊璐墿杞﹀勾闄�
+  updateCartItemDuration(userId: string, unitId: string,productId: string, pricingId: number, duration: number): ApiPromise {
+    return createAxios({
+      url: `${baseUrl}/update/duration`,
+      method: 'put',
+      params: { userId, unitId, productId,pricingId, duration }
     }) as ApiPromise
   },
 
@@ -42,20 +51,20 @@
   },
 
   // 鑾峰彇璐墿杞﹀晢鍝佸垪琛�
-  getCartItems(userId: string, unitId: string): ApiPromise {
+  getCartItems(userId: string, unitId: string,productId: string): ApiPromise {
     return createAxios({
       url: `${baseUrl}/items`,
       method: 'get',
-      params: { userId, unitId }
+      params: { userId, unitId, productId }
     }) as ApiPromise
   },
 
   // 娓呯┖璐墿杞�
-  clearCart(userId: string, unitId: string): ApiPromise {
+  clearCart(userId: string, unitId: string, productId: string): ApiPromise {
     return createAxios({
       url: `${baseUrl}/clear`,
       method: 'delete',
-      params: { userId, unitId }
+      params: { userId, unitId, productId }
     }) as ApiPromise
   }
 }
diff --git a/src/api/orderApi.ts b/src/api/orderApi.ts
index de14af6..5ad9150 100644
--- a/src/api/orderApi.ts
+++ b/src/api/orderApi.ts
@@ -154,15 +154,6 @@
     }) as ApiPromise
   },
 
-  // 鍚姩骞跺畬鎴愬鎵规祦绋嬶紙澶栭儴宸ヤ綔娴佹湇鍔★級
-  startWorkflowAndComplete(data: { processdefId: string; userid: string; businessKey: string }): ApiPromise {
-    return createAxios({
-      url: `/test/app/workflow/startProcessAndComplete`,
-      method: 'post',
-      data
-    }) as ApiPromise
-  },
-
   // 鏇存柊璁㈠崟鐨勫伐浣滄祦ID
   updateWorkflowId(orderId: string, workflowId: string): ApiPromise {
     return createAxios({
diff --git a/src/api/pointsApi.ts b/src/api/pointsApi.ts
index acd1e4b..3c1e0e4 100644
--- a/src/api/pointsApi.ts
+++ b/src/api/pointsApi.ts
@@ -27,7 +27,7 @@
   // 淇濆瓨绉垎瑙勫垯閰嶇疆
   savePointsRules(data: object): ApiPromise {
     return createAxios({
-      url: `${url}rules/update`,
+      url: `${url}rule/update`,
       data: data,
     }) as ApiPromise
   },
diff --git a/src/api/productApi.ts b/src/api/productApi.ts
index f2ac4cd..e8bd47a 100644
--- a/src/api/productApi.ts
+++ b/src/api/productApi.ts
@@ -29,7 +29,16 @@
         method: 'post',
         data: data,
     }) as ApiPromise
-   }
+   },
+    // 鏍规嵁ID鑾峰彇浜у搧璇︽儏
+    updateProductStatus(data: any): ApiPromise {
+        return createAxios({
+            baseURL: '/api',
+            url: `${url}updateListingStatus`,
+            method: 'post',
+            data: data,
+        }) as ApiPromise
+    },
 }
 
 export default productApi
diff --git a/src/api/productPricingApi.ts b/src/api/productPricingApi.ts
index 32e78b3..8f19d4a 100644
--- a/src/api/productPricingApi.ts
+++ b/src/api/productPricingApi.ts
@@ -30,6 +30,15 @@
     }) as ApiPromise
   },
 
+  // 鏍规嵁浜у搧ID鑾峰彇瀹氫环鍒楄〃
+  listBycondition(params: object): ApiPromise {
+    return createAxios({
+      url: `${baseUrl}/condition`,
+      method: 'get',
+      params,
+    }) as ApiPromise
+  },
+
   // 鍒犻櫎瀹氫环
   remove(id: string | number): ApiPromise {
     return createAxios({
diff --git a/src/api/workFlowApi.ts b/src/api/workFlowApi.ts
index eb9bf22..da3e25a 100644
--- a/src/api/workFlowApi.ts
+++ b/src/api/workFlowApi.ts
@@ -1,5 +1,6 @@
 import createAxios from '@/utils/axios'
-
+let url = 'http://192.168.20.51:7098/app'
+// http://10.100.19.12:9090 姝e紡
 const workFlowApi = {
   getWorkFlowParams(data: object = {}) : ApiPromise{
     return createAxios({
@@ -10,6 +11,33 @@
         },
         data: data
     }) as ApiPromise
-  }
+  },
+// 鍚姩骞跺畬鎴愬鎵规祦绋嬶紙澶栭儴宸ヤ綔娴佹湇鍔★級
+    startWorkflowAndComplete(data: { processdefId: string; userid: string; businessKey: string }): ApiPromise {
+        return createAxios({
+            baseURL: `${url}/workflow`,
+            url: `/startProcessAndComplete`,
+            method: 'post',
+            data
+        }) as ApiPromise
+    },
+    // 娴佺▼鎻愪氦
+    completeWorkflow(data: { taskId: string; userid: string; commponet: string }): ApiPromise {
+        return createAxios({
+            baseURL: `${url}/workflow`,
+            url: `/complete`,
+            method: 'post',
+            data
+        }) as ApiPromise
+    },
+    // 椹冲洖鍒拌捣鐐�
+    rejectStartNodeWorkflow(data: { taskId: string; userid: string; commponet: string }): ApiPromise {
+        return createAxios({
+            baseURL: `${url}/workflow`,
+            url: `/rejectStartNode`,
+            method: 'post',
+            data
+        }) as ApiPromise
+    },
 }
 export default  workFlowApi
\ No newline at end of file
diff --git a/src/stores/modules/userInfo.ts b/src/stores/modules/userInfo.ts
index 4d62116..68a3b15 100644
--- a/src/stores/modules/userInfo.ts
+++ b/src/stores/modules/userInfo.ts
@@ -1,8 +1,6 @@
 // 鐢ㄦ埛淇℃伅鐘舵�佺鐞�
-import { update } from 'lodash'
 import { defineStore } from 'pinia'
 import { UserInfo } from '@/stores/interface'
-import router from '@/router/index'
 
 export const useUserInfo = defineStore('userInfo', {
   state: (): UserInfo => {
diff --git a/src/views/approveManage/tradeApproval/approve.vue b/src/views/approveManage/tradeApproval/approve.vue
index 9c1494c..c9da9b0 100644
--- a/src/views/approveManage/tradeApproval/approve.vue
+++ b/src/views/approveManage/tradeApproval/approve.vue
@@ -270,6 +270,8 @@
 import { useUserInfo } from '@/stores/modules/userInfo'
 import createAxios from '@/utils/axios'
 import productApi from '@/api/productApi'
+import sysUserService from "@/api/sysUser";
+import workFlowApi from "@/api/workFlowApi";
 
 const route = useRoute()
 const router = useRouter()
@@ -370,6 +372,20 @@
     }
     
     // 鑾峰彇鐢ㄦ埛淇℃伅
+    // 鑾峰彇鐢ㄦ埛淇℃伅
+    try {
+      const userRes: any = await sysUserService.getUserdetail({ userId: data.userId })
+      if (userRes?.code === 200 && userRes.data) {
+        // 鐢ㄤ骇鍝佽鎯呰ˉ鍏ㄥご淇℃伅
+        data.unitName = userRes.data.unitName || data.unitName
+        data.userName = userRes.data.name || data.userName
+        data.userDept = userRes.data.departmentName || data.userDept
+        data.userPhone = userRes.data.phone || data.userPhone
+        data.userAccount = userRes.data.username || data.userAccount
+      }
+    }catch (e){
+
+    }
 
     // 鏄犲皠璁㈠崟璇︽儏澶撮儴淇℃伅
     const head = {
@@ -420,6 +436,7 @@
       items,
       pointTotal: pointTotalNum.toLocaleString(),
       cashTotal: cashTotalNum.toLocaleString(),
+      workflowId: data.workflowId || data.processinstId || ''
     })
 
     // 鍒濆鍖栬〃鍗曟暟鎹�
@@ -502,6 +519,19 @@
       // 瀹℃壒閫氳繃鍚庯紝浣跨敤鏂扮殑API鎺ュ彛鏇存柊璁㈠崟鐘舵�佸埌涓嬩竴涓姸鎬�
       await orderApi.updateOrderStatusToNext(orderId)
       ElMessage.success('瀹℃壒閫氳繃鎴愬姛')
+      if(!detail.workflowId.value){
+        ElMessage.error("宸ヤ綔娴乮d涓虹┖涓嶈兘杩涜宸ヤ綔娴佷换鍔℃彁浜�")
+        return
+      }
+      // 璋冪敤宸ヤ綔娴�
+      const wfRes: any = await workFlowApi.completeWorkflow({
+        taskId: String(detail.workflowId.value),
+        userid: userStore.getUserId,
+        commponet: '瀹℃牳閫氳繃'
+      })
+      if (wfRes?.code === 200 && wfRes.data?.processinstId) {
+         console.log('宸ヤ綔娴佹彁浜ゆ垚鍔�')
+      }
       router.back()
     } else {
       ElMessage.error(result?.msg || '瀹℃壒閫氳繃澶辫触')
@@ -555,6 +585,15 @@
       // 椹冲洖璁㈠崟锛屾洿鏂拌鍗曠姸鎬佸埌涓婁竴涓姸鎬�
       await orderApi.updateOrderStatusToPrevious(orderId)
       ElMessage.success('椹冲洖鎴愬姛')
+      // 璋冪敤宸ヤ綔娴�
+      const wfRes: any = await workFlowApi.rejectStartNodeWorkflow({
+        taskId: String(detail.workflowId.value),
+        userid: userStore.getUserId,
+        commponet: '椹冲洖'
+      })
+      if (wfRes?.code === 200 && wfRes.data?.processinstId) {
+        console.log('宸ヤ綔娴侀┏鍥炴垚鍔�')
+      }
       router.back()
     } else {
       ElMessage.error(result?.msg || '椹冲洖澶辫触')
diff --git a/src/views/approveManage/tradeApproval/list.vue b/src/views/approveManage/tradeApproval/list.vue
index 872c0bb..d123d48 100644
--- a/src/views/approveManage/tradeApproval/list.vue
+++ b/src/views/approveManage/tradeApproval/list.vue
@@ -35,11 +35,11 @@
               <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"
@@ -358,7 +358,7 @@
 // 鑾峰彇浜у搧绫诲瀷閫夐」
 const getProductTypeOptions = async () => {
   try {
-    const res = await productApi.getCategoryByParent({ parentCode: '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,
@@ -423,7 +423,7 @@
   // 娓呯┖浜у搧瀛愮骇閫夋嫨
   query.productSubType = ''
   // 鑾峰彇瀵瑰簲鐨勪骇鍝佸瓙绾ч�夐」
-  await getProductSubTypeOptions(value)
+  // await getProductSubTypeOptions(value)
 }
 
 // 鑾峰彇鐘舵�佺被鍨�
diff --git a/src/views/productManage/price/index.vue b/src/views/productManage/price/index.vue
index 57e9d93..6c6701c 100644
--- a/src/views/productManage/price/index.vue
+++ b/src/views/productManage/price/index.vue
@@ -247,6 +247,7 @@
   typeName: string
   describe: string
   shelfStatus?: '寰呬笂鏋�' | '宸蹭笂鏋�' | '宸蹭笅鏋�'
+  listingStatusName?: ''
 }
 
 interface PriceItem {
@@ -277,7 +278,7 @@
 })
 
 const productDetail = ref<ProductDetail | null>(null)
-const shelfStatus = computed(() => productDetail.value?.shelfStatus || '寰呬笂鏋�')
+const shelfStatus = computed(() => productDetail.value?.listingStatusName || '寰呬笂鏋�')
 const statusClass = computed(() => {
   switch (shelfStatus.value) {
     case '宸蹭笂鏋�':
@@ -824,6 +825,18 @@
         return
       }
       ElMessage.success('鏂板缓鎴愬姛')
+      // 淇敼浜у搧鐘舵�佷负宸茶浠�
+      // 鍒ゆ柇 浜у搧瀹氫环鍒楄〃鏄惁涓虹┖锛屼负绌哄垯鏇存柊鐘舵�侊紝涓嶄负绌哄垯璇存槑鏇存柊杩囦簡锛屼笉闇�瑕佸湪姝ゆ洿鏂�
+      if (priceList.value.length === 0) {
+        const updateParams = {
+          id: currentProductId.value,
+          listingStatus: 'PRICED'
+        }
+        const res: any = await productApi.updateProductStatus(updateParams)
+        if (res?.code !== 200) {
+          console.log('浜у搧鐘舵�佹洿鏂板け璐ワ紒锛�')
+        }
+      }
     }
 
     dialogVisible.value = false
diff --git a/src/views/productManage/productPriceViewer/index.vue b/src/views/productManage/productPriceViewer/index.vue
index 5d87a57..3c9e4fa 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">
@@ -353,7 +353,6 @@
 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'
@@ -394,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 () => {
@@ -403,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 || '鏃犳硶鑾峰彇鐢ㄦ埛淇℃伅锛岃鍏堢櫥褰�')
@@ -417,7 +417,8 @@
   }else{
     userInfo.value = userStore.getUserInfos
   }
-  
+  // 鑾峰彇璁㈣喘淇℃伅
+  fetchProductData(currentProductId.value ? currentProductId.value : '')
 })
 type PriceTypeKey = 'POINTS' | 'CURRENCY' | 'AGREEMENT' | 'FREE'
 interface OrderSuite extends PriceItem {
@@ -638,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) => {
@@ -708,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鍙樺寲
@@ -715,7 +724,7 @@
   if (newProductId) {
     fetchProductData(newProductId)
   }
-},{ immediate: true })
+})
 
 // 濂椾欢閫夋嫨澶勭悊
 const handleSuiteSelect = (suiteId: number, checked: any) => {
@@ -841,7 +850,7 @@
           unitId: '1'
         })
         if(wkParamsRes?.code === 200 && wkParamsRes.data?.processTemplateId){
-          const wfRes: any = await orderApi.startWorkflowAndComplete({
+          const wfRes: any = await workFlowApi.startWorkflowAndComplete({
             processdefId: wkParamsRes.data.processTemplateId,
             userid: String(currentUserId.value || ''),
             businessKey: businessKey
@@ -857,7 +866,7 @@
 
       // 娓呯┖璐墿杞︼紙鍚庣 + 鏈湴鐘舵�侊級
       try {
-        const clearRes: any = await cartApi.clearCart(currentUserId.value, currentUnitId.value)
+        const clearRes: any = await cartApi.clearCart(currentUserId.value, currentUnitId.value,currentProductId.value)
         if (clearRes?.code === 200) {
           cartItems.value = []
           orderSuites.value = []
@@ -910,7 +919,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,pricingId)
     if (res?.code === 200) {
       ElMessage.success('宸蹭粠璐墿杞︾Щ闄�')
     } else {
@@ -925,7 +934,13 @@
 const updateCartItem = async (pricingId: number, quantity: number, duration: number) => {
   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, pricingId, quantity)
+    }
+    if(duration){
+      res = await cartApi.updateCartItemDuration(currentUserId.value, currentUnitId.value, currentProductId.value, pricingId, duration)
+    }
     if (res?.code === 200) {
       ElMessage.success('璐墿杞﹀凡鏇存柊')
     } else {
@@ -940,7 +955,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)
     if (res?.code === 200) {
       cartItems.value = res.data || []
       // 灏嗚喘鐗╄溅鏁版嵁杞崲涓鸿鍗曞浠舵牸寮�
@@ -982,7 +997,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)
   }
@@ -992,7 +1007,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)
   }
@@ -1463,7 +1478,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