123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824 |
- {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: 184px;
- display: inline-block;
- }
-
- .list li i:first-child {
- position: relative;
- top: -6px;
- margin-right: 5px;
- }
- .list{
- padding-bottom: 24px;
- padding-right: 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;*/
- width: 64%;
- }
-
- .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;
- width: 36%;
- }
- .rotate {
- transform: rotateY(90deg);
- }
- .layui-zz-box{
- display: block;
- height: 100%;
- }
- .layui-fluid {
- padding: 15px 0;
- }
- .keyword{
- height: 35px;
- margin: 4px;
- }
- .keywords{
- height: 35px;
- margin: 4px;
- }
- input[disabled][type="checkbox"]:checked::before {
- content: "\2713";
- background-color: #2196F3;
- color: #fff;
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- border: 1px solid #2196F3;
- font-size: 12px;
- font-weight: bold;
- text-align: center;
- line-height: 18px;
- z-index: 999;
- }
- #range_person {
- height: calc(100vh - 130px);
- }
- .layui-border-left {
- display: inline-block;
- border-left: 5px solid #666666;
- padding-left: 10px;
- }
- .flex {
- display: flex;
- align-items: center;
- padding: 0px 20px;
- }
- .plr20 {
- padding: 0px 20px;
- }
- .circle {
- width: 5px;
- height: 5px;
- background-color: #333;
- border-radius: 50%;
- position: absolute;
- left: 0px;
- top: 10px;
- }
- .relative {
- position: relative;
- height: 30px;
- line-height: 30px;
- }
- .line {
- position:absolute;
- width:1px;
- height:30px;
- background-color: #666666;
- left: 2.3px;
- top:13px;
- }
- .mt10 {
- margin-top: 10px;
- }
- .delcolor{
- color: #249EFB;
- }
- .layui-card .layui-tab-brief .layui-tab-content{padding: 8px;}
- </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" >
- <div class="tree">
- <div class="clearfix rightitlebox layui-hide">
- <div class="left departnum">
- <div class="layui-inline">
- <div class="layui-input-inline" style="width: auto;">
- <input type="text" name="keyword" placeholder="请输入关键字搜索" autocomplete="off" class="layui-input keyword" id="keyword_left_text">
- </div>
- </div>
- </div>
- <div class="" style="cursor: pointer;" id="left_search">
- <button class="layui-btn layuiadmin-btn keyword" lay-submit lay-filter="LAY-app-contlist-search">
- <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
- </div>
- </div>
- <div class="list" id="range_person" style="overflow: auto;"></div>
- </div>
- </div>
- </div>
- <div class="layui-col-md2 layui-col-xs2 layui-col-sm2 layui-hide" style="position: unset;height: 90vh;">
- <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: 90vh;">
- <div class="clearfix rightitlebox">
- <div class="left departnum">
- <div class="layui-inline">
- <div class="layui-input-inline" style="width: auto;">
- <input type="text" name="keyword" id="keyword" placeholder="请输入关键字搜索" autocomplete="off" class="layui-input keyword">
- </div>
- </div>
- <div class="layui-inline" id="right_search">
- <button class="layui-btn layuiadmin-btn keyword" lay-submit lay-filter="LAY-app-contlist-search">
- <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
- </button>
- </div>
- </div>
- <div class="right" style="cursor: pointer;">
- <!-- 取消选择 -->
- <button class="layui-btn layuiadmin-btn layui-btn-primary keywords" style="display: flex;align-items: center;" id="all_del">取消选择</button>
- </div>
- </div>
- <div class="nowdepartbox">
- <table id="LAY-employee-list" lay-filter="LAY-employee-list" style="margin-top:15px;"></table>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div style="overflow: hidden; border-bottom: 1px dashed #ccc;padding-bottom: 15px;">
- <div class="layui-inline flex" style="float: left;">
- <div class="layui-border-left">最迟完成日期</div>
- <div class="layui-input-inline plr20">
- <input type="text" name="keyword" placeholder="请选择日期" autocomplete="off" class="layui-input" id="save_date">
- </div>
- </div>
- <div class="plr20" style="float: left;">
- <!-- 取消选择 -->
- <button class="layui-btn layuiadmin-btn" style="display: flex;align-items: center;" id="all_save"> 保存 </button>
- </div>
- </div>
- <div class="plr20 mt10">
- <div class="layui-border-left ">设置记录({$count}条)</div>
- </div>
- <div class="plr20" style="overflow:auto;max-height:150px;padding-bottom: 20px;">
- {volist name="data" id="t"}
- <div class="plr20 relative del{$t.id}">
- <div class="circle"></div>
- <div class="line"></div>
- <span>{$t.addtime} 设置{$t.count}个部门于{$t.end_date}之前完成</span>
- {if condition="$t.del eq 1"}
- <span data-id="{$t.id}">任务已取消</span>
- {elseif condition="$t.edit eq 1"/}
- <span>任务过期无法取消</span>
- {else /}
- <span data-id="{$t.id}" class="del_task delcolor" id="del{$t.id}">取消任务</span>
- {/if}
- </div>
- {/volist}
- </div>
- <script src="__STATIC__/layui/layui/layui.js"></script>
- <script src="__STATIC__/layui/layui/lay/modules/xm-select.js" type="text/javascript" charset="utf-8"></script>
- <script type="text/html" id="operateTpls">
- {{# if(d.is_manager){ }}
-
- <p class="strucinfo" data-leader="{{d.is_manager}}"><span>{{d.org_name}}</span><span class="leader" lay-event="removeleader"><img src="__STATIC__/img/managericon.png" style="width:80%" alt="" /></span></p>
- {{# }else{ }}
- <p class="strucinfo" data-leader="{{d.is_manager}}"><span>{{d.org_name}}</span><span class="setleader employee" lay-event="setleader"><i class="layui-icon layui-icon-friends"></i><img class="layui-hide" src="__STATIC__/img/managericon.png" style="width:80%" alt="" /></span></span></p>
- {{# } }}
- </script>
- <script type="text/html" id="operateTpl">
- <a class="layui-btn layui-btn-info layui-btn-xs" lay-event="edit">取消选择</a>
- </script>
- {/block} {block name="js"}
- <script>
- layui.config({
- base: '__LAYUI__/',
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'jquery', 'table', 'tree', 'layer','element','form','laydate'], function() {
- var table = layui.table,
- tree = layui.tree,
- layer = layui.layer,
- $ = layui.jquery,
- element = layui.element,
- laydate = layui.laydate,
- form = layui.form;
- var time = Date.parse(new Date())/1000;
- //点击选择人员
- $(document).on('click','.leftcontentbox li',function(e){
- if (e.target.localName === 'i') {
- let o = $(this).next();
- if (o && o[0] && o[0].localName === 'ul') {
- if (!o[0].style.display || o[0].style.display == 'block') {
- o[0].style.display = 'none';
- e.target.className = "group layui-icon layui-icon-triangle-r"
- } else {
- o[0].style.display = 'block';
- e.target.className = "group layui-icon layui-icon-triangle-d"
- }
- }
- }
- if (!(e.target.localName == 'input')) {
- return;
- }
- //唯一class
- var perclass = $(this).data('perclass');
- //类型 per员工 org部门
- var type = $(this).data('type');
- //选中/取消
- var c = $('.'+perclass).prop("checked");
- var res = c==true ? 1 : 0;
- //id
- var id = $(this).data('id');
-
- if (id>0) {
- var index = layer.load(1); //添加laoding,0-2两种方式
- $.ajax({
- url: '{:url("dailyTasks/assign_org_edit")}?id='+"{$id}"+"&cate={$type}&time="+time,
- data: {
- select_id:id,type:type,res:res
- },
- type: 'get',
- success: function(res) {
- // $('.departnum').html("已选中"+res.count+"人");
- if (res.code==0) {
- for (var i = res.data.length - 1; i >= 0; i--) {
- $('.per_org_'+res.data[i]).prop("checked",c);
- }
- table.reload('LAY-employee-list', {});
- layer.close(index);
- }
- },
- error:function(res){
- layer.close(index);
- }
- });
- }
- })
- //右侧搜索按钮
- $('#right_search').click(function(){
- var keyword = $('#keyword').val();
- table.reload('LAY-employee-list', {
- where: {
- keyword: keyword
- }
- , page: { curr: 1 }
- });
- });
- //左侧搜索
- $('#left_search').click(function(){
- var keyword = $('#keyword_left_text').val();
- operate.struct(keyword);
- });
- //取消全部
- $('#all_del').click(function(){
- operate.edit(-1);
- });
- //右侧选中人员列表
- var orgstrucUrl = '{:url("dailyTasks/get_orgs")}?id='+"{$id}"+"&cate={$type}&time="+time;
- table.render({
- elem: '#LAY-employee-list',
- url: orgstrucUrl,
- cols: [
- [
- /* {
- title: '序号',
- field: 'id',
- width: '25%',
- align:'center',
- },*/
- {
- title: '部门名称',
- field: 'name',
- width: '33%',
- align:'center',
- },{
- field: 'employee_count',
- title: '部门人员数量',
- width: '33%',
- // templet: '#operateTpls',
- align:'center',
- },
- {
- title: '操作',
- templet: '#operateTpl',
- width: '34%',
- align:'center',
- fixed: 'right'
- }]
- ],
- page: true,
- limit: 10,
- height: 'full-125',
- limits: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
- text: '对不起,加载出现异常!'
- });
- table.on('tool(LAY-employee-list)', function (obj) {
- var data = obj.data;
- if (obj.event === 'edit') {
- operate.edit(data.id);
- }
- });
- var operate = {
- struct: function(keyword) {
- // return false;
- var that = this;
- that.send({'keyword':keyword}, '{:url("dailyTasks/get_person")}?id='+33, function(res) {
- // that.send([], '{:url("train/class_assigns")}', function(res) {
- if(res.code == 0) {
- $('.list').html(that.setStruct(res.data,res.checkOrg));
- } else {
- $('.list').html('<span>' + res.msg + '</span>');
- }
- $('.everydepart .checkdiv').click(function(e) {
- var type = $(this).parents('li').data('type');
- var perclass = $(this).parents('li').data('perclass');
- var orgclass = $(this).parents('li').data('orgclass');
- var c = $('.'+perclass).prop("checked");
- if (type=='per') {
- $('.'+perclass).prop('checked',c);
- if (c===false) {
- // console.log(orgclass);
- $('.per_'+orgclass).prop('checked',false);
- }
- }else{
- $('.'+orgclass).prop('checked',c);
- }
- // e.stopPropagation();
- })
- });
- },
- send: function(data, url, callback) {
- if(data.length == 0) {
- return $.ajax({
- type: 'get',
- url: url,
- data: {},
- 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 + '" data-type='+elem.type+' data-perclass='+elem.per_class+' data-orgclass='+elem.org_class+'><div class="everydepart">';
- if(elem.children.length !== 0)
- html += '<i class="group layui-icon layui-icon-triangle-d"></i>';
- else
- html += '<i class="layui-icon layui-icon-user"></i>';
- html += '<span>' + elem.title + '</span>';
-
- for(var i in arr){
- if(arr[i]==elem.id){
- html += '<input data-did="' + elem.id + '" data-title="' + elem.title + '" data-class='+elem.class+' class="checkdiv '+elem.org_class+' '+elem.per_class+'" data-type="'+elem.type+'" type="checkbox" checked/></div>';
- flag=true;
- }
- }
-
- if(!flag){
- html += '<input data-did="' + elem.id + '" data-title="' + elem.title + '" data-class='+elem.class+' class="checkdiv '+elem.org_class+' '+elem.per_class+'" id="'+elem.class+'" data-type="'+elem.type+'" type="checkbox" /></div>';
- }
- html += '</li>';
- if(elem.children.length > 0) {
- html += that.setStruct(elem.children,checkOrg);
- }
- });
- html += '</ul>';
- return html
- },
- edit:function(eid){
- layer.confirm('确定取消指派此员工?', { title: ['信息', 'color:#333333;background-color:#D8E6F1;'] }, function (index) {
- $.ajax({
- url: '{:url("dailyTasks/del_assign")}?id='+"{$id}"+"&cate={$type}&time="+time,
- data: {
- eid: eid
- },
- type: 'post',
- success: function (res) {
- if (eid == -1) {
- $('input').prop('checked',false);
- } else {
- $(`.per_org_${eid}`).prop('checked',false);
- }
- if (res.code === 0) {
- layer.msg(res.msg, { anim: 0 });
- } else {
- layer.msg(res.msg, { anim: 6 });
- }
- var keywordcs = $('#keyword').val();
- table.reload('LAY-employee-list', {
- where: {
- keyword: keywordcs
- }
- , page: { curr: 1 }
- });
- }
- });
- });
- },
- del_task:function(id){
- $.ajax({
- url: '{:url("dailyTasks/del_task")}?id='+"{$id}"+"&cate={$type}&time="+time,
- type: 'post',
- data: {eid:id},
- dataType: 'json',
- success: function(res) {
- if(res.code === 0) {
- $('#del'+id).attr('disabled',true);
- $('#del'+id).html('任务已取消');
- $('#del'+id).removeClass('delcolor');
- layer.msg(res.msg, {
- anim: 0
- ,time: 2000
- }, function() {
- // parent.layui.table.reload('company-activity'); //重载表格
- // parent.layer.close(index); //再执行关闭
- });
- } else {
- layer.msg(res.msg, {
- anim: 6
- ,time: 2000
- });
- }
- }
- });
- }
- }
- // 结构初始化
- 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');
- }
- })
- //保存完成时间
- laydate.render({
- elem: '#save_date',
- type: "date",
- trigger: 'click'
- });
- //保存最后完成日期
- $('#all_save').click(function(){
- var date = $('#save_date').val();
- if (date=='') {
- layer.msg('请选择最迟完成日期', {
- anim: 6
- ,time: 2000
- });
- return false;
- }
- $.ajax({
- url: '{:url("dailyTasks/save_date")}?id='+"{$id}"+"&cate={$type}&time="+time,
- type: 'post',
- data: {date:date},
- dataType: 'json',
- success: function(res) {
- if(res.code === 0) {
- layer.msg(res.msg, {
- anim: 0
- ,time: 2000
- }, function() {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- });
- } else {
- layer.msg(res.msg, {
- anim: 6
- ,time: 2000
- });
- }
- }
- });
- });
- //取消任务
- $('.del_task').click(function(){
- var id = $(this).data('id');
- operate.del_task(id);
- })
- });
- </script>
- </body>
- {/block}
|