Browse Source

[feat]

仓库管理 库存报损
新增库存报损编辑页面是否关联单选按钮、仓库名称下拉框监听函数;
新增根据是否关联生产单号显示关联生产单号输入框方法;
新增仓库名称下拉框初始化方法;
新增部门名称动态获取方法;
修改添加物料方法,根据是否含生产单号设置物料来源;
修改选择物料回调方法,添加重复性验证;
新增库存报损列表显示页面导出函数;
dev
王晓迪 3 months ago
parent
commit
fb7446d05b
  1. 408
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/edit.html
  2. 24
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/inventoryReportDamage.html

408
ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/edit.html

@ -3,41 +3,30 @@
<head> <head>
<th:block th:include="include :: header('修改仓库库存报损')" /> <th:block th:include="include :: header('修改仓库库存报损')" />
<th:block th:include="include :: datetimepicker-css" /> <th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: bootstrap-fileinput-css" />
<th:block th:include="include :: bootstrap-editable-css" />
</head> </head>
<body class="white-bg"> <body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-inventoryReportDamage-edit" th:object="${warehouseInventoryReportDamage}"> <form class="form-horizontal m" id="form-inventoryReportDamage-edit" th:object="${warehouseInventoryReportDamage}">
<input name="reportDamageId" th:field="*{reportDamageId}" type="hidden"> <input name="reportDamageId" th:field="*{reportDamageId}" type="hidden">
<div class="form-group"> <input name="reportDamageCode" th:field="*{reportDamageCode}" type="hidden">
<label class="col-sm-3 control-label is-required">报废类型:</label> <!-- <div class="form-group"> -->
<div class="col-sm-8"> <!-- <label class="col-sm-3 control-label is-required">报废类型:</label>-->
<select name="warehousScrapType" class="form-control m-b" th:with="type=${@dict.getType('warehous_scrap_type')}" required> <!-- <div class="col-sm-8">-->
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{warehousScrapType}"></option> <!-- <select name="warehousScrapType" class="form-control m-b" th:with="type=${@dict.getType('warehous_scrap_type')}" required>-->
</select> <!-- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{warehousScrapType}"></option>-->
</div> <!-- </select>-->
</div> <!-- </div>-->
<div class="form-group"> <!-- </div>-->
<label class="col-sm-3 control-label is-required">是否关联生产单号:</label> <div class="form-group">
<div class="col-sm-8">
<div class="radio-box" th:each="dict : ${@dict.getType('yes_or_no')}" required>
<input type="radio" th:id="${'whetherMakeNo_' + dict.dictCode}" name="whetherMakeNo" th:value="${dict.dictValue}" th:field="*{whetherMakeNo}">
<label th:for="${'whetherMakeNo_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
<div class="form-group" hidden="hidden">
<label class="col-sm-3 control-label is-required">关联生产单号:</label>
<div class="col-sm-8">
<input name="makeNo" th:field="*{makeNo}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">申请部门:</label> <label class="col-sm-3 control-label is-required">申请部门:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="applyDept" th:field="*{applyDept}" class="form-control" type="text" required> <select name="applyDept" th:field="*{applyDept}" class="form-control" type="text" required disabled></select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label">申请时间:</label> <label class="col-sm-3 control-label">申请时间:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<div class="input-group date"> <div class="input-group date">
@ -47,29 +36,38 @@
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required">料号:</label> <label class="col-sm-3 control-label is-required">是否关联生产单号:</label>
<div class="col-sm-8">
<input name="materialNo" th:field="*{materialNo}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">物料名称:</label>
<div class="col-sm-8">
<input name="materialName" th:field="*{materialName}" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">物料数合计:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="materialTotal" th:field="*{materialTotal}" class="form-control" type="text" required> <!-- <div class="radio-box" th:each="dict : ${@dict.getType('yes_or_no')}" required>-->
<!-- <input type="radio" th:id="${'whetherMakeNo_' + dict.dictCode}" name="whetherMakeNo" th:value="${dict.dictValue}" th:field="*{whetherMakeNo}">-->
<!-- <label th:for="${'whetherMakeNo_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>-->
<!-- </div>-->
<div class="radio-inline">
<label><input type="radio" name="whetherMakeNo" value="0" checked></label>
</div>
<div class="radio-inline">
<label><input type="radio" name="whetherMakeNo" value="1"></label>
</div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group" id="makeNoInput">
<label class="col-sm-3 control-label is-required">数量合计:</label> <label class="col-sm-3 control-label is-required">关联生产单号</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="numTotal" th:field="*{numTotal}" class="form-control" type="text" required> <input name="makeNo" th:field="*{makeNo}" class="form-control" type="text" required>
</div> </div>
</div> </div>
<!-- <div class="form-group"> -->
<!-- <label class="col-sm-3 control-label is-required">物料数合计:</label>-->
<!-- <div class="col-sm-8">-->
<!-- <input name="materialTotal" th:field="*{materialTotal}" class="form-control" type="text" required>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="form-group"> -->
<!-- <label class="col-sm-3 control-label is-required">数量合计:</label>-->
<!-- <div class="col-sm-8">-->
<!-- <input name="numTotal" th:field="*{numTotal}" class="form-control" type="text" required>-->
<!-- </div>-->
<!-- </div>-->
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required">仓库ID:</label> <label class="col-sm-3 control-label is-required">仓库ID:</label>
<div class="col-sm-8"> <div class="col-sm-8">
@ -79,7 +77,7 @@
<div class="form-group"> <div class="form-group">
<label class="col-sm-3 control-label is-required">仓库名称:</label> <label class="col-sm-3 control-label is-required">仓库名称:</label>
<div class="col-sm-8"> <div class="col-sm-8">
<input name="warehouseName" th:field="*{warehouseName}" class="form-control" type="text" required> <select id="stockNameSelct" name="warehouseName" th:field="*{warehouseName}" class="form-control" type="text" required></select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -114,6 +112,9 @@
</div> </div>
<th:block th:include="include :: footer" /> <th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" /> <th:block th:include="include :: datetimepicker-js" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript"> <script th:inline="javascript">
var prefix = ctx + "warehouse/inventoryReportDamage"; var prefix = ctx + "warehouse/inventoryReportDamage";
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; var materialTypeDatas = [[${@category.getChildByCode('materialType')}]];
@ -124,61 +125,223 @@
var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]]; var warehouseDeptDatas = [[${@dict.getType('warehouseDept')}]];
var warehousScrapTypeDatas = [[${@dict.getType('warehous_scrap_type')}]]; var warehousScrapTypeDatas = [[${@dict.getType('warehous_scrap_type')}]];
$("#form-inventoryReportDamage-edit").validate({focusCleanup: true}); $("#form-inventoryReportDamage-edit").validate({focusCleanup: true});
var warehouseInventoryReportDamage = [[${warehouseInventoryReportDamage}]];
var stockData = [];
function submitHandler() { function submitHandler() {
if ($.validate.form()) { if ($.validate.form()) {
$.operate.save(prefix + "/edit", $('#form-inventoryReportDamage-edit').serialize()); var warehouseInventoryReportDamage = {
warehouseInventoryReportDamageChildList: []
};
warehouseInventoryReportDamage.reportDamageId = $("input[name='reportDamageId']").val();
warehouseInventoryReportDamage.reportDamageCode = $("input[name='reportDamageCode']").val();
$("select[name='applyDept']").removeAttr("disabled");
warehouseInventoryReportDamage.applyDept = $("select[name='applyDept']").val();
warehouseInventoryReportDamage.applyTime = $("input[name='applyTime']").val();
var whetherMakeNo = $("input[name='whetherMakeNo']:checked").val();
warehouseInventoryReportDamage.whetherMakeNo = whetherMakeNo;
if(whetherMakeNo === "1"){
var makeNo = $("input[name='makeNo']").val();
warehouseInventoryReportDamage.makeNo = makeNo;
}
warehouseInventoryReportDamage.warehouseName = $("select[name='warehouseName']").val();
warehouseInventoryReportDamage.warehouseCode = $("input[name='warehouseCode']").val();
warehouseInventoryReportDamage.warehouseStoreAddress = $("input[name='warehouseStoreAddress']").val();
warehouseInventoryReportDamage.remark = $("area[name='remark']").val();
var rows = $('#bootstrap-table-reportDamage-child').bootstrapTable('getData');
// 检查表格数据是否为空
if (rows.length === 0) {
$.modal.alertWarning("请至少添加一条物料信息再保存!");
return;
} else {
warehouseInventoryReportDamage.materialTotal = rows.length;
for (var i = 0; i < rows.length; i++) {
var DamageChild = {
materialNo: rows[i].materialNo,
materialName: rows[i].materialName,
materialType: rows[i].materialType,
materialDescribe: rows[i].materialDescribe,
materialBrand: rows[i].materialBrand,
materialUnit: rows[i].materialUnit,
materialPhotourl: rows[i].materialPhotourl,
actualScrapQuantity: rows[i].actualScrapQuantity,
scrapType: rows[i].scrapType,
scrapDetail: rows[i].scrapDetail,
qualityAssessment: rows[i].qualityAssessment,
estimatedValueRmb: rows[i].estimatedValueRmb,
responsibleUnit: rows[i].responsibleUnit,
remark: rows[i].remark,
};
// console.log(DamageChild);
warehouseInventoryReportDamage.warehouseInventoryReportDamageChildList.push(DamageChild);
}
}
console.log(warehouseInventoryReportDamage);
$.operate.saveJson(prefix + "/edit",JSON.stringify(warehouseInventoryReportDamage));
} }
} }
var options = { $(function (){
id : 'bootstrap-table-reportDamage-child', // 单选按钮赋值
modalName: "仓库库存报损物料信息", var whetherMakeNo = [[${warehouseInventoryReportDamage.whetherMakeNo}]];
columns: [ if(whetherMakeNo === "1"){
{checkbox: true}, $('input:radio[name="whetherMakeNo"][value="1"]').prop('checked', true);
{title: '库存报损id', field: 'reportDamageChildId', visible: false}, }else{
{title: '报损单号', field: 'reportDamageCode',visible: false}, $('input:radio[name="whetherMakeNo"][value="0"]').prop('checked', true);
{title: '料号', field: 'materialNo',}, }
{title: '图片', field: 'materialPhotourl',},
{title: '物料名称', field: 'materialName',}, var options = {
{title: '物料类型', field: 'materialType',}, id : 'bootstrap-table-reportDamage-child',
{title: '描述', field: 'materialDescribe',}, modalName: "仓库库存报损物料信息",
{title: '品牌', field: 'materialBrand',}, data: [[${warehouseInventoryReportDamage.warehouseInventoryReportDamageChildList}]],
{title: '单位', field: 'materialUnit',}, columns: [
{title: '实际报废数量', field: 'actualScrapQuantity', {title: '库存报损id', field: 'reportDamageChildId', visible: false},
editable: { {title: '报损单号', field: 'reportDamageCode',visible: false},
type: 'text', {title: '料号', field: 'materialNo',},
mode: 'inline', // 设定为行内编辑模式 {title: '图片', field: 'materialPhotourl',},
events: { {title: '物料名称', field: 'materialName',},
blur: function(e) { {title: '物料类型', field: 'materialType',
var value = $(this).val(); formatter: function(value, row, index) {
var errorMessage = validateActualScrapQuantity(value); return $.table.selectCategoryLabel(materialTypeDatas, value);
if (errorMessage) {alert(errorMessage);} }
} },
{title: '描述', field: 'materialDescribe',},
{title: '品牌', field: 'materialBrand',},
{title: '单位', field: 'materialUnit',},
{title: '实际报废数量', field: 'actualScrapQuantity',
editable: {
type: 'text',
mode: 'inline', // 设定为行内编辑模式
events: {
blur: function(e) {
var value = $(this).val();
var errorMessage = validateActualScrapQuantity(value);
if (errorMessage) {alert(errorMessage);}
}
},
}, },
}, },
}, {title: '报废类型', field: 'scrapType',
{title: '报废类型', field: 'scrapType',}, editable:{
{title: '报废明细', field: 'scrapDetail',}, type: 'text',
{title: '品质判定', field: 'qualityAssessment',}, }
{title: '预估价值(RMB)', field: 'estimatedValueRmb',}, },
{title: '责任单位', field: 'responsibleUnit',}, {title: '报废明细', field: 'scrapDetail',
{title: '备注', field: 'remark',}, editable:{
{title: '关联生产单号', field: 'makeNo',}, type: 'text',
{title: '仓库ID', field: 'warehouseCode',}, }
{title: '仓库名称', field: 'warehouseName',}, },
{title: '仓库存放地址', field: 'warehouseStoreAddress',}, {title: '品质判定', field: 'qualityAssessment',
{title: '申请部门ID', field: 'applyDeptId',}, editable:{
{title: '申请部门', field: 'applyDept',}, type: 'text',
{title: '操作', align: 'center', }
formatter: function(value, row, index) { },
var actions = []; {title: '预估价值(RMB)', field: 'estimatedValueRmb',
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.materialNo + '\')"><i class="fa fa-edit"></i>删除</a> '); editable:{
return actions.join(''); type: 'text',
}
},
{title: '责任单位', field: 'responsibleUnit',
editable:{
type: 'text',
}
},
{title: '备注', field: 'remark',
editable:{
type: 'text',
}
},
{
title: '报损报告',
field: 'damageReportUrl',
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" ><i class="fa fa-plus"></i>上传</a> ');
return actions.join('');
}
},
{title: '操作', align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.materialNo + '\')"><i class="fa fa-edit"></i>删除</a> ');
return actions.join('');
}
}
]
};
$.table.init(options);
var stockName = warehouseInventoryReportDamage.warehouseName;
loadWarehouseCodes(stockName);
changeWhetherMakeNo();
getDeptName();
//单选改变是否关联生产单号显示关联生产单号输入框
$("input[name='whetherMakeNo']").change(function () {
changeWhetherMakeNo();
});
$('#stockNameSelct').on('change', function() {
var selectedValue = $(this).val();
// console.log(selectedValue);
$.each(stockData,function (i,stock){
if(stock.stockName === selectedValue){
$("input[name='warehouseCode']").val(stock.stockNo);
$("input[name='warehouseStoreAddress']").val(stock.stockAddress);
} }
});
});
})
//根据是否关联生产单号显示关联生产单号输入框
function changeWhetherMakeNo() {
var whetherMakeNo = $("input[name='whetherMakeNo']:checked").val();
// console.log(whetherMakeNo);
if (whetherMakeNo === "1") {
$("#makeNoInput").show();
} else {
$("#makeNoInput").hide();
}
}
function loadWarehouseCodes(defaultStockName) {
var url = ctx + 'stock/stockInfo/getAllWarehouseCode';
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
success: function(data) {
var select = $('#stockNameSelct');
$.each(data, function(i, option) {
var stockValue = {};
stockValue.stockName = option.stockName;
stockValue.stockNo = option.stockNO;
stockValue.stockAddress = option.stockAddr;
stockData.push(stockValue);
var optionElement = $('<option>', {
value: option.stockName,
text : option.stockName
});
select.append(optionElement);
if (option.stockName === defaultStockName) {
optionElement.prop('selected', true);
}
});
},
error: function(error) {
console.log('Error: ', error);
} }
] });
}; }
$.table.init(options);
function getDeptName(){
$.ajax({
url: prefix + "/getUserDeptName",
type: "get",
dataType: "json",
success: function (result) {
console.log(result.data);
$("select[name='applyDept']").append($('<option></option>').val(result.data).html(result.data));
}
});
}
function validateActualScrapQuantity(v) { function validateActualScrapQuantity(v) {
if ($.common.isEmpty(v)) { if ($.common.isEmpty(v)) {
return '实际报废数量不能为空'; return '实际报废数量不能为空';
@ -190,39 +353,74 @@
} }
function insertRow() { function insertRow() {
var url = ctx + 'warehouse/inventoryCheck/materialSelect'; var ifMakeNo = $("input[name='whetherMakeNo']:checked").val();
var options = { if(ifMakeNo === "1"){
title: '选择物料', var makeNo = $("input[name='makeNo']").val();
url: url, if(!makeNo){
callBack: doSubmit $.modal.alertWarning("请输入生产单号!")
}; }else{
$.modal.openOptions(options); var url = prefix + '/materialInMakeOrderSelect/' + makeNo;
var options = {
title: '选择物料',
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
}else{
var url = ctx + 'warehouse/inventoryCheck/materialSelect';
var options = {
title: '选择物料',
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
} }
function doSubmit(index, layero,uniqueId){ function doSubmit(index, layero,uniqueId){
console.log(uniqueId); // console.log(uniqueId);
var iframeWin = window[layero.find('iframe')[0]['name']]; var iframeWin = window[layero.find('iframe')[0]['name']];
var rowData = iframeWin.$('#bootstrap-materialSelect-table').bootstrapTable('getSelections')[0]; var rowData = iframeWin.$('#bootstrap-materialSelect-table').bootstrapTable('getSelections')[0];
console.log("rowData: "+rowData); var rows = $("#bootstrap-table-reportDamage-child").bootstrapTable('getData');
if(rows.length > 0){
for(var i=0;i<rows.length;i++){
var data = rows[i];
if(data.materialNo == rowData.materialNo){
$.modal.alertError("不能选择已添加过的相同物料");
return;
}
};
insertTable(rowData);
}else{
insertTable(rowData);
}
layer.close(index);
}
function insertTable(rowData){
$("#bootstrap-table-reportDamage-child").bootstrapTable('insertRow', { $("#bootstrap-table-reportDamage-child").bootstrapTable('insertRow', {
index:1, index:1,
row: { row: {
materialNo:rowData.materialNo, materialNo:rowData.materialNo,
materialName: rowData.materialName, materialName: rowData.materialName,
materialType: rowData.materialType,
materialBrand: rowData.materialBrand,
materialPhotourl: rowData.materialPhotourl,
materialDescribe: rowData.materialDescribe, materialDescribe: rowData.materialDescribe,
materialUnit: rowData.materialUnit, materialUnit: rowData.materialUnit,
inventoryCheckNum : "", actualScrapQuantity: "",
inventoryAccountNum : "", scrapType: "",
warehouseStoreAddress : "", scrapDetail: "",
batchNumber : "", qualityAssessment: "",
estimatedValueRmb: "",
responsibleUnit: "",
remark : "" remark : ""
} }
}) })
layer.close(index);
} }
// 逻辑删除前端的一行数据 // 逻辑删除前端的一行数据
function removeRow(materialNo){ function removeRow(materialNo){
$("#bootstrap-table").bootstrapTable('remove', {field: 'materialNo', values: materialNo}) $("#bootstrap-table-reportDamage-child").bootstrapTable('remove', {field: 'materialNo', values: materialNo})
} }
$("input[name='applyTime']").datetimepicker({ $("input[name='applyTime']").datetimepicker({
format: "yyyy-mm-dd", format: "yyyy-mm-dd",

24
ruoyi-admin/src/main/resources/templates/warehouse/inventoryReportDamage/inventoryReportDamage.html

@ -64,7 +64,7 @@
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="warehouse:inventoryReportDamage:add"> <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="warehouse:inventoryReportDamage:add">
<i class="fa fa-plus"></i> 添加 <i class="fa fa-plus"></i> 添加
</a> </a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="warehouse:inventoryReportDamage:export"> <a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="warehouse:inventoryReportDamage:export">
<i class="fa fa-download"></i> 导出 <i class="fa fa-download"></i> 导出
</a> </a>
</div> </div>
@ -136,6 +136,28 @@
$.modal.open("详情",url); $.modal.open("详情",url);
} }
// 导出
function exportExcel() {
var ids = $.table.selectColumns("reportDamageCode");
var dataParam = $("#formId").serializeArray();
let tipMsg = "确定导出当前所有数据吗?";
if ($.common.isNotEmpty(ids)) {
tipMsg = `确定导出当前勾选的 ${ids.length} 条数据吗?`;
dataParam.push({ "name": "ids", "value": ids });
}
$.modal.loading("正在导出数据,请稍后...");
$.modal.confirm(tipMsg, function () {
$.post( prefix + "/export", dataParam, function (result) {
if (result.code === web_status.SUCCESS) {
window.location.href = ctx + "common/download?fileName="+ encodeURI(result.msg) + "&delete=" + true;
} else {
$.modal.alertError(result.msg);
}
$.modal.closeLoading();
});
});
}
</script> </script>
</body> </body>
</html> </html>
Loading…
Cancel
Save