activitiesSelectEN.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view v-if="activityData.length">
  3. <view class="activity-tip">Among multiple events of our conference, please kindly choose your preferable events to attend to(Multiple choice).</view>
  4. <view class="uni-list">
  5. <!-- <checkbox-group @change="selectAll">
  6. <label class="uni-list-cell uni-list-cell-pd">
  7. <view>
  8. <checkbox :checked="checkedAll"/>
  9. </view>
  10. <view> 全选 </view>
  11. </label>
  12. </checkbox-group> -->
  13. <checkbox-group @change="checkboxChange">
  14. <label class="uni-list-cell uni-list-cell-pd" v-for="item in activityData" :key="item.value">
  15. <view>
  16. <checkbox :value="item.id" :checked="item.checked" />
  17. </view>
  18. <view>
  19. <view style="font-weight: bold">{{ momentDate(item.activityStartTime) }} ~ {{ momentDate(item.activityEndTime) }}</view>
  20. <view>{{item.activityNameEn}}</view>
  21. </view>
  22. </label>
  23. </checkbox-group>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. props: {
  30. meetingId: {
  31. type: String,
  32. require: true
  33. }
  34. },
  35. data() {
  36. return {
  37. activityData: [],
  38. checkedIds: [],
  39. activityStartTimes: [],
  40. checkedAll: false,
  41. checkDetermine: true,
  42. }
  43. },
  44. mounted() {
  45. this.getActivityData();
  46. },
  47. methods: {
  48. selectAll(){
  49. this.checkedAll = !this.checkedAll;
  50. if(this.checkedAll){
  51. this.checkedIds = [];
  52. this.activityData.map(item=>{
  53. this.checkedIds.push(item.id);
  54. this.$set(item,'checked',true)
  55. })
  56. }else{
  57. this.checkedIds = [];
  58. this.activityData.map(item=>{
  59. this.$set(item,'checked',false)
  60. })
  61. }
  62. this.$emit('getcheckedIds', this.checkedIds.join(","))
  63. // console.log('this.checkedIds',this.checkedIds)
  64. },
  65. momentDate(date){
  66. return this.moment(date).format('lll')
  67. },
  68. async getActivityData(){
  69. console.log('meetingId', this.meetingId)
  70. const res= await this.$myRequest({
  71. url: '/meeting/meetingApplyOnlines/getActivityInfo',
  72. data: {
  73. meetingId: this.meetingId
  74. }
  75. })
  76. this.activityData = res.data.allMeetingActivitys || [];
  77. },
  78. checkboxChange: function (e) {
  79. this.checkedIds = e.detail.value;
  80. this.checkedIds.forEach((ids) =>{
  81. this.activityData.forEach((activity) => {
  82. if (activity.id === ids){
  83. console.log("判断结果:::",this.activityStartTimes.indexOf(activity.activityStartTime)>= 0);
  84. console.log("activity.activityStartTime",activity.activityStartTime);
  85. if (this.activityStartTimes.indexOf(activity.activityStartTime) >= 0){
  86. this.checkDetermine = false;
  87. uni.showToast({
  88. title: 'Kind Reminder: participants can only register for one parallel session. Hope you enjoy the conference.',
  89. icon: 'none',
  90. duration: 1500,
  91. });
  92. }else{
  93. this.activityStartTimes.push(activity.activityStartTime)
  94. }
  95. }
  96. })
  97. })
  98. console.log("轮询数组中的时间"+this.activityStartTimes)
  99. if(this.activityData.length == this.checkedIds.length){
  100. this.checkedAll = false;
  101. }else{
  102. this.checkedAll = false;
  103. }
  104. this.$emit('getcheckedIds', this.checkedIds.join(","));
  105. console.log("第一个页面中存在的数据",this.checkDetermine);
  106. this.$emit('getcheckDetermine', this.checkDetermine);
  107. // console.log(this.checkedIds)
  108. // var items = this.activityData,
  109. // values = e.detail.value;
  110. // for (var i = 0, lenI = items.length; i < lenI; ++i) {
  111. // const item = items[i]
  112. // if(values.indexOf(item.id) >= 0){
  113. // this.$'set(item,'checked',true)
  114. // }else{
  115. // this.$set(item,'checked',false)
  116. // }
  117. // }
  118. this.activityStartTimes = [];
  119. this.checkDetermine = true;
  120. }
  121. }
  122. }
  123. </script>
  124. <style scoped>
  125. .uni-list-cell {
  126. justify-content: flex-start
  127. }
  128. .activity-tip{
  129. padding: 20px;
  130. font-weight: bold;
  131. color: #333;
  132. }
  133. checkbox{
  134. transform:scale(0.7);
  135. margin-right: 10px;
  136. }
  137. </style>