liuxiaoxu
6 months ago
3 changed files with 277 additions and 6 deletions
@ -0,0 +1,224 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="zh" xmlns:th="http://www.thymeleaf.org" > |
|||
<head> |
|||
<th:block th:include="include :: header('新增品质管理退换货单')" /> |
|||
<th:block th:include="include :: datetimepicker-css" /> |
|||
</head> |
|||
<body class="white-bg"> |
|||
<div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
|||
<form class="form-horizontal m" id="form-returnAfterStorageDetail-edit" th:object="${qualityRefundsExchanges}"> |
|||
<input name="refundsExchangesId" th:field="*{refundsExchangesId}" type="hidden"> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">退换货单号:</label> |
|||
<div class="col-sm-8"> |
|||
<input name="refundsExchangesCode" th:field="*{refundsExchangesCode}" class="form-control" type="text"> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">交检时间:</label> |
|||
<div class="col-sm-8"> |
|||
<div class="input-group date"> |
|||
<input name="deliveryInspectionTime" th:value="${#dates.format(qualityRefundsExchanges.deliveryInspectionTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text"> |
|||
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<div class="form-group"> |
|||
<label class="col-sm-3 control-label">品质备注:</label> |
|||
<div class="col-sm-8"> |
|||
<input name="qualityRemark" th:field="*{qualityRemark}" class="form-control" type="text"> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
<!--物料信息--> |
|||
<div class="container"> |
|||
<div class="row"> |
|||
<div class="col-sm-12 select-table table-striped"> |
|||
<table id="bootstrap-table"></table> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
<th:block th:include="include :: footer" /> |
|||
<th:block th:include="include :: datetimepicker-js" /> |
|||
<!--用于可以修改列表字段的插件--> |
|||
<th:block th:include="include :: bootstrap-table-editable-js" /> |
|||
<script th:inline="javascript"> |
|||
var prefix = ctx + "quality/refundsExchanges" |
|||
var refundsExchangesCode = /*[[${refundsExchangesCode}]]*/ ''; |
|||
|
|||
var qualityRefundsExchanges = [[${qualityRefundsExchanges}]]; |
|||
|
|||
$("input[name='deliveryInspectionTime']").datetimepicker({ |
|||
format: "yyyy-mm-dd", |
|||
minView: "month", |
|||
autoclose: true |
|||
}); |
|||
|
|||
$("#form-returnAfterStorageDetail-edit").validate({ |
|||
focusCleanup: true |
|||
}); |
|||
|
|||
// 新增提交 |
|||
function submitHandler() { |
|||
// 获取表单数据 |
|||
const refundsExchangesData = $("#form-refundsExchanges-add").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 { |
|||
"materialNo": item.materialNo, // 假设id对应materialId |
|||
"materialPhotourl": item.materialPhotourl, // 假设quantity是物料数量字段 |
|||
"materialName": item.materialName, |
|||
"materialType": item.materialType, |
|||
"materialDescribe": item.materialDescribe, |
|||
"materialUnit": item.materialUnit, |
|||
"materialBrand": item.materialBrand, |
|||
"materialProcessMethod":item.materialProcessMethod, |
|||
"refundsExchangesNum":item.refundsExchangesNum |
|||
// ...其他字段 |
|||
}; |
|||
}); |
|||
|
|||
// 将全局变量 refundsExchangesCode 添加到要提交的数据中 |
|||
const combinedData = Object.assign({}, refundsExchangesData, { |
|||
refundsExchangesDetails: materialDataList, |
|||
refundsExchangesCode: refundsExchangesCode // 直接使用全局变量 |
|||
}); |
|||
// 合并表单数据和表格数据 |
|||
console.log(combinedData) |
|||
// 使用 JSON.stringify() 序列化数据 |
|||
const jsonData = JSON.stringify(combinedData); |
|||
// 发送 AJAX 请求到后端接口 |
|||
$.operate.saveJson(prefix + "/add", jsonData); |
|||
} |
|||
|
|||
//物料信息展示列表 |
|||
$(function() { |
|||
var options = { |
|||
modalName: "选择物料", |
|||
url: ctx + "quality/refundsExchanges/getMaterialListByRefundsExchangesCode", |
|||
queryParams: queryParams, |
|||
showSearch: false, |
|||
showRefresh: false, |
|||
showToggle: false, |
|||
showColumns: false, |
|||
pagination: false, // 设置不分页 |
|||
columns: [{ |
|||
checkbox: true |
|||
}, |
|||
{ |
|||
title: '退换货单号', |
|||
field: 'refundsExchangesCode', |
|||
visible: false |
|||
}, |
|||
|
|||
{ |
|||
title: '料号', |
|||
field: 'materialNo', |
|||
}, |
|||
{ |
|||
title: '图片', |
|||
field: 'materialPhotourl', |
|||
}, |
|||
{ |
|||
title: '物料名称', |
|||
field: 'materialName', |
|||
}, |
|||
{ |
|||
title: '物料类型', |
|||
field: 'materialType', |
|||
}, |
|||
{ |
|||
title: '描述', |
|||
field: 'materialDescribe', |
|||
}, |
|||
{ |
|||
title: '品牌', |
|||
field: 'materialBrand', |
|||
}, |
|||
{ |
|||
title: '单位', |
|||
field: 'materialUnit', |
|||
}, |
|||
{ |
|||
title: '加工方式', |
|||
field: 'materialProcessMethod', |
|||
}, |
|||
{ |
|||
title: '品质报告', |
|||
align: 'center', |
|||
formatter: function(value, row, index) { |
|||
// 这里直接使用row对象获取refundsExchangesCode,假设它是存在的 |
|||
var actions = []; |
|||
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="qualityReport(\'' + row.materialNo + '\', \'' + refundsExchangesCode + '\')"><i class="fa fa-plus"></i>报告</a> '); |
|||
return actions.join(''); |
|||
} |
|||
}, |
|||
{ |
|||
title: '退换数', |
|||
field: 'refundsExchangesNum', |
|||
} |
|||
] |
|||
}; |
|||
$.table.init(options); |
|||
}) |
|||
|
|||
function queryParams(params) { |
|||
var curParams = { |
|||
// 传递参数查询参数 |
|||
refundsExchangesCode: qualityRefundsExchanges.refundsExchangesCode |
|||
}; |
|||
console.log(curParams); |
|||
return curParams; |
|||
} |
|||
|
|||
|
|||
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, |
|||
materialPhotourl:rowData.materialPhotourl, |
|||
materialName: rowData.materialName, |
|||
materialType: rowData.materialType, |
|||
materialDescribe: rowData.materialDescribe, |
|||
materialBrand: rowData.materialBrand, |
|||
materialUnit: rowData.materialUnit, |
|||
materialProcessMethod: rowData.materialProcessMethod, |
|||
makeTotal:rowData.makeTotal |
|||
} |
|||
}) |
|||
layer.close(index); |
|||
} |
|||
|
|||
|
|||
/*品质报告*/ |
|||
function qualityReport(materialNo, refundsExchangesCode) { |
|||
var queryParams = new URLSearchParams(); |
|||
queryParams.append('materialNo', materialNo); |
|||
queryParams.append('refundsExchangesCode', encodeURIComponent(refundsExchangesCode)); |
|||
|
|||
var url = ctx + 'quality/refundsExchanges/qualityReport?' + queryParams.toString(); |
|||
$.modal.open("品质报告", url); |
|||
} |
|||
|
|||
</script> |
|||
</body> |
|||
</html> |
Loading…
Reference in new issue