| | |
| | | var insTbCount = 0; |
| | | layui.config({ |
| | | base: baseUrl + "/static/layui/lay/modules/" |
| | | }).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate','tableMerge'], function () { |
| | | }).extend({ |
| | | notice: 'notice/notice', |
| | | }).use(['layer', 'form', 'table', 'util', 'admin', 'xmSelect', 'laydate','tableMerge','notice'], function () { |
| | | var $ = layui.jquery; |
| | | var layer = layui.layer; |
| | | var form = layui.form; |
| | |
| | | var layDate = layui.laydate; |
| | | var laytpl = layui.laytpl; |
| | | var tableMerge = layui.tableMerge; |
| | | var notice = layui.notice; |
| | | |
| | | // 渲染搜索模板 |
| | | $.ajax({ |
| | |
| | | showEditModel(data); |
| | | }else if (layEvent === 'createTask') { |
| | | pakoutPreview(data.id); |
| | | }else if (layEvent === 'export') { |
| | | export1(data.id); |
| | | }else if (layEvent === 'del') { |
| | | doDel(data.id); |
| | | } else if (layEvent === 'complete') { |
| | |
| | | }) |
| | | } |
| | | |
| | | |
| | | function createTask(orderId) { |
| | | let loadIndex = layer.msg('请求中...', {icon: 16, shade: 0.01, time: false}); |
| | | function export1(id) { |
| | | notice.msg('正在导出文件......', {icon: 4}); |
| | | $.ajax({ |
| | | url: baseUrl+"/checkOrder/createTask/auth", |
| | | url: baseUrl + "/checkOrder/export/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | data: { |
| | | orderId: orderId |
| | | orderId: id |
| | | }, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | layer.close(loadIndex); |
| | | if (res.code === 200){ |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.reload({page: {curr: 1}}); |
| | | } else if (res.code === 403){ |
| | | top.location.href = baseUrl+"/"; |
| | | }else { |
| | | layer.msg(res.msg, {icon: 2}); |
| | | xhrFields: { |
| | | responseType: 'blob' |
| | | }, |
| | | success: function (data, status, xhr) { |
| | | notice.destroy(); |
| | | // 从响应头获取文件名 |
| | | var disposition = xhr.getResponseHeader('Content-Disposition'); |
| | | var filename = '盘点差异单.xlsx'; |
| | | if (disposition && disposition.indexOf('filename') !== -1) { |
| | | var filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/; |
| | | var matches = filenameRegex.exec(disposition); |
| | | if (matches != null && matches[1]) { |
| | | filename = decodeURIComponent(matches[1].replace(/['"]/g, '')); |
| | | } |
| | | } |
| | | |
| | | // 创建下载链接 |
| | | var blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}); |
| | | var link = document.createElement('a'); |
| | | link.href = window.URL.createObjectURL(blob); |
| | | link.download = filename; |
| | | document.body.appendChild(link); |
| | | link.click(); |
| | | document.body.removeChild(link); |
| | | window.URL.revokeObjectURL(link.href); |
| | | |
| | | layer.msg('导出成功', {icon: 1}); |
| | | }, |
| | | error: function (xhr, status, error) { |
| | | notice.destroy(); |
| | | if (xhr.status === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg('导出失败:' + error, {icon: 2}); |
| | | } |
| | | } |
| | | }) |
| | | }); |
| | | } |
| | | |
| | | function pakout(tableCache, layerIndex) { |
| | | // let loadIndex = layer.load(2); |
| | | notice.msg('正在生成盘点出库任务......', {icon: 4}); |
| | | $.ajax({ |
| | | url: baseUrl + "/out/checkPakOut/auth", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | contentType: 'application/json;charset=UTF-8', |
| | | data: JSON.stringify(tableCache), |
| | | method: 'POST', |
| | | success: function (res) { |
| | | notice.destroy(); |
| | | if (res.code === 200) { |
| | | layer.close(layerIndex); |
| | | layer.msg(res.msg, {icon: 1}); |
| | | insTb.reload({where: null}); |
| | | insTb2.reload({where: null, page: {curr: 1}}); |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | layer.msg(res.msg, {icon: 2}) |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | layDate.render({ |