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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<template>
  <div class="orderMgtInfo inner-bg-style">
    <el-form size="mini" ref="form" inline label-width="140px">
      <i :class="['el-icon-refresh', {'loading': featching}]" title="刷新" @click="refreshList"></i>
      <div v-if="form.orderType&&form.orderType !== 'T04'">
        <order-details-components :form="form" :newForm="newForm" :originalOrderAddressInfo="originalOrderAddressInfo">
        </order-details-components>
        <product-details-components :form="form"></product-details-components>
        <customer-details-components v-if="form.isMarketOrder !== '1'" :form="form">
        </customer-details-components>
      </div>
      <div v-if="form.orderType&&form.orderType === 'T04'">
        <create-order-details :form="form" :newForm="newForm"
                              :originalOrderAddressInfo="originalOrderAddressInfo"
                              @handleAdddressInfo="handleAdddressInfo">
        </create-order-details>
        <create-order-details-prod :form="form"></create-order-details-prod>
      </div>
      <order-flowing-component :form="form"></order-flowing-component>
      <store-delivery-component :form="form"
                                v-if="form.omsOrderDelivery && form.omsOrderDelivery.commonCarrier === '3'">
      </store-delivery-component>
      <div class="form-button">
        <span class="operationBtn" v-if="form.isMarketOrder !== '1'">
          <el-button size="mini" v-if="form.isCanRefund" type="warning"
                     @click="openReturnInfo(form)">生成退货单
          </el-button>
          <el-button :type="'primary'" size="mini"
                     v-if="form.isExitZeroOrder === '1' && (form.orderStatus === '04' || form.orderStatus === '05')"
                     @click="freeBuyProd(form)">0元购建单</el-button>
          <el-button :type="'warning'" size="mini" @click="manualPush(form)" v-if="
                    form.orderStatus === '03' &&
                    form.pushAnjiType !== '1' &&
                    form.operationStatus === '1'
                  ">手动推送</el-button>
          <el-button :type="'primary'" size="mini" v-if="form.isCreateOrder === '1'"
                     @click="createIntegralOrder(form)">手动建单</el-button>
        </span>
        <el-button size="mini" @click="goBack">返回</el-button>
      </div>
    </el-form>
    <return-info :show.sync="showReturnInfo" :orderRow='orderRow'></return-info>
  </div>
</template>
<script>
import orderDetailsComponents from '@/views/orderMgt/components/orderDetailsComponents.vue'
import productDetailsComponents from '@/views/orderMgt/components/productDetailsComponents.vue'
import customerDetailsComponents from '@/views/orderMgt/components/customerDetailsComponents.vue'
import orderFlowingComponent from '@/views/orderMgt/components/orderFlowingComponent.vue'
import storeDeliveryComponent from '@/views/orderMgt/components/storeDeliveryComponent.vue'
import orderMgtApi from '@/api/orderMgt'
import returnInfo from '@/views/orderMgt/components/returnInfo.vue'
import createOrderDetails from '@/views/orderMgt/components/createOrderDetails.vue'
import createOrderDetailsProd from '@/views/orderMgt/components/createOrderDetailsProd.vue'
import uploadFileApi from '@/api/uploadFile'
 
export default {
  props: ['orderId'],
  components: {
    orderDetailsComponents,
    productDetailsComponents,
    customerDetailsComponents,
    orderFlowingComponent,
    storeDeliveryComponent,
    returnInfo,
    createOrderDetails,
    createOrderDetailsProd
  },
  data() {
    return {
      form: {
        omsOrderDelivery: {}
      },
      orderDeliver: {
        expressNoS: [],
        companyName: null
      },
      showReturnInfo: false,
      orderRow: null,
      originalOrderAddressInfo: {},
      featching: false
    }
  },
  methods: {
    // 刷新
    refreshList() {
      this.featching = true
      setTimeout(() => {
        this.featching = false;
        this.getDetails();
      }, 500);
    },
    /**
     * 判断是否有菜单权限
     */
    isMenuAuthority(routerName, row, menuName) {
      const data = this.$store.state.userTree
      let flag = false
      data.forEach(item => {
        if (item.children.length) {
          for (const i of item.children) {
            if (i.code === routerName) {
              flag = true
              return
            }
          }
        }
      })
      if (flag) {
        this.$router.push({
          name: routerName,
          query: {
            orderId: row.orderId,
            promotionStatus: row.promotionStatus
          }
        })
      } else {
        this.$message({
          message: `当前暂无${menuName}权限`,
          type: 'warning'
        })
      }
    },
    // 0元购订单
    freeBuyProd(row) {
      this.isMenuAuthority('createOrder', row, '手动建单')
    },
    // 手动推送
    manualPush(row) {
      this.$confirm('是否手动推送?', '手动推送', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        try {
          const res = await orderMgtApi.compensationPush({
            orderId: row.orderId
          })
          if (res.code === '0') {
            this.$message({
              message: '推送成功',
              type: 'success'
            })
            this.form.pushAnjiType = '1'
          }
        } catch (error) {
          if (error.data.code && error.data.code === '500') {
            let msgError = null
            if (error.data.msg) {
              const _msg = error.data.msg
              msgError = _msg.replace('下单调用物流接口异常:', '')
            }
            this.tips(['推送到安吉失败!', `异常原因:${msgError}`], 'warning')
          }
        }
      })
    },
    // 安吉推送提示
    tips(confirmText, type) {
      const newDatas = []
      const h = this.$createElement
      for (const i in confirmText) {
        newDatas.push(h('p', null, confirmText[i]))
      }
      this.$confirm('提示', {
        title: '提示',
        message: h('div', null, newDatas),
        cancelButtonText: '取消',
        showConfirmButton: false,
        type: type
      })
    },
    // 跳转到积分手动建单
    createIntegralOrder(row) {
      this.isMenuAuthority('createIntegral', row, '创建积分订单')
    },
    // 打开退款订单
    openReturnInfo(row) {
      this.showReturnInfo = true
      this.orderRow = row
    },
    goBack() {
      // const name = this.$route.name === 'orderMgtInfo' ? 'orderMgtList' : 'distribution'
      // this.$router.push({ name })
      this.$router.go(-1)
    },
    /**
     * 获取文件信息
     */
    getFileInfo(businessId) {
      this.$set(this.form, 'fileArr', [])
      uploadFileApi.findFileInfoByBusinessId(businessId).then(res => {
        if (res.code === '200') {
          if (res.data) {
            res.data.forEach(item => {
              if (!item.isDelete) {
                this.form.fileArr.push(item)
              }
            })
          }
        }
      })
    },
    /**
       * 获取详情
       */
    getDetails() {
      return new Promise(resolve => {
        orderMgtApi.getOrderInfo({ orderId: this.$route.query.orderId }).then(res => {
          if (res.data) {
            if (res.data.omsOrderDelivery) {
              const omsOrderDelivery = res.data.omsOrderDelivery
              omsOrderDelivery.detail = omsOrderDelivery.fullAdd
              this.originalOrderAddressInfo = JSON.parse(JSON.stringify(res.data.omsOrderDelivery))
            }
            this.form = JSON.parse(JSON.stringify(res.data))
            if (this.form.omsOrderItems && this.form.omsOrderItems.length > 0) {
              this.form.omsOrderItems.forEach((item) => {
                this.getSpecificationCodeList(item)
                const specificationCodeArr = []
                const shipmentsCountArr = []
                const logisticProdsArr = item.logisticProdsJson && item.logisticProdsJson !== '' ? JSON.parse(item.logisticProdsJson) : []
                logisticProdsArr.forEach((v1) => {
                  specificationCodeArr.push(v1.skuId)
                  shipmentsCountArr.push({
                    shipmentsCount: v1.quantity,
                    skuId: v1.skuId
                  })
                })
                this.$set(item, 'specificationCode', specificationCodeArr)
                this.$set(item, 'shipmentsCountList', shipmentsCountArr)
              })
            }
            if (res.data.orderMerchantMemo) {
              this.originalOrderAddressInfo.orderMerchantMemo = res.data.orderMerchantMemo
            }
            if (this.form.orderType === 'T04' && this.form.annexBizId) {
              this.getFileInfo(this.form.annexBizId) // 手动建单附件信息
            }
            this.newForm = JSON.parse(JSON.stringify(this.form))
            resolve(res.data)
          }
        })
      })
    },
    /**
  * 根据商品主编码获取所有的规格编码集合
  */
    getSpecificationCodeList(row) {
      orderMgtApi.getSpecificationCodeData({ prodNum: row.spuNum }).then((res) => {
        let arr = []
        if (res.code === '200' && res.data.length) {
          arr = [...res.data]
        }
        this.$set(row, 'specificationCodeList', arr)
      }).catch(() => {
        this.$set(row, 'specificationCodeList', [])
      })
    },
    /**
     *获取订单物流信息
     */
    getExpressByOrderId(p) {
      if (!p.omsOrderDelivery.commonCarrier || p.omsOrderDelivery.commonCarrier === '3') {
        return
      }
      if (p.orderSource === 'YDJS' && p.omsOrderDelivery.waybillId === '1') {
        return
      }
      const expressByOrderBo = {}
      expressByOrderBo.orderno = this.$route.query.orderId
      expressByOrderBo.waybillno = p.omsOrderDelivery.waybillId
      orderMgtApi.getExpressByOrderId(expressByOrderBo).then(res => {
        if (res.data) {
          this.orderDeliver.expressNoS = res.data
          this.orderDeliver.companyName = p.omsOrderDelivery.modeOfDespatch
        }
      })
    },
    handleAdddressInfo(data) {
      this.originalOrderAddressInfo = data
    }
  },
  async created() {
    await this.getDetails()
    // await this.getExpressByOrderId(p)
  }
}
</script>
<style lang="scss">
.orderMgtInfo {
  padding: 10px;
  .el-form-item__content {
    color: #606266;
  }
  // 刷新旋转动画
  @keyframes rotation{
      from {transform: rotate(0deg);}
      to {transform: rotate(360deg);}
  }
 .el-icon-refresh {
    cursor: pointer;
    float: right;
    margin-top: 5px;
    &:hover {
      color: rgb(221, 46, 46);
      font-weight: bolder;
    }
    &.loading {
     animation: rotation 1s linear infinite;
    }
  }
}
.setButtonStyle {
  position: relative;
  .btnStyle {
    position: absolute;
    right: 50px;
  }
}
.orderTitle {
  font-size: 18px;
  // font-weight: bold;
  border-bottom: 1px solid #e5e5e5;
  padding-bottom: 10px;
  margin-bottom: 15px;
}
hr {
  border: none;
  height: 1px;
  background-color: #e5e5e5;
}
.orderMgtInfoStyle {
  .el-form-item__content {
    color: #606266;
  }
}
.form-button {
  text-align: center;
  padding: 15px 0;
  .operationBtn {
    margin-right: 10px;
  }
}
.order_details_style {
  .tipText {
    text-align: center;
    color: #d70012;
    font-size: 12px;
    margin-left: 20px;
    font-weight: normal;
  }
}
</style>