|
|
@ -367,7 +367,7 @@ |
|
|
|
|
|
|
|
{ title: '最新报价(RMB)',field: 'recentQuotationRMB',align: 'center',}, |
|
|
|
{ title: '最新报价(美元)',field: 'recentQuotationUSD',align: 'center',}, |
|
|
|
{ title: '最新报价历史',field: 'recentQuotationUSD',align: 'center', |
|
|
|
{ title: '最新报价历史',align: 'center', |
|
|
|
|
|
|
|
formatter: function (value, row, index) { |
|
|
|
var actions = []; |
|
|
@ -575,7 +575,7 @@ |
|
|
|
// 初始化时也需要根据当前的货币类型设置一次 |
|
|
|
$("#commonCurrency_add").trigger('change'); |
|
|
|
// getBusinessMembers(); |
|
|
|
getCustomerCode(); |
|
|
|
// getCustomerCode(); |
|
|
|
}); |
|
|
|
|
|
|
|
//监听币种的变化 |
|
|
@ -653,6 +653,7 @@ |
|
|
|
} |
|
|
|
|
|
|
|
var existingData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData'); |
|
|
|
var promises = []; |
|
|
|
|
|
|
|
// 存储要插入的新行 |
|
|
|
var newRows = []; |
|
|
@ -671,8 +672,10 @@ |
|
|
|
} |
|
|
|
|
|
|
|
if (!isDuplicate) { |
|
|
|
// 如果不存在,则准备插入新行 |
|
|
|
newRows.push({ |
|
|
|
// 如果不存在,则准备插入新行,并发起查询请求 |
|
|
|
promises.push(queryRecentQuotation(rowData.materialNo).then(function (quotationData) { |
|
|
|
// 将查询结果赋值给 newRows 中的相应字段 |
|
|
|
return { |
|
|
|
materialId: rowData.id, |
|
|
|
materialCode: rowData.materialNo, |
|
|
|
materialName: rowData.materialName, |
|
|
@ -686,6 +689,8 @@ |
|
|
|
usdTax: '', |
|
|
|
materialNum: "", |
|
|
|
materialSole: "", |
|
|
|
recentQuotationRMB: quotationData.data.materialRmb || '', |
|
|
|
recentQuotationUSD: quotationData.data.materialUsd || '', |
|
|
|
materialRmb: "", |
|
|
|
materialNoRmb: "", |
|
|
|
materialNoUsd: "", |
|
|
@ -699,22 +704,80 @@ |
|
|
|
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("不能选择已添加过的相同料号"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 批量插入新行 |
|
|
|
// 使用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() { |
|
|
|
if ($("#customerCode").val() == null || $("#customerCode").val() == '') { |
|
|
|
$.modal.alertWarning("请先选择客户"); |
|
|
@ -817,6 +880,9 @@ |
|
|
|
$.modal.open("最新报价历史", url); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |