Browse Source

[fix]

仓库管理 库存盘点
修改库存盘点列表页面表格列显示结构;
新增导出库存盘点信息方法;
修改新增库存盘点页面,调整子表表格结构;
修改表格删除绑定方法,实现删除行功能;
修改盘点人输入框赋值语句,写入当前登录名;
修改编辑库存盘点页面下拉框初始化和监听函数;
修改编辑页面提交函数,单独获取仓库名称值;
修改详情页面,补全正常显示效果;
dev
王晓迪 3 months ago
parent
commit
739e401af0
  1. 15
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html
  2. 141
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/detail.html
  3. 76
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/edit.html
  4. 42
      ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html

15
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/add.html

@ -3,6 +3,7 @@
<head>
<th:block th:include="include :: header('新增仓库库存盘点')" />
<th:block th:include="include :: datetimepicker-css" />
<th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
@ -64,7 +65,7 @@
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<!--用于可以修改列表字段的插件-->
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<script th:inline="javascript">
var loginName = [[${@permission.getPrincipalProperty('loginName')}]];
@ -132,10 +133,10 @@
$.modal.openOptions(options);
}
//收款凭证table列表
$(function() {
$("input[name='inventoryCheckName']").val(loginName);
var options = {
modalName: "收款凭证",
modalName: "库存盘点物料",
showColumns: false,
pagination: false,
showToggle: false,
@ -143,12 +144,11 @@
showSearch:false,
singleSelect:true,
columns: [
{checkbox: false},
{title: '库存盘点详情ID', field: 'inventoryCheckDetailId', visible: false},
{title: '料号', field: 'materialNo',},
{title: '物料名称', field: 'materialName',},
{title: '物料单位', field: 'materialUnit',},
{title: '物料描述', field: 'materialDescribe',},
{title: '单位', field: 'materialUnit',},
{title: '盘点数量', field: 'inventoryCheckNum', editable:true},
{title: '当时库存账上数量', field: 'inventoryAccountNum', editable:true},
{title: '存放地址', field: 'warehouseStoreAddress', editable:true},
@ -157,7 +157,7 @@
{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.receivablesRecordsId + '\')"><i class="fa fa-remove"></i>删除</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.materialNo + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}
@ -165,7 +165,6 @@
};
$.table.init(options);
loadWarehouseCodes();
$("input[name='inventoryCheckName']").value(loginName);
})
function doSubmit(index, layero,uniqueId){
@ -201,7 +200,7 @@
ajax: {
theme: "bootstrap",
allowClear: true,
placeholder: "请选择一个料号",
placeholder: "请选择",
type: 'GET', // 请求类型
url: url, // 后端接口URL
dataType: 'json', // 预期服务器返回的数据类型

141
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/detail.html

@ -26,9 +26,7 @@
<div class="form-group">
<label class="col-sm-3 control-label">仓库名称:</label>
<div class="col-sm-8">
<select id="stockName" name="warehouseName" class="form-control" th:field="*{warehouseName}" disabled />
<option value="">请选择仓库名称</option>
</select>
<input id="stockName" name="warehouseName" class="form-control" th:field="*{warehouseName}" disabled />
</div>
</div>
<div class="form-group">
@ -84,68 +82,11 @@
autoclose: true
});
// 新增提交
function submitHandler() {
// 获取表单数据
const inventoryCheckData = $("#form-inventoryCheck-edit").serializeArray().reduce((obj, item) => {
obj[item.name] = item.value;
return obj;
}, {});
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
var table = $('#bootstrap-table').bootstrapTable('getData');
// 检查表格数据是否为空
if (table.length===0){
$.modal.alertWarning("请至少添加一条物料数据后再保存!");
return;
}
console.log(table);
// 将表数据转换成与complaintNoticeData格式一致的数组
var materialDataList = table.map(function(item) {
// 根据实际字段名调整
return {
"inventoryCheckDetailId":item.inventoryCheckDetailId,
"materialNo": item.materialNo, // 假设id对应materialId
"materialName": item.materialName,
"materialUnit": item.materialUnit,
"materialDescribe": item.materialDescribe,
"inventoryCheckNum": item.inventoryCheckNum,
"inventoryAccountNum": item.inventoryAccountNum,
"warehouseStoreAddress": item.warehouseStoreAddress,
"batchNumber": item.batchNumber,
"remark": item.remark,
// ...其他字段
};
});
const combinedData = Object.assign({}, inventoryCheckData, { inventoryCheckDetails: materialDataList });
// 合并表单数据和表格数据
// const combinedData = Object.assign({}, ...complaintNoticeData.array(item => ({ [item.name]: item.value })), ...materialData);
console.log(combinedData)
// 使用 JSON.stringify() 序列化数据
const jsonData = JSON.stringify(combinedData);
// 发送 AJAX 请求到后端接口
$.operate.saveJson(prefix + "/detail", jsonData);
}
//添加物料信息
function insertRow() {
var url = ctx + 'warehouse/inventoryCheck/materialSelect';
var options = {
title: '选择物料',
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
//收款凭证table列表
//库存物料table列表
$(function() {
var options = {
modalName: "收款凭证",
modalName: "库存物料",
url: prefix + '/getInventoryCheckDetailList',
queryParams: queryParams,
showColumns: false,
@ -155,7 +96,6 @@
showSearch:false,
singleSelect:true,
columns: [
{checkbox: false},
{title: '库存盘点详情ID', field: 'inventoryCheckDetailId', visible: false},
{title: '料号', field: 'materialNo',},
{title: '物料名称', field: 'materialName',},
@ -182,81 +122,6 @@
}
function doSubmit(index, layero,uniqueId){
console.log(uniqueId);
var iframeWin = window[layero.find('iframe')[0]['name']];
var rowData = iframeWin.$('#bootstrap-materialSelect-table').bootstrapTable('getSelections')[0];
console.log("rowData: "+rowData);
$("#bootstrap-table").bootstrapTable('insertRow', {
index:1,
row: {
materialNo:rowData.materialNo,
materialName: rowData.materialName,
materialDescribe: rowData.materialDescribe,
materialUnit: rowData.materialUnit,
inventoryCheckNum : "",
inventoryAccountNum : "",
warehouseStoreAddress : "",
batchNumber : "",
remark : ""
}
})
layer.close(index);
}
// 逻辑删除前端的一行数据
function removeRow(materialNo){
$("#bootstrap-table").bootstrapTable('remove', {
field: 'materialNo',
values: materialNo
})
}
function loadWarehouseCodes() {
var url = ctx + 'stock/stockInfo/getAllWarehouseCode';
$("#stockName").select2({
ajax: {
theme: "bootstrap",
allowClear: true,
placeholder: "请选择一个料号",
type: 'GET', // 请求类型
url: url, // 后端接口URL
dataType: 'json', // 预期服务器返回的数据类型
data: function(params) {
return {
q: params.term, // 搜索关键词
page: params.page || 1 ,// 当前页码
// 其他参数
pageSize: 30
};
},
processResults: function(data, params) {
params.page = params.page || 1;
var options = [];
for (var i = 0; i < data.length; i++) {
var option = {
id: data[i].stockName,
text: data[i].stockName,
title: data[i].stockNO
};
options.push(option);
}
var moreDataAvaliable = (params.page * 30) < data.total_count;
return {
// 实现下拉实现填入stockName
results: options,
pagination: {
more: moreDataAvaliable // 是否还有更多数据
}
};
}
}
});
}
$('#stockName').on('select2:select', function(e) {
var data = e.params.data;
$("input[name='warehouseCode']").val(data.title);
});
</script>
</body>
</html>

76
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/edit.html

@ -91,6 +91,10 @@
obj[item.name] = item.value;
return obj;
}, {});
const selectedOptionText = $("#stockName option:selected").text();
inventoryCheckData.warehouseName = selectedOptionText;
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据
var table = $('#bootstrap-table').bootstrapTable('getData');
@ -152,7 +156,6 @@
showSearch:false,
singleSelect:true,
columns: [
{checkbox: false},
{title: '库存盘点详情ID', field: 'inventoryCheckDetailId', visible: false},
{title: '料号', field: 'materialNo',},
{title: '物料名称', field: 'materialName',},
@ -166,14 +169,15 @@
{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.receivablesRecordsId + '\')"><i class="fa fa-remove"></i>删除</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(\'' + row.materialNo + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
}
}
]
};
$.table.init(options);
loadWarehouseCodes();
var stockName = warehouseInventoryCheck.warehouseName;
loadWarehouseCodes(stockName);
})
function queryParams(params) {
@ -213,51 +217,37 @@
})
}
// 加载仓库Id列表函数
function loadWarehouseCodes() {
function loadWarehouseCodes(defaultStockName) {
var url = ctx + 'stock/stockInfo/getAllWarehouseCode';
$("#stockName").select2({
ajax: {
theme: "bootstrap",
allowClear: true,
placeholder: "请选择一个料号",
type: 'GET', // 请求类型
url: url, // 后端接口URL
dataType: 'json', // 预期服务器返回的数据类型
data: function(params) {
return {
q: params.term, // 搜索关键词
page: params.page || 1 ,// 当前页码
// 其他参数
pageSize: 30
};
},
processResults: function(data, params) {
params.page = params.page || 1;
var options = [];
for (var i = 0; i < data.length; i++) {
var option = {
id: data[i].stockName,
text: data[i].stockName,
title: data[i].stockNO
};
options.push(option);
$.ajax({
url: url,
type: 'GET',
dataType: 'json',
success: function(data) {
var select = $('#stockName');
$.each(data, function(i, option) {
var optionElement = $('<option>', {
value: option.stockNO,
text : option.stockName
});
select.append(optionElement);
if (option.stockName === defaultStockName) {
optionElement.prop('selected', true);
}
var moreDataAvaliable = (params.page * 30) < data.total_count;
return {
// 实现下拉实现填入stockName
results: options,
pagination: {
more: moreDataAvaliable // 是否还有更多数据
}
};
}
});
// 给下拉框添加 change 事件监听器
select.on('change', function() {
// 获取选中的 stockNo
var selectedStockNo = $(this).val();
// 将选中的 stockNo 赋值给指定的输入框
$("input[name='warehouseCode']").val(selectedStockNo);
});
},
error: function(error) {
console.log('Error: ', error);
}
});
}
$('#stockName').on('select2:select', function(e) {
var data = e.params.data;
$("input[name='warehouseCode']").val(data.title);
});
</script>
</body>

42
ruoyi-admin/src/main/resources/templates/warehouse/inventoryCheck/inventoryCheck.html

@ -49,7 +49,7 @@
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="warehouse:inventoryCheck:add">
<i class="fa fa-plus"></i> 添加
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="warehouse:inventoryCheck:export">
<a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="warehouse:inventoryCheck:export">
<i class="fa fa-download"></i> 导出
</a>
</div>
@ -89,14 +89,6 @@
title: '库存盘点人名',
field: 'inventoryCheckName',
},
{
title: '料号',
field: 'materialNo',
},
{
title: '物料名称',
field: 'materialName',
},
{
title: '仓库号',
field: 'warehouseCode',
@ -121,14 +113,15 @@
title: '备注内容',
field: 'remark',
},
{
title: '录入时间',
field: 'createTime',
},
{
title: '录入人',
field: 'createBy',
},
{
title: '录入时间',
field: 'createTime',
width: 120,
},
{
title: '更新人',
field: 'updateBy',
@ -159,6 +152,29 @@
console.log(url);
$.modal.open("库存盘点详情",url);
}
// 导出
function exportExcel() {
var ids = $.table.selectColumns("inventoryCheckCode");
var dataParam = $("#formId").serializeArray();
let tipMsg = "确定导出当前所有数据吗?";
if ($.common.isNotEmpty(ids)) {
tipMsg = `确定导出 ${ids} 数据吗?`;
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>
</body>
</html>
Loading…
Cancel
Save