From d45fd7768ac59fb44e65ce574aaf9fda1489488b Mon Sep 17 00:00:00 2001
From: lty <876263681@qq.com>
Date: 星期一, 23 六月 2025 14:03:48 +0800
Subject: [PATCH] #订单导入上限增加
---
src/main/webapp/static/js/mat/boxMat.js | 482 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 482 insertions(+), 0 deletions(-)
diff --git a/src/main/webapp/static/js/mat/boxMat.js b/src/main/webapp/static/js/mat/boxMat.js
new file mode 100644
index 0000000..7705d58
--- /dev/null
+++ b/src/main/webapp/static/js/mat/boxMat.js
@@ -0,0 +1,482 @@
+var pageCurr;
+var printMatCodeNos = [];
+var admin;
+function getCol() {
+ var cols = [
+ {type: 'checkbox'}
+ ,{field: 'tagId$', align: 'center',title: '褰掔被', templet: '#tagTpl'}
+ ,{field: 'memo', align: 'center',title: '鏈ㄧ璧勬枡',hide:false}
+ ];
+ // cols.push.apply(cols, matCols);
+ cols.push(
+ {fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150}
+ )
+ return cols;
+}
+
+layui.config({
+ base: baseUrl + "/static/layui/lay/modules/"
+}).extend({
+ dropdown: 'dropdown/dropdown',
+}).use(['table','laydate', 'form', 'treeTable', 'admin', 'xmSelect', 'dropdown', 'element'], function(){
+ var table = layui.table;
+ var $ = layui.jquery;
+ var layer = layui.layer;
+ var layDate = layui.laydate;
+ var form = layui.form;
+ admin = layui.admin;
+ var treeTable = layui.treeTable;
+ var xmSelect = layui.xmSelect;
+
+ // 鍟嗗搧鍒嗙被鏁版嵁
+ var insTb = treeTable.render({
+ elem: '#tag',
+ url: baseUrl+'/tag/list/auth',
+ headers: {token: localStorage.getItem('token')},
+ tree: {
+ iconIndex: 2, // 鎶樺彔鍥炬爣鏄剧ず鍦ㄧ鍑犲垪
+ isPidData: true, // 鏄惁鏄痠d銆乸id褰㈠紡鏁版嵁
+ idName: 'id', // id瀛楁鍚嶇О
+ pidName: 'parentId' // pid瀛楁鍚嶇О
+ },
+ cols: [],
+ done: function (data) {
+ $('.ew-tree-table-box').css('height', '100%');
+ insTb.expandAll();
+ }
+ });
+
+ // 鏁版嵁娓叉煋
+ tableIns = table.render({
+ elem: '#mat',
+ headers: {token: localStorage.getItem('token')},
+ url: baseUrl+'/boxMat/list/auth',
+ page: true,
+ limit: 16,
+ limits: [16, 30, 50, 100, 200, 500],
+ toolbar: '#toolbar',
+ cellMinWidth: 50,
+ height: 'full-105',
+ cols: [getCol()],
+ request: {
+ pageName: 'curr',
+ pageSize: 'limit'
+ },
+ parseData: function (res) {
+ return {
+ 'code': res.code,
+ 'msg': res.msg,
+ 'count': res.data.total,
+ 'data': res.data.records
+ }
+ },
+ 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';
+ }
+ });
+ }
+ });
+
+ // 鐩戝惉鎺掑簭浜嬩欢
+ table.on('sort(locMast)', function (obj) {
+ var searchData = {};
+ $.each($('#search-box [name]').serializeArray(), function() {
+ searchData[this.name] = this.value;
+ });
+ searchData['orderByField'] = obj.field;
+ searchData['orderByType'] = obj.type;
+ tableIns.reload({
+ where: searchData,
+ page: {
+ curr: 1
+ },
+ done: function (res, curr, count) {
+ if (res.code === 403) {
+ top.location.href = baseUrl+"/";
+ }
+ pageCurr=curr;
+ limit();
+ }
+ });
+ });
+
+ // 鐩戝惉澶村伐鍏锋爮浜嬩欢
+ table.on('toolbar(mat)', function (obj) {
+ var checkStatus = table.checkStatus(obj.config.id);
+ switch(obj.event) {
+ case 'addData':
+ showEditModel()
+ break;
+ case 'deleteData':
+ var data = checkStatus.data;
+ if (data.length === 0){
+ layer.msg('璇烽�夋嫨鏁版嵁');
+ } else {
+ layer.confirm('纭畾鍒犻櫎'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){
+ $.ajax({
+ url: baseUrl+"/mat/delete/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: {param: JSON.stringify(data)},
+ method: 'POST',
+ traditional:true,
+ success: function (res) {
+ if (res.code === 200){
+ layer.closeAll();
+ tableReload(false);
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ } else {
+ layer.msg(res.msg)
+ }
+ }
+ })
+ });
+ }
+ break;
+ case 'exportData':
+ layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
+ var titles=[];
+ var fields=[];
+ obj.config.cols[0].map(function (col) {
+ if (col.type === 'normal' && col.hide === false && col.toolbar == null) {
+ titles.push(col.title);
+ fields.push(col.field);
+ }
+ });
+ var exportData = {};
+ $.each($('#search-box [name]').serializeArray(), function() {
+ exportData[this.name] = this.value;
+ });
+ var param = {
+ 'mat': exportData,
+ 'fields': fields
+ };
+ $.ajax({
+ url: baseUrl+"/mat/export/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: JSON.stringify(param),
+ dataType:'json',
+ contentType:'application/json;charset=UTF-8',
+ method: 'POST',
+ success: function (res) {
+ layer.closeAll();
+ if (res.code === 200) {
+ table.exportFile(titles,res.data,'xls');
+ } else if (res.code === 403) {
+ top.location.href = baseUrl+"/";
+ } else {
+ layer.msg(res.msg)
+ }
+ }
+ });
+ });
+ break;
+ // 鎵归噺鎵撳嵃
+ case "btnPrintBatch":
+ printMatCodeNos = [];
+ var data = checkStatus.data;
+ if (data.length === 0){
+ layer.msg('璇烽�夋嫨鎵撳嵃鏁版嵁');
+ } else {
+ layer.open({
+ type: 1,
+ title: '鎵归噺鎵撳嵃 [鏁伴噺'+ data.length +']',
+ area: ['500px'],
+ shadeClose: true,
+ content: $('#printDataDiv'),
+ success: function(layero, index){
+ for (var i = 0; i<data.length;i++) {
+ printMatCodeNos.push(data[i].matnr);
+ }
+ },
+ end: function () {
+ }
+ });
+ }
+ break;
+ }
+ });
+
+ // 鐩戝惉琛屽伐鍏蜂簨浠�
+ table.on('tool(mat)', function(obj){
+ var data = obj.data;
+ switch (obj.event) {
+ // 鎵撳嵃
+ case "btnPrint":
+ printMatCodeNos = [];
+ layer.open({
+ type: 1,
+ title: data.matnr + ' [鏁伴噺锛�1]',
+ area: ['500px'],
+ shadeClose: true,
+ content: $('#printDataDiv'),
+ success: function(layero, index){
+ layer.iframeAuto(index);
+ printMatCodeNos.push(data.matnr);
+ },
+ end: function () {
+ }
+ });
+ break;
+ // 缂栬緫
+ case 'edit':
+ showEditModel(data)
+ break;
+ }
+ });
+
+ /* 鏄剧ず琛ㄥ崟寮圭獥 */
+ function showEditModel(mData) {
+ admin.open({
+ type: 1,
+ area: '600px',
+ title: (mData ? '淇敼' : '娣诲姞') + '鍟嗗搧',
+ content: $('#editDialog').html(),
+ success: function (layero, dIndex) {
+ // 鍥炴樉琛ㄥ崟鏁版嵁
+ form.val('detail', mData);
+ // 鏂板鑷姩鐢熸垚鍟嗗搧缂栧彿
+ if (!mData) {
+ http.get(baseUrl + "/mat/auto/matnr/auth", null, function (res) {
+ $('#matnr').val(res.data);
+ })
+ }
+ // 琛ㄥ崟鎻愪氦浜嬩欢
+ form.on('submit(editSubmit)', function (data) {
+ console.log(data)
+ data.field.tagId = insXmSel.getValue('valueStr');
+ if (isEmpty(data.field.tagId)) {
+ layer.msg('鍒嗙被涓嶈兘涓虹┖', {icon: 2});
+ return false;
+ }
+ var loadIndex = layer.load(2);
+ $.ajax({
+ url: baseUrl+"/mat/"+(mData?'update':'add')+"/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: data.field,
+ method: 'POST',
+ success: function (res) {
+ layer.close(loadIndex);
+ if (res.code === 200){
+ layer.close(dIndex);
+ layer.msg(res.msg, {icon: 1});
+ $(".layui-laypage-btn")[0].click();
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ }else {
+ layer.msg(res.msg, {icon: 2});
+ }
+ }
+ })
+ return false;
+ });
+ // 娓叉煋涓嬫媺鏍�
+ var insXmSel = xmSelect.render({
+ el: '#tagSel',
+ height: '250px',
+ data: insTb.options.data,
+ initValue: mData ? [mData.tagId] : [],
+ model: {label: {type: 'text'}},
+ prop: {
+ name: 'name',
+ value: 'id'
+ },
+ radio: true,
+ clickClose: true,
+ tree: {
+ show: true,
+ indent: 15,
+ strict: false,
+ expandedKeys: true
+ }
+ });
+ // 寮圭獥涓嶅嚭鐜版粴鍔ㄦ潯
+ $(layero).children('.layui-layer-content').css('overflow', 'visible');
+ layui.form.render('select');
+ }
+ });
+ }
+
+ // 妯℃澘閫夋嫨
+ form.on('radio(selectTemplateRadio)', function (data) {
+ $('.template-preview').hide();
+ $('#template-preview-'+data.value).show();
+ });
+
+ // 寮�濮嬫墦鍗�
+ form.on('submit(doPrint)', function (data) {
+ var templateNo = data.field.selectTemplate;
+ $.ajax({
+ url: baseUrl+"/mat/print/auth",
+ headers: {'token': localStorage.getItem('token')},
+ data: {param: printMatCodeNos},
+ method: 'POST',
+ async: false,
+ success: function (res) {
+ if (res.code === 200){
+ layer.closeAll();
+ for (let i=0;i<res.data.length;i++){
+ var templateDom = $("#templatePreview"+templateNo);
+ var className = templateDom.attr("class");
+ if (className === 'template-barcode') {
+ res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=1¶m="+res.data[i].matnr;
+ } else {
+ res.data[i]["barcodeUrl"]=baseUrl+"/mac/code/auth?type=2¶m="+res.data[i].matnr;
+ }
+ }
+ var tpl = templateDom.html();
+ var template = Handlebars.compile(tpl);
+ var html = template(res);
+ var box = $("#box");
+ box.html(html);box.show();
+ box.print({mediaPrint:true});
+ box.hide();
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ }else {
+ layer.msg(res.msg)
+ }
+ }
+ })
+ });
+
+ // 鎼滅储鏍忔悳绱簨浠�
+ form.on('submit(search)', function (data) {
+ pageCurr = 1;
+ tableReload(false);
+ });
+
+ // 鎼滅储鏍忛噸缃簨浠�
+ form.on('submit(reset)', function (data) {
+ pageCurr = 1;
+ clearFormVal($('#search-box'));
+ tableReload(false);
+ });
+
+ // 鏃堕棿閫夋嫨鍣�
+ layDate.render({
+ elem: '#createTime\\$',
+ type: 'datetime'
+ });
+ layDate.render({
+ elem: '#updateTime\\$',
+ type: 'datetime'
+ });
+
+
+});
+
+// excel瀵煎叆妯℃澘涓嬭浇
+function excelMouldDownload(){
+ layer.load(1, {shade: [0.1,'#fff']});
+ location.href = baseUrl + "/mat/excel/import/mould";
+ layer.closeAll('loading');
+}
+
+// excel瀵煎叆
+function importExcel() {
+ $("#importExcel").trigger("click");
+}
+function upload(obj){
+ if(!obj.files) {
+ return;
+ }
+ var file = obj.files[0];
+ admin.confirm('纭鍚屾 [' + file.name +'] 鏂囦欢鍚楋紵', function (index) {
+ layer.load(1, {shade: [0.1,'#fff']});
+ var url = baseUrl + "/mat/excel/import/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 uploadComplete(evt) {
+ var res = JSON.parse(evt.target.responseText);
+ if(res.code === 200) {
+ layer.msg(res.msg, {icon: 1});
+ loadTree("");
+ } else {
+ layer.msg(res.msg, {icon: 2});
+ }
+}
+function uploadFailed(evt) {
+ var res = JSON.parse(evt.target.responseText);
+ layer.msg(res.msg, {icon: 2});
+}
+
+// excel瀵煎嚭
+function exportExcel() {
+
+}
+
+
+function tableReload(child) {
+ var searchData = {};
+ $.each($('#search-box [name]').serializeArray(), function() {
+ searchData[this.name] = this.value;
+ });
+ (child ? parent.tableIns : tableIns).reload({
+ where: searchData,
+ page: {
+ curr: pageCurr
+ },
+ done: function (res, curr, count) {
+ if (res.code === 403) {
+ top.location.href = baseUrl+"/";
+ }
+ pageCurr=curr;
+ if (res.data.length === 0 && count !== 0) {
+ tableIns.reload({
+ where: searchData,
+ page: {
+ curr: pageCurr-1
+ }
+ });
+ pageCurr -= 1;
+ }
+ limit(child);
+ }
+ });
+}
+
+function clearFormVal(el) {
+ $(':input', el)
+ .val('')
+ .removeAttr('checked')
+ .removeAttr('selected');
+}
+
+$('body').keydown(function () {
+ if (event.keyCode === 13) {
+ $("#search").click();
+ }
+});
--
Gitblit v1.9.1