6 changed files with 303 additions and 183 deletions
@ -0,0 +1,284 @@ |
|||
|
|||
// 用于扫描条形码或二维码
|
|||
function scanCode(obj) { |
|||
} |
|||
|
|||
|
|||
// 用于计算盘点结果
|
|||
function calculateForLocation(obj) { |
|||
|
|||
} |
|||
|
|||
|
|||
function updateFlowShowForLocation() { |
|||
|
|||
} |
|||
|
|||
|
|||
layui.use(['form', 'step', 'flow', 'inputTag'], function () { |
|||
var $ = layui.$, |
|||
form = layui.form, |
|||
flow = layui.flow, |
|||
inputTag = layui.inputTag, |
|||
dropdown = layui.dropdown, //下拉菜单
|
|||
step = layui.step; |
|||
departmentManagerIdForLocation = $("#departmentManagerIdForLocation").val(); |
|||
|
|||
let takingPre = 0; |
|||
|
|||
|
|||
let tagData = []; |
|||
let tempData = $("#departmentManagerForLocation").val().split(","); |
|||
$.each(tempData, function (index, item) { |
|||
if (item !== "") { |
|||
tagData.push(item) |
|||
} |
|||
}); |
|||
$("#departmentManagerForLocation").val(""); |
|||
|
|||
|
|||
|
|||
|
|||
let tagLabel1 = inputTag.render({ |
|||
elem: '#departmentManagerForLocation', |
|||
data: tagData,//初始值
|
|||
removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
|
|||
createKeyNum: 13,//创建按键编号 默认,Enter 键
|
|||
onChange: function (data, value, type, index) { |
|||
if (type === "remove") { |
|||
let split = departmentManagerIdForLocation.split(","); |
|||
split.splice(index, 1); |
|||
departmentManagerIdForLocation = split.toString(); |
|||
$("#departmentManagerIdForLocation").val(departmentManagerIdForLocation); |
|||
} |
|||
} |
|||
}); |
|||
|
|||
// 用于打开负责人树形菜单
|
|||
$("#selectdepartmentManagerForLocation").on('click', function () { |
|||
layer.open({ |
|||
type: 2, |
|||
title: '弹窗内容', |
|||
skin: 'layui-layer-rim', |
|||
maxmin: true, |
|||
shadeClose: true, //点击遮罩关闭层
|
|||
area: ['70%', '70%'], |
|||
move: '.layui-layer-title', |
|||
fixed: false, |
|||
content: '/selectManager?type=Location', |
|||
end: function () { |
|||
departmentManagerIdForLocation = $("#departmentManagerIdForLocation").val(); |
|||
tagLabel1.createItem(); |
|||
}, |
|||
success: function (layero, index) { |
|||
var children = layero.children(); |
|||
var content = $(children[1]); |
|||
var iframeChildren = $(content.children()); |
|||
content.css('height', '100%'); |
|||
iframeChildren.css('height', '100%'); |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
|
|||
|
|||
|
|||
// 扫码盘点位置
|
|||
scanCode = function () { |
|||
parent.wx.scanQRCode({ |
|||
desc: 'scanQRCode desc', |
|||
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
|
|||
scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有
|
|||
success: function (res) { |
|||
// 回调
|
|||
var result = res.resultStr;//当needResult为1时返回处理结果
|
|||
var req = {}; |
|||
req.qrCode = result; |
|||
req.codeFlag = 2; |
|||
$.ajax({ |
|||
url: "/place/qywxApplicationInScanQrCode", |
|||
type: "post", |
|||
dataType: 'json', |
|||
data: JSON.stringify(req), |
|||
contentType: "application/json;charset=utf-8", |
|||
success: function (d) { |
|||
var data = d.data; |
|||
var flag = data["flag"]; |
|||
if (flag === 0) { |
|||
// 如果没有获取到位置
|
|||
layer.msg("并未查询到对应位置,请重新扫描", { |
|||
icon: 0, |
|||
time: 1000 |
|||
}, function () { |
|||
depositoryId = -1; |
|||
placeId = -1; |
|||
|
|||
}); |
|||
} else if (flag === 1) { |
|||
// 如果获取到的是库位
|
|||
var place = data["place"]; |
|||
$("#placeId").val(place.id); |
|||
$("#openSonByDepository").val(place.depositoryName); |
|||
$("#depositoryId").val(place.did); |
|||
|
|||
depositoryId = place.did; |
|||
placeId = place.id; |
|||
} else if (flag === 2) { |
|||
// 如果获取到的是仓库
|
|||
var depository = data["depository"]; |
|||
$("#placeId").val("0"); |
|||
$("#openSonByDepository").val(depository.dname); |
|||
$("#depositoryId").val(depository.id); |
|||
|
|||
depositoryId = depository.id; |
|||
placeId = "0"; |
|||
|
|||
} |
|||
updateTableShow(); |
|||
} |
|||
}) |
|||
} |
|||
}) |
|||
}; |
|||
|
|||
|
|||
|
|||
|
|||
// 用于计算盘点结果
|
|||
calculateForLocation = function (obj) { |
|||
let oldInventory = Number(obj.tr[0].childNodes[6].childNodes[0].innerText); |
|||
let nowInventory = Number(obj.value); |
|||
let number = 0; |
|||
let takingResult = ''; |
|||
let takingResultString = ''; |
|||
let req = {}; |
|||
if ((oldInventory) > (nowInventory)) { |
|||
number = oldInventory - nowInventory; |
|||
takingResult = "Inventory_down"; |
|||
takingResultString = "盘亏"; |
|||
} else if ((oldInventory) < (nowInventory)) { |
|||
number = nowInventory - oldInventory; |
|||
takingResult = "Inventory_up"; |
|||
takingResultString = "盘盈"; |
|||
} else { |
|||
takingResult = "Inventory_normal"; |
|||
takingResultString = "正常"; |
|||
} |
|||
obj.tr[0].childNodes[8].childNodes[0].innerText = takingResultString; |
|||
obj.tr[0].childNodes[9].childNodes[0].innerText = number; |
|||
obj.update({takingResult: takingResult}); |
|||
obj.update({takingInventory: number}); |
|||
req.number = number + ""; |
|||
req.takingResult = takingResult; |
|||
req.takingResultString = takingResultString; |
|||
req.id = obj.data.id + ""; |
|||
req.unit = obj.tr[0].childNodes[5].childNodes[0].innerText; |
|||
req.oldInventory = oldInventory + ""; |
|||
$.ajax({ |
|||
url: "/stockTaking/temporaryStorageForTakingResult", |
|||
dataType: "json", |
|||
data: JSON.stringify(req), |
|||
type: "POST", |
|||
contentType: "application/json;charset=utf-8" |
|||
}); |
|||
}; |
|||
|
|||
|
|||
// 用于打开仓库树形菜单
|
|||
$('#openSonByDepository').on('click', function () { |
|||
layer.open({ |
|||
type: 2, |
|||
title: '弹窗内容', |
|||
skin: 'layui-layer-rim', |
|||
maxmin: true, |
|||
shadeClose: true, //点击遮罩关闭层
|
|||
area: ['70%', '70%'], |
|||
move: '.layui-layer-title', |
|||
fixed: false, |
|||
content: '/selectDepository?type=2', |
|||
success: function (layero, index) { |
|||
var children = layero.children(); |
|||
var content = $(children[1]); |
|||
var iframeChildren = $(content.children()); |
|||
content.css('height', '100%'); |
|||
iframeChildren.css('height', '100%'); |
|||
}, |
|||
end: function () { |
|||
var nowDepositoryId = $("#depositoryId").val(); |
|||
var nowPlaceId = $("#placeId").val(); |
|||
if (nowDepositoryId !== depositoryId || nowPlaceId !== placeId) { |
|||
// 如果重新选择盘点位置
|
|||
var nowDepositoryName = $("#openSonByDepository").val(); |
|||
$("#form1")[0].reset(); |
|||
$("#depositoryId").val(nowDepositoryId); |
|||
$("#placeId").val(nowPlaceId); |
|||
$("#openSonByDepository").val(nowDepositoryName); |
|||
form.render(); |
|||
} |
|||
if (nowDepositoryId !== null && nowDepositoryId !== "") { |
|||
depositoryId = nowDepositoryId; |
|||
placeId = nowPlaceId; |
|||
updateFlowShowForLocation(); |
|||
} |
|||
} |
|||
}); |
|||
}); |
|||
|
|||
|
|||
updateFlowShowForLocation = function () { |
|||
$("#LAY_FlowForLocation").empty(); |
|||
takingPre = 0; |
|||
let req = {}; |
|||
req.depositoryId = depositoryId; |
|||
req.placeId = placeId; |
|||
req.size = size; |
|||
flow.load({ |
|||
elem: '#LAY_FlowForLocation' //流加载容器
|
|||
, done: function (page, next) { //执行下一页的回调
|
|||
let result; |
|||
let lis = []; |
|||
req.page = page; |
|||
$.ajax({ |
|||
url: '/material/findInventoryForStockTaking', |
|||
data: req, |
|||
type: 'get', |
|||
dataType: 'json', |
|||
contentType: "application/json;charset=utf-8", |
|||
success: function (res) { |
|||
result = res.data; |
|||
lis.push("<div class='clearfix'>"); |
|||
for (let i = 0; i < result.length; i++) { |
|||
let splitInventory = result[i].splitInventory; |
|||
let keys = Object.keys(splitInventory); |
|||
let InventoryItem = ""; |
|||
for (let j = 0; j < keys.length; j++) { |
|||
let key = keys[j]; |
|||
let item = '<p>' + "计量单位:" + key + ";对应库存:" + splitInventory[key] + '</p>'; |
|||
InventoryItem += item; |
|||
} |
|||
let brandItem ='<p>' + "物料品牌:"+result[i].mbrand + '</p>'; |
|||
if(result[i].mbrand === ""){ |
|||
brandItem = ""; |
|||
} |
|||
lis.push('<li style="width:100%;margin-top: 10px;float:left;border: 1px solid #9999996e;"><div class="layui-card my-shadow my-card flow1" iid='+result[i].id+' pid='+result[i].pid+' onclick="showDetail(this)">' + |
|||
'<div class="layui-card-header"><h2>' + "物料名称:" + result[i].mname + '</h2></div>'); |
|||
lis.push('<div class="layui-col-md4 my-info" style="margin-left: 15px; color: #999;font-size: 15px;">' |
|||
+'<p>' + "物料编码:" + result[i].mcode + '</p>' |
|||
+'<p>' + "物料型号:" + result[i].version + '</p>' |
|||
+ brandItem |
|||
+'<p>' + "所处库位:" + result[i].kingdeecode + '</p>' |
|||
+ InventoryItem |
|||
+ '</div></div></li>'); |
|||
} |
|||
lis.push('</div>'); |
|||
takingPre += result.length; |
|||
//执行下一页渲染,第二参数为:满足“加载更多”的条件,即后面仍有分页
|
|||
//pages为Ajax返回的总页数,只有当前页小于总页数的情况下,才会继续出现加载更多
|
|||
next(lis.join(''), takingPre < res.count); |
|||
} |
|||
}); |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
}); |
|||
Loading…
Reference in new issue