workOrderLowPrice.helpers.js 1010 Bytes
/**
 * @file 精品低价工单编辑门禁。仅识别接口返回的 lowPriceFlag,不介入低价审批流程。
 */

/** 低价工单被编辑时的统一提示 */
export const LOW_PRICE_ORDER_EDIT_MESSAGE = '低价单不可以编辑'

/**
 * 判断工单是否为禁止编辑的低价单,兼容接口返回数字或字符串。
 *
 * @param {Object|null|undefined} order 工单列表项或详情对象
 * @returns {boolean} lowPriceFlag 为 1 时返回 true
 */
export function isLowPriceOrder(order) {
  return Number(order?.lowPriceFlag) === 1
}

/**
 * 列表仅在即将进入 createOrder 编辑已有工单时拦截低价单;查看详情、确认及新增入口不受影响。
 *
 * @param {Object|null|undefined} order 工单列表项
 * @param {string} routeName 列表根据状态解析出的目标路由名
 * @returns {boolean} 是否应在跳转前拦截
 */
export function shouldBlockLowPriceOrderEdit(order, routeName) {
  return routeName === 'createOrder' && isLowPriceOrder(order)
}