role-list.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>角色列表</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. <style type="text/css">
  17. .el-tag{border-radius: 0px;}
  18. </style>
  19. </head>
  20. <body>
  21. <div class="vue-box" style="display: none;" :style="'display: block;'">
  22. <div class="c-panel">
  23. <!-- 参数栏 -->
  24. <div class="c-title">检索参数</div>
  25. <el-form @submit.native.prevent>
  26. <sa-item type="text" name="角色名称" v-model="p.name"></sa-item>
  27. <el-button type="primary" icon="el-icon-search" @click="f5()">查询</el-button>
  28. <el-button v-if="sa.isAuth('sp-role-add')" type="primary" icon="el-icon-plus" @click="add()">新增</el-button>
  29. </el-form>
  30. <!-- 数据列表 -->
  31. <el-table class="data-table" ref="data-table" :data="dataList">
  32. <el-table-column label="角色名称">
  33. <template slot-scope="s">
  34. <el-input v-if="s.row.is_update" v-model="s.row.name"></el-input>
  35. <span v-else>{{s.row.name}}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="责任描述">
  39. <template slot-scope="s">
  40. <el-input v-if="s.row.is_update" v-model="s.row.info"></el-input>
  41. <span v-else>{{s.row.info}}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="是否锁定" title="锁定的角色为系统维持正常运行的重要角色,不可删除">
  45. <template slot-scope="s">
  46. <el-tag v-if="s.row.isLock == 1">已锁定</el-tag>
  47. <el-tag v-else type="success">未锁定</el-tag>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="创建日期">
  51. <template slot-scope="s">
  52. {{sa.forDate(s.row.createTime, 2)}}
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="操作" width="220px">
  56. <template slot-scope="s">
  57. <el-button v-if="sa.isAuth('sp-role-edit')" type="text" @click="update(s.row)">
  58. <span :style="s.row.is_update ? 'color: red;' : ''">修改</span>
  59. </el-button>
  60. <el-button v-if="sa.isAuth('sp-role-del')" type="text" @click="del(s.row)">删除</el-button>
  61. <el-button v-if="sa.isAuth('sp-role-permission')" type="text" @click="menu_setup(s.row)">分配权限</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <!-- ------------- 分页 ------------- -->
  66. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataList.length" :sizes="[1000]" @change="f5()"></sa-item>
  67. </div>
  68. </div>
  69. <script>
  70. var app = new Vue({
  71. components: {
  72. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  73. },
  74. el: '.vue-box',
  75. data: {
  76. sa: sa, // 超级对象
  77. p: { // 查询参数
  78. name: '',
  79. pageNo: 1,
  80. pageSize: 1000,
  81. },
  82. dataList: [], // 数据集合
  83. },
  84. methods: {
  85. // 刷新
  86. f5: function(){
  87. sa.ajax('/role/getList', this.p, function(res) {
  88. this.dataList = sa.listAU(res.data);
  89. sa.f5TableHeight(); // 刷新表格高度
  90. }.bind(this));
  91. },
  92. // 修改
  93. update: function (data) {
  94. if(data.is_update == false) {
  95. data.is_update = true;
  96. } else {
  97. sa.confirm('是否修改数据?', function(){
  98. var data2 = sa.copyJSON(data);
  99. data2.createTime = undefined;
  100. sa.ajax('/role/update', data2, function(res){
  101. sa.ok('修改成功');
  102. data.is_update = false;
  103. })
  104. })
  105. }
  106. },
  107. // 删除
  108. del: function (data) {
  109. if(data.isLock == 1){
  110. return layer.alert('此角色是维持系统正常运行的重要角色,已被锁定,不可删除');
  111. };
  112. sa.confirm('是否删除,此操作不可撤销', function(){
  113. sa.ajax('/role/delete', {id: data.id},function(res){
  114. sa.arrayDelete(app.dataList, data);
  115. sa.ok('删除成功');
  116. sa.f5TableHeight(); // 刷新表格高度
  117. })
  118. });
  119. },
  120. // 添加
  121. add: function () {
  122. sa.showIframe('新增角色', 'role-add.html?id=-1', '420px', '280px');
  123. },
  124. // 修改权限菜单
  125. menu_setup: function(data){
  126. var title = '为 ['+data.name+'] 分配权限';
  127. sa.showIframe(title, 'menu-setup.html?roleId=' + data.id, '700px', '600px');
  128. }
  129. },
  130. created: function(){
  131. this.f5();
  132. sa.onInputEnter(); // 监听表单回车执行查询
  133. }
  134. })
  135. </script>
  136. </body>
  137. </html>