From c267a7ec40f10b5918476d887bc399a9d6c08936 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期六, 18 七月 2020 12:55:35 +0800
Subject: [PATCH] #
---
src/main/webapp/static/js/pakStore/stockAdjust.js | 243 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 241 insertions(+), 2 deletions(-)
diff --git a/src/main/webapp/static/js/pakStore/stockAdjust.js b/src/main/webapp/static/js/pakStore/stockAdjust.js
index 58f1ffe..0438e7a 100644
--- a/src/main/webapp/static/js/pakStore/stockAdjust.js
+++ b/src/main/webapp/static/js/pakStore/stockAdjust.js
@@ -1,4 +1,18 @@
-var pageCurr;
+var initCountVal = 0;
+var initAnfmeVal = "-";
+var matCodeData = [];
+var currLocNo;
+function getCol() {
+ var cols = [
+ {fixed: 'left', field: 'count', title: '瀹為檯鏁伴噺', align: 'center', edit:'text', width: 120, style:'color: blue;font-weight: bold'}
+ ,{field: 'anfme', align: 'center',title: '鏁伴噺'}
+ ];
+ arrRemove(detlCols, "field", "anfme")
+ cols.push.apply(cols, detlCols);
+ cols.push({fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:80})
+ return cols;
+}
+
layui.use(['table','laydate', 'form'], function() {
var table = layui.table;
var $ = layui.jquery;
@@ -6,6 +20,231 @@
var layDate = layui.laydate;
var form = layui.form;
+ tableIns = table.render({
+ elem: '#chooseData',
+ data: [],
+ even: true,
+ limit: 500,
+ cellMinWidth: 50,
+ toolbar: '#toolbar',
+ cols: [getCol()],
+ done: function (res, curr, count) {
+ limit();
+ }
+ });
+ // 椤甸潰淇敼
+ table.on('edit(chooseData)', function (obj) {
+ updateMatCodeData(obj.data.matnr, Number(obj.value));
+ });
-})
\ No newline at end of file
+ // 鐩戝惉澶村伐鍏锋爮浜嬩欢
+ table.on('toolbar(chooseData)', function (obj) {
+ switch(obj.event) {
+ case 'adjust':
+ if (isEmpty(currLocNo)) {
+ layer.msg("璇峰厛妫�绱㈠簱浣�")
+ inputTip($("#searchLocNo"));
+ return;
+ }
+ if (matCodeData.length === 0) {
+ layer.msg("璇峰厛娣诲姞鐗╂枡");
+ return;
+ }
+ for (var i=0;i<matCodeData.length;i++){
+ if (isNaN(matCodeData[i].count)) {
+ layer.msg("璇疯緭鍏ユ暟瀛�");
+ return;
+ }
+ if (matCodeData[i].count < 0){
+ layer.msg("鏁伴噺涓嶈兘灏忎簬闆�");
+ return;
+ }
+ }
+ layer.confirm('纭畾璋冩暣'+currLocNo+'搴撲綅鐨勬槑缁嗗悧锛�', {shadeClose: true}, function(){
+ $.ajax({
+ url: baseUrl+"/locDdetl/adjust/start",
+ headers: {'token': localStorage.getItem('token')},
+ data: JSON.stringify({
+ locNo: currLocNo,
+ list: matCodeData
+ }),
+ contentType:'application/json;charset=UTF-8',
+ method: 'POST',
+ async: false,
+ success: function (res) {
+ if (res.code === 200){
+ layer.msg(currLocNo + res.msg);
+ init(currLocNo)
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ }else {
+ layer.msg(res.msg)
+ }
+ }
+ })
+ });
+ break;
+ }
+ });
+
+ // 鐩戝惉琛屽伐鍏蜂簨浠�
+ table.on('tool(chooseData)', function(obj){
+ var data = obj.data;
+ switch (obj.event) {
+ case 'remove':
+ for (var i = matCodeData.length - 1; i >= 0; i--) {
+ if (matCodeData[i].matnr === data.matnr) {
+ matCodeData.splice(i, 1);
+ }
+ }
+ tableIns.reload({data: matCodeData,done:function (res) {limit();}});
+ break;
+ }
+ });
+
+ // 妫�绱簨浠�
+ form.on('submit(search)', function (data) {
+ let locNo = data.field.loc_no;
+ if (locNo === "") {
+ inputTip($("#searchLocNo"));
+ layer.msg("璇疯緭鍏ュ簱浣嶅彿");
+ return;
+ }
+ init(locNo);
+ });
+
+ // 閲嶇疆浜嬩欢
+ form.on('submit(reset)', function (data) {
+ reset();
+ });
+
+ function init(locNo) {
+ http.post(baseUrl + "/locDetl/list/auth", {locNo: locNo,limit: 1000}, function (res) {
+ matCodeData = [];
+ let data = res.data.records;
+ for (var i = 0; i<data.length; i++) {
+ data[i]["count"] = data[i].anfme;
+ data[i]["removeBtn"] = false;
+ matCodeData.push(data[i]);
+ }
+ locTips(true, locNo);
+ tableReload();
+ })
+ }
+
+ function reset() {
+ clearFormVal($('#search-box'));
+ matCodeData = [];
+ tableReload();
+ locTips(false);
+ }
+
+ // 閲嶈浇琛ㄦ牸
+ function tableReload() {
+ tableIns.reload({data: matCodeData,done:function (res) {
+ limit();
+ }});
+ }
+
+ // 搴撲綅鎻愮ず妗�
+ function locTips(retrieve, locNo) {
+ if (retrieve) {
+ http.post(baseUrl+"/locMast/"+locNo+"/auth", null, function (res) {
+ let data = res.data;
+ if (data != null) {
+ $(".retrieve").show();
+ $("#locMsg").html(locNo + " ,搴撲綅鐘舵�侊細" + data.locType$);
+ $('.not-retrieve').hide();
+ currLocNo = locNo;
+ } else {
+ layer.msg("璇疯緭鍏ユ湁鏁堝簱浣嶅彿");
+ $('.not-retrieve').show();
+ $("#locMsg").html("");
+ $(".retrieve").hide();
+ currLocNo = null;
+ inputTip($("#searchLocNo"));
+ }
+ })
+ } else {
+ $('.not-retrieve').show();
+ $("#locMsg").html("");
+ $(".retrieve").hide();
+ currLocNo = null;
+ }
+ }
+
+ function updateMatCodeData(matnr, count) {
+ if (isNaN(count)) {
+ layer.msg("璇疯緭鍏ユ暟瀛�");
+ } else {
+ if (count >= 0) {
+ for (var i=0;i<matCodeData.length;i++){
+ if (matCodeData[i]["matnr"] === matnr){
+ matCodeData[i]["count"] = count;
+ }
+ }
+ } else {
+ layer.msg("鏁伴噺蹇呴』澶т簬闆�");
+ }
+ }
+ tableIns.reload({data: matCodeData,done:function (res) {
+ limit();
+ }});
+ }
+})
+
+// 鎻愬彇鐗╂枡
+var matCodeLayerIdx;
+function getMat() {
+ if (isEmpty(currLocNo)) {
+ layer.msg("璇峰厛妫�绱㈠簱浣�")
+ inputTip($("#searchLocNo"));
+ return;
+ }
+ matCodeLayerIdx = layer.open({
+ type: 2,
+ title: '鎻愬彇鐗╂枡',
+ maxmin: true,
+ area: [top.detailWidth, top.detailHeight],
+ shadeClose: true,
+ content: 'matQuery.html',
+ success: function(layero, index){
+ }
+ });
+}
+
+// 鎼滅储妗嗙┖鍊兼彁绀�
+function inputTip(el) {
+ el.css("border-color", "red");
+ setTimeout(function () {
+ el.css("border-color", "#b8b8b8");
+ }, 1000);
+}
+
+// 娣诲姞琛ㄦ牸鏁版嵁
+function addTableData(data) {
+ let applyData = [];
+ for (var i=0;i<data.length;i++){
+ let pass = false;
+ for (var j=0;j<matCodeData.length;j++){
+ if (data[i].matNo === matCodeData[j].matnr) {
+ pass = true;
+ break;
+ }
+ }
+ if (!pass) {
+ applyData.push({
+ count: initCountVal,
+ anfme: initAnfmeVal,
+ removeBtn: true,
+ matnr: data[i].matNo,
+ maktx: data[i].matName,
+ altme: data[i].str1,
+ })
+ }
+ }
+ matCodeData.push.apply(matCodeData,applyData);
+ tableIns.reload({data: matCodeData});
+ layer.close(matCodeLayerIdx);
+}
\ No newline at end of file
--
Gitblit v1.9.1