constants.js 4.58 KB
/*
 * @Author: limin
 * @Date: 2019-09-01 19:06:01
 * @Last Modified by: chenwq
 * @Last Modified time: 2021-04-26 16:35:41
 */

export const TYPE_NAME = 'confType'
/**
 * 前端基础数据管理对应的接口名称的key
 */
export const BaseData = {
  channelType: 'channelType',
  productType: 'productType'
}
/**
 * 超级管理员类型
 */
export const SUPPER_ADMIN = true //

// 商户类型 - 除广汇外
export const userType = {
  1: '员工',
  2: '门店',
  3: '市级经销商',
  4: '省级经销商',
  5: '工厂'
}

// 商户类型 - 广汇
export const ghUserType = {
  1: '员工',
  2: '门店',
  3: '片区',
  4: '大区',
  5: '总部',
  6: '供应商'
}

// 商户类型 - 除广汇外
export const userTypeList = [{
  confId: 1,
  confLabel: '员工'
}, {
  confId: 2,
  confLabel: '门店'
}, {
  confId: 3,
  confLabel: '市级经销商'
}, {
  confId: 4,
  confLabel: '省级经销商'
}, {
  confId: 5,
  confLabel: '工厂'
}]

// 商户类型 - 广汇
export const ghUserTypeList = [{
  confId: 1,
  confLabel: '员工'
}, {
  confId: 2,
  confLabel: '门店'
}, {
  confId: 3,
  confLabel: '片区'
}, {
  confId: 4,
  confLabel: '大区'
}, {
  confId: 5,
  confLabel: '总部'
}, {
  confId: 6,
  confLabel: '供应商'
}]

// 商户分类
export const merchantClassifyList = [{
  confId: 1,
  confLabel: '批发/零售商'
}, {
  confId: 2,
  confLabel: '4S店'
}, {
  confId: 3,
  confLabel: '综合汽贸店'
}, {
  confId: 4,
  confLabel: '综合后服务门店 '
}, {
  confId: 5,
  confLabel: '厂家'
}, {
  confId: 6,
  confLabel: '园区店'
}, {
  confId: 7,
  confLabel: '服务商'
}]

// 商户分类 - 4S店(2)和服务商(7)- 查全部(2和7,排除园区店{id:6})
export const merchantStoreServiceList = [{
  confId: 2,
  confLabel: '4S店'
}, {
  confId: 7,
  confLabel: '服务商'
}]

// 品牌商
export const brandMerchantList = [{
  confId: '1',
  confValue: '3M/福膜'
}, {
  confId: '2',
  confValue: '强生/福膜'
}, {
  confId: '3',
  confValue: '强生/斯帝飞'
}, {
  confId: '4',
  confValue: '3M/斯帝飞'
}, {
  confId: '5',
  confValue: '3M/今蓝'
}, {
  confId: '6',
  confValue: '量子/今蓝'
}, {
  confId: '7',
  confValue: '强生'
}, {
  confId: '8',
  confValue: '今蓝'
}, {
  confId: '9',
  confValue: '琥珀'
}, {
  confId: '10',
  confValue: '嘀嘀虎'
}]

// 分账状态
export const divisionStatusList = [{
  confId: '1',
  confLabel: '待分账'
}, {
  confId: '2',
  confLabel: '分账中'
}, {
  confId: '3',
  confLabel: '分账成功'
}, {
  confId: '4',
  confLabel: '分账失败'
}]

// 提现状态
export const withdrawStatusList = [{
  confId: 1,
  confLabel: '提现中'
}, {
  confId: 2,
  confLabel: '提现成功'
}, {
  confId: 3,
  confLabel: '提现失败'
}]

// 提现渠道
export const withdrawChannelList = [{
  confId: 1,
  confLabel: '小程序'
}, {
  confId: 2,
  confLabel: 'PC后台'
}]

// 获取最近n个月,默认6个月
export function getCurrentSixMonth(n = 5) {
  return [
    new Date(new Date().setMonth((new Date().getMonth() - n))),
    new Date()
  ]
}

// 新值,旧值,整数部分位数,小数部分位数,最小值,最大值,规则
export function limitPrice(newValue, oldValue, intergerDigit, pointDigit, minValue, maxValue, regRule) {
  var reg = {
    priceReg: /^\d[\d\.]*$/,
    numReg: /^[1-9]\d*$/
  }
  regRule = regRule || 'priceReg'
  if (newValue && ((minValue && (newValue < minValue)) || (maxValue && (newValue > maxValue)))) {
    return oldValue || ''
  }
  if (newValue && reg[regRule].test(newValue + '')) {
    if ((/\./).test(newValue)) {
      newValue = newValue + ''
      var interger = newValue.split('.')[0]
      var point = newValue.split('.')[1]
      var intergerNum = interger.length > intergerDigit ? oldValue.split('.')[0] : interger
      var pointNum = point.length > pointDigit ? point.slice(0, pointDigit) : point
      newValue = pointDigit ? intergerNum + '.' + pointNum : newValue.split('.')[0]
    } else {
      newValue = newValue.length > intergerDigit ? oldValue.slice(0, intergerDigit) : newValue
    }
    return newValue
  } else {
    return newValue ? oldValue : ''
  }
}

/**
 * 时间控件-限制月份
 */
export const rangePickerOptions = {
  disabledDate(date) {
    if (date > new Date()) {
      return true
    }
    return false
  }
}

/**
 * 时间控件-(0-30天内的日期)
 */
export const appointDays = 35
export const afterTodayOptions = {
  disabledDate(date) {
    if (date < new Date(new Date().toLocaleDateString()) || (date > new Date(new Date().setDate(new Date().getDate() + (appointDays - 1))))) {
      return true
    }
    return false
  }
}