role-list.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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="https://unpkg.com/element-ui@2.13.0/lib/theme-chalk/index.css">
  9. <link rel="stylesheet" href="../../static/sa.css">
  10. <script src="https://unpkg.com/vue@2.6.10/dist/vue.min.js"></script>
  11. <script src="https://unpkg.com/element-ui@2.13.0/lib/index.js"></script>
  12. <script src="https://unpkg.com/http-vue-loader@1.4.2/src/httpVueLoader.js"></script>
  13. <script src="https://unpkg.com/jquery@3.4.1/dist/jquery.min.js"></script>
  14. <script src="https://www.layuicdn.com/layer-v3.1.1/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 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="编号" prop="id" width="70px" > </el-table-column>
  33. <el-table-column label="角色名称">
  34. <template slot-scope="s">
  35. <el-input v-if="s.row.is_update" v-model="s.row.name"></el-input>
  36. <span v-else>{{s.row.name}}</span>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="责任描述">
  40. <template slot-scope="s">
  41. <el-input v-if="s.row.is_update" v-model="s.row.info"></el-input>
  42. <span v-else>{{s.row.info}}</span>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="是否锁定" title="锁定的角色为系统维持正常运行的重要角色,不可删除">
  46. <template slot-scope="s">
  47. <el-tag v-if="s.row.isLock == 1">已锁定</el-tag>
  48. <el-tag v-else type="success">未锁定</el-tag>
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="创建日期">
  52. <template slot-scope="s">
  53. {{sa.forDate(s.row.createTime, 2)}}
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="操作" width="220px">
  57. <template slot-scope="s">
  58. <el-button type="text" @click="update(s.row)">
  59. <span :style="s.row.is_update ? 'color: red;' : ''">修改</span>
  60. </el-button>
  61. <el-button type="text" @click="del(s.row)">删除</el-button>
  62. <el-button type="text" @click="menu_setup(s.row)">分配权限</el-button>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <!-- ------------- 分页 ------------- -->
  67. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataList.length" :sizes="[1000]" @change="f5()"></sa-item>
  68. </div>
  69. </div>
  70. <script>
  71. var app = new Vue({
  72. components: {
  73. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  74. },
  75. el: '.vue-box',
  76. data: {
  77. sa: sa, // 超级对象
  78. p: { // 查询参数
  79. name: '',
  80. pageNo: 1,
  81. pageSize: 1000,
  82. },
  83. dataList: [], // 数据集合
  84. },
  85. methods: {
  86. // 刷新
  87. f5: function(){
  88. sa.ajax('/role/getList', this.p, function(res) {
  89. this.dataList = sa.listAU(res.data);
  90. sa.f5TableHeight(); // 刷新表格高度
  91. }.bind(this));
  92. },
  93. // 修改
  94. update: function (data) {
  95. if(data.is_update == false) {
  96. data.is_update = true;
  97. } else {
  98. sa.confirm('是否修改数据?', function(){
  99. var data2 = sa.copyJSON(data);
  100. data2.createTime = undefined;
  101. sa.ajax('/role/update', data2, function(res){
  102. sa.ok('修改成功');
  103. data.is_update = false;
  104. })
  105. })
  106. }
  107. },
  108. // 删除
  109. del: function (data) {
  110. if(data.isLock == 1){
  111. return layer.alert('此角色是维持系统正常运行的重要角色,已被锁定,不可删除');
  112. };
  113. sa.confirm('是否删除,此操作不可撤销', function(){
  114. sa.ajax('/role/delete', {id: data.id},function(res){
  115. sa.arrayDelete(app.dataList, data);
  116. sa.ok('删除成功');
  117. sa.f5TableHeight(); // 刷新表格高度
  118. })
  119. });
  120. },
  121. // 添加
  122. add: function () {
  123. sa.showIframe('新增角色', 'role-add.html?id=-1', '420px', '280px');
  124. },
  125. // 修改权限菜单
  126. menu_setup: function(data){
  127. var title = '为 ['+data.name+'] 分配权限';
  128. sa.showIframe(title, 'menu-setup.html?roleId=' + data.id, '700px', '600px');
  129. }
  130. },
  131. created: function(){
  132. this.f5();
  133. sa.onInputEnter(); // 监听表单回车执行查询
  134. }
  135. })
  136. </script>
  137. </body>
  138. </html>