knowledge.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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="contentKnowledge"
  10. @submit="search"
  11. :model="searchForm">
  12. <el-form-item prop="tenantId">
  13. <el-select class="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="subType">
  23. <el-select v-model="searchForm.subType"
  24. clearable
  25. placeholder="请选择知识类别">
  26. <el-option label="演奏小技巧"
  27. :value="1"></el-option>
  28. <el-option label="乐理基础"
  29. :value="2"></el-option>
  30. <el-option label="乐器保养"
  31. :value="3"></el-option>
  32. <el-option label="乐曲演奏展示"
  33. :value="4"></el-option>
  34. </el-select>
  35. </el-form-item>
  36. <el-form-item prop="subjectId">
  37. <el-select v-model="searchForm.subjectId" clearable filterable placeholder="请选择声部">
  38. <el-option v-for="item in selects.subjects" :value="item.id" :label="item.name" :key="item.id"></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button native-type="submit" type="danger">搜索</el-button>
  43. </el-form-item>
  44. </save-form>
  45. <!-- 列表 -->
  46. <div class="tableWrap">
  47. <el-table :data='tableList'
  48. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  49. <el-table-column align='center'
  50. label="轮播图">
  51. <template slot-scope="scope">
  52. <img class="bannerImg"
  53. :src="scope.row.coverImage"
  54. alt="">
  55. </template>
  56. </el-table-column>
  57. <el-table-column align='center'
  58. prop="title"
  59. label="标题">
  60. </el-table-column>
  61. <el-table-column align='center'
  62. label="跳转连接">
  63. <template slot-scope="scope">
  64. <overflow-text width="100%" :text="scope.row.linkUrl + '/' + scope.row.id"></overflow-text>
  65. <!-- {{ scope.row.linkUrl + '/' + scope.row.id }} -->
  66. </template>
  67. </el-table-column>
  68. <el-table-column align='center'
  69. prop="remark"
  70. label="是否使用">
  71. <template slot-scope="scope">
  72. {{ scope.row.status == 1 ? '是' : '否' }}
  73. </template>
  74. </el-table-column>
  75. <el-table-column align='center'
  76. prop="createTime"
  77. label="创建时间">
  78. <template slot-scope="scope">
  79. {{ scope.row.createTime ? scope.row.createTime.split(' ')[0] : '--' }}
  80. </template>
  81. </el-table-column>
  82. <el-table-column align='center'
  83. prop="subType"
  84. label="知识类别">
  85. <template slot-scope="scope">
  86. {{ scope.row.subType | formatSubType }}
  87. </template>
  88. </el-table-column>
  89. <el-table-column align='center'
  90. prop="subjectName"
  91. label="所属声部">
  92. <template slot-scope="scope">
  93. {{ scope.row.subjectName }}
  94. </template>
  95. </el-table-column>
  96. <el-table-column align='center'
  97. prop="order"
  98. label="排序">
  99. </el-table-column>
  100. <el-table-column align="center"
  101. prop="remark"
  102. label="适用范围">
  103. <template slot-scope="scope">
  104. <p v-if=" scope.row.tenantId == 1">对内</p>
  105. <p v-if=" scope.row.tenantId == 2">对外</p>
  106. </template>
  107. </el-table-column>
  108. <el-table-column align='center'
  109. label="操作">
  110. <template slot-scope="scope">
  111. <el-button @click="openTeaching('update', scope.row)"
  112. v-if="!scope.row.memo || permission('banner/copyrightbtn')"
  113. type="text">修改</el-button>
  114. <div style="display: inline-block"
  115. v-if="!scope.row.memo || permission('banner/copyrightbtn')">
  116. <el-button v-if="scope.row.status == 1"
  117. @click="onStop(scope.row, 0)"
  118. type="text">停用</el-button>
  119. <el-button v-else
  120. @click="onStop(scope.row, 1)"
  121. type="text">启用</el-button>
  122. </div>
  123. <el-button @click="onDel(scope.row)"
  124. v-if="!scope.row.memo || permission('banner/copyrightbtn')"
  125. type="text">删除</el-button>
  126. </template>
  127. </el-table-column>
  128. </el-table>
  129. <pagination
  130. saveKey="contentKnowledge"
  131. sync :total.sync="pageInfo.total"
  132. :page.sync="pageInfo.page"
  133. :limit.sync="pageInfo.limit"
  134. :page-sizes="pageInfo.page_size"
  135. @pagination="getList" />
  136. </div>
  137. </div>
  138. </template>
  139. <script>
  140. import { newsList, newsUpdate, newsDel } from '@/api/contentManager'
  141. import pagination from '@/components/Pagination/index'
  142. import store from '@/store'
  143. import cleanDeep from 'clean-deep'
  144. import { permission } from '@/utils/directivePage'
  145. export default {
  146. name: 'knowledge',
  147. components: {
  148. pagination
  149. },
  150. data () {
  151. return {
  152. searchForm: {
  153. tenantId: '1',
  154. subjectId: null,
  155. subType: null,
  156. },
  157. tableList: [],
  158. organId: null,
  159. teacherId: this.$route.query.teacherId,
  160. pageInfo: {
  161. // 分页规则
  162. limit: 10, // 限制显示条数
  163. page: 1, // 当前页
  164. total: 1, // 总条数
  165. page_size: [10, 20, 40, 50] // 选择限制显示条数
  166. }
  167. }
  168. },
  169. mounted () {
  170. this.$store.dispatch('setSubjects')
  171. this.getList()
  172. },
  173. methods: {
  174. search() {
  175. this.pageInfo.page = 1
  176. this.getList()
  177. },
  178. permission (str) {
  179. return permission(str)
  180. },
  181. getList () {
  182. let params = {
  183. clientName: 'manage',
  184. tenantId: this.searchForm.tenantId,
  185. subType: this.searchForm.subType,
  186. subjectId: this.searchForm.subjectId,
  187. rows: this.pageInfo.limit,
  188. page: this.pageInfo.page,
  189. type: 7
  190. }
  191. newsList(cleanDeep(params)).then(res => {
  192. if (res.code == 200) {
  193. this.tableList = res.data.rows
  194. this.pageInfo.total = res.data.total
  195. }
  196. })
  197. },
  198. openTeaching (type, rows) {
  199. let params = {}
  200. if (type == 'update') {
  201. params.id = rows.id
  202. }
  203. params.type = 7
  204. params.pageType = type
  205. this.$router.push({
  206. path: '/contentManager/contentOperation',
  207. query: params
  208. })
  209. },
  210. onDel (row) { // 删除
  211. this.$confirm('确定是否删除?', '提示', {
  212. confirmButtonText: '确定',
  213. cancelButtonText: '取消',
  214. type: 'warning'
  215. }).then(() => {
  216. newsDel({ id: row.id }).then(res => {
  217. if (res.code == 200) {
  218. this.$message.success('删除成功')
  219. this.getList()
  220. } else {
  221. this.$message.error(res.msg)
  222. }
  223. })
  224. }).catch(() => { })
  225. },
  226. onStop (row, status) { // 停止
  227. // newsUpdate
  228. let tempStr = ['停用', '启用']
  229. newsUpdate({
  230. id: row.id,
  231. status: status
  232. }).then(res => {
  233. if (res.code == 200) {
  234. this.$message.success(tempStr[status] + '成功')
  235. this.getList()
  236. } else {
  237. this.$message.error(res.msg)
  238. }
  239. })
  240. }
  241. },
  242. filters: {
  243. formatSubType (val) {
  244. const template = {
  245. 1: '演奏小技巧',
  246. 2: '乐理基础',
  247. 3: '乐器保养',
  248. 4: '乐曲演奏展示'
  249. }
  250. return template[val]
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss" scoped>
  256. .bannerImg {
  257. height: 60px;
  258. }
  259. </style>