<template>
  <el-form label-width="120px" class="view" v-loading="formLoading" :class="{ 'mobile-card': mobile }">
    <el-row>
      <el-col :span="12">
        <el-form-item label="订单号">
          <div class="el-input el-input--default is-disabled el-input--suffix ">{{ formData.orderNo }}</div>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="配送方式">
          <div class="el-input el-input--default is-disabled el-input--suffix ">{{ formData.order.deliveryType?
            getDictLabel(DICT_TYPE.TRADE_DELIVERY_TYPE, formData.order.deliveryType) : '' }}</div>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="订单类型">
          <div class="el-input el-input--default is-disabled el-input--suffix ">{{
            getDictLabel(DICT_TYPE.TRADE_ORDER_TYPE, formData.order.type) }}</div>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="收货人">
          <div class="el-input el-input--default is-disabled el-input--suffix ">{{ formData.order.receiverName }}</div>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="买家">
            <div class="el-input el-input--default is-disabled el-input--suffix ">{{ formData?.user?.nickname }}
            </div>
          </el-form-item>
        
      </el-col>
      <el-col :span="12">
        <el-form-item label="订单来源">
          <div class="el-input el-input--default is-disabled el-input--suffix ">{{
            getDictLabel(DICT_TYPE.TERMINAL, formData.order.terminal) }}</div>
        </el-form-item>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="联系电话">
          <div class="el-input el-input--default is-disabled el-input--suffix ">{{ formData.order.receiverMobile }}</div>
        </el-form-item>
      </el-col>
      
      <el-col :span="12">
        <el-form-item label="付款方式">
            <div class="el-input el-input--default is-disabled el-input--suffix ">{{
              getDictLabel(DICT_TYPE.PAY_CHANNEL_CODE, formData.order.payChannelCode) }}</div>
          </el-form-item>
        
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="支付单号">
          <div class="el-input el-input--default is-disabled el-input--suffix ">{{ formData.order.payOrderId }}
          </div>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="买家留言">
            <div class="el-input el-input--default is-disabled el-input--suffix "> {{ formData.order.userRemark }}</div>
          </el-form-item>
        
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="12">
        <el-form-item label="商家备注">
            <div class="el-input el-input--default is-disabled el-input--suffix ">{{ formData.order.remark }}</div>
          </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
<script lang="ts" setup>
import * as AfterSaleApi from '@/api/mall/trade/afterSale/index'
import { DICT_TYPE, getDictLabel, getDictObj } from '@/utils/dict'
import { useAppStore } from '@/store/modules/app'
const appStore = useAppStore()
const mobile = computed(() => appStore.getMobile)
defineOptions({ name: 'TradeAfterSaleDetail' })
const formData = ref({
  order: {},
  logs: []
})

const props = defineProps({
  obj: {
    default: {}
  }
})
/** 获得详情 */
const getDetail = async (id) => {
  if (id) {
    const res = await AfterSaleApi.getAfterSale(id)
    // 没有表单信息则关闭页面返回
    if (res == null) {
      message.notifyError('售后订单不存在')
      close()
    }
    formData.value = res
  }
}
onMounted(() => {
  getDetail(props.obj.id)
})
defineExpose({ getDetail }) // 提供 open 方法，用于打开弹窗
</script>

<style src="@/styles/PcComponents.css"  lang="scss" scoped></style>
