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