function insertRow() {
// 获取现有的表格数据
var currentData = $('#' + table.options.id).bootstrapTable('getData');
// 保存当前输入的数据
currentData.forEach(function (row, index) {
var processNameInput = $("input[name='processName[" + index + "]']").val();
var targetNumInput = $("input[name='targetNum[" + index + "]']").val();
var realityNumInput = $("input[name='realityNum[" + index + "]']").val();
if (processNameInput !== undefined) {
row.processName = processNameInput;
}
if (targetNumInput !== undefined) {
row.targetNum = targetNumInput;
}
if (realityNumInput !== undefined) {
row.realityNum = realityNumInput;
}
});
// 生成唯一的 id
var newRowId = 'row-' + Date.now() + '-' + Math.floor(Math.random() * 1000);
var newRow = {
id: newRowId,
processName: '',
targetNum: '',
realityNum: '',
workShopId: $('#treeId').val(),
groupId: null,
processId: null,
isNew: true // 添加标记
};
// 添加新行到现有数据
currentData.push(newRow);
// 更新表格数据
$('#' + table.options.id).bootstrapTable('load', currentData);
}
04-22
1800
03-31
4162