notice.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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-input @clear="getData()" clearable v-model="queryParams.name" placeholder="请输入公告名称" size="mini"></el-input>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="4">
  13. <el-form-item label-width="10" style='margin-left:10px'>
  14. <el-button type="primary" @click="getData" size="mini">筛选</el-button>
  15. <el-button
  16. type="primary"
  17. plain
  18. icon="el-icon-plus"
  19. size="mini"
  20. @click="handleAdd"
  21. >新增公告</el-button>
  22. </el-form-item>
  23. </el-col>
  24. </el-row>
  25. </el-form>
  26. <el-table v-loading='loading' :data="list" style="width: 100%;margin-top:10px;" height="50vh">
  27. <el-table-column align="center" prop="name" label="公告名称"/>
  28. <el-table-column align="center" prop="ctime" label="创建时间"/>
  29. <el-table-column align="center" prop="date" label="状态">
  30. <template slot-scope="scope">
  31. <span v-if="scope.row.status==1">编辑中</span>
  32. <span v-if="scope.row.status==2">上线</span>
  33. <span v-if="scope.row.status==-1">下线</span>
  34. </template>
  35. </el-table-column>
  36. <el-table-column align="center" prop="date" label="操作">
  37. <template slot-scope="scope">
  38. <el-button @click="handleEdit(scope.row)" size="mini" type="warning">编辑</el-button>
  39. <el-button @click="del(scope.row.id)" size="mini" type="danger">删除</el-button>
  40. </template>
  41. </el-table-column>
  42. </el-table>
  43. <Page
  44. ref="pageButton"
  45. :current="form.page"
  46. :page_size="form.page_size"
  47. :total="total"
  48. @pageChange="gopage"
  49. />
  50. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  51. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  52. <el-form-item label="比赛名称" prop="name">
  53. <el-input clearable v-model="form.name" placeholder="请输入比赛名称"></el-input>
  54. </el-form-item>
  55. <el-form-item label="开始时间" prop="start_time">
  56. <el-date-picker
  57. v-model="form.start_time"
  58. type="date"
  59. placeholder="选择日期"
  60. format="yyyy-MM-dd"
  61. value-format="yyyy-MM-dd"
  62. size="mini"
  63. >
  64. </el-date-picker>
  65. </el-form-item>
  66. <el-form-item label="结束时间" prop="end_time">
  67. <el-date-picker
  68. v-model="form.end_time"
  69. type="date"
  70. placeholder="选择日期"
  71. format="yyyy-MM-dd"
  72. value-format="yyyy-MM-dd"
  73. size="mini"
  74. >
  75. </el-date-picker>
  76. </el-form-item>
  77. </el-form>
  78. <div slot="footer" class="dialog-footer">
  79. <el-button type="primary" @click="submitForm">确 定</el-button>
  80. <el-button @click="open=false">取 消</el-button>
  81. </div>
  82. </el-dialog>
  83. </section>
  84. </template>
  85. <script>
  86. import Page from "../../components/Page";
  87. export default {
  88. components: {
  89. Page,
  90. },
  91. data(){
  92. return{
  93. loading:false,
  94. queryParams:{
  95. page:1
  96. },
  97. form:{},
  98. list:[{},{}],
  99. total:0,
  100. title:'新增赛事',
  101. open:false,
  102. rules:{
  103. name: [
  104. { required: true, message: '请输入比赛名称', trigger: 'blur' }
  105. ],
  106. start_time: [
  107. { required: true, message: '请输入开始时间', trigger: 'blur' }
  108. ],
  109. end_time: [
  110. { required: true, message: '请输入结束时间', trigger: 'blur' }
  111. ]
  112. },
  113. matchList:[],
  114. groupList:[],
  115. userList:[]
  116. }
  117. },
  118. methods:{
  119. del(id) {
  120. this.$confirm("确定删除吗?", "提示", {
  121. type: "warning",
  122. }).then(() => {
  123. this.$api.delArticle({ id: id }).then((res) => {
  124. this.$message({
  125. message: "删除成功",
  126. type: "success",
  127. });
  128. this.getData();
  129. });
  130. });
  131. },
  132. gopage(size) {
  133. if (size) {
  134. this.queryParams.page_size = size;
  135. }
  136. this.queryParams.page = this.$refs.pageButton.page;
  137. this.getData();
  138. },
  139. getData(){
  140. this.loading = true;
  141. //
  142. this.$api.getArticleList(this.queryParams).then(res=>{
  143. this.list=res.data.data.list
  144. this.total = res.data.data.total;
  145. this.loading = false;
  146. })
  147. },
  148. handleAdd(){
  149. this.open=true;
  150. this.title='新增赛事';
  151. this.form={}
  152. this.$router.push({path:'/addNotice'})
  153. },
  154. handleEdit(row){
  155. this.open=true;
  156. this.title='新增赛事';
  157. // this.form={}
  158. this.$router.push({path:'/addNotice',query:{id:row.id}})
  159. },
  160. /** 提交按钮 */
  161. submitForm() {
  162. this.$refs["form"].validate(valid => {
  163. if (valid) {
  164. if (this.form.id != null) {
  165. this.$api.updateMatch(this.form).then(response => {
  166. this.msgSuccess("修改成功");
  167. this.open = false;
  168. this.getData();
  169. });
  170. } else {
  171. this.$api.addMatch(this.form).then(response => {
  172. this.msgSuccess("新增成功");
  173. this.open = false;
  174. this.getData();
  175. });
  176. }
  177. }
  178. });
  179. },
  180. },
  181. created(){
  182. this.getData()
  183. }
  184. }
  185. </script>