|  |  |  | 
|---|
|  |  |  | var cols = [ | 
|---|
|  |  |  | {type: 'checkbox'} | 
|---|
|  |  |  | ,{field: 'tagId$', align: 'center',title: '归类', templet: '#tagTpl'} | 
|---|
|  |  |  | // ,{field: 'matnrNew', align: 'center',title: '新商品编号', width: 180} | 
|---|
|  |  |  | ]; | 
|---|
|  |  |  | cols.push.apply(cols, matCols); | 
|---|
|  |  |  | cols.push( | 
|---|
|  |  |  | {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:150} | 
|---|
|  |  |  | {fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | return cols; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | url: baseUrl+'/mat/list/auth', | 
|---|
|  |  |  | page: true, | 
|---|
|  |  |  | limit: 16, | 
|---|
|  |  |  | limits: [16, 30, 50, 100, 200, 500], | 
|---|
|  |  |  | limits: [16, 30, 50, 100, 200, 500, 50000], | 
|---|
|  |  |  | toolbar: '#toolbar', | 
|---|
|  |  |  | cellMinWidth: 50, | 
|---|
|  |  |  | height: 'full-105', | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // excel导出 | 
|---|
|  |  |  | function exportExcel() { | 
|---|
|  |  |  | // window.location.href = baseUrl + "/mat/excel/export/auth" | 
|---|
|  |  |  | const url = baseUrl + "/mat/excel/export/auth"; //记得拼接参数 | 
|---|
|  |  |  | const xhr = new XMLHttpRequest(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var params = ''; | 
|---|
|  |  |  | $.each($('#search-box [name]').serializeArray(), function() { | 
|---|
|  |  |  | params += this.name + '=' + this.value + '&'; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | params = params.substring(0, params.length - 1); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | xhr.open('POST', url, true); | 
|---|
|  |  |  | xhr.setRequestHeader('token', localStorage.getItem('token')); | 
|---|
|  |  |  | xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); | 
|---|
|  |  |  | xhr.responseType = 'blob'; // 返回类型blob | 
|---|
|  |  |  | xhr.onload = function(e) { | 
|---|
|  |  |  | if (this.status === 200) { | 
|---|
|  |  |  | const blob = this.response; | 
|---|
|  |  |  | const reader = new FileReader(); | 
|---|
|  |  |  | reader.readAsDataURL(blob); // 转换为base64,可以直接放入a表情href | 
|---|
|  |  |  | reader.onload = function(e) { | 
|---|
|  |  |  | const a = document.createElement('a'); | 
|---|
|  |  |  | a.download = new Date().getTime() + '_export_data.xlsx'; | 
|---|
|  |  |  | a.href = e.target.result; | 
|---|
|  |  |  | document.documentElement.appendChild(a); | 
|---|
|  |  |  | a.click(); | 
|---|
|  |  |  | a.remove(); // 等价于document.documentElement.removeChild(a); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | xhr.send(params); // 发送ajax请求 | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 同步新商品编号 | 
|---|
|  |  |  | function importNewMatnr() { | 
|---|
|  |  |  | $("#importNewMatnr").trigger("click"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | function uploadNewMatnr(obj){ | 
|---|
|  |  |  | if(!obj.files) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | var file = obj.files[0]; | 
|---|
|  |  |  | var filename = file.name | 
|---|
|  |  |  | var filenameArr = filename.split(".") | 
|---|
|  |  |  | var filetype = filenameArr[filenameArr.length - 1] //文件类型 | 
|---|
|  |  |  | if (filetype != "xlsx") { | 
|---|
|  |  |  | layer.msg("请上传xlsx格式文件"); | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | admin.confirm('确认同步 [' + file.name +'] 文件吗?', function (index) { | 
|---|
|  |  |  | layer.load(1, {shade: [0.1,'#fff']}); | 
|---|
|  |  |  | var url = baseUrl + "/mat/excel/importNewMatnr/auth"; | 
|---|
|  |  |  | var form = new FormData(); | 
|---|
|  |  |  | form.append("file", file); | 
|---|
|  |  |  | xhr = new XMLHttpRequest(); | 
|---|
|  |  |  | xhr.open("post", url, true); //post方式,url为服务器请求地址,true 该参数规定请求是否异步处理。 | 
|---|
|  |  |  | xhr.setRequestHeader('token', localStorage.getItem('token')); | 
|---|
|  |  |  | xhr.onload = uploadComplete; //请求完成 | 
|---|
|  |  |  | xhr.onerror =  uploadFailed; //请求失败 | 
|---|
|  |  |  | xhr.onloadend = function () { // // 上传完成重置文件流 | 
|---|
|  |  |  | layer.closeAll('loading'); | 
|---|
|  |  |  | $("#importExcel").val(""); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | // xhr.upload.onprogress = progressFunction;//【上传进度调用方法实现】 | 
|---|
|  |  |  | xhr.upload.onloadstart = function(){//上传开始执行方法 | 
|---|
|  |  |  | ot = new Date().getTime();   //设置上传开始时间 | 
|---|
|  |  |  | oloaded = 0;//设置上传开始时,以上传的文件大小为0 | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | xhr.send(form); | 
|---|
|  |  |  | }, function(index){ | 
|---|
|  |  |  | $("#importExcel").val(""); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | function tableReload(child) { | 
|---|
|  |  |  | var searchData = {}; | 
|---|