authUser.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <div id="authUser" class="plg-tab-container">
  2. <div id="authUser-grid-1" class="grid-container-full"></div>
  3. </div>
  4. <script type="text/javascript">
  5. (function () {
  6. // cSpell:ignore layui api authmgr augrid microservice multiselect newcolumn prologui fdata cindex layero
  7. var BASE_URL = '/api/service-authorization/';
  8. var opts = {
  9. skin: "terrace",
  10. columns: [{
  11. id: "id",
  12. name: "id",
  13. type: 'txt',
  14. width: "50",
  15. hidden: true
  16. },
  17. {
  18. id: "clientId",
  19. name: "客户端",
  20. type: 'txt',
  21. width: "200"
  22. },
  23. // {
  24. // id: "clientSecret",
  25. // name: "密码",
  26. // type: 'txt',
  27. // width: "200"
  28. // },
  29. {
  30. id: "resourceIds",
  31. name: "资源",
  32. type: 'txt',
  33. width: "*"
  34. }
  35. ],
  36. multiselect: true,
  37. toolbar: [{
  38. type: "button",
  39. name: "deleteBtn",
  40. className: "danger plg-toolbar-right",
  41. value: "<i class='layui-icon layui-icon-delete'></i>删除"
  42. }, {
  43. type: "newcolumn"
  44. },
  45. {
  46. type: "button",
  47. name: "updateBtn",
  48. className: "normal plg-toolbar-right",
  49. value: "<i class='layui-icon layui-icon-edit'></i>修改"
  50. }, {
  51. type: "newcolumn"
  52. },
  53. {
  54. type: "button",
  55. name: "addBtn",
  56. className: "plg-toolbar-right",
  57. value: "<i class='layui-icon layui-icon-add-1'></i>添加"
  58. }, {
  59. type: "newcolumn"
  60. },
  61. {
  62. type: "input",
  63. name: 'clientId',
  64. label: '客户端:',
  65. width:300,
  66. placeholder:"请输入客户端名称"
  67. },
  68. /*{
  69. type: "newcolumn"
  70. },
  71. {
  72. type: "input",
  73. name: "authorities",
  74. label: "权限:",
  75. offsetLeft: 10
  76. },*/
  77. {
  78. type: "newcolumn"
  79. },
  80. {
  81. type: "button",
  82. name: "searchBtn",
  83. className: "",
  84. value: "查询"
  85. },
  86. {
  87. type: "newcolumn"
  88. },
  89. {
  90. type: "button",
  91. name: "all",
  92. className: "normal",
  93. value: "所有"
  94. },
  95. {
  96. type: "newcolumn"
  97. }
  98. ],
  99. formData: [{
  100. type: "settings",
  101. inputWidth: 280,
  102. width: 400,
  103. labelWidth: 100,
  104. position: "label-left",
  105. labelAlign: "left"
  106. },
  107. {
  108. type: "hidden",
  109. name: 'id'
  110. },
  111. {
  112. type: "input",
  113. name: 'clientId',
  114. label: '客户端',
  115. required:true,
  116. validate:"NotEmpty",
  117. placeholder:"请输入客户端名称"
  118. },
  119. {
  120. type: "password",
  121. name: "clientSecret",
  122. label: "密码",
  123. required:true,
  124. validate:"NotEmpty",
  125. placeholder:"请输入密码"
  126. },
  127. {
  128. type: "hidden",
  129. name: "authorizedGrantTypes",
  130. label: "授权类型",
  131. value:''
  132. },
  133. {
  134. type: "input",
  135. name: "scopes",
  136. label: "作用域",
  137. placeholder:"请输入作用域",
  138. value: 'all'
  139. },
  140. {
  141. type: "input",
  142. name: "resourceIds",
  143. label: "资源(使用','分割)",
  144. rows: 3,
  145. value:'',
  146. note: {text:"可为空"}
  147. },
  148. {
  149. type: "hidden",
  150. name: "authorities",
  151. value:'',
  152. label: "权限(格式:服务名:权限编号,使用','分割)",
  153. rows: 3
  154. },
  155. {
  156. type: "hidden",
  157. name: "authorityGroups",
  158. value:'',
  159. label: "权限组(资源组名称,使用','分割)",
  160. rows: 3
  161. },
  162. ],
  163. url: BASE_URL + 'authmgr/like', //数据接口
  164. type: "get", //数据提交方式,默认为get
  165. params: {}, //查询提交参数,分页参数默认为pageNum,pageSize
  166. page: true, //是否启用分页
  167. pageNum: "pageNo",
  168. totalCount: "totalCount" //总记录数字段,默认totalCount
  169. };
  170. var augrid = new PlgGrid(opts);
  171. augrid.renderTo("authUser-grid-1");
  172. augrid.loadData();
  173. // 被迫使用这种无赖的选择,万恶的使用js操作DOM
  174. // //console.log("$('#form_container .dhxform_base_nested')::" + $('#form_container .dhxform_base_nested'));
  175. // $('#form_container .cus-class').append($('#form_container .dhxform_base_nested'));
  176. // $('#form_container .cus-class').find('.topmost').eq(0).css({float: 'left'});
  177. // $('#form_container .dhxform_base_nested').css({display: 'inline-block'});
  178. augrid.attachToolBarEvent("onButtonClick", function (name) {
  179. var operationGroup = {
  180. searchBtn: function () {
  181. var fdata = augrid.getToolBarForm().getFormData();
  182. augrid.setParams(fdata);
  183. augrid.reload();
  184. },
  185. all: function () {
  186. augrid.setParams({});
  187. augrid.reload();
  188. },
  189. addBtn: function () {
  190. augrid.showDialog(0, "添加", 800, 600, {
  191. url: BASE_URL + 'authmgr/add',
  192. type: "post"
  193. });
  194. },
  195. updateBtn: function () {
  196. augrid.showDialog(1, "编辑", 430, 350, {
  197. url: BASE_URL + 'authmgr/update',
  198. type: "post"
  199. });
  200. },
  201. deleteBtn: function () {
  202. var ids = augrid.getCheckedIds();
  203. ids = (ids == null || ids == "") ? augrid.getSelectedRowData("id") : ids;
  204. // debugger;
  205. if (ids == null) {
  206. PlgDialog.msg("请选择行!");
  207. return;
  208. }
  209. var loading = layer.load(0, {
  210. shade: false
  211. }); //0代表加载的风格,支持0-2
  212. Prolog.ajax({
  213. url: BASE_URL + 'authmgr/delete',
  214. type: 'POST',
  215. data: {id: ids},
  216. dataType: 'json',
  217. success: function (data) {
  218. layer.close(loading);
  219. if (data.success) {
  220. augrid.reload();
  221. } else {
  222. layer.msg(data.message);
  223. }
  224. }
  225. });
  226. },
  227. }
  228. if(name && operationGroup.hasOwnProperty(name)){
  229. operationGroup[name]();
  230. }
  231. });
  232. }())
  233. </script>