373 lines
9.2 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,
startTime: null,
endTime: null,
selectDay: null,
selectCountTime: null,
bannerList: [],
room: {},
userData: {},
serviceList: [],
},
/**
* 生命周期函数--监听页面加载
*/
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(_dataId).then(res => {
console.log('编辑,获取信息', res)
if (_meetingRoomId === null) {
_meetingRoomId = res.data.roomContentId
_this.setData({
meetingRoomId: _meetingRoomId,
startTime: res.data.startTime,
endTime: res.data.endDate
})
let serviceId = []
for (let key in res.data.reservationServes) {
let eachObj = res.data.reservationServes[key]
serviceId.push(eachObj.serveId)
}
_this.getRoomInfo(_meetingRoomId, serviceId)
// 计算日期和时间
_this.getTimeDetail(res.data.startTime, res.data.endDate)
}
_this.setData({
detail: {
orderUser: res.data.orderUser,
orderTel: res.data.orderTel,
title: res.data.title,
personNum: res.data.personNum,
leader: res.data.leader,
depName: res.data.depName,
remark: res.data.remark,
}
})
})
}
},
/**
* 获取会议室基本信息
* @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.indoorPicUrl) {
try {
bannerList = JSON.parse(detail.indoorPicUrl).map(item => item.url)
} catch (error) {
console.log(`JSON error : ${error}`);
2024-06-27 14:55:40 +08:00
}
}
2024-09-24 23:04:06 +08:00
_this.getService(serveId)
// 提前处理服务,不需要进入页面后获取
2024-09-24 23:04:06 +08:00
// let serviceList = detail.roomServeList.map(item => {
// let isSel = false
// if (serveId.includes(item.id)) {
// isSel = true
// }
// return {
// serveId: item.id,
// serveName: item.serveName,
// isSelect: isSel,
// num: '',
// type: 'free'
// }
// })
console.log(detail)
_this.setData({
2024-09-24 23:04:06 +08:00
// serviceList: serviceList,
room: detail,
bannerList
})
})
},
2024-09-24 23:04:06 +08:00
getService() {
let _this = this;
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)
serviceList.push({
serveId: eachObj[keys[0]],
serveName: keys[0],
isSelect: false,
num: '',
type: 'free'
})
}
console.log(serviceList)
// 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
data['detail'][name] = value
this.setData({
...data
})
},
// 跳转-空间设施
jumpMeetingFacilities() {
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
}
// if (_this.data.detail.orderName == '') {
// // 错误提示
// 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
// console.log(serviceList)
for (let key in serviceList) {
let eachObj = serviceList[key]
console.log(eachObj)
if (eachObj.isSelect === true) {
2024-09-24 23:04:06 +08:00
service.push({
name: eachObj['serveName'],
value: eachObj['serveId'],
remark: ''
})
}
}
// console.log(service)
// return
saveChangyangMeetingRecordRq({
2024-09-24 23:04:06 +08:00
mr: {
"roomId": _this.data.meetingRoomId,
"start": _this.data.startTime,
"end": _this.data.endTime,
"mrdate": "2024-09-27",
"timeFormat": "0",
"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,
},
serve: service
}).then(res => {
console.log('saveMeetingRecordRq', res);
if (res.code == 0) {
wx.reLaunch({
url: '/pages/meeting/pay/waitComplete/waitComplete?id=' + res.reservationId,
})
} else {
// 错误提示
Notify({
type: 'danger',
message: res.msg
});
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
console.log('onShow');
let _this = this
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
2024-02-27 12:00:47 +08:00
})