group.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <div id="group">
  3. <el-row>
  4. <el-col :span="24" class="info">
  5. <el-col :span="24" class="top">
  6. <el-col :span="15" class="title">
  7. 班级分组名单
  8. </el-col>
  9. <span v-if="role === '4'">
  10. <el-col :span="9" class="btn">
  11. <el-button type="primary" @click="clickAdd()">创建组</el-button>
  12. </el-col>
  13. </span>
  14. </el-col>
  15. <el-col :span="24" class="main">
  16. <groupList :groupList="groupList"></groupList>
  17. <!-- 删除组 -->
  18. <!-- @shanchu="shanchu" -->
  19. </el-col>
  20. <el-col :span="24" class="foot">
  21. <footInfo></footInfo>
  22. </el-col>
  23. </el-col>
  24. </el-row>
  25. <van-dialog v-model="show" title="创建小组" :showConfirmButton="false">
  26. <van-form @submit="onSubmit">
  27. <van-field v-model="form.name" name="组名" label="组名" placeholder="请输入小组名称" />
  28. <div style="margin: 16px;">
  29. <el-button type="primary" @click="onSubmit">提交</el-button>
  30. </div>
  31. </van-form>
  32. </van-dialog>
  33. </div>
  34. </template>
  35. <script>
  36. import footInfo from '@/layout/common/footInfo.vue';
  37. import groupList from '@/layout/class/groupList.vue';
  38. import { createNamespacedHelpers, mapState, mapGetters } from 'vuex';
  39. const { mapActions: mapGroup } = createNamespacedHelpers('group');
  40. export default {
  41. name: 'achieve',
  42. props: {},
  43. components: {
  44. footInfo, //底部信息
  45. groupList, //分组列表
  46. },
  47. data: () => ({
  48. role: '4',
  49. groupList: [],
  50. form: {},
  51. show: false,
  52. }),
  53. created() {
  54. this.searchInfo();
  55. },
  56. computed: {
  57. ...mapState(['user']),
  58. keyWord() {
  59. let meta = this.$route.meta;
  60. let main = meta.title || '';
  61. return main;
  62. },
  63. },
  64. methods: {
  65. ...mapGroup(['query', 'create', 'delete']),
  66. clickAdd() {
  67. this.show = true;
  68. },
  69. async searchInfo({ ...info } = {}) {
  70. const res = await this.query({ ...info });
  71. this.$set(this, `groupList`, res.data);
  72. },
  73. async onSubmit(form) {
  74. this.form.termid = this.user.termid;
  75. this.form.batchid = this.user.batchid;
  76. this.form.classid = this.user.classid;
  77. let data = this.form;
  78. console.log(this.form);
  79. let res = await this.create(data);
  80. let msg = `${this.keyWord}创建分组成功`;
  81. if (this.$checkRes(res, msg)) this.show = false;
  82. this.searchInfo();
  83. },
  84. // 删除组
  85. // async shanchu(id) {
  86. // console.log(id);
  87. // const res = await this.delete(id);
  88. // this.$checkRes(res, '删除成功', '删除失败');
  89. // this.searchInfo();
  90. // },
  91. },
  92. };
  93. </script>
  94. <style lang="less" scoped>
  95. .info {
  96. width: 100%;
  97. min-height: 667px;
  98. position: relative;
  99. background-color: #edeae8;
  100. }
  101. .top {
  102. height: 50px;
  103. line-height: 50px;
  104. margin: 0 0 10px 0;
  105. background: #fff;
  106. }
  107. .top .title {
  108. padding: 0 15px;
  109. font-size: 20px;
  110. }
  111. .top .btn {
  112. text-align: right;
  113. padding: 0 30px;
  114. }
  115. .main {
  116. margin: 0 0 50px 0;
  117. }
  118. </style>