group.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <template>
  2. <section class="content">
  3. <h4>赛事分组</h4>
  4. <el-divider></el-divider>
  5. <el-form label-width="80px" class="filter-form">
  6. <el-row>
  7. <el-col :span="6">
  8. <el-form-item label="赛事名称">
  9. <el-select v-model="queryParams.match_id" placeholder="请选择比赛" size="mini">
  10. <el-option v-for="item in matchList" :key='item.id' :label="item.name" :value="item.id"></el-option>
  11. </el-select>
  12. </el-form-item>
  13. </el-col>
  14. <el-col :span="4">
  15. <el-form-item label-width="10" style='margin-left:10px'>
  16. <el-button type="primary" @click="getData" size="mini">筛选</el-button>
  17. <el-button
  18. type="primary"
  19. plain
  20. icon="el-icon-plus"
  21. size="mini"
  22. @click="handleAdd"
  23. >新增分组</el-button>
  24. </el-form-item>
  25. </el-col>
  26. </el-row>
  27. </el-form>
  28. <el-table v-loading='loading' :data="list" style="width: 100%;margin-top:10px;" height="50vh">
  29. <el-table-column align="center" prop="name" label="分组名称"/>
  30. <el-table-column align="center" prop="match_name" label="比赛名称"/>
  31. <el-table-column align="center" prop="join_count" label="参赛人数"/>
  32. <el-table-column align="center" prop="out_count" label="退赛人数"/>
  33. <el-table-column align="center" prop="date" label="操作">
  34. <template slot-scope="scope">
  35. <el-button @click="title='编辑分组',open=true,form=scope.row" size="mini" type="warning">编辑</el-button>
  36. <el-button @click="del(scope.row.id)" size="mini" type="danger">删除</el-button>
  37. </template>
  38. </el-table-column>
  39. </el-table>
  40. <Page
  41. ref="pageButton"
  42. :current="form.page"
  43. :page_size="form.page_size"
  44. :total="total"
  45. @pageChange="gopage"
  46. />
  47. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  48. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  49. <el-form-item label="分组名称" prop="name">
  50. <el-input clearable v-model="form.name" placeholder="请输入分组名称" ></el-input>
  51. </el-form-item>
  52. <el-form-item label="比赛名称" prop="match_id">
  53. <el-select v-model="form.match_id" placeholder="请选择比赛">
  54. <el-option v-for="item in matchList" :key='item.id' :label="item.name" :value="item.id"></el-option>
  55. </el-select>
  56. </el-form-item>
  57. </el-form>
  58. <div slot="footer" class="dialog-footer">
  59. <el-button type="primary" @click="submitForm">确 定</el-button>
  60. <el-button @click="open=false">取 消</el-button>
  61. </div>
  62. </el-dialog>
  63. </section>
  64. </template>
  65. <script>
  66. import Page from "../../components/Page";
  67. export default {
  68. components: {
  69. Page,
  70. },
  71. data(){
  72. return{
  73. loading:false,
  74. queryParams:{
  75. page:1
  76. },
  77. form:{},
  78. list:[{},{}],
  79. total:0,
  80. title:'新增分组',
  81. open:false,
  82. rules:{
  83. name: [
  84. { required: true, message: '请输入分组名称', trigger: 'blur' }
  85. ],
  86. match_id: [
  87. { required: true, message: '请选择比赛', trigger: 'blur' }
  88. ],
  89. },
  90. matchList:[],
  91. groupList:[],
  92. userList:[]
  93. }
  94. },
  95. methods:{
  96. del(id) {
  97. this.$confirm("确定删除吗?", "提示", {
  98. type: "warning",
  99. }).then(() => {
  100. this.$api.delGroup({ id: id }).then((res) => {
  101. this.$message({
  102. message: "删除成功",
  103. type: "success",
  104. });
  105. this.getData();
  106. });
  107. });
  108. },
  109. gopage(size) {
  110. if (size) {
  111. this.queryParams.page_size = size;
  112. }
  113. this.queryParams.page = this.$refs.pageButton.page;
  114. this.getData();
  115. },
  116. getData(){
  117. this.loading = true;
  118. this.$api.getMatchList().then(res=>{
  119. this.matchList=res.data.data
  120. })
  121. this.$api.getGroupList().then(res=>{
  122. this.groupList=res.data.data
  123. })
  124. this.$api.getUserSearch().then(res=>{
  125. this.userList=res.data.data
  126. })
  127. //
  128. this.$api.getGroups(this.queryParams).then(res=>{
  129. this.list=res.data.data.list
  130. this.total = res.data.data.total;
  131. this.loading = false;
  132. })
  133. },
  134. handleAdd(){
  135. this.open=true;
  136. this.title='新增分组';
  137. this.form={}
  138. },
  139. /** 提交按钮 */
  140. submitForm() {
  141. this.$refs["form"].validate(valid => {
  142. if (valid) {
  143. if (this.form.id != null) {
  144. this.$api.updateGroup(this.form).then(response => {
  145. this.msgSuccess("修改成功");
  146. this.open = false;
  147. this.getData();
  148. });
  149. } else {
  150. this.$api.addGroup(this.form).then(response => {
  151. this.msgSuccess("新增成功");
  152. this.open = false;
  153. this.getData();
  154. });
  155. }
  156. }
  157. });
  158. },
  159. },
  160. created(){
  161. this.getData()
  162. }
  163. }
  164. </script>