| | |
| | | }, |
| | | |
| | | // 从购物车移除商品 |
| | | 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 |
| | | }, |
| | | |
| | |
| | | }, |
| | | |
| | | // 获取购物车商品列表 |
| | | 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 |
| | | } |
| | | } |
| | |
| | | }) 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({ |
| | |
| | | // 保存积分规则配置 |
| | | savePointsRules(data: object): ApiPromise { |
| | | return createAxios({ |
| | | url: `${url}rules/update`, |
| | | url: `${url}rule/update`, |
| | | data: data, |
| | | }) as ApiPromise |
| | | }, |
| | |
| | | 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 |
| | |
| | | }) as ApiPromise |
| | | }, |
| | | |
| | | // 根据产品ID获取定价列表 |
| | | listBycondition(params: object): ApiPromise { |
| | | return createAxios({ |
| | | url: `${baseUrl}/condition`, |
| | | method: 'get', |
| | | params, |
| | | }) as ApiPromise |
| | | }, |
| | | |
| | | // 删除定价 |
| | | remove(id: string | number): ApiPromise { |
| | | return createAxios({ |
| | |
| | | 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({ |
| | |
| | | }, |
| | | 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 |
| | |
| | | // 用户信息状态管理 |
| | | 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 => { |
| | |
| | | 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() |
| | |
| | | } |
| | | |
| | | // 获取用户信息 |
| | | // 获取用户信息 |
| | | 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 = { |
| | |
| | | items, |
| | | pointTotal: pointTotalNum.toLocaleString(), |
| | | cashTotal: cashTotalNum.toLocaleString(), |
| | | workflowId: data.workflowId || data.processinstId || '' |
| | | }) |
| | | |
| | | // 初始化表单数据 |
| | |
| | | // 审批通过后,使用新的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 || '审批通过失败') |
| | |
| | | // 驳回订单,更新订单状态到上一个状态 |
| | | 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 || '驳回失败') |
| | |
| | | <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" |
| | |
| | | // 获取产品类型选项 |
| | | 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, |
| | |
| | | // 清空产品子级选择 |
| | | query.productSubType = '' |
| | | // 获取对应的产品子级选项 |
| | | await getProductSubTypeOptions(value) |
| | | // await getProductSubTypeOptions(value) |
| | | } |
| | | |
| | | // 获取状态类型 |
| | |
| | | typeName: string |
| | | describe: string |
| | | shelfStatus?: '待上架' | '已上架' | '已下架' |
| | | listingStatusName?: '' |
| | | } |
| | | |
| | | interface PriceItem { |
| | |
| | | }) |
| | | |
| | | 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 '已上架': |
| | |
| | | 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 |
| | |
| | | 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' |
| | |
| | | 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) => { |
| | |
| | | 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 |
| | |
| | | |
| | | // 清空购物车(后端 + 本地状态) |
| | | 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 = [] |
| | |
| | | |
| | | 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 { |
| | |
| | | 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 { |
| | |
| | | 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 || [] |
| | | // 将购物车数据转换为订单套件格式 |
| | |
| | | // 处理数量变化 |
| | | 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; } |