Forráskód Böngészése

feat(形象店铺申请): 添加申请方类型和报销状态功能

yz 1 hónapja
szülő
commit
fc6ad96818

+ 329 - 0
src/constants/image-store-apply.js

@@ -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
+}

+ 4 - 1
src/constants/index.js

@@ -9,4 +9,7 @@ export * from './shipment'
 export * from './claim'
 
 // 投诉管理相关常量
-export * from './complaint'
+export * from './complaint'
+
+// 形象店铺申请相关常量
+export * from './image-store-apply'

+ 32 - 17
src/views/image-store-apply/index.vue

@@ -29,27 +29,34 @@
         </el-button>
       </template>
 
+      <!-- 申请方类型显示 -->
+      <template slot="applicantType" slot-scope="{row}">
+        <el-tag
+          :type="getApplicantTypeType(row.applicantType)"
+          size="small"
+        >
+          {{ getApplicantTypeLabel(row.applicantType) }}
+        </el-tag>
+      </template>
+
       <!-- 审核状态显示 -->
       <template slot="auditStatus" slot-scope="{row}">
         <el-tag
           :type="getAuditStatusType(row.auditStatus)"
           size="small"
         >
-          {{ getAuditStatusText(row.auditStatus) }}
+          {{ getAuditStatusLabel(row.auditStatus) }}
         </el-tag>
       </template>
 
-      <!-- 申请金额格式化 -->
-      <template slot="applyAmount" slot-scope="{row}">
-        ¥{{ formatAmount(row.applyAmount) }}
-      </template>
-
-      <!-- 审核金额格式化 -->
-      <template slot="auditAmount" slot-scope="{row}">
-        <span v-if="row.auditAmount && parseFloat(row.auditAmount) > 0">
-          ¥{{ formatAmount(row.auditAmount) }}
-        </span>
-        <span v-else>-</span>
+      <!-- 是否需要报销显示 -->
+      <template slot="needReimburse" slot-scope="{row}">
+        <el-tag
+          :type="getNeedReimburseType(row.needReimburse)"
+          size="small"
+        >
+          {{ getNeedReimburseText(row.needReimburse) }}
+        </el-tag>
       </template>
 
       <!-- 操作列 -->
@@ -62,7 +69,7 @@
           查看详情
         </el-button>
         <el-button
-          v-if="row.auditStatus === 0"
+          v-if="canAudit(row.auditStatus)"
           type="text"
           size="small"
           @click="handleApprove(row)"
@@ -70,7 +77,7 @@
           审核通过
         </el-button>
         <el-button
-          v-if="row.auditStatus === 0"
+          v-if="canAudit(row.auditStatus)"
           type="text"
           size="small"
           @click="handleReject(row)"
@@ -152,7 +159,7 @@
                   :type="getAuditStatusType(detailData.auditStatus)"
                   size="small"
                 >
-                  {{ getAuditStatusText(detailData.auditStatus) }}
+                  {{ getAuditStatusLabel(detailData.auditStatus) }}
                 </el-tag>
               </div>
             </el-col>
@@ -395,14 +402,22 @@
 </template>
 
 <script>
+import { getApplicantTypeLabel, getApplicantTypeType } from '@/constants/image-store-apply';
+import { getAuditStatusLabel, getAuditStatusType } from '@/constants/image-store-apply';
+
+
 import imageStoreApplyMixin from './mixins/imageStoreApplyIndex'
+import { canAudit } from '@/constants/image-store-apply'
 
 export default {
   name: 'ImageStoreApply',
-  mixins: [imageStoreApplyMixin]
+  mixins: [imageStoreApplyMixin],
+  methods: {
+    canAudit
+  }
 }
 </script>
 
-<style lang="=scss" scoped src="./index.scss">
+<style lang="scss" scoped src="./index.scss">
 
 </style>

+ 62 - 33
src/views/image-store-apply/mixins/imageStoreApplyIndex.js

@@ -1,6 +1,24 @@
 import { getList, getDetail, update, getAttachmentList } from '@/api/order/image-store-apply'
 import { formatFileSize } from '@/util/util'
 import { mapGetters } from 'vuex'
+import {
+  APPLICANT_TYPE,
+  APPLICANT_TYPE_OPTIONS,
+  AUDIT_STATUS,
+  AUDIT_STATUS_OPTIONS,
+  NEED_REIMBURSE,
+  NEED_REIMBURSE_OPTIONS,
+  getApplicantTypeLabel,
+  getApplicantTypeType,
+  getAuditStatusLabel,
+  getAuditStatusType,
+  getNeedReimburseLabel,
+  getNeedReimburseType,
+  canAudit,
+  isAuditCompleted,
+  isDealerApplicant,
+  isStoreApplicant
+} from '@/constants/image-store-apply'
 
 /**
  * @typedef {import('@/api/order/image-store-apply').ImageStoreApplyRecord} ImageStoreApplyRecord
@@ -89,6 +107,15 @@ export default {
             searchPlaceholder: '请输入申请编号'
           },
           {
+            label: '申请方类型',
+            prop: 'applicantType',
+            minWidth: 100,
+            slot: true,
+            search: true,
+            type: 'select',
+            dicData: APPLICANT_TYPE_OPTIONS
+          },
+          {
             label: '客户编码',
             prop: 'customerCode',
             minWidth: 120,
@@ -132,11 +159,7 @@ export default {
             slot: true,
             search: true,
             type: 'select',
-            dicData: [
-              { label: '未审核', value: 0 },
-              { label: '审核通过', value: 1 },
-              { label: '审核不通过', value: 2 }
-            ]
+            dicData: AUDIT_STATUS_OPTIONS
           },
           {
             label: '审核金额',
@@ -199,6 +222,8 @@ export default {
   },
 
   methods: {
+    isDealerApplicant,
+    isStoreApplicant,
     /**
      * 格式化金额显示
      * @param {number|string} amount - 金额
@@ -209,32 +234,28 @@ export default {
       return parseFloat(amount).toFixed(2)
     },
 
+    getApplicantTypeLabel,
+    getApplicantTypeType,
+    getAuditStatusType,
+    getAuditStatusLabel,
+
+
     /**
-     * 获取审核状态类型
-     * @param {number} status - 审核状态
-     * @returns {string} 状态类型
+     * 获取是否需要报销标签
+     * @param {number} value - 报销状态值
+     * @returns {string} 对应的标签文本
      */
-    getAuditStatusType(status) {
-      const statusMap = {
-        0: 'warning', // 未审核
-        1: 'success', // 审核通过
-        2: 'danger'   // 审核不通过
-      }
-      return statusMap[status] || 'info'
+    getNeedReimburseText(value) {
+      return getNeedReimburseLabel(value)
     },
 
     /**
-     * 获取审核状态文本
-     * @param {number} status - 审核状态
-     * @returns {string} 状态文本
+     * 获取是否需要报销类型
+     * @param {number} value - 报销状态值
+     * @returns {string} 对应的Element UI标签类型
      */
-    getAuditStatusText(status) {
-      const statusMap = {
-        0: '未审核',
-        1: '审核通过',
-        2: '审核不通过'
-      }
-      return statusMap[status] || '未知状态'
+    getNeedReimburseType(value) {
+      return getNeedReimburseType(value)
     },
 
     /**
@@ -354,12 +375,17 @@ export default {
      * @param {ImageStoreApplyRecord} row - 行数据
      */
     handleApprove(row) {
+      if (!canAudit(row.auditStatus)) {
+        this.$message.warning('当前状态不允许审核操作')
+        return
+      }
+
       this.$confirm('确定要审核通过该申请吗?', '确认审核', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
         type: 'success'
       }).then(async () => {
-        await this.submitAudit(row, 1, '审核通过')
+        await this.submitAudit(row, AUDIT_STATUS.APPROVED, '审核通过')
       }).catch(() => {
         // 用户取消操作
       })
@@ -370,6 +396,11 @@ export default {
      * @param {ImageStoreApplyRecord} row - 行数据
      */
     handleReject(row) {
+      if (!canAudit(row.auditStatus)) {
+        this.$message.warning('当前状态不允许审核操作')
+        return
+      }
+
       this.rejectForm = {
         id: row.id,
         applyNo: row.applyNo,
@@ -399,19 +430,17 @@ export default {
         // 找到对应的行数据
         const row = this.data.find(item => item.id === this.rejectForm.id)
         if (!row) {
-          this.$message.error('数据不存在')
+          this.$message.error('未找到对应的申请记录')
           return
         }
 
-        await this.submitAudit(row, 2, this.rejectForm.auditRemark)
+        await this.submitAudit(row, AUDIT_STATUS.REJECTED, this.rejectForm.auditRemark)
         this.rejectVisible = false
       } catch (error) {
-        if (error.message) {
-          // 表单验证错误
-          return
+        if (error !== false) { // 不是表单验证失败
+          console.error('提交拒绝审核失败:', error)
+          this.$message.error('提交失败,请重试')
         }
-        console.error('审核操作失败:', error)
-        this.$message.error('审核操作失败')
       }
     },