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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<template>
  <div>
    <div class="orderTitle">商品信息</div>
    <div class="setButtonStyle">
      <el-form-item label="店铺:">{{form.merchantName}}</el-form-item>
      <!-- <el-button size="mini" @click="refund" type="warning">发起退款</el-button> -->
    </div>
    <div class="omsOrderShops">
      <el-table border :span-method="arraySpanMethod" :data="form.omsOrderItems">
        <el-table-column type="index" align="center" :key="Math.random()" label="序号" width="80px">
        </el-table-column>
        <el-table-column v-if="form.isMarketOrder !== '1'" :key="Math.random()" type="expand">
          <template slot-scope="props">
            <el-table :data="props.row.codeIds" border>
              <el-table-column label="瓶码编号" align="center">
                <template slot-scope="scope">
                  {{scope.row}}
                </template>
              </el-table-column>
              <el-table-column label="商品溯源" align="center">
                <template slot-scope="scope">
                  <el-button type="primary" @click="getProductSourceInfo(scope.row,scope.$index)"
                             size="mini">查看</el-button>
                </template>
              </el-table-column>
            </el-table>
          </template>
        </el-table-column>
        <el-table-column label="商品图片" :key="Math.random()" width="200px" align="center">
          <template slot-scope="scope">
            <product-img :imgUrl="scope.row.imgUrl"></product-img>
          </template>
        </el-table-column>
        <el-table-column label="商品主编码" :key="Math.random()" width="160px" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.spuNum ? scope.row.spuNum : '-'}}
          </template>
        </el-table-column>
        <el-table-column label="商品" :key="Math.random()" prop="spuName" width="180px"
                         show-overflow-tooltip>
          <template slot-scope="scope">
            <span class="giftStyle" v-if="scope.row.promotionType === '2'">赠</span>
            <span class="giftStyle" v-if="scope.row.refundStatus && scope.row.refundStatus!== '00'">
              退
            </span>
            <span class="giftStyle"
                  v-if="scope.row.omsOrderItemsDetails && scope.row.omsOrderItemsDetails.length">组</span>
            <el-popover v-if="scope.row.omsOrderItemsDetails && scope.row.omsOrderItemsDetails.length"
                        placement="top" width="840" trigger="click">
              <el-table :data="scope.row.omsOrderItemsDetails" border size="mini">
                <el-table-column width="150" property="spuNum" label="商品主编码" show-overflow-tooltip>
                </el-table-column>
                <el-table-column min-width="150" property="spuName" label="商品名称"
                                 show-overflow-tooltip></el-table-column>
                <el-table-column width="150" property="address" label="商品规格" show-overflow-tooltip>
                  <template slot-scope="scope">
                    {{scope.row.skuProps && JSON.parse(scope.row.skuProps).length ? JSON.parse(scope.row.skuProps).map(item=>item.propValueName).join('/') : '-'}}
                  </template>
                </el-table-column>
                <el-table-column min-width="100" property="listPrice" label="挂牌价"
                                 show-overflow-tooltip>
                  <template slot-scope="scope">
                    <span v-if="form.orderSource == 'WLY'">
                      {{scope.row.listPrice ?  '¥'+scope.row.listPrice.toFixed(2) : '¥0.00'}}
                    </span>
                    <span v-else>-</span>
                  </template>
                </el-table-column>
                <el-table-column min-width="100" property="reduceStorage" label="实际扣减数量"
                                 align="center" show-overflow-tooltip>
                  <template slot-scope="props">
                    {{ scope.row.buyQuantity }} * {{props.row.reduceStorage}}
                    ({{scope.row.spuUnit ? scope.row.spuUnit : '瓶'}})
                  </template>
                </el-table-column>
                <el-table-column label="实收金额(元)" width="150px">
                  <template slot-scope="scope">
                    {{scope.row.totelAmtAct ?  '¥'+scope.row.totelAmtAct.toFixed(2) : '¥0.00'}}
                  </template>
                </el-table-column>
              </el-table>
              <span slot="reference" class="link-style">{{scope.row.spuName}}</span>
            </el-popover>
            <span v-else>{{scope.row.spuName}}</span>
          </template>
        </el-table-column>
        <el-table-column label="商品规格" :key="Math.random()" show-overflow-tooltip>
          <template slot-scope="scope">
            {{scope.row.skuProps && JSON.parse(scope.row.skuProps).length ? JSON.parse(scope.row.skuProps).map(item=>item.propValueName).join('/') : '-'}}
          </template>
        </el-table-column>
        <el-table-column v-if="form.isMarketOrder !=='1'" :key="Math.random()" label="销售金额(元)"
                         width="160px">
          <template slot-scope="scope">
            <!-- <span  v-if="scope.row.promotionType !== '2'"> -->
            {{scope.row.totelAmt ?  '¥'+scope.row.totelAmt.toFixed(2) : '-'}}
            <!-- </span>
                       <span v-else>-</span> -->
          </template>
        </el-table-column>
        <el-table-column v-if="form.isMarketOrder !=='1'" :key="Math.random()" label="实收金额(元)"
                         width="160px">
          <template slot-scope="scope">
            <span v-if="scope.row.promotionType !== '2'">
              {{scope.row.totelAmtAct ? '¥'+scope.row.totelAmtAct.toFixed(2) : '-'}}
            </span>
            <span v-else>-</span>
          </template>
        </el-table-column>
        <el-table-column label="购买数量" :key="Math.random()" align="center">
          <template slot-scope="scope">
            <span
                  v-if="scope.row.omsOrderItemsDetails && scope.row.omsOrderItemsDetails.length">{{scope.row.buyQuantity}}</span>
            <span v-else>
              {{scope.row.buyQuantity}}
              <span v-if="!scope.row.rightExchange">
                * {{JSON.parse(scope.row.expInfo).skuReduceStorage}}
                ({{scope.row.spuUnit ? scope.row.spuUnit : '瓶'}})
              </span>
            </span>
          </template>
        </el-table-column>
        <el-table-column label="售后状态">
          <template slot-scope="scope">
            {{ getRefundStatus(scope.row.refundStatus) }}
          </template>
        </el-table-column>
        <el-table-column v-if="$route.query.promotionStatus&&$route.query.promotionStatus.indexOf('虚拟权益活动') !== -1"
                         label="兑换状态" :key="Math.random()">
          <template slot-scope="scope">
            {{scope.row.rightExchange ?
                      scope.row.rightExchange === '1' ? '已兑换':'未兑换'
                    :'-'}}
          </template>
        </el-table-column>
        <el-table-column align="center"
                         v-if="form.omsOrderDelivery && form.omsOrderDelivery.commonCarrier&&form.omsOrderDelivery.commonCarrier !== '3'"
                         label="物流跟踪">
          <template slot-scope="scope">
            <el-button type="text" v-if="!scope.row.rightExchange"
                       @click="logisticsDetails(scope.row)">查看物流</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog title="发起退款" :visible.sync="dialogVisible" v-if="dialogVisible"
               :close-on-cliick-modal="false" :modal-append-to-body="false" width="30%">
      <el-form size="mini" ref="form" :model="refundForm">
        <el-form-item label="退款金额" prop="refundMoney" :rules="{required:true,message:'退款金额不能为空'}">
          <el-input-number :min='1' @keydown.native="limiInputType" v-model="refundForm.refundMoney"
                           :max="form.orderPrice"></el-input-number>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
        <el-button size="mini" type="danger" :loading="loading" @click="sureRefund">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="商品溯源详情" class="sourceFormInfo" :visible.sync="productSourceVisible"
               :close-on-click-modal="false" :modal-append-to-body="false" width="600px">
      <product-source-info :form="sourceForm" :orderForm='form'></product-source-info>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="productSourceVisible = false">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog title="物流跟踪" class="ogisticsFormInfo" :visible.sync="logisticsVisible"
               :close-on-click-modal="false" :modal-append-to-body="false" width="750px">
      <logistics-tracking-component :formData="logisticsForm"></logistics-tracking-component>
      <span slot="footer" class="dialog-footer">
        <el-button size="mini" @click="logisticsVisible = false">关闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import orderMgtApi from '@/api/orderMgt'
import { limiInputType } from '@/utils/limiInputType'
import productSourceInfo from './productSourceInfo.vue'
import productImg from '@/views/product/components/productImg.vue'
import logisticsTrackingComponent from './logisticsTrackingComponent.vue'
 
export default {
  props: ['form'],
  components: { productSourceInfo, productImg, logisticsTrackingComponent },
  data () {
    return {
      dialogVisible: false,
      productSourceVisible: false,
      refundForm: {
        refundMoney: 1
      },
      loading: false,
      sourceForm: {},
      logisticsVisible: false,
      logisticsForm: null // 物流信息
    }
  },
  methods: {
    /**
     * 获取售后状态
     */
    getRefundStatus (status) {
      switch (status) {
        case '10':
          return '售后中'
        case '20':
          return '退款失败'
        case '30':
          return '退款成功'
        default:
          return '-'
      }
    },
    /**
     * 查看商品物流信息
     */
    async logisticsDetails (row) {
      let prodCode = null
      const params = {
        orderNo: this.form.orderId
      }
      if (row.omsOrderItemsDetails && row.omsOrderItemsDetails.length) {
        prodCode = row.omsOrderItemsDetails.map((item) => item.spuNum).join(',')
      } else {
        prodCode = row.spuNum
      }
      const res = await orderMgtApi.queryByExpressInfoList({ ...params, ...{ prodCode: prodCode } })
      if (res.code === '0') {
        this.logisticsVisible = true
        this.logisticsForm = res.data
      }
    },
    /**
     * 合并行(赠品的行)
     */
    arraySpanMethod ({ row, column, rowIndex, columnIndex }) {
      if (row.promotionType === '2' || (this.form.isMarketOrder !== '1' && !row.codeIds.length)) {
        if (columnIndex === 1) {
          return [0, 0]
        } else if (columnIndex === 2) {
          return [1, 2]
        }
      }
    },
    /**
     * 获取商品溯源详情
     */
    getProductSourceInfo (row, index) {
      orderMgtApi.getProductSourceInfo(row).then(res => {
        if (res.data) {
          this.productSourceVisible = true
          this.sourceForm = res.data
        }
      })
    },
    /**
     * 限制不能输入数字
     */
    limiInputType (e) {
      limiInputType(e)
    },
    /**
       * 确定退款
       */
    sureRefund () {
      this.$refs.form.validate().then(res => {
        this.loading = true
        orderMgtApi.refun().then(res => {
          if (res.data) {
            this.loading = false
            this.$message({
              message: '退款成功',
              type: 'success'
            })
          }
        }).catch(() => {
          this.loading = false
        })
      })
    },
    /**
       *
       */
    refund () {
      this.dialogVisible = true
    }
  }
}
</script>
<style lang="scss">
.omsOrderShops {
  padding-left: 100px;
  padding-right: 20px;
}
.el-table__body img {
  width: 50px;
}
.sourceFormInfo {
  .el-dialog__body {
    padding: 15px 20px;
    height: 500px;
    position: relative;
    overflow: hidden;
    .sourceForm {
      position: absolute;
      left: 0;
      top: 0;
      right: -17px;
      bottom: 0;
      overflow-y: scroll;
      padding: 5px 10px;
    }
  }
}
.ogisticsFormInfo {
  .el-dialog__body {
    max-height: 600px;
    overflow-y: auto;
    width: 90%;
    margin: 0 auto;
    &::-webkit-scrollbar {
      display: none;
    }
  }
}
.link-style {
  color: #409eff;
  cursor: pointer;
}
</style>