From 1a987c661d60c77b258a3be42c09a3fd2ba3ae06 Mon Sep 17 00:00:00 2001 From: LSH Date: 星期一, 14 八月 2023 15:34:59 +0800 Subject: [PATCH] #订单出库自动出浅库位 --- src/main/webapp/static/js/mat/mat.js | 73 ++++++++++++++++++++++++++++++++++++ 1 files changed, 72 insertions(+), 1 deletions(-) diff --git a/src/main/webapp/static/js/mat/mat.js b/src/main/webapp/static/js/mat/mat.js index ecf879f..8bfb2be 100644 --- a/src/main/webapp/static/js/mat/mat.js +++ b/src/main/webapp/static/js/mat/mat.js @@ -5,10 +5,11 @@ 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; } @@ -433,9 +434,79 @@ // 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); // 杞崲涓篵ase64锛屽彲浠ョ洿鎺ユ斁鍏琛ㄦ儏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(); // 绛変环浜巇ocument.documentElement.removeChild(a); + }; + } + }; + xhr.send(params); // 鍙戦�乤jax璇锋眰 } +// 鍚屾鏂板晢鍝佺紪鍙� +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("璇蜂笂浼爔lsx鏍煎紡鏂囦欢"); + 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鏂瑰紡锛寀rl涓烘湇鍔″櫒璇锋眰鍦板潃锛宼rue 璇ュ弬鏁拌瀹氳姹傛槸鍚﹀紓姝ュ鐞嗐�� + 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 = {}; -- Gitblit v1.9.1