From c1da11dc1dcab04d565c3c36447ed081c07ebaeb Mon Sep 17 00:00:00 2001 From: SelfRidicule Date: Sun, 10 Mar 2024 17:21:44 +0800 Subject: [PATCH] 1 --- miniprogram/api/meeting/visitorIinvitation.js | 36 +++ .../visitorIinvitation/detail/detail.js | 40 ++- .../meeting/visitorIinvitation/list/list.js | 245 +++++++++++++++--- .../meeting/visitorIinvitation/list/list.json | 3 +- .../meeting/visitorIinvitation/list/list.wxml | 55 ++-- miniprogram/utils/util.js | 18 +- 6 files changed, 340 insertions(+), 57 deletions(-) diff --git a/miniprogram/api/meeting/visitorIinvitation.js b/miniprogram/api/meeting/visitorIinvitation.js index 649e020..12ed790 100644 --- a/miniprogram/api/meeting/visitorIinvitation.js +++ b/miniprogram/api/meeting/visitorIinvitation.js @@ -26,4 +26,40 @@ export function visitorPersonRq(data) { method: "post", data, }); +} + + +// 访客-预约记录 +export function selectVisitorRecordByIntervieweeIdRq(data) { + return request({ + url: `/api/visitor/selectVisitorRecordByIntervieweeId?pageNum=${data.pageNum}&pageSize=${data.pageSize}`, + method: "post", + data, + }); +} + +// 访客-审核记录 +export function selectVisitorRecordByUserIdRq(data) { + return request({ + url: `/api/visitor/selectVisitorRecordByUserId?pageNum=${data.pageNum}&pageSize=${data.pageSize}`, + method: "post", + data, + }); +} + +// 访客-预约审核 +export function updateVisitorPersonStatusRq(data) { + return request({ + url: '/api/visitor/updateVisitorPersonStatus', + method: "post", + data, + }); +} + +// 获取访客记录的详情 +export function selectVisitorRecordByIdRq(id) { + return request({ + url: '/api/visitor/selectVisitorRecordById/' + id, + method: "get", + }); } \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js b/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js index 2307c85..5bae5fd 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js +++ b/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js @@ -7,7 +7,8 @@ import { } from "../../../../utils/util.js" import { - visitorPersonRq + visitorPersonRq, + selectVisitorRecordByIdRq } from "../../../../api/meeting/visitorIinvitation.js" @@ -18,6 +19,9 @@ Page({ */ data: { IMG_NAME: app.IMG_NAME, + id: null, + title: null, + type: null, userDetail: {}, idcardTypeShow: false, idcardTypeList: [{ @@ -57,9 +61,12 @@ Page({ let userDetail = wx.getStorageSync('user') // let detail = _this.data.detail; - detail.intervieweeId = userDetail.id // 访客id - detail.name = userDetail.username // 访客姓名 - detail.phone = userDetail.mobile // 访客手机号 + // 添加 默认设置访客信息 + if (options.type == 'add') { + detail.intervieweeId = userDetail.id // 访客id + detail.name = userDetail.username // 访客姓名 + detail.phone = userDetail.mobile // 访客手机号 + } _this.setData({ ...options, userDetail, @@ -69,6 +76,29 @@ Page({ wx.setNavigationBarTitle({ title: options.title }) + // 有id查询详情 + if (options.id) { + // 获取详情 + _this.getDetail() + } + }, + + // 获取详情 + getDetail() { + let _this = this; + selectVisitorRecordByIdRq(_this.data.id).then(res => { + console.log('selectVisitorRecordByIdRq', res); + let detail = res.data; + _this.setData({ + detail, + fileList: [{ + relativeUrl: detail.photo, + url: app.IMG_NAME + detail.photo, + name: detail.photo, + deletable: false, + }] + }) + }) }, // 跳转-索引栏(单位、人员) @@ -207,7 +237,7 @@ Page({ let fileList = _this.data.fileList; fileList.push({ relativeUrl: fileData.fileName, - url: app.DOMAIN_NAME + fileData.fileName, + url: app.IMG_NAME + fileData.fileName, name: fileData.fileName, deletable: true, }) diff --git a/miniprogram/pages/meeting/visitorIinvitation/list/list.js b/miniprogram/pages/meeting/visitorIinvitation/list/list.js index 8ad5849..5260392 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/list/list.js +++ b/miniprogram/pages/meeting/visitorIinvitation/list/list.js @@ -1,9 +1,35 @@ +import Notify from '@vant/weapp/notify/notify'; + +import { + selectVisitorRecordByIntervieweeIdRq, + selectVisitorRecordByUserIdRq, + updateVisitorPersonStatusRq +} from "../../../../api/meeting/visitorIinvitation.js" + +import { + selfFormatTimeYMDHM +} from "../../../../utils/util.js" + Page({ /** * 页面的初始数据 */ data: { + tabTitle: '预约记录', + userDetail: {}, + changeData: false, + // 预约 + reservationPageNum: 1, + reservationPageSize: 10, + reservationDataList: [], + reservationIsAll: false, + // 审核 + verifyPageNum: 1, + verifyPageSize: 10, + verifyDataList: [], + verifyIsAll: false, + // dialogShow: false, dialogId: null, dialogContent: null, @@ -13,21 +39,122 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { + 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 + }) + } + }) + }, + + // 格式化数据 + 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; + }) }, // tab 切换 tabClickSwitch(event) { - wx.showToast({ - title: `切换到标签 ${event.detail.title}`, - icon: 'none', - }); + this.setData({ + tabTitle: event.detail.title, + }) }, // 显示-弹出框 showDialog(e) { console.log('showDialog', e); - let _this = this _this.setData({ dialogShow: true, @@ -36,19 +163,51 @@ Page({ }) }, - // 弹出框-通过 - dialogSuccess() { + // 弹出框-审核 + dialogVerify(e) { + console.log('dialogSuccess', e); + let status = e.currentTarget.dataset.status; let _this = this - _this.setData({ - dialogShow: false, - }) - }, - - // 弹出框-驳回 - dialogReject() { - let _this = this - _this.setData({ - dialogShow: false, + // 驳回 需要输入描述信息 + 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(); }) }, @@ -61,13 +220,24 @@ Page({ }) }, - // 跳转-预约 - goReservation() { + 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 + } wx.navigateTo({ - url: '/pages/meeting/visitorIinvitation/detail/detail?title=预约', + url: '/pages/meeting/visitorIinvitation/detail/detail' + urlParam, }) }, + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -79,7 +249,26 @@ Page({ * 生命周期函数--监听页面显示 */ onShow() { - + 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(); + } }, /** @@ -108,6 +297,9 @@ Page({ */ onReachBottom() { console.log('onReachBottom'); + let _this = this; + // 获取数据 + _this.getDataList() }, /** @@ -116,15 +308,4 @@ Page({ onShareAppMessage() { }, - onChange(event) { - wx.showToast({ - title: `切换到标签 ${event.detail.name}`, - icon: 'none', - }); - }, - toCheckFn() { - wx.reLaunch({ - url: '/pages/meeting/visitorIinvitation/visitorIinvitation', - }) - } }) \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/list/list.json b/miniprogram/pages/meeting/visitorIinvitation/list/list.json index 0fc2ce7..e94ab16 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/list/list.json +++ b/miniprogram/pages/meeting/visitorIinvitation/list/list.json @@ -7,6 +7,7 @@ "van-icon": "@vant/weapp/icon/index", "van-button": "@vant/weapp/button/index", "van-dialog": "@vant/weapp/dialog/index", - "van-field": "@vant/weapp/field/index" + "van-field": "@vant/weapp/field/index", + "van-notify": "@vant/weapp/notify/index" } } \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/list/list.wxml b/miniprogram/pages/meeting/visitorIinvitation/list/list.wxml index f8f34aa..94f8923 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/list/list.wxml +++ b/miniprogram/pages/meeting/visitorIinvitation/list/list.wxml @@ -1,41 +1,62 @@ - + - 访客:张三 - 待审核 + 被访人:{{item.userName}} + {{item.statusName}} - 访问事由: 参观会议参观会议参观会议参观会议参观会议参观会议参观会议参观会议参观会议参观会议参观会议 + 访问事由: {{item.visitContent}} - 2024-02-02 14:00 + {{item.visitTimeFormat}} 查看详情 - 审核 - + + + 访客:{{item.name}} + {{item.statusName}} + + + + + 访问事由: {{item.visitContent}} + + + + {{item.visitTimeFormat}} + + + 查看详情 + 审核 + + + - 立即预约 + 立即预约 - - - - - 驳回 - 通过 - - + - \ No newline at end of file + + + + + 驳回 + 通过 + + + + + \ No newline at end of file diff --git a/miniprogram/utils/util.js b/miniprogram/utils/util.js index a4af14b..e23bba1 100644 --- a/miniprogram/utils/util.js +++ b/miniprogram/utils/util.js @@ -99,6 +99,19 @@ function selfFormatTimeYMDHMS(time) { } +//返回 2017-12-12 12:30 +function selfFormatTimeYMDHM(time) { + let date = new Date(time); + let year = date.getFullYear() + let month = date.getMonth() + 1 + let day = date.getDate() + let hour = date.getHours() + let minute = date.getMinutes() + let second = date.getSeconds() + + return [year, month, day].map(formatNumber).join('-') + ' ' + [hour, minute].map(formatNumber).join(':') +} + //返回 2017-12-12 12 function selfFormatTimeYMDH(time) { let date = new Date(time); @@ -164,8 +177,8 @@ function twoTimeInterval(startTime, endTime) { let returnVal = ((days == 0) ? "" : days + "天") + ((hours == 0) ? "" : hours + "时") + - ((minutes == 0) ? "" : minutes + "分") - // + ((seconds == 0) ? "" : seconds + "秒"); + ((minutes == 0) ? "" : minutes + "分") + // + ((seconds == 0) ? "" : seconds + "秒"); return returnVal; } @@ -202,6 +215,7 @@ module.exports = { formatTime2: formatTime2, selfFormatTimeReturnSecond59, selfFormatTimeYMDHMS, + selfFormatTimeYMDHM, selfFormatTimeYMD, selfFormatTimeHM, selfFormatTimeYMDH,