validate.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* 表单校验 */
  2. export const validateForm = (type,form) => {
  3. // console.log(type)
  4. switch (type) {
  5. case '内部会议': return validateInsideMeeting(form);
  6. case '公开会议': return validateOpenMeeting(form);
  7. case '路演': return validateRoadshow(form);
  8. case '沙龙': return validateRoadshow(form);
  9. case '报告电话会': return validateTelmeeting(form);
  10. case '事项': return validateMatter(form);
  11. }
  12. }
  13. /* 内部会议校验 */
  14. const validateInsideMeeting = ({activityType,selectResearchers}) => {
  15. let haveCheck = false;
  16. const {researcherId,startTime,endTime} = selectResearchers[0];
  17. if(!activityType) {
  18. Toast('请选择活动类型');
  19. return haveCheck
  20. }
  21. if(!researcherId.length || !researcherId){
  22. Toast('请选择研究员');
  23. return haveCheck
  24. }
  25. if(!startTime){
  26. Toast('请选择开始时间');
  27. return haveCheck
  28. }
  29. if(!endTime){
  30. Toast('请选择结束时间');
  31. return haveCheck
  32. }
  33. haveCheck = true;
  34. return haveCheck
  35. }
  36. /* 报告电话会校验 */
  37. const validateTelmeeting = ({activityType,selectResearchers,activityClass}) => {
  38. let bol1 = validateInsideMeeting({activityType,selectResearchers})
  39. if(bol1) {
  40. let haveCheck = false;
  41. if(!activityClass){
  42. Toast('请选择活动类别 ');
  43. return haveCheck
  44. }
  45. haveCheck = true;
  46. return haveCheck
  47. } else {
  48. return false
  49. }
  50. }
  51. /* 路演校验 */
  52. const validateRoadshow = ({ activityType,selectResearchers,roadshowType,roadshowPlatform,roadshowCity,companyId }) => {
  53. let haveCheck = false;
  54. if(!activityType){
  55. Toast('请选择活动类型')
  56. return haveCheck
  57. }
  58. if(!roadshowType){
  59. Toast(`请选择${activityType}形式`)
  60. return haveCheck
  61. }
  62. if(!roadshowPlatform && roadshowType === '线上'){
  63. Toast('请输入路演平台')
  64. return haveCheck
  65. }
  66. if(!roadshowCity.length && roadshowType === '线下'){
  67. Toast('请选择路演城市')
  68. return haveCheck
  69. }
  70. if(!companyId && activityType!='沙龙'){
  71. Toast('请选择客户')
  72. return haveCheck
  73. }
  74. let haveFull_rs = selectResearchers.every(item => item.researcherId);
  75. let haveFull_startTime = selectResearchers.every(item => item.startTime);
  76. let haveFull_endTime = selectResearchers.every(item => item.endTime);
  77. if(!haveFull_rs){
  78. Toast('请选择研究员')
  79. return haveCheck
  80. }
  81. if(!haveFull_startTime){
  82. Toast('请选择开始时间')
  83. return haveCheck
  84. }
  85. if(!haveFull_endTime){
  86. Toast('请选择结束时间')
  87. return haveCheck
  88. }
  89. haveCheck = true;
  90. return haveCheck
  91. }
  92. /* 公开会议校验 */
  93. const validateOpenMeeting = ({ activityType,selectResearchers,roadshowType,roadshowPlatform,roadshowCity,meetingTheme,partnersName }) => {
  94. let haveCheck = false;
  95. if(!activityType){
  96. Toast('请选择活动类型')
  97. return haveCheck
  98. }
  99. if(!roadshowType){
  100. Toast('请选择会议形式')
  101. return haveCheck
  102. }
  103. if(!roadshowPlatform && roadshowType === '线上'){
  104. Toast('请输入会议平台')
  105. return haveCheck
  106. }
  107. if(!roadshowCity.length && roadshowType === '线下'){
  108. Toast('请选择会议城市')
  109. return haveCheck
  110. }
  111. if(!meetingTheme){
  112. Toast('请输入会议主题')
  113. return haveCheck
  114. }
  115. if(!partnersName){
  116. Toast('请输入合作方名称')
  117. return haveCheck
  118. }
  119. let haveFull_rs = selectResearchers.every(item => item.researcherId);
  120. let haveFull_startTime = selectResearchers.every(item => item.startTime);
  121. let haveFull_endTime = selectResearchers.every(item => item.endTime);
  122. if(!haveFull_rs){
  123. Toast('请选择研究员')
  124. return haveCheck
  125. }
  126. if(!haveFull_startTime){
  127. Toast('请选择开始时间')
  128. return haveCheck
  129. }
  130. if(!haveFull_endTime){
  131. Toast('请选择结束时间')
  132. return haveCheck
  133. }
  134. haveCheck = true;
  135. return haveCheck
  136. }
  137. /* 事项校验 */
  138. const validateMatter = ({ startTime,endTime,matterContent }) => {
  139. let haveCheck = false;
  140. if(!matterContent) {
  141. Toast('请输入事项内容');
  142. return haveCheck
  143. }
  144. if(!startTime){
  145. Toast('请选择开始时间');
  146. return haveCheck
  147. }
  148. if(!endTime){
  149. Toast('请选择结束时间');
  150. return haveCheck
  151. }
  152. haveCheck = true;
  153. return haveCheck
  154. }
  155. /* 提示框 */
  156. export const Toast = (title,icon="none",duration=1500) => {
  157. uni.showToast({
  158. title,
  159. icon,
  160. duration
  161. })
  162. }