orderDetail.vue 7.71 KB
<!-- 订单详情 -->
<template>
  <div class="order-detail marketing p-t-20 edit-box">
    <div class="container m-b-20">
      <p class="edit-title">订单信息</p>
      <el-form label-width="100px" :inline="true">
        <el-row v-for="(item, index) in detailFormDataRow" :key="index">
          <el-form-item v-for="(subItem, subIndex) in item.rowList" :key="subIndex" :label="subItem.label">
            <span class="detail-txt ellipsis-1" :title="detailForm[subItem.name]">{{detailForm[subItem.name]}}</span>
          </el-form-item>
        </el-row>
      </el-form>
    </div>
    <div :class="['container', orderRefund ? 'm-b-20' : 'edit-container']">
      <p class="edit-title">发货信息</p>
      <el-form label-width="100px" :inline="true">
        <el-form-item label="物流信息">
          <span>{{detailForm.deliveryCompany}}&nbsp;&nbsp;&nbsp;{{detailForm.deliveryNumber}}</span>
        </el-form-item>
      </el-form>
      <div v-if="orderGoods.length" class="p-l-40">
        <table class="show-table">
          <tbody>
            <tr v-for="(item, index) in orderGoods" :key="index" style="height: 70px;">
              <td><img :src="item.goodsImage" class="img-60" /></td>
              <td>{{ item.goodsName }}</td>
              <td>{{ item.specificationData }}</td>
              <td>{{ item.activityPrice ? item.activityPrice : item.retailPrice }}元 * {{item.goodsNumber}}</td>
            </tr>
            <tr v-if="detailForm.subOrderCoupon" style="height: 40px;">
              <td style="text-align: left;" colspan="3">优惠券</td>
              <td>{{detailForm.subOrderCoupon.discountAmount}}元</td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <div class="container edit-container" v-if="orderRefund">
      <p class="edit-title">售后信息</p>
      <el-form label-width="100px" :inline="true">
        <el-row v-for="(item, index) in afterInfoDataRow" :key="index">
          <el-form-item v-for="(subItem, subIndex) in item.rowList" :key="subIndex" :label="subItem.label">
            <span class="detail-txt ellipsis-1" :title="orderRefund[subItem.name]">{{orderRefund[subItem.name] || '-'}}</span>
          </el-form-item>
        </el-row>
      </el-form>
      <div class="flex" style="padding: 0 30px;">
        <!-- <img v-for="(item, index) in orderRefund.imgUrls" :key="index" class="img-60" :src="item"/> -->
        <span v-for="(item, index) in orderRefund.imgUrls" :key="index">
          <el-image class="img-60 comment-img" :src="item" :preview-src-list="[item]"></el-image>
        </span>
      </div>
    </div>
    <div class="footer" :style="{ left: footerLeft + 'px', width: footerWidth + 'px' }">
      <el-button type="default" @click="handleCancel">返回</el-button>
    </div>
  </div>
</template>

<script>
import * as dayjs from 'dayjs'
import { orderManageStatusList, orderSourceList, deliveryTypeList } from '@/common/constant'
export default {
  name: 'orderDetail',
  data() {
    return {
      size: 'small',
      title: '查看订单',
      footerLeft: '0',
      footerWidth: '0',
      editChildRef: 'editChildRef',
      routeInfo: {
        orderCode: ''
      },
      detailForm: {},
      orderRefund: null,
      orderGoods: [],
      // 订单信息
      detailFormDataRow: [],
      detailFormData: [
        {
          label: '订单编号',
          name: 'orderCode'
        },
        {
          label: '订单时间',
          name: 'createdDateStr'
        },
        {
          label: '客户信息',
          name: 'customerName'
        },
        {
          label: '订单类型',
          name: 'orderSourceName'
        },
        {
          label: '门店信息',
          name: 'merchantName'
        },
        {
          label: '订单状态',
          name: 'orderStatusName'
        },
        {
          label: '支付总价',
          name: 'payPrice'
        },
        {
          label: '发货地址',
          name: 'shipAddress'
        }
      ],
      // 售后信息
      afterInfoDataRow: [],
      afterInfoData: [
        {
          label: '售后类型',
          name: 'refundTypeName'
        },
        {
          label: '申请金额',
          name: 'refundPrice'
        },
        {
          label: '申请时间',
          name: 'createdDateStr'
        },
        {
          label: '快递公司',
          name: 'deliveryCompany'
        },
        {
          label: '快递单号',
          name: 'deliveryNumber'
        },
        {
          label: '申请描述',
          name: 'remark'
        }
      ],
      // 基本数据
      baseData: {
        orderStatusList: orderManageStatusList,
        orderSourceList: orderSourceList,
        deliveryTypeList: deliveryTypeList,
        refundTypeList: [
          { confId: '1', confName: '退款退货' },
          { confId: '2', confName: '退款不退货' }
        ]
      }
    }
  },

  created() {
    this.formToRow('detailFormData')
    this.formToRow('afterInfoData')
  },

  mounted() {
    this.footerLeft = document.querySelector('.base-container-right').offsetLeft
    this.footerWidth = document.documentElement.clientWidth - this.footerLeft
    this.routeInfo = this.$route.query
    this.getInfo()
  },

  methods: {
    formToRow(formName, numOfRow = 3) {
      var rowNum = Math.ceil(this[formName].length / numOfRow)
      for(var i = 0; i < rowNum; i++) {
        for(var j = 0; j < numOfRow; j++) {
          if(j == 0) {
            this[formName + 'Row'][i] = {
              rowList: []
            }
          }
          if((i * numOfRow + j) < this[formName].length) {
            this[formName + 'Row'][i].rowList.push(this[formName][i * numOfRow + j])
          }
        }
      }
    },
    getInfo() {
      this.$apis.orderManage.getOrderDetailApi({ orderCode: this.routeInfo.orderCode }).then(res => {
        this.detailForm = res
        this.orderRefund = res.orderRefund || null
        this.detailForm.createdDateStr = dayjs(this.detailForm.createdDate).format('YYYY-MM-DD HH:mm:ss')
        if(this.orderRefund) {
          this.orderRefund.refundTypeName  = this.baseData.refundTypeList.map(item => item.confId).includes(res.orderRefund.refundType + '') ? this.baseData.refundTypeList.find(item => item.confId == res.orderRefund.refundType).confName : '-'
          this.orderRefund.createdDateStr = dayjs(this.orderRefund.createdDate).format('YYYY-MM-DD HH:mm:ss')
        }
        if(this.detailForm.subOrderCoupon) {
          this.detailForm.subOrderCoupon.discountAmount = (this.detailForm.subOrderCoupon.discountAmount / 100).toFixed(2)
        }
        this.orderGoods = res.orderGoods || []
        this.detailForm.payPrice = res.payPrice ? (res.payPrice + '元') : '-'
        this.detailForm.orderSourceName = this.baseData.orderSourceList.map(item => item.confId).includes(res.orderSource + '') ? this.baseData.orderSourceList.find(item => item.confId == res.orderSource).confName : '-'
        this.detailForm.orderStatusName = this.baseData.orderStatusList.map(item => item.confId).includes(res.orderStatus + '') ? this.baseData.orderStatusList.find(item => item.confId == res.orderStatus).confName : '-'
      })
    },
    handleCancel() {
      this.$router.push({
        path: '/orderManage/index'
      })
    }
  }
}
</script>
<style>
.marketing.order-detail .el-form--inline .el-form-item {
  margin: 0;
}
.marketing.order-detail .el-form--inline .el-form-item__content {
  height: 30px;
}
.marketing.order-detail .flex {
  justify-content: flex-start;
}
.detail-txt {
  display: inline-block;
  width: 220px;
}
.marketing.order-detail .show-table>tbody>tr>td {
  text-align: center;
  vertical-align: middle;
}
.marketing.order-detail .show-table td {
  padding-right: 20px;
}
.order-detail .comment-img {
  margin-top: 10px;
  margin-right: 20px;
}
</style>