mirror of
https://gitee.com/elegant_wings/dbd-meeting-wx-small.git
synced 2025-06-21 18:59:36 +08:00
653 lines
16 KiB
JavaScript
653 lines
16 KiB
JavaScript
const app = getApp()
|
||
|
||
import Dialog from '@vant/weapp/dialog/dialog';
|
||
import Notify from '@vant/weapp/notify/notify';
|
||
|
||
import {
|
||
selfFormatTimeYMD,
|
||
selfFormatTimeHM
|
||
} from "../../../../utils/util.js"
|
||
|
||
import {
|
||
selectReservationListByUserIdRq,
|
||
selectVisitorInvitationRecordRq,
|
||
cancelOrderRq,
|
||
approveOrderRq
|
||
} from "../../../../api/meeting/meetingRoom.js"
|
||
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
IMG_NAME: app.IMG_NAME,
|
||
userData: null,
|
||
dataChange: false,
|
||
tabTitle: '预约记录',
|
||
// 预约记录参数
|
||
reservationPageNum: 1,
|
||
reservationPageSize: 10,
|
||
reservationDataList: [],
|
||
reservationIsDataAll: false,
|
||
search: {
|
||
title: {
|
||
text: '会议名称',
|
||
value: ''
|
||
},
|
||
status: {
|
||
value: 5,
|
||
option: [{
|
||
text: '全部预约',
|
||
value: ''
|
||
},
|
||
{
|
||
text: '待审核',
|
||
value: 5
|
||
},
|
||
{
|
||
text: '待开始',
|
||
value: 7
|
||
},
|
||
{
|
||
text: '已结束',
|
||
value: 11
|
||
},
|
||
{
|
||
text: '已取消',
|
||
value: 1
|
||
},
|
||
{
|
||
text: '已驳回',
|
||
value: 3
|
||
}, {
|
||
text: '占用',
|
||
value: 4
|
||
}, {
|
||
text: '进行中',
|
||
value: 9
|
||
},
|
||
]
|
||
}
|
||
},
|
||
showRejectReason: false, // 是否展示弹出层
|
||
rejectlId: '', // 驳回预约会议id
|
||
rejectReason: '', // 驳回预约原因
|
||
beforeReject(action) {
|
||
return new Promise(resolve => {
|
||
if (action === 'confirm') {
|
||
resolve(false)
|
||
} else {
|
||
resolve(true)
|
||
}
|
||
});
|
||
}, // 弹出层点击确认不关闭,手动关
|
||
// 会议重新预约需要参数
|
||
editId: '',
|
||
showEdit: false,
|
||
editAction: [{
|
||
name: '重新选择时间、会议室',
|
||
type: 1
|
||
},
|
||
{
|
||
name: '重新编辑会议信息',
|
||
type: 2
|
||
},
|
||
],
|
||
timeShow: false,
|
||
currentDate: new Date().getTime(),
|
||
minDate: new Date().getTime(),
|
||
maxDate: '',
|
||
formatter(type, value) {
|
||
if (type === 'year') {
|
||
return `${value}年`;
|
||
}
|
||
if (type === 'month') {
|
||
return `${value}月`;
|
||
}
|
||
if (type === 'day') {
|
||
return `${value}日`;
|
||
}
|
||
return value;
|
||
},
|
||
// 参与记录参数,不需要
|
||
// participatePageNum: 1,
|
||
// participatePageSize: 10,
|
||
// participateDataList: [],
|
||
// participateIsDataAll: false,
|
||
},
|
||
changeSearchTitle(e) {
|
||
this.setData({
|
||
['search.title.value']: e.detail,
|
||
})
|
||
},
|
||
searchTitle() {
|
||
// 刷新预约数据
|
||
this.setData({
|
||
reservationPageNum: 1,
|
||
reservationDataList: [],
|
||
reservationIsDataAll: false,
|
||
})
|
||
this.getDataList()
|
||
this.selectComponent('#item').toggle()
|
||
},
|
||
changeSearchStatus(e) {
|
||
// 刷新预约数据
|
||
this.setData({
|
||
reservationPageNum: 1,
|
||
reservationDataList: [],
|
||
reservationIsDataAll: false,
|
||
['search.status.value']: e.detail
|
||
})
|
||
this.getDataList()
|
||
},
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad(options) {
|
||
let _this = this;
|
||
_this.setData({
|
||
userData: wx.getStorageSync('user'),
|
||
})
|
||
// 获取数据
|
||
let userId = _this.data.userData.id
|
||
// 获取预约数据
|
||
_this.getReservationData({
|
||
userId,
|
||
pageNum: _this.data.reservationPageNum,
|
||
pageSize: _this.data.reservationPageSize,
|
||
})
|
||
// 获取一月后时间,默认只能选一个月之后
|
||
const today = new Date()
|
||
const newDate = new Date(today)
|
||
newDate.setMonth(newDate.getMonth() + 1)
|
||
_this.setData({
|
||
maxDate: newDate.getTime()
|
||
})
|
||
},
|
||
|
||
// 获取数据
|
||
getDataList() {
|
||
// 获取参数
|
||
let _this = this;
|
||
let tabTitle = _this.data.tabTitle
|
||
let userId = _this.data.userData.id
|
||
let isDataAll = null
|
||
let pageNum = null
|
||
let pageSize = null
|
||
// 预约记录参数,目前只保留预约记录,其余去掉
|
||
isDataAll = _this.data.reservationIsDataAll
|
||
pageNum = _this.data.reservationPageNum
|
||
pageSize = _this.data.reservationPageSize
|
||
|
||
// 判断数据是否已全部加载
|
||
if (isDataAll) {
|
||
return;
|
||
}
|
||
// 传递参数
|
||
let param = {
|
||
userId,
|
||
pageNum,
|
||
pageSize
|
||
}
|
||
_this.getReservationData(param)
|
||
},
|
||
|
||
// 获取预约数据
|
||
getReservationData(param) {
|
||
let _this = this;
|
||
let {
|
||
pageNum,
|
||
pageSize,
|
||
userId
|
||
} = param
|
||
// 查询数据
|
||
selectReservationListByUserIdRq({
|
||
role: 5, // 按不同角色去查询预约记录。1.普通用户, 3.会议服务人员 ,5.会议管理员
|
||
pageNum,
|
||
pageSize,
|
||
title: _this.data.search.title.value,
|
||
status: _this.data.search.status.value
|
||
}).then(res => {
|
||
console.log('selectReservationListByUserIdRq', res);
|
||
// 判断数据是否全部查询
|
||
let queryDataList = res.rows;
|
||
if (_this.data.reservationDataList.length < res.total) {
|
||
// 更新参数
|
||
let reservationDataList = _this.data.reservationDataList.concat(_this.formartData(queryDataList));
|
||
let reservationPageNum = _this.data.reservationPageNum + 1;
|
||
_this.setData({
|
||
reservationPageNum,
|
||
reservationDataList,
|
||
})
|
||
} else {
|
||
_this.setData({
|
||
reservationIsDataAll: true
|
||
})
|
||
}
|
||
})
|
||
},
|
||
|
||
// 获取参与数据,此处不需要
|
||
getParticipateData(param) {
|
||
let _this = this;
|
||
let {
|
||
pageNum,
|
||
pageSize,
|
||
userId
|
||
} = param
|
||
// 查询数据
|
||
selectVisitorInvitationRecordRq({
|
||
pageNum,
|
||
pageSize,
|
||
userId
|
||
}).then(res => {
|
||
console.log('selectVisitorInvitationRecordRq', res);
|
||
// 判断数据是否全部查询
|
||
let queryDataList = res.page.records;
|
||
if (queryDataList && queryDataList.length > 0) {
|
||
// 更新参数
|
||
let participateDataList = _this.data.participateDataList.concat(_this.formartData(queryDataList));
|
||
let participatePageNum = _this.data.participatePageNum + 1;
|
||
_this.setData({
|
||
participatePageNum,
|
||
participateDataList,
|
||
})
|
||
} else {
|
||
_this.setData({
|
||
participateIsDataAll: true
|
||
})
|
||
}
|
||
})
|
||
},
|
||
|
||
// 格式化数据
|
||
formartData(queryDataList) {
|
||
// 格式化数据
|
||
return queryDataList.map(item => {
|
||
item.timeSlot = selfFormatTimeYMD(item.start) + ' ' + selfFormatTimeHM(item.start) + '~' + selfFormatTimeHM(item.end);
|
||
// 状态字体颜色
|
||
let statusColor = "#FFB119";
|
||
// 按钮是否显示
|
||
let statusValue = item.status;
|
||
let showCancel = false // 显示取消操作
|
||
let showEdit = false // 显示编辑操作
|
||
let showStaff = false // 显示会务人员
|
||
let showApprove = false // 显示审批操作
|
||
let statusName = ''
|
||
// 预约状态,1 取消 3 驳回 4 占用 5 待审核 7 审核通过,待开始 9 进行中 11已结束
|
||
if (statusValue == 1) {
|
||
// 取消
|
||
// 状态字体颜色
|
||
statusColor = "#333333"
|
||
statusName = '已取消'
|
||
}
|
||
if (statusValue == 3) {
|
||
// 驳回,可以修改
|
||
statusColor = "#333333"
|
||
showCancel = true
|
||
showEdit = true
|
||
statusName = '已驳回'
|
||
}
|
||
if (statusValue == 4) {
|
||
// 占用,可以修改,取消
|
||
showEdit = true
|
||
showCancel = true
|
||
showStaff = true
|
||
statusName = '已占用'
|
||
}
|
||
if (statusValue == 5) {
|
||
// 待审核,普通用户只能取消,管理员可以修改
|
||
showEdit = true
|
||
showCancel = true
|
||
showApprove = true
|
||
showStaff = true
|
||
statusName = '待审核'
|
||
}
|
||
if (statusValue == 7) {
|
||
// 审核通过,可以取消,不允许修改
|
||
showCancel = true
|
||
showStaff = true
|
||
statusName = '已通过'
|
||
}
|
||
if (statusValue == 11) {
|
||
// 已结束
|
||
statusColor = "#333333"
|
||
statusName = '已结束'
|
||
}
|
||
// 赋值
|
||
item.showCancel = showCancel
|
||
item.showEdit = showEdit
|
||
item.showApprove = showApprove
|
||
item.showStaff = showStaff
|
||
item.statusName = statusName
|
||
// 状态字体颜色
|
||
item.statusColor = statusColor;
|
||
// 图片
|
||
if (item.imgs) {
|
||
try {
|
||
item.indoorPicUrlFirst = item.imgs[0].url
|
||
} catch (error) {
|
||
console.log(`JSON error : ${error}`);
|
||
}
|
||
}
|
||
return item
|
||
})
|
||
},
|
||
|
||
// 跳转-预约详情
|
||
jumpMeetingDetail(e) {
|
||
console.log('jumpMeetingDetail', e);
|
||
let id = e.currentTarget.dataset.id
|
||
wx.navigateTo({
|
||
url: "/pages/meeting/reservationRecord/meetingRecord/meetingDetail/meetingDetail?act=approve&id=" + id,
|
||
})
|
||
},
|
||
/**
|
||
* 跳转会务负责人页面,选择会务负责人
|
||
* @param {}} e
|
||
*/
|
||
goStaff(e) {
|
||
let id = e.currentTarget.dataset.id
|
||
wx.navigateTo({
|
||
url: "/pages/meeting/meetingRoom/meetingStaff/meetingStaff?rId=" + id,
|
||
})
|
||
},
|
||
// 取消预约一系列方法
|
||
cancelConfirm(e) {
|
||
console.log('cancelConfirm', e);
|
||
let _this = this;
|
||
let id = e.currentTarget.dataset.id
|
||
_this.setData({
|
||
cancelId: id,
|
||
showCancelReason: true,
|
||
cancelReason: ''
|
||
})
|
||
},
|
||
onCloseCancel(e) {
|
||
let _this = this;
|
||
_this.setData({
|
||
cancelId: '',
|
||
showCancelReason: false,
|
||
cancelReason: ''
|
||
})
|
||
},
|
||
onChangeCancelReason(e) {
|
||
let _this = this;
|
||
_this.setData({
|
||
cancelReason: e.detail
|
||
})
|
||
},
|
||
// 取消订单
|
||
cancelOrder() {
|
||
let _this = this;
|
||
let id = _this.data.cancelId
|
||
let reason = _this.data.cancelReason
|
||
if (id === '') {
|
||
return
|
||
}
|
||
if (reason === '') {
|
||
Notify('请输入取消原因!')
|
||
return
|
||
}
|
||
cancelOrderRq({
|
||
id: id,
|
||
content: reason
|
||
}).then(res => {
|
||
console.log('cancelOrderRq', res);
|
||
if (res.code == 0) {
|
||
// 刷新预约数据
|
||
_this.setData({
|
||
reservationPageNum: 1,
|
||
reservationDataList: [],
|
||
reservationIsDataAll: false,
|
||
showCancelReason: false
|
||
})
|
||
_this.getDataList()
|
||
} else {
|
||
// 危险通知
|
||
Notify({
|
||
type: 'danger',
|
||
message: res.msg
|
||
});
|
||
}
|
||
})
|
||
},
|
||
editConfirm(e) {
|
||
let id = e.currentTarget.dataset.id
|
||
this.setData({
|
||
editId: id,
|
||
showEdit: true
|
||
})
|
||
},
|
||
hideEdit() {
|
||
this.setData({
|
||
showEdit: false
|
||
})
|
||
},
|
||
editMode(e) {
|
||
let _this = this
|
||
if (e.detail.type === 1) {
|
||
// 重选时间会议室
|
||
this.setData({
|
||
showEdit: false,
|
||
timeShow: true
|
||
})
|
||
} else {
|
||
// 直接跳转
|
||
console.log('重新编辑会议基本信息!')
|
||
this.setData({
|
||
showEdit: false,
|
||
})
|
||
wx.navigateTo({
|
||
url: "/pages/meeting/meetingRoom/meetingOrder/meetingOrder?rId=" + _this.data.editId,
|
||
})
|
||
}
|
||
},
|
||
showTimePicker() {
|
||
this.setData({
|
||
timeShow: true
|
||
});
|
||
},
|
||
hideTimePicker() {
|
||
this.setData({
|
||
timeShow: false
|
||
});
|
||
},
|
||
// 跳转会议预约页面
|
||
goRes(e) {
|
||
let _this = this
|
||
let date = new Date(e.detail);
|
||
let year = date.getFullYear()
|
||
let month = date.getMonth() + 1
|
||
let day = date.getDate()
|
||
let chooseTime = year + '-' + month + '-' + day + ' 00:00:00'
|
||
let chooseTimeStr = new Date(chooseTime).getTime()
|
||
// 加入rId参数,为预约id,用于重新修改
|
||
wx.navigateTo({
|
||
url: '/pages/meeting/meetingReservation/meetingReservation?rId=' + _this.data.editId + '&time=' + chooseTimeStr,
|
||
})
|
||
},
|
||
pass(e) {
|
||
let _this = this;
|
||
let id = e.currentTarget.dataset.id
|
||
Dialog.confirm({
|
||
title: '确认',
|
||
message: '是否确认通过会议室申请?',
|
||
})
|
||
.then(() => {
|
||
// on confirm
|
||
approveOrderRq({
|
||
id: id,
|
||
content: '审核通过',
|
||
operate: 'PASS'
|
||
}).then(res => {
|
||
console.log('passOrder', res)
|
||
if (res.code == 0) {
|
||
// 刷新预约数据
|
||
_this.setData({
|
||
reservationPageNum: 1,
|
||
reservationDataList: [],
|
||
reservationIsDataAll: false,
|
||
showRejectReason: false
|
||
})
|
||
Notify({
|
||
type: 'success',
|
||
message: '已通过该申请!'
|
||
})
|
||
_this.getDataList()
|
||
} else {
|
||
// 危险通知
|
||
Notify({
|
||
type: 'danger',
|
||
message: res.msg
|
||
});
|
||
}
|
||
})
|
||
})
|
||
.catch(() => {
|
||
// on cancel
|
||
});
|
||
},
|
||
// 驳回预约
|
||
rejectConfirm(e) {
|
||
console.log('rejectConfirm', e);
|
||
let _this = this;
|
||
let id = e.currentTarget.dataset.id
|
||
_this.setData({
|
||
rejectId: id,
|
||
showRejectReason: true,
|
||
rejectReason: ''
|
||
})
|
||
},
|
||
onCloseReject(e) {
|
||
let _this = this;
|
||
_this.setData({
|
||
rejectId: '',
|
||
showRejectReason: false,
|
||
rejectReason: ''
|
||
})
|
||
},
|
||
onChangeRejectReason(e) {
|
||
let _this = this;
|
||
_this.setData({
|
||
rejectReason: e.detail
|
||
})
|
||
},
|
||
// 取消订单
|
||
rejectOrder() {
|
||
let _this = this;
|
||
let id = _this.data.rejectId
|
||
let reason = _this.data.rejectReason
|
||
if (id === '') {
|
||
return
|
||
}
|
||
if (reason === '') {
|
||
Notify('请输入驳回原因!')
|
||
return
|
||
}
|
||
// 执行驳回方法
|
||
console.log('驳回,原因为' + reason)
|
||
approveOrderRq({
|
||
id: id,
|
||
content: reason,
|
||
operate: 'REJECTED'
|
||
}).then(res => {
|
||
console.log('rejectOrder', res);
|
||
if (res.code == 0) {
|
||
// 刷新预约数据
|
||
_this.setData({
|
||
reservationPageNum: 1,
|
||
reservationDataList: [],
|
||
reservationIsDataAll: false,
|
||
showRejectReason: false
|
||
})
|
||
Notify({
|
||
type: 'danger',
|
||
message: '已驳回该申请!'
|
||
})
|
||
_this.getDataList()
|
||
} else {
|
||
// 危险通知
|
||
Notify({
|
||
type: 'danger',
|
||
message: res.msg
|
||
});
|
||
}
|
||
})
|
||
},
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow() {
|
||
let _this = this;
|
||
// 数据是否变化
|
||
if (_this.data.dataChange) {
|
||
// 刷新数据
|
||
_this.setData({
|
||
dataChange: false,
|
||
// 预约记录参数
|
||
reservationPageNum: 1,
|
||
reservationDataList: [],
|
||
reservationIsDataAll: false,
|
||
})
|
||
_this.getDataList()
|
||
}
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh() {
|
||
console.log('onPullDownRefresh', '页面相关事件处理函数--监听用户下拉动作');
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom() {
|
||
console.log('onReachBottom', '页面上拉触底事件的处理函数');
|
||
let _this = this;
|
||
// 获取数据
|
||
_this.getDataList()
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage(e) {
|
||
console.log('onShareAppMessage', e);
|
||
let _this = this;
|
||
let id = e.target.dataset.id;
|
||
let detail = _this.data.reservationDataList.find(item => item.id == id)
|
||
//
|
||
let param = {
|
||
title: detail.title,
|
||
path: "/pages/meeting/invite/invite?id=" + id,
|
||
imageUrl: app.IMG_NAME + detail.roomContent.indoorPicUrlFirst,
|
||
}
|
||
console.log('onShareAppMessage', param);
|
||
return param;
|
||
}
|
||
}) |