aee661772b
Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
1.1 KiB
JavaScript
31 lines
1.1 KiB
JavaScript
export function isFreightFeeName(name) {
|
|
const text = String(name || '');
|
|
return text.includes('运费') || text.includes('运输费');
|
|
}
|
|
|
|
/** 运输单价对应的运费计费类型。 */
|
|
export function freightBillingType(row = {}) {
|
|
const rule = row.billingRule || {};
|
|
const rules = Array.isArray(rule.rules) ? rule.rules : [];
|
|
const freightRule = rules.find(
|
|
item => isFreightFeeName(item?.feeItem) || isFreightFeeName(item?.feeType)
|
|
);
|
|
return freightRule?.billingType || row.billingType || rule.billingType || '';
|
|
}
|
|
|
|
export function isTierUnitPrice(row) {
|
|
return freightBillingType(row) === '阶梯单价';
|
|
}
|
|
|
|
export function isIntervalBilling(row) {
|
|
const type = freightBillingType(row);
|
|
return type === '区间单价' || (type.includes('区间') && type.includes('一口价'));
|
|
}
|
|
|
|
/** 阶梯单价、区间单价、区间一口价的运输单价不开放手工调整。 */
|
|
export function isUnitPriceAdjustable(row) {
|
|
const type = freightBillingType(row);
|
|
if (!type) return true;
|
|
return !isTierUnitPrice(row) && !isIntervalBilling(row);
|
|
}
|