training.vue 4.9 KB

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