banner.vue 6.3 KB

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