authorityList.html 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  1. <!-- 权限管理 -->
  2. <style>
  3. #authoritymanager_grid_01>div { margin-top: 0px;}
  4. #authoritymanager_grid_sub .layui-tab { margin-top: 0px;}
  5. </style>
  6. <div id="authorityList" class="plg-tab-container">
  7. <div class="layui-carousel" id="authoritymanager_grid" style="margin-bottom: -15px;">
  8. <div carousel-item>
  9. <div id="authoritymanager_grid_01" class="grid-container-full"></div>
  10. <div id="authoritymanager_grid_01_edit" class="grid-container-full" style="min-height: 550px;">
  11. <div class="layui-row">
  12. <div class="layui-col-lg12">
  13. <div class="tc-title">
  14. <a href="#" id="authoritymanager_btn_back" class="back-link"><i class="layui-icon layui-icon-return"></i></a>
  15. <span id="authoritymanager_span_title"></span>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="layui-row layui-col-space15" style="margin: 20px;">
  20. <div class="layui-col-lg12 tc-panel" style="min-height: 300px;">
  21. <div id="authoritymanager_grid_sub" style="min-height: 450px;"></div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. <script type="text/javascript">
  29. /**
  30. * jiw
  31. * 2018.11.29
  32. * 权限、权限组管理界面
  33. */
  34. (function () {
  35. var grid = null;
  36. var form1 = null, tabs1;
  37. var grid_wnd_0 = null, grid_wnd_1 = null, grid_wnd_2 = null, tmp_gridrow_id = 0, tmp_gridrowdata = null, stepindex = 0, tmp_type = "0";
  38. var m = $(document.body).height();
  39. var rsp_type = [{ text: "资源权限", value: "0" }, { text: "数据权限", value: "1" }];
  40. var param = { "type": "0", "pageNum": 1, "pageSize": 10 };
  41. gridInit(0);
  42. //滑屏
  43. var carousel = layui.carousel;
  44. var car = carousel.render({
  45. elem: "#authoritymanager_grid",
  46. autoplay: false,
  47. index: 0,
  48. arrow: "none",
  49. indicator: "none",
  50. anim: "fade",
  51. width: "100%",
  52. height: "100%"
  53. });
  54. function changePanel(name) {
  55. car.slide(name);
  56. }
  57. //返回主页面
  58. $("#authoritymanager_btn_back").click(function () {
  59. changePanel("authoritymanager_grid_01");
  60. return false;
  61. });
  62. function gridInit(type) {
  63. if (type === 0) {
  64. var gridOpts = {
  65. skin: "terrace",
  66. rowId: "p_id",
  67. columns: [
  68. { id: "p_id", name: "id", type: "ro", hidden: true },
  69. { id: "p_name", name: "权限名称", type: "ro" },
  70. { id: "p_type", name: "权限类型", type: "ro", render: function (v) { return getNameByID(rsp_type, v); } },
  71. { id: "p_remark", name: "权限描述", type: "ro" },
  72. { id: "p_flg", name: "是否启用", type: "ch" },
  73. {
  74. id: "op", name: "操作", type: 'button', align: "center", width: 200, render: function () {
  75. var t1 = "修改^res_roleManagedata_editClick,删除^res_roleManagedata_delClick,资源权限^res_roleManagedata_edit2Click";
  76. var t2 = "修改^res_roleManagedata_editClick,删除^res_roleManagedata_delClick,数据权限^res_roleManagedata_edit1Click";
  77. if (tmp_type === "1") {
  78. return t2;
  79. }
  80. else {
  81. return t1;
  82. }
  83. }
  84. }
  85. ],
  86. multiselect: false,
  87. toolbar: [
  88. { type: "input", name: "search", label: "权限名称:", placeholder: "", offsetLeft: 10 },
  89. { type: "newcolumn" },
  90. {
  91. type: "combo",
  92. name: "type",
  93. label: "权限类型:",
  94. offsetLeft: 20,
  95. width: 130,
  96. options: rsp_type
  97. },
  98. { type: "newcolumn" },
  99. { type: "button", offsetLeft: 20, name: "btn_search", width: 50, value: "查询" },
  100. { type: "newcolumn" },
  101. { type: "newcolumn" },
  102. {
  103. type: "button",
  104. name: "btn_add",
  105. className: "plg-toolbar-right",
  106. width: 80,
  107. offsetLeft: 20,
  108. value: "<i class='layui-icon layui-icon-add-1'></i>新增"
  109. }, { type: "newcolumn" }
  110. ],
  111. imagePath: "/prologui/assets/PlgGrid",
  112. url: "/api/service-users/authority/query/v1.0",
  113. type: "post",
  114. params: param,
  115. contentType: "application/x-www-form-urlencoded",
  116. page: true,
  117. totalCount: "totalCount"
  118. };
  119. grid = new PlgGrid(gridOpts);
  120. grid.renderTo("authoritymanager_grid_01");
  121. grid.loadData();
  122. //工具栏按钮事件
  123. grid.attachToolBarEvent("onButtonClick", function (name) {
  124. // 查询
  125. if (name === "btn_search") {
  126. grid.setParams(grid.getToolBarForm().getFormData());
  127. grid.reload();
  128. }
  129. // 新增
  130. else if (name === "btn_add") {
  131. addauthority();
  132. }
  133. });
  134. grid.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
  135. var p = grid.getToolBarForm().getFormData();
  136. tmp_type = p.type;
  137. p.pageNum = 1;
  138. p.pageSize = 10;
  139. grid.setParams(p);
  140. grid.reload();
  141. });
  142. // 双击行编辑
  143. grid.on("onRowDblClicked", function () {
  144. show_info(grid.getSelectedRowData());
  145. });
  146. }
  147. }
  148. //添加权限
  149. function addauthority() {
  150. stepindex = 0;
  151. var str;
  152. if (tmp_type === "0") {
  153. str = `<div class="layui-col-lg12 tc-15-step" id="authoritymanager_grid_roleadd_main">
  154. <ol>
  155. <li class="succeed">
  156. <div class="tc-15-step-name"><span class="tc-15-step-num">1</span>填写信息</div>
  157. <div class="tc-15-step-arrow"></div>
  158. </li>
  159. <li class="disabled">
  160. <div class="tc-15-step-name"><span class="tc-15-step-num">2</span>资源权限</div>
  161. <div class="tc-15-step-arrow"></div>
  162. </li>
  163. <li class="disabled">
  164. <div class="tc-15-step-name"><span class="tc-15-step-num">3</span>完成</div>
  165. <div class="tc-15-step-arrow"></div>
  166. </li>
  167. </ol>
  168. </div>
  169. <div class="layui-col-lg12" id="authoritymanager_grid_roleadd_content"></div>
  170. <div class="layui-col-lg12 button-ft">
  171. <button class="layui-btn layui-btn-sm layui-btn-normal" id="authorityadd_btn_next">下一步</button>
  172. </div>`;
  173. }
  174. else {
  175. str = `<div class="layui-col-lg12 tc-15-step" id="authoritymanager_grid_roleadd_main">
  176. <ol>
  177. <li class="succeed">
  178. <div class="tc-15-step-name"><span class="tc-15-step-num">1</span>填写信息</div>
  179. <div class="tc-15-step-arrow"></div>
  180. </li>
  181. <li class="disabled">
  182. <div class="tc-15-step-name"><span class="tc-15-step-num">2</span>货主</div>
  183. <div class="tc-15-step-arrow"></div>
  184. </li>
  185. <li class="disabled">
  186. <div class="tc-15-step-name"><span class="tc-15-step-num">3</span>机构/仓</div>
  187. <div class="tc-15-step-arrow"></div>
  188. </li>
  189. <li class="disabled">
  190. <div class="tc-15-step-name"><span class="tc-15-step-num">4</span>贸易伙伴</div>
  191. <div class="tc-15-step-arrow"></div>
  192. </li>
  193. <li class="disabled">
  194. <div class="tc-15-step-name"><span class="tc-15-step-num">5</span>完成</div>
  195. <div class="tc-15-step-arrow"></div>
  196. </li>
  197. </ol>
  198. </div>
  199. <div class="layui-col-lg12" style="min-height: 280px;">
  200. <div id="authoritymanager_grid_roleadd_content"></div>
  201. </div>
  202. </div>
  203. <div class="layui-col-lg12 button-ft">
  204. <button class="layui-btn layui-btn-sm layui-btn-normal" id="authorityadd_btn_next">下一步</button>
  205. </div>`;
  206. }
  207. $("#authoritymanager_grid_sub").html(str);
  208. $("#authorityadd_btn_next").show();
  209. $("ol li").each(function () {
  210. if ($(this).index() === 0) {
  211. $(this).removeClass("disabled");
  212. $(this).addClass("succeed");
  213. }
  214. else {
  215. $(this).removeClass("succeed");
  216. $(this).addClass("disabled");
  217. }
  218. });
  219. authorityFormInit(0, {});
  220. changePanel("authoritymanager_grid_01_edit");
  221. $("#authoritymanager_grid_roleadd_content").height((m > 530) ? m - 400 : m);
  222. $("#authoritymanager_grid_sub").width("100%");
  223. $("#authoritymanager_grid_01_edit .tc-panel").attr("style", "min-height: 400px;");
  224. $("#authorityadd_btn_next").click(function () {
  225. if (stepindex === 0) {
  226. var b = form1.validate();
  227. if (!b) return;
  228. var fd = form1.getFormData();
  229. rdata = save_authorityinfo(grid, "/api/service-users/authority/insert/v1.0", "post", "application/x-www-form-urlencoded", fd);
  230. if (rdata === null) {
  231. layer.msg("获取权限信息失败!");
  232. return;
  233. }
  234. tmp_gridrowdata = rdata;
  235. if (tmp_type === "0") {
  236. roleauthInit(0, tmp_gridrowdata);
  237. }
  238. else {
  239. authorityauthInit(0, tmp_gridrowdata, 0);
  240. }
  241. }
  242. else {
  243. if (tmp_type === "0") {
  244. if (stepindex === 1) {
  245. $("#authoritymanager_grid_roleadd_content").html("<h1>权限新增成功,3秒后返回!</h1>");
  246. grid.reload();
  247. $("#authorityadd_btn_next").hide();
  248. setTimeout(function () { changePanel("authoritymanager_grid_01"); }, 3000);
  249. }
  250. }
  251. else {
  252. if (stepindex === 1) {
  253. authorityauthInit(1, tmp_gridrowdata, 0);
  254. }
  255. else if (stepindex === 2) {
  256. authorityauthInit(2, tmp_gridrowdata, 0);
  257. }
  258. else if (stepindex === 3) {
  259. $("#authoritymanager_grid_roleadd_content").html("<h1>权限新增成功,3秒后返回!</h1>");
  260. grid.reload();
  261. $("#authorityadd_btn_next").hide();
  262. setTimeout(function () { changePanel("authoritymanager_grid_01"); }, 3000);
  263. }
  264. }
  265. }
  266. stepindex++;
  267. $("ol li").each(function () {
  268. if (stepindex === $(this).index()) {
  269. $(this).removeClass("disabled");
  270. $(this).addClass("succeed");
  271. }
  272. });
  273. });
  274. }
  275. //权限-表单
  276. function authorityFormInit(ntype, rdata) {
  277. var tit = "新增权限";
  278. var rediv = "authoritymanager_grid_roleadd_content";
  279. if (ntype === 1) {
  280. tit = "权限 [" + rdata.p_name + "] 信息修改";
  281. rediv = "authoritymanager_grid_sub";
  282. }
  283. $("#authoritymanager_span_title").html(tit);
  284. $("#" + rediv).html("");
  285. var formcfg = {
  286. renderer: rediv,
  287. items: [
  288. { type: "settings", inputWidth: 140, width: 550, labelWidth: 80, position: "label-left", labelAlign: "left" },
  289. {
  290. type: "settings",
  291. inputWidth: 140,
  292. width: 550,
  293. labelWidth: 80,
  294. position: "label-left",
  295. labelAlign: "left"
  296. },
  297. {
  298. type: "block", width: 520,
  299. list: [
  300. { type: "input", name: "p_name", label: "权限名称:", validate: "NotEmpty", required: true, editable: false },
  301. { type: "newcolumn", offset: 40 },
  302. {
  303. type: "combo",
  304. name: "p_type",
  305. label: "权限类型:",
  306. offsetLeft: 10,
  307. width: 130,
  308. options: rsp_type,
  309. disabled: true
  310. }
  311. ]
  312. },
  313. {
  314. type: "block", width: 520,
  315. list: [
  316. { type: "input", name: "p_remark", label: "权限描述:" },
  317. { type: "newcolumn", offset: 40 },
  318. { type: "checkbox", name: "p_flg", label: "是否启用:" }]
  319. },
  320. {
  321. type: "block", width: 520, list: [
  322. { type: "button", name: "btn_save_roleinfo", offsetLeft: 80, value: "保存", hidden: (ntype != 1) },
  323. { type: "hidden", name: "p_id" },
  324. ]
  325. }
  326. ]
  327. };
  328. rdata.p_type = tmp_type;
  329. form1 = new PlgForm(formcfg);
  330. form1.setFormData(rdata);
  331. if (ntype === 1) {
  332. form1.getDForm().disableItem("p_name");
  333. }
  334. form1.attachEvent("onButtonClick", function (name) {
  335. if (name === "btn_save_roleinfo") {
  336. var fd = form1.getFormData();
  337. save_authorityinfo(grid, "/api/service-users/authority/update/v1.0", "put", "application/x-www-form-urlencoded", fd);
  338. }
  339. });
  340. }
  341. //权限-信息保存
  342. function save_authorityinfo(grid, url, type, contentType, formData) {
  343. var rep = null;
  344. Prolog.ajax({
  345. url: url,
  346. type: type,
  347. contentType: contentType,
  348. data: formData,
  349. async: false,
  350. success: function (data) {
  351. if (data.success) {
  352. if (type === "put")
  353. layer.msg("保存成功!");
  354. grid.reload();
  355. rep = data.data;
  356. }
  357. else {
  358. layer.msg(data.message);
  359. }
  360. },
  361. error: function () {
  362. }
  363. });
  364. return rep;
  365. }
  366. //数据权限-分配
  367. function authorityauthInit(ntype, rdata, type, grid) {
  368. var rediv = "authoritymanager_grid_roleadd_content";
  369. if (type === 1) {
  370. rediv = "authoritymanager_grid_sub" + ntype;
  371. }
  372. if (grid_wnd_0 != null)
  373. {
  374. grid_wnd_0.getGrid().clearAll();
  375. }
  376. if (ntype === 0){
  377. $("#"+rediv).html("");
  378. param.roleid = rdata.p_id;
  379. param.companyid = "";
  380. param.search = "";
  381. var gridopt = {
  382. skin: "terrace",
  383. rowId: "companyid",
  384. columns: [
  385. { id: "companyid", name: "companyid", type: "ro", hidden: true },
  386. { id: "companycode", name: "货主编号", type: "ro" },
  387. { id: "locname", name: "货主名称", type: "ro" },
  388. { id: "zjm", name: "助记码", type: "ro" }
  389. ],
  390. toolbar: [
  391. { type: "input", name: "search", label: "查询条件:", placeholder: "名称", offsetLeft: 10 }, { type: "newcolumn" },
  392. {
  393. type: "combo",
  394. name: "type",
  395. label: "状态:",
  396. offsetLeft: 10,
  397. width: 130,
  398. options: [{ text: "未分配", value: "0" }, { text: "已分配", value: "1" }],
  399. hidden: (type === 0)
  400. }, { type: "newcolumn" },
  401. { type: "button", name: "btn_search", offsetLeft: 20, value: "查询" }, { type: "newcolumn" },
  402. { type: "button", name: "btn_save", offsetLeft: 10, value: "保存" }
  403. ],
  404. multiselect: true,
  405. imagePath: "/prologui/assets/PlgGrid",
  406. url: "/api/service-users/company/queryConsignorPage/v1.0",
  407. type: "post",
  408. contentType: "application/x-www-form-urlencoded",
  409. params: param,
  410. page: true,
  411. totalCount: "totalCount"
  412. };
  413. grid_wnd_0 = new PlgGrid(gridopt);
  414. grid_wnd_0.renderTo(rediv);
  415. grid_wnd_0.loadData();
  416. if (type === 1) {
  417. $("#" + rediv).height(m - 300);
  418. }
  419. else {
  420. $("#" + rediv).width("100%");
  421. }
  422. grid_wnd_0.attachToolBarEvent("onButtonClick", function (name) {
  423. var p = grid_wnd_0.getToolBarForm().getFormData();
  424. // 查询
  425. if (name === "btn_search") {
  426. p.roleid = rdata.p_id;
  427. grid_wnd_0.setParams(p);
  428. grid_wnd_0.reload();
  429. } else if (name === "btn_save") {
  430. var state = grid_wnd_0.getToolBarForm().getFormData().type;
  431. var sid = grid_wnd_0.getCheckedIds();
  432. if (sid === null) return;
  433. state = (state === "0") ? "1" : "0";
  434. save_authorityauth(ntype, sid, state);
  435. }
  436. });
  437. grid_wnd_0.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
  438. var p = grid_wnd_0.getToolBarForm().getFormData();
  439. p.pageNum = 1;
  440. p.pageSize = 10;
  441. p.roleid = rdata.p_id;
  442. grid_wnd_0.setParams(p);
  443. grid_wnd_0.reload();
  444. });
  445. }
  446. else if (ntype === 1){
  447. $("#"+rediv).html("");
  448. param.roleid = rdata.p_id;
  449. param.companyid = "";
  450. param.search = "";
  451. var gridopt = {
  452. skin: "terrace",
  453. rowId: "companyid",
  454. columns: [
  455. { id: "companyid", name: "companyid", type: "ro", hidden: true },
  456. { id: "companycode", name: "仓编号", type: "ro" },
  457. { id: "locname", name: "仓名称", type: "ro" },
  458. { id: "zjm", name: "助记码", type: "ro" }
  459. ],
  460. toolbar: [
  461. { type: "input", name: "search", label: "查询条件:", placeholder: "名称", offsetLeft: 10 }, { type: "newcolumn" },
  462. {
  463. type: "combo",
  464. name: "type",
  465. label: "状态:",
  466. offsetLeft: 10,
  467. width: 130,
  468. options: [{ text: "未分配", value: "0" }, { text: "已分配", value: "1" }],
  469. hidden: (type === 0)
  470. }, { type: "newcolumn" },
  471. { type: "button", name: "btn_search", offsetLeft: 20, value: "查询" }, { type: "newcolumn" },
  472. { type: "button", name: "btn_save", offsetLeft: 10, value: "保存" }
  473. ],
  474. multiselect: true,
  475. imagePath: "/prologui/assets/PlgGrid",
  476. url: "/api/service-users/branch/queryBranchPage/v1.0",
  477. type: "post",
  478. contentType: "application/x-www-form-urlencoded",
  479. params: param,
  480. page: true,
  481. totalCount: "totalCount"
  482. };
  483. grid_wnd_0 = new PlgGrid(gridopt);
  484. grid_wnd_0.renderTo(rediv);
  485. grid_wnd_0.loadData();
  486. if (type === 1) {
  487. $("#" + rediv).height(m - 300);
  488. }
  489. else {
  490. $("#" + rediv).width("100%");
  491. }
  492. grid_wnd_0.attachToolBarEvent("onButtonClick", function (name) {
  493. var p = grid_wnd_0.getToolBarForm().getFormData();
  494. // 查询
  495. if (name === "btn_search") {
  496. p.roleid = rdata.p_id;
  497. grid_wnd_0.setParams(p);
  498. grid_wnd_0.reload();
  499. } else if (name === "btn_save") {
  500. var state = grid_wnd_0.getToolBarForm().getFormData().type;
  501. var sid = grid_wnd_0.getCheckedIds();
  502. if (sid === null) return;
  503. state = (state === "0") ? "1" : "0";
  504. save_authorityauth(ntype, sid, state);
  505. }
  506. });
  507. grid_wnd_0.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
  508. var p = grid_wnd_0.getToolBarForm().getFormData();
  509. p.pageNum = 1;
  510. p.pageSize = 10;
  511. p.roleid = rdata.p_id;
  512. grid_wnd_0.setParams(p);
  513. grid_wnd_0.reload();
  514. });
  515. }
  516. else if (ntype === 2){
  517. $("#"+rediv).html("");
  518. param.roleid = rdata.p_id;
  519. param.companyid = "";
  520. param.search = "";
  521. var gridopt = {
  522. skin: "terrace",
  523. rowId: "companyid",
  524. columns: [
  525. { id: "companyid", name: "companyid", type: "ro", hidden: true },
  526. { id: "companycode", name: "客户编号", type: "ro" },
  527. { id: "locname", name: "客户名称", type: "ro" },
  528. { id: "zjm", name: "助记码", type: "ro" }
  529. ],
  530. toolbar: [
  531. { type: "input", name: "search", label: "查询条件:", placeholder: "名称", offsetLeft: 10 }, { type: "newcolumn" },
  532. {
  533. type: "combo",
  534. name: "type",
  535. label: "状态:",
  536. offsetLeft: 10,
  537. width: 130,
  538. options: [{ text: "未分配", value: "0" }, { text: "已分配", value: "1" }],
  539. hidden: (type === 0)
  540. }, { type: "newcolumn" },
  541. { type: "button", name: "btn_search", offsetLeft: 20, value: "查询" }, { type: "newcolumn" },
  542. { type: "button", name: "btn_save", offsetLeft: 10, value: "保存" }
  543. ],
  544. multiselect: true,
  545. imagePath: "/prologui/assets/PlgGrid",
  546. url: "/api/service-users/company/queryCustomerPage/v1.0",
  547. type: "post",
  548. contentType: "application/x-www-form-urlencoded",
  549. params: param,
  550. page: true,
  551. totalCount: "totalCount"
  552. };
  553. grid_wnd_0 = new PlgGrid(gridopt);
  554. grid_wnd_0.renderTo(rediv);
  555. grid_wnd_0.loadData();
  556. if (type === 1) {
  557. $("#" + rediv).height(m - 300);
  558. }
  559. else {
  560. $("#" + rediv).width("100%");
  561. }
  562. grid_wnd_0.attachToolBarEvent("onButtonClick", function (name) {
  563. var p = grid_wnd_0.getToolBarForm().getFormData();
  564. // 查询
  565. if (name === "btn_search") {
  566. p.roleid = rdata.p_id;
  567. grid_wnd_0.setParams(p);
  568. grid_wnd_0.reload();
  569. } else if (name === "btn_save") {
  570. var state = grid_wnd_0.getToolBarForm().getFormData().type;
  571. var sid = grid_wnd_0.getCheckedIds();
  572. if (sid === null) return;
  573. state = (state === "0") ? "1" : "0";
  574. save_authorityauth(ntype, sid, state);
  575. }
  576. });
  577. grid_wnd_0.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
  578. var p = grid_wnd_0.getToolBarForm().getFormData();
  579. p.pageNum = 1;
  580. p.pageSize = 10;
  581. p.roleid = rdata.p_id;
  582. grid_wnd_0.setParams(p);
  583. grid_wnd_0.reload();
  584. });
  585. }
  586. }
  587. //数据权限-保存
  588. function save_authorityauth(ntype, sid, state) {
  589. var par, rsp = null, url;
  590. if (ntype == 0) {
  591. url = "/api/service-users/role/allotUserRole/v1.0";
  592. par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
  593. }
  594. else if (ntype == 1) {
  595. url = "/api/service-users/role/allotUserRoleGroup/v1.0";
  596. par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
  597. }
  598. else if (ntype == 2) {
  599. url = "/api/service-users/role/allotUserRoleGroup/v1.0";
  600. par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
  601. }
  602. else if (ntype == 3) {
  603. url = "/api/service-users/role/allotUserRoleGroup/v1.0";
  604. par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
  605. }
  606. else if (ntype == 4) {
  607. url = "/api/service-users/role/allotUserRoleGroup/v1.0";
  608. par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
  609. }
  610. layer.msg("数据处理中...");
  611. Prolog.ajax({
  612. url: url,
  613. type: "post",
  614. contentType: "application/json",
  615. data: JSON.stringify(par),
  616. async: false,
  617. success: function (data) {
  618. if (typeof data != "object") data = JSON.parse(data);
  619. if (data.success) {
  620. layer.closeAll();
  621. grid_wnd_0.reload();
  622. rsp = data;
  623. }
  624. else {
  625. layer.open({
  626. type: 1, offset: "auto", id: 'layerError', title: "错误提示"
  627. , area: ["500px"], content: '<div style="padding: 10px;">' + data.message + '</div>'
  628. , btn: '关闭', btnAlign: 'r', shade: 0
  629. , yes: function () {
  630. layer.closeAll();
  631. }
  632. });
  633. rsp = null;
  634. }
  635. },
  636. error: function () {
  637. }
  638. });
  639. return rsp;
  640. }
  641. //分配资源权限
  642. function roleauthInit(ntype, rdata) {
  643. var rediv = "authoritymanager_grid_roleadd_content";
  644. if (ntype === 1) {
  645. rediv = "authoritymanager_grid_sub";
  646. }
  647. $("#" + rediv).html('<div id="authoritymanager_roleadd_1" class="layui-col-lg5" style="border: 1px solid #ddd ;height:370px;overflow:auto"></div>' +
  648. '<div id="authoritymanager_roleadd_2" class="layui-col-lg7" style="border: 1px solid #ddd ;height:370px;overflow:auto"></div>');
  649. var rid = rdata.p_id;
  650. var rsp_tree = [];
  651. Prolog.ajax({
  652. url: "/api/service-users/authority/getAuthMenu/v1.0",
  653. type: "get",
  654. contentType: "application/x-www-form-urlencoded",
  655. data: { "id": rdata.p_id },
  656. async: false,
  657. success: function (data) {
  658. if (data.success) {
  659. for (var i = 0; i < data.data.length; i++) {
  660. rsp_tree.push({
  661. id: data.data[i].id,
  662. name: "[" + data.data[i].id + "]" + data.data[i].name,
  663. menuId: data.data[i].id,
  664. nlevel: data.data[i].level,
  665. parentMenuId: data.data[i].parentid,
  666. isParent: (data.data[i].leaf === 0) ? true : false,
  667. checked: (data.data[i].status === "1") ? true : false,
  668. systemid: data.data[i].systemid
  669. });
  670. }
  671. }
  672. },
  673. error: function () {
  674. }
  675. });
  676. $("#authoritymanager_roleadd_1").html("");
  677. var treecfg = {
  678. renderer: "authoritymanager_roleadd_1",
  679. setData: rsp_tree,
  680. skin: "menu-tree",
  681. toolBar: false,
  682. delMenu: null,
  683. setting: {
  684. check: {
  685. enable: true
  686. },
  687. callback: {
  688. //单击事件的回调
  689. onClick: function (event, treeId, treeNode) {
  690. $("#authoritymanager_roleadd_2").html("");
  691. if (treeNode.isParent === true) {
  692. return;
  693. }
  694. var gridOpts = {
  695. skin: "terrace",
  696. rowId: "btn_no",
  697. columns: [
  698. { id: "id", name: "编号", type: "ro" },
  699. { id: "name", name: "名称", type: "ro" },
  700. { id: "status", name: "启用", type: "ch", width: "*" },
  701. { id: "menuid", name: "菜单ID", type: "ro" }
  702. ],
  703. multiselect: false,
  704. imagePath: "/prologui/assets/PlgGrid",
  705. url: '/api/service-users/authority/getAuthMenuRes/v1.0',
  706. type: "get",
  707. params: { "authid": rid, "menuid": treeNode.id, pageNum: 1, pageSize: 99 },
  708. contentType: "application/x-www-form-urlencoded",
  709. page: false
  710. };
  711. grid_wnd_0 = new PlgGrid(gridOpts);
  712. grid_wnd_0.renderTo("authoritymanager_roleadd_2");
  713. grid_wnd_0.loadData();
  714. grid_wnd_0.on("onCheck", function (rId, cInd, state) {
  715. if (!treeNode.checked) {
  716. grid_wnd_0.getGrid().setCheckedRows(cInd, 0);
  717. return;
  718. }
  719. var par = { "authid": rid, "resourceid": rId, "state": ((state) ? 1 : 0) };
  720. Prolog.ajax({
  721. url: "/api/service-users/authority/allotAuthMenuRes/v1.0",
  722. type: "post",
  723. contentType: "application/json",
  724. data: JSON.stringify(par),
  725. success: function (data) {
  726. if (typeof data != "object") data = JSON.parse(data);
  727. if (data.success) {
  728. }
  729. else {
  730. layer.msg(data.message);
  731. }
  732. },
  733. error: function () {
  734. }
  735. });
  736. });
  737. },
  738. //复选框的回调
  739. onCheck: function (e, treeId, treeNode) {
  740. var ids = "";
  741. var systemid = "";
  742. var nodes = tree1.treeObj.getChangeCheckedNodes();
  743. for (var i = 0, l = nodes.length; i < l; i++) {
  744. systemid = nodes[i].systemid;
  745. ids += nodes[i].id + ",";
  746. nodes[i].checkedOld = nodes[i].checked;
  747. }
  748. var par = {
  749. "systemid": systemid,
  750. "authid": rid,
  751. "menuids": ids.substring(0, ids.length - 1),
  752. "state": ((nodes[0].checked) ? 1 : 0)
  753. };
  754. Prolog.ajax({
  755. url: "/api/service-users/authority/allotAuthMenu/v1.0",
  756. type: "post",
  757. contentType: "application/json",
  758. data: JSON.stringify(par),
  759. success: function (data) {
  760. if (typeof data != "object") data = JSON.parse(data);
  761. if (data.success) {
  762. if (grid_wnd_0 != null) {
  763. grid_wnd_0.reload();
  764. }
  765. }
  766. else {
  767. layer.msg(data.message);
  768. }
  769. },
  770. error: function () {
  771. }
  772. });
  773. },
  774. }
  775. }
  776. };
  777. tree1 = new PlgZtree(treecfg);
  778. $("#" + rediv).width("100%");
  779. }
  780. //查看详细
  781. function show_info(rdata) {
  782. $("#authoritymanager_span_title").html("权限 [" + rdata.p_name + "] 信息查看");
  783. var str = `<ul>
  784. <li><span class='span-item-tit'>权限名称</span>
  785. <span class='span-item-txt'>` + ((rdata.p_name === null) ? "" : rdata.p_name) + `</sapn></li>
  786. <li><span class='span-item-tit'>权限描述</span>
  787. <span class='span-item-txt'>` + ((rdata.p_remark === null) ? "" : rdata.p_remark) + `</span></li>
  788. <li><span class='span-item-tit'>权限类型</span>
  789. <span class='span-item-txt'>` + ((rdata.p_type === null) ? "" : getNameByID(rsp_type, rdata.p_type)) + `</span></li>
  790. <li><span class='span-item-tit'>是否启用</span>
  791. <span class='span-item-txt'>` + ((rdata.p_flg === 1) ? "启用" : "停用") + `</span></li>
  792. </ul>`;
  793. $("#authoritymanager_grid_sub").html(str);
  794. changePanel("authoritymanager_grid_01_edit");
  795. }
  796. //验证下拉框是否为空
  797. function comboVal(data) {
  798. if (data.toString() === "-1") return false;
  799. return true;
  800. }
  801. //根据ID获取中文名称,rsp数据集合,code数据值
  802. function getNameByID(rsp, code) {
  803. var str = code;
  804. if (code === null) {
  805. str = "";
  806. }
  807. else if (rsp === null) {
  808. str = code;
  809. }
  810. else {
  811. for (var i = 0; i < rsp.length; i++) {
  812. if (rsp[i].value.toString() === code.toString()) {
  813. str = rsp[i].text;
  814. }
  815. }
  816. }
  817. return str;
  818. }
  819. window.res_roleManagedata_delClick = function (rid, rdata) {
  820. Prolog.delGridRowData(grid, "/api/service-users/authority/delete/v1.0", "", "", { "id": rid }, false);
  821. return false;
  822. };
  823. window.res_roleManagedata_editClick = function (rid, rdata) {
  824. grid.selectRowById(rid);
  825. authorityFormInit(1, rdata);
  826. changePanel("usermanager_grid_01_edit");
  827. return false;
  828. };
  829. window.res_roleManagedata_edit1Click = function (rid, rdata) {
  830. grid.selectRowById(rid);
  831. tmp_gridrow_id = rid;
  832. tmp_gridrowdata = rdata;
  833. $("#authoritymanager_grid_sub").html("");
  834. $("#authoritymanager_span_title").html("[" + rdata.p_name + "] 分配数据权限");
  835. var tabcfg = {
  836. renderer: "authoritymanager_grid_sub",
  837. indexActive: 0,
  838. skin: "card",
  839. content: [{
  840. title: "分配货主",
  841. id: "role_user_wnd_tab0",
  842. template: '<div id="authoritymanager_grid_sub0" style=""></div>'
  843. }, {
  844. title: "分配机构/仓",
  845. id: "role_user_wnd_tab1",
  846. template: '<div id="authoritymanager_grid_sub1" style=""></div>'
  847. }, {
  848. title: "贸易伙伴",
  849. id: "role_user_wnd_tab2",
  850. template: '<div id="authoritymanager_grid_sub2" style=""></div>'
  851. }]
  852. };
  853. var gridopt;
  854. var tabDiv;
  855. tabs1 = new PlgTabs(tabcfg).on(function (ele) {
  856. authorityauthInit(ele.index, rdata, 1);
  857. });
  858. tabs1.changeTabs('role_user_wnd_tab0');
  859. changePanel("authoritymanager_grid_01_edit");
  860. $("#authoritymanager_grid_sub").width("100%");
  861. $("#authoritymanager_grid_01_edit .tc-panel").attr("style", "padding:0;margin:0;min-height: 300px;");
  862. return false;
  863. };
  864. window.res_roleManagedata_edit2Click = function (rid, rdata) {
  865. grid.selectRowById(rid);
  866. tmp_gridrow_id = rid;
  867. $("#authoritymanager_span_title").html(" [" + rdata.p_name + "] 分配资源权限");
  868. roleauthInit(1, rdata);
  869. changePanel("authoritymanager_grid_01_edit");
  870. $("#authoritymanager_grid_sub").width("100%");
  871. $("#authoritymanager_roleadd_1").height((m > 530) ? m - 260 : m);
  872. $("#authoritymanager_roleadd_2").height((m > 530) ? m - 260 : m);
  873. return false;
  874. };
  875. })();
  876. </script>