fuliqi
2024-01-24 29c1e7eb5ac16e90d8991a86c1c071bc312ec8d9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<template>
  <div class="refund inner-bg-style">
    <refund-basic-info ref="refundForm" :form="form" :warehouseData="warehouseData"
                       :logisticSupplier="logisticSupplier" :warehouse="warehouse">
      <template slot="refundResult" slot-scope="scope">
        <el-form-item label="审核结果:">
          <el-radio-group v-model="auditState">
            <el-radio :label="true">通过</el-radio>
            <el-radio :label="false">驳回</el-radio>
          </el-radio-group>
          <!-- <el-switch v-model="auditState" active-color="#13ce66" inactive-color="#ff4949"  active-text="通过" inactive-text="驳回"></el-switch> -->
        </el-form-item>
        <div v-if="form.omsOrder && form.omsOrder.orderSource === 'DY'&& !auditState">
          <el-form-item label="上传凭证:" prop="evidence"
                        :rules="[{required:!auditState, message:'请上传凭证'}]">
            <custom-upload-img :limitNumber="1" @handle-success="handleSuccess"
                               @handle-remove="handleRemove" :fileList="fileList">
            </custom-upload-img>
          </el-form-item>
          <el-form-item label="审核意见:" prop="operationDesc"
                        :rules="[{required:!auditState, message:'请选择审核意见'}]">
            <el-select v-model="scope.data.operationDesc" placeholder="请选择审核意见">
              <el-option v-for="item in dyRefuseType" :key="item.id" :value="item.id"
                         :label="item.name"></el-option>
            </el-select>
          </el-form-item>
        </div>
        <el-form-item v-else label="审核意见:" prop="operationDesc"
                      :rules="[{required:!auditState, message:'请输入审核意见'},{max:1024, message:'审核意见最多只能输入 1024 个字'}]">
          <el-input type="textarea" v-model="scope.data.operationDesc"
                    :autosize="{minRows:4,maxRows:8}"></el-input>
        </el-form-item>
      </template>
    </refund-basic-info>
    <el-row class="buttonPosition" v-if="showBtn">
      <el-button type="primary" size="mini" @click="submit">保存</el-button>
      <el-button size="mini" @click="cancel">取消</el-button>
    </el-row>
  </div>
</template>
<script>
import orderMgtApi from '@/api/orderMgt'
import refundBasicInfo from '@/views/refundMgt/components/refundBasicInfo.vue'
import dyRefuseType from '@/utils/constant/dyRefuseType'
import uploadFileApi from '@/api/uploadFile'
 
export default {
  components: { refundBasicInfo },
  props: ['refundApi', 'name'],
  data () {
    return {
      form: {
        evidence: null
      },
      auditState: true,
      fileList: [],
      dyRefuseType,
      showBtn: false,
      logisticSupplier: null,
      warehouse: null,
      warehouseData: []
    }
  },
  created () {
    this.getDetails()
  },
  methods: {
    /**
     * 获取上传成功的图片
     */
    handleSuccess (data) {
      this.form.evidence = data.url
      this.fileList.push({
        url: data.url,
        id: data.id
      })
      this.$refs.refundForm.$refs.form.clearValidate('evidence')
    },
    /**
     * 移除图片
     */
    handleRemove (file) {
      uploadFileApi.removeFile({ key: file.id }).then(res => {
        this.fileList = this.fileList.filter(v => {
          return v.id !== file.id
        })
        this.form.evidence = null
      })
    },
    /**
       * 查询详情
       */
    getDetails () {
      this.refundApi.detailsInfo({ orderRefundId: this.$route.query.orderRefundId }).then(res => {
        if (res.data) {
          res.data.operationDesc = null
          res.data.evidence = null
          res.data.shopName = this.$route.query.shopName
          this.form = res.data
          this.showBtn = true
          // 获取物流服务商
          this.getLogisticsProvidersData()
        }
      })
    },
    /**
* 获取物流服务商
*/
    async getLogisticsProvidersData () {
      this.logisticSupplier = null
      this.warehouse = null
      const res = await orderMgtApi.getWarehouseTree({})
      if (res.code === '200' && res.data.length) {
        this.warehouseData = res.data
        const obj = this.warehouseData.find((v1) => v1.warehouseService === this.form.omsOrderDelivery.logisticSupplier)
        if (obj) {
          this.logisticSupplier = obj.warehouseServiceName
          const obj1 = obj.treeList && obj.treeList.length ? obj.treeList.find((v2) => v2.entityWarehouseNo === this.form.omsOrderDelivery.warehouse) : null
          if (obj1) {
            this.warehouse = obj1.warehouseName
          }
        }
      }
    },
    /**
       * 保存
       */
    submit () {
      this.$refs.refundForm.$refs.form.validate().then(res => {
        const params = {
          operationDesc: this.form.operationDesc,
          orderRefundId: this.$route.query.orderRefundId,
          evidence: this.form.evidence
        }
        if (this.form.omsOrderRefund.refundType !== '1' && this.auditState) {
          this.isRefundAndReturn(params)
        } else {
          if (this.auditState) {
            this.platformPass(params)
          } else {
            this.platformRefuse(params)
          }
        }
      }).catch(() => { })
    },
    // 当退款类型为退款退货且通过退款时提示
    isRefundAndReturn (params) {
      this.$confirm('确认后需用户寄回商品,确认通过审核?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.platformPass(params)
      }).catch(() => { })
    },
    /**
     * 通过退款
     */
    platformPass (params) {
      this.refundApi.platformPass(params).then(res => {
        if (res.code === '0') {
          this.$router.push({ name: this.name })
          this.$message({
            type: 'success',
            message: '操作成功'
          })
        }
      })
    },
    /**
     * 拒绝退款
     */
    platformRefuse (params) {
      this.refundApi.platformRefuse(params).then(res => {
        if (res.code === '0') {
          this.$router.push({ name: this.name })
          this.$message({
            type: 'success',
            message: '操作成功'
          })
        }
      })
    },
    /**
     * ‘取消
     */
    cancel () {
      this.$router.push({ name: this.name })
    }
  }
}
</script>
<style lang="scss">
.refund {
  padding: 10px;
  .buttonPosition {
    text-align: center;
    margin-top: 10px;
  }
}
</style>