training.vue 6.1 KB

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