purchaseCost.js 1.01 KB
export const PURCHASE_COST_TYPE_CUSTOM = 0;
export const PURCHASE_COST_TYPE_AUTO = 1;

export const purchaseCostTypeList = [
	{ confId: PURCHASE_COST_TYPE_AUTO, confName: "默认带入产品成本" },
	{ confId: PURCHASE_COST_TYPE_CUSTOM, confName: "自定义成本" },
];

export function isAutoPurchaseCostType(value) {
	return Number(value) === PURCHASE_COST_TYPE_AUTO;
}

export function hasOperationCost(value) {
	return value !== "" && value !== null && value !== undefined;
}

export function resolvePurchasePrice({ purchaseCostType, purchasePrice, operationCost }) {
	return isAutoPurchaseCostType(purchaseCostType) ? operationCost : purchasePrice;
}

export function getPurchaseCostTypeText(value) {
	return Number(value) === PURCHASE_COST_TYPE_CUSTOM ? "自定义成本" : "默认带入产品成本";
}

export function isPurchaseSupplySourceAllowed(value) {
	const sourceList = Array.isArray(value) ? value : String(value || "").split(",");
	return sourceList.some(source => ["1", "2"].includes(String(source).trim()));
}