appPage.vue 6.1 KB

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