index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. <template>
  2. <div class="app-container">
  3. <el-card class="operate-container" shadow="never">
  4. <i class="el-icon-tickets" style="margin-top: 5px"></i>
  5. <<<<<<< HEAD
  6. <span style="margin-top: 5px;">数据列表</span>
  7. <el-button class="btn-add" @click="handleAddMenu()" size="mini">
  8. =======
  9. <span style="margin-top: 5px">数据列表</span>
  10. <el-button
  11. class="btn-add"
  12. @click="handleAddMenu()"
  13. size="mini">
  14. >>>>>>> 259d796d8a144f6fcd5b371a06c66676c11ec3e9
  15. 添加
  16. </el-button>
  17. </el-card>
  18. <div class="table-container">
  19. <<<<<<< HEAD
  20. <el-table ref="menuTable" style="width: 100%" :data="list" v-loading="listLoading" border>
  21. <el-table-column label="编号" width="100" align="center">
  22. <template slot-scope="scope">{{ scope.row.id }}</template>
  23. </el-table-column>
  24. <el-table-column label="菜单名称" align="center">
  25. <template slot-scope="scope">{{ scope.row.title }}</template>
  26. </el-table-column>
  27. <el-table-column label="菜单级数" width="100" align="center">
  28. <template slot-scope="scope">{{ scope.row.level | levelFilter }}</template>
  29. </el-table-column>
  30. <el-table-column label="前端名称" align="center">
  31. <template slot-scope="scope">{{ scope.row.name }}</template>
  32. =======
  33. <el-table ref="menuTable"
  34. style="width: 100%"
  35. :data="list"
  36. v-loading="listLoading" border>
  37. <el-table-column label="编号" width="100" align="center">
  38. <template slot-scope="scope">{{scope.row.id}}</template>
  39. </el-table-column>
  40. <el-table-column label="菜单名称" align="center">
  41. <template slot-scope="scope">{{scope.row.title}}</template>
  42. </el-table-column>
  43. <el-table-column label="菜单级数" width="100" align="center">
  44. <template slot-scope="scope">{{scope.row.level | levelFilter}}</template>
  45. </el-table-column>
  46. <el-table-column label="前端名称" align="center">
  47. <template slot-scope="scope">{{scope.row.name}}</template>
  48. >>>>>>> 259d796d8a144f6fcd5b371a06c66676c11ec3e9
  49. </el-table-column>
  50. <el-table-column label="前端图标" width="100" align="center">
  51. <template slot-scope="scope"><svg-icon :icon-class="scope.row.icon"></svg-icon></template>
  52. </el-table-column>
  53. <el-table-column label="是否显示" width="100" align="center">
  54. <template slot-scope="scope">
  55. <<<<<<< HEAD
  56. <el-switch @change="handleHiddenChange(scope.$index, scope.row)" :active-value="0" :inactive-value="1"
  57. =======
  58. <el-switch
  59. @change="handleHiddenChange(scope.$index, scope.row)"
  60. :active-value="0"
  61. :inactive-value="1"
  62. >>>>>>> 259d796d8a144f6fcd5b371a06c66676c11ec3e9
  63. v-model="scope.row.hidden">
  64. </el-switch>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="排序" width="100" align="center">
  68. <<<<<<< HEAD
  69. <template slot-scope="scope">{{ scope.row.sort }}</template>
  70. </el-table-column>
  71. <el-table-column label="设置" width="120" align="center">
  72. <template slot-scope="scope">
  73. <el-button size="mini" type="text" :disabled="scope.row.level | disableNextLevel"
  74. =======
  75. <template slot-scope="scope">{{scope.row.sort }}</template>
  76. </el-table-column>
  77. <el-table-column label="设置" width="120" align="center">
  78. <template slot-scope="scope">
  79. <el-button
  80. size="mini"
  81. type="text"
  82. :disabled="scope.row.level | disableNextLevel"
  83. >>>>>>> 259d796d8a144f6fcd5b371a06c66676c11ec3e9
  84. @click="handleShowNextLevel(scope.$index, scope.row)">查看下级
  85. </el-button>
  86. </template>
  87. </el-table-column>
  88. <el-table-column label="操作" width="200" align="center">
  89. <template slot-scope="scope">
  90. <<<<<<< HEAD
  91. <el-button size="mini" type="text" @click="handleUpdate(scope.$index, scope.row)">编辑
  92. </el-button>
  93. <el-button size="mini" type="text" @click="handleDelete(scope.$index, scope.row)">删除
  94. =======
  95. <el-button
  96. size="mini"
  97. type="text"
  98. @click="handleUpdate(scope.$index, scope.row)">编辑
  99. </el-button>
  100. <el-button
  101. size="mini"
  102. type="text"
  103. @click="handleDelete(scope.$index, scope.row)">删除
  104. >>>>>>> 259d796d8a144f6fcd5b371a06c66676c11ec3e9
  105. </el-button>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. </div>
  110. <div class="pagination-container">
  111. <<<<<<< HEAD
  112. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  113. layout="total, sizes,prev, pager, next,jumper" :page-size="listQuery.pageSize" :page-sizes="[10, 15, 20]"
  114. :current-page.sync="listQuery.pageNum" :total="total">
  115. =======
  116. <el-pagination
  117. background
  118. @size-change="handleSizeChange"
  119. @current-change="handleCurrentChange"
  120. layout="total, sizes,prev, pager, next,jumper"
  121. :page-size="listQuery.pageSize"
  122. :page-sizes="[10,15,20]"
  123. :current-page.sync="listQuery.pageNum"
  124. :total="total">
  125. >>>>>>> 259d796d8a144f6fcd5b371a06c66676c11ec3e9
  126. </el-pagination>
  127. </div>
  128. </div>
  129. </template>
  130. <script>
  131. <<<<<<< HEAD
  132. import { fetchList, deleteMenu, updateMenu, updateHidden } from '@/api/menu'
  133. export default {
  134. name: "menuList",
  135. data() {
  136. return {
  137. list: null,
  138. total: null,
  139. listLoading: true,
  140. listQuery: {
  141. pageNum: 1,
  142. pageSize: 30
  143. },
  144. parentId: 0
  145. }
  146. },
  147. created() {
  148. this.resetParentId();
  149. this.getList();
  150. },
  151. watch: {
  152. $route(route) {
  153. this.resetParentId();
  154. this.getList();
  155. }
  156. },
  157. methods: {
  158. resetParentId() {
  159. this.listQuery.pageNum = 1;
  160. if (this.$route.query.parentId != null) {
  161. this.parentId = this.$route.query.parentId;
  162. } else {
  163. this.parentId = 0;
  164. }
  165. },
  166. handleAddMenu() {
  167. this.$router.push('/ums/addMenu');
  168. },
  169. getList() {
  170. this.listLoading = true;
  171. fetchList(this.parentId, this.listQuery).then(response => {
  172. this.listLoading = false;
  173. this.list = response.data.list;
  174. this.total = response.data.total;
  175. });
  176. },
  177. handleSizeChange(val) {
  178. this.listQuery.pageNum = 1;
  179. this.listQuery.pageSize = val;
  180. this.getList();
  181. },
  182. handleCurrentChange(val) {
  183. this.listQuery.pageNum = val;
  184. this.getList();
  185. },
  186. handleHiddenChange(index, row) {
  187. updateHidden(row.id, { hidden: row.hidden }).then(response => {
  188. this.$message({
  189. message: '修改成功',
  190. type: 'success',
  191. duration: 1000
  192. });
  193. });
  194. },
  195. handleShowNextLevel(index, row) {
  196. this.$router.push({ path: '/ums/menu', query: { parentId: row.id } })
  197. },
  198. handleUpdate(index, row) {
  199. this.$router.push({ path: '/ums/updateMenu', query: { id: row.id } });
  200. },
  201. handleDelete(index, row) {
  202. this.$confirm('是否要删除该菜单', '提示', {
  203. confirmButtonText: '确定',
  204. cancelButtonText: '取消',
  205. type: 'warning'
  206. }).then(() => {
  207. deleteMenu(row.id).then(response => {
  208. this.$message({
  209. message: '删除成功',
  210. type: 'success',
  211. duration: 1000
  212. });
  213. this.getList();
  214. });
  215. });
  216. }
  217. },
  218. filters: {
  219. levelFilter(value) {
  220. if (value === 0) {
  221. return '一级';
  222. } else if (value === 1) {
  223. return '二级';
  224. }
  225. },
  226. disableNextLevel(value) {
  227. if (value === 0) {
  228. return false;
  229. } else {
  230. return true;
  231. }
  232. }
  233. }
  234. }
  235. </script>
  236. <style scoped></style>
  237. =======
  238. import {fetchList,deleteMenu,updateMenu,updateHidden} from '@/api/menu'
  239. export default {
  240. name: "menuList",
  241. data() {
  242. return {
  243. list: null,
  244. total: null,
  245. listLoading: true,
  246. listQuery: {
  247. pageNum: 1,
  248. pageSize:30
  249. },
  250. parentId: 0
  251. }
  252. },
  253. created() {
  254. this.resetParentId();
  255. this.getList();
  256. },
  257. watch: {
  258. $route(route) {
  259. this.resetParentId();
  260. this.getList();
  261. }
  262. },
  263. methods: {
  264. resetParentId(){
  265. this.listQuery.pageNum = 1;
  266. if (this.$route.query.parentId != null) {
  267. this.parentId = this.$route.query.parentId;
  268. } else {
  269. this.parentId = 0;
  270. }
  271. },
  272. handleAddMenu() {
  273. this.$router.push('/ums/addMenu');
  274. },
  275. getList() {
  276. this.listLoading = true;
  277. fetchList(this.parentId, this.listQuery).then(response => {
  278. this.listLoading = false;
  279. this.list = response.data.list;
  280. this.total = response.data.total;
  281. });
  282. },
  283. handleSizeChange(val) {
  284. this.listQuery.pageNum = 1;
  285. this.listQuery.pageSize = val;
  286. this.getList();
  287. },
  288. handleCurrentChange(val) {
  289. this.listQuery.pageNum = val;
  290. this.getList();
  291. },
  292. handleHiddenChange(index, row) {
  293. updateHidden(row.id,{hidden:row.hidden}).then(response=>{
  294. this.$message({
  295. message: '修改成功',
  296. type: 'success',
  297. duration: 1000
  298. });
  299. });
  300. },
  301. handleShowNextLevel(index, row) {
  302. this.$router.push({path: '/ums/menu', query: {parentId: row.id}})
  303. },
  304. handleUpdate(index, row) {
  305. this.$router.push({path:'/ums/updateMenu',query:{id:row.id}});
  306. },
  307. handleDelete(index, row) {
  308. this.$confirm('是否要删除该菜单', '提示', {
  309. confirmButtonText: '确定',
  310. cancelButtonText: '取消',
  311. type: 'warning'
  312. }).then(() => {
  313. deleteMenu(row.id).then(response => {
  314. this.$message({
  315. message: '删除成功',
  316. type: 'success',
  317. duration: 1000
  318. });
  319. this.getList();
  320. });
  321. });
  322. }
  323. },
  324. filters: {
  325. levelFilter(value) {
  326. if (value === 0) {
  327. return '一级';
  328. } else if (value === 1) {
  329. return '二级';
  330. }
  331. },
  332. disableNextLevel(value) {
  333. if (value === 0) {
  334. return false;
  335. } else {
  336. return true;
  337. }
  338. }
  339. }
  340. }
  341. </script>
  342. <style scoped>
  343. </style>
  344. >>>>>>> 259d796d8a144f6fcd5b371a06c66676c11ec3e9