activity.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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
  80. :saveKey="'contentActivity'"
  81. sync :total.sync="pageInfo.total"
  82. :page.sync="pageInfo.page"
  83. :limit.sync="pageInfo.limit"
  84. :page-sizes="pageInfo.page_size"
  85. @pagination="getList" />
  86. </div>
  87. </div>
  88. </template>
  89. <script>
  90. import { newsList, newsUpdate, newsDel } from "@/api/contentManager";
  91. import pagination from "@/components/Pagination/index";
  92. export default {
  93. name: "activity",
  94. components: {
  95. pagination
  96. },
  97. data () {
  98. return {
  99. searchForm: {
  100. tenantId: '1'
  101. },
  102. tableList: [],
  103. organId: null,
  104. teacherId: this.$route.query.teacherId,
  105. pageInfo: {
  106. // 分页规则
  107. limit: 10, // 限制显示条数
  108. page: 1, // 当前页
  109. total: 1, // 总条数
  110. page_size: [10, 20, 40, 50] // 选择限制显示条数
  111. }
  112. };
  113. },
  114. mounted () {
  115. this.getList();
  116. },
  117. methods: {
  118. search() {
  119. this.pageInfo.page = 1
  120. this.getList()
  121. },
  122. getList () {
  123. let params = {
  124. clientName: 'manage',
  125. tenantId: this.searchForm.tenantId,
  126. rows: this.pageInfo.limit,
  127. page: this.pageInfo.page,
  128. type: 1
  129. };
  130. newsList(params).then(res => {
  131. if (res.code == 200) {
  132. this.tableList = res.data.rows;
  133. this.pageInfo.total = res.data.total;
  134. }
  135. });
  136. },
  137. openTeaching (type, rows) {
  138. let params = {};
  139. if (type == "update") {
  140. params.id = rows.id;
  141. }
  142. params.type = 1;
  143. params.pageType = type;
  144. this.$router.push({
  145. path: "/contentManager/contentOperation",
  146. query: params
  147. });
  148. },
  149. onDel (row) {
  150. // 删除
  151. this.$confirm("确定是否删除?", "提示", {
  152. confirmButtonText: "确定",
  153. cancelButtonText: "取消",
  154. type: "warning"
  155. })
  156. .then(() => {
  157. newsDel({ id: row.id }).then(res => {
  158. if (res.code == 200) {
  159. this.$message.success("删除成功");
  160. this.getList();
  161. } else {
  162. this.$message.error(res.msg);
  163. }
  164. });
  165. })
  166. .catch(() => { });
  167. },
  168. onStop (row, status) {
  169. // 停止
  170. // newsUpdate
  171. let tempStr = ["停用", "启用"];
  172. newsUpdate({
  173. id: row.id,
  174. status: status
  175. }).then(res => {
  176. if (res.code == 200) {
  177. this.$message.success(tempStr[status] + "成功");
  178. this.getList();
  179. } else {
  180. this.$message.error(res.msg);
  181. }
  182. });
  183. }
  184. }
  185. };
  186. </script>
  187. <style lang="scss" scoped>
  188. .bannerImg {
  189. height: 60px;
  190. }
  191. </style>