123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447 |
- {extend name="public/layout" /} {block name="title"}组织结构{/block} {block name="body"}
- <style>
- html,
- body {
- display: block;
- width: 100%;
- height: 100%;
- background-color: #fff;
- }
-
- .cardheader {
- padding-left: 10px;
- }
-
- .laytable-cell-1-0-1 {
- height: 32px !important;
- line-height: 32px !important;
- }
-
- .layui-tree-set,
- .layui-tree-entry {
- margin-top: 5px !important;
- }
-
- .layui-table tr {
- height: 7vh;
- }
-
- @media screen and (min-width: 992px) {
- .layui-col-md9 {
- margin-left: 1%;
- width: 74%;
- }
- }
-
- .layui-table thead tr,
- .layui-table-header {
- background-color: #D8E6F1 !important;
- }
-
- #root-list {
- border-right: 1px solid #f6f6f6;
- }
-
- #addRoot {
- border-top: 1px solid #f6f6f6;
- }
-
- .root {
- cursor: pointer;
- text-align: center;
- padding: 10px 1px;
- font-size: 1rem;
- font-weight: bold;
- }
-
- .root.selected {
- font-size: x-large;
- color: #269efb;
- }
-
- .root:hover {
- font-size: x-large;
- color: #269efb;
- }
-
- .layui-form-label {
- width: 150px;
- }
-
- .layui-input-block {
- margin-left: 180px;
- }
-
- .strucinfo {
- cursor: pointer;
- }
-
- .setleader {
- float: right;
- display: none;
- }
-
- .setleader:hover {
- display: block;
- }
-
- .leader {
- float: right;
- }
- /*重要 样式*/
-
- .layui-tree-entry.tree-node-current .layui-tree-main {
- background-color: #d7edbf87;
- }
- /*重要 样式*/
-
- .layui-btn.layui-btn-success {
- background-color: #009688;
- }
-
- .filterbutton {
- float: right;
- }
-
- .layui-layer-content {
- overflow: inherit !important;
- }
-
- .layui-zz-box {
- border: 1px solid #f2f2f2;
- margin-right: 5px;
- }
-
- .list>ul:first-child>li>div {
- background-color: #f2f2f2;
- display: block;
- padding: 5px
- }
-
- .list li {
- min-width: 150px;
- }
-
- .list li div {
- padding: 3px;
- padding-right: 5px;
- }
-
- .list>ul ul {
- margin-left: 15px;
- }
-
- .list .op {
- float: right;
- margin-left: 2px;
- }
-
- .list i.op:hover,
- .list i.group:hover,
- .list span:hover {
- cursor: pointer;
- }
-
- .list span {
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 84px;
- display: inline-block;
- }
-
- .list li i:first-child {
- position: relative;
- top: -6px;
- margin-right: 5px;
- }
- .list{
- padding-bottom: 24px;
- }
-
- .everydepart {
- display: block;
- position: relative;
- padding-right: 24px !important;
- }
-
- .everydepart .checkdiv {
- display: block;
- position: absolute;
- right: 4px;
- top: 10px;
- }
-
- .addbtn {
- position: absolute;
- display: block;
- width: 48px;
- height: 32px;
- top: 40%;
- left: 50%;
- margin-left: -24px;
- }
-
- .clearfix {
- clear: both;
- }
-
- .clearfix::after {
- clear: both;
- content: ' ';
- display: table;
- }
-
- .clearfix::before {
- content: ' ';
- display: table;
- }
-
- .height100 {
- height: 100%;
- }
-
- .showdepartbox {
- border: 1px solid #f2f2f2;
- }
-
- .left {
- float: left;
- }
-
- .right {
- float: right;
- }
-
- .everynowdepart {
- position: relative;
- height: 32px;
- padding-left: 16px;
- line-height: 32px;
- border-bottom: 1px solid #e9e9e9;
- padding-right: 48px;
- }
-
- .del {
- position: absolute;
- top: 0;
- right: 0;
- height: 32px;
- width: 48px;
- text-align: center;
- cursor: pointer;
- }
-
- .rightitlebox {
- padding: 0 8px;
- border-bottom: 1px solid #e4e4e4;
- }
- div{
- box-sizing: border-box;
- }
- .leftcontentbox{
- position: relative;
- height: 100%;
- overflow: hidden;
- }
- .layui-zz-box{
- display: block;
- height: 100%;
- }
- .layui-fluid {
- padding: 15px 0;
- }
- </style>
- <body>
- <div class="layui-fluid height100">
- <div class="layui-card height100">
- <div class="layui-card-body height100">
- <div class="layui-row height100">
- <div class="layui-col-md12 layui-col-xs12 layui-col-sm12 height100">
- <div class="layui-tab layui-tab-brief height100" lay-filter="component-tabs-hash">
- <div class="layui-tab-content height100">
- <div class="layui-tab-item layui-show clearfix height100">
- <div class="layui-col-md5 layui-col-xs5 layui-col-sm5 leftcontentbox" style=" min-width: 200px;">
- <div class="layui-zz-box" style="overflow: auto;">
- <div class="tree">
- <div class="list">
- </div>
- </div>
- </div>
- </div>
- <div class="layui-col-md2 layui-col-xs2 layui-col-sm2 " style="position: unset;height: 85vh;">
- <button type="button" class="addbtn">添加</button>
- <input type="hidden" id="departinput" />
- </div>
- <div class="layui-col-md5 layui-col-xs5 layui-col-sm5 showdepartbox" style="overflow: auto;height: 85vh;">
- <div class="clearfix rightitlebox">
- <div class="left departnum">已选择0个部门</div>
- <div class="right alldel" style="cursor: pointer;">全部清除</div>
- </div>
- <div class="nowdepartbox">
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- {/block} {block name="js"}
- <script>
- layui.config({
- base: '__LAYUI__/',
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'jquery', 'table', 'tree', 'layer'], function() {
- var table = layui.table,
- tree = layui.tree,
- layer = layui.layer,
- $ = layui.jquery,
- element = layui.element,
- form = layui.form;
- var jiaojie = function(from, to, callback) {
- return $.ajax({
- type: 'post',
- url: '{:url("org/receive")}',
- data: {
- from: from,
- to: to
- },
- success: function(res) {
- callback(res)
- }
- })
- }
- var operate = {
- struct: function() {
- var that = this;
- that.send([], '{:url("train/class_assign")}', function(res) {
- if(res.code == 0) {
- $('.list').html(that.setStruct(res.data,res.checkOrg));
- } else {
- $('.list').html('<span>' + res.msg + '</span>');
- }
- $('.everydepart').click(function() {
- $(this).children('.checkdiv')[0].checked = !$(this).children('.checkdiv')[0].checked;
- })
- $('.everydepart .checkdiv').click(function(e) {
- e.stopPropagation();
- })
- $('.addbtn').click();
- });
- },
- send: function(data, url, callback) {
- if(data.length == 0) {
- return $.ajax({
- type: 'get',
- url: url,
- data: {'id':{$id}},
- success: function(res) {
- callback(res)
- }
- })
- }
- return $.ajax({
- type: 'post',
- url: url,
- data: data,
- success: function(res) {
- callback(res)
- }
- })
- },
- setStruct: function(data,checkOrg) {
- var that = this;
- var arr=checkOrg?checkOrg.split(','):[];
- var html = '<ul>';
- data.forEach(function(elem, index) {
-
- var flag=false;
- html += '<li data-id="' + elem.id + '" data-level="' + elem.level + '"><div class="everydepart">';
- if(elem.children.length !== 0)
- html += '<i class="group layui-icon layui-icon-triangle-r layui-icon-triangle-d"></i>';
- else
- html += '<i class="layui-icon layui-icon-user"></i>';
- html += '<span>' + elem.title + '</span><span>(' + elem.all_count + ')</span>';
-
- for(var i in arr){
- if(arr[i]==elem.id){
- html += '<input data-did="' + elem.id + '" data-title="' + elem.title + '" class="checkdiv" type="checkbox" checked /></div>';
- flag=true;
- }
- }
-
- if(!flag){
- html += '<input data-did="' + elem.id + '" data-title="' + elem.title + '" class="checkdiv" type="checkbox" /></div>';
- }
- if(elem.children.length > 0) {
- html += that.setStruct(elem.children,checkOrg);
- }
- html += '</li>';
- });
- html += '</ul>';
- return html
- }
- }
- // 结构初始化
- operate.struct();
- $('.addbtn').click(function(e) {
- var arr = $('#departinput').val() ? JSON.parse($('#departinput').val()) : {};
- for(var i = 0; i < $('.checkdiv').length; i++) {
- if($('.checkdiv')[i].checked) {
- arr[$($('.checkdiv')[i]).data('did')] = $($('.checkdiv')[i]).data('title');
- $($('.checkdiv')[i]).parents('.everydepart').css('display', 'none');
- }
- }
- var str = "";
- var len = 0;
- for(var j in arr) {
- len = len + 1;
- str += '<div class="everynowdepart">' +
- '<span>' + arr[j] + '</span>' +
- '<div data-did="' + j + '" class="del">删除</div>' +
- '</div >';
- }
- $('.departnum').html('已选择' + len + '个部门');
- $('.nowdepartbox').html(str);
- $('#departinput').val(JSON.stringify(arr));
- $('.del').click(function() {
- $(this).parents('.everynowdepart').remove();
- $('.departnum').html('已选择' + $('.nowdepartbox .everynowdepart').length + '个部门');
- var arr = $('#departinput').val() ? JSON.parse($('#departinput').val()) : {};
- for(var i = 0; i < $('.checkdiv').length; i++) {
- delete arr[$(this).data('did')];
- if($($('.checkdiv')[i]).data('did') == $(this).data('did')) {
- $($('.checkdiv')[i]).parents('.everydepart').css('display', 'block');
- }
- }
- $('#departinput').val(JSON.stringify(arr));
- })
- })
- $('.alldel').click(function() {
- $('.nowdepartbox').html('');
- $('.departnum').html('已选择0个部门');
- $('#departinput').val("");
- for(var i = 0; i < $('.checkdiv').length; i++) {
- $($('.checkdiv')[i]).parents('.everydepart').css('display', 'block');
- }
- })
- });
- </script>
- </body>
- {/block}
|