286 lines
7.1 KiB
JavaScript
Raw Permalink Normal View History

2024-02-29 17:16:05 +08:00
let app = getApp();
2024-03-09 15:49:42 +08:00
import Notify from '@vant/weapp/notify/notify';
2024-02-29 17:16:05 +08:00
import {
2024-03-09 18:24:04 +08:00
selfFormatTimeYMDHMS
} from "../../../../utils/util.js"
2024-03-09 19:12:05 +08:00
import {
2024-03-10 17:21:44 +08:00
visitorPersonRq,
2024-03-10 17:58:40 +08:00
selectVisitorRecordByIdRq,
updateVisitorPersonStatusRq
2024-03-09 19:12:05 +08:00
} from "../../../../api/meeting/visitorIinvitation.js"
2024-03-01 15:07:02 +08:00
2024-02-26 09:06:34 +08:00
Page({
2024-03-01 15:07:02 +08:00
/**
* 页面的初始数据
*/
data: {
2024-03-09 15:49:42 +08:00
IMG_NAME: app.IMG_NAME,
2024-03-10 17:21:44 +08:00
id: null,
title: null,
type: null,
2024-03-10 17:58:40 +08:00
verifyShow: false,
2024-03-09 18:24:04 +08:00
userDetail: {},
fileList: [], // 上传文件
2024-03-09 15:49:42 +08:00
detail: {
customerId: null, //企业id
customerName: null, //企业名称
userId: null, // 被访人id
username: null, //被访人姓名
mobile: null, //被访人手机号
intervieweeId: null, // 访客id
name: null, // 访客姓名
phone: null, // 访客手机号
2024-03-09 18:24:04 +08:00
cardType: '居民身份证', // 证件类型
cardNo: null, // 证件号
2024-03-09 15:49:42 +08:00
visitTime: null, // 到访时间
leaveTime: null, // 离开时间
visitContent: null, // 来访事由
2024-03-09 18:41:21 +08:00
photo: null, // 头像-相对路径
url: null, // 人脸设备图片-全路径
2024-03-10 17:58:40 +08:00
},
// 审核
dialogShow: false,
dialogId: null,
dialogContent: null,
2024-03-01 15:07:02 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-03-09 14:24:42 +08:00
console.log('onLoad', options)
let _this = this;
2024-03-09 18:24:04 +08:00
let userDetail = wx.getStorageSync('user')
//
let detail = _this.data.detail;
2024-03-09 14:24:42 +08:00
_this.setData({
2024-03-09 18:24:04 +08:00
...options,
userDetail,
detail
2024-03-09 14:24:42 +08:00
})
2024-03-01 15:07:02 +08:00
// 页面初始化 options为页面跳转所带来的参数
wx.setNavigationBarTitle({
2024-03-08 14:11:33 +08:00
title: options.title
2024-03-01 15:07:02 +08:00
})
2024-03-10 17:21:44 +08:00
// 有id查询详情
if (options.id) {
// 获取详情
_this.getDetail()
}
},
// 获取详情
getDetail() {
let _this = this;
selectVisitorRecordByIdRq(_this.data.id).then(res => {
console.log('selectVisitorRecordByIdRq', res);
let detail = res.data;
2024-03-10 17:58:40 +08:00
// 是点击审核菜单或按钮并且是未审核的数据
if (_this.data.type == 'verify' && detail.status == 0) {
_this.setData({
verifyShow: true
})
}
2024-03-10 18:19:39 +08:00
// 设置状态颜色
let color = "#3794FF"
if (detail.status == 0) { // 待审核
color = "#3794FF"
} else if (detail.status == 1) { // 审核通过
color = "#62c855"
} else if (detail.status == 2) { // 审核驳回
color = "red"
}
detail.fontColor = color;
2024-03-10 17:21:44 +08:00
_this.setData({
detail,
fileList: [{
relativeUrl: detail.photo,
url: app.IMG_NAME + detail.photo,
name: detail.photo,
deletable: false,
}]
})
})
2024-03-09 14:24:42 +08:00
},
2024-03-09 18:24:04 +08:00
// 图片-上传前校验
beforeRead(event) {
const {
file,
callback
} = event.detail;
callback(file.type === 'image');
},
// 图片-上传后
afterRead(event) {
let _this = this;
const {
file
} = event.detail;
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
wx.uploadFile({
url: app.DOMAIN_NAME + '/api/dfs/upload',
filePath: file.url,
name: 'file',
formData: {},
success(res) {
console.log('upload file ', res);
let fileData = JSON.parse(res.data)
// 上传完成需要更新 fileList
let fileList = _this.data.fileList;
fileList.push({
relativeUrl: fileData.fileName,
2024-03-10 17:21:44 +08:00
url: app.IMG_NAME + fileData.fileName,
2024-03-09 18:24:04 +08:00
name: fileData.fileName,
deletable: true,
})
_this.setData({
fileList
})
},
});
},
// 删除图片
deleteImg(event) {
console.log('deleteImg', event);
let _this = this;
let fileList = _this.data.fileList;
fileList.splice(event.detail.index, 1);
_this.setData({
fileList
})
},
2024-03-09 19:02:53 +08:00
2024-03-10 17:58:40 +08:00
// 显示-弹出框
showDialog(e) {
console.log('showDialog', e);
let _this = this
_this.setData({
dialogShow: true,
dialogId: e.currentTarget.dataset.id,
dialogContent: null
})
},
// 弹出框-审核
dialogVerify(e) {
console.log('dialogSuccess', e);
let status = e.currentTarget.dataset.status;
let _this = this
// 驳回 需要输入描述信息
if (status == 2 && !_this.data.dialogContent) {
Notify({
type: 'danger',
2024-03-29 15:11:29 +08:00
message: '请输入驳回原因!'
2024-03-10 17:58:40 +08:00
});
return
}
updateVisitorPersonStatusRq({
id: _this.data.dialogId,
status,
rejectContent: _this.data.dialogContent,
}).then(res => {
console.log('updateVisitorPersonStatusRq', res);
// 刷新上个页面参数
let pages = getCurrentPages(); //获取page
let prevPage = pages[pages.length - 2]; //上一个页面(父页面)
prevPage.setData({
changeData: true
})
//
_this.setData({
dialogShow: false,
})
2024-03-10 18:35:19 +08:00
// 获取详情
_this.getDetail()
//
2024-03-10 17:58:40 +08:00
if (res.code == 0) {
_this.setData({
verifyShow: false
})
} else {
Notify({
type: 'danger',
message: res.msg
});
}
})
},
// 弹出框-输入框:输入内容时触发
dialogInput(e) {
let _this = this
console.log('dialogInput', e.detail);
_this.setData({
dialogContent: e.detail,
})
},
2024-03-09 19:02:53 +08:00
// 显示错误消息
showErrMsg(msg) {
Notify({
type: 'danger',
message: msg
});
},
2024-03-01 15:07:02 +08:00
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面初次渲染完成
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onReady: function () {
2024-03-01 15:07:02 +08:00
},
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面显示
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onShow: function () {
2024-03-01 15:07:02 +08:00
},
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面隐藏
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onHide: function () {
2024-03-01 15:07:02 +08:00
},
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面卸载
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onUnload: function () {
2024-03-01 15:07:02 +08:00
},
2024-03-09 14:24:42 +08:00
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
2024-03-01 15:07:02 +08:00
},
2024-03-09 14:24:42 +08:00
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
2024-03-01 15:07:02 +08:00
},
2024-03-09 14:24:42 +08:00
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
2024-03-01 15:07:02 +08:00
}
2024-02-26 09:06:34 +08:00
})