领料,退料
This commit is contained in:
parent
05c2643930
commit
7901fbc2d0
|
|
@ -63,7 +63,7 @@ function setParams(obj) {
|
|||
// 设置公司输入框的值
|
||||
$('#company').val(companyName);
|
||||
$('#companyName').val(companyName);
|
||||
$('#remark').val(companyName);
|
||||
$('#remark').val(companyName+"退还");
|
||||
|
||||
// 更新表单数据
|
||||
if (form && typeof form.val === 'function') {
|
||||
|
|
@ -400,15 +400,14 @@ function setSelectData(proList) {
|
|||
|
||||
console.log("设置公司名称:", companyName);
|
||||
|
||||
// 设置公司输入框的值
|
||||
$('#company').val(companyName);
|
||||
|
||||
$('#companyName').val(companyName);
|
||||
$('#remark').val(companyName);
|
||||
|
||||
// 如果 form 对象存在,更新表单数据
|
||||
if (window.form && typeof window.form.val === 'function') {
|
||||
window.form.val('formInfo', {
|
||||
company: companyName,
|
||||
|
||||
companyName: companyName
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
let objParam;
|
||||
let form, table, upload, tableIns, layer;
|
||||
let pageNum = 1;
|
||||
$('button[onclick="print()"]').hide();
|
||||
|
||||
function setParams(params) {
|
||||
objParam = JSON.parse(params);
|
||||
|
|
@ -38,6 +39,10 @@ function getDetailsById() {
|
|||
}, null);
|
||||
// 基本数据表格赋值
|
||||
function setTableData(obj) {
|
||||
// 根据status字段控制打印退料单按钮的显示
|
||||
if (objParam.status != 0) {
|
||||
$('button[onclick="print()"]').show();
|
||||
}
|
||||
$('#code2').html(obj.code + '<a style="margin:0 5px;color:#409EFF;cursor: pointer;" onclick=\'viewGs(' + JSON.stringify(obj) + ')\'>查看概述</a>');
|
||||
$('#backNum').html(obj.backNum);
|
||||
$('#manager').html(obj.manager);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ function setParams(obj) {
|
|||
// 设置公司输入框的值
|
||||
$('#company').val((companyName !== null && companyName !== '') ? companyName : '/');
|
||||
$('#companyName').val(companyName); // 设置隐藏字段
|
||||
$('#remark').val((companyName !== null && companyName !== '') ? companyName : '/');
|
||||
$('#remark').val((companyName !== null && companyName !== '') ? companyName+"领用" : '/');
|
||||
// 触发input事件
|
||||
$('#company').trigger('input');
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ function setSelectProData(proList) {
|
|||
// 设置公司输入框的值
|
||||
$('#company').val(companyName);
|
||||
$('#companyName').val(companyName);
|
||||
$('#remark').val(remark);
|
||||
$('#remark').val(remark+"领用");
|
||||
// 如果form对象存在,更新表单数据
|
||||
if (window.form && typeof window.form.val === 'function') {
|
||||
window.form.val('formInfo', {
|
||||
|
|
|
|||
|
|
@ -155,15 +155,15 @@ function initTable() {
|
|||
{
|
||||
field: "unit",
|
||||
title: "单位",
|
||||
width: '15%',
|
||||
width: '10%',
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
},
|
||||
{
|
||||
field: "num",
|
||||
width: '15%',
|
||||
title: "库存数量",
|
||||
width: '10%',
|
||||
title: "可用库存量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
|
|
@ -176,8 +176,8 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "dbfNum",
|
||||
width: '15%',
|
||||
title: "待处置量",
|
||||
width: '10%',
|
||||
title: "待处理量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
|
|
@ -188,6 +188,20 @@ function initTable() {
|
|||
return '<p style="color:#f56c6c;">' + d.dbfNum + ' </p>';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "totalNum",
|
||||
width: '15%',
|
||||
title: "库存总数",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort:true,
|
||||
templet: function (d) {
|
||||
if(d.totalNum > 0){
|
||||
return d.totalNum;
|
||||
}
|
||||
return '<p style="color:#f56c6c;">' + d.totalNum + ' </p>';
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
limits: [10, 15, 20, 25, 50, 100],
|
||||
|
|
@ -210,4 +224,4 @@ function exportExcel() {
|
|||
}
|
||||
let url = dataUrl + "backstage/inventoryCount/exportInventoryCountList";
|
||||
exportExcelUtil(url, '库存统计', JSON.stringify(params));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,6 +100,13 @@ function initTable() {
|
|||
if(res.code === 401){
|
||||
closeWindowOpen();
|
||||
}
|
||||
// 确保数据按工程名称排序
|
||||
res.list.sort(function(a, b) {
|
||||
if (a.proName < b.proName) return -1;
|
||||
if (a.proName > b.proName) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
return {
|
||||
"code": 0, // 解析接口状态
|
||||
"msg": '获取成功', // 解析提示文本
|
||||
|
|
@ -119,15 +126,15 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "proName",
|
||||
width: '10%',
|
||||
width: '9%',
|
||||
title: "工程名称",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort: true,
|
||||
sort: true
|
||||
},
|
||||
{
|
||||
field: "type",
|
||||
width: '10%',
|
||||
width: '8%',
|
||||
title: "物资类型",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -135,7 +142,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "name",
|
||||
width: '10%',
|
||||
width: '8%',
|
||||
title: "物资名称",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -143,7 +150,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "model",
|
||||
width: '10%',
|
||||
width: '8%',
|
||||
title: "规格型号",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -151,7 +158,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "unit",
|
||||
width: '6%',
|
||||
width: '5%',
|
||||
title: "单位",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -159,7 +166,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "needNum",
|
||||
width: '8%',
|
||||
width: '6%',
|
||||
title: "需用量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -170,7 +177,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "totalCg",
|
||||
width: '8%',
|
||||
width: '6%',
|
||||
title: "采购量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -182,7 +189,7 @@ function initTable() {
|
|||
{
|
||||
field: "totalLk",
|
||||
title: "利库量",
|
||||
width: '8%',
|
||||
width: '6%',
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort: true,
|
||||
|
|
@ -194,9 +201,20 @@ function initTable() {
|
|||
: `<span style='color: #666'>${totalLk}</span>`;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "price",
|
||||
width: '6%',
|
||||
title: "单价",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
return d.price || 0;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "totalCk",
|
||||
width: '8%',
|
||||
width: '7%',
|
||||
title: "出库总量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -209,9 +227,20 @@ function initTable() {
|
|||
: `<span style='color: #666'>${totalCk}</span>`;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "totalPrice",
|
||||
width: '6%',
|
||||
title: "总价",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
return d.totalPrice || 0;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "totalBack",
|
||||
width: '8%',
|
||||
width: '7%',
|
||||
title: "退还数量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -226,7 +255,7 @@ function initTable() {
|
|||
},
|
||||
{
|
||||
field: "totalDiff",
|
||||
width: '8%',
|
||||
width: '6%',
|
||||
title: "差缺量",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
|
|
@ -239,6 +268,21 @@ function initTable() {
|
|||
return totalDiff;
|
||||
},
|
||||
},
|
||||
{
|
||||
field: "totalDiffPrice",
|
||||
width: '7%',
|
||||
title: "差缺总价",
|
||||
unresize: true,
|
||||
align: "center",
|
||||
sort: true,
|
||||
templet: function (d) {
|
||||
let totalDiffPrice = d.totalDiffPrice || 0;
|
||||
if (totalDiffPrice > 0) {
|
||||
return '<span style="background-color: #f56c6c; color: #fff; border-radius: 5px; padding: 2px 5px;">' + totalDiffPrice + '</span>';
|
||||
}
|
||||
return totalDiffPrice;
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
limits: [10, 20, 30, 50, 100],
|
||||
|
|
@ -247,10 +291,102 @@ function initTable() {
|
|||
done: function (res, curr, count) {
|
||||
pageNum = tableIns.config.page.curr;
|
||||
table.resize("currentTableId");
|
||||
},
|
||||
|
||||
// 延迟执行合并操作,确保表格完全渲染
|
||||
setTimeout(function() {
|
||||
mergeProNameCells();
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 使用原生JavaScript合并工程名称相同的单元格
|
||||
function mergeProNameCells() {
|
||||
// 获取表格元素
|
||||
let tableElem = document.getElementById('currentTableId');
|
||||
if (!tableElem) {
|
||||
console.error('找不到表格元素');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取表格的tbody
|
||||
let tbody = tableElem.nextElementSibling.querySelector('.layui-table-body tbody');
|
||||
if (!tbody) {
|
||||
console.error('找不到表格tbody元素');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取所有行
|
||||
let rows = tbody.querySelectorAll('tr');
|
||||
if (rows.length <= 1) return;
|
||||
|
||||
console.log('开始合并工程名称相同的单元格,共' + rows.length + '行');
|
||||
|
||||
let startRow = 0;
|
||||
let mergeCount = 1;
|
||||
let currentProName = getProNameFromRow(rows[0]);
|
||||
|
||||
for (let i = 1; i < rows.length; i++) {
|
||||
let nextProName = getProNameFromRow(rows[i]);
|
||||
|
||||
console.log('比较行 ' + i + ':当前=' + currentProName + ',下一个=' + nextProName);
|
||||
|
||||
if (currentProName === nextProName) {
|
||||
mergeCount++;
|
||||
console.log('行 ' + i + ' 与前一行工程名称相同,合并计数:' + mergeCount);
|
||||
} else {
|
||||
// 执行合并
|
||||
if (mergeCount > 1) {
|
||||
console.log('合并行 ' + startRow + ' 到 ' + (i - 1) + ',共 ' + mergeCount + ' 行');
|
||||
mergeCells(rows, startRow, 1, mergeCount); // 工程名称在第2列(索引1)
|
||||
}
|
||||
|
||||
// 重置计数
|
||||
startRow = i;
|
||||
mergeCount = 1;
|
||||
currentProName = nextProName;
|
||||
}
|
||||
}
|
||||
|
||||
// 合并最后一组
|
||||
if (mergeCount > 1) {
|
||||
console.log('合并最后一组:行 ' + startRow + ' 到 ' + (rows.length - 1) + ',共 ' + mergeCount + ' 行');
|
||||
mergeCells(rows, startRow, 1, mergeCount); // 工程名称在第2列(索引1)
|
||||
}
|
||||
|
||||
console.log('单元格合并完成');
|
||||
}
|
||||
|
||||
// 从行中获取工程名称
|
||||
function getProNameFromRow(row) {
|
||||
// 工程名称在第2列(索引1)
|
||||
let cell = row.querySelectorAll('td')[1];
|
||||
if (cell) {
|
||||
return cell.textContent.trim();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// 合并单元格
|
||||
function mergeCells(rows, startRow, colIndex, rowspan) {
|
||||
if (startRow < 0 || startRow >= rows.length) return;
|
||||
|
||||
// 获取起始行的单元格
|
||||
let startCell = rows[startRow].querySelectorAll('td')[colIndex];
|
||||
if (!startCell) return;
|
||||
|
||||
// 设置rowspan
|
||||
startCell.rowSpan = rowspan;
|
||||
|
||||
// 隐藏被合并的单元格
|
||||
for (let i = 1; i < rowspan; i++) {
|
||||
let cell = rows[startRow + i].querySelectorAll('td')[colIndex];
|
||||
if (cell) {
|
||||
cell.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
function viewDetail(obj, type) {
|
||||
console.log('查看详情', type, obj);
|
||||
|
|
@ -305,4 +441,4 @@ function exportExcel() {
|
|||
}).catch(error => {
|
||||
layer.msg('导出失败:' + error.message, { icon: 2 });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue