groupList.vue 5.6 KB

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