groupList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <div id="groupList">
  3. <el-row>
  4. <el-col :span="24" class="list" v-for="(item, index) in groupList" :key="index">
  5. <el-collapse accordion>
  6. <el-collapse-item>
  7. <template slot="title">
  8. <el-col :span="2">{{ index + 1 }}.</el-col>
  9. <el-col :span="6" class="groupName"> {{ item.name }} {{ item.students.length }}人</el-col>
  10. <el-col :span="24" v-if="item.status !== '1'">
  11. <el-col :span="2">
  12. <el-button v-if="item.students.length >= 10" style="width:55px" round plain type="danger" size="mini" disabled>已满员</el-button>
  13. </el-col>
  14. <el-col :span="2"></el-col>
  15. <el-col :span="6">
  16. <el-button round type="danger" style="width:55px" plain size="mini" v-if="user.job === '班长'" @click="deleteGroup(item.id)">删除</el-button>
  17. </el-col>
  18. <el-col :span="1"></el-col>
  19. <el-col :span="6">
  20. <el-button
  21. round
  22. type="success"
  23. size="mini"
  24. style="width:55px"
  25. v-if="stuIdAndGroupId.groupId === '' && item.students.length <= 10"
  26. @click="joinGroup(item.id)"
  27. >加入</el-button
  28. >
  29. <el-button round type="danger" size="mini" style="width:55px" v-if="stuIdAndGroupId.groupId === item.id" plain @click="exitGroup(item.id)"
  30. >退出</el-button
  31. >
  32. </el-col>
  33. <el-col :span="1"></el-col>
  34. <el-col :span="6" v-if="user.job === '班长'">
  35. </el-col>
  36. </el-col>
  37. </template>
  38. <el-col :span="8" class="studentslist" v-for="(itemStrudent, indexStudent) in item.students" :key="indexStudent">
  39. <el-col :span="24" @click.native="openClick(item, itemStrudent)">
  40. <span> {{ itemStrudent.stuname }}({{ itemStrudent.type == '1' ? ' 组长' : '组员' }})</span>
  41. </el-col>
  42. </el-col>
  43. <van-dialog v-model="show" title="选择组长" :showConfirmButton="false">
  44. <van-form @submit="onSubmit">
  45. <van-field readonly clickable name="picker" :value="value" label="选择组长" placeholder="点击选择组长" @click="showPicker = true" />
  46. <div style="margin:16px,16px,0,16px;text-align:center">
  47. <van-button type="info">提交</van-button>
  48. </div>
  49. </van-form>
  50. </van-dialog>
  51. <van-popup v-model="showPicker" position="bottom">
  52. <van-picker value-key="stuname" show-toolbar :columns="columns" @confirm="onConfirm" @cancel="showPicker = false" />
  53. </van-popup>
  54. </el-collapse-item>
  55. </el-collapse>
  56. </el-col>
  57. </el-row>
  58. </div>
  59. </template>
  60. <script>
  61. import { mapState, createNamespacedHelpers, mapGetters } from 'vuex';
  62. import Vue from 'vue';
  63. import { Dialog } from 'vant';
  64. // 全局注册
  65. Vue.use(Dialog);
  66. export default {
  67. name: 'groupList',
  68. props: {
  69. show: null,
  70. groupList: null,
  71. stuIdAndGroupId: null,
  72. form: null,
  73. columns: null,
  74. },
  75. components: {},
  76. data: () => ({
  77. value: '',
  78. column: ['组员', '组长'],
  79. showPicker: false,
  80. }),
  81. created() {},
  82. computed: {
  83. ...mapState(['user']),
  84. userid() {
  85. return this.user.userid;
  86. },
  87. },
  88. methods: {
  89. // 进组
  90. joinGroup(groupId) {
  91. Dialog.confirm({
  92. title: '进组',
  93. message: '确认要加入此组?',
  94. })
  95. .then(() => {
  96. this.$emit('joinGroup', { groupId });
  97. })
  98. .catch(() => {
  99. // on cancel
  100. });
  101. },
  102. // 退出组
  103. exitGroup(groupId) {
  104. Dialog.confirm({
  105. title: '退组',
  106. message: '确认要退出此组?',
  107. })
  108. .then(() => {
  109. this.$emit('exitGroup', { groupId });
  110. })
  111. .catch(() => {
  112. // on cancel
  113. });
  114. },
  115. // 删除组
  116. deleteGroup(groupId) {
  117. Dialog.confirm({
  118. title: '删除',
  119. message: '确认删除此组?',
  120. })
  121. .then(() => {
  122. this.$emit('deleteGroup', { groupId });
  123. })
  124. .catch(() => {
  125. // on cancel
  126. });
  127. },
  128. openClick(item) {
  129. this.$emit('opanSubmit', item);
  130. },
  131. onSubmit() {
  132. this.$emit('onSubmit', { data: this.form });
  133. },
  134. onConfirm(value, index) {
  135. this.value = value.stuname;
  136. this.showPicker = false;
  137. this.$emit('onvalue', { value });
  138. },
  139. onConfirms(value) {},
  140. },
  141. };
  142. </script>
  143. <style lang="less" scoped>
  144. p {
  145. padding: 0;
  146. margin: 0;
  147. }
  148. .list {
  149. background: #fff;
  150. margin: 0 5px 5px 5px;
  151. width: 97%;
  152. padding: 0 10px;
  153. border-radius: 15px;
  154. }
  155. .list .groupName {
  156. overflow: hidden;
  157. text-overflow: ellipsis;
  158. white-space: nowrap;
  159. }
  160. .childName {
  161. padding: 15px 0;
  162. font-size: 15px;
  163. }
  164. button {
  165. width: 120%;
  166. }
  167. /deep/.van-dialog {
  168. height: 400px;
  169. }
  170. .studentslist {
  171. text-align: center;
  172. padding: 5px 0;
  173. }
  174. </style>