2025-05-21 16:42:30 +08:00

428 lines
11 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const app = getApp()
import Dialog from '@vant/weapp/dialog/dialog';
import Notify from '@vant/weapp/notify/notify';
import {
meetingRoomDetailRq,
getCustomerTicketRq,
calculateMeetingRoomAmountRq,
saveMeetingRecordRq,
saveChangyangMeetingRecordRq,
selectReservationByIdRq,
meetingRoomDict
} from "../../../../api/meeting/meetingRoom.js"
import {
selfFormatTimeYMD,
selfFormatTimeHM,
twoTimeInterval,
selfArrSum
} from "../../../../utils/util.js"
Page({
/**
* 页面的初始数据
*/
data: {
rId: '',
dep: '',
depId: '',
IMG_NAME: app.IMG_NAME,
detail: {},
meetingRoomId: null,
timeRange: null,
startTime: null,
endTime: null,
selectDay: null,
selectCountTime: null,
bannerList: [],
room: {},
userData: {},
serviceList: [],
typeOp: ['本地会议', '视频会议']
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
console.log('onLoad', options);
let userData = wx.getStorageSync('user')
if (userData.username == userData.mobile) {
userData.username = ''
}
this.setData({
...options,
userData: userData,
// selectDay: selfFormatTimeYMD(options.startTime),
// selectCountTime,
})
if (options.startTime && options.endTime) {
this.getTimeDetail(options.startTime, options.endTime)
}
// 详细信息
this.getDetail();
},
/**
* 计算并填充时间细节
* @param {*} sTime 开始时间 2024-09-18 09:04:00
* @param {*} eTime 结束时间 2024-09-18 10:04:00
*/
getTimeDetail(sTime, eTime) {
let selectCountTime = selfFormatTimeHM(sTime) + "-" + selfFormatTimeHM(eTime) + ' 共计' + twoTimeInterval(sTime, eTime)
this.setData({
selectDay: selfFormatTimeYMD(sTime),
selectCountTime,
})
},
// 详细信息
getDetail() {
let _this = this;
let _dataId = _this.data.rId
if (_dataId === '') {
console.log('新增预约')
// 为新增新增的会议室id是传来的
let _meetingRoomId = _this.data.meetingRoomId
_this.getRoomInfo(_meetingRoomId)
_this.setData({
detail: {
orderUser: _this.data.userData.username,
orderTel: _this.data.userData.mobile,
title: '',
personNum: '',
leader: '',
depName: _this.data.dep,
depId: _this.data.depId,
remark: ''
}
})
} else {
// 为编辑,编辑有两种情况,一是重新选择会议室和时间,另一种是编辑基本信息
// 1. 无时间和会议室id此时根据id获取信息获取信息后其中有roomId
// 2. 有时间和会议室id此时根据会议室id获取会议室信息即可
let _meetingRoomId = _this.data.meetingRoomId
if (_meetingRoomId !== null) {
_this.getRoomInfo(_meetingRoomId)
}
selectReservationByIdRq({
id: _dataId
}).then(res => {
console.log('编辑,获取信息', res)
let recordDetail = res.mr
let roomDetail = res.room
let serveDetail = res.serve
if (_meetingRoomId === null) {
_meetingRoomId = roomDetail.id
_this.setData({
meetingRoomId: _meetingRoomId,
startTime: recordDetail.start,
endTime: recordDetail.end,
timeRange: recordDetail.timeFormat
})
let serviceId = []
for (let key in serveDetail) {
let eachObj = serveDetail[key]
serviceId.push(eachObj.value)
}
_this.getRoomInfo(_meetingRoomId, serviceId)
// 计算日期和时间
_this.getTimeDetail(recordDetail.start, recordDetail.end)
}
_this.setData({
dep: recordDetail.userOrg,
depId: recordDetail.userOrgId,
detail: {
orderUser: recordDetail.bookingUserName,
orderTel: recordDetail.bookingUserPhone,
title: recordDetail.title,
personNum: recordDetail.personNum,
leader: recordDetail.leader,
depId: recordDetail.userOrgId,
depName: recordDetail.userOrg,
remark: recordDetail.remark,
type:recordDetail.ext2
}
})
})
}
},
/**
* 获取会议室基本信息
* @param {*} roomId 会议室id
* @param {*} serveId 提供服务id用于编辑时默认勾选
*/
getRoomInfo(roomId, serveId) {
serveId = serveId || []
// 获取会议室详情
let _this = this
meetingRoomDetailRq({
roomId: this.data.meetingRoomId
}).then(res => {
let detail = res.room
let bannerList = []
if (detail.imgs) {
try {
bannerList = detail.imgs.map(item => item.url)
} catch (error) {
console.log(`JSON error : ${error}`);
}
}
let hasServeId = detail.ext1
_this.getService(hasServeId, serveId)
_this.setData({
// serviceList: serviceList,
room: detail,
bannerList
})
})
},
getService(hasServeId, serveId) {
console.log(hasServeId)
let _this = this;
if (!hasServeId || hasServeId == '') {
// 为空,此时无服务
_this.setData({
serviceList: []
})
return
}
// 拆分此会议室拥有的服务id与字典比对
let hasServeIdArr = hasServeId.split(',')
meetingRoomDict().then(res => {
console.log('meetingRoomDict', res)
let queryParam = _this.data.queryParam
let dataObj = res.data
// 封装参数
let serviceList = []
for (let key in dataObj.services) {
let eachObj = dataObj.services[key]
const keys = Object.keys(eachObj)
let isSel = false
let sId = eachObj[keys[0]]
if (hasServeIdArr.includes(sId)) {
// 此房间拥有的服务才继续处理
if (serveId.includes(sId)) {
isSel = true
}
serviceList.push({
serveId: eachObj[keys[0]],
serveName: keys[0],
isSelect: isSel,
num: '',
type: 'free'
})
}
}
// queryParam.shapeDict.list = typeList
_this.setData({
serviceList: serviceList
})
})
},
// input修改监听
inputChange(e) {
console.log('input change', e);
let _this = this
let name = e.currentTarget.dataset.name
let value = e.detail
let _data = _this.data.detail
_data[name] = value
let key = 'detail.' + name
this.setData({
[key]: value
})
},
// 跳转-空间设施
jumpMeetingFacilities() {
console.log('跳转', this.data.serviceList)
if (this.data.serviceList.length == 0) {
// 没有服务
Notify('此会议室不提供服务!')
return
}
let meetingRoomId = this.data.meetingRoomId;
let serviceListJsonStr = JSON.stringify(this.data.serviceList)
wx.navigateTo({
url: `/pages/meeting/meetingRoom/meetingService/meetingService?meetingRoomId=${meetingRoomId}&serviceList=${serviceListJsonStr}`
})
},
// 提交订单
submitCase() {
let _this = this
// 参数校验
if (!_this.data.detail.title) {
// 错误提示
Notify({
type: 'danger',
message: '请输入会议名称!'
});
return;
}
if (_this.data.detail.personNum == '') {
// 错误提示
Notify({
type: 'danger',
message: '请输入参会人数!'
});
return;
}
if (_this.data.detail.depName == '' || _this.data.detail.depId == '') {
// 错误提示
Notify({
type: 'danger',
message: '请选择单位!'
});
return;
}
if (!_this.data.detail.orderUser || _this.data.detail.orderUser === '') {
// 错误提示
Notify({
type: 'danger',
message: '请输入预约人!'
});
return
}
if (!_this.data.detail.orderUser || _this.data.detail.orderTel == '') {
// 错误提示
Notify({
type: 'danger',
message: '请输入联系方式!'
});
return;
}
// 处理一下serviceList
let service = []
let serviceList = _this.data.serviceList
for (let key in serviceList) {
let eachObj = serviceList[key]
if (eachObj.isSelect === true) {
service.push({
name: eachObj['serveName'],
value: eachObj['serveId'],
remark: ''
})
}
}
let timeFormat = _this.data.timeRange
if (timeFormat == 4) {
timeFormat = 0
}
let data = {
"mr": {
"id": _this.data.rId,
"roomId": _this.data.meetingRoomId,
"start": _this.data.startTime,
"end": _this.data.endTime,
"mrdate": _this.data.selectDay,
"timeFormat": timeFormat,
"title": _this.data.detail.title,
"personNum": _this.data.detail.personNum,
"leader": _this.data.detail.leader,
"userOrgId": _this.data.detail.depId,
"userOrg": _this.data.detail.depName,
"bookingUserName": _this.data.detail.orderUser,
"bookingUserPhone": _this.data.detail.orderTel,
"remark": _this.data.detail.remark,
// "ext2": _this.data.detail.type,
},
"serve": service
}
console.log('saveData', data)
saveChangyangMeetingRecordRq(data).then(res => {
console.log('saveMeetingRecordRq', res);
if (res.code == 0) {
wx.reLaunch({
url: '/pages/meeting/pay/waitComplete/waitComplete',
})
} else {
// 错误提示
Notify({
type: 'danger',
message: res.msg
});
}
})
},
showTypePicker() {
this.setData({
showType: true
})
},
hideTypePicker(){
this.setData({
showType: false
})
},
chooseType(e){
this.setData({
['detail.type']: e.detail.value
})
this.hideTypePicker()
},
chooseDep() {
// 非管理员无法选择
if (this.data.userData.roomRole != 5) {
return
}
wx.navigateTo({
url: '/pages/meeting/meetingRoom/meetingDep/meetingDep?depId=' + this.data.depId
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
console.log('onShow');
let _this = this
// console.log(this.data)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})