2025-05-25 12:44:28 +08:00
|
|
|
|
let form, table;
|
|
|
|
|
|
let tableIns;
|
|
|
|
|
|
let pageNum = 1; // 定义分页
|
|
|
|
|
|
layui.use(["form", "table"], function () {
|
|
|
|
|
|
form = layui.form;
|
|
|
|
|
|
table = layui.table;
|
|
|
|
|
|
initTable();
|
2026-01-29 15:24:32 +08:00
|
|
|
|
// getStatistics();
|
2025-05-25 12:44:28 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 数据概览
|
|
|
|
|
|
function getStatistics() {
|
|
|
|
|
|
let encryptedData = {};
|
|
|
|
|
|
let url = dataUrl + 'backstage/projectMaterial/getStatistics?encryptedData=' + encodeURIComponent(JSON.stringify(encryptedData));
|
|
|
|
|
|
ajaxRequest(url, "GET", null, true, function () {
|
|
|
|
|
|
}, function (result) {
|
|
|
|
|
|
if (result.code === 200) {
|
|
|
|
|
|
setNum(result.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
}, function (xhr, status, error) {
|
|
|
|
|
|
errorFn(xhr, status, error)
|
|
|
|
|
|
}, null);
|
|
|
|
|
|
|
|
|
|
|
|
// 数据概览赋值
|
|
|
|
|
|
function setNum(obj) {
|
|
|
|
|
|
$('#num').html(parseInt(obj.projectCount || 0));
|
|
|
|
|
|
$('#num2').html(parseInt(obj.totalPurchaseCount || 0));
|
|
|
|
|
|
$('#num3').html(parseInt(obj.totalOutCount || 0));
|
|
|
|
|
|
$('#num4').html(parseInt(obj.totalShortageCount || 0));
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 查询/重置
|
|
|
|
|
|
function queryTable(type) {
|
|
|
|
|
|
if (type === 1) {
|
2025-12-01 15:26:40 +08:00
|
|
|
|
let keyWord = $('#keyWord').val();
|
|
|
|
|
|
let flag = checkValue(keyWord);
|
2025-05-25 12:44:28 +08:00
|
|
|
|
if (flag) {
|
2025-12-01 15:26:40 +08:00
|
|
|
|
$('#keyWord').val('');
|
|
|
|
|
|
return layer.msg('关键字查询包含特殊字符,请重新输入', { icon: 2 });
|
2025-05-25 12:44:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
let useUnit = $('#useUnit').val();
|
|
|
|
|
|
let flag2 = checkValue(useUnit);
|
|
|
|
|
|
if (flag2) {
|
|
|
|
|
|
$('#useUnit').val('');
|
|
|
|
|
|
return layer.msg('领用单位查询包含特殊字符,请重新输入', { icon: 2 });
|
|
|
|
|
|
}
|
|
|
|
|
|
reloadTable(1);
|
|
|
|
|
|
} else if (type === 2) {
|
2025-12-01 15:26:40 +08:00
|
|
|
|
$('#keyWord').val('');
|
2025-05-25 12:44:28 +08:00
|
|
|
|
$('#useUnit').val('');
|
|
|
|
|
|
$('#isShortage').val('');
|
|
|
|
|
|
layui.form.render();
|
|
|
|
|
|
reloadTable(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 刷新页面数据
|
|
|
|
|
|
function reloadData() {
|
|
|
|
|
|
reloadTable(1);
|
|
|
|
|
|
getStatistics();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重载表格
|
|
|
|
|
|
function reloadTable(pageNum) {
|
|
|
|
|
|
table.reload("currentTableId", {
|
|
|
|
|
|
where: {
|
|
|
|
|
|
encryptedData: JSON.stringify({
|
2025-12-01 15:26:40 +08:00
|
|
|
|
'keyWord': $('#keyWord').val(),
|
2025-05-25 12:44:28 +08:00
|
|
|
|
'isShortage': $('#isShortage').val()
|
|
|
|
|
|
}),
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化表格
|
|
|
|
|
|
function initTable() {
|
|
|
|
|
|
tableIns = table.render({
|
|
|
|
|
|
elem: "#currentTableId",
|
|
|
|
|
|
id: 'currentTableId',
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
authorization: sessionStorage.getItem("gz-token"),
|
|
|
|
|
|
},
|
|
|
|
|
|
// height: "full-300",
|
|
|
|
|
|
url: dataUrl + "backstage/inventoryCount/queryLedgerListByProjectAndModel",
|
|
|
|
|
|
where: {
|
|
|
|
|
|
encryptedData: JSON.stringify({
|
2025-12-01 15:26:40 +08:00
|
|
|
|
'keyWord': $('#keyWord').val(),
|
2025-05-25 12:44:28 +08:00
|
|
|
|
'leaseUnit': $('#useUnit').val(),
|
|
|
|
|
|
'isShortage': $('#isShortage').val()
|
|
|
|
|
|
}),
|
|
|
|
|
|
},
|
|
|
|
|
|
request: {
|
|
|
|
|
|
pageName: 'pageNum',
|
|
|
|
|
|
limitName: 'pageSize'
|
|
|
|
|
|
},
|
|
|
|
|
|
parseData: function (res) { // res 即为原始返回的数据
|
|
|
|
|
|
if(res.code === 401){
|
|
|
|
|
|
closeWindowOpen();
|
|
|
|
|
|
}
|
2026-01-29 15:41:46 +08:00
|
|
|
|
// 确保数据按工程名称排序
|
|
|
|
|
|
res.list.sort(function(a, b) {
|
|
|
|
|
|
if (a.proName < b.proName) return -1;
|
|
|
|
|
|
if (a.proName > b.proName) return 1;
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2025-05-25 12:44:28 +08:00
|
|
|
|
return {
|
|
|
|
|
|
"code": 0, // 解析接口状态
|
|
|
|
|
|
"msg": '获取成功', // 解析提示文本
|
|
|
|
|
|
"count": res.total, // 解析数据长度
|
|
|
|
|
|
"data": res.list // 解析数据列表
|
|
|
|
|
|
};
|
|
|
|
|
|
},
|
|
|
|
|
|
cols: [
|
|
|
|
|
|
[
|
|
|
|
|
|
{
|
|
|
|
|
|
width: '5%',
|
|
|
|
|
|
title: "序号",
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
return d.LAY_NUM;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "proName",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '9%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "工程名称",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
sort: true
|
2025-05-25 12:44:28 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "type",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '8%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "物资类型",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "name",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '8%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "物资名称",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "model",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '8%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "规格型号",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "unit",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '5%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "单位",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "needNum",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '6%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "需用量",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
return d.totalCg || 0;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "totalCg",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '6%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "采购量",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
return d.totalCg || 0;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "totalLk",
|
|
|
|
|
|
title: "利库量",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '6%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
2026-01-29 15:24:32 +08:00
|
|
|
|
const totalLk = d.totalLk || 0;
|
|
|
|
|
|
const rowData = JSON.stringify(d).replace(/"/g, '"');
|
2026-01-29 15:29:24 +08:00
|
|
|
|
return totalLk > 0
|
|
|
|
|
|
? `<a style='color: #1E9FFF' onclick='viewDetail(${rowData},1)'>${totalLk}</a>`
|
|
|
|
|
|
: `<span style='color: #666'>${totalLk}</span>`;
|
2025-05-25 12:44:28 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2026-01-29 15:41:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: "price",
|
|
|
|
|
|
width: '6%',
|
|
|
|
|
|
title: "单价",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
return d.price || 0;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-05-25 12:44:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: "totalCk",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '7%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "出库总量",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
2026-01-29 15:24:32 +08:00
|
|
|
|
const totalCk = d.totalCk || 0;
|
|
|
|
|
|
const rowData = JSON.stringify(d).replace(/"/g, '"');
|
2026-01-29 15:29:24 +08:00
|
|
|
|
return totalCk > 0
|
|
|
|
|
|
? `<a style='color: #1E9FFF' onclick='viewDetail(${rowData},2)'>${totalCk}</a>`
|
|
|
|
|
|
: `<span style='color: #666'>${totalCk}</span>`;
|
2025-05-25 12:44:28 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2026-01-29 15:41:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: "totalPrice",
|
|
|
|
|
|
width: '6%',
|
|
|
|
|
|
title: "总价",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
return d.totalPrice || 0;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-05-25 12:44:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
field: "totalBack",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '7%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "退还数量",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
2026-01-29 15:24:32 +08:00
|
|
|
|
const totalBack = d.totalBack || 0;
|
|
|
|
|
|
const rowData = JSON.stringify(d).replace(/"/g, '"');
|
2026-01-29 15:29:24 +08:00
|
|
|
|
return totalBack > 0
|
|
|
|
|
|
? `<a style='color: #1E9FFF' onclick='viewDetail(${rowData},3)'>${totalBack}</a>`
|
|
|
|
|
|
: `<span style='color: #666'>${totalBack}</span>`;
|
2025-05-25 12:44:28 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
field: "totalDiff",
|
2026-01-29 15:41:46 +08:00
|
|
|
|
width: '6%',
|
2025-05-25 12:44:28 +08:00
|
|
|
|
title: "差缺量",
|
|
|
|
|
|
unresize: true,
|
|
|
|
|
|
align: "center",
|
|
|
|
|
|
sort: true,
|
|
|
|
|
|
templet: function (d) {
|
|
|
|
|
|
let totalDiff = d.totalDiff || 0;
|
|
|
|
|
|
if (totalDiff > 0) {
|
|
|
|
|
|
return '<span style="background-color: #f56c6c; color: #fff; border-radius: 5px; padding: 2px 5px;">' + totalDiff + '</span>';
|
|
|
|
|
|
}
|
|
|
|
|
|
return totalDiff;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2026-01-29 15:41:46 +08:00
|
|
|
|
{
|
|
|
|
|
|
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;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2025-05-25 12:44:28 +08:00
|
|
|
|
],
|
|
|
|
|
|
],
|
|
|
|
|
|
limits: [10, 20, 30, 50, 100],
|
|
|
|
|
|
limit: 50,
|
|
|
|
|
|
page: false,
|
|
|
|
|
|
done: function (res, curr, count) {
|
|
|
|
|
|
pageNum = tableIns.config.page.curr;
|
|
|
|
|
|
table.resize("currentTableId");
|
2026-01-29 15:41:46 +08:00
|
|
|
|
|
|
|
|
|
|
// 延迟执行合并操作,确保表格完全渲染
|
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
|
mergeProNameCells();
|
|
|
|
|
|
}, 100);
|
|
|
|
|
|
}
|
2025-05-25 12:44:28 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-29 15:41:46 +08:00
|
|
|
|
// 使用原生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';
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-25 12:44:28 +08:00
|
|
|
|
// 查看详情
|
2026-01-29 15:24:32 +08:00
|
|
|
|
function viewDetail(obj, type) {
|
|
|
|
|
|
console.log('查看详情', type, obj);
|
|
|
|
|
|
if (type === 1) {
|
|
|
|
|
|
openIframeByParamObj("projectLkDetails", "利库详情", "./child/project_lk_details.html", "92%", "95%", obj, 0);
|
|
|
|
|
|
} else if (type===2){
|
|
|
|
|
|
openIframeByParamObj("projectCkDetails", "出库详情", "./child/project_ck_details.html", "92%", "95%", obj, 0);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
openIframeByParamObj("projectTkDetails", "退库详情", "./child/project_tk_details.html", "92%", "95%", obj, 0);
|
|
|
|
|
|
}
|
2025-05-25 12:44:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-29 15:24:32 +08:00
|
|
|
|
|
2025-05-25 12:44:28 +08:00
|
|
|
|
// 导出Excel
|
|
|
|
|
|
function exportExcel() {
|
2025-12-01 15:26:40 +08:00
|
|
|
|
let keyWord = $('#keyWord').val();
|
2025-05-25 12:44:28 +08:00
|
|
|
|
let isShortage = $('#isShortage').val();
|
2026-01-29 15:24:32 +08:00
|
|
|
|
|
2025-05-25 12:44:28 +08:00
|
|
|
|
let params = {
|
2025-12-01 15:26:40 +08:00
|
|
|
|
'keyWord': keyWord,
|
2025-05-25 12:44:28 +08:00
|
|
|
|
'isShortage': isShortage
|
|
|
|
|
|
};
|
2026-01-29 15:24:32 +08:00
|
|
|
|
|
2025-05-25 12:44:28 +08:00
|
|
|
|
let encryptedData = JSON.stringify(params);
|
|
|
|
|
|
let url = dataUrl + 'backstage/inventoryCount/exportLedgerListByProjectAndModel?encryptedData=' + encodeURIComponent(encryptedData);
|
2026-01-29 15:24:32 +08:00
|
|
|
|
|
2025-05-25 12:44:28 +08:00
|
|
|
|
// 创建隐藏的下载链接
|
|
|
|
|
|
let link = document.createElement('a');
|
|
|
|
|
|
link.href = url;
|
|
|
|
|
|
link.download = '工程物料统计_' + new Date().getTime() + '.xlsx';
|
|
|
|
|
|
link.style.display = 'none';
|
2026-01-29 15:24:32 +08:00
|
|
|
|
|
2025-05-25 12:44:28 +08:00
|
|
|
|
// 添加授权头并下载
|
|
|
|
|
|
fetch(url, {
|
|
|
|
|
|
method: 'GET',
|
|
|
|
|
|
headers: {
|
|
|
|
|
|
'authorization': sessionStorage.getItem("gz-token")
|
|
|
|
|
|
}
|
|
|
|
|
|
}).then(response => {
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
|
return response.blob();
|
|
|
|
|
|
}
|
|
|
|
|
|
throw new Error('导出失败');
|
|
|
|
|
|
}).then(blob => {
|
|
|
|
|
|
let downloadUrl = window.URL.createObjectURL(blob);
|
|
|
|
|
|
link.href = downloadUrl;
|
|
|
|
|
|
document.body.appendChild(link);
|
|
|
|
|
|
link.click();
|
|
|
|
|
|
document.body.removeChild(link);
|
|
|
|
|
|
window.URL.revokeObjectURL(downloadUrl);
|
|
|
|
|
|
layer.msg('导出成功', { icon: 1 });
|
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
|
layer.msg('导出失败:' + error.message, { icon: 2 });
|
|
|
|
|
|
});
|
2026-01-29 15:41:46 +08:00
|
|
|
|
}
|