|
|
@ -11,7 +11,7 @@ |
|
|
|
<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" disabled> |
|
|
|
<input name="refundsExchangesCode" th:field="*{refundsExchangesCode}" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
@ -25,7 +25,15 @@ |
|
|
|
<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" disabled> |
|
|
|
<input name="qualityRemark" th:field="*{qualityRemark}" class="form-control" type="text" readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-3 control-label is-required">是否退回供应商:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select name="isReturnedToSupplier" id="isReturnedToSupplier" class="form-control m-b" th:with="type=${@dict.getType('yes_or_no')}" required> |
|
|
|
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option> |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</form> |
|
|
@ -48,6 +56,8 @@ |
|
|
|
var materialTypeDatas = [[${@category.getChildByCode('materialType')}]]; |
|
|
|
|
|
|
|
var supplier = []; |
|
|
|
var supplierCodeList = []; |
|
|
|
var supplierNameList = []; |
|
|
|
var $table = $("#bootstrap-table"); |
|
|
|
|
|
|
|
var prefix = ctx + "quality/refundsExchanges"; |
|
|
@ -58,17 +68,17 @@ |
|
|
|
// 新增提交 |
|
|
|
function submitHandler() { |
|
|
|
|
|
|
|
$("input[name='refundsExchangesCode']").removeAttr("disabled"); |
|
|
|
$("input[name='qualityRemark']").removeAttr("disabled"); |
|
|
|
var isReturnedToSupplier = $("#isReturnedToSupplier").val(); |
|
|
|
if(isReturnedToSupplier === ''||isReturnedToSupplier === null||isReturnedToSupplier === undefined){ |
|
|
|
$.modal.msgError("请选择是否退回供应商"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const afterNoConfirmSupplierData = $("#form-afterNoConfirmSupplier-edit").serializeArray().reduce((obj, item) => { |
|
|
|
obj[item.name] = item.value; |
|
|
|
return obj; |
|
|
|
}, {}); |
|
|
|
// 获取bootstrap-table的数据,这里假设你使用bootstrap-table的API获取所有数据 |
|
|
|
var table = $('#bootstrap-table').bootstrapTable('getData'); |
|
|
|
|
|
|
|
// 将表数据转换成与afterNoConfirmSupplierData格式一致的数组 |
|
|
|
var materialDataList = table.map(function(item) { |
|
|
|
// 根据实际字段名调整 |
|
|
|
return { |
|
|
@ -79,6 +89,8 @@ |
|
|
|
"materialType": item.materialType, |
|
|
|
"materialUnit": item.materialUnit, |
|
|
|
"materialBrand": item.materialBrand, |
|
|
|
"materialModel": item.materialModel, |
|
|
|
"materialProcessMethod": item.materialProcessMethod, |
|
|
|
"materialDescribe": item.materialDescribe, |
|
|
|
"makeTotal":item.makeTotal, |
|
|
|
"qualityHasqualifiedNum":item.qualityHasqualifiedNum, |
|
|
@ -93,8 +105,18 @@ |
|
|
|
}; |
|
|
|
}); |
|
|
|
|
|
|
|
// 合并表单数据和表格数据 |
|
|
|
//const combinedData = Object.assign({}, ...afterNoConfirmSupplierData.map(item => ({ [item.name]: item.value })), ...materialData); |
|
|
|
if(isReturnedToSupplier === "1"){ |
|
|
|
var supplierNull = false; |
|
|
|
materialDataList.forEach(function (data){ |
|
|
|
if(data.supplierCode === ''|| data.supplierCode === null ||data.supplierCode === undefined){ |
|
|
|
supplierNull = true; |
|
|
|
} |
|
|
|
}); |
|
|
|
if(supplierNull){ |
|
|
|
$.modal.msgError("存在供应商信息为空,请选择"); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
const combinedData = Object.assign({}, afterNoConfirmSupplierData, { refundsExchangesDetails: materialDataList }); |
|
|
|
|
|
|
|
console.log(combinedData) |
|
|
@ -116,9 +138,7 @@ |
|
|
|
pagination: false, // 设置不分页 |
|
|
|
queryParams: queryParams, |
|
|
|
modalName: "选择物料", |
|
|
|
columns: [{ |
|
|
|
checkbox: true |
|
|
|
}, |
|
|
|
columns: [ |
|
|
|
{ |
|
|
|
title: '退换货详情Id', |
|
|
|
field: 'refundsExchangesDetailId', |
|
|
@ -131,10 +151,12 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '料号', |
|
|
|
field: 'materialNo' |
|
|
|
field: 'materialNo', |
|
|
|
align: 'center', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '图片', |
|
|
|
align: 'center', |
|
|
|
field: 'materialPhotourl', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.imageView(value); |
|
|
@ -142,49 +164,45 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料名称', |
|
|
|
align: 'center', |
|
|
|
field: 'materialName' |
|
|
|
}, |
|
|
|
// { |
|
|
|
// title: '物料类型', |
|
|
|
// align: 'center', |
|
|
|
// field: 'materialType', |
|
|
|
// formatter: function(value, row, index) { |
|
|
|
// return $.table.selectCategoryLabel(materialTypeDatas, value); |
|
|
|
// } |
|
|
|
// }, |
|
|
|
{ |
|
|
|
title: '物料类型', |
|
|
|
field: 'materialType', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectCategoryLabel(materialTypeDatas, value); |
|
|
|
} |
|
|
|
title: '描述', |
|
|
|
align: 'center', |
|
|
|
field: 'materialDescribe', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '物料描述', |
|
|
|
field: 'materialDescribe', |
|
|
|
title: '型号', |
|
|
|
align: 'center', |
|
|
|
field: 'materialModel', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '品牌', |
|
|
|
align: 'center', |
|
|
|
field: 'materialBrand', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '单位', |
|
|
|
align: 'center', |
|
|
|
field: 'materialUnit', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '加工方式', |
|
|
|
align: 'center', |
|
|
|
field: 'materialProcessMethod', |
|
|
|
formatter: function(value, row, index) { |
|
|
|
return $.table.selectDictLabel(processMethodDatas, value); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '订单数', |
|
|
|
field: 'makeTotal', |
|
|
|
visible: false |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '品质已合格数', |
|
|
|
field: 'qualityHasqualifiedNum', |
|
|
|
visible: false |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '本次到货数', |
|
|
|
field: 'thisArrivedNum', |
|
|
|
visible: false |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '品质报告', |
|
|
|
align: 'center', |
|
|
@ -196,33 +214,40 @@ |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '品质不合格数', |
|
|
|
align: 'center', |
|
|
|
field: 'qualityUnqualifiedNum', |
|
|
|
}, |
|
|
|
{title: '选择供应商ID',field: 'supplierCode', |
|
|
|
{ |
|
|
|
title: '供应商ID',field: 'supplierCode', |
|
|
|
align: 'center', |
|
|
|
formatter:function (value, row, index) { |
|
|
|
return supplierCodeAsyncFormatter(value,row,index); |
|
|
|
return supplierCodeFormatter(value,row,index); |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '选择供应商名称',field: 'supplierName', |
|
|
|
{title: '供应商名称',field: 'supplierName', |
|
|
|
formatter:function(value, row, index){ |
|
|
|
return getSupplierNameType(value,row,index) |
|
|
|
return supplierNameFormatter(value,row,index); |
|
|
|
} |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '退货联系人', |
|
|
|
field: 'customerContact', |
|
|
|
align: 'center', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '联系人电话', |
|
|
|
field: 'contactNumber', |
|
|
|
align: 'center', |
|
|
|
}, |
|
|
|
{ |
|
|
|
title: '退货地址', |
|
|
|
field: 'supplierAddress', |
|
|
|
align: 'center', |
|
|
|
} |
|
|
|
] |
|
|
|
}; |
|
|
|
$.table.init(options); |
|
|
|
loadSupplierCodes(); |
|
|
|
}) |
|
|
|
|
|
|
|
function queryParams(params) { |
|
|
@ -235,93 +260,110 @@ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 自定义供应商代码列的格式化函数,异步获取供应商代码 |
|
|
|
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) { |
|
|
|
function loadSupplierCodes() { |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'system/supplier/getSupplierCodes', // 获取所有供应商代码 |
|
|
|
url: ctx + 'system/supplier/matchSupplierList', // 获取所有供应商代码 |
|
|
|
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>'); |
|
|
|
success: function (result) { |
|
|
|
var supplierList = result.data; |
|
|
|
supplierList.forEach(function (data){ |
|
|
|
supplierCodeList.push(data.supplierCode); |
|
|
|
supplierNameList.push(data.supplierName); |
|
|
|
}); |
|
|
|
supplier = codes; |
|
|
|
// 设置默认值(如果存在) |
|
|
|
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; |
|
|
|
supplier.forEach(function (index){ |
|
|
|
if(index.supplierCode === newSupplierCode){ |
|
|
|
newRow.supplierName = index.supplierName; |
|
|
|
newRow.customerContact = index.customerContact; |
|
|
|
newRow.contactNumber = index.contactNumber; |
|
|
|
newRow.supplierAddress = index.customerAddress; |
|
|
|
} |
|
|
|
//自定义供应商编号的初始化函数 |
|
|
|
function supplierCodeFormatter(value, row, index){ |
|
|
|
var selectHtml = `<select class="form-control" style="width: 120px;" onchange="onSupplierCodeChange(this, ${index})">`; |
|
|
|
selectHtml += '<option value=""' + (value === undefined || value === '' ? ' selected' : '') + '>所有</option>'; |
|
|
|
supplierCodeList.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child + '"' + (value === child ? ' selected' : '') + '>' + child + '</option>'; |
|
|
|
}); |
|
|
|
// getSupplierNameType(newRow.supplierCode,newRow,rowIndex); |
|
|
|
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
|
|
|
|
selectHtml += '</select>'; |
|
|
|
return selectHtml; |
|
|
|
} |
|
|
|
|
|
|
|
function getSupplierNameType(value, row, index) { |
|
|
|
var selectHtml = '<select class="form-control" onchange="onSupplierNameChange(this, ' + index + ')">'; |
|
|
|
// 假设此函数根据供应商ID返回设备列表 |
|
|
|
var supplierNames = []; |
|
|
|
function onSupplierCodeChange(selectElement, rowIndex) { |
|
|
|
var supplierCodeValue = $(selectElement).val(); |
|
|
|
if (supplierCodeValue) { |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'system/supplier/getSupplierName', |
|
|
|
type: 'post', |
|
|
|
data: {supplierCode: row.supplierCode}, |
|
|
|
async: false, |
|
|
|
success: function (result) { |
|
|
|
console.log(result); |
|
|
|
supplierNames = result; |
|
|
|
url: ctx + 'system/supplier/getSelectSupplier', |
|
|
|
method: 'GET', |
|
|
|
dataType: 'json', |
|
|
|
data:{supplierCode: supplierCodeValue}, |
|
|
|
success: function(response) { |
|
|
|
if (response.data) { |
|
|
|
var newData = response.data; |
|
|
|
var newRowData = { |
|
|
|
supplierCode : supplierCodeValue, |
|
|
|
supplierName : newData.supplierName, |
|
|
|
customerContact : newData.customerContact, |
|
|
|
contactNumber : newData.contactNumber, |
|
|
|
supplierAddress : newData.customerAddress, |
|
|
|
}; |
|
|
|
$('#bootstrap-table').bootstrapTable('updateRow', { |
|
|
|
index: rowIndex, // 使用传递进来的索引 |
|
|
|
row: newRowData |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.error('后端请求数据为空'); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, status, error) { |
|
|
|
console.error('请求出错:', status, ", ", error); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (supplierNames) { |
|
|
|
supplierNames.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child.supplierCode + '"' + (value === child.supplierCode ? ' selected' : '') + '>' + child.supplierName + '</option>'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//自定义供应商名称的初始化函数 |
|
|
|
function supplierNameFormatter(value, row, index){ |
|
|
|
var selectHtml = `<select class="form-control" style="width: 120px;" onchange="onSupplierNameChange(this, ${index})">`; |
|
|
|
selectHtml += '<option value=""' + (value === undefined || value === '' ? ' selected' : '') + '>所有</option>'; |
|
|
|
supplierNameList.forEach(function (child) { |
|
|
|
selectHtml += '<option value="' + child + '"' + (value === child ? ' selected' : '') + '>' + child + '</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; |
|
|
|
supplier.forEach(function (index){ |
|
|
|
if(index.supplierName === newSupplierName){ |
|
|
|
newRow.customerContact = index.customerContact; |
|
|
|
newRow.contactNumber = index.contactNumber; |
|
|
|
newRow.supplierAddress = index.customerAddress; |
|
|
|
var supplierNameValue = $(selectElement).val(); |
|
|
|
console.log(supplierNameValue); |
|
|
|
if (supplierNameValue) { |
|
|
|
$.ajax({ |
|
|
|
url: ctx + 'system/supplier/getSelectSupplier', |
|
|
|
method: 'GET', |
|
|
|
dataType: 'json', |
|
|
|
data:{supplierName: supplierNameValue}, |
|
|
|
success: function(response) { |
|
|
|
console.log(response); |
|
|
|
if (response.data) { |
|
|
|
var newData = response.data; |
|
|
|
var newRowData = { |
|
|
|
supplierName : supplierNameValue, |
|
|
|
supplierCode : newData.supplierCode, |
|
|
|
customerContact : newData.customerContact, |
|
|
|
contactNumber : newData.contactNumber, |
|
|
|
supplierAddress : newData.customerAddress, |
|
|
|
}; |
|
|
|
$('#bootstrap-table').bootstrapTable('updateRow', { |
|
|
|
index: rowIndex, // 使用传递进来的索引 |
|
|
|
row: newRowData |
|
|
|
}); |
|
|
|
} else { |
|
|
|
console.error('后端请求数据为空'); |
|
|
|
} |
|
|
|
}, |
|
|
|
error: function(xhr, status, error) { |
|
|
|
console.error('请求出错:', status, ", ", error); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 更新行数据 |
|
|
|
$table.bootstrapTable('updateRow', {index: rowIndex, row: newRow}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
function qualityReport(materialNo, refundsExchangesCode) { |
|
|
|