已废弃
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.

1591 lines
89 KiB

2 years ago
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<title>仓库盘点</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">
2 years ago
<link rel="stylesheet" href="/static/css/public.css" media="all">
<link rel="stylesheet" href="/static/js/lay-module/step-lay/step.css" media="all">
<link rel="stylesheet" href="/static/css/inputTag.css">
<link rel="stylesheet" href="/static/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
<style>
.inputdiv {
display: flex;
background-color: #fff;
height: 38px;
line-height: 38px;
border: 1px solid rgb(238, 238, 238);
}
.layui-card-body {
padding: 0px;
}
.layui-form-label {
padding: 9px 0px;
text-align: left;
}
.layui-input-block {
margin-left: 80px;
}
.layui-form-select {
width: 100%;
border-style: none;
}
.lay-step {
display: none;
}
</style>
</head>
<body>
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layui-carousel" id="stepForm" lay-filter="stepForm" style="margin: 0 auto; ">
<div carousel-item style="overflow: inherit">
<div>
<fieldset class="table-search-fieldset" style="padding-left: 0px;padding-right: 0px">
<legend>库存盘点</legend>
<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">
<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="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"/>
</div>
</div>
</div>
</div>
</div>
<fieldset class="table-search-fieldset">
<legend>盘点明细</legend>
<div class="layui-card-body" id="InventoryDetails" style="padding-right: 0px">
<hr>
<i class="layui-icon layui-icon-subtraction" style="display: inline"
onclick="deleteItem(this)"></i>
<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 fairy-tag-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>
</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"
style="margin-top: 10px"
onclick="scanMaterialCodeForTaking(this)">
</div>
</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">
<select id="barCode" name="barCode"
style="border-style: none">
</select>
<img src="/static/images/search.ico" height="16" width="16"
id="barCodeImg"
style="margin-top: 10px"
onclick="scanBarCodeForTaking(this)">
</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"
id="openSonByMateralType" readonly
lay-verify="required"/>
<input type="text" id="materialTypeId" name="typeId"
placeholder="请选择物料类型" class="layui-input"
style="display: none" lay-verify="required"/>
</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
name="texture"/>
</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
name="version"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select id="unit" name="unit"></select>
</div>
</div>
<div class="layui-form-item" style="display: none" id="producedDateItem">
<label class="layui-form-label">生产日期:</label>
<div class="layui-input-block">
<!-- <input type="text" name="producedDate" id="producedDate" placeholder="请填写生产日期" onclick="selectDate(this)"-->
<!-- autocomplete="off" class="layui-input">-->
<select name="producedDate" id="producedDate">
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">库存数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" readonly id="oldInventory"
name="oldInventory" lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盘点数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" onblur="calculate(this)"
name="newInventory" lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盘点结果:</label>
<div class="layui-input-block">
<select name="takingResult" id="result">
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盈亏数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" readonly
id="Inventory_number"
name="inventory" lay-verify="required"/>
</div>
</div>
<i class="layui-icon layui-icon-addition" style="display: inline"
onclick="addItem(this)"></i>
</div>
</fieldset>
<!-- 提交按钮-->
<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>
</div>
</form>
</div>
</div>
</fieldset>
</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>
</div>
<script src="/static/lib/layui-v2.8.6/layui.js" charset="utf-8"></script>
2 years ago
<script src="/static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
// 用于添加标签
function addItem(obj) {
}
// 用于删除标签
function deleteItem(obj) {
}
// 用于扫描条形码或二维码
function scanCode(obj) {
}
// 用于加载物料选择菜单
function selectMaterial() {
}
// 用于通过物料名称获取物料
function selectMaterialByName() {
}
// 用于编码查询
function selectCode(obj) {
}
// 用于扫描物料编码
function scanMaterialCodeForTaking() {
}
// 用于扫描条形码
function scanBarCodeForTaking() {
}
// 用于二次渲染页面
function Coverpage() {
}
// 用于计算盘点结果
function calculate(obj) {
}
// 用于暂存卡片个数
let params = [];
// 用于卡片编号
var NewIdNumber = 1;
// 用于存储当前选择的盘点位置
let depositoryId;
let placeId;
// 用于存储当前选择的负责人
let departmentManagerId;
// 用于存储没有对应关系的物料
let barCodeList = {};
let needToUpdate = {};
// 用于标志是否为第一次提交
let flagForForm = false;
layui.use(['form', 'step', 'flow', 'laydate', 'inputTag'], function () {
var $ = layui.$,
form = layui.form,
laydate = layui.laydate,
inputTag = layui.inputTag,
step = layui.step;
departmentManagerId = $("#departmentManagerId").val();
// 用于分步表单加载
step.render({
elem: '#stepForm',
filter: 'stepForm',
width: '100%', //设置容器宽度
height: '900px',
stepItems: [{
title: '填写信息'
}, {
title: '提交成功'
}]
});
let tagData = [];
let tempData = $("#departmentManager").val().split(",");
$.each(tempData, function (index, item) {
if (item !== "") {
tagData.push(item)
}
});
$("#departmentManager").val("");
let tagLabel = inputTag.render({
elem: '#departmentManager',
data: tagData,//初始值
removeKeyNum: 8,//删除按键编号 默认,BackSpace 键
createKeyNum: 13,//创建按键编号 默认,Enter 键
onChange: function (data, value, type, index) {
if (type === "remove") {
let split = departmentManagerId.split(",");
split.splice(index, 1);
departmentManagerId = split.toString();
$("#departmentManagerId").val(departmentManagerId);
}
}
});
// 用于打开仓库树形菜单
$('#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();
}
depositoryId = nowDepositoryId;
placeId = nowPlaceId;
}
});
});
// 用于打开负责人树形菜单
$("#selectdepartmentManager").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 () {
departmentManagerId = $("#departmentManagerId").val();
tagLabel.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) {
if(!flagForForm){
flagForForm = true;
data = data.field;
data.params = params;
data.needToUpdate = needToUpdate;
data.barCodeListByNoMaterial = barCodeList;
data.departmentManagerId = departmentManagerId;
$.ajax({
url: "/stockTaking/addStockTakingRecord",
type: 'post',
dataType: 'json',
contentType: "application/json;charset=utf-8",
data: JSON.stringify(data),
beforeSend: function () {
this.layerIndex = layer.load(0, {shade: [0.5, '#393D49']});
},
success: function (data) {
layer.msg("申请提交成功", {
icon: 6,//成功的表情
time: 500 //1秒关闭(如果不配置,默认是3秒)
}, function () {
step.next('#stepForm');
});
},
complete: function () {
layer.close(this.layerIndex);
}
});
}
});
form.on('submit(formStep2)', function (data) {
step.next('#stepForm');
return false;
});
$('.pre').click(function () {
step.pre('#stepForm');
});
$('.next').click(function () {
step.next('#stepForm');
});
// 实现卡片添加
addItem = function (obj) {
// 获取父元素id
var parentId = obj.parentNode.id;
NewIdNumber = NewIdNumber + 1;
var materialItem = `
<div class="layui-card-body" id=` + "InventoryDetails" + NewIdNumber + ` style="padding-right: 0px">
<hr>
<i class="layui-icon layui-icon-subtraction" style="display: inline"
onclick="deleteItem(this)"></i>
<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" + NewIdNumber + ` class="layui-input" id=` + "mid" + NewIdNumber + `
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" style="margin: 0px;">
<div class="inputdiv">
<input id=` + "code" + NewIdNumber + ` name= ` + "code" + NewIdNumber + ` 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"
style="margin-top: 10px" onclick="scanMaterialCodeForTaking(this)">
</div>
</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">
<select id=` + "barCode" + NewIdNumber + ` name=` + "barCode" + NewIdNumber + `
style="border-style: none">
</select>
<img src="/static/images/search.ico" height="16" width="16" id=` + "barCodeImg" + NewIdNumber + `
style="margin-top: 10px" onclick="scanBarCodeForTaking(this)">
</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" id="openSonByMateralType" readonly
lay-verify="required"/>
<input type="text" id=` + "materialTypeId" + NewIdNumber + ` name=` + "typeId" + NewIdNumber + ` placeholder="请选择物料类型" class="layui-input" style="display: none" lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">材质:</label>
<div class="layui-input-block">
<input name=` + "texture" + NewIdNumber + ` type="text" placeholder="请填写材质名称" class="layui-input" />
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">规格型号:</label>
<div class="layui-input-block">
<input name=` + "version" + NewIdNumber + ` type="text" placeholder="请填写规格型号" class="layui-input"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">计量单位:</label>
<div class="layui-input-block">
<select name=` + "unit" + NewIdNumber + ` id=` + "unit" + NewIdNumber + `></select>
</div>
</div>
<div class="layui-form-item" style="display: none" id=` + "producedDateItem" + NewIdNumber + `>
<label class="layui-form-label">生产日期:</label>
<div class="layui-input-block">
<select name=` + "producedDate" + NewIdNumber + ` id=` + "producedDate" + NewIdNumber + ` >
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">库存数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" readonly
name=` + "oldInventory" + NewIdNumber + ` id=` + "oldInventory" + NewIdNumber + ` lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盘点数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" onblur="calculate(this)"
name=` + "newInventory" + NewIdNumber + ` lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盘点结果:</label>
<div class="layui-input-block">
<select name=` + "takingResult" + NewIdNumber + ` id=` + "result" + NewIdNumber + `>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盈亏数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" readonly id=` + "Inventory_number" + NewIdNumber + `
name=` + "inventory" + NewIdNumber + ` lay-verify="required"/>
</div>
</div>
<i class="layui-icon layui-icon-addition" style="display: inline"
onclick="addItem(this)"></i>
</div>
`;
// 获取当前高度
var height = parseInt(($("#stepForm").css('height')).split("px")[0]);
params.push(NewIdNumber);
// $("#form1").css("height", height + 682 + 'px');
$("#stepForm").css("height", height + 735 + 'px');
$("#" + parentId).after(materialItem);
};
// 实现卡片删除
deleteItem = function (obj) {
// 获取父节点
var parent = obj.parentNode;
var parentId = parent.id;
parentId = parseInt(parentId.split("InventoryDetails")[1]);
// 获取祖父节点
var reparent = parent.parentNode;
var height = parseInt(($("#stepForm").css('height')).split("px")[0]);
$("#stepForm").css("height", height - 735 + 'px');
params = remove(params, parentId);
reparent.removeChild(parent);
};
//删除数组中指定元素
function remove(arr, item) {
var result = [];
for (let i = 0; i < arr.length; i++) {
if (arr[i] === item) {
continue;
}
result.push(arr[i]);
}
return result;
}
// 扫码盘点位置
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
});
} 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";
}
}
})
}
})
};
// 用于打开物料树形菜单
selectMaterial = function (obj) {
if (depositoryId !== undefined && departmentManagerId !== undefined && departmentManagerId !== "") {
var parent = obj.parentNode.parentNode.parentNode.parentNode;
var parentId = parent.id;
// 物料编码父级
var codeChildren = parent.childNodes[7];
// 物料名称父级
var materialChildren = parent.childNodes[5];
// 物料类型父级
var typeChildren = parent.childNodes[11];
// 材质父级
var textureChildren = parent.childNodes[13];
// 规格型号父级
var versionChildren = parent.childNodes[15];
// 计量单位父级
var unitChildren = parent.childNodes[17];
// 库存数量父级
var inventoryChildren = parent.childNodes[21];
// 条形码父级
var barCodeChildren = parent.childNodes[9];
// 编码条目
var codeItem = codeChildren.childNodes[3].childNodes[1];
// 具体条码
var codeValue = codeItem.childNodes[1];
// 物料条目
var materialItem = materialChildren.childNodes[3].childNodes;
// 物料名称
var materialName = materialItem[1].childNodes[1];
// 物料编码
var materialId = materialItem[3];
// 输入的物料名称
var mname = materialName.value;
// 物料种类条目
var materialTypeItem = typeChildren.childNodes[3].childNodes;
// 条形码条目
var barCodeItem = barCodeChildren.childNodes[3];
layer.open({
type: 2,
title: '弹窗内容',
skin: 'layui-layer-rim',
maxmin: true,
shadeClose: true, //点击遮罩关闭层
area: ['70%', '70%'],
move: '.layui-layer-title',
fixed: false,
content: '/getMaterialAll?mname=' + mname + '&type=3&clickObj=' + parentId + '&placeId=' + placeId + '&depositoryId=' + depositoryId,
// content: '/selectMaterialByCardForTaking?mname=' + mname + '&type=3&clickObj=' + parentId + '&placeId=' + placeId + '&depositoryId=' + depositoryId,
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 mid = materialId.value;
if (mid !== '') {
$.ajax({
url: "/material/findInventoryByIdAndPid?mid=" + mid + "&pid=" + placeId,
type: "get",
dataType: 'json',
contentType: "application/json;charset=utf-8",
success: function (d) {
var material = d.data.materialById;
var code = material.code;
if (code === undefined) {
code = "";
}
codeValue.value = code;
materialTypeItem[1].value = material.typeName;
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
var materialAndBarCodeList = material.materialAndBarCodeList;
var idNumber = materialId.name.split("mid")[1];
if (materialAndBarCodeList.length > 0) {
// 如果有对应的条形码
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
let unitItem = $("#unit" + idNumber);
unitItem.empty();
unitItem.append(new Option(material.unit, "-1"));
let splitInfoList = material.splitInfoList;
if (splitInfoList.length > 0) {
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
form.render();
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d.data['producedDateList'];
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
}
form.render();
} else {
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
}
});
}
}
});
} else {
layer.msg("请先选择盘点位置或负责人", {
icon: 0,
time: 500
})
}
};
// 用于实现通过编码查询物料
selectCode = function (obj) {
if (depositoryId !== undefined && departmentManagerId !== undefined && departmentManagerId !== "") {
// 输入code
var code = obj.value;
var parent = obj.parentNode.parentNode.parentNode.parentNode;
var parentId = parent.id;
// 物料编码父级
var codeChildren = parent.childNodes[7];
// 物料名称父级
var materialChildren = parent.childNodes[5];
// 物料类型父级
var typeChildren = parent.childNodes[11];
// 材质父级
var textureChildren = parent.childNodes[13];
// 规格型号父级
var versionChildren = parent.childNodes[15];
// 计量单位父级
var unitChildren = parent.childNodes[17];
// 库存数量父级
var inventoryChildren = parent.childNodes[21];
// 条形码父级
var barCodeChildren = parent.childNodes[9];
// 编码条目
var codeItem = codeChildren.childNodes[3].childNodes[1];
// 具体条码
var codeValue = codeItem.childNodes[1];
// 物料条目
var materialItem = materialChildren.childNodes[3].childNodes;
// 物料名称
var materialName = materialItem[1].childNodes[1];
// 物料编码
var materialId = materialItem[3];
// 物料种类条目
var materialTypeItem = typeChildren.childNodes[3].childNodes;
// 条形码条目
var barCodeItem = barCodeChildren.childNodes[3];
// 获取对应元素
var req = {};
req.code = code;
req.depositoryId = depositoryId;
req.placeId = placeId;
$.ajax({
url: "/material/findMatrialByCodeForTaking",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
var d = d.data;
if (d == null) {
layer.msg("该位置暂未该物品,请确认是否输入正确");
materialName.value = "";
materialId.value = "";
obj.value = "";
materialTypeItem[1].value = "";
materialTypeItem[3].value = "";
textureChildren.childNodes[3].childNodes[1].value = "";
versionChildren.childNodes[3].childNodes[1].value = "";
unitChildren.childNodes[3].childNodes[1].value = "";
inventoryChildren.childNodes[3].childNodes[1].value = "";
} else {
materialName.value = d.mname;
materialId.value = d.id;
materialTypeItem[1].value = d.typeName;
materialTypeItem[3].value = d.typeId;
textureChildren.childNodes[3].childNodes[1].value = d.texture === null || d.texture === undefined ? '' : d.texture;
versionChildren.childNodes[3].childNodes[1].value = d.version === null || d.version === undefined ? '' : d.version;
inventoryChildren.childNodes[3].childNodes[1].value = d.quantity;
// 获取物料与条形码的对应关系
var materialAndBarCodeList = d["materialAndBarCodeList"];
var idNumber = materialId.name.split("mid")[1];
let unit = $("#unit" + idNumber);
var barCode = $("#barCode" + idNumber);
if (barCode.length > 0) {
barCode.empty();
}
unit.empty();
unit.append(new Option(d.baseUnit, "-1"));
if (d.splitInfoList !== null && d.splitInfoList.length > 0) {
$.each(d.splitInfoList, function (index, item) {
unit.append(new Option(item.newUnit, item.newUnit));//往下拉菜单里添加元素
});
form.render();
}
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
var producedDateItem = $("#producedDate" + idNumber);
if (producedDateItem.length > 0) {
producedDateItem.empty();
}
var shelfLife = d.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d['producedDateList'];
if (producedDateList != null && producedDateList != undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
}
form.render();
} else {
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
}
}
});
} else {
layer.msg("请先选择盘点位置或负责人", {
icon: 0,
time: 500
})
}
};
// 通过物料名称获取物料
selectMaterialByName = function (obj) {
if (depositoryId !== undefined && departmentManagerId !== undefined && departmentManagerId !== "") {
// 如果已经选择盘点的位置
// 输入物料名称
var data = obj.value;
var parent = obj.parentNode.parentNode.parentNode.parentNode;
var parentId = parent.id;
// 物料编码父级
var codeChildren = parent.childNodes[7];
// 物料名称父级
var materialChildren = parent.childNodes[5];
// 物料类型父级
var typeChildren = parent.childNodes[11];
// 材质父级
var textureChildren = parent.childNodes[13];
// 规格型号父级
var versionChildren = parent.childNodes[15];
// 计量单位父级
var unitChildren = parent.childNodes[17];
// 库存数量父级
var inventoryChildren = parent.childNodes[21];
// 条形码父级
var barCodeChildren = parent.childNodes[9];
// 编码条目
var codeItem = codeChildren.childNodes[3].childNodes[1];
// 具体条码
var codeValue = codeItem.childNodes[1];
// 物料条目
var materialItem = materialChildren.childNodes[3].childNodes;
// 物料名称
var materialName = materialItem[1].childNodes[1];
// 物料编码
var materialId = materialItem[3];
// 物料种类条目
var materialTypeItem = typeChildren.childNodes[3].childNodes;
// 条形码条目
var barCodeItem = barCodeChildren.childNodes[3];
var req = {};
data = data.split(",")[0];
if(data !== ""){
req.mname = data;
req.depositoryId = depositoryId;
req.placeId = placeId;
$.ajax({
url: "/material/findMaterialForTaking",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
if (d.count > 1) {
layer.msg("请点击右侧搜索确定物品");
materialId.value = "";
codeValue.value = "";
textureChildren.childNodes[3].childNodes[1].value = "";
versionChildren.childNodes[3].childNodes[1].value = "";
unitChildren.childNodes[3].childNodes[1].value = "";
inventoryChildren.childNodes[3].childNodes[1].value = "";
return false;
} else if (d.count === 0) {
layer.msg("没有该物品,请确认输入是否正确");
materialId.value = "";
codeValue.value = "";
materialName.value = "";
materialTypeItem[1].value = '';
materialTypeItem[3].value = "";
textureChildren.childNodes[3].childNodes[1].value = "";
versionChildren.childNodes[3].childNodes[1].value = "";
unitChildren.childNodes[3].childNodes[1].value = "";
inventoryChildren.childNodes[3].childNodes[1].value = "";
return false;
} else {
var material = d.data;
materialName.value = material.mname;
materialId.value = material.id;
codeValue.value = material.code;
materialTypeItem[1].value = material.typeName;
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
inventoryChildren.childNodes[3].childNodes[1].value = material.baseUnitQuantity;
var idNumber = materialId.name.split("mid")[1];
// 获取物料与条形码的对应关系
var materialAndBarCodeList = material["materialAndBarCodeList"];
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
let unitItem = $("#unit" + idNumber);
unitItem.empty();
unitItem.append(new Option(material.baseUnit, "-1"));
let splitInfoList = material.splitInfoList;
if (splitInfoList.length > 0) {
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
var shelfLife = d.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = d['producedDateList'];
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
}
form.render();
} else {
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
}
}
});
}
} else {
layer.msg("请先选择盘点位置或负责人", {
icon: 0,
time: 500
})
}
};
// 用于二次渲染页面
Coverpage = function (num, obj) {
// 获取待添加父类
NewIdNumber = num;
if (num === 0) { // 如果是第一个
NewIdNumber = "";
}
var texture = obj.texture === null || obj.texture === undefined ? "" : obj.texture;
var version = obj.version === null || obj.version === undefined ? "" : obj.version;
var unit = obj.unit === null || obj.unit === undefined ? "" : obj.unit;
var materialItem = `
<div class="layui-card-body" id=` + "InventoryDetails" + NewIdNumber + ` style="padding-right: 0px">
<hr>
<i class="layui-icon layui-icon-subtraction" style="display: inline"
onclick="deleteItem(this)"></i>
<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" value="${obj.mname}"
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" + NewIdNumber + ` class="layui-input" id=` + "mid" + NewIdNumber + `
value="${obj.mid}" 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" style="margin: 0px;">
<div class="inputdiv">
<input id=` + "code" + NewIdNumber + ` name= ` + "code" + NewIdNumber + ` type="text" placeholder="请填写入物料编码"
onblur="selectCode(this)" value="${obj.code}"
class="layui-input" lay-verify="required"
style="border-style: none">
<img src="/static/images/search.ico" height="16" width="16"
style="margin-top: 10px" onclick="scanMaterialCodeForTaking(this)">
</div>
</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">
<select id=` + "barCode" + NewIdNumber + ` name=` + "barCode" + NewIdNumber + `
style="border-style: none">
</select>
<img src="/static/images/search.ico" height="16" width="16" id=` + "barCodeImg" + NewIdNumber + `
style="margin-top: 10px" onclick="scanBarCodeForTaking(this)">
</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" id="openSonByMateralType" readonly
value="${obj.typeName}" lay-verify="required"/>
<input type="text" id=` + "materialTypeId" + NewIdNumber + ` name=` + "typeId" + NewIdNumber + ` value="${obj.typeId}"
placeholder="请选择物料类型" class="layui-input" style="display: none" lay-verify="required"/>
</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" value="${texture}"
name=` + "texture" + NewIdNumber + `/>
</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" value="${version}"
name=` + "version" + NewIdNumber + `/>
</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" value="${unit}"
name=` + "unit" + NewIdNumber + `/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">库存数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" readonly value="${obj.quantity}"
name=` + "oldInventory" + NewIdNumber + ` id=` + "oldInventory" + NewIdNumber + ` lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盘点数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" onblur="calculate(this)"
name=` + "newInventory" + NewIdNumber + ` lay-verify="required"/>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盘点结果:</label>
<div class="layui-input-block">
<select name=` + "takingResult" + NewIdNumber + ` id=` + "result" + NewIdNumber + `>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">盈亏数量:</label>
<div class="layui-input-block">
<input type="number" class="layui-input" readonly id=` + "Inventory_number" + NewIdNumber + `
name=` + "Inventory_number" + NewIdNumber + ` lay-verify="required"/>
</div>
</div>
<i class="layui-icon layui-icon-addition" style="display: inline"
onclick="addItem(this)"></i>
</div>
`;
// 获取当前高度
var height = parseInt(($("#stepForm").css('height')).split("px")[0]);
if (NewIdNumber !== "") {
params.push(NewIdNumber)
}
$("#stepForm").css("height", height + 682 + 'px');
var oldIdNumber = NewIdNumber - 1;
if (oldIdNumber === 0) {
oldIdNumber = "";
}
$("#InventoryDetails" + oldIdNumber).after(materialItem);
};
// 用于扫描物料编码
scanMaterialCodeForTaking = function (obj) {
if (depositoryId !== undefined && departmentManagerId !== undefined && departmentManagerId !== "") {
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.placeId = placeId;
req.depositoryId = depositoryId;
req.codeFlag = 2;
$.ajax({
url: "/material/qywxStockTakingScanQrCode",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
var data = d.data;
if (data == null) {
layer.msg("对于编码:" + result + ",并未发现对应的物料", {
icon: 0,
time: 1000 //0.5秒关闭(如果不配置,默认是3秒)
}, function () {
})
} else {
var parent = obj.parentNode.parentNode.parentNode.parentNode;
var parentId = parent.id;
// 物料编码父级
var codeChildren = parent.childNodes[7];
// 物料名称父级
var materialChildren = parent.childNodes[5];
// 物料类型父级
var typeChildren = parent.childNodes[11];
// 材质父级
var textureChildren = parent.childNodes[13];
// 规格型号父级
var versionChildren = parent.childNodes[15];
// 计量单位父级
var unitChildren = parent.childNodes[17];
// 库存数量父级
var inventoryChildren = parent.childNodes[21];
// 条形码父级
var barCodeChildren = parent.childNodes[9];
// 编码条目
var codeItem = codeChildren.childNodes[3].childNodes[1];
// 具体条码
var codeValue = codeItem.childNodes[1];
// 物料条目
var materialItem = materialChildren.childNodes[3].childNodes;
// 物料名称
var materialName = materialItem[1].childNodes[1];
// 物料编码
var materialId = materialItem[3];
// 物料种类条目
var materialTypeItem = typeChildren.childNodes[3].childNodes;
// 条形码条目
var barCodeItem = barCodeChildren.childNodes[3];
materialName.value = data.mname;
materialId.value = data.id;
materialTypeItem[1].value = data.typeName;
materialTypeItem[3].value = data.typeId;
codeValue.value = data.code;
textureChildren.childNodes[3].childNodes[1].value = data.texture === null || data.texture === undefined ? '' : data.texture;
versionChildren.childNodes[3].childNodes[1].value = data.version === null || data.version === undefined ? '' : data.version;
unitChildren.childNodes[3].childNodes[1].value = data.unit === null || data.unit === undefined ? '' : data.unit;
inventoryChildren.childNodes[3].childNodes[1].value = data.quantity;
// 获取物料与条形码的对应关系
var materialAndBarCodeList = data["materialAndBarCodeList"];
var idNumber = materialId.name.split("mid")[1];
$("#barCode" + idNumber).empty();
if (materialAndBarCodeList !== null && materialAndBarCodeList.length > 0) {
var barCodeInput = barCodeItem.childNodes[1].childNodes[1];
var barCodeImg = barCodeItem.childNodes[1].childNodes[3];
var id = barCodeInput.id;
form.render();
$.each(materialAndBarCodeList, function (index, item) {
$("#barCode" + idNumber).append(new Option(item.bmcode, item.id));//往下拉菜单里添加元素
});
form.render();
}
var unitItem = $("#unit" + idNumber);
unitItem.empty();
unitItem.append(new Option(data.unit, "-1"));
let splitInfoList = data.splitInfoList;
if (splitInfoList.length > 0) {
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
form.render();
var shelfLife = data.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + idNumber).show();
var producedDateList = data['producedDateList'];
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + idNumber).append(new Option(item, item));
})
}
form.render();
} else {
$("#" + "producedDateItem" + idNumber).hide();
form.render();
}
}
}
})
}
})
} else {
layer.msg("请先选择盘点位置或负责人", {
icon: 0,
time: 500
})
}
};
// 用于扫描条形码
scanBarCodeForTaking = function (obj) {
var id = obj.id;
id = id.split("barCodeImg")[1];
if (depositoryId !== undefined && departmentManagerId !== undefined && departmentManagerId !== "") {
parent.wx.scanQRCode({
desc: 'scanQRCode desc',
needResult: 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果,
scanType: ["barCode"], // 可以指定扫二维码还是条形码(一维码),默认二者都有
success: function (res) {
// 回调
var result = res.resultStr;//当needResult为1时返回处理结果
var req = {};
req.qrCode = result;
req.depositoryId = depositoryId;
req.placeId = placeId;
req.codeFlag = 1;
$.ajax({
url: "/material/qywxStockTakingScanBarCode",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
var data = d.data;
var material = data["material"];
var barCodeListByNoMaterial = data["barCodeListByNoMaterial"];
if (material !== null) {
var parent = obj.parentNode.parentNode.parentNode.parentNode;
var parentId = parent.id;
// 物料编码父级
var codeChildren = parent.childNodes[7];
// 物料名称父级
var materialChildren = parent.childNodes[5];
// 物料类型父级
var typeChildren = parent.childNodes[11];
// 材质父级
var textureChildren = parent.childNodes[13];
// 规格型号父级
var versionChildren = parent.childNodes[15];
// 计量单位父级
var unitChildren = parent.childNodes[17];
// 库存数量父级
var inventoryChildren = parent.childNodes[21];
// 条形码父级
var barCodeChildren = parent.childNodes[9];
// 编码条目
var codeItem = codeChildren.childNodes[3].childNodes[1];
// 具体条码
var codeValue = codeItem.childNodes[1];
// 物料条目
var materialItem = materialChildren.childNodes[3].childNodes;
// 物料名称
var materialName = materialItem[1].childNodes[1];
// 物料编码
var materialId = materialItem[3];
// 物料种类条目
var materialTypeItem = typeChildren.childNodes[3].childNodes;
materialName.value = material.mname;
materialId.value = material.id;
codeValue.value = material.code;
materialTypeItem[1].value = material.typeName;
materialTypeItem[3].value = material.typeId;
textureChildren.childNodes[3].childNodes[1].value = material.texture === null || material.texture === undefined ? '' : material.texture;
versionChildren.childNodes[3].childNodes[1].value = material.version === null || material.version === undefined ? '' : material.version;
inventoryChildren.childNodes[3].childNodes[1].value = material.quantity;
$("#barCode" + id).empty();
$("#barCode" + id).append(new Option(result, 0));//往下拉菜单里添加元素
var shelfLife = material.shelfLife;
if (shelfLife !== null && shelfLife !== undefined) {
$("#" + "producedDateItem" + id).show();
var producedDateList = material['producedDateList'];
if (producedDateList !== null && producedDateList !== undefined && producedDateList.length > 0) {
$.each(producedDateList, function (index, item) {
$("#" + "producedDate" + id).append(new Option(item, item));
})
}
form.render();
} else {
$("#" + "producedDateItem" + id).hide();
form.render();
}
form.render();
var unitItem = $("#unit" + id);
unitItem.empty();
unitItem.append(new Option(material.unit, "-1"));
let splitInfoList = material.splitInfoList;
if (splitInfoList.length > 0) {
$.each(splitInfoList, function (index, item) {
unitItem.append(new Option(item.newUnit, item.newUnit));
})
}
form.render();
}
if (barCodeListByNoMaterial.length > 0) {
// 如果扫描的条形码没有对应的物料
var content = '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: 300;">' +
'<p>未发现的条码,是否需要添加对应关系</p><hr>' +
'<table>';
for (let i = 0; i < barCodeListByNoMaterial.length; i++) {
var item = "<tr><td>" + barCodeListByNoMaterial[i] + "</td></tr>";
content += item;
}
content += '</table></div>';
layer.open({
type: 1
, title: false //不显示标题栏
, closeBtn: false
, area: '300px;'
, shade: 0.8
, id: 'LAY_layuipro' //设定一个id,防止重复弹出
, btn: ['添加', '取消']
, btnAlign: 'c'
, moveType: 1 //拖拽模式,0或者1
, content: content
, success: function (layero) {
var btn = layero.find('.layui-layer-btn');
btn.find('.layui-layer-btn0').click(function () {
$.each(barCodeListByNoMaterial, function (index, item) {
$("#barCode" + id).append(new Option(item, item));//往下拉菜单里添加元素
});
barCodeList["barCode" + id] = barCodeListByNoMaterial;
needToUpdate["barCode" + id] = true;
form.render()
});
}
});
}
}
})
}
});
} else {
layer.msg("请先选择盘点位置或负责人", {
icon: 0,
time: 500
})
}
};
// 用于计算盘点结果
calculate = function (obj) {
var parent = obj.parentNode.parentNode.parentNode;
var oldInventoryItem = parent.childNodes[21].childNodes[3].childNodes[1];
var nowInventoryItem = parent.childNodes[23].childNodes[3].childNodes[1];
var resultItem = parent.childNodes[25].childNodes[3].childNodes[1];
var InventoryItem = parent.childNodes[27].childNodes[3].childNodes[1];
var oldInventory = Number(oldInventoryItem.value);
var nowInventory = Number(nowInventoryItem.value);
$('#' + resultItem.id).empty();
if (oldInventory > nowInventory) {
// 如果盘点数目小于库存数目
$('#' + resultItem.id).append(new Option("盘亏", 'Inventory_down'));//往下拉菜单里添加元素
$("#" + InventoryItem.id).val(oldInventory - nowInventory);
} else if (oldInventory < nowInventory) {
// 如果盘点数目大于库存数目
$('#' + resultItem.id).append(new Option("盘盈", 'Inventory_up'));//往下拉菜单里添加元素
$("#" + InventoryItem.id).val(nowInventory - oldInventory);
} else {
// 如果盘点数目等于库存数目
$('#' + resultItem.id).append(new Option("正常", 'Inventory_normal'));//往下拉菜单里添加元素
$("#" + InventoryItem.id).val(nowInventory - oldInventory);
}
form.render();
};
form.on('select()', function (data) {
var id = data.elem.id; //得到select原始DOM对象id
var req = {};
if (id.includes("producedDate")) {
var idNumber = id.split('producedDate')[1]; // 得到当前id对应数字
req.mid = $("#" + "mid" + idNumber).val();
req.producedDate = data.value;
$.ajax({
url: "/material/findQuantityByProducedDate",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
$("#" + "oldInventory" + idNumber).val(d.data)
}
});
}
else if (id.includes("unit")) {
let idNumber = id.split("unit")[1]; // 得到当前id对应数字
req.mid = $("#" + "mid" + idNumber).val();
req.unit = data.value;
req.placeId = $("#placeId").val();
$.ajax({
url: "/material/findQuantityByUnit",
type: "post",
dataType: 'json',
data: JSON.stringify(req),
contentType: "application/json;charset=utf-8",
success: function (d) {
$("#" + "oldInventory" + idNumber).val(d.data)
}
});
}
});
$('body').on('click', '[data-refresh]', function () {
location.reload();
})
});
</script>
</body>
</html>