role-list.html 4.7 KB

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