activity.vue 6.3 KB

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