<template>
  <div v-loading="loading">
    <el-form :model="formData" label-position="top">
      <el-row>
        <el-col :span="6">
          <el-form-item label="客户名称"
            >{{ formData.data.customerName }}
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="订单类型">
            {{ dictDataEcho(formData.data.type, salesType) }}
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="收件人">
        {{ formData.data.contacts }},{{ formData.data.phone }}
      </el-form-item>
      <el-form-item label="收件地址">
        {{ formData.data.countryName }},{{ formData.data.provinceName }},{{
          formData.data.cityName
        }},{{ formData.data.detailedAddress }}</el-form-item
      >
      <el-form-item label="订单明细">
        <el-table :data="formData.data.orderDetailsList">
          <el-table-column prop="productCode" label="产品编码" />
          <el-table-column prop="productName" label="产品名称" />
          <el-table-column prop="price" label="单价" />
          <el-table-column prop="quantity" label="数量" />
          <el-table-column prop="remark" label="备注" />
        </el-table>
      </el-form-item>
      <el-row>
        <el-col :span="6">
          <el-form-item label="订单金额">
            {{ moneyFormat(formData.data.amountMoney, 2) }}
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </div>
</template>

<script setup>
import { watch } from "vue";

const { proxy } = getCurrentInstance();
const props = defineProps({
  orderData: {
    type: Object,
    default: {},
  },
});
const loading = ref(false);
const formData = reactive({
  data: {},
});
const getDetails = () => {
  loading.value = true;
  proxy
    .post("/orderInfo/detail", {
      id: props.orderData.id,
    })
    .then((res) => {
      formData.data = res;
      loading.value = false;
    });
};

const salesType = ref([]);
const getDict = () => {
  proxy.getDict(["order_sales_type"]).then((res) => {
    salesType.value = res["order_sales_type"];
  });
};
getDict();
onMounted(() => {
  if (props.orderData && props.orderData.id) {
    getDetails();
  }
});
</script>

<style lang="scss" scoped>
</style>