<template>
|
<view class="client-visit-detail">
|
<PageHeader title="会议室详情"
|
@back="goBack" />
|
<u-form ref="formRef"
|
label-width="90">
|
<!-- 客户信息 -->
|
<u-cell-group title="会议室信息">
|
<u-form-item label="会议室名称"
|
prop="name"
|
required
|
border-bottom>
|
<u-input v-model="form.name"
|
placeholder="请输入会议室名称" />
|
</u-form-item>
|
<u-form-item label="位置"
|
required
|
prop="location"
|
border-bottom>
|
<u-input v-model="form.location"
|
placeholder="请输入位置" />
|
</u-form-item>
|
<u-form-item label="容纳人数"
|
required
|
prop="capacity"
|
border-bottom>
|
<u-input v-model="form.capacity"
|
placeholder="请输入容纳人数" />
|
</u-form-item>
|
<u-form-item label="设备配置"
|
prop="equipment"
|
border-bottom>
|
<u-input v-model="form.equipment"
|
readonly
|
placeholder="请选择设备配置"
|
@click="showEquipmentSheet = true" />
|
<template #right>
|
<up-icon name="arrow-right"
|
@click="openEquipmentSheet"></up-icon>
|
</template>
|
</u-form-item>
|
<u-form-item label="状态"
|
prop="status"
|
border-bottom>
|
<u-input v-model="statusname"
|
readonly
|
placeholder="请选择状态"
|
@click="showStatusSheet = true" />
|
<template #right>
|
<up-icon name="arrow-right"
|
@click="showStatusSheet = true"></up-icon>
|
</template>
|
</u-form-item>
|
<u-form-item label="备注"
|
prop="remark"
|
border-bottom>
|
<u-input v-model="form.remark"
|
placeholder="请输入备注" />
|
</u-form-item>
|
</u-cell-group>
|
<!-- 提交按钮 -->
|
<view class="footer-btns">
|
<u-button class="cancel-btn"
|
@click="goBack">取消</u-button>
|
<u-button class="sign-btn"
|
type="primary"
|
@click="handleSubmit"
|
:loading="loading">保存</u-button>
|
</view>
|
</u-form>
|
<!-- 设备配置选择器 -->
|
<u-popup :show="showEquipmentSheet"
|
mode="bottom"
|
@close="showEquipmentSheet = false"
|
height="200px">
|
<view class="popup-content">
|
<view class="popup-body">
|
<u-checkbox-group v-model="form.equipment"
|
@change="handleEquipmentChange"
|
icon-placement="right"
|
placement="row">
|
<view style="width:100%;padding:10px;margin-top:20px;">
|
<u-checkbox v-for="option in equipmentOptions"
|
:key="option.value"
|
:name="option.value"
|
:label="option.name"
|
class="checkbox-item"></u-checkbox>
|
</view>
|
</u-checkbox-group>
|
</view>
|
</view>
|
</u-popup>
|
<!-- 状态选择器 -->
|
<up-action-sheet :show="showStatusSheet"
|
:actions="statusOptions"
|
@select="onStatusSelect"
|
@close="showStatusSheet = false" />
|
</view>
|
</template>
|
|
<script setup>
|
// 替换 toast 方法
|
defineOptions({ name: "meeting-settings-detail" });
|
const showToast = message => {
|
uni.showToast({
|
title: message,
|
icon: "none",
|
});
|
};
|
|
import { ref, onMounted } from "vue";
|
import PageHeader from "@/components/PageHeader.vue";
|
import useUserStore from "@/store/modules/user";
|
import { saveRoom } from "@/api/managementMeetings/meetingSettings";
|
|
const userStore = useUserStore();
|
|
// 表单数据
|
const form = ref({
|
name: "",
|
location: "",
|
capacity: "",
|
equipment: [],
|
status: "",
|
remark: "",
|
});
|
const equipmentOptions = ref([
|
{ value: "投影仪", name: "投影仪" },
|
{ value: "电视", name: "电视" },
|
{ value: "音响", name: "音响" },
|
{ value: "电话", name: "电话" },
|
{ value: "视频会议系统", name: "视频会议系统" },
|
{ value: "白板", name: "白板" },
|
{ value: "写字板", name: "写字板" },
|
{ value: "无线网络", name: "无线网络" },
|
]);
|
const statusOptions = ref([
|
{ value: "1", name: "启用" },
|
{ value: "0", name: "禁用" },
|
]);
|
//// 页面状态
|
const loading = ref(false);
|
const formRef = ref(null);
|
const showEquipmentSheet = ref(false);
|
const showStatusSheet = ref(false);
|
const openEquipmentSheet = () => {
|
showEquipmentSheet.value = true;
|
};
|
// 返回上一页
|
const goBack = () => {
|
uni.navigateBack();
|
};
|
const statusname = ref("");
|
// 状态选择
|
const onStatusSelect = action => {
|
form.value.status = action.value;
|
statusname.value = action.name;
|
showStatusSheet.value = false;
|
};
|
// 设备配置选择
|
const handleEquipmentChange = val => {
|
form.value.equipment = val;
|
console.log("form.value.equipment", form.value.equipment);
|
};
|
// 提交表单
|
const handleSubmit = async () => {
|
if (!form.value.name) {
|
showToast("请输入会议室名称");
|
return;
|
}
|
|
if (!form.value.location) {
|
showToast("请输入位置");
|
return;
|
}
|
|
if (!form.value.capacity) {
|
showToast("请输入容纳人数");
|
return;
|
}
|
try {
|
loading.value = true;
|
form.value.equipment = form.value.equipment.join(",");
|
form.value.status = Number(form.value.status);
|
form.value.capacity = Number(form.value.capacity);
|
// 使用安全浅拷贝,避免对象展开在某些运行时抛错
|
console.log("form.value", form.value);
|
saveRoom(form.value).then(res => {
|
if (res.code !== 200) {
|
showToast("保存失败,请重试");
|
return;
|
}
|
loading.value = false;
|
showToast("保存成功");
|
setTimeout(() => {
|
goBack();
|
}, 500);
|
});
|
} catch (e) {
|
loading.value = false;
|
console.error("保存失败:", e);
|
showToast("保存失败,请重试");
|
}
|
};
|
|
// 初始化页面数据
|
const initPageData = () => {
|
// 从本地存储中获取会议 room 数据
|
const meetingRoom = uni.getStorageSync("meetingRoom");
|
if (meetingRoom) {
|
form.value = JSON.parse(JSON.stringify(meetingRoom));
|
if (meetingRoom.equipment) {
|
if (Array.isArray(meetingRoom.equipment)) {
|
form.value.equipment = meetingRoom.equipment;
|
} else {
|
form.value.equipment = meetingRoom.equipment.split(",");
|
}
|
}
|
statusname.value = meetingRoom.status === 1 ? "启用" : "禁用";
|
|
// 清除本地存储中的数据,避免下次打开时仍然显示
|
uni.removeStorageSync("meetingRoom");
|
}
|
};
|
|
onMounted(() => {
|
initPageData();
|
});
|
</script>
|
|
<style scoped lang="scss">
|
@import "@/static/scss/form-common.scss";
|
.client-visit {
|
min-height: 100vh;
|
background: #f8f9fa;
|
padding-bottom: 5rem;
|
}
|
|
.footer-btns {
|
position: fixed;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
background: #fff;
|
display: flex;
|
justify-content: space-around;
|
align-items: center;
|
padding: 0.75rem 0;
|
box-shadow: 0 -0.125rem 0.5rem rgba(0, 0, 0, 0.05);
|
z-index: 1000;
|
}
|
|
.cancel-btn {
|
font-weight: 400;
|
font-size: 1rem;
|
color: #666;
|
background: #f5f5f5;
|
border: 1px solid #ddd;
|
width: 45%;
|
height: 2.5rem;
|
border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
|
}
|
|
.sign-btn {
|
font-weight: 500;
|
font-size: 1rem;
|
color: #fff;
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
border: none;
|
width: 45%;
|
height: 2.5rem;
|
border-radius: 2.5rem 2.5rem 2.5rem 2.5rem;
|
}
|
|
.location-icon {
|
color: #1989fa;
|
font-size: 1.2rem;
|
}
|
|
.selector-container {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
width: 100%;
|
height: 100%;
|
}
|
|
.selector-text {
|
font-size: 14px;
|
color: #333;
|
}
|
|
.popup-content {
|
padding: 20rpx;
|
}
|
|
.popup-header {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
margin-bottom: 20rpx;
|
}
|
|
.popup-title {
|
font-size: 16px;
|
font-weight: bold;
|
color: #333;
|
}
|
|
.close-icon {
|
font-size: 20px;
|
color: #999;
|
}
|
|
.popup-body {
|
max-height: 60vh;
|
overflow-y: auto;
|
margin-bottom: 20rpx;
|
}
|
|
.checkbox-item {
|
margin-bottom: 15rpx;
|
font-size: 14px;
|
}
|
|
.popup-footer {
|
display: flex;
|
justify-content: space-between;
|
gap: 15rpx;
|
}
|
|
.cancel-btn-popup {
|
flex: 1;
|
border-radius: 8rpx;
|
}
|
|
.confirm-btn-popup {
|
flex: 1;
|
border-radius: 8rpx;
|
}
|
.checkbox-item {
|
margin-top: 40rpx;
|
}
|
</style>
|