| | |
| | | var pageCurr; |
| | | function getCol() { |
| | | var cols = [ |
| | | {field: 'wrkNo', align: 'center',title: '工作号'} |
| | | ,{field: 'ioTime$', align: 'center',title: '工作时间', width: 160} |
| | | {field: 'wrkNo', align: 'center',title: I18n.t('work_no')} |
| | | ,{field: 'ioTime$', align: 'center',title: I18n.t('work_time'), width: 160} |
| | | ]; |
| | | cols.push.apply(cols, detlCols); |
| | | cols.push({field: 'modiUser$', align: 'center',title: '修改人员', hide:true} |
| | | ,{field: 'modiTime$', align: 'center',title: '修改时间', hide:true}) |
| | | if (typeof getDetlCols === 'function') { |
| | | cols.push.apply(cols, getDetlCols()); |
| | | } else { |
| | | cols.push.apply(cols, detlCols); |
| | | } |
| | | cols.push({field: 'modiUser$', align: 'center',title: I18n.t('modifier'), hide:true} |
| | | ,{field: 'modiTime$', align: 'center',title: I18n.t('modify_time'), hide:true}) |
| | | return cols; |
| | | } |
| | | function updatePagination() { |
| | | if (typeof I18n === 'undefined') return; |
| | | |
| | | // Update 'Total X items' |
| | | $('.layui-laypage-count').each(function() { |
| | | var text = $(this).text(); |
| | | var count = text.match(/\d+/); |
| | | if (count) { |
| | | $(this).text(I18n.t('total_prefix') + count[0] + I18n.t('total_suffix')); |
| | | } |
| | | }); |
| | | |
| | | // Update 'Go to [input] page [button]' |
| | | $('.layui-laypage-skip').each(function() { |
| | | var $this = $(this); |
| | | // Replace "到第" (First text node) |
| | | var contents = $this.contents(); |
| | | for (var i = 0; i < contents.length; i++) { |
| | | if (contents[i].nodeType === 3 && contents[i].textContent.trim() !== '') { |
| | | // Assuming the first non-empty text node is "到第" |
| | | contents[i].textContent = I18n.t('jump_to'); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | // Replace "页" (Text node after input) |
| | | var input = $this.find('.layui-input'); |
| | | if (input.length) { |
| | | var nextNode = input[0].nextSibling; |
| | | if (nextNode && nextNode.nodeType === 3) { |
| | | nextNode.textContent = I18n.t('page'); |
| | | } |
| | | } |
| | | |
| | | // Replace Button text |
| | | var btn = $this.find('.layui-laypage-btn'); |
| | | if (btn.length) { |
| | | btn.text(I18n.t('confirm')); |
| | | } |
| | | }); |
| | | |
| | | // Update 'X items/page' |
| | | $('.layui-laypage-limits select option').each(function() { |
| | | var text = $(this).text(); |
| | | var limit = text.match(/\d+/); |
| | | if (limit) { |
| | | $(this).text(limit[0] + I18n.t('items_per_page')); |
| | | } |
| | | }); |
| | | } |
| | | layui.use(['table','laydate', 'form'], function(){ |
| | | var table = layui.table; |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | |
| | | var doneCallback = function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | form.on('checkbox(tableCheckbox)', function (data) { |
| | | var _index = $(data.elem).attr('table-index')||0; |
| | | if(data.elem.checked){ |
| | | res.data[_index][data.value] = 'Y'; |
| | | }else{ |
| | | res.data[_index][data.value] = 'N'; |
| | | } |
| | | }); |
| | | if (typeof I18n !== 'undefined') { |
| | | I18n.updatePage($('.layui-table-view')); |
| | | updatePagination(); |
| | | } |
| | | }; |
| | | |
| | | $(document).on('i18n:updated', function() { |
| | | tableIns.reload({ |
| | | cols: [getCol()], |
| | | done: doneCallback |
| | | }); |
| | | }); |
| | | |
| | | // 数据渲染 |
| | | tableIns = table.render({ |
| | |
| | | response: { |
| | | statusCode: 200 |
| | | }, |
| | | done: function(res, curr, count) { |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | form.on('checkbox(tableCheckbox)', function (data) { |
| | | var _index = $(data.elem).attr('table-index')||0; |
| | | if(data.elem.checked){ |
| | | res.data[_index][data.value] = 'Y'; |
| | | }else{ |
| | | res.data[_index][data.value] = 'N'; |
| | | } |
| | | }); |
| | | } |
| | | done: doneCallback |
| | | }); |
| | | |
| | | // 监听排序事件 |
| | |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | if (typeof I18n !== 'undefined') { |
| | | I18n.updatePage($('.layui-table-view')); |
| | | updatePagination(); |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | } |
| | |
| | | case 'addData': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '新增', |
| | | title: I18n.t('add'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | |
| | | case 'deleteData': |
| | | var data = checkStatus.data; |
| | | if (data.length === 0){ |
| | | layer.msg('请选择数据'); |
| | | layer.msg(I18n.t('please_select_data')); |
| | | } else { |
| | | layer.confirm('确定删除'+(data.length===1?'此':data.length)+'条数据吗', function(){ |
| | | layer.confirm(I18n.t('confirm_delete_prefix')+(data.length===1?I18n.t('this'):data.length)+I18n.t('confirm_delete_suffix'), function(){ |
| | | $.ajax({ |
| | | url: baseUrl+"/wrkDetl/delete/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | |
| | | } |
| | | break; |
| | | case 'exportData': |
| | | layer.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | layer.confirm(I18n.t('confirm_export_excel'), {shadeClose: true, |
| | | title: typeof I18n !== 'undefined' ? I18n.t('prompt') : '提示', |
| | | btn: [typeof I18n !== 'undefined' ? I18n.t('confirm') : '确定', typeof I18n !== 'undefined' ? I18n.t('cancel') : '取消'] |
| | | }, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | |
| | | case 'detail': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '详情', |
| | | title: I18n.t('detail'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | |
| | | case 'edit': |
| | | layer.open({ |
| | | type: 2, |
| | | title: '修改', |
| | | title: I18n.t('modify'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | |
| | | case 'modiUser': |
| | | var param = top.reObject(data).modiUser; |
| | | if (param === undefined) { |
| | | layer.msg("无数据"); |
| | | layer.msg(I18n.t('no_data_found')); |
| | | } else { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '修改人员详情', |
| | | title: I18n.t('modifier_detail'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | |
| | | case 'appeUser': |
| | | var param = top.reObject(data).appeUser; |
| | | if (param === undefined) { |
| | | layer.msg("无数据"); |
| | | layer.msg(I18n.t('no_data_found')); |
| | | } else { |
| | | layer.open({ |
| | | type: 2, |
| | | title: '创建者详情', |
| | | title: I18n.t('creator_detail'), |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: false, |
| | |
| | | if (res.code === 403) { |
| | | top.location.href = baseUrl+"/"; |
| | | } |
| | | if (typeof I18n !== 'undefined') { |
| | | I18n.updatePage($('.layui-table-view')); |
| | | updatePagination(); |
| | | } |
| | | pageCurr=curr; |
| | | if (res.data.length === 0 && count !== 0) { |
| | | tableIns.reload({ |