| | |
| | | :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"> |
| | |
| | | <td class="value">{{ statusText(orderStatus.status) }}</td> |
| | | <td></td> |
| | | <td class="value link"> |
| | | <el-link type="primary" @click="viewOrder">查看订单信息</el-link> |
| | | <!-- <el-link type="primary" @click="viewOrder">查看订单信息</el-link>--> |
| | | </td> |
| | | </tr> |
| | | </tbody> |
| | |
| | | <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> |
| | |
| | | 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() |
| | | |
| | |
| | | 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 () => { |
| | |
| | | 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 || '无法获取用户信息,请先登录') |
| | |
| | | }else{ |
| | | userInfo.value = userStore.getUserInfos |
| | | } |
| | | |
| | | // 获取订购信息 |
| | | fetchProductData(currentProductId.value ? currentProductId.value : '') |
| | | }) |
| | | type PriceTypeKey = 'POINTS' | 'CURRENCY' | 'AGREEMENT' | 'FREE' |
| | | interface OrderSuite extends PriceItem { |
| | |
| | | |
| | | 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) => { |
| | |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | | // 修改activeTab 默认值 |
| | | if(priceList.value.length > 0){ |
| | | |
| | | activeTab.value = groupedPriceData.value.hasOwnProperty('enterprise') ? 'enterprise' |
| | | : groupedPriceData.value.hasOwnProperty('project') ? 'project' : 'personal' |
| | | } |
| | | |
| | | } |
| | | |
| | | // 监听产品ID变化 |
| | |
| | | if (newProductId) { |
| | | fetchProductData(newProductId) |
| | | } |
| | | },{ immediate: true }) |
| | | }) |
| | | |
| | | // 套件选择处理 |
| | | const handleSuiteSelect = (suiteId: number, checked: any) => { |
| | |
| | | }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 |
| | | } |
| | | |
| | | // 组装创建订单参数(CreateOrderDTO) |
| | | const payload = { |
| | | userId: currentUserId.value, |
| | |
| | | providerId: productHeader.value.createUserId, |
| | | paymentType: paymentType, |
| | | buyerRemarks: '', |
| | | processdefId: processdefId, |
| | | items: items.map(it => ({ |
| | | pricingId: it.id, |
| | | productId: it.productId, |
| | |
| | | applyTime: data.applyTime ? String(data.applyTime) : new Date().toLocaleString() |
| | | } |
| | | // 调用工作流接口发起审批流程,拿到流程实例ID后回写订单workflow_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 = [] |
| | |
| | | |
| | | 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 { |
| | |
| | | } |
| | | } |
| | | |
| | | const updateCartItem = async (pricingId: number, quantity: number, duration: number) => { |
| | | const updateCartItem = async (pricingId: number, quantity: number | null, duration: number | null) => { |
| | | 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? 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 { |
| | |
| | | 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 || [] |
| | | // 将购物车数据转换为订单套件格式 |
| | |
| | | // 处理数量变化 |
| | | 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) |
| | | } |
| | |
| | | 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) |
| | | } |
| | |
| | | white-space: nowrap; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | line-height: 1; |
| | | line-height: 2; |
| | | } |
| | | .label { color:#606266; font-weight: 500; } |
| | | .value { color:#303133; } |