|
@ -27,15 +27,17 @@ |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-3 control-label is-required">供应商名称:</label> |
|
|
<label class="col-sm-3 control-label is-required">供应商名称:</label> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
|
<input name="supplierName" class="form-control select2" required /> |
|
|
<input name="supplierName" class="form-control select2" required readonly> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-3 control-label">定价日期:</label> |
|
|
<label class="col-sm-3 control-label">定价日期:</label> |
|
|
|
|
|
<div class="col-sm-8"> |
|
|
<div class="input-group date"> |
|
|
<div class="input-group date"> |
|
|
<input name="pricingDate" class="form-control" type="text" /> |
|
|
<input name="pricingDate" class="form-control" type="text" /> |
|
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|
|
<span class="input-group-addon"><i class="fa fa-calendar"></i></span> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</div> |
|
|
<div class="form-group"> |
|
|
<div class="form-group"> |
|
|
<label class="col-sm-3 control-label">备注说明:</label> |
|
|
<label class="col-sm-3 control-label">备注说明:</label> |
|
@ -159,6 +161,16 @@ |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
{title: '最新报价',field: 'materialSole',align: 'center',}, |
|
|
{title: '最新报价',field: 'materialSole',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: 'materialNum',align: 'center',editable: true,visible: false}, |
|
|
{title: '物料的数量', field: 'materialNum',align: 'center',editable: true,visible: false}, |
|
|
{title: '物料的不含税单价(RMB)',field: 'materialNoRmb',align: 'center', |
|
|
{title: '物料的不含税单价(RMB)',field: 'materialNoRmb',align: 'center', |
|
|
editable:{ |
|
|
editable:{ |
|
@ -189,7 +201,6 @@ |
|
|
{title: '录入时间',field: 'createTime',align: 'center',visible: false }, |
|
|
{title: '录入时间',field: 'createTime',align: 'center',visible: false }, |
|
|
{title: '更新人',field: 'updateBy',align: 'center',visible: false}, |
|
|
{title: '更新人',field: 'updateBy',align: 'center',visible: false}, |
|
|
{title: '上次更新时间',field: 'updateTime',align: 'center',visible: false}, |
|
|
{title: '上次更新时间',field: 'updateTime',align: 'center',visible: false}, |
|
|
{title: '备注',field: 'remark',align: 'center'}, |
|
|
|
|
|
{title: '操作', align: 'center', |
|
|
{title: '操作', align: 'center', |
|
|
formatter: function (value, row, index) { |
|
|
formatter: function (value, row, index) { |
|
|
var actions = []; |
|
|
var actions = []; |
|
@ -234,48 +245,94 @@ |
|
|
}); |
|
|
}); |
|
|
getPurchaseQuoteCode(); |
|
|
getPurchaseQuoteCode(); |
|
|
}); |
|
|
}); |
|
|
function doSubmit(index, layero,uniqueId){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function doSubmit(index, layero, 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'); |
|
|
var selectedRows = iframeWin.$('#bootstrap-select-table').bootstrapTable('getSelections'); |
|
|
var rows = $("#bootstrap-sub-table-1").bootstrapTable('getData').length; |
|
|
|
|
|
for(var j=0;i<rows;j++){ |
|
|
if (selectedRows.length === 0) { |
|
|
var data = $("#bootstrap-sub-table-1").bootstrapTable('getData'); |
|
|
$.modal.alertWarning("请选择至少一条物料信息"); |
|
|
for (var i = 0;i<data.length;i++){ |
|
|
return; |
|
|
if(data[i].materialNo==rowData[j].materialNo){ |
|
|
|
|
|
//如果是物料料号的相同,则从rowData清除相同的料号物料 |
|
|
|
|
|
rowData.splice(j,1); |
|
|
|
|
|
$.modal.alertError("不能选择已添加过的相同料号" + rowData[j].materialNo); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
console.log("rowData: "+rowData); |
|
|
|
|
|
for(var i=0;i<rowData.length;i++){ |
|
|
var existingData = $("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('getData'); |
|
|
$("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('insertRow', { |
|
|
var materialCodesSet = new Set(); // 使用 Set 来存储物料号 |
|
|
index: i, |
|
|
|
|
|
row: { |
|
|
// 存储所有现有的物料号 |
|
|
materialId:rowData[i].id, |
|
|
existingData.forEach(function(row) { |
|
|
materialCode: rowData[i].materialNo, |
|
|
materialCodesSet.add(row.materialCode); |
|
|
materialName: rowData[i].materialName, |
|
|
}); |
|
|
materialType: rowData[i].materialType, |
|
|
|
|
|
describe: rowData[i].describe, |
|
|
// 存储所有即将插入的料号 |
|
|
brand: rowData[i].brand, |
|
|
var newMaterialCodesSet = new Set(); |
|
|
unit: rowData[i].unit, |
|
|
|
|
|
processMethod: rowData[i].processMethod, |
|
|
var promises = selectedRows.map(rowData => { |
|
|
materialSole: '', |
|
|
// 检查是否已经存在相同的料号 |
|
|
photoUrl: rowData[i].photoUrl, |
|
|
if (materialCodesSet.has(rowData.materialNo) || newMaterialCodesSet.has(rowData.materialNo)) { |
|
|
materialNum: 1, |
|
|
$.modal.alertError("不能选择已添加过的相同料号 " + rowData.materialNo); |
|
|
materialRmb: "", |
|
|
return Promise.reject("Duplicate material number: " + rowData.materialNo); |
|
|
materialNoRmb: "", |
|
|
} |
|
|
materialNoRmbSum: "", |
|
|
|
|
|
materialRmbSum: "", |
|
|
// 标记即将插入的物料号 |
|
|
remark: "" |
|
|
newMaterialCodesSet.add(rowData.materialNo); |
|
|
} |
|
|
|
|
|
|
|
|
return queryRecentQuotation(rowData.materialNo) |
|
|
|
|
|
.then(function(quotationData) { |
|
|
|
|
|
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, |
|
|
|
|
|
materialSole: quotationData.data.materialRmb || '', |
|
|
|
|
|
photoUrl: rowData.photoUrl, |
|
|
|
|
|
materialNum: 1, |
|
|
|
|
|
materialRmb: "", |
|
|
|
|
|
materialNoRmb: "", |
|
|
|
|
|
materialNoRmbSum: "", |
|
|
|
|
|
materialRmbSum: "", |
|
|
|
|
|
remark: "" |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 使用 Promise.all 来等待所有请求完成,并将结果直接存入 newRows |
|
|
|
|
|
Promise.all(promises) |
|
|
|
|
|
.then(function(newRows) { |
|
|
|
|
|
// 批量插入新行 |
|
|
|
|
|
newRows.forEach(function(row) { |
|
|
|
|
|
$("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('insertRow', { index: 1, row: row }); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
layer.close(index); |
|
|
}) |
|
|
}) |
|
|
} |
|
|
.catch(function(error) { |
|
|
layer.close(index); |
|
|
console.error('Some requests failed:', error); |
|
|
|
|
|
layer.close(index); |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function insertRow() { |
|
|
function insertRow() { |
|
|
|
|
|
|
|
|
|
|
|
if ($("#selectSupplierQuoteCode").val() == null || $("#selectSupplierQuoteCode").val() == '') { |
|
|
|
|
|
$.modal.alertWarning("请先选择供应商ID"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
if ($("#taxRate").val() == null || $("#taxRate").val() == '') { |
|
|
|
|
|
$.modal.alertWarning("请先填写税率"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var url = ctx + "erp/material/select"; |
|
|
var url = ctx + "erp/material/select"; |
|
|
var options = { |
|
|
var options = { |
|
|
title: '选择料号', |
|
|
title: '选择料号', |
|
@ -378,6 +435,41 @@ |
|
|
values: materialCode |
|
|
values: materialCode |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//最新报价历史 |
|
|
|
|
|
function recentQuotationHistory(materialCode){ |
|
|
|
|
|
var supplierQuoteCode = $("#selectSupplierQuoteCode").val(); |
|
|
|
|
|
var queryParams = new URLSearchParams(); |
|
|
|
|
|
queryParams.append("materialCode", materialCode); |
|
|
|
|
|
queryParams.append("supplierQuoteCode", encodeURIComponent(supplierQuoteCode)); |
|
|
|
|
|
var url = ctx +'purchase/purchaseQuote/recentQuotationHistory?'+queryParams.toString(); |
|
|
|
|
|
|
|
|
|
|
|
$.modal.open("最新报价历史", url); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查找最新的报价数据 |
|
|
|
|
|
function queryRecentQuotation(materialNo) { |
|
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
|
// 使用AJAX请求从服务器获取最近的报价信息 |
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
url: prefix + '/queryLatestRecentQuotation', |
|
|
|
|
|
type: 'GET', |
|
|
|
|
|
data: { materialNo: materialNo, supplierQuoteCode: $("#selectSupplierQuoteCode").val() }, |
|
|
|
|
|
success: function (data) { |
|
|
|
|
|
resolve(data); // 成功时解析数据 |
|
|
|
|
|
}, |
|
|
|
|
|
error: function (jqXHR, textStatus, errorThrown) { |
|
|
|
|
|
reject(new Error('查找最新报价数据失败')); // 失败时抛出错误 |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
</body> |
|
|
</body> |
|
|
</html> |
|
|
</html> |