| | |
| | | import orderApi from '@/api/orderApi' |
| | | import { useUserInfo } from '@/stores/modules/userInfo' |
| | | import createAxios from '@/utils/axios' |
| | | import {queryUserDetail} from "@/api/userInfo"; |
| | | import productApi from "@/api/productApi"; |
| | | import sysUserService from "@/api/sysUser"; |
| | | |
| | | const route = useRoute() |
| | | const router = useRouter() |
| | |
| | | onMounted(async () => { |
| | | const orderId = String(route.params.id || '') |
| | | if (!orderId) return |
| | | |
| | | // 获取用户信息 |
| | | if (!userStore.getUserId) { |
| | | try { |
| | | const res: any = await queryUserDetail() |
| | | if (res?.code === 200 && res.data) { |
| | | userStore.updateUserDetail(res.data) |
| | | } else { |
| | | ElMessage.error(res?.msg || '无法获取用户信息,请先登录') |
| | | return |
| | | } |
| | | } catch (e) { |
| | | console.error('获取用户详情失败:', e) |
| | | ElMessage.error('获取用户信息失败,请稍后重试') |
| | | return |
| | | } |
| | | } |
| | | try { |
| | | const res = (await orderApi.getOrderDetail(orderId)) as any |
| | | const data = res?.data || {} |
| | | |
| | | const statusName: string = data.orderStatus || '' |
| | | const uiStatus = statusServerToUi[statusName] || 'INFO' |
| | | |
| | | // 根据产品id获取产品信息,更新头部展示 |
| | | try { |
| | | if (data.productId) { |
| | | const detailRes: any = await productApi.getProductById({ id: data.productId }) |
| | | if (detailRes?.code === 200 && detailRes.data) { |
| | | // 用产品详情补全头信息 |
| | | data.productName = detailRes.data.name || data.productName |
| | | data.providerName = detailRes.data.submissionUnit || data.providerName |
| | | data.industry = detailRes.data.industrialChainName || data.industry |
| | | data.productDesc = detailRes.data.describe || data.productDesc |
| | | data.projectUnit = detailRes.data.importantAreaName || data.productDesc |
| | | data.productType = detailRes.data.typeName || data.productDesc |
| | | } |
| | | } |
| | | } catch (e) { |
| | | // 忽略产品详情失败,不阻塞订单详情 |
| | | } |
| | | |
| | | // 获取用户信息 |
| | | 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 = { |
| | |
| | | const submit = async () => { |
| | | try { |
| | | const orderId = String(route.params.id || '') |
| | | const userId = userStore.getUserId ? Number(userStore.getUserId) : undefined |
| | | const userId = userStore.getUserId ? userStore.getUserId : undefined |
| | | |
| | | if (!orderId || !userId) { |
| | | ElMessage.error('订单ID或用户ID不能为空') |
| | |
| | | }) |
| | | |
| | | const orderId = String(route.params.id || '') |
| | | const userId = userStore.getUserId ? Number(userStore.getUserId) : undefined |
| | | const userId = userStore.getUserId ? userStore.getUserId : undefined |
| | | const content = evaluationForm.content.trim() |
| | | |
| | | if (!orderId || !userId) { |
| | |
| | | }) |
| | | |
| | | if (result && result.code === 200) { |
| | | // 更新订单状态进入下一个状态 |
| | | await orderApi.updateOrderStatusToNext(orderId) |
| | | // 更新订单评价状态为已评价 |
| | | await orderApi.updateOrderStatusToIsEvaluate(orderId) |
| | | ElMessage.success('评价提交成功') |
| | | router.back() |
| | | evaluationLoading.value = false |