appPage.vue 6.2 KB

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