activity.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <div>
  3. <!-- 搜索标题 -->
  4. <div @click="openTeaching('create')"
  5. class="newBand">新建</div>
  6. <!-- 搜索标题 -->
  7. <save-form :inline="true"
  8. class="searchForm"
  9. @submit="search"
  10. :saveKey="'contentActivity'"
  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="标题"></el-table-column>
  41. <el-table-column align="center"
  42. label="跳转连接">
  43. <template slot-scope="scope">
  44. <overflow-text :text="scope.row.linkUrl + '/' + scope.row.id"></overflow-text>
  45. </template>
  46. </el-table-column>
  47. <el-table-column align="center"
  48. prop="remark"
  49. label="是否使用">
  50. <template slot-scope="scope">{{ scope.row.status == 1 ? '是' : '否' }}</template>
  51. </el-table-column>
  52. <el-table-column align="center"
  53. prop="order"
  54. label="排序"></el-table-column>
  55. <el-table-column align="center"
  56. prop="remark"
  57. label="适用范围">
  58. <template slot-scope="scope">
  59. <p v-if=" scope.row.tenantId == 1">对内</p>
  60. <p v-if=" scope.row.tenantId == 2">对外</p>
  61. </template>
  62. </el-table-column>
  63. <el-table-column align="center"
  64. label="操作">
  65. <template slot-scope="scope">
  66. <el-button @click="openTeaching('update', scope.row)"
  67. type="text">修改</el-button>
  68. <el-button v-if="scope.row.status == 1"
  69. @click="onStop(scope.row, 0)"
  70. type="text">停用</el-button>
  71. <el-button v-else
  72. @click="onStop(scope.row, 1)"
  73. type="text">启用</el-button>
  74. <el-button @click="onDel(scope.row)"
  75. type="text">删除</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <pagination sync :total.sync="pageInfo.total"
  80. :page.sync="pageInfo.page"
  81. :limit.sync="pageInfo.limit"
  82. :page-sizes="pageInfo.page_size"
  83. @pagination="getList" />
  84. </div>
  85. </div>
  86. </template>
  87. <script>
  88. import { newsList, newsUpdate, newsDel } from "@/api/contentManager";
  89. import pagination from "@/components/Pagination/index";
  90. export default {
  91. name: "activity",
  92. components: {
  93. pagination
  94. },
  95. data () {
  96. return {
  97. searchForm: {
  98. tenantId: '1'
  99. },
  100. tableList: [],
  101. organId: null,
  102. teacherId: this.$route.query.teacherId,
  103. pageInfo: {
  104. // 分页规则
  105. limit: 10, // 限制显示条数
  106. page: 1, // 当前页
  107. total: 1, // 总条数
  108. page_size: [10, 20, 40, 50] // 选择限制显示条数
  109. }
  110. };
  111. },
  112. mounted () {
  113. this.getList();
  114. },
  115. methods: {
  116. search() {
  117. this.pageInfo.page = 1
  118. this.getList()
  119. },
  120. getList () {
  121. let params = {
  122. clientName: 'manage',
  123. tenantId: this.searchForm.tenantId,
  124. rows: this.pageInfo.limit,
  125. page: this.pageInfo.page,
  126. type: 1
  127. };
  128. newsList(params).then(res => {
  129. if (res.code == 200) {
  130. this.tableList = res.data.rows;
  131. this.pageInfo.total = res.data.total;
  132. }
  133. });
  134. },
  135. openTeaching (type, rows) {
  136. let params = {};
  137. if (type == "update") {
  138. params.id = rows.id;
  139. }
  140. params.type = 1;
  141. params.pageType = type;
  142. this.$router.push({
  143. path: "/contentManager/contentOperation",
  144. query: params
  145. });
  146. },
  147. onDel (row) {
  148. // 删除
  149. this.$confirm("确定是否删除?", "提示", {
  150. confirmButtonText: "确定",
  151. cancelButtonText: "取消",
  152. type: "warning"
  153. })
  154. .then(() => {
  155. newsDel({ id: row.id }).then(res => {
  156. if (res.code == 200) {
  157. this.$message.success("删除成功");
  158. this.getList();
  159. } else {
  160. this.$message.error(res.msg);
  161. }
  162. });
  163. })
  164. .catch(() => { });
  165. },
  166. onStop (row, status) {
  167. // 停止
  168. // newsUpdate
  169. let tempStr = ["停用", "启用"];
  170. newsUpdate({
  171. id: row.id,
  172. status: status
  173. }).then(res => {
  174. if (res.code == 200) {
  175. this.$message.success(tempStr[status] + "成功");
  176. this.getList();
  177. } else {
  178. this.$message.error(res.msg);
  179. }
  180. });
  181. }
  182. }
  183. };
  184. </script>
  185. <style lang="scss" scoped>
  186. .bannerImg {
  187. height: 60px;
  188. }
  189. </style>