crowdDetail.vue 11.3 KB
<!-- 订单详情 -->
<template>
  <div class="order-detail marketing">
    <div class="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" class="row-item">
              <span class="detail-txt ellipsis-1" :title="detailForm[subItem.name]">{{ detailForm[subItem.name] ? detailForm[subItem.name] + (subItem.suffix || '') : '-' }}</span>
            </el-form-item>
          </el-row>
          <template v-if="detailForm.formDescribe">
            <el-form-item label="其他信息">{{ detailForm.formDescribe }}</el-form-item>
          </template>
        </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="form-img">
          <el-form label-width="100px" :inline="true">
            <el-form-item label="售后凭证">
              <div class="flex">
                <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>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
    <!-- <GLFooter>
      <el-button @click="handleCancel"
                 size="medium">取消</el-button>
    </GLFooter> -->
  </div>
</template>

<script>
import * as dayjs from 'dayjs'
import { orderManageStatusList, orderSourceList, deliveryTypeList } from '@/common/constant'
export default {
  name: 'orderDetail',
  data() {
    return {
      size: 'small',
      title: '查看订单',
      editChildRef: 'editChildRef',
      routeInfo: {
        orderCode: ''
      },
      detailForm: {},
      orderRefund: null,
      orderGoods: [],
      // 订单信息
      detailFormDataRow: [],
      detailFormData: [],
      // 售后信息
      afterInfoDataRow: [],
      afterInfoData: [
        {
          label: '售后类型',
          name: 'refundTypeName'
        },
        {
          label: '申请金额',
          name: 'refundPrice'
        },
        {
          label: '申请时间',
          name: 'createdDateStr'
        },
        {
          label: '申请描述',
          name: 'remark'
        },
        {
          label: '快递公司',
          name: 'deliveryCompany'
        },
        {
          label: '快递单号',
          name: 'deliveryNumber'
        }
        // {
        //   label: '售后凭证',
        //   name: ''
        // }
      ],
      // 基本数据
      baseData: {
        orderStatusList: orderManageStatusList,
        orderSourceList: orderSourceList,
        deliveryTypeList: deliveryTypeList,
        refundTypeList: [
          { confId: '1', confName: '退款退货' },
          { confId: '2', confName: '退款不退货' },
          { confId: '3', confName: '众筹订单退款' }
        ],
        shareStaffTypeList: [
          { confId: '1', confName: '个微' },
          { confId: '2', confName: '企微' }
        ]
      },
      hideStatus: false
    }
  },

  created() {},

  mounted() {
    this.getCrowdfundingOrderConfig()
  },

  methods: {
    async getCrowdfundingOrderConfig() {
      let detailFormData = [
        {
          label: '订单编号',
          name: 'orderCode'
        },
        {
          label: '商户订单号',
          name: 'outTradeNo'
        },
        {
          label: '订单时间',
          name: 'createdDateStr'
        },
        {
          label: '手机号码',
          name: 'customerPhone'
        },
        {
          label: '推荐人',
          name: 'shareStaffName'
        },
        {
          label: '推荐人ID',
          name: 'shareStaffId'
        },
        {
          label: '推荐人类型',
          name: 'shareStaffTypeName'
        },
        {
          label: '车架号',
          name: 'vin'
        },
        {
          label: '门店信息',
          name: 'merchantName'
        },
        {
          label: '客户名称',
          name: 'customerName'
        },
        {
          label: '分润比例',
          name: 'takeFee',
          suffix: '%'
        },
        {
          label: '订单类型',
          name: 'orderSourceName'
        },
        {
          label: '订单状态',
          name: 'orderStatusName'
        },
        {
          label: '支付定金',
          name: 'payPrice'
        },
        {
          label: '尾款',
          name: 'crowdFundingPrice'
        },
        {
          label: '发货地址',
          name: 'shipAddress'
        },
        {
          label: '微信名称',
          name: 'weChatName'
        },
        {
          label: '活动名称',
          name: 'activityName'
        },
        {
          label: '商品名称',
          name: 'goodsName'
        }
      ]
      this.detailFormData = detailFormData
      this.routeInfo = this.$route.query
      this.getInfo()
      this.formToRow('afterInfoData')
    },
    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.order.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')
          this.orderRefund.refundPrice = this.orderRefund.refundPrice + '元'
        }
        if (this.detailForm.shareStaffType) {
          this.detailForm.shareStaffTypeName = this.baseData.shareStaffTypeList.map(item => item.confId).includes(this.detailForm.shareStaffType + '') ? this.baseData.shareStaffTypeList.find(item => item.confId == this.detailForm.shareStaffType).confName : '-'
        }
        if (this.detailForm.subOrderCoupon) {
          this.detailForm.subOrderCoupon.discountAmount = (this.detailForm.subOrderCoupon.discountAmount / 100).toFixed(2)
        }
        this.orderGoods = res.orderGoods || []
        this.detailForm.crowdFundingPrice = (res.crowdFundingPrice - res.payPrice).toFixed(2) + '元'
        this.detailForm.payPrice = res.payPrice ? res.payPrice + '元' : '0元'
        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 : '-'
        if (!this.detailForm.takeFee) {
          var takeFeeIdx = this.detailFormData.findIndex(item => item.name == 'takeFee')
          this.detailFormData.splice(takeFeeIdx, 1)
        }
        // 其他信息
        if (!this.hideStatus) {
          var formDescribeObj = {
            label: '其他信息',
            name: 'formDescribe',
            contentName: 'formContent',
            attrList: ['First', 'Second']
          }
          this.detailForm[formDescribeObj.name] = ''
          this.detailForm[formDescribeObj.name] = this.detailForm.plateNo ? '车牌号:' + this.detailForm.plateNo + ' ' : ''
          this.detailForm[formDescribeObj.name] += this.detailForm.vehicleType ? '品牌车型:' + this.detailForm.vehicleType + ' ' : ''
          formDescribeObj.attrList.forEach(item => {
            let label = this.detailForm[formDescribeObj.name + item]
            let value = this.detailForm[formDescribeObj.contentName + item]
            if (label) {
              this.detailForm[formDescribeObj.name] += label + ':' + value + ' '
            }
          })
        }
        // 商品名称
        this.detailForm.goodsName = this.detailForm.orderGoods.length ? this.detailForm.orderGoods.map(item => item.goodsName).join(',') : '-'
        console.log(this.detailForm)
        this.formToRow('detailFormData')
      })
    }
    // handleCancel() {
    //   this.$router.push({
    //     path: '/orderManage/index'
    //   })
    // }
  }
}
</script>
<style scoped lang="scss">
.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 .form-img .el-form--inline .el-form-item__content {
  height: auto !important;
}
.marketing.order-detail .flex {
  justify-content: flex-start;
}
.marketing.order-detail .row-item {
  width: 33%;
}
.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>