var pageCurr; var admin; var treeCond; layui.config({ base: baseUrl + "/static/layui/lay/modules/" }).extend({ steps: 'steps/steps', cascader: 'cascader/cascader', }).use(['table','laydate', 'form', 'admin', 'xmSelect', 'element', 'cascader', 'tree', 'dropdown'], function(){ var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var layDate = layui.laydate; var tree = layui.tree; var form = layui.form; var dropdown = layui.dropdown; admin = layui.admin; $('#organization').html(localStorage.getItem('nickname') + ' '); // 部门人员 筛选 dropdown.render({ elem: '#organization' ,content: ['
'].join('') ,style: 'width: 370px; height: 350px; padding: 0 15px; box-shadow: 1px 1px 30px rgb(0 0 0 / 12%);' ,ready: function(){ loadTree(); } }); // 树形图 var organizationTree; window.loadTree = function(condition){ var loadIndex = layer.load(2); $.ajax({ url: baseUrl+"/dept/user/tree/auth", headers: {'token': localStorage.getItem('token')}, data: { 'condition': condition }, method: 'POST', success: function (res) { layer.close(loadIndex); if (res.code === 200){ organizationTree = tree.render({ elem: '#organizationTree', id: 'organizationTree', onlyIconControl: true, data: res.data, click: function (obj) { treeCond = { key: obj.data.key, val: obj.data.id } $('#organization').html(obj.data.title + ' '); $('#organizationTree').find('.ew-tree-click').removeClass('ew-tree-click'); $(obj.elem).children('.layui-tree-entry').addClass('ew-tree-click'); clearFormVal($('#search-box')); tableIns.reload({ where: {[obj.data.key]: obj.data.id}, page: {curr: 1} }); } }); treeData = res.data; } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(res.msg) } } }) } // 数据渲染 tableIns = table.render({ elem: '#weekly', headers: {token: localStorage.getItem('token')}, url: baseUrl+'/weekly/list/auth', page: true, limit: 16, limits: [16, 30, 50, 100, 200, 500], toolbar: '#toolbar', cellMinWidth: 150, cols: [[ // {type: 'checkbox'}, {field: 'id', align: 'center',title: 'ID',hide : true} ,{field: 'startTime$', align: 'center',title: '开始日期',hide : true} ,{field: 'endTime$', align: 'center',title: '结束日期',hide : true} ,{field: 'userId$', align: 'center',title: '所属人员',hide : true} ,{field: 'hostId$', align: 'center',title: '所属商户',hide : true} ,{field: 'deptId$', align: 'center',title: '所属部门',hide : true} ,{field: 'cstmrIdsReality', align: 'center',title: '实际甲方单位ID集合',hide : true} ,{field: 'status$', align: 'center',title: '状态',hide : false} ,{field: 'settle$', align: 'center',title: '进度',hide : false} ,{field: 'settleMsg', align: 'center',title: '审核进度',hide : true} ,{field: 'comment', align: 'center',title: '评论',hide : false} ,{field: 'createBy$', align: 'center',title: '添加人员',hide : true} ,{field: 'createTime$', align: 'center',title: '添加时间',hide : true} ,{field: 'updateBy$', align: 'center',title: '修改人员',hide : true} ,{field: 'updateTime$', align: 'center',title: 'update_time',hide : true} ,{field: 'memo', align: 'center',title: '备注(50字)',hide : false} ,{field: 'director$', align: 'center',title: '审批人',hide : true} ,{field: 'settleSize', align: 'center',title: '流程长度',hide : true} ,{field: 'settleCurrent', align: 'center',title: '当前进度',hide : true} ,{field: 'cstmrIdsPlan', align: 'center',title: '计划甲方单位ID集合',hide : true} ,{field: 'weeklyAll', align: 'center',title: '周数',hide : false} ,{field: 'weeklyNowMonth', align: 'center',title: '当月第几周',hide : true} ,{field: 'weeklyYear', align: 'center',title: '年',hide : true} ,{field: 'weeklyMonth', align: 'center',title: '月',hide : true} ,{field: 'weeklyDay', align: 'center',title: '日',hide : true} ,{field: 'weeklyDayMonth', align: 'center',title: '周',hide : true} ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} ]], request: { pageName: 'curr', pageSize: 'limit' }, parseData: function (res) { return { 'code': res.code, 'msg': res.msg, 'count': res.data.total, 'data': res.data.records } }, response: { statusCode: 200 }, done: function(res, curr, count) { if (res.code === 403) { top.location.href = baseUrl+"/"; } pageCurr=curr; limit(); } }); // 监听排序事件 table.on('sort(weekly)', function (obj) { var searchData = {}; $.each($('#search-box [name]').serializeArray(), function() { searchData[this.name] = this.value; }); searchData['orderByField'] = obj.field; searchData['orderByType'] = obj.type; tableIns.reload({ where: searchData, page: { curr: 1 }, done: function (res, curr, count) { if (res.code === 403) { top.location.href = baseUrl+"/"; } pageCurr=curr; limit(); } }); }); // 监听头工具栏事件 table.on('toolbar(weekly)', function (obj) { var checkStatus = table.checkStatus(obj.config.id); switch(obj.event) { case 'addBlank': showEditModel(); break; case 'refreshData': tableIns.reload({ page: { curr: pageCurr } }); limit(); break; case 'deleteData': var data = checkStatus.data; var ids=[]; data.map(function (track) { ids.push(track.id); }); if (ids.length === 0){ layer.msg('请选择数据'); } else { layer.confirm('确定删除'+(ids.length===1?'此':ids.length)+'条数据吗', function(){ $.ajax({ url: baseUrl+"/weekly/delete/auth", headers: {'token': localStorage.getItem('token')}, data: {ids: ids}, method: 'POST', traditional:true, success: function (res) { if (res.code === 200){ layer.closeAll(); tableReload(false); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(res.msg) } } }) }); } break; case 'exportData': layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ var titles=[]; var fields=[]; obj.config.cols[0].map(function (col) { if (col.type === 'normal' && col.hide === false && col.toolbar == null) { titles.push(col.title); fields.push(col.field); } }); var exportData = {}; $.each($('#search-box [name]').serializeArray(), function() { exportData[this.name] = this.value; }); var param = { 'config': exportData, 'fields': fields }; $.ajax({ url: baseUrl+"/weekly/export/auth", headers: {'token': localStorage.getItem('token')}, data: JSON.stringify(param), dataType:'json', contentType:'application/json;charset=UTF-8', method: 'POST', success: function (res) { layer.closeAll(); if (res.code === 200) { table.exportFile(titles,res.data,'xls'); } else if (res.code === 403) { top.location.href = baseUrl+"/"; } else { layer.msg(res.msg) } } }); }); break; } }); // 监听行工具事件 table.on('tool(weekly)', function(obj){ var data = obj.data; switch (obj.event) { case 'approval2': layer.confirm('审批通过?', { skin: 'layui-layer-admin', shade: .1, offset: '200px', title: data.name }, function (i) { layer.close(i); approval2(data.id); }); break; case 'more': top.weeklyByMore=data.id; console.log(top.weeklyByMore) admin.popupRight({ type: 1, window: "top", area: "1250px", url: "weekly_more.html", end: function () { // $(".layui-laypage-btn")[0].click(); } }) break; case 'del': layer.confirm('确定删除这条数据吗', function(){ $.ajax({ url: baseUrl+"/weekly/delete/auth", headers: {'token': localStorage.getItem('token')}, data: {ids: data.id}, method: 'POST', traditional:true, success: function (res) { if (res.code === 200){ layer.closeAll(); tableReload(false); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(res.msg) } } }) }); break; case "edit": showEditModel(data); break; case "look": var $a = $(obj.tr).find('a[lay-event="look"]'); var offset = $a.offset(); var top2 = offset.top; var left = offset.left; layer.open({ type: 1, title: false, area: '2100px', offset: [top2 + 'px', (left - 1430 + $a.outerWidth()) + 'px'], shade: .01, shadeClose: true, fixed: false, content: '