status.js 2.74 KB
import { sceneTypeOptions, VIEW_MODE } from "@/views/goods/shelfProduct/constant/index.js";

// 判断是否为查看状态
// true: 查看状态
// false: 编辑状态
export function isView(mode) {
	return mode === VIEW_MODE.VIEW;
}

export function isEdit(mode) {
	return mode === VIEW_MODE.EDIT;
}
export function isSaving(mode) {
	return mode === VIEW_MODE.SAVING;
}

/**
 * 是否为精品升级
 *  @returns {boolean} 是否
 */
export function isQualityUpgrade(sceneType) {
	return sceneType === sceneTypeOptions[0].value;
}
/**
 * 是否为会员权益升级
 *  @returns {boolean} 是否
 */
export function isMemberRightsUpgrade(sceneType) {
	const memberValues = sceneTypeOptions.slice(1).map(item => item.value);
	return memberValues.includes(sceneType);
}

// 一些老接口所收的sceneType, 如果是会员权益, 则传0 否则传1
export function getMemberRightsUpgradeValue(baseSceneCode) {
	return isMemberRightsUpgrade(baseSceneCode) ? 0 : 1;
}

/**
 * 上架类型 是否为修改
 *  @returns {boolean} 是否
 */
export function isShelfStyleEdit(shelfStyle) {
	return shelfStyle === 2;
}

/**
 * 5.8.6 版本改为 是否膜类
 * 是否太阳膜
 *  @returns {boolean} 是否
 */
export function isSolarFilm(goodType) {
	return [1, 12, 14].includes(goodType);
}

/**
 *	是否为单店模式
 */
export function isSingleShopMode(shelfType) {
	return shelfType === 1;
}
/**
 *	是否为批量模式
 */
export function isBatchPublishMode(shelfType) {
	return shelfType === 2;
}

/**
 *  分账配置 表格仅展示下面这些expenseCategoryId || feeCategoryNameId
 * @param {*} sceneType
 * @returns array[number]
 */
export function getSelectFilterIds(baseSceneCode) {
	const ids = [1, 2, 1300, 1301];
	return ids;
}

/**
 * 分账配置 - 表格仅展示下面这些expenseCategoryId || feeCategoryNameId
 * @param {*} baseSceneCode
 * @returns
 */
export function getTableFilterIds(baseSceneCode) {
	const sceneTypeFilter = {
		// 精品升级
		1: [1, 2, 3, 4, 1300, 1301],
		// 会员升级权益
		0: [1, 2, 4, 701, 1300, 1301],
	};
	const sceneType = isMemberRightsUpgrade(baseSceneCode) ? 0 : 1;

	return sceneTypeFilter[sceneType] || [];
}

/**
 *  "产品成本获取方式 1-自定义成本
 * @param {*} upgradeProductCostStyle
 * @returns
 */
export function isUpgradeProductCostStyleCustom(upgradeProductCostStyle) {
	return upgradeProductCostStyle === 1;
}

/**
 * 产品成本获取方式 2-默认带入产品成本"
 * @param {*} upgradeProductCostStyle
 * @returns
 */
export function isUpgradeProductCostStyleDefault(upgradeProductCostStyle) {
	return upgradeProductCostStyle === 2;
}

/**
 * 是否直营
 * 权益、延保 且 供应方=广联直营 0-否 1-是
 *  @returns
 */
export function isDirectOperation(supplyFlag) {
	return supplyFlag === 1;
}