flashPage.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <div>
  3. <!-- 搜索标题 -->
  4. <div @click="openTeaching('create')"
  5. class='newBand'>新建</div>
  6. <!-- 搜索标题 -->
  7. <save-form :inline="true"
  8. class="searchForm"
  9. saveKey="contentFlashPage"
  10. @submit="search"
  11. :model="searchForm">
  12. <el-form-item prop="organId">
  13. <el-select class="multiple" clearable
  14. filterable
  15. v-model.trim="searchForm.organId"
  16. placeholder="请选择分部">
  17. <el-option v-for="(item,index) in selects.branchs"
  18. :key="index"
  19. :label="item.name"
  20. :value="item.id"></el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item>
  24. <el-button native-type="submit" type="danger">搜索</el-button>
  25. </el-form-item>
  26. </save-form>
  27. <!-- 列表 -->
  28. <div class="tableWrap">
  29. <el-table :data='tableList'
  30. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  31. <el-table-column align='center'
  32. label="轮播图">
  33. <template slot-scope="scope">
  34. <img class="bannerImg"
  35. :src="scope.row.coverImage"
  36. alt="">
  37. </template>
  38. </el-table-column>
  39. <el-table-column align='center'
  40. prop="title"
  41. label="标题">
  42. </el-table-column>
  43. <el-table-column align='center'
  44. label="跳转连接">
  45. <template slot-scope="scope">
  46. <overflow-text :text="scope.row.linkUrl"></overflow-text>
  47. <!-- {{ scope.row.linkUrl }} -->
  48. </template>
  49. </el-table-column>
  50. <el-table-column align='center'
  51. prop="remark"
  52. label="是否使用">
  53. <template slot-scope="scope">
  54. {{ scope.row.status == 1 ? '是' : '否' }}
  55. </template>
  56. </el-table-column>
  57. <el-table-column align='center'
  58. prop="order"
  59. label="排序">
  60. </el-table-column>
  61. <el-table-column align="center"
  62. prop="remark"
  63. label="适用分部">
  64. <template slot-scope="scope">
  65. <overflow-text :text="scope.row.organNameList"></overflow-text>
  66. </template>
  67. </el-table-column>
  68. <el-table-column align='center'
  69. label="操作">
  70. <template slot-scope="scope">
  71. <el-button @click="openTeaching('update', scope.row)"
  72. type="text">修改</el-button>
  73. <el-button v-if="scope.row.status == 1"
  74. @click="onStop(scope.row, 0)"
  75. type="text">停用</el-button>
  76. <el-button v-else
  77. @click="onStop(scope.row, 1)"
  78. type="text">启用</el-button>
  79. <el-button @click="onDel(scope.row)"
  80. type="text">删除</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <pagination
  85. saveKey="contentFlashPage"
  86. sync :total.sync="pageInfo.total"
  87. :page.sync="pageInfo.page"
  88. :limit.sync="pageInfo.limit"
  89. :page-sizes="pageInfo.page_size"
  90. @pagination="getList" />
  91. </div>
  92. </div>
  93. </template>
  94. <script>
  95. import { newsList, newsUpdate, newsDel } from '@/api/contentManager'
  96. import pagination from '@/components/Pagination/index'
  97. export default {
  98. name: 'banner',
  99. components: {
  100. pagination
  101. },
  102. data () {
  103. return {
  104. searchForm: {
  105. organId: null
  106. },
  107. tableList: [],
  108. teacherId: this.$route.query.teacherId,
  109. pageInfo: {
  110. // 分页规则
  111. limit: 10, // 限制显示条数
  112. page: 1, // 当前页
  113. total: 1, // 总条数
  114. page_size: [10, 20, 40, 50] // 选择限制显示条数
  115. }
  116. }
  117. },
  118. mounted () {
  119. this.$store.dispatch("setBranchs");
  120. this.getList()
  121. },
  122. methods: {
  123. search() {
  124. this.pageInfo.page = 1
  125. this.getList()
  126. },
  127. getList () {
  128. let params = {
  129. clientName: 'manage',
  130. organId: this.searchForm.organId,
  131. rows: this.pageInfo.limit,
  132. page: this.pageInfo.page,
  133. type: 5
  134. }
  135. newsList(params).then(res => {
  136. if (res.code == 200) {
  137. this.tableList = res.data.rows
  138. this.pageInfo.total = res.data.total
  139. }
  140. })
  141. },
  142. openTeaching (type, rows) {
  143. let params = {}
  144. if (type == 'update') {
  145. params.id = rows.id
  146. }
  147. params.type = 5
  148. params.pageType = type
  149. this.$router.push({
  150. path: '/contentManager/contentOperation',
  151. query: params
  152. })
  153. },
  154. onDel (row) { // 删除
  155. this.$confirm('确定是否删除?', '提示', {
  156. confirmButtonText: '确定',
  157. cancelButtonText: '取消',
  158. type: 'warning'
  159. }).then(() => {
  160. newsDel({ id: row.id }).then(res => {
  161. if (res.code == 200) {
  162. this.$message.success('删除成功')
  163. this.getList()
  164. } else {
  165. this.$message.error(res.msg)
  166. }
  167. })
  168. }).catch(() => { })
  169. },
  170. onStop (row, status) { // 停止
  171. // newsUpdate
  172. let tempStr = ['停用', '启用']
  173. newsUpdate({
  174. id: row.id,
  175. status: status
  176. }).then(res => {
  177. if (res.code == 200) {
  178. this.$message.success(tempStr[status] + '成功')
  179. this.getList()
  180. } else {
  181. this.$message.error(res.msg)
  182. }
  183. })
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .bannerImg {
  190. height: 60px;
  191. }
  192. </style>