| | |
| | | var layDate = layui.laydate; |
| | | var form = layui.form; |
| | | var admin = layui.admin; |
| | | |
| | | // 数据渲染 |
| | | var t = typeof I18n !== 'undefined' ? I18n.t : function(k) { return k; }; |
| | | var dateIns = layDate.render({ |
| | | elem: '#modi_time' |
| | | ,type: 'datetime' |
| | | ,range: true |
| | | ,lang: typeof I18n !== 'undefined' && I18n.getLanguage().toLowerCase() === 'zh-cn' ? 'cn' : 'en' |
| | | }); |
| | | tableIns = table.render({ |
| | | elem: '#area', |
| | | headers: {token: localStorage.getItem('token')}, |
| | |
| | | height: 'full-120', |
| | | cols: [[ |
| | | {type: 'checkbox'} |
| | | // ,{field: 'id', align: 'center',title: 'ID'} |
| | | // ,{field: 'tagId', align: 'center',title: ''} |
| | | ,{field: 'areaId', align: 'center',title: '库区编号'} |
| | | ,{field: 'areaName', align: 'center',title: '库区名称'} |
| | | ,{field: 'memo', align: 'center',title: '库区备注'} |
| | | // ,{field: 'backup1', align: 'center',title: '备用字段'} |
| | | // ,{field: 'backup2', align: 'center',title: '备用字段2'} |
| | | // ,{field: 'backup3', align: 'center',title: '备用字段3'} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | | ,{field: 'areaId', align: 'center',title: t('area_id')} |
| | | ,{field: 'areaName', align: 'center',title: t('area_name')} |
| | | ,{field: 'memo', align: 'center',title: t('area_memo')} |
| | | ,{fixed: 'right', title: t('operation'), align: 'center', toolbar: '#operate', width:180} |
| | | ]], |
| | | request: { |
| | | pageName: 'curr', |
| | |
| | | } |
| | | pageCurr=curr; |
| | | limit(); |
| | | if (typeof I18n !== 'undefined') { |
| | | I18n.updatePage(); |
| | | if (I18n.updateLayuiPagination) { |
| | | I18n.updateLayuiPagination(); |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | |
| | | $(document).on('i18n:languageChanged', function() { |
| | | if (typeof I18n !== 'undefined' && tableIns) { |
| | | tableIns.reload({ |
| | | cols: [[ |
| | | {type: 'checkbox'}, |
| | | {field: 'areaId', align: 'center', title: I18n.t('area_id')}, |
| | | {field: 'areaName', align: 'center', title: I18n.t('area_name')}, |
| | | {field: 'memo', align: 'center', title: I18n.t('area_memo')}, |
| | | {fixed: 'right', title: I18n.t('operation'), align: 'center', toolbar: '#operate', width:180} |
| | | ]] |
| | | }); |
| | | |
| | | layDateRender(); |
| | | |
| | | I18n.updatePage(); |
| | | if (I18n.updateLayuiPagination) { |
| | | I18n.updateLayuiPagination(); |
| | | } |
| | | } |
| | | }); |
| | | |
| | |
| | | break; |
| | | case 'deleteData': |
| | | if (checkStatus.length === 0) { |
| | | layer.msg('请选择要删除的数据', {icon: 2}); |
| | | layer.msg(t('please_select_data'), {icon: 2}); |
| | | return; |
| | | } |
| | | del(checkStatus.map(function (d) { |
| | |
| | | })); |
| | | break; |
| | | case 'exportData': |
| | | admin.confirm('确定导出Excel吗', {shadeClose: true}, function(){ |
| | | admin.confirm(t('confirm_export_excel'), {shadeClose: true}, function(){ |
| | | var titles=[]; |
| | | var fields=[]; |
| | | obj.config.cols[0].map(function (col) { |
| | |
| | | |
| | | /* 弹窗 - 新增、修改 */ |
| | | function showEditModel(mData) { |
| | | var isCn = typeof I18n !== 'undefined' && I18n.getLanguage().toLowerCase() === 'zh-cn'; |
| | | admin.open({ |
| | | type: 1, |
| | | area: '600px', |
| | | title: (mData ? '修改' : '添加') + '订单状态', |
| | | title: (mData ? t('edit') : t('add')) + (isCn ? '' : ' ') + t('zone_management'), |
| | | content: $('#editDialog').html(), |
| | | success: function (layero, dIndex) { |
| | | layDateRender(mData); |
| | | form.val('detail', mData); |
| | | |
| | | if (typeof I18n !== 'undefined') { |
| | | I18n.updatePage(layero); |
| | | // Double check with a slight delay to ensure DOM is ready and accessible |
| | | setTimeout(function() { |
| | | I18n.updatePage(layero); |
| | | }, 50); |
| | | } |
| | | |
| | | layDateRender(mData); |
| | | form.on('submit(editSubmit)', function (data) { |
| | | var loadIndex = layer.load(2); |
| | | $.ajax({ |
| | |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.close(dIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | layer.msg(t('response.operation_success'), {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | |
| | | |
| | | /* 删除 */ |
| | | function del(ids) { |
| | | layer.confirm('确定要删除选中数据吗?', { |
| | | layer.confirm(t('confirm_delete_selected'), { |
| | | skin: 'layui-layer-admin', |
| | | shade: .1 |
| | | }, function (i) { |
| | |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | layer.msg(t('response.operation_success'), {icon: 1}); |
| | | tableReload(); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | |
| | | |
| | | // 时间选择器 |
| | | function layDateRender(data) { |
| | | var lang = (typeof I18n !== 'undefined' && I18n.getLanguage().indexOf('en') > -1) ? 'en' : 'cn'; |
| | | setTimeout(function () { |
| | | layDate.render({ |
| | | elem: '.layui-laydate-range' |
| | | ,type: 'datetime' |
| | | ,range: true |
| | | $('.layui-laydate-range').each(function() { |
| | | var $this = $(this); |
| | | var val = $this.val(); |
| | | |
| | | // Clone the element to remove old event listeners and lay-key |
| | | var $newElem = $this.clone(); |
| | | $newElem.removeAttr('lay-key'); |
| | | $newElem.val(val); |
| | | |
| | | $this.replaceWith($newElem); |
| | | |
| | | layDate.render({ |
| | | elem: $newElem[0] |
| | | ,type: 'datetime' |
| | | ,range: true |
| | | ,lang: lang |
| | | }); |
| | | }); |
| | | |
| | | }, 300); |
| | | } |
| | | layDateRender(); |