unknown 5dc16e9566 调试接口
修改为测试环境,调试接口
2024-09-24 17:36:03 +08:00

351 lines
7.9 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: '',
queryParam: {
timeRangeDict: {
list: [{
text: '全天',
value: null
}, {
text: '上午',
value: 1
}, {
text: '下午',
value: 2
}, {
text: '晚上',
value: 3
}],
value: null,
},
meetingTypeDict: {
list: [],
value: null,
},
personDict: {
list: [{
text: "人数",
value: null
}, {
text: "0-10",
value: 1
}, {
text: "11-20",
value: 2
}, {
text: "21-30",
value: 3
}, {
text: "31-40",
value: 4
}, {
text: "41-50",
value: 5
}, {
text: "50-100",
value: 6
}, {
text: "100以上",
value: 7
}],
value: null,
},
itemDict: {
list: [],
value: null,
title: '设备'
},
shapeDict: {
list: [],
value: null,
},
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 页面初始化 options为页面跳转所带来的参数
if (options.name) {
wx.setNavigationBarTitle({
title: options.name
})
}
if (!options.rId) {
// 首页过来会找不到rId设为空否则会报错
options.rId = ''
}
if (!options.dep) {
options.dep = ''
}
const time = options.time
if (!time || time === '') {
app.selfShowMsg('请选择时间!', '/pages/meeting/index/index')
return
}
this.setData({
date: time,
rId: options.rId,
dep: options.dep
})
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.initData();
},
// 初始化数据
initData() {
let _this = this;
// 1.会议室类型2.人数3.会议室设备4.形式
meetingRoomDict("1").then(res => {
console.log('meetingRoomDict("1")', res);
// 封装参数
let list = res.roomContents.map(item => {
return {
text: item.typeName,
value: item.typeValue
}
})
list = [{
text: "楼层",
value: null
}, ...list]
// 赋值参数
let queryParam = _this.data.queryParam;
queryParam.meetingTypeDict.list = list;
_this.setData({
queryParam
})
console.log('meetingRoomDict("1")=>', list);
})
// meetingRoomDict("2").then(res => {
// console.log('meetingRoomDict("2")', res);
// // 封装参数
// let list = res.roomContents.map(item => {
// return {
// text: item.capacityNum + '人',
// value: item.capacityNum
// }
// })
// list = [{
// text: "人数",
// value: null
// }, ...list]
// // 赋值参数
// let queryParam = _this.data.queryParam;
// queryParam.personDict.list = list;
// _this.setData({
// queryParam
// })
// console.log('meetingRoomDict("2")=>', list);
// })
meetingRoomDict("3").then(res => {
console.log('meetingRoomDict("3")', res);
// 封装参数
let list = res.roomItem.map(item => {
return {
text: item.name,
value: item.id
}
})
// 赋值参数
let queryParam = _this.data.queryParam;
queryParam.itemDict.list = list;
_this.setData({
queryParam
})
console.log('meetingRoomDict("3")=>', list);
})
meetingRoomDict("4").then(res => {
console.log('meetingRoomDict("4")', res);
// 封装参数
let list = res.roomContents.map(item => {
return {
text: item.shape,
value: item.shape
}
})
list = [{
text: "形式",
value: null
}, ...list]
// 赋值参数
let queryParam = _this.data.queryParam;
queryParam.shapeDict.list = list;
_this.setData({
queryParam
})
console.log('meetingRoomDict("4")=>', list);
})
// 数据-会议室列表
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 roomItemList = queryParam.itemDict.list.filter(item => item.select).map(item => {
return {
"id": item.value,
"name": item.text
}
})
let param = {
"type": queryParam.meetingTypeDict.value,
"capacityNum": queryParam.personDict.value,
"roomItemList": roomItemList,
"shape": queryParam.shapeDict.value,
timeRange: queryParam.timeRangeDict.value
}
// 会议室列表数据
meetingRoomListRq(param).then(res => {
console.log('meetingRoomListRq', res);
let roomArr = {}
let valueObj = res.rows
for (let key in valueObj) {
let eachObj = valueObj[key]
if (eachObj['type'] in roomArr) {} else {
roomArr[eachObj['type']] = {
name: eachObj['typeName'],
list: []
}
}
roomArr[eachObj['type']]['list'].push(eachObj)
}
// console.log(roomArr)
_this.setData({
roomDataList: roomArr
})
})
},
// 会议室
jumpMeetingRoom(e) {
console.log('jumpMeetingRoom', e)
let timeRange = this.data.queryParam.timeRangeDict.value
timeRange = timeRange ? timeRange : 0
// 跳转预约详情
wx.navigateTo({
url: "/pages/meeting/meetingRoom/meetingRoom?id=" + e.currentTarget.dataset.id + '&time=' + this.data.date + '&timeRange=' + timeRange + '&rId=' + this.data.rId + '&dep=' + this.data.dep,
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})