feat: 订单功能完善
This commit is contained in:
@@ -3,15 +3,20 @@
|
||||
<!-- 卡片头部 -->
|
||||
<view class="card-header">
|
||||
<view class="status-info">
|
||||
<image class="status-icon" :src="ICON_MAP[orderData.orderType]"></image>
|
||||
<view class="order-title">{{ orderData.commodityName }}</view>
|
||||
<image class="status-icon" :src="getStatusIcon()"></image>
|
||||
<view class="order-title">
|
||||
{{ orderData.workOrderTypeName || orderData.commodityName }}
|
||||
</view>
|
||||
<image class="arrow-icon" src="./images/arrow.png"></image>
|
||||
</view>
|
||||
<view
|
||||
v-if="orderData.status !== 'pending'"
|
||||
:class="['status-tag', `tag-${orderData.orderStatus}`]"
|
||||
:class="[
|
||||
'status-tag',
|
||||
`tag-${orderData.orderStatus || orderData.workOrderStatus}`,
|
||||
]"
|
||||
>
|
||||
{{ getStatusText(orderData.orderStatus) }}
|
||||
{{ getStatusText(orderData.orderStatus || orderData.workOrderStatus) }}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -19,31 +24,19 @@
|
||||
<Divider />
|
||||
|
||||
<!-- 卡片内容 -->
|
||||
<view class="card-content">
|
||||
<view class="info-row">
|
||||
<text class="label">创建时间:</text>
|
||||
<text class="value">{{ orderData.createTime }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">联系房客:</text>
|
||||
<text class="value">{{ orderData.visitorName }}</text>
|
||||
</view>
|
||||
<view class="info-row">
|
||||
<text class="label">联系电话:</text>
|
||||
<text class="value">{{ orderData.contactPhone }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<OrderCardContent :order-data="orderData" />
|
||||
|
||||
<!-- 操作区域 -->
|
||||
<view v-if="orderData.status === 'pending'" class="action-area">
|
||||
<view v-if="shouldShowActionArea()" class="action-area">
|
||||
<button class="action-btn" @click.stop="handleCall">立即呼叫</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { defineProps } from "vue";
|
||||
import { defineProps, defineExpose } from "vue";
|
||||
import Divider from "@/components/Divider/index.vue";
|
||||
import OrderCardContent from "./OrderCardContent.vue";
|
||||
import serviceIcon from "./images/service.png";
|
||||
import ticketIcon from "./images/ticket.png";
|
||||
import hotelIcon from "./images/hotel.png";
|
||||
@@ -55,11 +48,17 @@ const props = defineProps({
|
||||
required: true,
|
||||
default: () => ({
|
||||
id: "",
|
||||
title: "",
|
||||
workOrderTypeName: "",
|
||||
createTime: "",
|
||||
contactName: "",
|
||||
contactPhone: "",
|
||||
orderStatus: "0", // pending-待处理, completed-已完成, cancelled-已取消
|
||||
orderType: undefined, // 0-酒店订单, 1-门票订单, 2-其他订单, undefined-工单
|
||||
orderNumber: "", // 订单编号
|
||||
checkInTime: "", // 入住时间
|
||||
visitorName: "", // 游客姓名
|
||||
commodityAmount: 0, // 份数
|
||||
workOrderStatus: 0, // 工单状态:0-待处理, 1-已完成
|
||||
}),
|
||||
},
|
||||
});
|
||||
@@ -69,23 +68,53 @@ const emit = defineEmits(["click", "call", "complete"]);
|
||||
|
||||
// 图标映射
|
||||
const ICON_MAP = {
|
||||
0: serviceIcon,
|
||||
1: ticketIcon,
|
||||
2: hotelIcon,
|
||||
0: hotelIcon, // 酒店订单
|
||||
1: ticketIcon, // 门票订单
|
||||
2: hotelIcon, // 其他订单
|
||||
};
|
||||
|
||||
// 获取状态图标
|
||||
const getStatusIcon = () => {
|
||||
// 工单情况:orderType 为 undefined
|
||||
if (props.orderData.orderType === undefined) {
|
||||
return serviceIcon;
|
||||
}
|
||||
// 订单情况:根据 orderType 返回对应图标
|
||||
return ICON_MAP[props.orderData.orderType] || serviceIcon;
|
||||
};
|
||||
|
||||
// 判断是否显示操作区域
|
||||
const shouldShowActionArea = () => {
|
||||
// 工单情况:orderType 为 undefined,且 workOrderStatus = 0 时显示
|
||||
if (props.orderData.orderType === undefined) {
|
||||
return props.orderData.workOrderStatus === "0";
|
||||
}
|
||||
};
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status) => {
|
||||
const statusMap = {
|
||||
// 工单情况:orderType 为 undefined
|
||||
if (props.orderData.orderType === undefined) {
|
||||
const workOrderStatusMap = {
|
||||
0: "待接单",
|
||||
1: "处理中",
|
||||
2: "已完成",
|
||||
3: "已关闭",
|
||||
};
|
||||
return workOrderStatusMap[status] || "未知状态";
|
||||
}
|
||||
|
||||
// 订单情况:orderType 有值
|
||||
const orderStatusMap = {
|
||||
0: "待支付",
|
||||
1: "待确认",
|
||||
2: "待使用",
|
||||
3: "已取消",
|
||||
4: "已退款",
|
||||
5: "已退款",
|
||||
4: "退款中",
|
||||
5: "已推荐",
|
||||
6: "已完成",
|
||||
};
|
||||
return statusMap[status] || "未知状态";
|
||||
return orderStatusMap[status] || "未知状态";
|
||||
};
|
||||
|
||||
// 处理卡片点击
|
||||
@@ -98,11 +127,6 @@ const handleCall = () => {
|
||||
emit("call", props.orderData);
|
||||
};
|
||||
|
||||
// 处理完成
|
||||
const handleComplete = () => {
|
||||
emit("complete", props.orderData);
|
||||
};
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({
|
||||
getStatusText,
|
||||
|
||||
Reference in New Issue
Block a user