@ -247,15 +247,26 @@
return $.table.selectDictLabel(processMethodDatas, value);
}
},
{ title: '对外售价',field: 'materialSole',editable: true},
{title: '国内税率',field: 'countTax',align: 'center',editable: true,
},
{ title: '美元汇率',field: 'usdTax', align: 'center',editable: true,
{ title: '对外售价',field: 'materialSole',
editable: {
type: 'number',
mode: 'inline',
title: '对外售价',
validate: function (value) {
if (!value) {
return '对外售价不能为空';
}
if (isNaN(value)) {
return '对外售价必须为数字';
}
}
}
},
{title: '国内税率',field: 'countTax',align: 'center',},
{ title: '美元汇率',field: 'usdTax', align: 'center',},
{field: 'materialNum',align: 'center',title: '物料的数量',
editable:{
type : 'number',
type : 'text ',
mode: 'inline',
title : '物料的数量',
validate : function(value) {
@ -274,6 +285,9 @@
editable:{
type: 'text', // 使用'text'类型,因为我们需自定义验证小数
mode: 'inline',
enabled: function() {
return ($("#commonCurrency_add").val() === '1'); // 当货币类型为2时启用
},
title: '物料的不含税单价(RMB)',
validate: function(value) {
// 验证是否为空
@ -299,7 +313,10 @@
editable: {
type: 'text', // 使用'text'类型,因为我们需自定义验证小数
mode: 'inline',
title: '物料的不含税单价(RMB)',
enabled: function() {
return ($("#commonCurrency_add").val() === '2'); // 当货币类型为2时启用
},
title: '物料的不含税单价(美元)',
validate: function(value) {
// 验证是否为空
if (!value) {
@ -318,64 +335,18 @@
}
}
},
{ title: '物料的含税单价(美元)',
field: 'materialUsd',
align: 'center',
},
{ title: '物料的含税总价(美元)',
field: 'materialUsdSum',
align: 'center',
},
{ title: '物料的不含税总价(美元)',
field: 'materialNoUsdSum',
align: 'center',
},
{ title: '物料的含税总价(RMB)',
field: 'materialNoRmbSum',
align: 'center',
},
{title: '物料的不含税总价(RMB)',
field: 'materialRmbSum',
align: 'center',
},
{
field: 'createBy',
align: 'center',
title: '录入人',
visible: false
},
{
field: 'createTime',
align: 'center',
title: '录入时间',
visible: false
},
{
field: 'updateBy',
align: 'center',
title: '更新人',
visible: false
},
{
field: 'updateTime',
align: 'center',
title: '上次更新时间',
visible: false
},
{
field: 'remark',
align: 'center',
title: '备注',
visible: false
},
{
field: 'auditStatus',
align: 'center',
title: '审核状态',
visible: false,
formatter: function(value, row, index) {
return $.table.selectDictLabel(auditStatusDatas, value);
}
{ title: '物料的含税单价(美元)',field: 'materialUsd',align: 'center',},
{ title: '物料的含税总价(美元)',field: 'materialUsdSum', align: 'center',},
{ title: '物料的不含税总价(美元)',field: 'materialNoUsdSum',align: 'center',},
{ title: '物料的含税总价(RMB)',field: 'materialNoRmbSum',align: 'center',},
{title: '物料的不含税总价(RMB)',field: 'materialRmbSum',align: 'center',},
{field: 'createBy', align: 'center',title: '录入人',visible: false},
{field: 'createTime',align: 'center',title: '录入时间',visible: false},
{field: 'updateBy',align: 'center',title: '更新人',visible: false},
{field: 'updateTime',align: 'center',title: '上次更新时间',visible: false},
{field: 'remark',align: 'center',title: '备注',visible: false},
{field: 'auditStatus',align: 'center',title: '审核状态',visible: false,
formatter: function(value, row, index) {return $.table.selectDictLabel(auditStatusDatas, value);}
},
{title: '操作', align: 'center',
@ -394,34 +365,34 @@
}else{
rmb1 = $("#rmbTax_add").val();
}
var rmb = Number(rmb1).toFixed(2) / 100 ;
var rmb = parseFloat(rmb1) ;
var usd = $("#usdTax_add").val();
if (usd =='' || usd== null){
usd = 0;
}else{
usd = Number(usd).toFixed(2 );
usd = parseFloat(usd );
}
console.log(commonCurrency1);
if(commonCurrency1 == 1){
row.materialNoRmb = Number (row.materialNoRmb).toFixed(2);
row.materialRmb = Number(row.materialNoRmb * Number(1 + rmb) );
row.materialNoRmbSum = Number(row.materialNum * Number (row.materialNoRmb)).toFixed(2);
row.materialRmbSum = Number (row.materialRmb * row.materialNum).toFixed(2);
row.materialNoUsd = Number (row.materialNoRmb / usd).toFixed(2);
row.materialNoUsdSum = Number (row.materialNum * row.materialNoUsd).toFixed(2);
row.materialUsd = Number(row.materialNoUsd).toFixed(2)
row.materialUsdSum = Number(row.materialNum * Number(row.materialUsd) ).toFixed(2);
row.materialNoRmb = parseFloat (row.materialNoRmb).toFixed(2);
row.materialRmb = parseFloat(row.materialNoRmb * parseFloat(1 + rmb)).toFixed(2 );
row.materialNoRmbSum = parseFloat(row.materialNum * parseFloat (row.materialNoRmb)).toFixed(2);
row.materialRmbSum = parseFloat (row.materialRmb * row.materialNum).toFixed(2);
row.materialNoUsd = parseFloat (row.materialNoRmb / usd).toFixed(2);
row.materialNoUsdSum = parseFloat (row.materialNum * row.materialNoUsd).toFixed(2);
row.materialUsd = parseFloat(row.materialNoUsd).toFixed(2);
row.materialUsdSum = parseFloat(row.materialNum * row.materialUsd ).toFixed(2);
}
else if( commonCurrency1 == 2){
row.materialNoUsd = Number (row.materialNoUsd).toFixed(2);
row.materialUsd = Number (row.materialNoUsd).toFixed(2);
row.materialUsdSum = Number (row.materialNum * row.materialUsd).toFixed(2);
row.materialNoUsdSum = Number (row.materialNoUsd * row.materialNum).toFixed(2);
row.materialNoRmb = Number (row.materialNoUsd * usd).toFixed(2);
row.materialRmb = Number (row.materialNoRmb * (1 + rmb)).toFixed(2);
row.materialNoRmbSum = Number (row.materialNoRmb * row.materialNum).toFixed(2);
row.materialRmbSum = Number (row.materialRmb * row.materialNum).toFixed(2);
row.materialNoUsd = parseFloat (row.materialNoUsd).toFixed(2);
row.materialUsd = parseFloat (row.materialNoUsd).toFixed(2);
row.materialUsdSum = parseFloat (row.materialNum * row.materialUsd).toFixed(2);
row.materialNoUsdSum = parseFloat (row.materialNoUsd * row.materialNum).toFixed(2);
row.materialNoRmb = parseFloat (row.materialNoUsd * usd).toFixed(2);
row.materialRmb = parseFloat (row.materialNoRmb * (1 + rmb)).toFixed(2);
row.materialNoRmbSum = parseFloat (row.materialNoRmb * row.materialNum).toFixed(2);
row.materialRmbSum = parseFloat (row.materialRmb * row.materialNum).toFixed(2);
}
getTotalAmount()
},
@ -535,49 +506,65 @@
});
//计算金额
function getTotalAmount() {
// $("#addFinishbomTable").bootstrapTable('refresh');
let getData = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData', true);
var enterprise = "";let enterpriseSum = 0; let noRmb = 0;
let rmb = 0;let noRmbSum = 0;let rmbSum = 0;let noUsd = 0;
let usd = 0;let noUsdSum = 0; let usdSum = 0;
for(let i=0;i< getData.length ; i + + ) {
enterprise += getData[i].materialName + ": 数量 :" + getData[i].materialNum +"; ";
enterpriseSum += Number(getData[i].materialNum);
noRmb += Number(getData[i].materialNoRmb);
rmb += Number(getData[i].materialRmb) ;
noRmbSum += Number(getData[i].materialNoRmbSum);
rmbSum += Number(getData[i].materialRmbSum);
noUsd += Number(getData[i].materialNoUsd) ;
usd += Number(getData[i].materialUsd) ;
noUsdSum += Number(getData[i].materialNoUsdSum);
usdSum += Number(getData[i].materialUsdSum);
}
$("#enterprise_add").val(enterprise);
$("#enterpriseSum_add").val(Number(enterpriseSum).toFixed(2));
$("#noRmb_add").val(Number(noRmb).toFixed(2));
$("#rmb_add").val(Number(rmb).toFixed(2));
$("#noRmbSum_add").val(Number(noRmbSum).toFixed(2));
$("#rmbSum_add").val(Number(rmbSum).toFixed(2));
$("#noUsd_add").val(Number(noUsd).toFixed(2));
$("#usd_add").val(Number(usd).toFixed(2));
$("#noUsdSum_add").val(Number(noUsdSum).toFixed(2));
$("#usdSum_add").val(Number(usdSum).toFixed(2));
// 获取表格数据
const data = $("#bootstrap-sub-table-quoteChild").bootstrapTable('getData', true);
// 初始化汇总对象,减少代码重复并提高清晰度
const sums = {
enterprise: "", // 用于拼接物料名称和数量
enterpriseSum: 0, // 物料总数量
currencies: {
noRmb: { total: 0, single: 0 }, // 非人民币数量与总金额
rmb: { total: 0, single: 0 }, // 人民币
noUsd: { total: 0, single: 0 }, // 非美元
usd: { total: 0, single: 0 } // 美元
}
};
// 遍历数据进行计算
for (let i = 0; i < data.length ; i + + ) {
const item = data[i];
// 拼接物料信息
sums.enterprise += "" + item.materialName + ": 数量 : " + item.materialNum;
sums.enterpriseSum += parseFloat(item.materialNum); // 累加物料数量
// 分别累加各货币的单个金额和总金额
['noRmb', 'rmb', 'noUsd', 'usd'].forEach(currency => {
sums.currencies[currency].single += parseFloat(item['material' + [currency] ]);
sums.currencies[currency].total += parseFloat(item['material' + [currency] + 'Sum']);
});
}
updateFormValues(sums);
}
function updateFormValues(sums) {
// 物料合计与数量合计没有在sums中直接给出,这里假设它们需要单独处理或已存在于页面其他部分
$("#enterprise_add").val(sums.enterprise);
$("#enterpriseSum_add").val(sums.enterpriseSum);
// 更新不含税单价和总价
$("#noRmb_add").val(sums.currencies.noRmb.single);
$("#noRmbSum_add").val(sums.currencies.noRmb.total);
$("#rmb_add").val(sums.currencies.rmb.single);
$("#rmbSum_add").val(sums.currencies.rmb.total);
$("#noUsd_add").val(sums.currencies.noUsd.single);
$("#noUsdSum_add").val(sums.currencies.noUsd.total);
$("#usd_add").val(sums.currencies.usd.single);
$("#usdSum_add").val(sums.currencies.usd.total);
}
$(document).ready(function() {
// 监听货币选项变化
$("#commonCurrency_add").on("change", function() {
var isEditable = $(this).val() === "1";
var fieldName = "";
if (isEditable) {
fieldName = "materialNoRmb";
$("#rmbTax_add").prop("disabled", false);
$("#usdTax_add").prop("disabled", false);
} else {
fieldName = "materialNoUsd";
$("#rmbTax_add").prop("disabled", true);
$("#usdTax_add").prop("disabled", true);
}
// if (isEditable) {
// fieldName = "materialNoRmb";
// $("#rmbTax_add").prop("disabled", false);
// $("#usdTax_add").prop("disabled", false);
// } else {
// fieldName = "materialNoUsd";
// $("#rmbTax_add").prop("disabled", true);
// $("#usdTax_add").prop("disabled", true);
// }
var materialColumnCells = $('#bootstrap-sub-table-quoteChild tbody tr td [field=" '+ fieldName+' "]');
// 根据是否可编辑,添加或移除xEditable