|
@@ -0,0 +1,329 @@
|
|
|
+/**
|
|
|
+ * 形象店铺申请管理相关常量定义
|
|
|
+ * @fileoverview 定义形象店铺申请管理中使用的所有枚举值和配置
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * 申请方类型枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const APPLICANT_TYPE = {
|
|
|
+ /** 经销商 */
|
|
|
+ DEALER: 1,
|
|
|
+ /** 门店 */
|
|
|
+ STORE: 2
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 是否需要报销枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const NEED_REIMBURSE = {
|
|
|
+ /** 不需要报销 */
|
|
|
+ NO: 0,
|
|
|
+ /** 需要报销 */
|
|
|
+ YES: 1
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 审核状态枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const AUDIT_STATUS = {
|
|
|
+ /** 待提交 */
|
|
|
+ PENDING_SUBMIT: 0,
|
|
|
+ /** 待审核 */
|
|
|
+ PENDING_AUDIT: 1,
|
|
|
+ /** 已通过 */
|
|
|
+ APPROVED: 2,
|
|
|
+ /** 已拒绝 */
|
|
|
+ REJECTED: 3
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 申请方类型配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const APPLICANT_TYPE_CONFIG = {
|
|
|
+ [APPLICANT_TYPE.DEALER]: {
|
|
|
+ label: '经销商',
|
|
|
+ type: 'primary',
|
|
|
+ color: '#409EFF'
|
|
|
+ },
|
|
|
+ [APPLICANT_TYPE.STORE]: {
|
|
|
+ label: '门店',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 是否需要报销配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const NEED_REIMBURSE_CONFIG = {
|
|
|
+ [NEED_REIMBURSE.NO]: {
|
|
|
+ label: '否',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ },
|
|
|
+ [NEED_REIMBURSE.YES]: {
|
|
|
+ label: '是',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 审核状态配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const AUDIT_STATUS_CONFIG = {
|
|
|
+ [AUDIT_STATUS.PENDING_SUBMIT]: {
|
|
|
+ label: '待提交',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ },
|
|
|
+ [AUDIT_STATUS.PENDING_AUDIT]: {
|
|
|
+ label: '待审核',
|
|
|
+ type: 'warning',
|
|
|
+ color: '#E6A23C'
|
|
|
+ },
|
|
|
+ [AUDIT_STATUS.APPROVED]: {
|
|
|
+ label: '已通过',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ },
|
|
|
+ [AUDIT_STATUS.REJECTED]: {
|
|
|
+ label: '已拒绝',
|
|
|
+ type: 'danger',
|
|
|
+ color: '#F56C6C'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 申请方类型选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const APPLICANT_TYPE_OPTIONS = [
|
|
|
+ { label: '经销商', value: APPLICANT_TYPE.DEALER },
|
|
|
+ { label: '门店', value: APPLICANT_TYPE.STORE }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 是否需要报销选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const NEED_REIMBURSE_OPTIONS = [
|
|
|
+ { label: '否', value: NEED_REIMBURSE.NO },
|
|
|
+ { label: '是', value: NEED_REIMBURSE.YES }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 审核状态选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const AUDIT_STATUS_OPTIONS = [
|
|
|
+ { label: '待提交', value: AUDIT_STATUS.PENDING_SUBMIT },
|
|
|
+ { label: '待审核', value: AUDIT_STATUS.PENDING_AUDIT },
|
|
|
+ { label: '已通过', value: AUDIT_STATUS.APPROVED },
|
|
|
+ { label: '已拒绝', value: AUDIT_STATUS.REJECTED }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取申请方类型标签
|
|
|
+ * @param {number} value - 申请方类型值
|
|
|
+ * @returns {string} 对应的标签文本
|
|
|
+ */
|
|
|
+export const getApplicantTypeLabel = (value) => {
|
|
|
+ const config = APPLICANT_TYPE_CONFIG[value]
|
|
|
+ return config ? config.label : '未知类型'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取申请方类型Element UI标签类型
|
|
|
+ * @param {number} value - 申请方类型值
|
|
|
+ * @returns {string} 对应的Element UI标签类型
|
|
|
+ */
|
|
|
+export const getApplicantTypeType = (value) => {
|
|
|
+ const config = APPLICANT_TYPE_CONFIG[value]
|
|
|
+ return config ? config.type : 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取申请方类型颜色
|
|
|
+ * @param {number} value - 申请方类型值
|
|
|
+ * @returns {string} 对应的颜色值
|
|
|
+ */
|
|
|
+export const getApplicantTypeColor = (value) => {
|
|
|
+ const config = APPLICANT_TYPE_CONFIG[value]
|
|
|
+ return config ? config.color : '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取是否需要报销标签
|
|
|
+ * @param {number} value - 报销状态值
|
|
|
+ * @returns {string} 对应的标签文本
|
|
|
+ */
|
|
|
+export const getNeedReimburseLabel = (value) => {
|
|
|
+ const config = NEED_REIMBURSE_CONFIG[value]
|
|
|
+ return config ? config.label : '未知状态'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取是否需要报销类型
|
|
|
+ * @param {number} value - 报销状态值
|
|
|
+ * @returns {string} 对应的Element UI标签类型
|
|
|
+ */
|
|
|
+export const getNeedReimburseType = (value) => {
|
|
|
+ const config = NEED_REIMBURSE_CONFIG[value]
|
|
|
+ return config ? config.type : 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取是否需要报销颜色
|
|
|
+ * @param {number} value - 报销状态值
|
|
|
+ * @returns {string} 对应的颜色值
|
|
|
+ */
|
|
|
+export const getNeedReimburseColor = (value) => {
|
|
|
+ const config = NEED_REIMBURSE_CONFIG[value]
|
|
|
+ return config ? config.color : '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取审核状态标签
|
|
|
+ * @param {number} value - 审核状态值
|
|
|
+ * @returns {string} 对应的标签文本
|
|
|
+ */
|
|
|
+export const getAuditStatusLabel = (value) => {
|
|
|
+ const config = AUDIT_STATUS_CONFIG[value]
|
|
|
+ return config ? config.label : '未知状态'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取审核状态类型
|
|
|
+ * @param {number} value - 审核状态值
|
|
|
+ * @returns {string} 对应的Element UI标签类型
|
|
|
+ */
|
|
|
+export const getAuditStatusType = (value) => {
|
|
|
+ const config = AUDIT_STATUS_CONFIG[value]
|
|
|
+ return config ? config.type : 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取审核状态颜色
|
|
|
+ * @param {number} value - 审核状态值
|
|
|
+ * @returns {string} 对应的颜色值
|
|
|
+ */
|
|
|
+export const getAuditStatusColor = (value) => {
|
|
|
+ const config = AUDIT_STATUS_CONFIG[value]
|
|
|
+ return config ? config.color : '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证申请方类型值是否有效
|
|
|
+ * @param {number} value - 申请方类型值
|
|
|
+ * @returns {boolean} 是否为有效值
|
|
|
+ */
|
|
|
+export const isValidApplicantType = (value) => {
|
|
|
+ return Object.values(APPLICANT_TYPE).includes(value)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证是否需要报销值是否有效
|
|
|
+ * @param {number} value - 报销状态值
|
|
|
+ * @returns {boolean} 是否为有效值
|
|
|
+ */
|
|
|
+export const isValidNeedReimburse = (value) => {
|
|
|
+ return Object.values(NEED_REIMBURSE).includes(value)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证审核状态值是否有效
|
|
|
+ * @param {number} value - 审核状态值
|
|
|
+ * @returns {boolean} 是否为有效值
|
|
|
+ */
|
|
|
+export const isValidAuditStatus = (value) => {
|
|
|
+ return Object.values(AUDIT_STATUS).includes(value)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否为经销商申请
|
|
|
+ * @param {number} applicantType - 申请方类型
|
|
|
+ * @returns {boolean} 是否为经销商申请
|
|
|
+ */
|
|
|
+export const isDealerApplicant = (applicantType) => {
|
|
|
+ return applicantType === APPLICANT_TYPE.DEALER
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否为门店申请
|
|
|
+ * @param {number} applicantType - 申请方类型
|
|
|
+ * @returns {boolean} 是否为门店申请
|
|
|
+ */
|
|
|
+export const isStoreApplicant = (applicantType) => {
|
|
|
+ return applicantType === APPLICANT_TYPE.STORE
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否需要报销
|
|
|
+ * @param {number} needReimburse - 报销状态
|
|
|
+ * @returns {boolean} 是否需要报销
|
|
|
+ */
|
|
|
+export const isNeedReimburse = (needReimburse) => {
|
|
|
+ return needReimburse === NEED_REIMBURSE.YES
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否可以进行审核操作
|
|
|
+ * @param {number} auditStatus - 审核状态
|
|
|
+ * @returns {boolean} 是否可以审核
|
|
|
+ */
|
|
|
+export const canAudit = (auditStatus) => {
|
|
|
+ return auditStatus === AUDIT_STATUS.PENDING_AUDIT
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否可以编辑申请
|
|
|
+ * @param {number} auditStatus - 审核状态
|
|
|
+ * @returns {boolean} 是否可以编辑
|
|
|
+ */
|
|
|
+export const canEdit = (auditStatus) => {
|
|
|
+ return auditStatus === AUDIT_STATUS.PENDING_SUBMIT
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断审核是否已完成
|
|
|
+ * @param {number} auditStatus - 审核状态
|
|
|
+ * @returns {boolean} 审核是否已完成
|
|
|
+ */
|
|
|
+export const isAuditCompleted = (auditStatus) => {
|
|
|
+ return auditStatus === AUDIT_STATUS.APPROVED || auditStatus === AUDIT_STATUS.REJECTED
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断审核是否通过
|
|
|
+ * @param {number} auditStatus - 审核状态
|
|
|
+ * @returns {boolean} 审核是否通过
|
|
|
+ */
|
|
|
+export const isAuditApproved = (auditStatus) => {
|
|
|
+ return auditStatus === AUDIT_STATUS.APPROVED
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断审核是否被拒绝
|
|
|
+ * @param {number} auditStatus - 审核状态
|
|
|
+ * @returns {boolean} 审核是否被拒绝
|
|
|
+ */
|
|
|
+export const isAuditRejected = (auditStatus) => {
|
|
|
+ return auditStatus === AUDIT_STATUS.REJECTED
|
|
|
+}
|