|
@ -102,114 +102,186 @@ |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<!-- <div class="row">--> |
|
|
|
|
|
<!-- <button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button>--> |
|
|
|
|
|
<!-- <button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button>--> |
|
|
|
|
|
<!-- <div class="col-sm-12 select-table table-striped">--> |
|
|
|
|
|
<!-- <table id="bootstrap-sub-table-1"></table>--> |
|
|
|
|
|
<!-- </div>--> |
|
|
|
|
|
<!-- </div>--> |
|
|
|
|
|
</form> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="container"> |
|
|
|
|
|
<!-- 增加设备履历 --> |
|
|
|
|
|
<div class="row"> |
|
|
|
|
|
<div class="col-sm-12 d-flex align-items-center"> |
|
|
|
|
|
<a class="btn btn-success ml-auto" onclick="addEquipMaterialDetail()"> |
|
|
|
|
|
<i class="fa fa-plus"></i> 增加 |
|
|
|
|
|
</a> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
<div class="row"> |
|
|
<div class="row"> |
|
|
<button type="button" class="btn btn-white btn-sm" onclick="addRow()"><i class="fa fa-plus"> 增加</i></button> |
|
|
|
|
|
<button type="button" class="btn btn-white btn-sm" onclick="sub.delRow()"><i class="fa fa-minus"> 删除</i></button> |
|
|
|
|
|
<div class="col-sm-12 select-table table-striped"> |
|
|
<div class="col-sm-12 select-table table-striped"> |
|
|
<table id="bootstrap-sub-table-1"></table> |
|
|
<table id="form-equipMaterialDetail-add"></table> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
|
</form> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
<th:block th:include="include :: footer" /> |
|
|
<th:block th:include="include :: footer" /> |
|
|
<th:block th:include="include :: select2-js" /> |
|
|
<th:block th:include="include :: select2-js" /> |
|
|
|
|
|
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|
|
<script th:inline="javascript"> |
|
|
<script th:inline="javascript"> |
|
|
var prefix = ctx + "erp/equipmentResume"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var equipMaterial = [[${equipMaterial}]]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var prefix = ctx + "system/makeorder"; |
|
|
|
|
|
// var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; |
|
|
$(function(){ |
|
|
$(function(){ |
|
|
|
|
|
|
|
|
var options = { |
|
|
var options = { |
|
|
id: 'bootstrap-sub-table-1', |
|
|
id: "form-equipMaterialDetail-add", |
|
|
|
|
|
url: prefix + "/getEquipMaterialDetails", |
|
|
pagination: false, |
|
|
pagination: false, |
|
|
showSearch: false, |
|
|
showSearch: false, |
|
|
showRefresh: false, |
|
|
showRefresh: false, |
|
|
showToggle: false, |
|
|
showToggle: false, |
|
|
showColumns: false, |
|
|
showColumns: false, |
|
|
|
|
|
queryParams:queryParams, |
|
|
sidePagination: "client", |
|
|
sidePagination: "client", |
|
|
columns: [{ |
|
|
columns: [{ |
|
|
checkbox: true |
|
|
checkbox: true |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
field: 'index', |
|
|
field: 'equipmentIndex', |
|
|
align: 'center', |
|
|
align: 'center', |
|
|
title: "序号", |
|
|
title: "序号", |
|
|
formatter: function (value, row, index) { |
|
|
formatter: function (value, row, index) { |
|
|
var columnIndex = $.common.sprintf("<input type='hidden' name='equipResumes[%s].index' value='%s'>", index,$.table.serialNumber(index)); |
|
|
// 使用bootstrap-table的内置序号生成 |
|
|
var columnId = $.common.sprintf("<input type='hidden' name='equipResumes[%s].id' value='%s'>", index, row.id); |
|
|
return index + 1; |
|
|
return columnIndex + $.table.serialNumber(index) + columnId; |
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
field: 'equipmentId', |
|
|
field: 'equipmentId', |
|
|
align: 'center', |
|
|
align: 'center', |
|
|
title: '出货设备id', |
|
|
title: '出货设备id', |
|
|
formatter: function(value, row, index) { |
|
|
// formatter: function(value, row, index) { |
|
|
return '添加后系统自动生成'; |
|
|
// return '添加后系统自动生成'; |
|
|
} |
|
|
// } |
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
field: 'equipmentModel', |
|
|
field: 'equipmentModel', |
|
|
align: 'center', |
|
|
align: 'center', |
|
|
title: '设备型号', |
|
|
title: '设备型号', |
|
|
formatter: function(value, row, index) { |
|
|
editable:true |
|
|
var html = $.common.sprintf("<input class='form-control equipmentModel' type='text' name='equipResumes[%s].equipmentModel' value='%s'>", index, value); |
|
|
|
|
|
return html; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
field: 'serialNo', |
|
|
field: 'serialNo', |
|
|
align: 'center', |
|
|
align: 'center', |
|
|
title: '流水号', |
|
|
title: '流水号', |
|
|
formatter: function(value, row, index) { |
|
|
editable:true |
|
|
var html = $.common.sprintf("<input class='form-control' type='text' name='equipResumes[%s].serialNo' value='%s'>", index, value); |
|
|
|
|
|
return html; |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
field: 'producePic', |
|
|
field: 'producePic', |
|
|
align: 'center', |
|
|
align: 'center', |
|
|
title: '生产图片', |
|
|
title: '生产图片', |
|
|
formatter: function(value, row, index) { |
|
|
editable:true |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
{ |
|
|
{ |
|
|
title: '操作', |
|
|
title: '操作', |
|
|
align: 'center', |
|
|
align: 'center', |
|
|
formatter: function(value, row, index) { |
|
|
formatter: function (value, row, index) { |
|
|
var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index); |
|
|
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="removeRow(' + index + ')"><i class="fa fa-remove"></i>删除</a>'; |
|
|
return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>'; |
|
|
} |
|
|
} |
|
|
} |
|
|
}] |
|
|
|
|
|
|
|
|
] |
|
|
}; |
|
|
}; |
|
|
$.table.init(options); |
|
|
$.table.init(options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
function addRow() { |
|
|
function queryParams(params) { |
|
|
var count = $("#bootstrap-sub-table-1").bootstrapTable('getData').length; |
|
|
var curParams = { |
|
|
var row = { |
|
|
// 传递参数查询参数 |
|
|
index: $.table.serialNumber(count), |
|
|
makeNo: equipMaterial.makeNo, |
|
|
|
|
|
quoteId: equipMaterial.quoteId |
|
|
|
|
|
}; |
|
|
|
|
|
return curParams; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//添加设备履历 |
|
|
|
|
|
function addEquipMaterialDetail() { |
|
|
|
|
|
var newRow = { |
|
|
equipmentId: "", |
|
|
equipmentId: "", |
|
|
equipmentModel: "", |
|
|
equipmentModel: "", |
|
|
serialNo: "", |
|
|
serialNo: "", |
|
|
producePic: "", |
|
|
producePic: "", |
|
|
} |
|
|
// 假设每个新增的行都有一个唯一的标识符或者索引,这里为了演示直接使用时间戳 |
|
|
sub.addRow(row); |
|
|
equipmentIndex: new Date().getTime(), |
|
|
|
|
|
}; |
|
|
|
|
|
$('#form-equipMaterialDetail-add').bootstrapTable('append', newRow); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function removeRow(index) { |
|
|
|
|
|
var data = $('#form-equipMaterialDetail-add').bootstrapTable('getData'); |
|
|
|
|
|
var row = data[index]; // 获取要删除的行数据 |
|
|
|
|
|
if (row) { |
|
|
|
|
|
$('#form-equipMaterialDetail-add').bootstrapTable('remove', { |
|
|
|
|
|
field: 'equipmentIndex', |
|
|
|
|
|
values: [row.equipmentIndex] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$("#form-equipMaterial-add").validate({ |
|
|
$("#form-equipMaterial-add").validate({ |
|
|
focusCleanup: true |
|
|
focusCleanup: true |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
/*function submitHandler() { |
|
|
/* |
|
|
if ($.validate.form()) { |
|
|
* 提交设备履历信息 |
|
|
$.operate.save(prefix + "/edit", $('#form-equipMaterial-add').serialize()); |
|
|
* */ |
|
|
|
|
|
function submitHandler() { |
|
|
|
|
|
// 获取表单数据 |
|
|
|
|
|
const equipMaterialData = $("#form-equipMaterial-add").serializeArray().reduce((obj, item) => { |
|
|
|
|
|
obj[item.name] = item.value; |
|
|
|
|
|
return obj; |
|
|
|
|
|
}, {}); |
|
|
|
|
|
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据 |
|
|
|
|
|
// var table = $('#form-equipMaterialDetail-add').bootstrapTable('getData'); |
|
|
|
|
|
//获取选中复选框行的数据 |
|
|
|
|
|
const selectedRows = $("#form-equipMaterialDetail-add").bootstrapTable('getSelections'); |
|
|
|
|
|
// 检查表格数据是否为空 |
|
|
|
|
|
if (selectedRows.length===0){ |
|
|
|
|
|
$.modal.alertWarning("请至少添加一条数据后再保存!"); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
}*/ |
|
|
// 将表数据转换成与complaintNoticeData格式一致的数组 |
|
|
|
|
|
var equipDetailDataList = selectedRows.map(function(item) { |
|
|
|
|
|
// 根据实际字段名调整 |
|
|
|
|
|
return { |
|
|
|
|
|
"equipmentId": item.equipmentId, |
|
|
|
|
|
"equipmentModel": item.equipmentModel, |
|
|
|
|
|
"serialNo": item.serialNo, |
|
|
|
|
|
"producePic": item.producePic |
|
|
|
|
|
// ...其他字段 |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 合并表单数据和表格数据 |
|
|
|
|
|
const combinedData = Object.assign({}, equipMaterialData, { sysEquipDetailDtos: equipDetailDataList }); |
|
|
|
|
|
|
|
|
|
|
|
console.log(combinedData) |
|
|
|
|
|
// 使用 JSON.stringify() 序列化数据 |
|
|
|
|
|
const jsonData = JSON.stringify(combinedData); |
|
|
|
|
|
// 发送 AJAX 请求到后端接口 |
|
|
|
|
|
$.operate.saveJson(prefix + "/addEquipmentResumeSave", jsonData); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|
</html> |
|
|
</html> |