Преглед изворни кода

refactor(complaint): 使用常量替换状态和类型的硬编码值

yz пре 3 недеља
родитељ
комит
4ccebc702b
3 измењених фајлова са 16 додато и 8 уклоњено
  1. 1 1
      src/api/complaint/index.js
  2. 14 6
      src/views/complaint/complaintMixin.js
  3. 1 1
      src/views/complaint/index.vue

+ 1 - 1
src/api/complaint/index.js

@@ -175,7 +175,7 @@ export const getDetail = (complaintId) => {
  */
 export const updateStatus = (id, status, closeReason) => {
   return request({
-    url: '/api/blade-factory/api/factory/complaint/status',
+    url: '/api/blade-factory/api/factory/complaint',
     method: 'put',
     data: {
       id,

+ 14 - 6
src/views/complaint/complaintMixin.js

@@ -18,6 +18,8 @@ import {
   COMPLAINT_STATUS_OPTIONS,
   REPLY_STATUS_OPTIONS,
   REPLY_TYPE_OPTIONS,
+  COMPLAINT_STATUS,
+  REPLY_TYPE,
   getComplainantTypeLabel,
   getComplaintTypeLabel,
   getComplainantTypeType,
@@ -84,7 +86,7 @@ export default {
       statusDialogTitle: '',
       /** @type {StatusForm} */
       statusForm: {
-        status: 1,
+        status: COMPLAINT_STATUS.PROCESSING,
         closeReason: ''
       },
       statusLoading: false,
@@ -113,7 +115,7 @@ export default {
       addReplyVisible: false,
       replyForm: {
         complaintId: '',
-        replyType: 1,
+        replyType: REPLY_TYPE.SYSTEM,
         replyContent: '',
         replyAttachUrl: ''
       },
@@ -249,6 +251,12 @@ export default {
      */
     replyTypeOptions() {
       return REPLY_TYPE_OPTIONS
+    },
+    /**
+     * 投诉状态常量
+     */
+    COMPLAINT_STATUS() {
+      return COMPLAINT_STATUS
     }
   },
   methods: {
@@ -453,7 +461,7 @@ export default {
       this.statusDialogTitle = '处理投诉'
       this.statusForm = {
         id: row.id,
-        status: 1,
+        status: COMPLAINT_STATUS.PROCESSING,
         closeReason: ''
       }
       this.currentIds = null
@@ -468,7 +476,7 @@ export default {
       this.statusDialogTitle = '关闭投诉'
       this.statusForm = {
         id: row.id,
-        status: 3,
+        status: COMPLAINT_STATUS.CLOSED,
         closeReason: ''
       }
       this.currentIds = null
@@ -540,7 +548,7 @@ export default {
       this.replyForm = {
         complaintId: this.currentComplaintId,
         complaintNo: this.currentComplaintNo,
-        replyType: 1,
+        replyType: REPLY_TYPE.SYSTEM,
         replyContent: '',
         replyAttachUrl: ''
       }
@@ -617,7 +625,7 @@ export default {
       }
       this.statusDialogTitle = '批量处理投诉'
       this.statusForm = {
-        status: 1,
+        status: COMPLAINT_STATUS.PROCESSING,
         closeReason: ''
       }
       this.currentIds = this.selectionList.map(item => item.id)

+ 1 - 1
src/views/complaint/index.vue

@@ -378,7 +378,7 @@
             <el-option label="已关闭" :value="3"></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="关闭原因" prop="closeReason" v-if="statusForm.status === 3">
+        <el-form-item label="关闭原因" prop="closeReason" v-if="statusForm.status === COMPLAINT_STATUS.CLOSED">
           <el-input
             type="textarea"
             :rows="3"