From 3e867b935ca291a0555a31ffb324e8705df93be2 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期一, 09 八月 2021 08:11:35 +0800 Subject: [PATCH] # --- src/main/webapp/static/js/ioWorks/matQuery.js | 294 +++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 268 insertions(+), 26 deletions(-) diff --git a/src/main/webapp/static/js/ioWorks/matQuery.js b/src/main/webapp/static/js/ioWorks/matQuery.js index 390e731..7a2b7f1 100644 --- a/src/main/webapp/static/js/ioWorks/matQuery.js +++ b/src/main/webapp/static/js/ioWorks/matQuery.js @@ -1,5 +1,8 @@ var matData = []; +var cstmrVal; +var itemVal; + function getCol() { var cols = [ {field: 'count', align: 'center',title: '鍑哄簱鏁伴噺', edit:'text', width: 130, style:'color: blue;font-weight: bold'} @@ -9,17 +12,25 @@ cols.push({fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:65}) return cols; } - -layui.use(['table','laydate', 'form'], function() { +layui.config({ + base: baseUrl + "/static/layui/lay/modules/" +}).extend({ + notice: 'notice/notice', +}).use(['table','laydate', 'form', 'admin', 'notice', 'xmSelect'], function() { var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var form = layui.form; + var notice = layui.notice; + var layDate = layui.laydate; + var admin = layui.admin; + var xmSelect = layui.xmSelect; tableIns = table.render({ elem: '#chooseData', headers: {token: localStorage.getItem('token')}, data: [], + limit: 100, even: true, toolbar: '#toolbar', cellMinWidth: 50, @@ -38,38 +49,198 @@ table.on('toolbar(chooseData)', function (obj) { var data = matData; switch (obj.event) { - case 'outbound': + case 'createDoc': if (data.length === 0){ - layer.msg('璇峰厛娣诲姞鐗╂枡'); - } else { - var locDetls = []; - data.forEach(function(elem) { - locDetls.push({nodeId: elem.nodeId, matnr: elem.matnr, count: elem.count}); + notice.error({ + title: '娑堟伅閫氱煡', + message: '璇锋坊鍔犵墿鏂�' }); + } else { + var success = true; + for (var i=0;i<matData.length;i++) { + if (matData[i].count <= 0) { + notice.error({ + title: '娑堟伅閫氱煡', + message: matData[i].matnr + '鐗╂枡鏁伴噺蹇呴』澶т簬闆讹紒' + }); + success = false; + return false; + } + } + var index = layer.load(1, {shade: [0.1,'#000']}); + // 鍗曟嵁绫诲瀷 + var docTypeData; $.ajax({ - url: baseUrl+"/work/pakout/init", + url: baseUrl+"/work/docType/all/get", headers: {'token': localStorage.getItem('token')}, - data: JSON.stringify(locDetls), - contentType:'application/json;charset=UTF-8', method: 'POST', + async: false, success: function (res) { if (res.code === 200){ - matData = []; - tableIns.reload({data: matData,done:function (res) { - limit(); - }}); - layer.msg(res.msg, {icon: 1}); - } else if (res.code === 403){ - top.location.href = baseUrl+"/"; + docTypeData = res; } else { - layer.msg(res.msg) + layer.msg(res.msg, {icon: 2}) } } }); + var tpl1 = $('#docTypeSelectTpl').html(); + var template1 = Handlebars.compile(tpl1); + var html1 = template1(docTypeData); + $("#docType").html(html1); + + // 瀹㈡埛 + var cstmrData; + // $.ajax({ + // url: baseUrl+"/work/cstmr/all/get", + // headers: {'token': localStorage.getItem('token')}, + // method: 'POST', + // async: false, + // success: function (res) { + // if (res.code === 200){ + // cstmrData = res; + // } else { + // layer.msg(res.msg, {icon: 2}) + // } + // } + // }); + // var tpl2 = $('#cstmrSelectTpl').html(); + // var template2 = Handlebars.compile(tpl2); + // var html2 = template2(cstmrData); + // $("#cstmr").html(html2); + // 鍗曢�� + $.ajax({ + url: baseUrl+"/work/cstmr/all/get/kv", + headers: {'token': localStorage.getItem('token')}, + method: 'POST', + async: false, + success: function (res) { + if (res.code === 200){ + cstmrData = res.data; + } else { + layer.msg(res.msg, {icon: 2}) + } + } + }); + cstmrVal = xmSelect.render({ + el: '#cstmr', + radio: true, + clickClose: true, + filterable: true, + create: function(val, arr){ + if(arr.length === 0){ + return { + name: val, + value: val + } + } + }, + model: { + icon: 'hidden', + label: { + type: 'text', + } + }, + data: cstmrData + }) + + // 椤圭洰 + var itemData; + // $.ajax({ + // url: baseUrl+"/work/item/all/get", + // headers: {'token': localStorage.getItem('token')}, + // method: 'POST', + // async: false, + // success: function (res) { + // if (res.code === 200){ + // itemData = res; + // } else { + // layer.msg(res.msg, {icon: 2}); + // } + // } + // }); + // var tpl3 = $('#itemSelectTpl').html(); + // var template3 = Handlebars.compile(tpl3); + // var html3 = template3(itemData); + // $("#item").html(html3); + $.ajax({ + url: baseUrl+"/work/item/all/get/kv", + headers: {'token': localStorage.getItem('token')}, + method: 'POST', + async: false, + success: function (res) { + if (res.code === 200){ + itemData = res.data; + } else { + layer.msg(res.msg, {icon: 2}); + } + } + }); + itemVal = xmSelect.render({ + el: '#item', + radio: true, + clickClose: true, + filterable: true, + create: function(val, arr){ + if(arr.length === 0){ + return { + name: val, + value: val + } + } + }, + model: { + icon: 'hidden', + label: { + type: 'text', + } + }, + data: itemData + }) + + // 寮圭獥 + layer.close(index); + if (success) { + admin.open({ + type: 1, + title: '鍗曟嵁濉厖', + offset: '100px', + area: ['360px'], + shade: 0.3, + content: $('#getOrderNo'), + success: function(layero, index){ + layer.iframeAuto(index); + $(layero).children('.layui-layer-content').css('overflow', 'visible'); + layui.form.render('select'); + }, + cancel: function () { + $('#orderNo').val(''); + } + }); + } } break; } }); + + + // // 澶氶�� + // var demo1 = xmSelect.render({ + // el: '#demo1', + // filterable: true, + // create: function(val, arr){ + // if(arr.length === 0){ + // return { + // name: val, + // value: val + // } + // } + // }, + // data: [ + // {name: '寮犱笁', value: 1, selected: true}, + // {name: '鏉庡洓', value: 2}, + // {name: '鐜嬩簲', value: 3, disabled: true}, + // ] + // }) // 鐩戝惉琛屽伐鍏蜂簨浠� table.on('tool(chooseData)', function(obj){ @@ -88,29 +259,79 @@ } }); + // 寮�濮嬬敓鎴愭嫞璐у崟 + form.on('submit(confirm)', function (data) { + var matDetls = []; + matData.forEach(function(elem) { + matDetls.push({ + matnr: elem.matnr + , count: elem.count + }); + }); + var req = JSON.stringify({ + docType: data.field.docType + , orderNo: data.field.orderNo + , orderTime: data.field.orderTime + , item: itemVal.getValue()[0] ? itemVal.getValue()[0].name : null + , cstmr: cstmrVal.getValue()[0] ? cstmrVal.getValue()[0].name : null + , list: matDetls + }) + $.ajax({ + url: baseUrl+"/work/order/init", + headers: {'token': localStorage.getItem('token')}, + data: req, + contentType:'application/json;charset=UTF-8', + method: 'POST', + success: function (res) { + if (res.code === 200){ + notice.success({ + title: '娑堟伅閫氱煡', + message: res.msg + }); + top.layui.layer.close(top.popupRight); + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + notice.error({ + title: '娑堟伅閫氱煡', + message: res.msg + }); + } + } + }); + }) + function updateMatData(locNo, matnr, count) { if (isNaN(count)) { - layer.msg("璇疯緭鍏ユ暟瀛�"); + notice.error({ + title: '娑堟伅閫氱煡', + message: '璇疯緭鍏ユ暟瀛�' + }); } else { if (count > 0) { for (var i=0;i<matData.length;i++){ if (matData[i]["matnr"] === matnr){ - // if (count > locDetlData[i]["anfme"]) { - // layer.msg("涓嶈兘瓒呰繃鍘熸暟閲�"); - // } else { - matData[i]["count"] = count; - // } + matData[i]["count"] = count; break; } } } else { - layer.msg("鏁伴噺蹇呴』澶т簬闆�"); + notice.error({ + title: '娑堟伅閫氱煡', + message: '鏁伴噺蹇呴』澶т簬闆�' + }); } } tableIns.reload({data: matData,done:function (res) { limit(); }}); } + + layDate.render({ + elem: '#orderTime', + trigger: 'click', + type: 'date' + }); }) @@ -149,4 +370,25 @@ matData.push.apply(matData, data); tableIns.reload({data: matData}); layer.close(matDetlLayerIdx); +} + +function initOrderNo() { + $.ajax({ + url: baseUrl+"/work/orderNo/init", + headers: {'token': localStorage.getItem('token')}, + async: false, + method: 'GET', + success: function (res) { + if (res.code === 200){ + $('#orderNo').val(res.data) + } else if (res.code === 403){ + top.location.href = baseUrl+"/"; + } else { + notice.error({ + title: '娑堟伅閫氱煡', + message: res.msg + }); + } + } + }); } \ No newline at end of file -- Gitblit v1.9.1