123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197 |
- {extend name="public/layout" /} {block name="title"}分配{/block} {block name="body"}
- <link rel="stylesheet" href="__STATIC__/css/csspc.css">
- <link rel="stylesheet" href="__STATIC__/css/font.css">
- <link rel="stylesheet" " href=" __STATIC__/css/common.css">
- <style>
- html,body{
- background: #f5f5f5;
- font-size: 12px;
- padding-bottom: 20px;
- box-sizing: border-box;
- min-width:1200px;
- overflow-x: auto;
- }
- .toptitbox{
- display: block;
- width:1200px;
- padding: 15px 10px;
- border: 1px solid #F0F0F0;
- background: #FCFCFC;
- margin-bottom: 10px;
- position: relative;
- line-height: 28px;
- }
- .golastbtn{
- display: block;
- margin-right: 21px;
- color: #000;
- background: url(__STATIC__/img/btn_bg.gif) repeat-x;
- border: 1px solid #C0C0C0;
- padding: 0 12px;
- *padding: 0 6px;
- height: 28px;
- cursor: pointer;
- }
- .mainbox{
- display: block;
- width:1200px;
- height:100%;
- padding-top: 20px;
- margin: 0 auto;
- }
- .bodys{
- padding: 10px 0;
- 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;
- padding-left: 24px;
- }
- .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 - 320px);
- }
- .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;
- }
- .dapartbox li {
- width: 50%;
- padding: 0;
- }
- .layui-table td, .layui-table th{width:25%;}
- .layui-table-body{
- height: auto !important;
- overflow: initial;
- }
- </style>
- <body>
- <div class="mainbox">
- <div class="clearfix toptitbox">
- <div class="left">您当前的操作 · <b>客户资源分配</b></div>
- <div class="right">
- <div class="left">点击这里返回列表:</div>
- <button class="left golastbtn" type="button">返回列表</button>
- </div>
- </div>
- <div class="bodys wpsr">
- <div class="layui-fluid">
- <div class="layui-card clearfix">
-
- <div class="layui-col-md5 layui-col-xs5 layui-col-sm5 leftcontentbox">
- <div class="layui-zz-box">
-
- <div class="layui-inline" style="display:block;">
- <div class="layui-tab layui-tab-card" lay-filter="maintenanceOrder">
- <ul class="layui-tab-title dapartbox">
- <li class="lay-dapart layui-this">选择分配到部门</li>
- <li class="lay-person">选择分配到人</li>
- </ul>
- <div class="layui-tab-content">
- <div class="layui-tab-item layui-show lay-dapartbox">
- <div class="list" id="range_person" style="overflow: auto;"></div>
- </div>
- <div class="layui-tab-item lay-personbox" style="height: calc(100vh - 320px);overflow: auto;">
- <div class="departnum">
- <div class="layui-inline layui-form" style="width: 35%;">
- <select name="type" lay-filter="type" id="type">
- <option value=1>按部门搜索</option>
- <option value=2>按人员搜索</option>
- </select>
- </div>
- <div class="layui-inline" style="width: 43%;">
- <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>
- <table class="customer_table" id="customer_table" lay-filter="customer_table">
- </table>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
-
- <div class="layui-col-md5 layui-col-xs5 layui-col-sm5 showdepartbox" style="overflow: auto;height: calc(100vh - 255px);">
- <div class="clearfix rightitlebox">
- <span>可分配资源:<a class="count_a" style="font-weight: bold;color:#249EFB">{$count}</a></span>
- <!-- <span>已分配:0</span>
- <span>未分配:0</span> -->
- </div>
- <div class="nowdepartbox">
- <table class="layui-table">
- <colgroup>
- <col width="150">
- <col width="200">
- <col>
- </colgroup>
- <thead>
- <tr>
- <th>部门名称</th>
- <th>分配资源数量</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody id="nowdepartbox">
- </tbody>
- </table>
- </div>
- <div class="nowdepartbox1 layui-hide">
- <table class="layui-table">
- <colgroup>
- <col width="150">
- <col width="200">
- <col>
- </colgroup>
- <thead>
- <tr>
- <th>姓名</th>
- <th>部门名称</th>
- <th>分配资源数量</th>
- <th>操作</th>
- </tr>
- </thead>
- <tbody id="nowdepartbox1">
- </tbody>
- </table>
- </div>
- </div>`
- </div>
- </div>
- <div class="plr20 mt10">
- <button class="layui-btn layuiadmin-btn" style="display: flex;align-items: center;" id="all_save"> 确定分配
- </button>
- </div>
- </div>
- </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>
- {/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,
- tableData = [],
- tableData0 = [],
- customertable = [],
- customer_id = "{$customer_id}";
- var notlist = 1;
- var notlist1 = 1;
- var htmlright = [];
- var cunts = 0;
- var time = Date.parse(new Date()) / 1000;
- $('.golastbtn').click(function () {
- if(!customer_id){
- window.parent.backresourcefun(window.location.search.split('?')[1], '{:url("manager_emp/distribution")}', 'distribution');
- }else{
- window.parent.backresourcefun1(window.location.search.split('?')[1], '{:url("manager_emp/distribution")}', 'distribution');
- }
-
- })
- //点击选择人员
- $(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');
- var count_a1 = parseInt('{$count}');
- var htmlcount2=0;
- if (id > 0) {
-
- $.ajax({
- url: '{:url("manager_emp/get_child_orgs")}?id=' + id,
- data: {},
- type: 'get',
- success: function (res) {
- if (res.code == 0) {
- for (var i = res.data.length - 1; i >= 0; i--) {
- $('.per_org_' + res.data[i]).prop("checked", c);
- var delcount = 0;
- if (c == false) {
- $('#delorg' + res.data[i]).remove();
- ckboxs();
- }
- }
-
- if (c == true) {
- var html = '';
- for (var i = res.param.length - 1; i >= 0; i--) {
- if ($('#delorg' + res.param[i].id).length > 0) {
- //已存在
- } else {
- html += '<tr data-id=' + res.param[i].id + ' id=delorg' + res.param[i].id + '>';
- html += '<td>' + res.param[i].name + '</td>';
- html += '<td><input data-id=' + res.param[i].id + ' type="text" name="title" data-index="" value="" required lay-verify="required" placeholder="请输入正整数" autocomplete="off" class="layui-input inputText01 inputText"></td>';
- html += '<td data-id=' + res.param[i].id + ' class="strucinfo">删除</td>';
- html += '</tr>';
- }
- }
- $('#nowdepartbox').append(html);
-
- ckboxs();
-
-
-
- $(".inputText01").keyup(function(){
- $(this).val($(this).val().replace(/\D|^0/g,''));
- }).bind("paste",function(){
- return false;
- })
-
- setInterval(()=>{
- $(".inputText01").off('input').on('input',function(){
- var countleft =0;
- var aaa = 0;
- for(var i=0;i<$('#nowdepartbox tr').length;i++){
- countleft = $($('#nowdepartbox input')[i]).off('input').val();
- if(countleft==''||countleft==0){
- countleft = 0;
- }else{
- countleft=parseInt(countleft);
- aaa += countleft;
- }
- }
- if(aaa==0){
- notlist = 0
- }else{
- notlist = 1
- }
-
- if(aaa>count_a1){
- var inputval2;
- inputval2=$(this).val().slice(0,-1);
- $(this).val(inputval2);
- layer.msg('分配资源不能大于可分配资源');
- return false;
- }else{
- htmlcount2=count_a1-aaa;
- $('.count_a').html(htmlcount2);
- }
-
- })
- })
-
-
- for (let i = 0; i < $('#nowdepartbox .strucinfo').length; i++) {
- $($('#nowdepartbox .strucinfo')[i]).off('click').on('click', function (e) {
- let id = e.currentTarget.dataset.id;
- $('.per_org_' + id).prop("checked", false);
- $('#delorg' + id).remove();
- ckboxs();
- })
- }
- }
-
- function ckboxs(){
- var lengthlist=$('#nowdepartbox tr').length;
- var nocounts = count_a1- (count_a1%lengthlist);
- var li_list = nocounts/lengthlist;
- var inputval=0;
- var countcon=0;
- for(let i = 0; i < lengthlist; i++){
- if(lengthlist>count_a1){
- cunts=0;
- $($('#nowdepartbox input')[i]).off('input').val(i<count_a1?1:'')
- if(i<count_a1-1){
- htmlcount2 = count_a1-i;
- $('.count_a').html(htmlcount2);
- }
- }else{
- $($('#nowdepartbox input')[i]).off('input').val(li_list);
- }
- inputval = $($('#nowdepartbox tr')[i]).find('input').val();
- if(inputval==''||inputval==0){
- inputval = 0;
- }else{
- countcon+=parseInt(inputval);
- }
- }
- htmlcount2=count_a1-countcon;
- $('.count_a').html(htmlcount2);
- }
- //右侧表格处理
- // var selectData = res.param;
- // tableData0 = selectData.map(v => {
- // let item = tableData0.filter(o => (v.id == o.id && o.value));
- // if (item.length) {
- // return {...v,value: item[0].value};
- // } else {
- // return {...v,value: ''};
- // }
- // })
- // var html = '';
- // tableData0.forEach( function(item,index){
- // // console.log(item.id + '---' + item.name)
- // html += '<tr data-id='+item.id+' id=delorg'+item.id+'>';
- // html += '<td>'+item.name+'</td>';
- // html += `<td><input type="text" name="title" data-index="${index}" value="${item.value}" required lay-verify="required" placeholder="请输入正整数" autocomplete="off" class="layui-input inputText"></td>`;
- // html += '<td>删除</td>';
- // html += '</tr>';
- // // checked.push(item.id);
- // })
- // $('#nowdepartbox').html(html);
- // setTimeout(() => {
- // $('.inputText').on('change',function(e){
- // let index = parseInt($(this).prop('dataset').index);
- // tableData0[index].value = $(this).val();
- // })
- // })
- }else if(res.code == 403){
- $(".exitbtn").trigger("click");
- }
- },
- error: function (res) {
- }
- });
- }
- })
- //右侧搜索按钮
- $('#right_search').click(function () {
- var keyword = $('#keyword').val();
- var type = $('#type').val();
- var ids = [];
- htmlright = [];
- htmlright = htmlright.concat(tableData);
- for(var i=0;i<htmlright.length;i++){
- ids.push(htmlright[i].id)
- }
- function noRepeat1(arr) {
- for(var i = 0; i < arr.length-1; i++){
- for(var j = i+1; j < arr.length; j++){
- if(arr[i]===arr[j]){
- arr.splice(j,1);
- j--;
- }
- }
- }
- return arr;
- }
- var arrinfo=noRepeat1(ids);
- table.reload('customer_table', {
- where: {
- keyword: keyword,
- type: type,
- ids:arrinfo.toString()
- }
- , page: false,
- done: function (res) {
- console.log(res)
- for(var i=0;i<res.data.length;i++){
- if(res.data[i]['checked']==true){
- var index= res.data[i]['LAY_TABLE_INDEX'];
- $('tr[data-index=' + index + '] input[type="checkbox"]').prop('checked', true);
- $('tr[data-index=' + index + '] input[type="checkbox"]').next().addClass('layui-form-checked');
- }
- }
- onform();
- }
- });
-
- });
- 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("manager_emp/get_orgs",array("pid"=>$pid))}', function (res) {
- if (res.code == 0) {
- if(res.data.length==0){
- param_type=1
- $('.lay-dapart').hide();
- $('.lay-dapartbox').removeClass('layui-show');
- $('.lay-dapartbox').hide();
- $('.dapartbox li').css('width','100%')
- $('.lay-person').addClass('layui-this');
- $('.lay-personbox').addClass('layui-show');
- $('.nowdepartbox').addClass('layui-hide');
- $('.nowdepartbox1').removeClass('layui-hide');
- var tableheader = [ //表头
- { field: 'name', title: '姓名', templet: '#nameTpl', minWidth: 150 }
- , { field: 'org_name', title: '部门', minWidth: 150, templet: '#phone' }
- , { type: 'checkbox', minWidth: 40 }
- ];
- table.render({
- elem: '#customer_table'
- , url: '{:url("manager_emp/get_persons")}' //数据接口
- , id: 'customer_table'
- , page: false //开启分页
- , autoSort: false
- , cols: [tableheader]
- , height: 'full-120',
- page: false,
- limit: 10000,
- done: function (res) {
- customertable = res.data;
- }
- });
- }else{
- param_type=0;
- $('.lay-dapart').show();
- $('.lay-dapartbox').show();
- $('.dapartbox li').css('width', '50%')
-
- $('.lay-person').removeClass('layui-this');
- $('.lay-personbox').removeClass('layui-show');
- $('.lay-dapart').addClass('layui-this');
- $('.lay-dapartbox ').addClass('layui-show');
- $('.nowdepartbox').removeClass('layui-hide');
- $('.nowdepartbox1').addClass('layui-hide');
- $('.list').html(that.setStruct(res.data, res.checkOrg));
- }
-
- } else {
- $('.list').html('<span>' + res.msg + '</span>');
- }
- });
- },
- send: function (data, url, callback) {
- if (data.length == 0) {
- return $.ajax({
- type: 'get',
- url: url,
- data: {},
- success: function (res) {
- if(res.code == 403){
- $(".exitbtn").trigger("click");
- }
- callback(res)
- }
- })
- }
- return $.ajax({
- type: 'post',
- url: url,
- data: data,
- success: function (res) {
- if(res.code == 403){
- $(".exitbtn").trigger("click");
- }
- 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
- }
- }
- // 结构初始化
- operate.struct();
- //监听 分配类型切换
- var is = false;
- var param_type = 0;//点击分配时要提交的参数
- element.on('tab(maintenanceOrder)', function (data) {
- var type = data.index;
- if (type == 1 && is == false) {
- var tableheader = [ //表头
- { field: 'name', title: '姓名', templet: '#nameTpl', minWidth: 150 }
- , { field: 'org_name', title: '部门', minWidth: 150, templet: '#phone' }
- , { type: 'checkbox', minWidth: 40 }
- ];
- table.render({
- elem: '#customer_table'
- , url: '{:url("manager_emp/get_persons")}' //数据接口
- , id: 'customer_table'
- , page: false //开启分页
- , autoSort: false
- , cols: [tableheader]
- , height: 'full-120',
- page: false,
- limit: 10000,
- done: function (res) {
- customertable = res.data;
- }
- });
- is = true;
- }
- //改变右侧
- if (type == 0) {
- $('.nowdepartbox').show();
- $('.nowdepartbox1').hide();
- } else if (type == 1) {
- $('.nowdepartbox').hide();
- $('.nowdepartbox1').show();
- $('.nowdepartbox1').removeClass('layui-hide');
- }
- param_type = type;
- //
- });
- //监听分配到人员列表的表格
- var checked = [];
- onform();
- var counts = '{$count}';
- var htmlcount = 0;
- function onform(){
- table.on('checkbox(customer_table)', function (obj) {
- //选中的数据
- var selectData = layui.table.checkStatus('customer_table').data;
- var isb=0;
- if(counts>selectData.length){
- isb=1;
- var nocounts = counts- (counts%selectData.length);
- var li_list = nocounts/selectData.length;
- if(selectData.length>0){
- htmlcount = counts-(li_list*(selectData.length))
- $('.count_a').html(htmlcount);
- }else{
- htmlcount = counts
- $('.count_a').html(htmlcount);
- }
- }else if(counts==selectData.length){
- isb=0;
- htmlcount = counts-selectData.length;
- $('.count_a').html(htmlcount);
- }else{
- isb=0;
- }
-
-
- tableData = selectData.map((v,i) => {
- let item = tableData.filter(o => (v.id == o.id));
- if(isb==1){
- if (item.length) {
- // return { ...v, value: item[0].value };
- return { ...v, value: li_list};
- } else {
- return { ...v, value: li_list};
- }
- }else{
- counts = parseInt(counts);
- if(selectData.length<counts){
- htmlcount = counts-i;
- $('.count_a').html(htmlcount);
- }else{
- htmlcount = 0;
- $('.count_a').html(htmlcount);
- }
- if (item.length) {
- // return { ...v, value: item[0].value };
- return { ...v, value: i<counts?1:''};
- } else {
- return { ...v, value: i<counts?1:''};
- }
- }
-
- })
- for(var i=0;i<htmlright.length;i++){
- if(htmlright[i].id==obj.data.id){
- htmlright.splice(i,1)
- }
- }
- tableData=htmlright.concat(tableData);
- tableData = tableData.filter((item, index, selfArr) => {
- return tableData.findIndex((x) => x.id === item.id) === index;
- });
- if (checked.length == 0) {
- var html = '';
- tableData.forEach(function (item, index) {
- html += '<tr data-id=' + item.id + ' id=del' + item.id + '>';
- html += '<td>' + item.name + '</td>';
- html += '<td>' + item.org_name + '</td>';
- html += `<td><input type="text" name="title" data-index="${index}" value="${item.value}" required lay-verify="required" placeholder="请输入正整数" autocomplete="off" class="layui-input inputText"></td>`;
- html += '<td data-id=' + item.id + ' class="strucinfo">删除</td>';
- html += '</tr>';
- })
- $('#nowdepartbox1').html(html);
- setTimeout(() => {
- $('.inputText').on('change', function (e) {
- let index = parseInt($(this).prop('dataset').index);
- tableData[index].value = $(this).val();
- })
- })
- $(".inputText").keyup(function(){
- $(this).val($(this).val().replace(/\D|^0/g,''));
- }).bind("paste",function(){
- return false;
- })
-
- $('.inputText').off('input').on('input', function (obj) {
- forlist($(this));
- })
- function forlist(_this){
- var countcon=0;
- var inputval = 0;
- for (let i = 0; i < $('#nowdepartbox1 tr').length; i++) {
- inputval = $($('#nowdepartbox1 tr')[i]).find('input').val();
- inputval = inputval.replace(/\D/g,'');
- if(inputval==''||inputval==0){
- inputval = 0;
- }else{
- countcon+=parseInt(inputval);
- }
-
- }
- if(countcon==0){
- notlist1 = 0;
- }else{
- notlist1 = 1;
- }
- if(countcon>counts){
- let index = parseInt(_this.prop('dataset').index);
- var inputval2;
- if(index==$('#nowdepartbox1 tr').length-1){
- inputval2 = _this.val().slice(0,-1);
- }
- tableData[index].value = _this.val(inputval2);
- layer.msg('分配资源不能大于可分配资源');
- return false;
- }else{
- htmlcount=counts-countcon;
- $('.count_a').html(htmlcount);
- }
-
- }
- for (let i = 0; i < $('#nowdepartbox1 .strucinfo').length; i++) {
- $($('#nowdepartbox1 .strucinfo')[i]).off('click').on('click', function (e) {
- let id = e.currentTarget.dataset.id;
- customertable.forEach(function (itm, idx) {
- if (id == itm.id) {
- let j = idx;
- let td = $("tr[data-index='" + j + "'] .layui-form-checkbox");
- for (let i = 0; i < td.length; i++) {
- let arr = td[i].className.split(' ');
- if (arr[arr.length - 1] == 'layui-form-checked') {
- td[i].click();
- }
- }
- }
-
- })
- for(var i=0;i<htmlright.length;i++){
- if(htmlright.length>0){
- if(htmlright[i].id==id){
- htmlright.splice(i,1)
- }
- }else{
- htmlright=[];
- tableData=[];
- }
- }
- $('#del' + id).remove();
- })
- }
- }
- });
- }
- //点击确定分配
- $('#all_save').click(function () {
- data = [];
- var type = param_type;
- var resources_id = "{$id}";
- if (type == 1) {
- console.log(tableData)
- type = 'person';
- for (let i = 0; i < tableData.length; i++) {
- let item = {};
- item.con_id = tableData[i].id;
- item.count = tableData[i].value;
- data.push(item);
- }
- } else {
- type = 'org';
- let param = {};
- $("body").find(".nowdepartbox input").each(function (index, domEle) {
- param = {};
- param.con_id = $(domEle).data('id');
- param.count = $(domEle).val();
- data.push(param);
- // 回调函数第一个参数一定是索引号 可以自己指定索引号名称
- // console.log(index);
- // // 回调函数第二个参数一定是 dom元素对象
- // console.log(domEle);
- // console.log($(domEle).data('id'),$(domEle).val())
- // $(domEle).css("color",arr[index]);
- // sum += parseInt($(domEle).text());
- })
- }
- if (data.length==0) {
- layer.msg('请选择分配对象');
- return false;
- }
- if (param_type == 0 && notlist == 0) {
- layer.msg('请设置分配资源数量');
- return false;
- } else if (param_type == 1 && notlist1 == 0) {
- layer.msg('请设置分配资源数量');
- return false;
- }
- //2023-03-11 添加loading 连点数据错误
- var loadingIndex = layer.load('Loading...', {
- shade: [0.6,'#000'] //0.1透明度的白色背景
- });
- $.ajax({
- url: '{:url("manager_emp/distribution_resources")}',
- type: 'post',
- data: { type: type, content: data, resources_id: resources_id, customer_id: customer_id },
- dataType: 'json',
- success: function (res) {
- if (res.code == 0) {
- layer.msg(res.msg, {
- anim: 0
- , time: 2000
- }, function () {
- if (!customer_id) {
- window.parent.backresourcefun(window.location.search.split('?')[1], '{:url("manager_emp/distribution")}', 'distribution');
- } else {
- window.parent.backresourcefun1(window.location.search.split('?')[1], '{:url("manager_emp/distribution")}', 'distribution');
- }
- // window.parent.backresourcefun(window.location.search.split('?')[1], '{:url("manager_emp/distribution")}', 'distribution');
- // var index = parent.layer.getFrameIndex(window.name);
- // parent.layui.table.reload('pool_customer_table');
- // parent.layer.close(index);
- // window.parent.opoo();
- });
- layer.close(loadingIndex);
- }else if(res.code == 403){
- $(".exitbtn").trigger("click");
- } else {
- layer.msg(res.msg, {
- anim: 6
- , time: 2000
- }, function () {
- // var index = parent.layer.getFrameIndex(window.name);
- // parent.layui.table.reload('pool_customer_table');
- // parent.layer.close(index);
- });
- layer.close(loadingIndex);
- }
- }
- });
- });
- });
- </script>
- </body>
- {/block}
|