/* 表单校验 */ export const validateForm = (type,form) => { // console.log(type) switch (type) { case '内部会议': return validateInsideMeeting(form); case '公开会议': return validateOpenMeeting(form); case '路演': return validateRoadshow(form); case '沙龙': return validateRoadshow(form); case '报告电话会': return validateTelmeeting(form); case '事项': return validateMatter(form); } } /* 内部会议校验 */ const validateInsideMeeting = ({activityType,selectResearchers}) => { let haveCheck = false; const {researcherId,startTime,endTime} = selectResearchers[0]; if(!activityType) { Toast('请选择活动类型'); return haveCheck } if(!researcherId.length || !researcherId){ Toast('请选择研究员'); return haveCheck } if(!startTime){ Toast('请选择开始时间'); return haveCheck } if(!endTime){ Toast('请选择结束时间'); return haveCheck } haveCheck = true; return haveCheck } /* 报告电话会校验 */ const validateTelmeeting = ({activityType,selectResearchers,activityClass}) => { let bol1 = validateInsideMeeting({activityType,selectResearchers}) if(bol1) { let haveCheck = false; if(!activityClass){ Toast('请选择活动类别 '); return haveCheck } haveCheck = true; return haveCheck } else { return false } } /* 路演校验 */ const validateRoadshow = ({ activityType,selectResearchers,roadshowType,roadshowPlatform,roadshowCity,companyId }) => { let haveCheck = false; if(!activityType){ Toast('请选择活动类型') return haveCheck } if(!roadshowType){ Toast(`请选择${activityType}形式`) return haveCheck } if(!roadshowPlatform && roadshowType === '线上'){ Toast('请输入路演平台') return haveCheck } if(!roadshowCity.length && roadshowType === '线下'){ Toast('请选择路演城市') return haveCheck } if(!companyId && activityType!='沙龙'){ Toast('请选择客户') return haveCheck } let haveFull_rs = selectResearchers.every(item => item.researcherId); let haveFull_startTime = selectResearchers.every(item => item.startTime); let haveFull_endTime = selectResearchers.every(item => item.endTime); if(!haveFull_rs){ Toast('请选择研究员') return haveCheck } if(!haveFull_startTime){ Toast('请选择开始时间') return haveCheck } if(!haveFull_endTime){ Toast('请选择结束时间') return haveCheck } haveCheck = true; return haveCheck } /* 公开会议校验 */ const validateOpenMeeting = ({ activityType,selectResearchers,roadshowType,roadshowPlatform,roadshowCity,meetingTheme,partnersName }) => { let haveCheck = false; if(!activityType){ Toast('请选择活动类型') return haveCheck } if(!roadshowType){ Toast('请选择会议形式') return haveCheck } if(!roadshowPlatform && roadshowType === '线上'){ Toast('请输入会议平台') return haveCheck } if(!roadshowCity.length && roadshowType === '线下'){ Toast('请选择会议城市') return haveCheck } if(!meetingTheme){ Toast('请输入会议主题') return haveCheck } if(!partnersName){ Toast('请输入合作方名称') return haveCheck } let haveFull_rs = selectResearchers.every(item => item.researcherId); let haveFull_startTime = selectResearchers.every(item => item.startTime); let haveFull_endTime = selectResearchers.every(item => item.endTime); if(!haveFull_rs){ Toast('请选择研究员') return haveCheck } if(!haveFull_startTime){ Toast('请选择开始时间') return haveCheck } if(!haveFull_endTime){ Toast('请选择结束时间') return haveCheck } haveCheck = true; return haveCheck } /* 事项校验 */ const validateMatter = ({ startTime,endTime,matterContent }) => { let haveCheck = false; if(!matterContent) { Toast('请输入事项内容'); return haveCheck } if(!startTime){ Toast('请选择开始时间'); return haveCheck } if(!endTime){ Toast('请选择结束时间'); return haveCheck } haveCheck = true; return haveCheck } /* 提示框 */ export const Toast = (title,icon="none",duration=1500) => { uni.showToast({ title, icon, duration }) }