471615499@qq.com 84947c9b12 修改页面效果
修改页面效果
2024-10-16 13:16:39 +08:00

453 lines
10 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 {
meetingRoomDict,
meetingRoomListRq,
} from "../../../api/meeting/meetingRoom.js"
import Notify from '@vant/weapp/notify/notify';
Page({
/**
* 页面的初始数据
*/
data: {
IMG_NAME: app.IMG_NAME,
roomDataList: {},
rId: '',
dep: '',
date: '',
dateStr: '',
adminTel: '83605343',
queryParam: {
timeRangeDict: {
list: [{
text: '全天',
value: 4
}, {
text: '上午',
value: 1
}, {
text: '下午',
value: 2
}, {
text: '晚上',
value: 3
}],
value: 4,
},
meetingTypeDict: {
list: [],
value: null,
},
personDict: {
list: [{
text: '人数',
value: ''
}, {
text: '1-20',
value: 1
}, {
text: '21-50',
value: 2
}, {
text: '51-100',
value: 3
}, {
text: '100 以上',
value: 4
}],
value: '',
},
itemDict: {
list: [],
value: null,
title: '设备'
},
shapeDict: {
list: [],
value: null,
},
},
showPicker: false,
actions: [],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 页面初始化 options为页面跳转所带来的参数
let userDetail = wx.getStorageSync('user')
if (options.name) {
wx.setNavigationBarTitle({
title: options.name
})
}
if (!options.rId) {
// 首页过来会找不到rId设为空否则会报错
options.rId = ''
}
if (!options.dep) {
options.dep = ''
options.depId = ''
}
const time = options.time
if (!time || time === '') {
app.selfShowMsg('请选择时间!', '/pages/meeting/index/index')
return
}
const _date = new Date(parseInt(time))
const _year = _date.getFullYear()
const _month = _date.getMonth() + 1 // 月份从0开始需要+1
const _day = _date.getDate()
// 设置标题
wx.setNavigationBarTitle({
title: _year + '年' + _month + '月' + _day + '日'
})
this.setData({
date: time,
rId: options.rId,
dep: options.dep,
depId: options.depId,
dateStr: _year + '-' + _month + '-' + _day,
userDetail: userDetail
})
if (options.rId == '' && (userDetail.roomRole != 5 && options.depId == '')) {
// 新增时,非管理员必须认证单位
Notify('非法操作!')
wx.navigateBack()
return
}
// 初始化数据
this.initData();
},
// 初始化数据
initData() {
let _this = this;
meetingRoomDict().then(res => {
console.log('meetingRoomDict', res)
let queryParam = _this.data.queryParam
let dataObj = res.data
// 封装参数
let floorList = []
for (let key in dataObj.floors) {
let eachObj = dataObj.floors[key]
const keys = Object.keys(eachObj)
floorList.push({
text: keys[0],
value: keys[0]
})
}
floorList = [{
text: "楼层",
value: null
}, ...floorList]
queryParam.meetingTypeDict.list = floorList
let deviceList = []
for (let key in dataObj.devices) {
let eachObj = dataObj.devices[key]
const keys = Object.keys(eachObj)
deviceList.push({
text: keys[0],
value: keys[0]
})
}
// 赋值参数
queryParam.itemDict.list = deviceList
let typeList = []
for (let key in dataObj.types) {
let eachObj = dataObj.types[key]
const keys = Object.keys(eachObj)
typeList.push({
text: keys[0],
value: keys[0]
})
}
typeList = [{
text: "形式",
value: null
}, ...typeList]
queryParam.shapeDict.list = typeList
// let numList = []
// for (let key in dataObj.personNum) {
// let eachObj = dataObj.personNum[key]
// // const keys = Object.keys(eachObj)
// numList.push({
// text: eachObj,
// value: eachObj
// })
// }
// numList = [{
// text: "人数",
// value: null
// }, ...numList]
// queryParam.personDict.list = numList
_this.setData({
queryParam
})
})
// 数据-会议室列表
this.meetingRoomList()
},
// 查询条件变动
dictChange(e) {
console.log('dictChange', e);
let queryParam = this.data.queryParam;
queryParam[e.currentTarget.dataset.type].value = e.detail;
this.setData({
queryParam
})
// 数据-会议室列表
this.meetingRoomList()
},
// 设备-多选
dictSwitchChange(e) {
console.log('dictSwitchChange', e);
let select = e.detail;
let name = e.currentTarget.dataset.name;
let id = e.currentTarget.dataset.id;
let queryParam = this.data.queryParam;
queryParam.itemDict.list = queryParam.itemDict.list.map(item => {
if (item.value == id) {
item.select = select;
}
return item
})
// 计算选择数量
let selectCount = queryParam.itemDict.list.filter(item => item.select).length;
console.log('selectCount', selectCount);
if (selectCount > 0) {
queryParam.itemDict.title = '设备+' + selectCount;
} else {
queryParam.itemDict.title = '设备';
}
this.setData({
queryParam
})
// 数据-会议室列表
this.meetingRoomList()
},
// 设备多选收起
itemDictConfirm() {
this.selectComponent('#itemSelect').toggle();
},
// 数据-会议室列表
meetingRoomList() {
let _this = this;
let queryParam = _this.data.queryParam;
let devicesArr = []
for (let key in queryParam.itemDict.list) {
let eachObj = queryParam.itemDict.list[key]
if (eachObj.select) {
devicesArr.push(eachObj.value)
}
}
let minPerNum = 0
let maxPerNum = 1000
let perNumValue = queryParam.personDict.value
if (perNumValue == 1) {
// 1-20
maxPerNum = 20
minPerNum = 1
} else if (perNumValue == 2) {
// 21-50
minPerNum = 21
maxPerNum = 50
} else if (perNumValue == 3) {
// 51-100
minPerNum = 51
maxPerNum = 100
} else if (perNumValue == 4) {
// 51-100
minPerNum = 101
maxPerNum = 1000
} else {
// 全部
minPerNum = 1
maxPerNum = 1000
}
let param = {
floor: queryParam.meetingTypeDict.value, // 楼层
min: minPerNum, // 最小容纳人数
max: maxPerNum, // 最大容纳人数
devices: devicesArr, // 设备
typeName: queryParam.shapeDict.value, // 形状
timeFormat: 1, // 预约时间格式0 任意时间管理员1上午2下午3晚上 4 全天。值为0时读取startTime和endTime为预约会议时间范围其他值读取mrdate再拼接时间为预约会议时间范围。返回值为1时读取 am上午 0可预约 1不可预约 pm下午 0可预约 1不可预约 night晚上 0可预约 1不可预约这里默认全部为1
mrdate: _this.data.dateStr
}
// 会议室列表数据
meetingRoomListRq(param).then(res => {
console.log('meetingRoomListRq', res);
let roomArr = {}
let valueObj = res.data
for (let key in valueObj) {
let eachObj = valueObj[key]
if (eachObj['floorId'] in roomArr) {} else {
roomArr[eachObj['floorId']] = {
name: eachObj['floor'],
list: []
}
}
roomArr[eachObj['floorId']]['list'].push(eachObj)
}
// console.log(roomArr)
_this.setData({
roomDataList: roomArr
})
})
},
chooseMeetingTime(e) {
let id = e.currentTarget.dataset.id
let am = e.currentTarget.dataset.am
let pm = e.currentTarget.dataset.pm
let night = e.currentTarget.dataset.night
if (this.data.userDetail.roomRole == 5) {
// 管理员,直接进入即可,全天都可以选择
this.jumpMeetingRoom(id, 4, 0)
return
}
let cAction = []
if (am == 0) {
cAction[0] = {
name: '上午',
subname: '8:00 - 12:00',
range: 1,
status: 0,
id: id
}
} else {
cAction[0] = {
name: '上午',
subname: '8:00 - 12:00',
range: 1,
status: 1,
id: id
}
}
if (pm == 0) {
cAction[1] = {
name: '下午',
subname: '12:00 - 17:30',
range: 2,
status: 0,
id: id
}
} else {
cAction[1] = {
name: '下午(不可预约)',
subname: '12:00 - 17:30',
range: 2,
status: 1,
id: id
}
}
if (night == 0) {
cAction[2] = {
name: '晚上',
subname: '17:30 - 24:00',
range: 3,
status: 0,
id: id
}
} else {
cAction[2] = {
name: '晚上(不可预约)',
subname: '17:30 - 24:00',
range: 3,
status: 1,
id: id
}
}
this.setData({
showPicker: true,
actions: cAction
})
},
/**
* 跳转会议室详情
* @param {*} id 会议室id
* @param {*} range 会议室时间选择范围
* @param {*} status 是否可以预约
*/
jumpMeetingRoom(id, range, status) {
// 跳转预约详情
wx.navigateTo({
url: "/pages/meeting/meetingRoom/meetingRoom?status=" + status + "&id=" + id + '&time=' + this.data.date + '&timeRange=' + range + '&rId=' + this.data.rId + '&dep=' + this.data.dep + '&depId=' + this.data.depId
})
},
callAdmin() {
let num = this.data.adminTel
wx.makePhoneCall({
phoneNumber: num
})
},
onClosePicker() {
this.setData({ showPicker: false })
},
onSelectRange(event) {
console.log(event.detail)
let timeRange = event.detail.range
let id = event.detail.id
let status = event.detail.status
this.jumpMeetingRoom(id, timeRange, status)
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})