You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
5.6 KiB
143 lines
5.6 KiB
<!DOCTYPE html>
|
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>layui</title>
|
|
<meta name="renderer" content="webkit">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
|
<link rel="stylesheet" href="/static/lib/layui-v2.8.6/css/layui.css" media="all">
|
|
<link rel="stylesheet" href="/static/css/public.css" media="all">
|
|
</head>
|
|
<body>
|
|
<input id="depositoryId" name="depositoryId" th:value="${depositoryId}" style="display: none">
|
|
<input id="quantity" name="quantity" th:value="${quantity}" style="display: none">
|
|
<input id="placeId" name="placeId" th:value="${placeId}" style="display: none">
|
|
<input id="mid" name="mid" th:value="${mid}" style="display: none">
|
|
<input id="unit" name="unit" th:value="${unit}" style="display: none">
|
|
<div id="test2" class="demo-tree"></div>
|
|
<script src="/static/lib/layui-v2.8.6/layui.js" charset="utf-8"></script>
|
|
<script>
|
|
layui.use(['form', 'layer','dropdown','tree'], function () {
|
|
var $ = layui.jquery,
|
|
tree = layui.tree;
|
|
|
|
// 用于标志是否为第一次提交
|
|
let flagForForm = false;
|
|
// 获取当前仓库
|
|
var depositoryId = $("#depositoryId").val();
|
|
// 当前库存总数
|
|
var quantity = $("#quantity").val();
|
|
// 定义转移前的库位
|
|
var fromPlaceId = $("#placeId").val();
|
|
// 获取转移的物料
|
|
var mid = $("#mid").val();
|
|
// 获取转移的计量单位
|
|
var unit = $("#unit").val();
|
|
test = tree.render({
|
|
elem: '#test2'
|
|
,data: []
|
|
,onlyIconControl: true //是否仅允许节点左侧图标控制展开收缩
|
|
,click: function(obj){
|
|
var data = obj.data;
|
|
if(data.id === -1 ){
|
|
return false;
|
|
}
|
|
// 判断点击的是仓库还是库位
|
|
// 用于判断是库位还是仓库
|
|
var flag = false;
|
|
var dataId = data.id;
|
|
let placeId = 0;
|
|
if(typeof dataId === "string"){
|
|
flag = true;
|
|
}
|
|
if(!flag) {
|
|
placeId = 0;
|
|
}else{
|
|
var did = dataId.split("-");
|
|
placeId = did[1];
|
|
}
|
|
// 弹出输入框用于输入转移数量
|
|
outQuantityCheck(placeId)
|
|
|
|
}
|
|
});
|
|
$.ajax({
|
|
url: "/repository/treeMenus_Place?depositoryId="+depositoryId,
|
|
type: 'get',
|
|
dataType: 'json',
|
|
contentType: "application/json;charset=utf-8",
|
|
beforeSend: function () {
|
|
},
|
|
success: function (d) {
|
|
let data2 = d.data;
|
|
test.reload({
|
|
data:data2
|
|
});
|
|
},
|
|
|
|
});
|
|
|
|
outQuantityCheck = function (placeId) {
|
|
layer.prompt({
|
|
formType: 0,
|
|
value: quantity,
|
|
title: '请输入转移数量',
|
|
}, function (value, index, elem) {
|
|
if (Number(value) > Number(quantity)) {
|
|
layer.msg("非法值,重新输入!", {
|
|
icon: 0,
|
|
time: 500
|
|
},
|
|
function () {
|
|
// 修改数量为当前数
|
|
$(elem).val(quantity)
|
|
})
|
|
} else {
|
|
// 修改当前物料所在库位
|
|
if(!flagForForm){
|
|
flagForForm = true;
|
|
var req = {};
|
|
req.quantity = value;
|
|
req.mid = mid;
|
|
req.fromPlaceId = fromPlaceId;
|
|
req.toPlaceId = placeId;
|
|
req.unit = unit;
|
|
req.depositoryId = depositoryId;
|
|
$.ajax({
|
|
url:"/material/editPlaceMaterial",
|
|
type: 'post',
|
|
dataType: 'json',
|
|
contentType: "application/json;charset=utf-8",
|
|
data: JSON.stringify(req),
|
|
success:function (data) {
|
|
if(data.status === 205){
|
|
layer.msg("修改成功",{
|
|
icon:1,
|
|
time:1000
|
|
},function () {
|
|
var index = parent.layer.getFrameIndex(window.name);
|
|
parent.layer.close(index);
|
|
})
|
|
}else{
|
|
layer.msg(data.statusInfo.detail,{
|
|
icon:5,
|
|
time:1000
|
|
},function () {
|
|
flagForForm = false;
|
|
var index = parent.layer.getFrameIndex(window.name);
|
|
parent.layer.close(index);
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
}
|
|
})
|
|
</script>
|
|
</body>
|
|
</html>
|