p-honggang.li
9 天以前 bd125eecd57d2f4e559c6170d20157591300fe3d
修改购物车等BUG
11个文件已修改
201 ■■■■ 已修改文件
src/api/cartApi.ts 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/orderApi.ts 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/pointsApi.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/productApi.ts 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/productPricingApi.ts 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/workFlowApi.ts 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/modules/userInfo.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/approveManage/tradeApproval/approve.vue 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/approveManage/tradeApproval/list.vue 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productManage/price/index.vue 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/productManage/productPriceViewer/index.vue 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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
  }
}
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({
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
  },
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
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({
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 正式
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
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 => {
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("工作流id为空不能进行工作流任务提交")
        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 || '驳回失败')
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)
}
// 获取状态类型
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
src/views/productManage/productPriceViewer/index.vue
@@ -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 {
    // 这里需要根据实际接口调整,可能需要传递更多参数
    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) // 暂时传递默认duration为1
    await updateCartItem(pricingId, quantity, null) // 暂时传递默认duration为1
  } catch (error) {
    console.error('更新数量失败:', error)
  }
@@ -992,7 +1007,7 @@
const handleDurationChange = async (pricingId: number, duration: number) => {
  try {
    // 这里可能需要根据实际接口调整,传递duration参数
    await updateCartItem(pricingId, 1, duration) // 暂时传递默认quantity为1
    await updateCartItem(pricingId, null, duration) // 暂时传递默认quantity为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; }