feat: 创建工单的类型拉取
This commit is contained in:
@@ -7,13 +7,19 @@
|
||||
<view class="order-content">
|
||||
<view class="order-item">
|
||||
<image src="./images/icon_service.png" class="order-icon"></image>
|
||||
<text class="order-description">加一台麻将机</text>
|
||||
<text class="order-description">{{ workOrderTypeName }}</text>
|
||||
</view>
|
||||
<view class="order-line"></view>
|
||||
<view class="order-details">
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">房间号:</text>
|
||||
<text class="detail-value">302</text>
|
||||
<text class="detail-label">房间号:</text>
|
||||
<input
|
||||
v-if="!isCallSuccess"
|
||||
class="detail-input"
|
||||
placeholder="请填写房间号"
|
||||
v-model="roomId"
|
||||
/>
|
||||
<text v-else class="detail-value">{{ roomId }}</text>
|
||||
</view>
|
||||
<view class="detail-item">
|
||||
<text class="detail-label">服务时间:</text>
|
||||
@@ -42,12 +48,12 @@
|
||||
<text v-else class="detail-value">{{ contactPhone }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
<!-- 呼叫前显示立即呼叫按钮 -->
|
||||
<button v-if="!isCallSuccess" class="order-button" @click="handleCall">
|
||||
立即呼叫
|
||||
</button>
|
||||
|
||||
|
||||
<!-- 呼叫成功后显示两个按钮 -->
|
||||
<view v-else class="order-buttons">
|
||||
<button class="order-button-secondary" @click="viewWorkOrder">
|
||||
@@ -73,69 +79,95 @@ import { ref, onMounted, nextTick } from "vue";
|
||||
import { SCROLL_TO_BOTTOM } from "@/constant/constant";
|
||||
|
||||
|
||||
import { createWorkOrder } from "@/request/api/OrderApi";
|
||||
|
||||
import { createWorkOrder, workOrderTypeListForBiz } from "@/request/api/OrderApi";
|
||||
const workOrderTypeId = ref('')
|
||||
const workOrderTypeName = ref('')
|
||||
const roomId = ref('')
|
||||
const contactName = ref("");
|
||||
const contactPhone = ref("");
|
||||
const isCallSuccess = ref(false); // 呼叫成功状态
|
||||
const workOrderId = ref(""); // 工单ID
|
||||
const workOrderId = ref(""); // 工单ID
|
||||
|
||||
|
||||
const handleCall = async () => {
|
||||
// 验证输入
|
||||
if (!contactName.value.trim()) {
|
||||
uni.showToast({
|
||||
title: '请填写联系人',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!contactPhone.value.trim()) {
|
||||
uni.showToast({
|
||||
title: '请填写联系电话',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
// 验证输入
|
||||
if (!roomId.value.trim()) {
|
||||
uni.showToast({
|
||||
title: '请填写房间号',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await createWorkOrder({
|
||||
contactName: contactName.value,
|
||||
contactPhone: contactPhone.value,
|
||||
workOrderTypeId: '1942741501754765314',
|
||||
roomId: '302',
|
||||
});
|
||||
|
||||
if (res.code === 0) {
|
||||
// 保存工单ID
|
||||
workOrderId.value = res.data?.id || "";
|
||||
|
||||
// 设置呼叫成功状态
|
||||
isCallSuccess.value = true;
|
||||
|
||||
uni.showToast({
|
||||
title: '工单创建成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '创建工单失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
if (!contactName.value.trim()) {
|
||||
uni.showToast({
|
||||
title: '请填写联系人',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('创建工单失败:', error);
|
||||
uni.showToast({
|
||||
title: '网络错误,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
if (!contactPhone.value.trim()) {
|
||||
uni.showToast({
|
||||
title: '请填写联系电话',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
sendCreateWorkOrder()
|
||||
};
|
||||
|
||||
/// 创建工单
|
||||
const sendCreateWorkOrder = () => {
|
||||
try {
|
||||
const res = await createWorkOrder({
|
||||
contactName: contactName.value,
|
||||
contactPhone: contactPhone.value,
|
||||
workOrderTypeId: workOrderTypeId.value,
|
||||
roomId: roomId.value,
|
||||
});
|
||||
|
||||
if (res.code === 0) {
|
||||
// 保存工单ID
|
||||
workOrderId.value = res.data?.id || "";
|
||||
|
||||
// 设置呼叫成功状态
|
||||
isCallSuccess.value = true;
|
||||
|
||||
uni.showToast({
|
||||
title: '工单创建成功',
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '创建工单失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('创建工单失败:', error);
|
||||
uni.showToast({
|
||||
title: '网络错误,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取工单类型
|
||||
const getWorkOrderType = async () => {
|
||||
const res = await workOrderTypeListForBiz()
|
||||
if(res.code === 0) {
|
||||
workOrderTypeId.value = res.data.id
|
||||
workOrderTypeName.value = res.data.workOrderTypeName
|
||||
}
|
||||
}
|
||||
|
||||
// 查看工单
|
||||
const viewWorkOrder = () => {
|
||||
|
||||
@@ -9,8 +9,13 @@ const userWorkOrderList = (args) => {
|
||||
return request.post("/hotelBiz/workOrder/userWorkOrderList", args);
|
||||
};
|
||||
|
||||
/// 获取工单类型
|
||||
const workOrderTypeListForBiz = () => {
|
||||
return request.get('/hotelBiz/workOrder/workOrderTypeListForBiz', {});
|
||||
}
|
||||
|
||||
/// 创建工单
|
||||
function createWorkOrder(args) {
|
||||
const createWorkOrder = (args) => {
|
||||
return request.post('/hotelBiz/workOrder/createWorkOrder', args);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user