role-list.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>角色列表</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport"
  7. content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
  8. <!-- 所有的 css & js 资源 -->
  9. <link rel="stylesheet" href="../../static/kj/element-ui/theme-chalk/index.css">
  10. <link rel="stylesheet" href="../../static/sa.css">
  11. <script src="../../static/kj/vue.min.js"></script>
  12. <script src="../../static/kj/element-ui/index.js"></script>
  13. <script src="../../static/kj/httpVueLoader.js"></script>
  14. <script src="../../static/kj/jquery.min.js"></script>
  15. <script src="../../static/kj/layer/layer.js"></script>
  16. <script src="../../static/sa.js"></script>
  17. </head>
  18. <body>
  19. <div class="vue-box" style="display: none;" :style="'display: block;'">
  20. <div class="c-panel">
  21. <!-- 参数栏 -->
  22. <div class="c-title">检索参数</div>
  23. <el-form @submit.native.prevent>
  24. <sa-item type="text" name="角色名称" v-model="p.name"></sa-item>
  25. <el-button type="primary" icon="el-icon-search" @click="f5()">查询</el-button>
  26. <el-button type="primary" icon="el-icon-plus" @click="add()">新增</el-button>
  27. </el-form>
  28. <!-- 数据列表 -->
  29. <el-table class="data-table" ref="data-table" :data="dataList">
  30. <el-table-column label="编号" prop="id" width="70px"></el-table-column>
  31. <el-table-column label="角色名称">
  32. <template slot-scope="s">
  33. <el-input v-if="s.row.is_update" v-model="s.row.name"></el-input>
  34. <span v-else>{{s.row.name}}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="责任描述">
  38. <template slot-scope="s">
  39. <el-input v-if="s.row.is_update" v-model="s.row.info"></el-input>
  40. <span v-else>{{s.row.info}}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="是否锁定" title="锁定的角色为系统维持正常运行的重要角色,不可删除">
  44. <template slot-scope="s">
  45. {{s.row.isLock == 1 ? '是' : '否'}}
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="创建日期">
  49. <template slot-scope="s">
  50. {{sa.forDate(s.row.createTime, 2)}}
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="操作" width="220px">
  54. <template slot-scope="s">
  55. <el-button type="text" @click="update(s.row)">
  56. <span :style="s.row.is_update ? 'color: red;' : ''">修改</span>
  57. </el-button>
  58. <el-button type="text" @click="del(s.row)">删除</el-button>
  59. <el-button type="text" @click="menu_setup(s.row)">分配权限</el-button>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <!-- ------------- 分页 ------------- -->
  64. <sa-item type="page" :curr.sync="p.pageNo" :size.sync="p.pageSize" :total="dataList.length" :sizes="[1000]"
  65. @change="f5()"></sa-item>
  66. </div>
  67. </div>
  68. <script>
  69. var app = new Vue({
  70. components: {
  71. "sa-item": httpVueLoader('../../sa-frame/com/sa-item.vue'),
  72. },
  73. el: '.vue-box',
  74. data: {
  75. sa: sa, // 超级对象
  76. p: { // 查询参数
  77. name: '',
  78. pageNo: 1,
  79. pageSize: 1000,
  80. },
  81. dataList: [], // 数据集合
  82. },
  83. methods: {
  84. // 刷新
  85. f5: function () {
  86. sa.ajax('/role/getList', this.p, function (res) {
  87. this.dataList = sa.listAU(res.data);
  88. sa.f5TableHeight(); // 刷新表格高度
  89. }.bind(this));
  90. },
  91. // 修改
  92. update: function (data) {
  93. if (data.is_update == false) {
  94. data.is_update = true;
  95. } else {
  96. sa.confirm('是否修改数据?', function () {
  97. var data2 = sa.copyJSON(data);
  98. data2.createTime = undefined;
  99. sa.ajax('/role/update', data2, function (res) {
  100. sa.ok('修改成功');
  101. data.is_update = false;
  102. })
  103. })
  104. }
  105. },
  106. // 删除
  107. del: function (data) {
  108. if (data.isLock == 1) {
  109. return layer.alert('此角色是维持系统正常运行的重要角色,已被锁定,不可删除');
  110. }
  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>