This commit is contained in:
xman 2025-06-18 14:38:07 +08:00
parent 51a42a9b25
commit fba4b3c058

View File

@ -411,26 +411,34 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($,
},
edit: function () {
Controller.api.bindevent();
console.log("sb:init...");
// 判断 #c-action 是否存在且有值
const $action = $("#c-action");
if ($action.length && $action.val()) {
function calculatePerformance() {
console.log("sb:计算利润...");
const orderOnlineAmount = parseFloat($("#order-online-amount").val()) || 0;
console.log("sb:计算利润:预收款..."+orderOnlineAmount);
const onlineAmountLast = parseFloat($("#c-online_total").val()) || 0; //线上尾款
console.log("sb:计算利润:线上尾款..."+onlineAmountLast);
const offlineAmount = parseFloat($("#c-total").val()) || 0; //线下尾款
console.log("sb:计算利润:线下尾款..."+offlineAmount);
const cost = parseFloat($("#order-cost").val()) || 0; //成本
console.log("sb:计算利润:师傅成本..."+cost);
const materialCost = parseFloat($("#order-material_cost").val()) || 0;//材料
console.log("sb:计算利润:材料成本..."+materialCost);
const performance = (orderOnlineAmount + onlineAmountLast + offlineAmount) - (cost + materialCost);
$("#c-performance").val(performance.toFixed(2));
}
["c-online_total", "c-total", "order-cost", "order-material_cost"].forEach(function(id) {
/* ["c-online_total", "c-total", "order-cost", "order-material_cost"].forEach(function(id) {
$("#" + id).on("input", calculatePerformance);
});*/
$('#c-online_total #c-total, #order-cost, #order-material_cost').on('input', function () {
//calcProfit();
calculatePerformance();
});
// 页面加载时先算一次