|
|
@ -41,7 +41,7 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<div class="form-group" id="commonCurrency"> |
|
|
|
<label class="col-sm-4 control-label">报价币种:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<select class="form-control" id="commonCurrency_add" name="commonCurrency" th:with="dictList=${@dict.getType('sys_common_currency')}" required> |
|
|
@ -50,12 +50,12 @@ |
|
|
|
</select> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label is-required">美元汇率:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<input name="usdTax" id="usdTax_add" class="form-control" type="number" placeholder="当前未配置美元汇率,请联系总经理" required readonly> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<!-- <div class="form-group"> --> |
|
|
|
<!-- <label class="col-sm-4 control-label is-required">美元汇率:</label>--> |
|
|
|
<!-- <div class="col-sm-8">--> |
|
|
|
<!-- <input name="usdTax" id="usdTax_add" class="form-control" type="number" placeholder="当前未配置美元汇率,请联系总经理" required readonly>--> |
|
|
|
<!-- </div>--> |
|
|
|
<!-- </div>--> |
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label is-required">是否含税:</label> |
|
|
@ -70,15 +70,15 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">国内税率:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
|
<div class="input-group"> |
|
|
|
<input name="rmbTax" id="rmbTax_add" class="form-control" type="number" placeholder="13" /> |
|
|
|
<span class="input-group-addon">%</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<!-- <div class="form-group">--> |
|
|
|
<!-- <label class="col-sm-4 control-label">国内税率:</label>--> |
|
|
|
<!-- <div class="col-sm-8">--> |
|
|
|
<!-- <div class="input-group">--> |
|
|
|
<!-- <input name="rmbTax" id="rmbTax_add" class="form-control" type="number" placeholder="13" />--> |
|
|
|
<!-- <span class="input-group-addon">%</span>--> |
|
|
|
<!-- </div>--> |
|
|
|
<!-- </div>--> |
|
|
|
<!-- </div>--> |
|
|
|
<div class="form-group"> |
|
|
|
<label class="col-sm-4 control-label">订价日期:</label> |
|
|
|
<div class="col-sm-8"> |
|
|
@ -289,7 +289,6 @@ |
|
|
|
$("#form-customerQuote-add input[name='businessMembers']").val(loginName); |
|
|
|
var options = { |
|
|
|
id:'bootstrap-sub-table-quoteChild', |
|
|
|
// url: ctx + "system/quoteChild/list", |
|
|
|
showColumns: false, |
|
|
|
pagination: false, |
|
|
|
showToggle: false, |
|
|
@ -361,9 +360,21 @@ |
|
|
|
return actions.join(''); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// {title: '国内税率',field: 'countTax',align: 'center',}, |
|
|
|
// { title: '美元汇率',field: 'usdTax', align: 'center',}, |
|
|
|
{title: '物料的数量',field: 'materialNum',align: 'center', |
|
|
|
editable:{ |
|
|
|
type : 'text', |
|
|
|
mode: 'inline', |
|
|
|
title : '物料的数量', |
|
|
|
validate : function(value) { |
|
|
|
if (!value) { |
|
|
|
return '用量不能为空'; |
|
|
|
} |
|
|
|
if (isNaN(value)) { |
|
|
|
return '用量必须为数字'; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ title: '物料的不含税单价(RMB)', |
|
|
|
field: 'materialNoRmb', |
|
|
|
align: 'center', |
|
|
@ -393,21 +404,6 @@ |
|
|
|
} |
|
|
|
}, |
|
|
|
{ title: '物料的含税单价(RMB)',field: 'materialRmb',align: 'center',}, |
|
|
|
{field: 'materialNum',align: 'center',title: '物料的数量', |
|
|
|
editable:{ |
|
|
|
type : 'text', |
|
|
|
mode: 'inline', |
|
|
|
title : '物料的数量', |
|
|
|
validate : function(value) { |
|
|
|
if (!value) { |
|
|
|
return '用量不能为空'; |
|
|
|
} |
|
|
|
if (isNaN(value)) { |
|
|
|
return '用量必须为数字'; |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
{title: '物料的不含税总价(RMB)',field: 'materialNoRmbSum',align: 'center',}, |
|
|
|
{ title: '物料的含税总价(RMB)',field: 'materialRmbSum',align: 'center',}, |
|
|
|
{title: '物料的不含税单价(美元)', |
|
|
@ -458,110 +454,47 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
|
|
|
|
onClickCell: function(field, value, row, $element) { |
|
|
|
// 根据物料号是否存在决定是否允许编辑 |
|
|
|
if (field !== 'index' && field !== 'materialCode' && field !== 'photoUrl' && field !== 'operation') { |
|
|
|
var isEditable = !row.materialCode; // 如果物料号不存在,则允许编辑 |
|
|
|
// 判断是否已有编辑框,避免重复打开 |
|
|
|
if (isEditable && !$element.find('.editable-input').length) { |
|
|
|
// 模拟开启编辑 |
|
|
|
var input = $('<input type="text" class="form-control editable-input" value="' + value + '">'); |
|
|
|
$element.empty().append(input); |
|
|
|
input.focus(); |
|
|
|
input.blur(function() { |
|
|
|
// 用户离开输入框时,手动保存编辑值并关闭编辑状态 |
|
|
|
var newValue = input.val(); |
|
|
|
// 这里你需要添加代码来实际更新表格数据和关闭编辑状态 |
|
|
|
row[field] = newValue; // 更新数据模型 |
|
|
|
$element.text(newValue).removeClass('editing'); |
|
|
|
}); |
|
|
|
$element.addClass('editing'); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
onEditableSave: function(field, row, oldValue, $el) { |
|
|
|
onEditableSave:function(field, row, oldValue, $el){ |
|
|
|
var commonCurrency1 = $("#commonCurrency_add option:selected").val(); |
|
|
|
//把上面输入的百分比国内汇率由整数转换成小数 |
|
|
|
var rmbRateInput = parseFloat($("#rmbTax_add").val()) || 0; |
|
|
|
var rmbRate = rmbRateInput / 100; // 将输入的百分比转换为小数 |
|
|
|
var rmbRate = rmbRateInput / 100; |
|
|
|
rmbRate = parseFloat(rmbRate.toFixed(2)); // 确保rmbRate转换为两位小数的浮点数 |
|
|
|
var usdRate = parseFloat($("#usdTax_add").val()) || 0; |
|
|
|
|
|
|
|
var testMaterialNum = parseFloat(row.materialNum) || 0; |
|
|
|
|
|
|
|
console.log("rmbRate:",rmbRate) |
|
|
|
console.log("usdRate:",usdRate) |
|
|
|
|
|
|
|
console.log("testMaterialNum:",testMaterialNum) |
|
|
|
// // 确保计算使用的是正确的数值类型 |
|
|
|
// var noTaxValue = field === 'materialNoRmb' ? parseFloat(row.materialNoRmb) : parseFloat(row.materialNoUsd); |
|
|
|
// |
|
|
|
// // 计算不含税价格 |
|
|
|
// var noTaxPrice = noTaxValue.toFixed(2); |
|
|
|
|
|
|
|
|
|
|
|
// 根据选择的货币类型计算其他值 |
|
|
|
if (commonCurrency1 === '1') { |
|
|
|
// RMB为基准货币 |
|
|
|
row.materialRmb = (parseFloat(row.materialNoRmb) * (1 + rmbRate)).toFixed(2); |
|
|
|
row.materialRmbSum = (parseFloat(row.materialRmb) * testMaterialNum).toFixed(2); |
|
|
|
row.materialNoRmbSum = (parseFloat(row.materialNoRmb) * testMaterialNum).toFixed(2); |
|
|
|
row.materialNoUsd = (parseFloat(row.materialNoRmb) / usdRate).toFixed(2); |
|
|
|
row.materialUsd = row.materialNoUsd; // 保持一致,除非有特别的计算逻辑 |
|
|
|
row.materialUsdSum = (parseFloat(row.materialUsd) * testMaterialNum).toFixed(2); |
|
|
|
row.materialNoUsdSum = (parseFloat(row.materialNoUsd) * testMaterialNum).toFixed(2); |
|
|
|
} else if (commonCurrency1 === '2') { |
|
|
|
// USD为基准货币 |
|
|
|
row.materialUsd = row.materialNoUsd |
|
|
|
row.materialUsdSum = (parseFloat(row.materialUsd) * testMaterialNum).toFixed(2); |
|
|
|
row.materialNoUsdSum = (parseFloat(row.materialNoUsd) * testMaterialNum).toFixed(2); |
|
|
|
row.materialNoRmb = (parseFloat(row.materialNoUsd) * usdRate).toFixed(2); |
|
|
|
row.materialRmb = (parseFloat(row.materialNoRmb) * (1 + rmbRate)).toFixed(2); |
|
|
|
row.materialNoRmbSum = (parseFloat(row.materialNoRmb) * testMaterialNum).toFixed(2); |
|
|
|
row.materialRmbSum = (parseFloat(row.materialRmb) * testMaterialNum).toFixed(2); |
|
|
|
} |
|
|
|
|
|
|
|
// 确保getTotalAmount函数存在且正确引用 |
|
|
|
if (typeof getTotalAmount === 'function') { |
|
|
|
getTotalAmount(); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}; |
|
|
|
$.table.init(options); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化表格 |
|
|
|
var bootstrapSubTableQuoteChild = $('#bootstrap-sub-table-quoteChild').bootstrapTable(options); |
|
|
|
// 监听货币类型选择器变化 |
|
|
|
// $("#commonCurrency_add").on('change', function() { |
|
|
|
// var currencyVal = $(this).val(); |
|
|
|
// var columns = bootstrapSubTableQuoteChild.bootstrapTable('getColumns'); |
|
|
|
// columns.forEach(function(column) { |
|
|
|
// // 根据货币类型和列名决定是否启用编辑 |
|
|
|
// if (column.field !== 'materialNoRmb' && column.field !== 'materialNoUsd') { |
|
|
|
// column.editable.enabled = function() { |
|
|
|
// return (currencyVal === '1' && row.materialNoRmb) || (currencyVal === '2' && row.materialNoUsd); |
|
|
|
// }; |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// // bootstrapSubTableQuoteChild.bootstrapTable('refreshOptions', { columns: columns }); |
|
|
|
// }); |
|
|
|
|
|
|
|
// 添加编辑保存事件监听器 |
|
|
|
bootstrapSubTableQuoteChild.on('editable-save.bs.table', function(e, field, row, oldValue, $el) { |
|
|
|
var currencyVal = $("#commonCurrency_add").val(); |
|
|
|
var requiredField = (currencyVal === '1') ? 'materialNoRmb' : 'materialNoUsd'; |
|
|
|
|
|
|
|
// 检查是否尝试编辑除requiredField外的字段,且requiredField未填写 |
|
|
|
if (field !== requiredField && (!row[requiredField] || row[requiredField].trim() === '')) { |
|
|
|
$.modal.alertWarning((currencyVal === '1' ? "请首先填写物料的不含税单价(RMB)" : "请首先填写物料的不含税单价(美元)")); |
|
|
|
// 可以选择取消这次编辑操作,但Bootstrap Table默认不会提供直接的API来取消编辑后的保存,您可能需要手动恢复数据或采取其他策略。 |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// 初始化时也需要根据当前的货币类型设置一次 |
|
|
|
$("#commonCurrency_add").trigger('change'); |
|
|
|
// getBusinessMembers(); |
|
|
|
// getCustomerCode(); |
|
|
|
}); |
|
|
|
|
|
|
|
//监听币种的变化 |
|
|
@ -588,24 +521,6 @@ |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
// function getCustomerCode(){ |
|
|
|
// //获取单号 |
|
|
|
// $.ajax({ |
|
|
|
// url: prefix + "/getId", |
|
|
|
// type: "post", |
|
|
|
// dateType: "json", |
|
|
|
// success: function (resp) { |
|
|
|
// if (resp.code === 0) { |
|
|
|
// $("input[name='supplierCode']").val(resp.data); |
|
|
|
// } else { |
|
|
|
// $.modal.msgError("失败啦"); |
|
|
|
// } |
|
|
|
// }, |
|
|
|
// error: function () { |
|
|
|
// $.modal.msgError("后台出错啦!"); |
|
|
|
// } |
|
|
|
// }); |
|
|
|
// } |
|
|
|
function getBusinessMembers(){ |
|
|
|
/*业务员列表*/ |
|
|
|
$.ajax({ |
|
|
@ -675,8 +590,8 @@ |
|
|
|
brand: rowData.brand, |
|
|
|
processMethod: rowData.processMethod, |
|
|
|
photoUrl: rowData.photoUrl, |
|
|
|
countTax: '', |
|
|
|
usdTax: '', |
|
|
|
countTax: $("#rmbTax_add").val(), |
|
|
|
usdTax: $("#usdTax_add").val(), |
|
|
|
materialNum: "", |
|
|
|
materialSole: "", |
|
|
|
recentQuotationRMB: quotationData.data.materialRmb || '', |
|
|
@ -739,15 +654,19 @@ |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if ($("#usdTax_add").val() == null || $("#usdTax_add").val() == '') { |
|
|
|
$.modal.alertWarning("当前未配置美元汇率,请联系总经理"); |
|
|
|
return; |
|
|
|
if ($("#commonCurrency_add").val() === "2") { |
|
|
|
if ($("#usdTax_add").val() == null || $("#usdTax_add").val() == '') { |
|
|
|
$.modal.alertWarning("当前未配置美元汇率,请联系总经理"); |
|
|
|
return; |
|
|
|
} |
|
|
|
}else if ($("#commonCurrency_add").val() === "1") { |
|
|
|
if ($("#rmbTax_add").val() == null || $("#rmbTax_add").val() == '') { |
|
|
|
$.modal.alertWarning("请输入国内的税率"); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($("#rmbTax_add").val() == null || $("#rmbTax_add").val() == '') { |
|
|
|
$.modal.alertWarning("请输入国内的税率"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var url = ctx + "erp/material/select"; |
|
|
@ -849,6 +768,110 @@ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 选择币种 |
|
|
|
$("#commonCurrency_add").on('change', function() { |
|
|
|
var selectedValue = $(this).val(); |
|
|
|
var $table = $("#bootstrap-sub-table-quoteChild"); |
|
|
|
updateColumnVisibility(selectedValue); |
|
|
|
if(selectedValue ==="1"){ |
|
|
|
if($('#usdTax').length!=0){ |
|
|
|
$('#usdTax').remove(); |
|
|
|
} |
|
|
|
if($('#rmbTax').length!=0){ |
|
|
|
$('#rmbTax').remove(); |
|
|
|
} |
|
|
|
var $taxArea = $( |
|
|
|
'<div class="form-group" id="rmbTax">\n' + |
|
|
|
' <label class="col-sm-4 control-label is-required">税率:</label>\n' + |
|
|
|
' <div class="col-sm-8">\n' + |
|
|
|
' <div class="input-group">\n' + |
|
|
|
' <input name="rmbTax" id="rmbTax_add" class="form-control" type="number" required>\n' + |
|
|
|
' <span class="input-group-addon">%</span>\n' + |
|
|
|
' </div>\n' + |
|
|
|
' </div>\n' + |
|
|
|
'</div>' |
|
|
|
); |
|
|
|
$('#commonCurrency').after($taxArea); |
|
|
|
|
|
|
|
// 为税率输入框添加 change 事件监听器 |
|
|
|
$taxArea.on('change', '#rmbTax_add', function(event) { |
|
|
|
var taxValue = $(this).val(); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
data.forEach(function(row, index) { |
|
|
|
updateColumnValue(index, taxValue, "countTax"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$taxArea.find('#rmbTax_add').trigger('change'); |
|
|
|
}else if(selectedValue ==="2"){ |
|
|
|
//当弹出美元汇率的时候,自动获取美元汇率 |
|
|
|
loadLatestUsdTax(); |
|
|
|
if($('#usdTax').length!=0){ |
|
|
|
$('#usdTax').remove(); |
|
|
|
} |
|
|
|
if($('#rmbTax').length!=0){ |
|
|
|
$('#rmbTax').remove(); |
|
|
|
} |
|
|
|
var $taxArea = $( |
|
|
|
'<div class="form-group" id="usdTax">' + |
|
|
|
'<label class="col-sm-4 control-label is-required">美元汇率:</label>' + |
|
|
|
'<div class="col-sm-8">' + |
|
|
|
'<input id="usdTax_add" name="usdTax" class="form-control" type="number" placeholder="当前未配置美元汇率,请联系总经理" readonly required/>' + |
|
|
|
'</div>' + |
|
|
|
'</div>' |
|
|
|
); |
|
|
|
$('#commonCurrency').after($taxArea); |
|
|
|
|
|
|
|
$taxArea.on('change', '#usdTax_add', function(event) { |
|
|
|
var taxValue = $(this).val(); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
data.forEach(function(row, index) { |
|
|
|
updateColumnValue(index, taxValue, "usdTax"); |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$taxArea.find('#usdTax_add').trigger('change'); |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// 更新列可见性的函数 |
|
|
|
function updateColumnVisibility(currencyType,columnName) { |
|
|
|
var $table = $("#bootstrap-sub-table-quoteChild"); |
|
|
|
var usdColumns = [ 'materialNoUsd', 'materialUsd', 'materialUsdSum', 'materialNoUsdSum']; |
|
|
|
var rmbColumns = [ 'materialNoRmb', 'materialRmb', 'materialNoRmbSum', 'materialRmbSum']; |
|
|
|
if (currencyType === '1') { |
|
|
|
// 隐藏指定的列 |
|
|
|
usdColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('hideColumn', columnName); |
|
|
|
}); |
|
|
|
// 显示指定的列 |
|
|
|
rmbColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('showColumn', columnName); |
|
|
|
}); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
// data.forEach(function(row, index) { |
|
|
|
// updateColumnValue(index, 0, "usdTax"); |
|
|
|
// }); |
|
|
|
} else { |
|
|
|
// 隐藏指定的列 |
|
|
|
rmbColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('hideColumn', columnName); |
|
|
|
}); |
|
|
|
// 显示指定的列 |
|
|
|
usdColumns.forEach(function(columnName) { |
|
|
|
$table.bootstrapTable('showColumn', columnName); |
|
|
|
}); |
|
|
|
var data = $table.bootstrapTable('getData'); |
|
|
|
// data.forEach(function(row, index) { |
|
|
|
// updateColumnValue(index, 0, "countTax"); |
|
|
|
// }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
</body> |
|
|
|
</html> |