753 lines
19 KiB
JavaScript
753 lines
19 KiB
JavaScript
// pages/guestEditSignUpinfo/guestEditSignUpInfo.js
|
||
import MeetingApi from '../../assets/js/http/meetingApi'
|
||
import {
|
||
compareDate
|
||
} from '../../utils/validate'
|
||
import {
|
||
baseUrl,
|
||
URL_CONFIG
|
||
} from '../../assets/js/project.config.js'
|
||
|
||
import WasicTopicData from '../../assets/js/wasicStaticData.js'
|
||
const LinkTopicsEnums = {
|
||
free: {
|
||
name: '免费专题',
|
||
index: 6
|
||
},
|
||
freeTwo: {
|
||
name: '免费专题',
|
||
index: 8
|
||
}
|
||
}
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
info: {}, // 参会人的信息
|
||
isWasic: false, // 是否是WASIC
|
||
// 可选课题名称的数组
|
||
linkTopicsOptionArr: [],
|
||
// WASIC可选会议的数组-前端写死
|
||
showTopicsArr: [...WasicTopicData],
|
||
guestType_dictText: '', // 嘉宾类型
|
||
// 抵达时间
|
||
arrivalTime: '请选择抵达时间',
|
||
// 入住酒店时间
|
||
inHotelTime: '请选择入住酒店时间',
|
||
// 离店时间
|
||
outHotelTime: '请选择离店时间',
|
||
// 离开时间
|
||
departureTime: '请选择离开时间',
|
||
// 是否选择发票的选中的索引
|
||
index: -1,
|
||
// 是否需要用餐
|
||
haveMeal: '',
|
||
// 是否住酒店
|
||
needHotel: '',
|
||
// 是否接站
|
||
needPick: '',
|
||
// 是否送站
|
||
needSend: '',
|
||
// 上传图片的id
|
||
imageIds: '',
|
||
// 记录临时的文件名 用于回显 小程序上传后后端的名会乱码
|
||
tempFiles: '点击上传',
|
||
// ppt Id
|
||
speechPpt: '',
|
||
|
||
// 是否
|
||
need: [{
|
||
value: 1,
|
||
name: '是'
|
||
},
|
||
{
|
||
value: 0,
|
||
name: '否'
|
||
},
|
||
],
|
||
},
|
||
// 初始化嘉宾类型
|
||
initGuestType(type) {
|
||
switch (type) {
|
||
case 1:
|
||
this.setData({
|
||
'guestType_dictText': 'VIP'
|
||
});
|
||
break
|
||
case 2:
|
||
this.setData({
|
||
'guestType_dictText': '演讲嘉宾'
|
||
});
|
||
break
|
||
case 3:
|
||
this.setData({
|
||
'guestType_dictText': '特邀嘉宾'
|
||
});
|
||
break
|
||
case 4:
|
||
this.setData({
|
||
'guestType_dictText': '合作伙伴'
|
||
});
|
||
break
|
||
case 5:
|
||
this.setData({
|
||
'guestType_dictText': '参展商'
|
||
});
|
||
break
|
||
}
|
||
},
|
||
// 表单的显示隐藏
|
||
initForm(record) {
|
||
// 存储所有需要更新的字段
|
||
let updateObj = {}
|
||
|
||
if (record.guestType === 1 && record.speechPpt) {
|
||
this.setData({
|
||
'info.speechPpt': record.speechPpt
|
||
})
|
||
}
|
||
|
||
// 不是合作伙伴和参展商
|
||
let isCoopOrExint = record.guestType !== 4 && record.guestType !== 5
|
||
// 是否用餐-vip\演讲嘉宾 管吃饭
|
||
if ((record.guestType === 1 || record.guestType === 2) && record.haveMeals !== null) {
|
||
updateObj.haveMeal = record.haveMeals
|
||
}
|
||
// 是否住酒店-只有VIP管
|
||
if (record.guestType === 1 && record.checkInHotel !== null) {
|
||
updateObj.needHotel = record.checkInHotel
|
||
if (record.checkInHotel === 1 && record.inHotelTime) {
|
||
updateObj.inHotelTime = record.inHotelTime
|
||
}
|
||
if (record.checkInHotel === 1 && record.outHotelTime) {
|
||
updateObj.outHotelTime = record.outHotelTime
|
||
}
|
||
|
||
}
|
||
// 是否接站
|
||
if (isCoopOrExint && record.pickUp !== null) {
|
||
// this.setData({
|
||
// needPick: record.pickUp
|
||
// })
|
||
updateObj.needPick = record.pickUp
|
||
if (record.pickUp === 1 && record.arrivalTime) {
|
||
// this.setData({
|
||
// 'arrivalTime':record.arrivalTime
|
||
// })
|
||
updateObj.arrivalTime = record.arrivalTime
|
||
}
|
||
}
|
||
// 是否送站
|
||
if (isCoopOrExint && record.deliveryStation !== null) {
|
||
this.setData({
|
||
needSend: record.deliveryStation
|
||
})
|
||
updateObj.needSend = record.deliveryStation
|
||
|
||
if (record.deliveryStation === 1 && record.departureTime) {
|
||
this.setData({
|
||
'departureTime': record.departureTime
|
||
})
|
||
updateObj.departureTime = record.departureTime
|
||
}
|
||
|
||
}
|
||
this.setData({
|
||
...updateObj
|
||
})
|
||
},
|
||
formSubmit(e) {
|
||
const formData = JSON.parse(JSON.stringify(e.detail.value))
|
||
formData.guestType = this.data.info.guestType
|
||
formData.inHotelTime = this.data.info.inHotelTime
|
||
formData.outHotelTime = this.data.info.outHotelTime
|
||
formData.arrivalTime = this.data.info.arrivalTime
|
||
formData.departureTime = this.data.info.departureTime
|
||
formData.id = this.data.info.id
|
||
if (this.data.info.guestType === 1 || this.data.info.guestType === 2) {
|
||
formData.photo = this.data.info.photo
|
||
formData.speechPpt = this.data.info.speechPpt
|
||
}
|
||
// 如果会议是WASIC 需要对是否选择会议名称做校验
|
||
if (this.data.isWasic) {
|
||
let choiceArr = formData.choiceTopic
|
||
if (formData.radioKey) {
|
||
choiceArr.push(formData.radioKey)
|
||
delete formData.radioKey
|
||
}
|
||
if (formData.radioKeyTwo) {
|
||
choiceArr.push(formData.radioKeyTwo)
|
||
delete formData.radioKeyTwo
|
||
}
|
||
// 只选择一个免费参观的不能报名成功
|
||
let judgeFlag = choiceArr.filter(tt => tt !== LinkTopicsEnums.freeTwo.index + '')
|
||
if (judgeFlag.length === 0) {
|
||
wx.showToast({
|
||
title: '请至少选择一个非参观类会议',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
formData.choiceTopic = choiceArr.join(',')
|
||
}
|
||
console.log(formData)
|
||
// VIP || 演讲嘉宾 || 特邀嘉宾的校验
|
||
if (this.data.info.guestType === 1 || this.data.info.guestType === 2 || this.data.info.guestType === 3) {
|
||
if(this.data.info.guestType === 1 || this.data.info.guestType === 2) {
|
||
if (!formData.haveMeals) {
|
||
wx.showToast({
|
||
title: '请选择是否用餐',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (formData.haveMeals === "1" && !formData.huiPeople) {
|
||
wx.showToast({
|
||
title: '请选择是否回民',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
}
|
||
|
||
|
||
if (this.data.info.guestType === 1 && formData.checkInHotel && formData.checkInHotel === "1") {
|
||
if (!formData.inHotelTime) {
|
||
wx.showToast({
|
||
title: '请选择入住酒店时间',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
if (!formData.outHotelTime) {
|
||
wx.showToast({
|
||
title: '请选择离店时间',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
if (formData.inHotelTime && formData.outHotelTime) {
|
||
let flag = compareDate(formData.inHotelTime, formData.outHotelTime)
|
||
if (flag) {
|
||
wx.showToast({
|
||
title: '入住酒店时间不能大于离店时间',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
}
|
||
|
||
if (!formData.roomLayout) {
|
||
wx.showToast({
|
||
title: '请输入房型',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
}
|
||
|
||
if (!formData.pickUp) {
|
||
wx.showToast({
|
||
title: '请选择是否接站',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (formData.pickUp === "1" && !formData.arrivalTime) {
|
||
wx.showToast({
|
||
title: '请选择抵达时间',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (formData.pickUp === "1" && !formData.destination) {
|
||
wx.showToast({
|
||
title: '请选择抵达站',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (formData.pickUp === "1" && !formData.arrivalShift) {
|
||
wx.showToast({
|
||
title: '请输入到达班次',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (!formData.deliveryStation) {
|
||
wx.showToast({
|
||
title: '请选择是否送站',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (formData.deliveryStation === "1" && !formData.departureTime) {
|
||
wx.showToast({
|
||
title: '请选择离开时间',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (formData.arrivalTime && formData.departureTime) {
|
||
let flag = compareDate(formData.arrivalTime, formData.departureTime)
|
||
if (flag) {
|
||
wx.showToast({
|
||
title: '抵达时间不能大于离开时间',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
}
|
||
|
||
if (formData.deliveryStation === "1" && !formData.departureStation) {
|
||
wx.showToast({
|
||
title: '请输入离开站',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
if (formData.deliveryStation === "1" && !formData.departureShift) {
|
||
wx.showToast({
|
||
title: '请输入离开班次',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
|
||
MeetingApi.editSignUpInfo(formData).then(res => {
|
||
if (res.success) {
|
||
wx.showToast({
|
||
title: '编辑成功',
|
||
icon: 'none',
|
||
duration: 1000
|
||
})
|
||
let pages = getCurrentPages()
|
||
let prevPage = pages[pages.length - 2];
|
||
prevPage.queryPeronInfo(this.data.info.id)
|
||
wx.navigateBack({
|
||
delta: 1,
|
||
})
|
||
} else {
|
||
wx.showToast({
|
||
title: res.message,
|
||
icon: 'none',
|
||
duration: 1000
|
||
})
|
||
}
|
||
})
|
||
|
||
} else {
|
||
if (this.data.info.arrivalTime && this.data.info.departureTime) {
|
||
let flag = compareDate(this.data.info.arrivalTime, this.data.info.departureTime)
|
||
if (flag) {
|
||
wx.showToast({
|
||
title: '抵达时间不能大于离开时间',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
return
|
||
}
|
||
}
|
||
const param = {
|
||
arrivalTime: this.data.info.arrivalTime,
|
||
departureTime: this.data.info.departureTime,
|
||
id: this.data.info.id,
|
||
guestType: this.data.info.guestType,
|
||
choiceTopic: formData.choiceTopic
|
||
}
|
||
// 合作伙伴不需要校验
|
||
MeetingApi.editSignUpInfo(param).then(res => {
|
||
if (res.success) {
|
||
wx.showToast({
|
||
title: '编辑成功',
|
||
icon: 'none',
|
||
duration: 1000
|
||
})
|
||
let pages = getCurrentPages()
|
||
let prevPage = pages[pages.length - 2];
|
||
prevPage.queryPeronInfo(this.data.info.id)
|
||
wx.navigateBack({
|
||
delta: 1,
|
||
})
|
||
} else {
|
||
wx.showToast({
|
||
title: res.message,
|
||
icon: 'none',
|
||
duration: 1000
|
||
})
|
||
}
|
||
})
|
||
|
||
}
|
||
},
|
||
// 抵达时间选择
|
||
bindDateChangeArriveTime(e) {
|
||
this.setData({
|
||
arrivalTime: e.detail.value,
|
||
'info.arrivalTime': e.detail.value
|
||
})
|
||
},
|
||
// 离开时间选择
|
||
bindDateChangeLeaveTime(e) {
|
||
this.setData({
|
||
departureTime: e.detail.value,
|
||
'info.departureTime': e.detail.value
|
||
})
|
||
},
|
||
// 入住酒店时间
|
||
bindDateChangeInHotelTime(e) {
|
||
this.setData({
|
||
inHotelTime: e.detail.value,
|
||
'info.inHotelTime': e.detail.value
|
||
})
|
||
},
|
||
// 离店时间选择
|
||
bindDateChangeOutHotelTime(e) {
|
||
this.setData({
|
||
outHotelTime: e.detail.value,
|
||
'info.outHotelTime': e.detail.value
|
||
})
|
||
},
|
||
// 是否用餐
|
||
needHaveMeal(e) {
|
||
let value = Number(e.detail.value)
|
||
this.setData({
|
||
haveMeal: value
|
||
})
|
||
},
|
||
// 是否住酒店
|
||
needHotel(e) {
|
||
let value = Number(e.detail.value)
|
||
this.setData({
|
||
needHotel: value,
|
||
inHotelTime: '请选择入住酒店时间',
|
||
outHotelTime: '请选择离店时间'
|
||
})
|
||
console.log(this.data.needHotel)
|
||
|
||
},
|
||
// 是否接站
|
||
needPick(e) {
|
||
let value = Number(e.detail.value)
|
||
this.setData({
|
||
needPick: value,
|
||
arrivalTime: '请选择抵达时间'
|
||
})
|
||
},
|
||
// 是否送站
|
||
needSend(e) {
|
||
let value = Number(e.detail.value)
|
||
this.setData({
|
||
needSend: value,
|
||
departureTime: '请选择离开时间'
|
||
})
|
||
},
|
||
//参会人信息
|
||
queryPeronInfo(id) {
|
||
MeetingApi.queryPersongInfoById({
|
||
id: id
|
||
}).then(res => {
|
||
if (res.success) {
|
||
this.initGuestType(res.result.guestType)
|
||
this.setData({
|
||
info: res.result,
|
||
})
|
||
this.initForm(this.data.info)
|
||
if(this.data.isWasic) {
|
||
// 会议id查询当前绑定的课题信息
|
||
this.getLinkTopicsOptionArr(res.result.meetingId)
|
||
}
|
||
// 演讲ppt、
|
||
if (res.result.speechPpt) {
|
||
this.initFileList(res.result.speechPpt).then(res => {
|
||
this.setData({
|
||
speechPptList: res
|
||
})
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
// 获取图片的id
|
||
getImagesId(e) {
|
||
this.setData({
|
||
'info.photo': e.detail.join(',')
|
||
})
|
||
},
|
||
// ppt的上传
|
||
uploadPPT() {
|
||
const that = this
|
||
wx.chooseMessageFile({
|
||
count: 1, //能选择文件的数量
|
||
type: 'file', //能选择文件的类型,我这里只允许上传文件.还有视频,图片,或者都可以
|
||
success(res) {
|
||
console.log(res);
|
||
var size = res.tempFiles[0].size;
|
||
var name = res.tempFiles[0].name;
|
||
var temporaryPdfArr = [];
|
||
temporaryPdfArr.push(res.tempFiles[0]);
|
||
var filePath = res.tempFiles[0].path;
|
||
if (size > 10485760) { //限制了文件的大小和具体文件类型
|
||
wx.showToast({
|
||
title: '文件大小不能超过10MB',
|
||
icon: "none",
|
||
duration: 2000,
|
||
mask: true
|
||
})
|
||
} else {
|
||
wx.showLoading({
|
||
title: '上传中...',
|
||
mask: true,
|
||
});
|
||
// 如果多个文件 要循环上传
|
||
wx.uploadFile({
|
||
url: baseUrl + URL_CONFIG + 'sys/common/upload', //上传的路径
|
||
filePath: filePath, //刚刚在data保存的文件路径
|
||
name: 'file', //后台获取的凭据
|
||
success(res) {
|
||
var fileBackDa = JSON.parse(res.data);
|
||
console.log(fileBackDa);
|
||
var backPdfArr = [];
|
||
backPdfArr.push(fileBackDa)
|
||
wx.hideLoading(); //隐藏提示框
|
||
//上传成功,
|
||
const fileList = [{
|
||
name: name,
|
||
id: 'fileBackDa.result.id'
|
||
}]
|
||
that.setData({
|
||
tempFiles: name,
|
||
'info.speechPpt': fileBackDa.result.id,
|
||
speechPptList: fileList
|
||
});
|
||
}
|
||
})
|
||
}
|
||
}
|
||
})
|
||
},
|
||
// 通过文件id获取文件的相关信息
|
||
getFileInfo(id) {
|
||
return new Promise(resolve => {
|
||
let result = {}
|
||
MeetingApi.queryFileInfoById({
|
||
id: id
|
||
}).then(res => {
|
||
if (res.success) {
|
||
result = res.result
|
||
}
|
||
}).finally(() => {
|
||
resolve(result)
|
||
})
|
||
})
|
||
},
|
||
// 获取文件信息
|
||
async initFileList(fileIds) {
|
||
if (fileIds) {
|
||
const fileList = []
|
||
let arr = fileIds.split(',')
|
||
for (let i = 0; i < arr.length; i++) {
|
||
let fileObj = {}
|
||
fileObj = await this.getFileInfo(arr[i])
|
||
fileList.push({
|
||
id: fileObj.id,
|
||
name: fileObj.fileName
|
||
})
|
||
}
|
||
return fileList
|
||
}
|
||
},
|
||
// 取消会议名称的选中
|
||
cancelChoiceTopic() {
|
||
let updateObj = {}
|
||
this.updateCheckboxArr(this.data.showTopicsArr, [], 'all')
|
||
updateObj.showTopicsArr = this.data.showTopicsArr
|
||
this.setData({
|
||
...updateObj
|
||
})
|
||
|
||
},
|
||
// 获取国际研讨会-能选择课题的数据字典数据
|
||
getLinkTopicsOptionArr(meetingId) {
|
||
MeetingApi.getLinkTopics({
|
||
id: meetingId
|
||
}).then(res => {
|
||
if (res.success) {
|
||
let arr = res.result || []
|
||
this.data.showTopicsArr.map(tt => {
|
||
tt.children.map(item => {
|
||
let ele = arr.find(a => a.value + '' === item.value)
|
||
if (ele) {
|
||
item.text = ele.text
|
||
item.title = ele.title
|
||
}
|
||
})
|
||
tt.radioChildren && tt.radioChildren.map(item => {
|
||
let ele = arr.find(a => a.value + '' === item.value)
|
||
if (ele) {
|
||
item.text = ele.text
|
||
item.title = ele.title
|
||
}
|
||
})
|
||
})
|
||
const updateObj = {
|
||
showTopicsArr: this.data.showTopicsArr
|
||
}
|
||
// 选中的主题
|
||
const choiceTopic = (this.data.info.choiceTopic || '').split(',')
|
||
this.updateCheckboxArr(this.data.showTopicsArr, choiceTopic, 'all')
|
||
updateObj.showTopicsArr = this.data.showTopicsArr
|
||
|
||
this.setData({
|
||
...updateObj
|
||
})
|
||
|
||
}
|
||
})
|
||
},
|
||
// 选择的课题发生改变
|
||
changeChoiceTopic(e) {
|
||
const values = e.detail.value // 是一个数组 ['1', '2']
|
||
this.updateCheckboxArr(this.data.showTopicsArr, values, 'check')
|
||
let updateObj = {
|
||
showTopicsArr: this.data.showTopicsArr
|
||
}
|
||
this.setData({
|
||
...updateObj
|
||
})
|
||
},
|
||
changeRadioTopic(e) {
|
||
const value = e.detail.value
|
||
let keyName = e.currentTarget.dataset.name
|
||
this[keyName] = value
|
||
let pIndex = this.data.showTopicsArr.findIndex(tt => tt.radioKey === keyName)
|
||
if (pIndex > -1) {
|
||
this.data.showTopicsArr[pIndex].radioChildren.map(radioItem => {
|
||
radioItem.checked = false
|
||
if (radioItem.value === value) {
|
||
radioItem.checked = true
|
||
}
|
||
})
|
||
}
|
||
let updateObj = {
|
||
showTopicsArr: this.data.showTopicsArr
|
||
}
|
||
this.setData({
|
||
...updateObj
|
||
})
|
||
},
|
||
/**
|
||
* 更新Checkbox对应的选中状态
|
||
* @param arr-Checkbox对应的数组 和 showTopicsArr 对应的数据格式一致
|
||
* @param valueArr-选中的值-数组
|
||
* @param type-类型 ‘all’ 单选多选全都匹配; ‘check’-匹配多选 ‘radio’匹配单选
|
||
*/
|
||
updateCheckboxArr(arr, valueArr, type) {
|
||
arr.map(tt => {
|
||
if (type === 'all' || type === 'check') {
|
||
tt.children.map(item => {
|
||
item.checked = false
|
||
if (valueArr.indexOf(item.value) > -1) {
|
||
item.checked = true
|
||
}
|
||
})
|
||
}
|
||
if (type === 'all' || type === 'radio') {
|
||
tt.radioChildren && tt.radioChildren.map(item => {
|
||
item.checked = false
|
||
if (valueArr.indexOf(item.value) > -1) {
|
||
item.checked = true
|
||
}
|
||
})
|
||
}
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面加载
|
||
*/
|
||
onLoad: function (options) {
|
||
this.queryPeronInfo(options.situationId)
|
||
this.data.isWasic = !!options.isWasic
|
||
this.setData({
|
||
isWasic: this.data.isWasic
|
||
})
|
||
// this.queryPeronInfo('1526466713801809921')
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage: function () {
|
||
|
||
}
|
||
})
|