|
|
@ -43,6 +43,8 @@ |
|
|
|
|
|
|
|
var qualityRefundsExchanges = [[${qualityRefundsExchanges}]]; |
|
|
|
|
|
|
|
var $table = $("#bootstrap-table"); |
|
|
|
|
|
|
|
var prefix = ctx + "quality/refundsExchanges"; |
|
|
|
$("#form-qualityRefundsExchanges-edit").validate({ |
|
|
|
focusCleanup: true |
|
|
@ -79,10 +81,15 @@ |
|
|
|
"materialUnit": item.materialUnit, |
|
|
|
"materialBrand": item.materialBrand, |
|
|
|
"materialDescribe": item.materialDescribe, |
|
|
|
"snCode": item.snCode, |
|
|
|
"complaintProblem": item.complaintProblem, |
|
|
|
// "emergencyDegree": item.emergencyDegree, |
|
|
|
"adverseReportUrl": item.adverseReportUrl, |
|
|
|
"makeTotal":item.makeTotal, |
|
|
|
"qualityHasqualifiedNum":item.qualityHasqualifiedNum, |
|
|
|
"thisArrivedNum":item.thisArrivedNum, |
|
|
|
"qualityUnqualifiedNum":item.qualityUnqualifiedNum, |
|
|
|
"supplierCode":item.supplierCode, |
|
|
|
"supplierName":item.supplierName, |
|
|
|
"customerContact":item.customerContact, |
|
|
|
"contactNumber":item.contactNumber, |
|
|
|
"supplierAddress":item.supplierAddress, |
|
|
|
// ...其他字段 |
|
|
|
}; |
|
|
|
}); |
|
|
@ -180,13 +187,15 @@ |
|
|
|
title: '品质不合格数', |
|
|
|
field: 'qualityUnqualifiedNum', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '选择供应商ID', |
|
|
|
field: 'supplierCode', |
|
|
|
{title: '选择供应商ID',field: 'supplierCode', |
|
|
|
formatter:function (value, row, index) { |
|
|
|
return supplierCodeAsyncFormatter(value,row,index); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '选择供应商名称', |
|
|
|
field: 'supplierName', |
|
|
|
{title: '选择供应商名称',field: 'supplierName', |
|
|
|
formatter:function(value, row, index){ |
|
|
|
return getSupplierNameType(value,row,index) |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '退货联系人', |
|
|
@ -215,6 +224,78 @@ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 自定义供应商代码列的格式化函数,异步获取供应商代码 |
|
|
|
function supplierCodeAsyncFormatter(value, row, index) { |
|
|
|
var selectHtml = '<select class="form-control supplier-code" onchange="supplierCodeChange(this, ' + index + ')">'; |
|
|
|
// 先不填充,等待ajax获取数据 |
|
|
|
selectHtml += '</select>'; |
|
|
|
loadSupplierCodes(selectHtml, index); // 异步加载供应商代码 |
|
|
|
return selectHtml; |
|
|
|
} |
|
|
|
|
|
|
|
// 加载供应商代码的函数 |
|
|
|
function loadSupplierCodes(selectHtml, index) { |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'system/supplier/getSupplierCodes', // 获取所有供应商代码 |
|
|
|
type: 'POST', |
|
|
|
dataType: 'json', |
|
|
|
success: function (codes) { |
|
|
|
var selectElement = $('.supplier-code:eq(' + index + ')'); |
|
|
|
codes.forEach(function (code) { |
|
|
|
selectElement.append('<option value="' + code.supplierCode + '">' + code.supplierCode + '</option>'); |
|
|
|
}); |
|
|
|
// 设置默认值(如果存在) |
|
|
|
var rowData = $table.bootstrapTable('getData')[index]; |
|
|
|
if (rowData && rowData.supplierCode) { |
|
|
|
selectElement.val(rowData.supplierCode); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 列中获取成本类型的下拉改变数据 |
|
|
|
function supplierCodeChange(selectElement, rowIndex) { |
|
|
|
var newSupplierCode = $(selectElement).val(); |
|
|
|
var tableData = $table.bootstrapTable('getData'); |
|
|
|
var newRow = tableData[rowIndex]; |
|
|
|
newRow.supplierCode = newSupplierCode; |
|
|
|
// getSupplierNameType(newRow.supplierCode,newRow,rowIndex); |
|
|
|
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
function getSupplierNameType(value, row, index) { |
|
|
|
var selectHtml = '<select class="form-control" onchange="onSupplierNameChange(this, ' + index + ')">'; |
|
|
|
// 假设此函数根据供应商ID返回设备列表 |
|
|
|
var supplierNames = []; |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'system/supplier/getSupplierName', |
|
|
|
type: 'post', |
|
|
|
data: {supplierCode: row.supplierCode}, |
|
|
|
async: false, |
|
|
|
success: function (result) { |
|
|
|
console.log(result); |
|
|
|
supplierNames = result; |
|
|
|
} |
|
|
|
}); |
|
|
|
if (supplierNames) { |
|
|
|
supplierNames.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child.supplierCode + '"' + (value === child.supplierCode ? ' selected' : '') + '>' + child.supplierName + '</option>'; |
|
|
|
}); |
|
|
|
selectHtml += '</select>'; |
|
|
|
return selectHtml; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 供应商名称改变时的处理函数 |
|
|
|
function onSupplierNameChange(selectElement, rowIndex) { |
|
|
|
var newSupplierName = $(selectElement).val(); |
|
|
|
var tableData = $table.bootstrapTable('getData'); |
|
|
|
var newRow = tableData[rowIndex]; // 获取当前行数据 |
|
|
|
newRow.supplierName = newSupplierName; |
|
|
|
// 更新行数据 |
|
|
|
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
} |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |