| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293 |
- @using ContractService.Configuration
- @using ContractService.Helpers
- @using ContractService.Views.Shared.Modals
- @using ContractService.Views.Shared.Table
- @{
- string companyNo = ViewBag.CompanyNo ?? "", lawFirmNo = ViewBag.LawFirmNo ?? "";
- var table = new TableViewModel(IwbConsts.ApiAppUrl + "Organization/GetAll", ViewBag.ActiveMenu)
- .SetFields(new List<FieldItem>()
- {
- new FieldItem("name", "部门名称", align: "left"),
- new FieldItem("description", "部门描述"),
- new FieldItem("", "操作", "ActionsFormatter"),
- }).SetPageArray(10000).SetOther(" data-row-attributes=\"RowAttributes\" "
- );
- var inputs = new List<Input>()
- {
- new InputHide("id"),
- new InputHide("companyNo"),
- new InputHide("lawFirmNo"),
- new InputHide("parentNo"),
- new Input("parentName", "父部门").SetDisabled(),
- new Input("name", "部门名称"),
- new InputNumber("sort", "排序序号").SetMin(1),
- new InputTextarea("description", "部门描述").SetNotRequired(),
- };
- var modalBody = new ModalBodyViewModel().AddInputs(inputs);
- var modal = new ModalViewModel("部门").SetBody(modalBody);
- }
- @section css{
- }
- <link href="~/Content/Libs/jstree/themes/default/style.min.css" rel="stylesheet" />
- @Html.Partial("Table/_Table", table)
- <!--Modal Start-->
- @Html.Partial("Modals/_Modal", modal)
- <section>
- <!--Auth Modal -->
- <div class="modal fade" id="auth_Modal" role="dialog" aria-labelledby="ModalLabel_AUTH" aria-hidden="true">
- <div class="modal-dialog" role="document" style="min-height: 700px; width: 500px;">
- <div class="modal-content" style="">
- @Html.Partial("Modals/_ModalHeader", new ModalHeaderViewModel("部门授权", ""))
- <form>
- <div class="modal-body" style=" padding: 10px 30px;">
- <div class="" id="auth-tree"></div>
- </div>
- </form>
- @Html.Partial("Modals/_ModalFooter", "0")
- </div>
- </div>
- </div>
- </section>
- <!--Modal End-->
- @using (Html.BeginScripts())
- {
- <script src="~/Content/Libs/jstree/jstree.min.js"></script>
- <script type="text/javascript">
- var $table = $('#table');
- var actions = [], funs = [];
- $(function () {
- @if (!string.IsNullOrEmpty(companyNo))
- {
- <text>
- funs = LoadTreeTable({
- searchList: [{ "KeyField": "companyNo", "KeyWords": '@(companyNo)', "FieldType": 0, "ExpType": 0 }],
- idField: 'id',
- treeShowField: 'name',
- parentIdField: 'parentNo',
- customDataField: ['path']
- }) ||
- { none: function() { console.log("No type"); } };
- </text>
- }
- else if(!string.IsNullOrEmpty(lawFirmNo))
- {
- <text>
- funs = LoadTreeTable({
- searchList: [{ "KeyField": "lawFirmNo", "KeyWords": '@(lawFirmNo)', "FieldType": 0, "ExpType": 0 }],
- idField: 'id',
- treeShowField: 'name',
- parentIdField: 'parentNo',
- customDataField: ['path']
- }) ||
- { none: function() { console.log("No type"); } };
- </text>
- }
- var btnCreate = funs['btnCreate'];
- funs['btnCreate'] = function(url, id) {
- console.log("Add", id);
- var row;
- if (typeof id === "string" && id !== "") {
- row = $table.bootstrapTable("getRowByUniqueId", id);
- }
- if (row) {
- var data = $.extend({}, { parentName: row.name, parentNo: row.id, companyNo: '@(companyNo)', lawFirmNo: '@(lawFirmNo)', sort: 1});
- btnCreate(url, data);
- } else {
- abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
- }
- }
- var btnUpdate = funs['btnUpdate'];
- funs['btnUpdate'] = function(url, id) {
- console.log("Edit", id);
- var row;
- if (typeof id === "string" && id !== "") {
- row = $table.bootstrapTable("getRowByUniqueId", id);
- }
- if (row) {
- var data = $.extend({}, row, { parentName: row.parentName ? row.parentName : "根节点", companyNo: '@(companyNo)', lawFirmNo: '@(lawFirmNo)', sort: row.sort});
- btnUpdate(url, data);
- } else {
- abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
- }
- }
- //var btnOrgAuth = funs['btnUpdate'];
- funs['btnOrgAuth'] = function(url, id) {
- console.log("Auth", id);
- var row;
- if (typeof id === "string" && id !== "") {
- row = $table.bootstrapTable("getRowByUniqueId", id);
- }
- if (row) {
- var orgId = row.id;
- $.iwbAjax4({
- url: abp.appUrl + 'Organization/GetPermissions?orgId=' + orgId,
- success: function(res) {
- $("#auth_Modal").on('show.bs.modal',
- function() {
- AuthFormatter(res);
- $("#auth_Modal").find("button.save-btn").off("click").on("click",
- function() {
- var authData = GetAuthData(orgId);
- $.iwbAjax1({
- url: url,
- success: function() { $("#auth_Modal").modal("hide"); },
- data: authData
- });
- });
- });
- $("#auth_Modal").modal("show");
- }
- });
- } else {
- abp.message.warn(abp.localization.iwbZero('SelectRecordOperation'));
- }
- }
- });
- //自定义属性
- function RowAttributes(r) {
- return {
- "data-no": r.id,
- "data-parent": r.parentNo
- };
- }
- </script>
- <script>
- function AuthFormatter(data) {
- var authData = [];
- authData.push(data);
- authData = AuthDataConvert(authData).authData;
- console.log(authData);
- $("#auth-tree").jstree("destroy");
- $("#auth-tree").jstree({
- plugins: ["wholerow", "checkbox", "types"],
- core: {
- themes: {
- responsive: false
- },
- data: authData
- },
- types: {
- default:
- {
- icon: "fa fa-folder m--font-warning"
- },
- file: {
- icon: "fa fa-file m--font-warning"
- }
- }
- });
- //[{
- // text: "Same but with checkboxes",
- // children: [{
- // id:"",
- // text: "initially selected",
- // state: {
- // selected: !0
- // opened: !0
- // disabled: !0
- // }
- // }]
- // }]
- }
- function AuthDataConvert(data) {
- //console.log(data);
- var authData = [], j = 0;
- for (var i = 0; i < data.length; i++) {
- var item = data[i], newItem = {};
- newItem["id"] = item.name;
- newItem["text"] = item.permDisplayName;
- newItem["icon"] = item.icon + " m--font-warning ";
- newItem["state"] = {};
- newItem["state"].opened = item.isOpen;
- var childResult = { "authData": [], "isAuth": true };
- if (item.children && item.children.length > 0) {
- childResult = AuthDataConvert(item.children);
- newItem["children"] = childResult.authData;
- }
- if (!(item.isAuth && childResult.isAuth)) {
- j++;
- }
- newItem["state"].selected = item.isAuth && childResult.isAuth;
- authData.push(newItem);
- }
- var result = { "authData": authData, "isAuth": j === 0 };
- return result;
- }
- function GetAuthData(roleId) {
- var authData = { Id: roleId, PermissionNames: [] };
- var permissionNames = $('#auth-tree').jstree(true).get_selected(false); //获得所有选中节点,返回值为数组
- //console.log(1,permissionNames);
- //加上灰色的节点
- $(".jstree-undetermined").each(function () {
- permissionNames.push($(this).parent().parent().attr('id'));
- });
- //console.log(2,permissionNames);
- authData.PermissionNames = permissionNames;
- return authData;
- }
- </script>
- <script>
- function FunctionCall(type, url, id, that) {
- funs[type] ? funs[type].call(this, url, id, that) : funs["none"].call(this);
- }
- </script>
- <script>
- //操作按钮
- function ActionsFormatter(v, r) {
- var str = '<div class="btn-tool">';
- for (var i = 0; i < actions.length; i++) {
- str += '<span class="table-action" onclick="FunctionCall(\'' +
- actions[i]["type"] +
- '\',\'' +
- actions[i]["url"] +
- '\',\'' +
- r.id +
- '\',this)"><i class="' +
- actions[i]["icon"] +
- '"></i>' +
- actions[i]["name"] +
- ' </span>';
- }
- str += '</div>';
- return str;
- }
- // 格式化类型
- function TypeFormatter(v) {
- var functionTypeName = $('#hid-functionType option[value="' + v + '"]').text();
- switch (v) {
- case 9:
- return '<span class="label sm label-warning">' + functionTypeName + '</span>';
- case 1:
- return '<span class="label sm label-danger">' + functionTypeName + '</span>';
- case 2:
- return '<span class="label sm label-info">' + functionTypeName + '</span>';
- case 3:
- return '<span class="label sm label-success">' + functionTypeName + '</span>';
- default:
- return v;
- }
- }
- </script>
- }
- <section style="display: none">
- <select id="hid-type">
- <option value=""></option>
- </select>
- @*@Html.DropDownList("hid-type", type)*@
- </section>
|