423 lines
11 KiB
JavaScript
Raw Normal View History

2024-02-27 12:00:47 +08:00
const app = getApp()
2024-03-05 19:18:13 +08:00
import Dialog from '@vant/weapp/dialog/dialog';
2024-03-05 20:07:13 +08:00
import Notify from '@vant/weapp/notify/notify';
2024-03-05 19:18:13 +08:00
2024-03-04 17:10:32 +08:00
import {
meetingRoomDetailRq,
getCustomerTicketRq,
calculateMeetingRoomAmountRq,
saveMeetingRecordRq,
saveChangyangMeetingRecordRq,
2024-09-24 23:04:06 +08:00
selectReservationByIdRq,
meetingRoomDict
2024-03-04 17:10:32 +08:00
} from "../../../../api/meeting/meetingRoom.js"
2024-03-04 18:00:27 +08:00
import {
selfFormatTimeYMD,
selfFormatTimeHM,
twoTimeInterval,
selfArrSum
2024-03-04 18:00:27 +08:00
} from "../../../../utils/util.js"
2024-02-27 12:00:47 +08:00
Page({
/**
* 页面的初始数据
*/
data: {
rId: '',
dep: '',
2024-09-24 23:04:06 +08:00
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);
this.setData({
...options,
userData: wx.getStorageSync('user'),
// selectDay: selfFormatTimeYMD(options.startTime),
// selectCountTime,
})
if (options.startTime && options.endTime) {
this.getTimeDetail(options.startTime, options.endTime)
}
2024-03-04 17:10:32 +08:00
// 详细信息
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: '',
2024-09-24 23:04:06 +08:00
depName: _this.data.dep,
depId: _this.data.depId,
remark: ''
2024-03-05 20:07:13 +08:00
}
})
} 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
2024-09-24 23:04:06 +08:00
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}`);
2024-06-27 14:55:40 +08:00
}
}
2024-10-04 17:29:12 +08:00
let hasServeId = detail.ext1
_this.getService(hasServeId, serveId)
_this.setData({
2024-09-24 23:04:06 +08:00
// serviceList: serviceList,
room: detail,
bannerList
})
})
},
2024-10-04 17:29:12 +08:00
getService(hasServeId, serveId) {
console.log(hasServeId)
2024-09-24 23:04:06 +08:00
let _this = this;
2024-10-04 17:29:12 +08:00
if (!hasServeId || hasServeId == '') {
// 为空,此时无服务
_this.setData({
serviceList: []
})
return
}
// 拆分此会议室拥有的服务id与字典比对
let hasServeIdArr = hasServeId.split(',')
2024-09-24 23:04:06 +08:00
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]]
2024-10-04 17:29:12 +08:00
if (hasServeIdArr.includes(sId)) {
// 此房间拥有的服务才继续处理
if (serveId.includes(sId)) {
isSel = true
}
serviceList.push({
serveId: eachObj[keys[0]],
serveName: keys[0],
isSelect: isSel,
num: '',
type: 'free'
})
}
2024-09-24 23:04:06 +08:00
}
// queryParam.shapeDict.list = typeList
_this.setData({
serviceList: serviceList
2024-09-24 23:04:06 +08:00
})
})
},
// 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() {
2024-10-04 17:29:12 +08:00
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;
2024-02-27 12:00:47 +08:00
}
2024-09-28 17:46:21 +08:00
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) {
2024-09-24 23:04:06 +08:00
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,
2024-09-24 23:04:06 +08:00
"roomId": _this.data.meetingRoomId,
"start": _this.data.startTime,
"end": _this.data.endTime,
"mrdate": _this.data.selectDay,
"timeFormat": timeFormat,
2024-09-24 23:04:06 +08:00
"title": _this.data.detail.title,
"personNum": _this.data.detail.personNum,
"leader": _this.data.detail.leader,
2024-09-24 23:04:06 +08:00
"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,
2024-09-24 23:04:06 +08:00
},
"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
2024-09-28 17:46:21 +08:00
// console.log(this.data)
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
2024-02-27 12:00:47 +08:00
})