123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943 |
- <!-- 权限管理 -->
- <style>
- #authoritymanager_grid_01>div { margin-top: 0px;}
- #authoritymanager_grid_sub .layui-tab { margin-top: 0px;}
- </style>
- <div id="authorityList" class="plg-tab-container">
- <div class="layui-carousel" id="authoritymanager_grid" style="margin-bottom: -15px;">
- <div carousel-item>
- <div id="authoritymanager_grid_01" class="grid-container-full"></div>
- <div id="authoritymanager_grid_01_edit" class="grid-container-full" style="min-height: 550px;">
- <div class="layui-row">
- <div class="layui-col-lg12">
- <div class="tc-title">
- <a href="#" id="authoritymanager_btn_back" class="back-link"><i class="layui-icon layui-icon-return"></i></a>
- <span id="authoritymanager_span_title"></span>
- </div>
- </div>
- </div>
- <div class="layui-row layui-col-space15" style="margin: 20px;">
- <div class="layui-col-lg12 tc-panel" style="min-height: 300px;">
- <div id="authoritymanager_grid_sub" style="min-height: 450px;"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <script type="text/javascript">
- /**
- * jiw
- * 2018.11.29
- * 权限、权限组管理界面
- */
- (function () {
- var grid = null;
- var form1 = null, tabs1;
- 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";
- var m = $(document.body).height();
- var rsp_type = [{ text: "资源权限", value: "0" }, { text: "数据权限", value: "1" }];
- var param = { "type": "0", "pageNum": 1, "pageSize": 10 };
- gridInit(0);
- //滑屏
- var carousel = layui.carousel;
- var car = carousel.render({
- elem: "#authoritymanager_grid",
- autoplay: false,
- index: 0,
- arrow: "none",
- indicator: "none",
- anim: "fade",
- width: "100%",
- height: "100%"
- });
- function changePanel(name) {
- car.slide(name);
- }
- //返回主页面
- $("#authoritymanager_btn_back").click(function () {
- changePanel("authoritymanager_grid_01");
- return false;
- });
- function gridInit(type) {
- if (type === 0) {
- var gridOpts = {
- skin: "terrace",
- rowId: "p_id",
- columns: [
- { id: "p_id", name: "id", type: "ro", hidden: true },
- { id: "p_name", name: "权限名称", type: "ro" },
- { id: "p_type", name: "权限类型", type: "ro", render: function (v) { return getNameByID(rsp_type, v); } },
- { id: "p_remark", name: "权限描述", type: "ro" },
- { id: "p_flg", name: "是否启用", type: "ch" },
- {
- id: "op", name: "操作", type: 'button', align: "center", width: 200, render: function () {
- var t1 = "修改^res_roleManagedata_editClick,删除^res_roleManagedata_delClick,资源权限^res_roleManagedata_edit2Click";
- var t2 = "修改^res_roleManagedata_editClick,删除^res_roleManagedata_delClick,数据权限^res_roleManagedata_edit1Click";
- if (tmp_type === "1") {
- return t2;
- }
- else {
- return t1;
- }
- }
- }
- ],
- multiselect: false,
- toolbar: [
- { type: "input", name: "search", label: "权限名称:", placeholder: "", offsetLeft: 10 },
- { type: "newcolumn" },
- {
- type: "combo",
- name: "type",
- label: "权限类型:",
- offsetLeft: 20,
- width: 130,
- options: rsp_type
- },
- { type: "newcolumn" },
- { type: "button", offsetLeft: 20, name: "btn_search", width: 50, value: "查询" },
- { type: "newcolumn" },
- { type: "newcolumn" },
- {
- type: "button",
- name: "btn_add",
- className: "plg-toolbar-right",
- width: 80,
- offsetLeft: 20,
- value: "<i class='layui-icon layui-icon-add-1'></i>新增"
- }, { type: "newcolumn" }
- ],
- imagePath: "/prologui/assets/PlgGrid",
- url: "/api/service-users/authority/query/v1.0",
- type: "post",
- params: param,
- contentType: "application/x-www-form-urlencoded",
- page: true,
- totalCount: "totalCount"
- };
- grid = new PlgGrid(gridOpts);
- grid.renderTo("authoritymanager_grid_01");
- grid.loadData();
- //工具栏按钮事件
- grid.attachToolBarEvent("onButtonClick", function (name) {
- // 查询
- if (name === "btn_search") {
- grid.setParams(grid.getToolBarForm().getFormData());
- grid.reload();
- }
- // 新增
- else if (name === "btn_add") {
- addauthority();
- }
- });
- grid.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
- var p = grid.getToolBarForm().getFormData();
- tmp_type = p.type;
- p.pageNum = 1;
- p.pageSize = 10;
- grid.setParams(p);
- grid.reload();
- });
- // 双击行编辑
- grid.on("onRowDblClicked", function () {
- show_info(grid.getSelectedRowData());
- });
- }
- }
- //添加权限
- function addauthority() {
- stepindex = 0;
- var str;
- if (tmp_type === "0") {
- str = `<div class="layui-col-lg12 tc-15-step" id="authoritymanager_grid_roleadd_main">
- <ol>
- <li class="succeed">
- <div class="tc-15-step-name"><span class="tc-15-step-num">1</span>填写信息</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- <li class="disabled">
- <div class="tc-15-step-name"><span class="tc-15-step-num">2</span>资源权限</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- <li class="disabled">
- <div class="tc-15-step-name"><span class="tc-15-step-num">3</span>完成</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- </ol>
- </div>
- <div class="layui-col-lg12" id="authoritymanager_grid_roleadd_content"></div>
- <div class="layui-col-lg12 button-ft">
- <button class="layui-btn layui-btn-sm layui-btn-normal" id="authorityadd_btn_next">下一步</button>
- </div>`;
- }
- else {
- str = `<div class="layui-col-lg12 tc-15-step" id="authoritymanager_grid_roleadd_main">
- <ol>
- <li class="succeed">
- <div class="tc-15-step-name"><span class="tc-15-step-num">1</span>填写信息</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- <li class="disabled">
- <div class="tc-15-step-name"><span class="tc-15-step-num">2</span>货主</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- <li class="disabled">
- <div class="tc-15-step-name"><span class="tc-15-step-num">3</span>机构/仓</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- <li class="disabled">
- <div class="tc-15-step-name"><span class="tc-15-step-num">4</span>贸易伙伴</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- <li class="disabled">
- <div class="tc-15-step-name"><span class="tc-15-step-num">5</span>完成</div>
- <div class="tc-15-step-arrow"></div>
- </li>
- </ol>
- </div>
- <div class="layui-col-lg12" style="min-height: 280px;">
- <div id="authoritymanager_grid_roleadd_content"></div>
- </div>
- </div>
- <div class="layui-col-lg12 button-ft">
- <button class="layui-btn layui-btn-sm layui-btn-normal" id="authorityadd_btn_next">下一步</button>
- </div>`;
- }
- $("#authoritymanager_grid_sub").html(str);
- $("#authorityadd_btn_next").show();
- $("ol li").each(function () {
- if ($(this).index() === 0) {
- $(this).removeClass("disabled");
- $(this).addClass("succeed");
- }
- else {
- $(this).removeClass("succeed");
- $(this).addClass("disabled");
- }
- });
- authorityFormInit(0, {});
- changePanel("authoritymanager_grid_01_edit");
- $("#authoritymanager_grid_roleadd_content").height((m > 530) ? m - 400 : m);
- $("#authoritymanager_grid_sub").width("100%");
- $("#authoritymanager_grid_01_edit .tc-panel").attr("style", "min-height: 400px;");
- $("#authorityadd_btn_next").click(function () {
- if (stepindex === 0) {
- var b = form1.validate();
- if (!b) return;
- var fd = form1.getFormData();
- rdata = save_authorityinfo(grid, "/api/service-users/authority/insert/v1.0", "post", "application/x-www-form-urlencoded", fd);
- if (rdata === null) {
- layer.msg("获取权限信息失败!");
- return;
- }
- tmp_gridrowdata = rdata;
- if (tmp_type === "0") {
- roleauthInit(0, tmp_gridrowdata);
- }
- else {
- authorityauthInit(0, tmp_gridrowdata, 0);
- }
- }
- else {
- if (tmp_type === "0") {
- if (stepindex === 1) {
- $("#authoritymanager_grid_roleadd_content").html("<h1>权限新增成功,3秒后返回!</h1>");
- grid.reload();
- $("#authorityadd_btn_next").hide();
- setTimeout(function () { changePanel("authoritymanager_grid_01"); }, 3000);
- }
- }
- else {
- if (stepindex === 1) {
- authorityauthInit(1, tmp_gridrowdata, 0);
- }
- else if (stepindex === 2) {
- authorityauthInit(2, tmp_gridrowdata, 0);
- }
- else if (stepindex === 3) {
- $("#authoritymanager_grid_roleadd_content").html("<h1>权限新增成功,3秒后返回!</h1>");
- grid.reload();
- $("#authorityadd_btn_next").hide();
- setTimeout(function () { changePanel("authoritymanager_grid_01"); }, 3000);
- }
- }
- }
- stepindex++;
- $("ol li").each(function () {
- if (stepindex === $(this).index()) {
- $(this).removeClass("disabled");
- $(this).addClass("succeed");
- }
- });
- });
- }
- //权限-表单
- function authorityFormInit(ntype, rdata) {
- var tit = "新增权限";
- var rediv = "authoritymanager_grid_roleadd_content";
- if (ntype === 1) {
- tit = "权限 [" + rdata.p_name + "] 信息修改";
- rediv = "authoritymanager_grid_sub";
- }
- $("#authoritymanager_span_title").html(tit);
- $("#" + rediv).html("");
- var formcfg = {
- renderer: rediv,
- items: [
- { type: "settings", inputWidth: 140, width: 550, labelWidth: 80, position: "label-left", labelAlign: "left" },
- {
- type: "settings",
- inputWidth: 140,
- width: 550,
- labelWidth: 80,
- position: "label-left",
- labelAlign: "left"
- },
- {
- type: "block", width: 520,
- list: [
- { type: "input", name: "p_name", label: "权限名称:", validate: "NotEmpty", required: true, editable: false },
- { type: "newcolumn", offset: 40 },
- {
- type: "combo",
- name: "p_type",
- label: "权限类型:",
- offsetLeft: 10,
- width: 130,
- options: rsp_type,
- disabled: true
- }
- ]
- },
- {
- type: "block", width: 520,
- list: [
- { type: "input", name: "p_remark", label: "权限描述:" },
- { type: "newcolumn", offset: 40 },
- { type: "checkbox", name: "p_flg", label: "是否启用:" }]
- },
- {
- type: "block", width: 520, list: [
- { type: "button", name: "btn_save_roleinfo", offsetLeft: 80, value: "保存", hidden: (ntype != 1) },
- { type: "hidden", name: "p_id" },
- ]
- }
- ]
- };
- rdata.p_type = tmp_type;
- form1 = new PlgForm(formcfg);
- form1.setFormData(rdata);
- if (ntype === 1) {
- form1.getDForm().disableItem("p_name");
- }
- form1.attachEvent("onButtonClick", function (name) {
- if (name === "btn_save_roleinfo") {
- var fd = form1.getFormData();
- save_authorityinfo(grid, "/api/service-users/authority/update/v1.0", "put", "application/x-www-form-urlencoded", fd);
- }
- });
- }
- //权限-信息保存
- function save_authorityinfo(grid, url, type, contentType, formData) {
- var rep = null;
- Prolog.ajax({
- url: url,
- type: type,
- contentType: contentType,
- data: formData,
- async: false,
- success: function (data) {
- if (data.success) {
- if (type === "put")
- layer.msg("保存成功!");
- grid.reload();
- rep = data.data;
- }
- else {
- layer.msg(data.message);
- }
- },
- error: function () {
- }
- });
- return rep;
- }
- //数据权限-分配
- function authorityauthInit(ntype, rdata, type, grid) {
- var rediv = "authoritymanager_grid_roleadd_content";
- if (type === 1) {
- rediv = "authoritymanager_grid_sub" + ntype;
- }
- if (grid_wnd_0 != null)
- {
- grid_wnd_0.getGrid().clearAll();
- }
- if (ntype === 0){
- $("#"+rediv).html("");
- param.roleid = rdata.p_id;
- param.companyid = "";
- param.search = "";
-
- var gridopt = {
- skin: "terrace",
- rowId: "companyid",
- columns: [
- { id: "companyid", name: "companyid", type: "ro", hidden: true },
- { id: "companycode", name: "货主编号", type: "ro" },
- { id: "locname", name: "货主名称", type: "ro" },
- { id: "zjm", name: "助记码", type: "ro" }
- ],
- toolbar: [
- { type: "input", name: "search", label: "查询条件:", placeholder: "名称", offsetLeft: 10 }, { type: "newcolumn" },
- {
- type: "combo",
- name: "type",
- label: "状态:",
- offsetLeft: 10,
- width: 130,
- options: [{ text: "未分配", value: "0" }, { text: "已分配", value: "1" }],
- hidden: (type === 0)
- }, { type: "newcolumn" },
- { type: "button", name: "btn_search", offsetLeft: 20, value: "查询" }, { type: "newcolumn" },
- { type: "button", name: "btn_save", offsetLeft: 10, value: "保存" }
- ],
- multiselect: true,
- imagePath: "/prologui/assets/PlgGrid",
- url: "/api/service-users/company/queryConsignorPage/v1.0",
- type: "post",
- contentType: "application/x-www-form-urlencoded",
- params: param,
- page: true,
- totalCount: "totalCount"
- };
- grid_wnd_0 = new PlgGrid(gridopt);
- grid_wnd_0.renderTo(rediv);
- grid_wnd_0.loadData();
-
- if (type === 1) {
- $("#" + rediv).height(m - 300);
- }
- else {
- $("#" + rediv).width("100%");
- }
- grid_wnd_0.attachToolBarEvent("onButtonClick", function (name) {
- var p = grid_wnd_0.getToolBarForm().getFormData();
- // 查询
- if (name === "btn_search") {
- p.roleid = rdata.p_id;
- grid_wnd_0.setParams(p);
- grid_wnd_0.reload();
- } else if (name === "btn_save") {
- var state = grid_wnd_0.getToolBarForm().getFormData().type;
- var sid = grid_wnd_0.getCheckedIds();
- if (sid === null) return;
- state = (state === "0") ? "1" : "0";
- save_authorityauth(ntype, sid, state);
- }
- });
- grid_wnd_0.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
- var p = grid_wnd_0.getToolBarForm().getFormData();
- p.pageNum = 1;
- p.pageSize = 10;
- p.roleid = rdata.p_id;
- grid_wnd_0.setParams(p);
- grid_wnd_0.reload();
- });
- }
- else if (ntype === 1){
- $("#"+rediv).html("");
- param.roleid = rdata.p_id;
- param.companyid = "";
- param.search = "";
-
- var gridopt = {
- skin: "terrace",
- rowId: "companyid",
- columns: [
- { id: "companyid", name: "companyid", type: "ro", hidden: true },
- { id: "companycode", name: "仓编号", type: "ro" },
- { id: "locname", name: "仓名称", type: "ro" },
- { id: "zjm", name: "助记码", type: "ro" }
- ],
- toolbar: [
- { type: "input", name: "search", label: "查询条件:", placeholder: "名称", offsetLeft: 10 }, { type: "newcolumn" },
- {
- type: "combo",
- name: "type",
- label: "状态:",
- offsetLeft: 10,
- width: 130,
- options: [{ text: "未分配", value: "0" }, { text: "已分配", value: "1" }],
- hidden: (type === 0)
- }, { type: "newcolumn" },
- { type: "button", name: "btn_search", offsetLeft: 20, value: "查询" }, { type: "newcolumn" },
- { type: "button", name: "btn_save", offsetLeft: 10, value: "保存" }
- ],
- multiselect: true,
- imagePath: "/prologui/assets/PlgGrid",
- url: "/api/service-users/branch/queryBranchPage/v1.0",
- type: "post",
- contentType: "application/x-www-form-urlencoded",
- params: param,
- page: true,
- totalCount: "totalCount"
- };
- grid_wnd_0 = new PlgGrid(gridopt);
- grid_wnd_0.renderTo(rediv);
- grid_wnd_0.loadData();
-
- if (type === 1) {
- $("#" + rediv).height(m - 300);
- }
- else {
- $("#" + rediv).width("100%");
- }
-
- grid_wnd_0.attachToolBarEvent("onButtonClick", function (name) {
- var p = grid_wnd_0.getToolBarForm().getFormData();
- // 查询
- if (name === "btn_search") {
- p.roleid = rdata.p_id;
- grid_wnd_0.setParams(p);
- grid_wnd_0.reload();
- } else if (name === "btn_save") {
- var state = grid_wnd_0.getToolBarForm().getFormData().type;
- var sid = grid_wnd_0.getCheckedIds();
- if (sid === null) return;
- state = (state === "0") ? "1" : "0";
- save_authorityauth(ntype, sid, state);
- }
- });
- grid_wnd_0.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
- var p = grid_wnd_0.getToolBarForm().getFormData();
- p.pageNum = 1;
- p.pageSize = 10;
- p.roleid = rdata.p_id;
- grid_wnd_0.setParams(p);
- grid_wnd_0.reload();
- });
- }
- else if (ntype === 2){
- $("#"+rediv).html("");
- param.roleid = rdata.p_id;
- param.companyid = "";
- param.search = "";
-
- var gridopt = {
- skin: "terrace",
- rowId: "companyid",
- columns: [
- { id: "companyid", name: "companyid", type: "ro", hidden: true },
- { id: "companycode", name: "客户编号", type: "ro" },
- { id: "locname", name: "客户名称", type: "ro" },
- { id: "zjm", name: "助记码", type: "ro" }
- ],
- toolbar: [
- { type: "input", name: "search", label: "查询条件:", placeholder: "名称", offsetLeft: 10 }, { type: "newcolumn" },
- {
- type: "combo",
- name: "type",
- label: "状态:",
- offsetLeft: 10,
- width: 130,
- options: [{ text: "未分配", value: "0" }, { text: "已分配", value: "1" }],
- hidden: (type === 0)
- }, { type: "newcolumn" },
- { type: "button", name: "btn_search", offsetLeft: 20, value: "查询" }, { type: "newcolumn" },
- { type: "button", name: "btn_save", offsetLeft: 10, value: "保存" }
- ],
- multiselect: true,
- imagePath: "/prologui/assets/PlgGrid",
- url: "/api/service-users/company/queryCustomerPage/v1.0",
- type: "post",
- contentType: "application/x-www-form-urlencoded",
- params: param,
- page: true,
- totalCount: "totalCount"
- };
- grid_wnd_0 = new PlgGrid(gridopt);
- grid_wnd_0.renderTo(rediv);
- grid_wnd_0.loadData();
-
- if (type === 1) {
- $("#" + rediv).height(m - 300);
- }
- else {
- $("#" + rediv).width("100%");
- }
-
- grid_wnd_0.attachToolBarEvent("onButtonClick", function (name) {
- var p = grid_wnd_0.getToolBarForm().getFormData();
- // 查询
- if (name === "btn_search") {
- p.roleid = rdata.p_id;
- grid_wnd_0.setParams(p);
- grid_wnd_0.reload();
- } else if (name === "btn_save") {
- var state = grid_wnd_0.getToolBarForm().getFormData().type;
- var sid = grid_wnd_0.getCheckedIds();
- if (sid === null) return;
- state = (state === "0") ? "1" : "0";
- save_authorityauth(ntype, sid, state);
- }
- });
- grid_wnd_0.getToolBarForm().getCombo("type").attachEvent("onChange", function (v, t) {
- var p = grid_wnd_0.getToolBarForm().getFormData();
- p.pageNum = 1;
- p.pageSize = 10;
- p.roleid = rdata.p_id;
- grid_wnd_0.setParams(p);
- grid_wnd_0.reload();
- });
- }
- }
- //数据权限-保存
- function save_authorityauth(ntype, sid, state) {
- var par, rsp = null, url;
- if (ntype == 0) {
- url = "/api/service-users/role/allotUserRole/v1.0";
- par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
- }
- else if (ntype == 1) {
- url = "/api/service-users/role/allotUserRoleGroup/v1.0";
- par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
- }
- else if (ntype == 2) {
- url = "/api/service-users/role/allotUserRoleGroup/v1.0";
- par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
- }
- else if (ntype == 3) {
- url = "/api/service-users/role/allotUserRoleGroup/v1.0";
- par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
- }
- else if (ntype == 4) {
- url = "/api/service-users/role/allotUserRoleGroup/v1.0";
- par = { "type": state, "roleid": tmp_gridrow_id, "userids": sid };
- }
- layer.msg("数据处理中...");
- Prolog.ajax({
- url: url,
- type: "post",
- contentType: "application/json",
- data: JSON.stringify(par),
- async: false,
- success: function (data) {
- if (typeof data != "object") data = JSON.parse(data);
- if (data.success) {
- layer.closeAll();
- grid_wnd_0.reload();
- rsp = data;
- }
- else {
- layer.open({
- type: 1, offset: "auto", id: 'layerError', title: "错误提示"
- , area: ["500px"], content: '<div style="padding: 10px;">' + data.message + '</div>'
- , btn: '关闭', btnAlign: 'r', shade: 0
- , yes: function () {
- layer.closeAll();
- }
- });
- rsp = null;
- }
- },
- error: function () {
- }
- });
- return rsp;
- }
- //分配资源权限
- function roleauthInit(ntype, rdata) {
- var rediv = "authoritymanager_grid_roleadd_content";
- if (ntype === 1) {
- rediv = "authoritymanager_grid_sub";
- }
- $("#" + rediv).html('<div id="authoritymanager_roleadd_1" class="layui-col-lg5" style="border: 1px solid #ddd ;height:370px;overflow:auto"></div>' +
- '<div id="authoritymanager_roleadd_2" class="layui-col-lg7" style="border: 1px solid #ddd ;height:370px;overflow:auto"></div>');
- var rid = rdata.p_id;
- var rsp_tree = [];
- Prolog.ajax({
- url: "/api/service-users/authority/getAuthMenu/v1.0",
- type: "get",
- contentType: "application/x-www-form-urlencoded",
- data: { "id": rdata.p_id },
- async: false,
- success: function (data) {
- if (data.success) {
- for (var i = 0; i < data.data.length; i++) {
- rsp_tree.push({
- id: data.data[i].id,
- name: "[" + data.data[i].id + "]" + data.data[i].name,
- menuId: data.data[i].id,
- nlevel: data.data[i].level,
- parentMenuId: data.data[i].parentid,
- isParent: (data.data[i].leaf === 0) ? true : false,
- checked: (data.data[i].status === "1") ? true : false,
- systemid: data.data[i].systemid
- });
- }
- }
- },
- error: function () {
- }
- });
- $("#authoritymanager_roleadd_1").html("");
- var treecfg = {
- renderer: "authoritymanager_roleadd_1",
- setData: rsp_tree,
- skin: "menu-tree",
- toolBar: false,
- delMenu: null,
- setting: {
- check: {
- enable: true
- },
- callback: {
- //单击事件的回调
- onClick: function (event, treeId, treeNode) {
- $("#authoritymanager_roleadd_2").html("");
- if (treeNode.isParent === true) {
- return;
- }
- var gridOpts = {
- skin: "terrace",
- rowId: "btn_no",
- columns: [
- { id: "id", name: "编号", type: "ro" },
- { id: "name", name: "名称", type: "ro" },
- { id: "status", name: "启用", type: "ch", width: "*" },
- { id: "menuid", name: "菜单ID", type: "ro" }
- ],
- multiselect: false,
- imagePath: "/prologui/assets/PlgGrid",
- url: '/api/service-users/authority/getAuthMenuRes/v1.0',
- type: "get",
- params: { "authid": rid, "menuid": treeNode.id, pageNum: 1, pageSize: 99 },
- contentType: "application/x-www-form-urlencoded",
- page: false
- };
- grid_wnd_0 = new PlgGrid(gridOpts);
- grid_wnd_0.renderTo("authoritymanager_roleadd_2");
- grid_wnd_0.loadData();
- grid_wnd_0.on("onCheck", function (rId, cInd, state) {
- if (!treeNode.checked) {
- grid_wnd_0.getGrid().setCheckedRows(cInd, 0);
- return;
- }
- var par = { "authid": rid, "resourceid": rId, "state": ((state) ? 1 : 0) };
- Prolog.ajax({
- url: "/api/service-users/authority/allotAuthMenuRes/v1.0",
- type: "post",
- contentType: "application/json",
- data: JSON.stringify(par),
- success: function (data) {
- if (typeof data != "object") data = JSON.parse(data);
- if (data.success) {
- }
- else {
- layer.msg(data.message);
- }
- },
- error: function () {
- }
- });
- });
- },
- //复选框的回调
- onCheck: function (e, treeId, treeNode) {
- var ids = "";
- var systemid = "";
- var nodes = tree1.treeObj.getChangeCheckedNodes();
- for (var i = 0, l = nodes.length; i < l; i++) {
- systemid = nodes[i].systemid;
- ids += nodes[i].id + ",";
- nodes[i].checkedOld = nodes[i].checked;
- }
- var par = {
- "systemid": systemid,
- "authid": rid,
- "menuids": ids.substring(0, ids.length - 1),
- "state": ((nodes[0].checked) ? 1 : 0)
- };
- Prolog.ajax({
- url: "/api/service-users/authority/allotAuthMenu/v1.0",
- type: "post",
- contentType: "application/json",
- data: JSON.stringify(par),
- success: function (data) {
- if (typeof data != "object") data = JSON.parse(data);
- if (data.success) {
- if (grid_wnd_0 != null) {
- grid_wnd_0.reload();
- }
- }
- else {
- layer.msg(data.message);
- }
- },
- error: function () {
- }
- });
- },
- }
- }
- };
- tree1 = new PlgZtree(treecfg);
- $("#" + rediv).width("100%");
- }
- //查看详细
- function show_info(rdata) {
- $("#authoritymanager_span_title").html("权限 [" + rdata.p_name + "] 信息查看");
- var str = `<ul>
- <li><span class='span-item-tit'>权限名称</span>
- <span class='span-item-txt'>` + ((rdata.p_name === null) ? "" : rdata.p_name) + `</sapn></li>
- <li><span class='span-item-tit'>权限描述</span>
- <span class='span-item-txt'>` + ((rdata.p_remark === null) ? "" : rdata.p_remark) + `</span></li>
- <li><span class='span-item-tit'>权限类型</span>
- <span class='span-item-txt'>` + ((rdata.p_type === null) ? "" : getNameByID(rsp_type, rdata.p_type)) + `</span></li>
- <li><span class='span-item-tit'>是否启用</span>
- <span class='span-item-txt'>` + ((rdata.p_flg === 1) ? "启用" : "停用") + `</span></li>
- </ul>`;
- $("#authoritymanager_grid_sub").html(str);
- changePanel("authoritymanager_grid_01_edit");
- }
- //验证下拉框是否为空
- function comboVal(data) {
- if (data.toString() === "-1") return false;
- return true;
- }
- //根据ID获取中文名称,rsp数据集合,code数据值
- function getNameByID(rsp, code) {
- var str = code;
- if (code === null) {
- str = "";
- }
- else if (rsp === null) {
- str = code;
- }
- else {
- for (var i = 0; i < rsp.length; i++) {
- if (rsp[i].value.toString() === code.toString()) {
- str = rsp[i].text;
- }
- }
- }
- return str;
- }
- window.res_roleManagedata_delClick = function (rid, rdata) {
- Prolog.delGridRowData(grid, "/api/service-users/authority/delete/v1.0", "", "", { "id": rid }, false);
- return false;
- };
- window.res_roleManagedata_editClick = function (rid, rdata) {
- grid.selectRowById(rid);
- authorityFormInit(1, rdata);
- changePanel("usermanager_grid_01_edit");
- return false;
- };
- window.res_roleManagedata_edit1Click = function (rid, rdata) {
- grid.selectRowById(rid);
- tmp_gridrow_id = rid;
- tmp_gridrowdata = rdata;
- $("#authoritymanager_grid_sub").html("");
- $("#authoritymanager_span_title").html("[" + rdata.p_name + "] 分配数据权限");
- var tabcfg = {
- renderer: "authoritymanager_grid_sub",
- indexActive: 0,
- skin: "card",
- content: [{
- title: "分配货主",
- id: "role_user_wnd_tab0",
- template: '<div id="authoritymanager_grid_sub0" style=""></div>'
- }, {
- title: "分配机构/仓",
- id: "role_user_wnd_tab1",
- template: '<div id="authoritymanager_grid_sub1" style=""></div>'
- }, {
- title: "贸易伙伴",
- id: "role_user_wnd_tab2",
- template: '<div id="authoritymanager_grid_sub2" style=""></div>'
- }]
- };
- var gridopt;
- var tabDiv;
- tabs1 = new PlgTabs(tabcfg).on(function (ele) {
- authorityauthInit(ele.index, rdata, 1);
- });
- tabs1.changeTabs('role_user_wnd_tab0');
- changePanel("authoritymanager_grid_01_edit");
- $("#authoritymanager_grid_sub").width("100%");
- $("#authoritymanager_grid_01_edit .tc-panel").attr("style", "padding:0;margin:0;min-height: 300px;");
- return false;
- };
- window.res_roleManagedata_edit2Click = function (rid, rdata) {
- grid.selectRowById(rid);
- tmp_gridrow_id = rid;
- $("#authoritymanager_span_title").html(" [" + rdata.p_name + "] 分配资源权限");
- roleauthInit(1, rdata);
- changePanel("authoritymanager_grid_01_edit");
- $("#authoritymanager_grid_sub").width("100%");
- $("#authoritymanager_roleadd_1").height((m > 530) ? m - 260 : m);
- $("#authoritymanager_roleadd_2").height((m > 530) ? m - 260 : m);
- return false;
- };
- })();
- </script>
|