|
|
@ -251,6 +251,16 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
{ title: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',}, |
|
|
|
{ title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',}, |
|
|
|
{ title: '最新报价历史',align: 'center', |
|
|
|
|
|
|
|
formatter: function (value, row, index) { |
|
|
|
var actions = []; |
|
|
|
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="recentQuotationHistory(\'' + row.materialCode + '\')"><i class="fa fa-edit"></i>最新报价历史</a> '); |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}, |
|
|
|
{title: '国内税率',field: 'countTax',align: 'center',}, |
|
|
|
{ title: '美元汇率',field: 'usdTax', align: 'center',}, |
|
|
|
{field: 'materialNum',align: 'center',title: '物料的数量', |
|
|
@ -404,46 +414,139 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
function doSubmit(index, layero,uniqueId){ |
|
|
|
function doSubmit(index, layero, uniqueId) { |
|
|
|
console.log(uniqueId); |
|
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
|
var rowData = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections')[0]; |
|
|
|
console.log("rowData: "+rowData); |
|
|
|
let enterpriseSum = $("#enterpriseSum").val(); |
|
|
|
$("#enterpriseSum").val((enterpriseSum==''?0:enterpriseSum) + 1); |
|
|
|
var timestamp = new Date().getTime(); |
|
|
|
var totalNum = $("#bootstrap-table-Quote-child-edit1").bootstrapTable('getData').length; |
|
|
|
$("#bootstrap-table-Quote-child-edit1").bootstrapTable('insertRow', { |
|
|
|
index: totalNum, |
|
|
|
row: { |
|
|
|
id:'', |
|
|
|
quoteId:$("#supplierCode").val(), |
|
|
|
materialId:rowData.id, |
|
|
|
materialCode: rowData.materialNo, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
describe: rowData.describe, |
|
|
|
brand: rowData.brand, |
|
|
|
photoUrl: rowData.photoUrl, |
|
|
|
unit: rowData.unit, |
|
|
|
processMethod: rowData.processMethod, |
|
|
|
countTax: '', |
|
|
|
usdTax: '', |
|
|
|
materialSole: "", |
|
|
|
materialRmb: "", |
|
|
|
materialNum: "", |
|
|
|
materialNoRmb: "", |
|
|
|
materialNoUsd: "", |
|
|
|
materialRmb: "", |
|
|
|
materialNoRmbSum: "", |
|
|
|
materialRmbSum: "", |
|
|
|
materialUsd: "", |
|
|
|
materialUsdSum: "", |
|
|
|
materialNoUsdSum: "", |
|
|
|
remark: "", |
|
|
|
var selectedRows = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections'); |
|
|
|
|
|
|
|
if (selectedRows.length === 0) { |
|
|
|
$.modal.alertError("请选择至少一条物料信息"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var existingData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData'); |
|
|
|
var promises = []; |
|
|
|
|
|
|
|
// 存储要插入的新行 |
|
|
|
var newRows = []; |
|
|
|
|
|
|
|
// 遍历选中的每一行物料信息 |
|
|
|
for (var i = 0; i < selectedRows.length; i++) { |
|
|
|
var rowData = selectedRows[i]; |
|
|
|
|
|
|
|
// 检查是否已经存在相同的物料 |
|
|
|
var isDuplicate = false; |
|
|
|
for (var j = 0; j < existingData.length; j++) { |
|
|
|
if (existingData[j].materialCode === rowData.materialNo) { |
|
|
|
isDuplicate = true; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (!isDuplicate) { |
|
|
|
// 如果不存在,则准备插入新行,并发起查询请求 |
|
|
|
promises.push(queryRecentQuotation(rowData.materialNo).then(function (quotationData) { |
|
|
|
// 将查询结果赋值给 newRows 中的相应字段 |
|
|
|
return { |
|
|
|
materialId: rowData.id, |
|
|
|
materialCode: rowData.materialNo, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
describe: rowData.describe, |
|
|
|
brand: rowData.brand, |
|
|
|
unit: rowData.unit, |
|
|
|
processMethod: rowData.processMethod, |
|
|
|
photoUrl: rowData.photoUrl, |
|
|
|
countTax: '', |
|
|
|
usdTax: '', |
|
|
|
materialNum: "", |
|
|
|
materialSole: "", |
|
|
|
recentQuotationRMB: quotationData.data.materialRmb || '', |
|
|
|
recentQuotationUSD: quotationData.data.materialUsd || '', |
|
|
|
materialRmb: "", |
|
|
|
materialNoRmb: "", |
|
|
|
materialNoUsd: "", |
|
|
|
materialUsd: "", |
|
|
|
materialUsdSum: "", |
|
|
|
materialNoUsdSum: "", |
|
|
|
materialNoRmbSum: "", |
|
|
|
materialRmbSum: "", |
|
|
|
createBy: "", |
|
|
|
createTime: "", |
|
|
|
updateBy: "", |
|
|
|
updateTime: "", |
|
|
|
remark: "", |
|
|
|
}; |
|
|
|
}).catch(function (error) { |
|
|
|
// 返回一个默认对象以保证数据结构一致 |
|
|
|
return { |
|
|
|
materialId: rowData.id, |
|
|
|
materialCode: rowData.materialNo, |
|
|
|
materialName: rowData.materialName, |
|
|
|
materialType: rowData.materialType, |
|
|
|
describe: rowData.describe, |
|
|
|
brand: rowData.brand, |
|
|
|
unit: rowData.unit, |
|
|
|
processMethod: rowData.processMethod, |
|
|
|
photoUrl: rowData.photoUrl, |
|
|
|
countTax: '', |
|
|
|
usdTax: '', |
|
|
|
materialNum: "", |
|
|
|
materialSole: "", |
|
|
|
recentQuotationRMB: '', |
|
|
|
recentQuotationUSD: '', |
|
|
|
materialRmb: "", |
|
|
|
materialNoRmb: "", |
|
|
|
materialNoUsd: "", |
|
|
|
materialUsd: "", |
|
|
|
materialUsdSum: "", |
|
|
|
materialNoUsdSum: "", |
|
|
|
materialNoRmbSum: "", |
|
|
|
materialRmbSum: "", |
|
|
|
createBy: "", |
|
|
|
createTime: "", |
|
|
|
updateBy: "", |
|
|
|
updateTime: "", |
|
|
|
remark: "", |
|
|
|
}; |
|
|
|
})); |
|
|
|
} else { |
|
|
|
$.modal.alertError("不能选择已添加过的相同料号"); |
|
|
|
} |
|
|
|
}) |
|
|
|
layer.close(index); |
|
|
|
} |
|
|
|
|
|
|
|
// 使用Promise.all等待所有查询完成 |
|
|
|
Promise.all(promises).then(function (rows) { |
|
|
|
newRows = rows.filter(row => !!row); // 清除可能的null或undefined |
|
|
|
if (newRows.length > 0) { |
|
|
|
// 批量插入新行 |
|
|
|
for (var k = 0; k < newRows.length; k++) { |
|
|
|
$("#bootstrap-sub-table-quoteChild").bootstrapTable('insertRow', { index: 1, row: newRows[k] }); |
|
|
|
} |
|
|
|
} |
|
|
|
layer.close(index); |
|
|
|
}).catch(function (error) { |
|
|
|
console.error('Some requests failed:', error); |
|
|
|
layer.close(index); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 查找最新的报价数据 |
|
|
|
function queryRecentQuotation(materialNo) { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
// 使用AJAX请求从服务器获取最近的报价信息 |
|
|
|
$.ajax({ |
|
|
|
url: prefix + '/queryLatestRecentQuotation', // 假设这是你的API路径 |
|
|
|
type: 'GET', |
|
|
|
data: { materialNo: materialNo, customerCode: $("#customerCode").val() }, |
|
|
|
success: function (data) { |
|
|
|
resolve(data); // 成功时解析数据 |
|
|
|
}, |
|
|
|
error: function (jqXHR, textStatus, errorThrown) { |
|
|
|
reject(new Error('查找最新报价数据失败')); // 失败时抛出错误 |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
function insertRow() { |
|
|
|
var url = ctx + "erp/material/select"; |
|
|
@ -502,6 +605,19 @@ |
|
|
|
function toPercentage(numerator, denominator) { |
|
|
|
return (numerator / denominator) * 100 + '%'; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//最新报价历史 |
|
|
|
function recentQuotationHistory(materialCode){ |
|
|
|
var customerCode = $("#customerCode").val(); |
|
|
|
var queryParams = new URLSearchParams(); |
|
|
|
queryParams.append("materialCode", materialCode); |
|
|
|
queryParams.append("customerCode", encodeURIComponent(customerCode)); |
|
|
|
var url = prefix + '/recentQuotationHistory?'+queryParams.toString(); |
|
|
|
|
|
|
|
$.modal.open("最新报价历史", url); |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |