|
|
|
@ -48,13 +48,33 @@ |
|
|
|
style="margin: 0 auto;max-width: 460px;padding-top: 40px;"> |
|
|
|
|
|
|
|
<div class="layui-card-body" id="cardItem"> |
|
|
|
<div class="layui-form-item"> |
|
|
|
<label class="layui-form-label">是否代领:</label> |
|
|
|
<div class="layui-input-block"> |
|
|
|
<input type="checkbox" name="flagForAgency" lay-skin="switch" |
|
|
|
lay-text="是|否"> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div id="agencyItem" style="display: none"> |
|
|
|
<div class="layui-form-item"> |
|
|
|
<label class="layui-form-label">人员:</label> |
|
|
|
<div class="layui-input-block"> |
|
|
|
<input type="text" placeholder="请选择人员" class="layui-input" |
|
|
|
id="agencyUser" |
|
|
|
onblur="selectUser(this)" |
|
|
|
/> |
|
|
|
<input type="text" name="agencyUid" class="layui-input" |
|
|
|
id="agencyUid" |
|
|
|
style="display: none"/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="layui-form-item"> |
|
|
|
<label class="layui-form-label">部门:</label> |
|
|
|
<div class="layui-input-block"> |
|
|
|
<input type="text" placeholder="请选择部门" class="layui-input" |
|
|
|
readonly |
|
|
|
id="openCompanyAdminorg" |
|
|
|
onclick="selectPost(this)" |
|
|
|
/> |
|
|
|
<input type="text" name="adminorgId" class="layui-input" |
|
|
|
id="adminorgId" |
|
|
|
@ -206,6 +226,15 @@ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function selectUser() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function SelectTheUser() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 用于标志是否为第一次提交 |
|
|
|
let flagForForm = false; |
|
|
|
layui.use(['form', 'step', 'layer', 'jquery'], function () { |
|
|
|
@ -217,6 +246,28 @@ |
|
|
|
let depositoryDisplay = $("#depositoryId").css("display"); |
|
|
|
|
|
|
|
|
|
|
|
selectPost = function (obj) { |
|
|
|
let id = obj.id; |
|
|
|
layer.open({ |
|
|
|
type: 2, |
|
|
|
title: '弹窗内容', |
|
|
|
skin: 'layui-layer-rim', |
|
|
|
maxmin: true, |
|
|
|
shadeClose: true, //点击遮罩关闭层 |
|
|
|
area: ['70%', '70%'], |
|
|
|
content: '/selectPost?id=' + id, |
|
|
|
move: '.layui-layer-title', |
|
|
|
fixed: false, |
|
|
|
success: function (layero, index) { |
|
|
|
var children = layero.children(); |
|
|
|
var content = $(children[1]); |
|
|
|
var iframeChildren = $(content.children()); |
|
|
|
content.css('height', '100%'); |
|
|
|
iframeChildren.css('height', '100%'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
$("#code").blur(function () { |
|
|
|
var code = $(this).val(); |
|
|
|
var req = {}; |
|
|
|
@ -251,7 +302,7 @@ |
|
|
|
if (depositoryDisplay !== "none") { |
|
|
|
$("#showDepository").empty(); |
|
|
|
let depositoryList = d.depositoryList; |
|
|
|
if(depositoryList !== null) { |
|
|
|
if (depositoryList !== null) { |
|
|
|
for (let i = 0; i < depositoryList.length; i++) { |
|
|
|
$("#showDepository").append(new Option(depositoryList[i].dname, depositoryList[i].id)); |
|
|
|
} |
|
|
|
@ -270,8 +321,8 @@ |
|
|
|
var data = $(this).val(); |
|
|
|
var req = {}; |
|
|
|
req.mname = data; |
|
|
|
if(data !== ""){ |
|
|
|
let loading2 = layer.open({ type: 3, shade: [0.25, '#000'], icon: 2, speed: 0}); |
|
|
|
if (data !== "") { |
|
|
|
let loading2 = layer.open({type: 3, shade: [0.25, '#000'], icon: 2, speed: 0}); |
|
|
|
$.ajax({ |
|
|
|
url: "/material/findInventoryByCondition", |
|
|
|
type: "post", |
|
|
|
@ -280,7 +331,7 @@ |
|
|
|
contentType: "application/json;charset=utf-8", |
|
|
|
success: function (d) { |
|
|
|
if (d.count > 1) { |
|
|
|
layer.msg("请点击右侧搜索确定物品",{icon:0,time:500},function () { |
|
|
|
layer.msg("请点击右侧搜索确定物品", {icon: 0, time: 500}, function () { |
|
|
|
$("#mid").val(""); |
|
|
|
$("#code").val(""); |
|
|
|
layer.close(loading2); |
|
|
|
@ -288,7 +339,7 @@ |
|
|
|
|
|
|
|
return false; |
|
|
|
} else if (d.count === 0) { |
|
|
|
layer.msg("没有该物品,请确认输入是否正确",{icon:5,time:500},function() { |
|
|
|
layer.msg("没有该物品,请确认输入是否正确", {icon: 5, time: 500}, function () { |
|
|
|
$("#mid").val(""); |
|
|
|
$("#code").val(""); |
|
|
|
layer.close(loading2); |
|
|
|
@ -306,11 +357,11 @@ |
|
|
|
$("#unit").append(new Option(item.newUnit, item.newUnit)); |
|
|
|
}); |
|
|
|
if (depositoryDisplay !== "none") { |
|
|
|
$("#showDepository" ).empty(); |
|
|
|
$("#showDepository").empty(); |
|
|
|
let depositoryList = material.depositoryList; |
|
|
|
if(depositoryList !== null){ |
|
|
|
if (depositoryList !== null) { |
|
|
|
for (let i = 0; i < depositoryList.length; i++) { |
|
|
|
$("#showDepository" ).append(new Option(depositoryList[i].dname, depositoryList[i].id)); |
|
|
|
$("#showDepository").append(new Option(depositoryList[i].dname, depositoryList[i].id)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -368,7 +419,7 @@ |
|
|
|
}, |
|
|
|
end: function () { |
|
|
|
var mid = $("#mid").val(); |
|
|
|
let loading2 = layer.open({ type: 3, shade: [0.25, '#000'], icon: 2, speed: 0}); |
|
|
|
let loading2 = layer.open({type: 3, shade: [0.25, '#000'], icon: 2, speed: 0}); |
|
|
|
$.ajax({ |
|
|
|
url: "/material/findMatrialById?mid=" + mid, |
|
|
|
type: "get", |
|
|
|
@ -389,7 +440,7 @@ |
|
|
|
if (depositoryDisplay !== "none") { |
|
|
|
$("#showDepository").empty(); |
|
|
|
let depositoryList = material.depositoryList; |
|
|
|
if(depositoryList !== null) { |
|
|
|
if (depositoryList !== null) { |
|
|
|
for (let i = 0; i < depositoryList.length; i++) { |
|
|
|
$("#showDepository").append(new Option(depositoryList[i].dname, depositoryList[i].id)); |
|
|
|
} |
|
|
|
@ -409,7 +460,7 @@ |
|
|
|
elem: '#stepForm', |
|
|
|
filter: 'stepForm', |
|
|
|
width: '100%', //设置容器宽度 |
|
|
|
height: '600px', |
|
|
|
height: '750px', |
|
|
|
stepItems: [{ |
|
|
|
title: '填写信息' |
|
|
|
}, { |
|
|
|
@ -417,6 +468,28 @@ |
|
|
|
}] |
|
|
|
}); |
|
|
|
|
|
|
|
// 监听开关 |
|
|
|
form.on('switch()', function (data) { |
|
|
|
let isAgency = data.elem.checked; //开关是否开启,true或者false |
|
|
|
if (isAgency) { |
|
|
|
// 如果开启了代领功能 |
|
|
|
$("#agencyItem").show(); |
|
|
|
// 添加必填 |
|
|
|
$("#agencyUid").attr("lay-verify", "required"); |
|
|
|
|
|
|
|
$("#openCompanyAdminorg").off("click"); |
|
|
|
|
|
|
|
} else { |
|
|
|
$("#agencyItem").hide(); |
|
|
|
// 删除必填 |
|
|
|
$("#agencyUid").removeAttr("lay-verify"); |
|
|
|
|
|
|
|
|
|
|
|
$("#openCompanyAdminorg").on('click', selectPost); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
form.on('submit(formStep)', function (data) { |
|
|
|
if (!flagForForm) { |
|
|
|
@ -529,13 +602,13 @@ |
|
|
|
unit = $("#unit").val(); |
|
|
|
|
|
|
|
} |
|
|
|
mcode = $("#code" ).val(); |
|
|
|
mcode = $("#code").val(); |
|
|
|
if (mcode === "" || mcode === undefined || mcode === null) { |
|
|
|
layer.msg("请输入物料的正确编码!", {icon: 0, time: 500}, function () { |
|
|
|
$("#quantity" ).val("") |
|
|
|
$("#quantity").val("") |
|
|
|
}); |
|
|
|
} else { |
|
|
|
let val = $("#quantity" ).val(); |
|
|
|
let val = $("#quantity").val(); |
|
|
|
if (val !== null && val !== undefined && val !== '') { |
|
|
|
var req = {}; |
|
|
|
req.mcode = mcode; |
|
|
|
@ -557,7 +630,7 @@ |
|
|
|
if (!flag) { // 如果当前数目不合适 |
|
|
|
layer.msg("当前单个仓库中物料数量不足", {icon: 0, time: 500}, function () { |
|
|
|
layer.close(loading2); |
|
|
|
$("#quantity" ).val(""); |
|
|
|
$("#quantity").val(""); |
|
|
|
}, |
|
|
|
); |
|
|
|
} else { |
|
|
|
@ -573,28 +646,6 @@ |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
selectPost = function (obj) { |
|
|
|
let id = obj.id; |
|
|
|
layer.open({ |
|
|
|
type: 2, |
|
|
|
title: '弹窗内容', |
|
|
|
skin: 'layui-layer-rim', |
|
|
|
maxmin: true, |
|
|
|
shadeClose: true, //点击遮罩关闭层 |
|
|
|
area: ['70%', '70%'], |
|
|
|
content: '/selectPost?id=' + id, |
|
|
|
move: '.layui-layer-title', |
|
|
|
fixed: false, |
|
|
|
success: function (layero, index) { |
|
|
|
var children = layero.children(); |
|
|
|
var content = $(children[1]); |
|
|
|
var iframeChildren = $(content.children()); |
|
|
|
content.css('height', '100%'); |
|
|
|
iframeChildren.css('height', '100%'); |
|
|
|
} |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
selectConstructionUnit = function (obj) { |
|
|
|
let id = obj.id; |
|
|
|
layer.open({ |
|
|
|
@ -617,6 +668,78 @@ |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// 用于选择代领用户 |
|
|
|
selectUser = function (obj) { |
|
|
|
let name = obj.value; |
|
|
|
if (name !== "") { |
|
|
|
let req = {}; |
|
|
|
req.name = name; |
|
|
|
req.scope = "department"; |
|
|
|
$.ajax({ |
|
|
|
url: "/sys/findUserByName", |
|
|
|
type: "post", |
|
|
|
data: JSON.stringify(req), |
|
|
|
dataType: 'json', |
|
|
|
contentType: "application/json;charset=utf-8", |
|
|
|
beforeSend: function () { |
|
|
|
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']}); |
|
|
|
}, |
|
|
|
success: function (res) { |
|
|
|
layer.close(this.layerIndex); |
|
|
|
let data = res.data; |
|
|
|
let count = res.count; |
|
|
|
if (count === 0) { |
|
|
|
layer.msg("部门中不存在该用户,请重试", { |
|
|
|
icon: 0, |
|
|
|
time: 1000 |
|
|
|
}, function () { |
|
|
|
$("#adminorgId").val(""); |
|
|
|
$("#openCompanyAdminorg").val(""); |
|
|
|
$("#agencyUid").val(""); |
|
|
|
$("#agencyUser").val(""); |
|
|
|
}) |
|
|
|
} else if (count > 1) { |
|
|
|
|
|
|
|
let content = ``; |
|
|
|
$.each(data, function (index, item) { |
|
|
|
let listItem = `<div class="userItem"> |
|
|
|
<button type="button" onclick="SelectTheUser(this)" name=` + item.name + ` id=` + item.id + ` adminorgname=` + item.maindeparmentname + ` adminorg=` + item.maindeparment + ` class="layui-btn layui-btn-fluid">` + item.number + "-" + item.name + `</button> |
|
|
|
</div>`; |
|
|
|
content += listItem; |
|
|
|
}); |
|
|
|
selectUserIfame = layer.open({ |
|
|
|
type: 1, |
|
|
|
title: false, |
|
|
|
area: ["70%", "70%"], |
|
|
|
content: content |
|
|
|
}) |
|
|
|
} else { |
|
|
|
let user = data[0]; |
|
|
|
$("#adminorgId").val(user.maindeparment); |
|
|
|
$("#openCompanyAdminorg").val(user.maindeparmentname); |
|
|
|
$("#agencyUid").val(user.id); |
|
|
|
$("#agencyUser").val(user.name); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 用于选定人员 |
|
|
|
SelectTheUser = function (obj) { |
|
|
|
let data = $(obj); |
|
|
|
let adminorg = data.attr("adminorg"); |
|
|
|
let adminorgName = data.attr("adminorgname"); |
|
|
|
let id = data.attr("id"); |
|
|
|
let name = data.attr("name"); |
|
|
|
$("#adminorgId").val(adminorg); |
|
|
|
$("#openCompanyAdminorg").val(adminorgName); |
|
|
|
$("#agencyUid").val(id); |
|
|
|
$("#agencyUser").val(name); |
|
|
|
layer.close(selectUserIfame) |
|
|
|
}; |
|
|
|
|
|
|
|
}) |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
|