|
@ -27,16 +27,18 @@ |
|
|
<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> |
|
|
<div class="col-sm-8"> |
|
|
<div class="col-sm-8"> |
|
@ -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++){ |
|
|
|
|
|
if(data[i].materialNo==rowData[j].materialNo){ |
|
|
|
|
|
//如果是物料料号的相同,则从rowData清除相同的料号物料 |
|
|
|
|
|
rowData.splice(j,1); |
|
|
|
|
|
$.modal.alertError("不能选择已添加过的相同料号" + rowData[j].materialNo); |
|
|
|
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var existingData = $("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('getData'); |
|
|
|
|
|
var materialCodesSet = new Set(); // 使用 Set 来存储物料号 |
|
|
|
|
|
|
|
|
|
|
|
// 存储所有现有的物料号 |
|
|
|
|
|
existingData.forEach(function(row) { |
|
|
|
|
|
materialCodesSet.add(row.materialCode); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 存储所有即将插入的料号 |
|
|
|
|
|
var newMaterialCodesSet = new Set(); |
|
|
|
|
|
|
|
|
|
|
|
var promises = selectedRows.map(rowData => { |
|
|
|
|
|
// 检查是否已经存在相同的料号 |
|
|
|
|
|
if (materialCodesSet.has(rowData.materialNo) || newMaterialCodesSet.has(rowData.materialNo)) { |
|
|
|
|
|
$.modal.alertError("不能选择已添加过的相同料号 " + rowData.materialNo); |
|
|
|
|
|
return Promise.reject("Duplicate material number: " + rowData.materialNo); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
console.log("rowData: "+rowData); |
|
|
// 标记即将插入的物料号 |
|
|
for(var i=0;i<rowData.length;i++){ |
|
|
newMaterialCodesSet.add(rowData.materialNo); |
|
|
$("#bootstrap-sub-table-purchaseQuoteChild").bootstrapTable('insertRow', { |
|
|
|
|
|
index: i, |
|
|
return queryRecentQuotation(rowData.materialNo) |
|
|
row: { |
|
|
.then(function(quotationData) { |
|
|
materialId:rowData[i].id, |
|
|
return { |
|
|
materialCode: rowData[i].materialNo, |
|
|
materialId:rowData.id, |
|
|
materialName: rowData[i].materialName, |
|
|
materialCode: rowData.materialNo, |
|
|
materialType: rowData[i].materialType, |
|
|
materialName: rowData.materialName, |
|
|
describe: rowData[i].describe, |
|
|
materialType: rowData.materialType, |
|
|
brand: rowData[i].brand, |
|
|
describe: rowData.describe, |
|
|
unit: rowData[i].unit, |
|
|
brand: rowData.brand, |
|
|
processMethod: rowData[i].processMethod, |
|
|
unit: rowData.unit, |
|
|
materialSole: '', |
|
|
processMethod: rowData.processMethod, |
|
|
photoUrl: rowData[i].photoUrl, |
|
|
materialSole: quotationData.data.materialRmb || '', |
|
|
|
|
|
photoUrl: rowData.photoUrl, |
|
|
materialNum: 1, |
|
|
materialNum: 1, |
|
|
materialRmb: "", |
|
|
materialRmb: "", |
|
|
materialNoRmb: "", |
|
|
materialNoRmb: "", |
|
|
materialNoRmbSum: "", |
|
|
materialNoRmbSum: "", |
|
|
materialRmbSum: "", |
|
|
materialRmbSum: "", |
|
|
remark: "" |
|
|
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) { |
|
|
|
|
|
console.error('Some requests failed:', error); |
|
|
layer.close(index); |
|
|
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> |