mirror of
https://gitee.com/elegant_wings/dbd-meeting-wx-small.git
synced 2025-06-21 18:59:36 +08:00
290 lines
6.4 KiB
JavaScript
290 lines
6.4 KiB
JavaScript
const app = getApp()
|
||
|
||
import Notify from '@vant/weapp/notify/notify';
|
||
|
||
import {
|
||
getStaff,
|
||
selectReservationByIdRq,
|
||
addStaff
|
||
} from "../../../../api/meeting/meetingRoom.js"
|
||
|
||
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
IMG_NAME: app.IMG_NAME,
|
||
rId: '',
|
||
checkUser: [],
|
||
// staffMusicList: [{
|
||
// id: 1,
|
||
// name: '张三',
|
||
// isSelect: false
|
||
// }],
|
||
staffMusicList: [],
|
||
// staffServeList: [{
|
||
// id: 4,
|
||
// name: '赵六',
|
||
// isSelect: false
|
||
// }],
|
||
staffServeList: [],
|
||
serviceCheckAll: false,
|
||
musicCheckAll: false
|
||
},
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad(options) {
|
||
let _this = this
|
||
let rId = options.rId
|
||
|
||
// console.log(ser)
|
||
_this.setData({
|
||
rId: rId
|
||
})
|
||
// 获取数据
|
||
_this.getData()
|
||
},
|
||
|
||
// 获取数据
|
||
getData() {
|
||
let _this = this
|
||
let id = _this.data.rId
|
||
// 获取预约信息
|
||
selectReservationByIdRq({
|
||
id: id
|
||
}).then(res => {
|
||
console.log('预约信息:', res)
|
||
let staffIdArr = []
|
||
let staff = res.waiters
|
||
for (let key in staff) {
|
||
staffIdArr.push(staff[key].userId)
|
||
}
|
||
getStaff().then(resStaff => {
|
||
console.log('会务人员:', resStaff)
|
||
let musicList = []
|
||
let serveList = []
|
||
let hasMusicStaff = false
|
||
let hasServiceStaff = false
|
||
|
||
for (let key in resStaff.voiceWaiter) {
|
||
let eachObj = resStaff.voiceWaiter[key]
|
||
let isSel = false
|
||
if (staffIdArr.includes(eachObj.id)) {
|
||
isSel = true
|
||
hasMusicStaff = true
|
||
}
|
||
musicList.push({
|
||
id: eachObj.id,
|
||
name: eachObj.username,
|
||
isSelect: isSel
|
||
})
|
||
}
|
||
for (let key in resStaff.serveWaiter) {
|
||
let eachObj = resStaff.serveWaiter[key]
|
||
let isSel = false
|
||
if (staffIdArr.includes(eachObj.id)) {
|
||
isSel = true
|
||
hasServiceStaff = true
|
||
}
|
||
serveList.push({
|
||
id: eachObj.id,
|
||
name: eachObj.username,
|
||
isSelect: isSel
|
||
})
|
||
}
|
||
|
||
// 保存初始状态到本地存储
|
||
wx.setStorageSync('staffStatus_' + _this.data.rId, {
|
||
hasMusicStaff,
|
||
hasServiceStaff
|
||
});
|
||
|
||
_this.setData({
|
||
staffServeList: serveList,
|
||
staffMusicList: musicList
|
||
})
|
||
})
|
||
})
|
||
// ajax获取当前预约的人员以及会务人员列表
|
||
},
|
||
|
||
// 服务选择
|
||
checkBoxClick(e) {
|
||
let _this = this
|
||
console.log('checkBoxClick', e)
|
||
// get param
|
||
let id = e.target.dataset.id
|
||
let type = e.target.dataset.type
|
||
if (type === 'music') {
|
||
let staffMusicList = _this.data.staffMusicList.map(item => {
|
||
if (item.id == id) {
|
||
item.isSelect = !item.isSelect
|
||
}
|
||
return item
|
||
})
|
||
_this.setData({
|
||
staffMusicList
|
||
})
|
||
} else {
|
||
let staffServeList = _this.data.staffServeList.map(item => {
|
||
if (item.id == id) {
|
||
item.isSelect = !item.isSelect
|
||
}
|
||
return item
|
||
})
|
||
_this.setData({
|
||
staffServeList
|
||
})
|
||
}
|
||
},
|
||
|
||
// 确定
|
||
submit() {
|
||
let _this = this;
|
||
// 提交
|
||
console.log(_this.data.staffMusicList)
|
||
console.log(_this.data.staffServeList)
|
||
let staffMusicList = _this.data.staffMusicList
|
||
let staffServeList = _this.data.staffServeList
|
||
let musicId = ''
|
||
// 检查音控组是否有选择
|
||
let hasMusicStaff = false
|
||
for (let key in staffMusicList) {
|
||
if (staffMusicList[key].isSelect) {
|
||
hasMusicStaff = true
|
||
musicId += staffMusicList[key].id + ','
|
||
}
|
||
}
|
||
if (musicId != '') {
|
||
// 去掉最后一个,
|
||
musicId = musicId.substring(0, musicId.length - 1)
|
||
}
|
||
let serveId = ''
|
||
// 检查会务服务组是否有选择
|
||
let hasServiceStaff = false
|
||
for (let key in staffServeList) {
|
||
if (staffServeList[key].isSelect) {
|
||
hasServiceStaff = true
|
||
serveId += staffServeList[key].id + ','
|
||
}
|
||
}
|
||
if (serveId != '') {
|
||
// 去掉最后一个,
|
||
serveId = serveId.substring(0, serveId.length - 1)
|
||
}
|
||
|
||
// 保存选择状态到本地存储
|
||
wx.setStorageSync('staffStatus_' + _this.data.rId, {
|
||
hasMusicStaff,
|
||
hasServiceStaff
|
||
});
|
||
|
||
addStaff({
|
||
id: _this.data.rId,
|
||
voiceWaiter: musicId,
|
||
serveWaiter: serveId
|
||
}).then(res => {
|
||
Notify({
|
||
type: 'success',
|
||
message: '分配成功!'
|
||
})
|
||
|
||
// 获取页面栈
|
||
let pages = getCurrentPages()
|
||
// 获取上一页实例
|
||
let prevPage = pages[pages.length - 2]
|
||
// 设置上一页的dataChange为true,触发刷新
|
||
prevPage.setData({
|
||
dataChange: true
|
||
})
|
||
|
||
// 返回上一页
|
||
wx.navigateBack()
|
||
})
|
||
|
||
// let pages = getCurrentPages(); //获取page
|
||
// let prevPage = pages[pages.length - 2]; //上一个页面(父页面)
|
||
// prevPage.setData({
|
||
// serviceList: _this.data.serviceList
|
||
// })
|
||
// console.log(_this.data.serviceList)
|
||
// wx.navigateBack()
|
||
},
|
||
checkMusicAll() {
|
||
let _this = this
|
||
let checkStatus = _this.data.musicCheckAll
|
||
checkStatus = checkStatus ? false : true
|
||
let staffMusicList = _this.data.staffMusicList.map(item => {
|
||
item.isSelect = checkStatus
|
||
return item
|
||
})
|
||
_this.setData({
|
||
staffMusicList,
|
||
musicCheckAll: checkStatus
|
||
})
|
||
},
|
||
checkServiceAll() {
|
||
let _this = this
|
||
let checkStatus = _this.data.serviceCheckAll
|
||
checkStatus = checkStatus ? false : true
|
||
let staffServeList = _this.data.staffServeList.map(item => {
|
||
item.isSelect = checkStatus
|
||
return item
|
||
})
|
||
_this.setData({
|
||
staffServeList,
|
||
serviceCheckAll: checkStatus
|
||
})
|
||
},
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom() {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage() {
|
||
|
||
}
|
||
}) |