feat: 创建工单的类型拉取
This commit is contained in:
@@ -7,13 +7,19 @@
|
|||||||
<view class="order-content">
|
<view class="order-content">
|
||||||
<view class="order-item">
|
<view class="order-item">
|
||||||
<image src="./images/icon_service.png" class="order-icon"></image>
|
<image src="./images/icon_service.png" class="order-icon"></image>
|
||||||
<text class="order-description">加一台麻将机</text>
|
<text class="order-description">{{ workOrderTypeName }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="order-line"></view>
|
<view class="order-line"></view>
|
||||||
<view class="order-details">
|
<view class="order-details">
|
||||||
<view class="detail-item">
|
<view class="detail-item">
|
||||||
<text class="detail-label">房间号:</text>
|
<text class="detail-label">房间号:</text>
|
||||||
<text class="detail-value">302</text>
|
<input
|
||||||
|
v-if="!isCallSuccess"
|
||||||
|
class="detail-input"
|
||||||
|
placeholder="请填写房间号"
|
||||||
|
v-model="roomId"
|
||||||
|
/>
|
||||||
|
<text v-else class="detail-value">{{ roomId }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="detail-item">
|
<view class="detail-item">
|
||||||
<text class="detail-label">服务时间:</text>
|
<text class="detail-label">服务时间:</text>
|
||||||
@@ -42,12 +48,12 @@
|
|||||||
<text v-else class="detail-value">{{ contactPhone }}</text>
|
<text v-else class="detail-value">{{ contactPhone }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 呼叫前显示立即呼叫按钮 -->
|
<!-- 呼叫前显示立即呼叫按钮 -->
|
||||||
<button v-if="!isCallSuccess" class="order-button" @click="handleCall">
|
<button v-if="!isCallSuccess" class="order-button" @click="handleCall">
|
||||||
立即呼叫
|
立即呼叫
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<!-- 呼叫成功后显示两个按钮 -->
|
<!-- 呼叫成功后显示两个按钮 -->
|
||||||
<view v-else class="order-buttons">
|
<view v-else class="order-buttons">
|
||||||
<button class="order-button-secondary" @click="viewWorkOrder">
|
<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 { 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 contactName = ref("");
|
||||||
const contactPhone = ref("");
|
const contactPhone = ref("");
|
||||||
const isCallSuccess = ref(false); // 呼叫成功状态
|
const isCallSuccess = ref(false); // 呼叫成功状态
|
||||||
const workOrderId = ref(""); // 工单ID
|
const workOrderId = ref(""); // 工单ID
|
||||||
|
|
||||||
|
|
||||||
const handleCall = async () => {
|
const handleCall = async () => {
|
||||||
// 验证输入
|
// 验证输入
|
||||||
if (!contactName.value.trim()) {
|
if (!roomId.value.trim()) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '请填写联系人',
|
title: '请填写房间号',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!contactPhone.value.trim()) {
|
|
||||||
uni.showToast({
|
|
||||||
title: '请填写联系电话',
|
|
||||||
icon: 'none',
|
|
||||||
duration: 2000
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
if (!contactName.value.trim()) {
|
||||||
const res = await createWorkOrder({
|
uni.showToast({
|
||||||
contactName: contactName.value,
|
title: '请填写联系人',
|
||||||
contactPhone: contactPhone.value,
|
icon: 'none',
|
||||||
workOrderTypeId: '1942741501754765314',
|
duration: 2000
|
||||||
roomId: '302',
|
});
|
||||||
});
|
return;
|
||||||
|
|
||||||
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);
|
if (!contactPhone.value.trim()) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '网络错误,请重试',
|
title: '请填写联系电话',
|
||||||
icon: 'none',
|
icon: 'none',
|
||||||
duration: 2000
|
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 = () => {
|
const viewWorkOrder = () => {
|
||||||
|
|||||||
@@ -9,8 +9,13 @@ const userWorkOrderList = (args) => {
|
|||||||
return request.post("/hotelBiz/workOrder/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);
|
return request.post('/hotelBiz/workOrder/createWorkOrder', args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user