|
@ -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: 'countTax',align: 'center',}, |
|
|
{ title: '美元汇率',field: 'usdTax', align: 'center',}, |
|
|
{ title: '美元汇率',field: 'usdTax', align: 'center',}, |
|
|
{field: 'materialNum',align: 'center',title: '物料的数量', |
|
|
{field: 'materialNum',align: 'center',title: '物料的数量', |
|
@ -404,46 +414,139 @@ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
function doSubmit(index, layero,uniqueId){ |
|
|
function doSubmit(index, layero, uniqueId) { |
|
|
console.log(uniqueId); |
|
|
console.log(uniqueId); |
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
var iframeWin = window[layero.find('iframe')[0]['name']]; |
|
|
var rowData = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections')[0]; |
|
|
var selectedRows = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections'); |
|
|
console.log("rowData: "+rowData); |
|
|
|
|
|
let enterpriseSum = $("#enterpriseSum").val(); |
|
|
if (selectedRows.length === 0) { |
|
|
$("#enterpriseSum").val((enterpriseSum==''?0:enterpriseSum) + 1); |
|
|
$.modal.alertError("请选择至少一条物料信息"); |
|
|
var timestamp = new Date().getTime(); |
|
|
return; |
|
|
var totalNum = $("#bootstrap-table-Quote-child-edit1").bootstrapTable('getData').length; |
|
|
} |
|
|
$("#bootstrap-table-Quote-child-edit1").bootstrapTable('insertRow', { |
|
|
|
|
|
index: totalNum, |
|
|
var existingData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData'); |
|
|
row: { |
|
|
var promises = []; |
|
|
id:'', |
|
|
|
|
|
quoteId:$("#supplierCode").val(), |
|
|
// 存储要插入的新行 |
|
|
materialId:rowData.id, |
|
|
var newRows = []; |
|
|
materialCode: rowData.materialNo, |
|
|
|
|
|
materialName: rowData.materialName, |
|
|
// 遍历选中的每一行物料信息 |
|
|
materialType: rowData.materialType, |
|
|
for (var i = 0; i < selectedRows.length; i++) { |
|
|
describe: rowData.describe, |
|
|
var rowData = selectedRows[i]; |
|
|
brand: rowData.brand, |
|
|
|
|
|
photoUrl: rowData.photoUrl, |
|
|
// 检查是否已经存在相同的物料 |
|
|
unit: rowData.unit, |
|
|
var isDuplicate = false; |
|
|
processMethod: rowData.processMethod, |
|
|
for (var j = 0; j < existingData.length; j++) { |
|
|
countTax: '', |
|
|
if (existingData[j].materialCode === rowData.materialNo) { |
|
|
usdTax: '', |
|
|
isDuplicate = true; |
|
|
materialSole: "", |
|
|
break; |
|
|
materialRmb: "", |
|
|
} |
|
|
materialNum: "", |
|
|
} |
|
|
materialNoRmb: "", |
|
|
|
|
|
materialNoUsd: "", |
|
|
if (!isDuplicate) { |
|
|
materialRmb: "", |
|
|
// 如果不存在,则准备插入新行,并发起查询请求 |
|
|
materialNoRmbSum: "", |
|
|
promises.push(queryRecentQuotation(rowData.materialNo).then(function (quotationData) { |
|
|
materialRmbSum: "", |
|
|
// 将查询结果赋值给 newRows 中的相应字段 |
|
|
materialUsd: "", |
|
|
return { |
|
|
materialUsdSum: "", |
|
|
materialId: rowData.id, |
|
|
materialNoUsdSum: "", |
|
|
materialCode: rowData.materialNo, |
|
|
remark: "", |
|
|
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() { |
|
|
function insertRow() { |
|
|
var url = ctx + "erp/material/select"; |
|
|
var url = ctx + "erp/material/select"; |
|
@ -502,6 +605,19 @@ |
|
|
function toPercentage(numerator, denominator) { |
|
|
function toPercentage(numerator, denominator) { |
|
|
return (numerator / denominator) * 100 + '%'; |
|
|
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> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|
</html> |
|
|
</html> |