index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div class="menuManage app-container">
  3. <div class="search">
  4. <div>
  5. <el-input
  6. v-model="query.columnName"
  7. size="small"
  8. placeholder="请输入名称"
  9. class="item-width-200 "
  10. ></el-input>
  11. <el-button
  12. class="ml10"
  13. type="primary"
  14. size="small"
  15. icon="el-icon-search"
  16. @click="handleSearch"
  17. >
  18. 搜索
  19. </el-button>
  20. <!-- <el-select
  21. v-model="query.columnId"
  22. size="small"
  23. clearable
  24. class="item-width-200 ml10"
  25. placeholder="请选择栏目"
  26. >
  27. <el-option
  28. v-for="item in options"
  29. :key="item.value"
  30. :label="item.label"
  31. :value="item.value"
  32. >
  33. </el-option>
  34. </el-select> -->
  35. </div>
  36. <el-button class="add-btn" type="primary" size="small" v-if="btnAuthObj.addColumn" @click="handleAdd"
  37. >添加</el-button
  38. >
  39. </div>
  40. <el-table
  41. :data="tableData"
  42. tooltip-effect="dark"
  43. border
  44. v-loading="loading"
  45. style="width: 100%"
  46. >
  47. <el-table-column
  48. prop="imgUrl"
  49. align="center"
  50. label="栏目背景图"
  51. show-overflow-tooltip
  52. >
  53. <template slot-scope="scope">
  54. <img class="icon" :src="scope.row.columnImg" alt="">
  55. </template>
  56. </el-table-column>
  57. <el-table-column
  58. prop="columnName"
  59. align="center"
  60. label="栏目名称"
  61. show-overflow-tooltip
  62. >
  63. </el-table-column>
  64. <el-table-column
  65. prop="columnMsg"
  66. align="center"
  67. label="栏目描述"
  68. show-overflow-tooltip
  69. >
  70. </el-table-column>
  71. <el-table-column
  72. align="center"
  73. label="小程序"
  74. show-overflow-tooltip
  75. >
  76. <template slot-scope="scope">
  77. <span>{{scope.row.belongType ==2?'慧研学':'贵大'}}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column
  81. prop="sort"
  82. align="center"
  83. label="排序"
  84. show-overflow-tooltip
  85. >
  86. </el-table-column>
  87. <el-table-column
  88. prop="status"
  89. align="center"
  90. label="状态"
  91. show-overflow-tooltip
  92. >
  93. <template slot-scope="scope">
  94. <span :class="[scope.row.status == 2?'red':'green']">{{scope.row.status == 2?"隐藏 ":"显示"}}</span>
  95. </template>
  96. </el-table-column>
  97. <el-table-column prop="address" align="center" label="操作">
  98. <template slot-scope="scope">
  99. <el-button type="text" size="small" v-if="$route.query.title != '二级栏目'" @click="handle(scope.row.id)">查看下级</el-button>
  100. <el-button type="text" size="small" v-if="btnAuthObj.editColumn" @click="handleEdit(scope.row)">编辑</el-button>
  101. <el-button type="text" size="small" v-if="btnAuthObj.delColumn" @click="handleDel(scope.row.id)">删除</el-button>
  102. </template>
  103. </el-table-column>
  104. </el-table>
  105. <div class="page-box">
  106. <el-pagination
  107. @size-change="handleSizeChange"
  108. @current-change="handleCurrentChange"
  109. background
  110. :current-page="query.currentPage"
  111. :page-sizes="[10, 20, 30, 40]"
  112. :page-size="query.pageSize"
  113. layout="total, sizes, prev, pager, next, jumper"
  114. :total="total"
  115. >
  116. </el-pagination>
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import { debounce } from "@/utils/index";
  122. import {getList,del} from '@/api/study';
  123. export default {
  124. name: "menuManage",
  125. data() {
  126. return {
  127. tableData: [],
  128. options:[],
  129. loading: false,
  130. query: {
  131. columnId: 0,
  132. columnName: "",
  133. currentPage: 1,
  134. pageSize: 10,
  135. },
  136. title: "",
  137. total: 0,
  138. };
  139. },
  140. // watch: {
  141. // query: {
  142. // handler: debounce(function (val) {
  143. // this.getList()
  144. // }),
  145. // deep: true,
  146. // },
  147. // },
  148. methods: {
  149. handleSearch(){
  150. this.query.currentPage = 1
  151. this.getList();
  152. },
  153. handle(id){
  154. let title,parentId
  155. if(!this.$route.query.title){
  156. title = '二级栏目'
  157. parentId = id
  158. }else if(this.$route.query.title == '二级栏目'){
  159. title = '三级栏目'
  160. parentId = this.$route.query.parentId
  161. }
  162. this.$router.push({
  163. path:'/studyManage/menuManage/index',
  164. query:{
  165. id,
  166. parentId,
  167. title
  168. }
  169. })
  170. },
  171. handleEdit(row){
  172. sessionStorage.setItem('studyMenu',JSON.stringify(row))
  173. this.$router.push({
  174. path:'/studyManage/menuManage/addMenu',
  175. query:{
  176. mode:'edit',
  177. title:'编辑栏目',
  178. id:this.$route.query.id,
  179. parentId:this.$route.query.parentId || 0,
  180. level:this.$route.query.title
  181. }
  182. })
  183. },
  184. handleAdd(){
  185. this.$router.push({
  186. path:'/studyManage/menuManage/addMenu',
  187. query:{
  188. id:this.$route.query.id,
  189. parentId:this.$route.query.parentId || 0,
  190. level:this.$route.query.title
  191. }
  192. })
  193. },
  194. // 点击删除
  195. handleDel(id) {
  196. this.$confirm(`此操作将删除该数据, 是否继续?`, '提示', {
  197. confirmButtonText: '确定',
  198. cancelButtonText: '取消',
  199. type: 'warning'
  200. }).then(() => {
  201. del({columnId:id}).then(res=>{
  202. if(res.state == 'Success'){
  203. this.$notify({
  204. title: '成功',
  205. message: '操作成功',
  206. type: 'success'
  207. });
  208. this.getList()
  209. }
  210. })
  211. })
  212. },
  213. handleSizeChange(val) {
  214. this.query.currentPage = 1;
  215. this.query.pageSize = val;
  216. this.getList()
  217. },
  218. handleCurrentChange(val) {
  219. this.query.currentPage = val;
  220. this.getList()
  221. },
  222. getList(){
  223. this.loading = true
  224. getList(this.query).then(res=>{
  225. this.loading = false
  226. if(res.state == 'Success'){
  227. this.tableData = res.content.records
  228. this.total = res.content.total
  229. }
  230. })
  231. }
  232. },
  233. created() {
  234. this.query.columnId = this.$route.query.id || 0
  235. this.getList()
  236. },
  237. };
  238. </script>
  239. <style lang="scss" scoped>
  240. .menuManage {
  241. .search{
  242. justify-content: space-between;
  243. }
  244. .icon{
  245. width: 80px;
  246. height: 80px;
  247. }
  248. }
  249. </style>