app-role-menu-list.html 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>app菜单管理-列表</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
  7. <!-- 所有的 css & js 资源 -->
  8. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="../../static/kj/vue.min.js"></script>
  11. <script src="../../static/kj/element-ui/index.js"></script>
  12. <script src="../../static/kj/httpVueLoader.js"></script>
  13. <script src="../../static/kj/jquery.min.js"></script>
  14. <script src="../../static/kj/layer/layer.js"></script>
  15. <script src="../../static/sa.js"></script>
  16. </head>
  17. <body>
  18. <div class="vue-box" style="display: none;" :style="'display: block;'">
  19. <div class="c-panel">
  20. <!-- ------------- 检索参数 ------------- -->
  21. <el-form ref="form" :model='p' @submit.native.prevent>
  22. <!-- <sa-item type="text" name="菜单名称" v-model="p.menuName"></sa-item>
  23. <el-button type="primary" icon="el-icon-search" @click="p.pageNo = 1; f5()">查询</el-button>
  24. <el-button type="info" icon="el-icon-refresh" @click="sa.f5()">重置</el-button> -->
  25. <el-button v-if="sa.isAuth('app-menu-add')" size="mini" type="primary" @click="add()">分配权限</el-button>
  26. </el-form>
  27. <!-- ------------- 数据列表 ------------- -->
  28. <el-table class="data-table" ref="data-table" :data="dataList" >
  29. <sa-td type="selection"></sa-td>
  30. <sa-td type="index" name="序号"></sa-td>
  31. <sa-td name="菜单名称" prop="menuName" ></sa-td>
  32. <sa-td name="前端路径" prop="path"></sa-td>
  33. <sa-td name="图标" prop="icon" type="img"></sa-td>
  34. <sa-td name="排序" prop="sort" ></sa-td>
  35. <!-- <sa-td name="状态" prop="enable" type="switch" :jv="{0: '禁用[red]', 1: '启用[green]'}" @change="s => updateEnable(s.row)"></sa-td>
  36. <sa-td name="是否认证后访问" prop="auth" type="switch" :jv="{0: '否', 1: '是'}" @change="s => updateAuth(s.row)"></sa-td> -->
  37. </el-table>
  38. <!-- ------------- 分页 ------------- -->
  39. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataCount" @change="f5()"></sa-item>
  40. </div>
  41. </div>
  42. <script>
  43. var app = new Vue({
  44. components: {
  45. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  46. "sa-td": httpVueLoader('../../sa-frame/com/sa-td.vue'),
  47. },
  48. el: '.vue-box',
  49. data: {
  50. p: { // 查询参数
  51. path: '', // 前端路径
  52. menuName: '', // 菜单名称
  53. icon: '', // 图标
  54. sort: '', // 排序
  55. enable: 1, // 状态(0=禁用,1=启用)
  56. auth: '', // 是否认证后访问(0=否,1=是)
  57. pageNo: 1, // 当前页
  58. pageSize: 10, // 页大小
  59. sortType: 0 // 排序方式
  60. },
  61. dataCount: 0,
  62. dataList: [], // 数据集合
  63. appRoleId: sa.p('appRoleId',0),
  64. authList: []
  65. },
  66. methods: {
  67. // 刷新
  68. f5: function() {
  69. sa.ajax('/sp-admin/AppMenu/getList', sa.removeNull(this.p), function(res) {
  70. this.dataList = res.data; // 数据
  71. this.dataCount = res.dataCount; // 数据总数
  72. sa.ajax('/sp-admin/ReRoleMenu/getList', {appRoleId : this.appRoleId}, function(res) {
  73. this.authList = res.data; // 数据
  74. this.dataList.forEach((item,index) => {
  75. if(this.authList.find((key) => key.appMenuId == item.id)){
  76. this.$nextTick(()=>{
  77. this.$refs['data-table'].toggleRowSelection(
  78. this.$refs['data-table'].data[index],
  79. true
  80. );
  81. });
  82. }
  83. })
  84. sa.f5TableHeight(); // 刷新表格高度
  85. }.bind(this));
  86. }.bind(this));
  87. },
  88. // 分配权限
  89. add() {
  90. let selectDatas = this.$refs['data-table'].selection;
  91. let list = '';
  92. selectDatas.forEach(item => {
  93. list += item.id + ',';
  94. })
  95. let item={list: list,roleId: this.appRoleId};
  96. sa.ajax('/sp-admin/ReRoleMenu/assignPermissions',item, function(res) {
  97. sa.msg('权限分配成功');
  98. }.bind(this));
  99. }
  100. },
  101. created: function() {
  102. this.f5();
  103. sa.onInputEnter();
  104. }
  105. })
  106. </script>
  107. </body>
  108. </html>