colmo设计师沙龙pc端后台管理系统

list.vue 4.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="body">
  3. <el-card class="box-card" shadow="never">
  4. 学期名称:
  5. <el-input v-model="name" style="width: 200px; margin-right: 20px" />
  6. <div style="float:right">
  7. <el-button type="primary" @click="onSearch">查询</el-button>
  8. <el-button @click="onReset">重置</el-button>
  9. <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新建学期</el-button>
  10. </div>
  11. </el-card>
  12. <el-table stripe :data="tableData" border style="width: 100%">
  13. <el-table-column prop="name" label="学期" />
  14. <el-table-column prop="state" label="状态" width="100">
  15. <template slot-scope="scope">
  16. {{ scope.row.state === 1 ? '发布' : '未发布' }}
  17. </template>
  18. </el-table-column>
  19. <el-table-column align="center" label="操作" min-width="100" width="280">
  20. <template slot-scope="scope">
  21. <el-button style="margin-right:1em" type="text" @click="toggleState(scope.row)">{{ scope.row.state === 1 ? '取消发布' : '发布' }}</el-button>
  22. <el-link :underline="false" style="margin-right:1em" type="primary">
  23. <router-link
  24. :to="{path:'schoolTerm/Edit',query: { termId: scope.row.termId }}"
  25. >编辑</router-link>
  26. </el-link>
  27. <el-popconfirm
  28. icon="el-icon-info"
  29. icon-color="red"
  30. title="确定要删除该学期吗?"
  31. @onConfirm="handleDelete(scope.row)"
  32. >
  33. <el-link slot="reference" :underline="false" type="danger">删除</el-link>
  34. </el-popconfirm>
  35. </template>
  36. </el-table-column>
  37. </el-table>
  38. <el-pagination
  39. v-show="Total!==0"
  40. style="float:right; margin:20px 0"
  41. :total="Total"
  42. :current-page="currentPage"
  43. :page-size="pageSize"
  44. :page-sizes="[pageSize, 20, 35,40,50,80,100]"
  45. layout="total, prev, pager, next, sizes"
  46. @size-change="handleSizeChange"
  47. @current-change="handleCurrentChange"
  48. />
  49. </div>
  50. </template>
  51. <script>
  52. import { getSchoolTermList, deleteSchoolTerm, UpdateSchoolTerm } from '@/api/schoolTerm'
  53. export default {
  54. data() {
  55. return {
  56. name: undefined,
  57. tableData: [],
  58. pageSize: 10,
  59. currentPage: 1,
  60. Total: 0 // 条目总数
  61. }
  62. },
  63. mounted() {
  64. this.onSearch()
  65. },
  66. methods: {
  67. // 改变每页显示条数
  68. handleSizeChange(val) {
  69. this.pageSize = val
  70. this.changePagination()
  71. },
  72. // 改变页码
  73. handleCurrentChange(val) {
  74. this.currentPage = val
  75. this.changePagination()
  76. },
  77. // 改变分页组件重新查询数据
  78. changePagination() {
  79. getSchoolTermList({
  80. name: this.name,
  81. pageNum: this.currentPage,
  82. pageSize: this.pageSize
  83. }).then((res) => {
  84. this.tableData = res.data.records
  85. })
  86. },
  87. onSearch() {
  88. getSchoolTermList({
  89. name: this.name,
  90. pageNum: this.currentPage,
  91. pageSize: this.pageSize
  92. }).then((res) => {
  93. this.tableData = res.data.records
  94. this.Total = res.data.total
  95. })
  96. },
  97. onReset() {
  98. this.name = undefined
  99. this.onSearch()
  100. },
  101. handleAdd() {
  102. this.$router.push({ path: 'schoolTerm/edit' })
  103. },
  104. toggleState(val) {
  105. if (val.state === 1) {
  106. this.$confirm('是否将本学期取消发布,取消后移动端将不再显示相关信息?', '提示', {
  107. confirmButtonText: '确定',
  108. cancelButtonText: '取消',
  109. type: 'warning'
  110. }).then(() => {
  111. UpdateSchoolTerm({ ...val, state: 0 }, val.termId).then(() => {
  112. this.$message({
  113. type: 'success',
  114. message: '已取消发布!'
  115. })
  116. this.onSearch()
  117. })
  118. }).catch(() => {})
  119. } else {
  120. this.$confirm('是否将本学期发布,发布后移动端将显示相关信息?', '提示', {
  121. confirmButtonText: '确定',
  122. cancelButtonText: '取消',
  123. type: 'warning'
  124. }).then(() => {
  125. UpdateSchoolTerm({ ...val, state: 1 }, val.termId).then(() => {
  126. this.$message({
  127. type: 'success',
  128. message: '发布成功!'
  129. })
  130. this.onSearch()
  131. })
  132. }).catch(() => {})
  133. }
  134. },
  135. handleDelete(row) {
  136. deleteSchoolTerm(row.termId).then(() => {
  137. this.onSearch()
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. </style>