|
@@ -79,16 +79,25 @@ $(document).ready(function () {
|
|
|
}
|
|
|
// 超计显示
|
|
|
function checkOverRange(data) {
|
|
|
+ const billsGatherOver = function (data, qtyField, tpField, per) {
|
|
|
+ if (data.end_contract_qty) {
|
|
|
+ if (!data[qtyField]) return true;
|
|
|
+ return data[qtyField] > 0
|
|
|
+ ? data.end_contract_qty > ZhCalc.mul(data[qtyField], per)
|
|
|
+ : data.end_contract_qty < ZhCalc.mul(data[qtyField], per) || data.end_contract_qty > 0;
|
|
|
+ } else {
|
|
|
+ if (!data[tpField]) return !!data.end_contract_tp;
|
|
|
+ return data[tpField] > 0
|
|
|
+ ? data.end_contract_tp > ZhCalc.mul(data[tpField], per)
|
|
|
+ : data.end_contract_tp < ZhCalc.mul(data[tpField], per) || data.end_contract_tp > 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
const bQty = $('#customRadio1')[0].checked, bDealQty = $('#customRadio2')[0].checked;
|
|
|
const nPercent = Math.min(Math.max(ZhCalc.div(parseFloat($('#over-percent').val()), 100), 0.5), 1);
|
|
|
for (const node of data) {
|
|
|
if (node) {
|
|
|
- const bOverRangeTz = node.end_contract_qty
|
|
|
- ? (node.quantity ? node.end_contract_qty > ZhCalc.mul(node.quantity, nPercent) : node.end_contract_qty)
|
|
|
- : (node.total_price ? node.end_contract_tp > ZhCalc.mul(node.total_price, nPercent) : node.end_contract_tp);
|
|
|
- const bOverRangeDeal = node.end_contract_qty
|
|
|
- ? (node.deal_bills_qty ? node.end_contract_qty > ZhCalc.mul(node.deal_bills_qty, nPercent) : node.end_contract_qty)
|
|
|
- : (node.deal_bills_tp ? node.end_contract_tp > ZhCalc.mul(node.deal_bills_tp, nPercent) : node.end_contract_tp);
|
|
|
+ const bOverRangeTz = billsGatherOver(node, 'quantity', 'total_price', nPercent);
|
|
|
+ const bOverRangeDeal = billsGatherOver(node, 'deal_bills_qty', 'deal_bills_tp', nPercent);
|
|
|
node.overRange = bQty ? bOverRangeTz : (bDealQty ? bOverRangeDeal : bOverRangeTz || bOverRangeDeal);
|
|
|
}
|
|
|
}
|