311 lines
8.3 KiB
JavaScript
Raw Normal View History

2024-03-10 17:21:44 +08:00
import Notify from '@vant/weapp/notify/notify';
import {
selectVisitorRecordByIntervieweeIdRq,
selectVisitorRecordByUserIdRq,
updateVisitorPersonStatusRq
} from "../../../../api/meeting/visitorIinvitation.js"
import {
selfFormatTimeYMDHM
} from "../../../../utils/util.js"
2024-02-29 17:16:05 +08:00
Page({
2024-03-07 20:15:43 +08:00
/**
* 页面的初始数据
*/
data: {
2024-03-10 17:21:44 +08:00
tabTitle: '预约记录',
userDetail: {},
changeData: false,
// 预约
reservationPageNum: 1,
reservationPageSize: 10,
reservationDataList: [],
reservationIsAll: false,
// 审核
verifyPageNum: 1,
verifyPageSize: 10,
verifyDataList: [],
verifyIsAll: false,
//
2024-03-08 12:00:15 +08:00
dialogShow: false,
dialogId: null,
dialogContent: null,
2024-03-07 20:15:43 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-03-10 17:21:44 +08:00
let _this = this;
let userDetail = wx.getStorageSync('user')
_this.setData({
...options,
userDetail,
})
// 获取-预约记录 数据
_this.getReservationData();
// 获取-预约审核 数据
_this.getVerifyData();
},
// 获取数据
getDataList() {
let _this = this;
let tabTitle = _this.data.tabTitle
if (tabTitle == '预约记录') {
_this.getReservationData()
} else if (tabTitle == '预约审核') {
_this.getVerifyData()
} else {
wx.showToast({
title: `tab 切换错误(${tabTitle})`,
icon: 'none',
});
return;
}
},
// 获取-预约记录 数据
getReservationData() {
let _this = this;
// 是否全部加载完成
if (_this.data.reservationIsAll) {
return;
}
selectVisitorRecordByIntervieweeIdRq({
pageNum: _this.data.reservationPageNum,
pageSize: _this.data.reservationPageSize,
intervieweeId: _this.data.userDetail.id
}).then(res => {
console.log('getReservationData', res);
let queryDataList = res.data.records;
if (queryDataList && queryDataList.length > 0) {
let reservationDataList = _this.data.reservationDataList.concat(_this.formartData(queryDataList))
_this.setData({
reservationDataList,
reservationPageNum: _this.data.reservationPageNum + 1
})
} else {
_this.setData({
reservationIsAll: true
})
}
})
},
// 获取-预约审核 数据
getVerifyData() {
let _this = this;
// 是否全部加载完成
if (_this.data.verifyIsAll) {
return;
}
selectVisitorRecordByUserIdRq({
pageNum: _this.data.verifyPageNum,
pageSize: _this.data.verifyPageSize,
userId: _this.data.userDetail.id
}).then(res => {
console.log('getVerifyData', res);
let queryDataList = res.data.records;
if (queryDataList && queryDataList.length > 0) {
let verifyDataList = _this.data.verifyDataList.concat(_this.formartData(queryDataList))
_this.setData({
verifyDataList,
verifyPageNum: _this.data.verifyPageNum + 1
})
} else {
_this.setData({
verifyIsAll: true
})
}
})
},
2024-03-08 12:00:15 +08:00
2024-03-10 17:21:44 +08:00
// 格式化数据
formartData(list) {
return list.map(item => {
let color = "#3794FF"
let verifyShow = false;
if (item.status == 0) { // 待审核
color = "#3794FF"
verifyShow = true;
} else if (item.status == 1) { // 审核通过
color = "#62c855"
} else if (item.status == 2) { // 审核驳回
color = "red"
}
item.fontColor = color;
item.verifyShow = verifyShow;
item.visitTimeFormat = selfFormatTimeYMDHM(item.visitTime);
return item;
})
2024-03-07 20:15:43 +08:00
},
// tab 切换
tabClickSwitch(event) {
2024-03-10 17:21:44 +08:00
this.setData({
tabTitle: event.detail.title,
})
2024-03-07 20:15:43 +08:00
},
2024-03-08 12:00:15 +08:00
// 显示-弹出框
showDialog(e) {
console.log('showDialog', e);
let _this = this
_this.setData({
dialogShow: true,
dialogId: e.currentTarget.dataset.id,
dialogContent: null
})
},
2024-03-10 17:21:44 +08:00
// 弹出框-审核
dialogVerify(e) {
console.log('dialogSuccess', e);
let status = e.currentTarget.dataset.status;
2024-03-08 12:00:15 +08:00
let _this = this
2024-03-10 17:21:44 +08:00
// 驳回 需要输入描述信息
if (status == 2 && !_this.data.dialogContent) {
Notify({
type: 'danger',
message: '请输入描述信息!'
});
return
}
updateVisitorPersonStatusRq({
id: _this.data.dialogId,
status,
rejectContent: _this.data.dialogContent,
}).then(res => {
console.log('updateVisitorPersonStatusRq', res);
if (res.code != 0) {
Notify({
type: 'danger',
message: res.msg
});
}
_this.setData({
// 预约
reservationPageNum: 1,
reservationPageSize: 10,
reservationDataList: [],
reservationIsAll: false,
// 审核
verifyPageNum: 1,
verifyPageSize: 10,
verifyDataList: [],
verifyIsAll: false,
//
dialogShow: false,
dialogId: null,
dialogContent: null
})
// 获取-预约记录 数据
_this.getReservationData();
// 获取-预约审核 数据
_this.getVerifyData();
2024-03-08 12:00:15 +08:00
})
},
// 弹出框-输入框:输入内容时触发
dialogInput(e) {
let _this = this
console.log('dialogInput', e.detail);
_this.setData({
dialogContent: e.detail,
})
},
2024-03-10 17:21:44 +08:00
goDetail(e) {
console.log('goDetail', e);
let id = e.currentTarget.dataset.id
let type = e.currentTarget.dataset.type
let urlParam = "?type=" + type;
if (type == 'add') {
urlParam = urlParam + "&title=预约"
} else if (type == 'verify') {
urlParam = urlParam + "&title=审核" + "&id=" + id
} else if (type == 'detail') {
urlParam = urlParam + "&title=详情" + "&id=" + id
}
2024-03-08 14:11:33 +08:00
wx.navigateTo({
2024-03-10 17:21:44 +08:00
url: '/pages/meeting/visitorIinvitation/detail/detail' + urlParam,
2024-03-08 14:11:33 +08:00
})
},
2024-03-10 17:21:44 +08:00
2024-03-07 20:15:43 +08:00
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
2024-03-10 17:21:44 +08:00
let _this = this;
if (_this.data.changeData) {
_this.setData({
dataChange: false,
// 预约
reservationPageNum: 1,
reservationPageSize: 10,
reservationDataList: [],
reservationIsAll: false,
// 审核
verifyPageNum: 1,
verifyPageSize: 10,
verifyDataList: [],
verifyIsAll: false,
})
// 获取-预约记录 数据
_this.getReservationData();
// 获取-预约审核 数据
_this.getVerifyData();
}
2024-03-07 20:15:43 +08:00
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
2024-03-08 12:00:15 +08:00
console.log('onReachBottom');
2024-03-10 17:21:44 +08:00
let _this = this;
// 获取数据
_this.getDataList()
2024-03-07 20:15:43 +08:00
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
},
2024-02-29 17:16:05 +08:00
})