Browse Source

合并盘点时通过物料盘点与位置盘点的表格页面

lwx_dev
erdanergou 3 years ago
parent
commit
eb3b16ffa8
  1. 1
      src/main/resources/static/js/lay-module/inputTag.js
  2. 18
      src/main/resources/templates/pages/post/selectManager.html
  3. 669
      src/main/resources/templates/pages/stockTaking/stockTaking.html
  4. 669
      target/classes/templates/pages/stockTaking/stockTaking.html

1
src/main/resources/static/js/lay-module/inputTag.js

@ -77,7 +77,6 @@
createItem() {
var value = this.elem.val().trim();
if (this.options.beforeCreate && typeof this.options.beforeCreate === 'function') {
var modifiedValue = this.options.beforeCreate(this.copyData, value);
if (typeof modifiedValue == 'string' && modifiedValue) {

18
src/main/resources/templates/pages/post/selectManager.html

@ -26,18 +26,16 @@
if (data.children !== undefined) {
return false;
}
var name = $("#departmentManager", window.parent.document).val();
var id = $("#departmentManagerId", window.parent.document).val();
$("#departmentManager", window.parent.document).val(data.title);
// if (name === undefined || name === null || name === "") {
// } else {
// $("#departmentManager", window.parent.document).val(name + data.title);
// }
if (id === undefined || id === null || id === "") {
$("#departmentManagerId", window.parent.document).val(data.id + ",");
var idForMaterial = $("#departmentManagerIdForMaterial", window.parent.document).val();
$("#departmentManagerForMaterial", window.parent.document).val(data.title);
$("#departmentManagerForLocation", window.parent.document).val(data.title);
if (idForMaterial === undefined || idForMaterial === null || idForMaterial === "") {
$("#departmentManagerIdForMaterial", window.parent.document).val(data.id + ",");
$("#departmentManagerIdForLocation", window.parent.document).val(data.id + ",");
} else {
$("#departmentManagerId", window.parent.document).val(id + data.id + ",");
$("#departmentManagerIdForMaterial", window.parent.document).val(idForMaterial + data.id + ",");
$("#departmentManagerIdForLocation", window.parent.document).val(idForMaterial + data.id + ",");
}
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);

669
src/main/resources/templates/pages/stockTaking/stockTaking.html

@ -46,108 +46,211 @@
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layui-fluid">
<div class="layui-tab">
<ul class="layui-tab-title" style="text-align: center">
<li class="layui-this">物料盘点</li>
<li class="layui-this">位置盘点</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto; ">
<div carousel-item style="overflow: inherit">
<div>
<form class="layui-form"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1" id="form1">
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px">
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料名称:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input type="text" placeholder="请选择物料" class="layui-input"
style="border-style: none"
id="openSonByMaterial"
onblur="selectMaterialByName(this)"
lay-verify="required"/>
<i class="layui-icon layui-icon-search"
style="display: inline;"
id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
<input type="text" name="mid" class="layui-input" id="mid"
style="display: none" lay-verify="required"/>
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto; ">
<div carousel-item style="overflow: inherit">
<div>
<div class="layui-fluid">
<div class="layui-card">
<form class="layui-form"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1" id="form1">
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px">
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料名称:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input type="text" placeholder="请选择物料" class="layui-input"
style="border-style: none"
id="openSonByMaterial"
onblur="selectMaterialByName(this)"
lay-verify="required"/>
<i class="layui-icon layui-icon-search"
style="display: inline;"
id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
</div>
<input type="text" name="mid" class="layui-input" id="mid"
style="display: none" lay-verify="required"/>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料编码:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input id="code" name="code" type="text"
placeholder="请填写入物料编码"
value=""
onblur="selectCode(this)"
class="layui-input" lay-verify="required"
style="border-style: none">
<img src="/static/images/search.ico" height="16" width="16"
id="qrCodeImg"
style="margin-top: 10px"
onclick="scanCodeInStorage(this)">
<input id="qrCode" name="qrCode" type="text"
style="display:none;">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">负责人:</label>
<div class="layui-input-block">
<div class="fairy-tag-container" style="border-style: none">
<div class="inputdiv">
<input type="text" id="departmentManagerForMaterial"
style="display: none"
th:value="${departmentHeadName}"/>
<i class="layui-icon layui-icon-search"
style="display: inline;right: 0;position: absolute;"
id="selectdepartmentManagerForMaterial"></i>
<input type="text" id="departmentManagerIdForMaterial"
name="departmentManagerId"
th:value="${departmentHeadId}"
class="layui-input" style="display: none"
lay-verify="required"/>
</div>
</div>
</div>
</div>
</div>
</form>
<table class="layui-hide" id="currentTableForMaterial"
lay-filter="currentTableFilterForMaterial"
style="margin-top: 123px"></table>
<!-- 提交按钮-->
<div class="layui-form-item" style="margin-top: 10px;">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-normal layui-btn-lg"
submitType="Material"
lay-submit
lay-filter="formStep">
&emsp;提交&emsp;
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料编码:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input id="code" name="code" type="text"
placeholder="请填写入物料编码"
value=""
onblur="selectCode(this)"
class="layui-input" lay-verify="required"
style="border-style: none">
<img src="/static/images/search.ico" height="16" width="16"
id="qrCodeImg"
style="margin-top: 10px"
onclick="scanCodeInStorage(this)">
<input id="qrCode" name="qrCode" type="text"
style="display:none;">
</div>
<!-- 下一步-->
<div>
<form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div style="text-align: center;margin-top: 90px;">
<i class="layui-icon layui-circle"
style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
<div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
提交成功
</div>
<div style="text-align: center;margin-top: 50px;">
<button class="layui-btn next">再填写一次</button>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">负责人:</label>
<div class="layui-input-block">
<div class="fairy-tag-container" style="border-style: none">
<div class="inputdiv">
<input type="text" id="departmentManager" style="display: none"
th:value="${departmentHeadName}"/>
<i class="layui-icon layui-icon-search"
style="display: inline;right: 0;position: absolute;"
id="selectdepartmentManager"></i>
<input type="text" id="departmentManagerId"
name="departmentManagerId"
th:value="${departmentHeadId}"
class="layui-input" style="display: none"
lay-verify="required"/>
</form>
</div>
</div>
</div>
</div>
<div class="layui-tab-item">
<div class="layui-carousel" id="stepForm1" lay-filter="stepForm" style="margin: 0 auto; ">
<div carousel-item style="overflow: inherit">
<div>
<div class="layui-card">
<form class="layui-form"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1">
<div class="layui-card-body" style="padding-right: 0px">
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">盘点位置:</label>
<div class="layui-input-block">
<div class="inputdiv">
<input type="text" placeholder="请选择盘点位置" class="layui-input"
style="border-style: none"
id="openSonByDepository" readonly
lay-verify="required"/>
<img src="/static/images/search.ico" height="16" width="16"
id="scanCodeImg"
style="margin-top: 10px" onclick="scanCode(this)">
</div>
<input type="text" name="depositoryId" class="layui-input"
id="depositoryId"
style="display: none" lay-verify="required"/>
<input type="text" name="placeId" class="layui-input"
id="placeId"
style="display: none" lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">负责人:</label>
<div class="layui-input-block">
<div class="fairy-tag-container" style="border-style: none">
<div class="inputdiv">
<input type="text" id="departmentManagerForLocation"
style="display: none"
th:value="${departmentHeadName}"/>
<i class="layui-icon layui-icon-search"
id="selectdepartmentManagerForLocation"
style="display: inline;right: 0;position: absolute;"
></i>
<input type="text" id="departmentManagerIdForLocation"
name="departmentManagerId"
th:value="${departmentHeadId}"
class="layui-input" style="display: none"
lay-verify="required"/>
</div>
</div>
</div>
</div>
</div>
</form>
<table class="layui-hide" lay-filter="currentTableFilterForLocation"
id="currentTableForLocation"
style="margin-top: 123px"></table>
<!-- 提交按钮-->
<div class="layui-form-item" style="margin-top: 10px;">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-normal layui-btn-lg"
submitType="Location"
lay-submit
lay-filter="formStep">
&emsp;提交&emsp;
</button>
</div>
</div>
</div>
</div>
</form>
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"
style="margin-top: 123px"></table>
<!-- 提交按钮-->
<div class="layui-form-item" style="margin-top: 10px;">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-normal layui-btn-lg"
lay-submit
lay-filter="formStep">
&emsp;提交&emsp;
</button>
<!-- 下一步-->
<div>
<form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div style="text-align: center;margin-top: 90px;">
<i class="layui-icon layui-circle"
style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
<div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
提交成功
</div>
<div style="text-align: center;margin-top: 50px;">
<button class="layui-btn next">再填写一次</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- 下一步-->
<div>
<form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div style="text-align: center;margin-top: 90px;">
<i class="layui-icon layui-circle"
style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
<div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
提交成功
</div>
<div style="text-align: center;margin-top: 50px;">
<button class="layui-btn next">再填写一次</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
@ -188,11 +291,20 @@
}
// 用于计算盘点结果
function calculate(obj) {
function calculateForMaterial(obj) {
}
function updateTableShow() {
// 用于计算盘点结果
function calculateForLocation(obj) {
}
function updateTableShowForMaterial() {
}
function updateTableShowForLocation() {
}
@ -200,7 +312,8 @@
let depositoryId;
let placeId;
// 用于存储当前选择的负责人
let departmentManagerId;
let departmentManagerIdForMaterial;
let departmentManagerIdForLocation;
layui.use(['form', 'step', 'flow', 'table', 'inputTag'], function () {
var $ = layui.$,
form = layui.form,
@ -208,7 +321,8 @@
inputTag = layui.inputTag,
dropdown = layui.dropdown, //下拉菜单
step = layui.step;
departmentManagerId = $("#departmentManagerId").val();
departmentManagerIdForMaterial = $("#departmentManagerIdForMaterial").val();
departmentManagerIdForLocation = $("#departmentManagerIdForLocation").val();
// 用于分步表单加载
step.render({
@ -223,36 +337,66 @@
}]
});
// 用于分步表单加载
step.render({
elem: '#stepForm1',
filter: 'stepForm',
width: '100%', //设置容器宽度
height: '900px',
stepItems: [{
title: '填写信息'
}, {
title: '提交成功'
}]
});
let tagData = [];
let tempData = $("#departmentManager").val().split(",");
let tempData = $("#departmentManagerForMaterial").val().split(",");
$.each(tempData, function (index, item) {
if (item !== "") {
tagData.push(item)
}
});
$("#departmentManager").val("");
$("#departmentManagerForMaterial").val("");
$("#departmentManagerForLocation").val("");
let tagLabel = inputTag.render({
elem: '#departmentManager',
elem: '#departmentManagerForMaterial',
data: tagData,//初始值
removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
createKeyNum: 13,//创建按键编号 默认,Enter 键
onChange: function (data, value, type, index) {
if (type === "remove") {
let split = departmentManagerIdForMaterial.split(",");
split.splice(index, 1);
departmentManagerIdForMaterial = split.toString();
$("#departmentManagerIdForMaterial").val(departmentManagerIdForMaterial);
}
}
});
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 = departmentManagerId.split(",");
let split = departmentManagerIdForLocation.split(",");
split.splice(index, 1);
departmentManagerId = split.toString();
$("#departmentManagerId").val(departmentManagerId);
departmentManagerIdForLocation = split.toString();
$("#departmentManagerIdForLocation").val(departmentManagerIdForLocation);
}
}
});
updateTableShow = function () {
updateTableShowForMaterial = function () {
let req = {};
req.mid = $("#mid").val();
table.reload('currentTableId', {
table.reload('currentTableForMaterial', {
url: '/material/findMaterialByConditionForStockTaking',
page: {
curr: 1
@ -262,7 +406,7 @@
};
table.render({
elem: "#currentTableId",
elem: "#currentTableForMaterial",
url: '/material/findMaterialByConditionForStockTaking',
parseData: function (res) { //res 即为原始返回的数据
return {
@ -310,7 +454,7 @@
$.each(res['data'], function (i, j) {
let takingUnit = j["takingUnit"];
if (takingUnit !== null) {
let parentItem = $("[lay-id='currentTableId'] tr:eq(" + (i + 1) + ")");
let parentItem = $("[lay-id='currentTableForMaterial'] tr:eq(" + (i + 1) + ")");
let unitHandleItem = parentItem.children()[6];
let quantityHandleItem = parentItem.children()[7];
unitHandleItem.childNodes[0].childNodes[1].childNodes[0].data = takingUnit;
@ -322,7 +466,7 @@
// 用于打开负责人树形菜单
$("#selectdepartmentManager").on('click', function () {
$("#selectdepartmentManagerForMaterial").on('click', function () {
layer.open({
type: 2,
title: '弹窗内容',
@ -334,7 +478,7 @@
fixed: false,
content: '/selectManager',
end: function () {
departmentManagerId = $("#departmentManagerId").val();
departmentManagerIdForMaterial = $("#departmentManagerIdForMaterial").val();
tagLabel.createItem();
},
success: function (layero, index) {
@ -348,13 +492,44 @@
});
// 用于打开负责人树形菜单
$("#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',
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%');
}
});
});
// 用于提交盘点情况
form.on('submit(formStep)', function (data) {
data = data.field;
data.depositoryId = depositoryId;
data.placeId = placeId;
data.departmentManager = departmentManagerId;
let submitType = this.getAttribute("submitType");
if ("Material" === submitType) {
data.departmentManager = departmentManagerIdForMaterial;
} else if ("Location" === submitType) {
data.departmentManager = departmentManagerIdForLocation;
}
$.ajax({
url: "/stockTaking/submitStockTaking",
type: 'post',
@ -393,14 +568,12 @@
});
table.on('edit(currentTableFilter)', function (obj) {
table.on('edit(currentTableFilterForMaterial)', function (obj) {
obj.update({stockTakingQuantity: obj.value});//修改当前行数据
calculate(obj);
calculateForMaterial(obj);
});
// 用于监听下拉菜单
table.on('tool(currentTableFilter)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
table.on('tool(currentTableFilterForMaterial)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
var data = obj.data //获得当前行数据
, layEvent = obj.event; //获得 lay-event 对应的值
if (layEvent === 'more') {
@ -431,7 +604,7 @@
});
// 用于计算盘点结果
calculate = function (obj) {
calculateForMaterial = function (obj) {
let oldInventory = Number(obj.tr[0].childNodes[7].childNodes[0].innerText);
let nowInventory = Number(obj.value);
let number = 0;
@ -459,7 +632,7 @@
req.takingResultString = takingResultString;
req.id = obj.data.id + "";
req.unit = obj.tr[0].childNodes[6].childNodes[0].innerText;
req.oldInventory = oldInventory+"";
req.oldInventory = oldInventory + "";
$.ajax({
url: "/stockTaking/temporaryStorageForTakingResult",
dataType: "json",
@ -475,7 +648,7 @@
var data = obj.value;
var req = {};
data = data.split(",")[0];
if(data !== ""){
if (data !== "") {
req.mname = data;
$.ajax({
url: "/material/findMaterialByCondition",
@ -486,9 +659,9 @@
success: function (d) {
if (d.count > 1) {
layer.msg("请点击右侧搜索确定物品");
$("#openSonByMaterial").val("");
$("#mid").val("");
$("#code").val("");
$("#openSonByMaterial").val("");
$("#mid").val("");
$("#code").val("");
return false;
} else if (d.count === 0) {
layer.msg("没有该物品,请确认输入是否正确");
@ -502,7 +675,7 @@
$("#mid").val(material.mid);
$("#code").val(material.code);
form.render();
updateTableShow();
updateTableShowForMaterial();
}
}
});
@ -518,7 +691,7 @@
var req = {};
req.code = code;
req.type = "out";
if(code !== ""){
if (code !== "") {
$.ajax({
url: "/material/findMatrialByCode",
type: "get",
@ -528,21 +701,21 @@
success: function (d) {
var d = d.data;
if (d == null) {
layer.msg("仓库中暂无该物料",{
icon:0,
time:1000
},function () {
layer.msg("仓库中暂无该物料", {
icon: 0,
time: 1000
}, function () {
$("#openSonByMaterial").val("");
$("#mid").val("");
$("#code").val("");
updateTableShow();
updateTableShowForMaterial();
});
} else {
$("#openSonByMaterial").val(d.mname);
$("#mid").val(d.mid);
form.render();
updateTableShow();
form.render();
updateTableShowForMaterial();
}
}
@ -551,6 +724,256 @@
};
table.render({
elem: "#currentTableForLocation",
url: '/material/findInventoryForStockTaking',
parseData: function (res) { //res 即为原始返回的数据
return {
"status": res.status, //解析接口状态
"message": res.statusInfo.message, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
},
request: {
pageName: 'page', //页码的参数名称,默认:page
limitName: 'size' //每页数据量的参数名,默认:limit
},
response: {
statusName: 'status' //规定数据状态的字段名称,默认:code
, statusCode: 200 //规定成功的状态码,默认:0
, msgName: 'message' //规定状态信息的字段名称,默认:msg
, countName: 'count' //规定数据总数的字段名称,默认:count
, dataName: 'data' //规定数据列表的字段名称,默认:data
},
where: {
depositoryId: "-1"
},
height: 'full-255',//固定高度-即固定表头固定第一行首行
cols: [
[
{field: 'mcode', width: 150, title: '存货编码', fixed: 'left'},
{field: 'mname', width: 150, title: '物料名称'},
{field: 'typeName', width: 100, title: '物料种类'},
{field: 'version', width: 150, title: '规格型号',},
{field: 'pcode', width: 150, title: '所处库位',},
{title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
{field: 'inventory', width: 100, title: '库存数'},
{field: 'stockTakingQuantity', width: 100, title: '盘点数', edit: 'quantity'},
{field: 'takingResultString', width: 100, title: '盘点结果'},
{field: 'takingInventory', width: 100, title: '盈亏数量'},
]
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
done: function (res, curr, count) {
$.each(res['data'], function (i, j) {
let takingUnit = j["takingUnit"];
if (takingUnit !== null) {
let parentItem = $("[lay-id='currentTableForLocation'] tr:eq(" + (i + 1) + ")");
let unitHandleItem = parentItem.children()[5];
let quantityHandleItem = parentItem.children()[6];
unitHandleItem.childNodes[0].childNodes[1].childNodes[0].data = takingUnit;
quantityHandleItem.childNodes[0].innerText = j["splitInventory"][takingUnit];
}
});
}
});
// 扫码盘点位置
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();
}
})
}
})
};
table.on('edit(currentTableFilterForLocation)', function (obj) {
obj.update({stockTakingQuantity: obj.value});//修改当前行数据
calculateForLocation(obj);
});
// 用于监听下拉菜单
table.on('tool(currentTableFilterForLocation)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
var data = obj.data //获得当前行数据
, layEvent = obj.event; //获得 lay-event 对应的值
if (layEvent === 'more') {
let splitInfoList = obj.data.splitInfoList;
if (splitInfoList.length > 0) {
let dropDownDataList = [];
for (var i = 0; i < splitInfoList.length; i++) {
let dropDownData = {};
dropDownData.title = splitInfoList[i].newUnit;
dropDownData.id = obj.data.id;
dropDownDataList.push(dropDownData);
}
dropdown.render({
elem: this //触发事件的 DOM 对象
, show: true //外部事件触发即显示
, data: dropDownDataList
, click: function (unit) {
this.elem[0].childNodes[0].data = unit.title;
obj.tr[0].childNodes[6].childNodes[0].innerText = obj.data.splitInventory[unit.title];
}
, align: 'right' //右对齐弹出(v2.6.8 新增)
, style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
})
}
//下拉菜单
}
});
// 用于计算盘点结果
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;
updateTableShowForLocation();
}
}
});
});
updateTableShowForLocation = function () {
let req = {};
req.depositoryId = depositoryId;
req.placeId = placeId;
table.reload('currentTableForLocation', {
url: '/material/findInventoryForStockTaking',
page: {
curr: 1
},
where: req
}, 'data');
};
});
</script>

669
target/classes/templates/pages/stockTaking/stockTaking.html

@ -46,108 +46,211 @@
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layui-fluid">
<div class="layui-tab">
<ul class="layui-tab-title" style="text-align: center">
<li class="layui-this">物料盘点</li>
<li class="layui-this">位置盘点</li>
</ul>
<div class="layui-tab-content">
<div class="layui-tab-item layui-show">
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto; ">
<div carousel-item style="overflow: inherit">
<div>
<form class="layui-form"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1" id="form1">
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px">
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料名称:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input type="text" placeholder="请选择物料" class="layui-input"
style="border-style: none"
id="openSonByMaterial"
onblur="selectMaterialByName(this)"
lay-verify="required"/>
<i class="layui-icon layui-icon-search"
style="display: inline;"
id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
<input type="text" name="mid" class="layui-input" id="mid"
style="display: none" lay-verify="required"/>
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto; ">
<div carousel-item style="overflow: inherit">
<div>
<div class="layui-fluid">
<div class="layui-card">
<form class="layui-form"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1" id="form1">
<div class="layui-card-body" id="takingHeader" style="padding-right: 0px">
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料名称:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input type="text" placeholder="请选择物料" class="layui-input"
style="border-style: none"
id="openSonByMaterial"
onblur="selectMaterialByName(this)"
lay-verify="required"/>
<i class="layui-icon layui-icon-search"
style="display: inline;"
id="selectMaterial" onclick="selectMaterial(this)"></i>
</div>
</div>
<input type="text" name="mid" class="layui-input" id="mid"
style="display: none" lay-verify="required"/>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料编码:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input id="code" name="code" type="text"
placeholder="请填写入物料编码"
value=""
onblur="selectCode(this)"
class="layui-input" lay-verify="required"
style="border-style: none">
<img src="/static/images/search.ico" height="16" width="16"
id="qrCodeImg"
style="margin-top: 10px"
onclick="scanCodeInStorage(this)">
<input id="qrCode" name="qrCode" type="text"
style="display:none;">
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">负责人:</label>
<div class="layui-input-block">
<div class="fairy-tag-container" style="border-style: none">
<div class="inputdiv">
<input type="text" id="departmentManagerForMaterial"
style="display: none"
th:value="${departmentHeadName}"/>
<i class="layui-icon layui-icon-search"
style="display: inline;right: 0;position: absolute;"
id="selectdepartmentManagerForMaterial"></i>
<input type="text" id="departmentManagerIdForMaterial"
name="departmentManagerId"
th:value="${departmentHeadId}"
class="layui-input" style="display: none"
lay-verify="required"/>
</div>
</div>
</div>
</div>
</div>
</form>
<table class="layui-hide" id="currentTableForMaterial"
lay-filter="currentTableFilterForMaterial"
style="margin-top: 123px"></table>
<!-- 提交按钮-->
<div class="layui-form-item" style="margin-top: 10px;">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-normal layui-btn-lg"
submitType="Material"
lay-submit
lay-filter="formStep">
&emsp;提交&emsp;
</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">物料编码:</label>
<div class="layui-input-block" style="margin: 0px;">
<div class="inputdiv">
<input id="code" name="code" type="text"
placeholder="请填写入物料编码"
value=""
onblur="selectCode(this)"
class="layui-input" lay-verify="required"
style="border-style: none">
<img src="/static/images/search.ico" height="16" width="16"
id="qrCodeImg"
style="margin-top: 10px"
onclick="scanCodeInStorage(this)">
<input id="qrCode" name="qrCode" type="text"
style="display:none;">
</div>
<!-- 下一步-->
<div>
<form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div style="text-align: center;margin-top: 90px;">
<i class="layui-icon layui-circle"
style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
<div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
提交成功
</div>
<div style="text-align: center;margin-top: 50px;">
<button class="layui-btn next">再填写一次</button>
</div>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">负责人:</label>
<div class="layui-input-block">
<div class="fairy-tag-container" style="border-style: none">
<div class="inputdiv">
<input type="text" id="departmentManager" style="display: none"
th:value="${departmentHeadName}"/>
<i class="layui-icon layui-icon-search"
style="display: inline;right: 0;position: absolute;"
id="selectdepartmentManager"></i>
<input type="text" id="departmentManagerId"
name="departmentManagerId"
th:value="${departmentHeadId}"
class="layui-input" style="display: none"
lay-verify="required"/>
</form>
</div>
</div>
</div>
</div>
<div class="layui-tab-item">
<div class="layui-carousel" id="stepForm1" lay-filter="stepForm" style="margin: 0 auto; ">
<div carousel-item style="overflow: inherit">
<div>
<div class="layui-card">
<form class="layui-form"
style="margin: 0 auto;max-width: 700px;"
lay-filter="form1">
<div class="layui-card-body" style="padding-right: 0px">
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">盘点位置:</label>
<div class="layui-input-block">
<div class="inputdiv">
<input type="text" placeholder="请选择盘点位置" class="layui-input"
style="border-style: none"
id="openSonByDepository" readonly
lay-verify="required"/>
<img src="/static/images/search.ico" height="16" width="16"
id="scanCodeImg"
style="margin-top: 10px" onclick="scanCode(this)">
</div>
<input type="text" name="depositoryId" class="layui-input"
id="depositoryId"
style="display: none" lay-verify="required"/>
<input type="text" name="placeId" class="layui-input"
id="placeId"
style="display: none" lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label" style="height: 40px;">负责人:</label>
<div class="layui-input-block">
<div class="fairy-tag-container" style="border-style: none">
<div class="inputdiv">
<input type="text" id="departmentManagerForLocation"
style="display: none"
th:value="${departmentHeadName}"/>
<i class="layui-icon layui-icon-search"
id="selectdepartmentManagerForLocation"
style="display: inline;right: 0;position: absolute;"
></i>
<input type="text" id="departmentManagerIdForLocation"
name="departmentManagerId"
th:value="${departmentHeadId}"
class="layui-input" style="display: none"
lay-verify="required"/>
</div>
</div>
</div>
</div>
</div>
</form>
<table class="layui-hide" lay-filter="currentTableFilterForLocation"
id="currentTableForLocation"
style="margin-top: 123px"></table>
<!-- 提交按钮-->
<div class="layui-form-item" style="margin-top: 10px;">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-normal layui-btn-lg"
submitType="Location"
lay-submit
lay-filter="formStep">
&emsp;提交&emsp;
</button>
</div>
</div>
</div>
</div>
</form>
<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"
style="margin-top: 123px"></table>
<!-- 提交按钮-->
<div class="layui-form-item" style="margin-top: 10px;">
<div class="layui-input-block">
<button type="button" class="layui-btn layui-btn-normal layui-btn-lg"
lay-submit
lay-filter="formStep">
&emsp;提交&emsp;
</button>
<!-- 下一步-->
<div>
<form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div style="text-align: center;margin-top: 90px;">
<i class="layui-icon layui-circle"
style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
<div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
提交成功
</div>
<div style="text-align: center;margin-top: 50px;">
<button class="layui-btn next">再填写一次</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- 下一步-->
<div>
<form class="layui-form" style="margin: 0 auto;max-width: 460px;padding-top: 40px;">
<div style="text-align: center;margin-top: 90px;">
<i class="layui-icon layui-circle"
style="color: white;font-size:30px;font-weight:bold;background: #52C41A;padding: 20px;line-height: 80px;">&#xe605;</i>
<div style="font-size: 24px;color: #333;font-weight: 500;margin-top: 30px;">
提交成功
</div>
<div style="text-align: center;margin-top: 50px;">
<button class="layui-btn next">再填写一次</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
@ -188,11 +291,20 @@
}
// 用于计算盘点结果
function calculate(obj) {
function calculateForMaterial(obj) {
}
function updateTableShow() {
// 用于计算盘点结果
function calculateForLocation(obj) {
}
function updateTableShowForMaterial() {
}
function updateTableShowForLocation() {
}
@ -200,7 +312,8 @@
let depositoryId;
let placeId;
// 用于存储当前选择的负责人
let departmentManagerId;
let departmentManagerIdForMaterial;
let departmentManagerIdForLocation;
layui.use(['form', 'step', 'flow', 'table', 'inputTag'], function () {
var $ = layui.$,
form = layui.form,
@ -208,7 +321,8 @@
inputTag = layui.inputTag,
dropdown = layui.dropdown, //下拉菜单
step = layui.step;
departmentManagerId = $("#departmentManagerId").val();
departmentManagerIdForMaterial = $("#departmentManagerIdForMaterial").val();
departmentManagerIdForLocation = $("#departmentManagerIdForLocation").val();
// 用于分步表单加载
step.render({
@ -223,36 +337,66 @@
}]
});
// 用于分步表单加载
step.render({
elem: '#stepForm1',
filter: 'stepForm',
width: '100%', //设置容器宽度
height: '900px',
stepItems: [{
title: '填写信息'
}, {
title: '提交成功'
}]
});
let tagData = [];
let tempData = $("#departmentManager").val().split(",");
let tempData = $("#departmentManagerForMaterial").val().split(",");
$.each(tempData, function (index, item) {
if (item !== "") {
tagData.push(item)
}
});
$("#departmentManager").val("");
$("#departmentManagerForMaterial").val("");
$("#departmentManagerForLocation").val("");
let tagLabel = inputTag.render({
elem: '#departmentManager',
elem: '#departmentManagerForMaterial',
data: tagData,//初始值
removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
createKeyNum: 13,//创建按键编号 默认,Enter 键
onChange: function (data, value, type, index) {
if (type === "remove") {
let split = departmentManagerIdForMaterial.split(",");
split.splice(index, 1);
departmentManagerIdForMaterial = split.toString();
$("#departmentManagerIdForMaterial").val(departmentManagerIdForMaterial);
}
}
});
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 = departmentManagerId.split(",");
let split = departmentManagerIdForLocation.split(",");
split.splice(index, 1);
departmentManagerId = split.toString();
$("#departmentManagerId").val(departmentManagerId);
departmentManagerIdForLocation = split.toString();
$("#departmentManagerIdForLocation").val(departmentManagerIdForLocation);
}
}
});
updateTableShow = function () {
updateTableShowForMaterial = function () {
let req = {};
req.mid = $("#mid").val();
table.reload('currentTableId', {
table.reload('currentTableForMaterial', {
url: '/material/findMaterialByConditionForStockTaking',
page: {
curr: 1
@ -262,7 +406,7 @@
};
table.render({
elem: "#currentTableId",
elem: "#currentTableForMaterial",
url: '/material/findMaterialByConditionForStockTaking',
parseData: function (res) { //res 即为原始返回的数据
return {
@ -310,7 +454,7 @@
$.each(res['data'], function (i, j) {
let takingUnit = j["takingUnit"];
if (takingUnit !== null) {
let parentItem = $("[lay-id='currentTableId'] tr:eq(" + (i + 1) + ")");
let parentItem = $("[lay-id='currentTableForMaterial'] tr:eq(" + (i + 1) + ")");
let unitHandleItem = parentItem.children()[6];
let quantityHandleItem = parentItem.children()[7];
unitHandleItem.childNodes[0].childNodes[1].childNodes[0].data = takingUnit;
@ -322,7 +466,7 @@
// 用于打开负责人树形菜单
$("#selectdepartmentManager").on('click', function () {
$("#selectdepartmentManagerForMaterial").on('click', function () {
layer.open({
type: 2,
title: '弹窗内容',
@ -334,7 +478,7 @@
fixed: false,
content: '/selectManager',
end: function () {
departmentManagerId = $("#departmentManagerId").val();
departmentManagerIdForMaterial = $("#departmentManagerIdForMaterial").val();
tagLabel.createItem();
},
success: function (layero, index) {
@ -348,13 +492,44 @@
});
// 用于打开负责人树形菜单
$("#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',
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%');
}
});
});
// 用于提交盘点情况
form.on('submit(formStep)', function (data) {
data = data.field;
data.depositoryId = depositoryId;
data.placeId = placeId;
data.departmentManager = departmentManagerId;
let submitType = this.getAttribute("submitType");
if ("Material" === submitType) {
data.departmentManager = departmentManagerIdForMaterial;
} else if ("Location" === submitType) {
data.departmentManager = departmentManagerIdForLocation;
}
$.ajax({
url: "/stockTaking/submitStockTaking",
type: 'post',
@ -393,14 +568,12 @@
});
table.on('edit(currentTableFilter)', function (obj) {
table.on('edit(currentTableFilterForMaterial)', function (obj) {
obj.update({stockTakingQuantity: obj.value});//修改当前行数据
calculate(obj);
calculateForMaterial(obj);
});
// 用于监听下拉菜单
table.on('tool(currentTableFilter)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
table.on('tool(currentTableFilterForMaterial)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
var data = obj.data //获得当前行数据
, layEvent = obj.event; //获得 lay-event 对应的值
if (layEvent === 'more') {
@ -431,7 +604,7 @@
});
// 用于计算盘点结果
calculate = function (obj) {
calculateForMaterial = function (obj) {
let oldInventory = Number(obj.tr[0].childNodes[7].childNodes[0].innerText);
let nowInventory = Number(obj.value);
let number = 0;
@ -459,7 +632,7 @@
req.takingResultString = takingResultString;
req.id = obj.data.id + "";
req.unit = obj.tr[0].childNodes[6].childNodes[0].innerText;
req.oldInventory = oldInventory+"";
req.oldInventory = oldInventory + "";
$.ajax({
url: "/stockTaking/temporaryStorageForTakingResult",
dataType: "json",
@ -475,7 +648,7 @@
var data = obj.value;
var req = {};
data = data.split(",")[0];
if(data !== ""){
if (data !== "") {
req.mname = data;
$.ajax({
url: "/material/findMaterialByCondition",
@ -486,9 +659,9 @@
success: function (d) {
if (d.count > 1) {
layer.msg("请点击右侧搜索确定物品");
$("#openSonByMaterial").val("");
$("#mid").val("");
$("#code").val("");
$("#openSonByMaterial").val("");
$("#mid").val("");
$("#code").val("");
return false;
} else if (d.count === 0) {
layer.msg("没有该物品,请确认输入是否正确");
@ -502,7 +675,7 @@
$("#mid").val(material.mid);
$("#code").val(material.code);
form.render();
updateTableShow();
updateTableShowForMaterial();
}
}
});
@ -518,7 +691,7 @@
var req = {};
req.code = code;
req.type = "out";
if(code !== ""){
if (code !== "") {
$.ajax({
url: "/material/findMatrialByCode",
type: "get",
@ -528,21 +701,21 @@
success: function (d) {
var d = d.data;
if (d == null) {
layer.msg("仓库中暂无该物料",{
icon:0,
time:1000
},function () {
layer.msg("仓库中暂无该物料", {
icon: 0,
time: 1000
}, function () {
$("#openSonByMaterial").val("");
$("#mid").val("");
$("#code").val("");
updateTableShow();
updateTableShowForMaterial();
});
} else {
$("#openSonByMaterial").val(d.mname);
$("#mid").val(d.mid);
form.render();
updateTableShow();
form.render();
updateTableShowForMaterial();
}
}
@ -551,6 +724,256 @@
};
table.render({
elem: "#currentTableForLocation",
url: '/material/findInventoryForStockTaking',
parseData: function (res) { //res 即为原始返回的数据
return {
"status": res.status, //解析接口状态
"message": res.statusInfo.message, //解析提示文本
"count": res.count, //解析数据长度
"data": res.data //解析数据列表
};
},
request: {
pageName: 'page', //页码的参数名称,默认:page
limitName: 'size' //每页数据量的参数名,默认:limit
},
response: {
statusName: 'status' //规定数据状态的字段名称,默认:code
, statusCode: 200 //规定成功的状态码,默认:0
, msgName: 'message' //规定状态信息的字段名称,默认:msg
, countName: 'count' //规定数据总数的字段名称,默认:count
, dataName: 'data' //规定数据列表的字段名称,默认:data
},
where: {
depositoryId: "-1"
},
height: 'full-255',//固定高度-即固定表头固定第一行首行
cols: [
[
{field: 'mcode', width: 150, title: '存货编码', fixed: 'left'},
{field: 'mname', width: 150, title: '物料名称'},
{field: 'typeName', width: 100, title: '物料种类'},
{field: 'version', width: 150, title: '规格型号',},
{field: 'pcode', width: 150, title: '所处库位',},
{title: '计量单位', width: 200, templet: '#changeUnit', align: "center"},
{field: 'inventory', width: 100, title: '库存数'},
{field: 'stockTakingQuantity', width: 100, title: '盘点数', edit: 'quantity'},
{field: 'takingResultString', width: 100, title: '盘点结果'},
{field: 'takingInventory', width: 100, title: '盈亏数量'},
]
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
skin: 'line',
done: function (res, curr, count) {
$.each(res['data'], function (i, j) {
let takingUnit = j["takingUnit"];
if (takingUnit !== null) {
let parentItem = $("[lay-id='currentTableForLocation'] tr:eq(" + (i + 1) + ")");
let unitHandleItem = parentItem.children()[5];
let quantityHandleItem = parentItem.children()[6];
unitHandleItem.childNodes[0].childNodes[1].childNodes[0].data = takingUnit;
quantityHandleItem.childNodes[0].innerText = j["splitInventory"][takingUnit];
}
});
}
});
// 扫码盘点位置
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();
}
})
}
})
};
table.on('edit(currentTableFilterForLocation)', function (obj) {
obj.update({stockTakingQuantity: obj.value});//修改当前行数据
calculateForLocation(obj);
});
// 用于监听下拉菜单
table.on('tool(currentTableFilterForLocation)', function (obj) { //注:tool 是工具条事件名,test 是 table 原始容器的属性 lay-filter="对应的值"
var data = obj.data //获得当前行数据
, layEvent = obj.event; //获得 lay-event 对应的值
if (layEvent === 'more') {
let splitInfoList = obj.data.splitInfoList;
if (splitInfoList.length > 0) {
let dropDownDataList = [];
for (var i = 0; i < splitInfoList.length; i++) {
let dropDownData = {};
dropDownData.title = splitInfoList[i].newUnit;
dropDownData.id = obj.data.id;
dropDownDataList.push(dropDownData);
}
dropdown.render({
elem: this //触发事件的 DOM 对象
, show: true //外部事件触发即显示
, data: dropDownDataList
, click: function (unit) {
this.elem[0].childNodes[0].data = unit.title;
obj.tr[0].childNodes[6].childNodes[0].innerText = obj.data.splitInventory[unit.title];
}
, align: 'right' //右对齐弹出(v2.6.8 新增)
, style: 'box-shadow: 1px 1px 10px rgb(0 0 0 / 12%);' //设置额外样式
})
}
//下拉菜单
}
});
// 用于计算盘点结果
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;
updateTableShowForLocation();
}
}
});
});
updateTableShowForLocation = function () {
let req = {};
req.depositoryId = depositoryId;
req.placeId = placeId;
table.reload('currentTableForLocation', {
url: '/material/findInventoryForStockTaking',
page: {
curr: 1
},
where: req
}, 'data');
};
});
</script>

Loading…
Cancel
Save