<template>
  <ElDialog v-model="showDialog"
    destroy-on-close
    width="fit-content"
    @close="dialogCloseHandler">
    <ElDescriptions title="采购单" border>
       <ElDescriptionsItem label="Id" prop="id">
        {{ detailData.id }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="编号" prop="sn">
        {{ detailData.sn }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="状态，JinXingZhong-->进行中、YiDaoHuo-->已到货、YiRuKu-->已入库、YiQuXiao-->已取消" prop="purchaseOrderStatus">
        {{ detailData.purchaseOrderStatus }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="供货客户 Id" prop="customerId">
        {{ detailData.customerId }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="采购日期" prop="purchaseDate">
        {{ detailData.purchaseDate }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="到货日期" prop="arrivalDate">
        {{ detailData.arrivalDate }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="产品分类 Id" prop="goodsCategoryId">
        {{ detailData.goodsCategoryId }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="分类名称" prop="goodsCategoryName">
        {{ detailData.goodsCategoryName }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="产品 Id" prop="goodsId">
        {{ detailData.goodsId }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="产品名称" prop="goodsName">
        {{ detailData.goodsName }}
      </ElDescriptionsItem>
      <ElDescriptionsItem label="产品编码" prop="goodSn">
        {{ detailData.goodSn }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="数量" prop="quantity">
        {{ detailData.quantity }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="计量单位；字典代码：unit" prop="unit">
        {{ detailData.unit }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="总金额；单位：元" prop="totalMoney">
        {{ detailData.totalMoney }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="备注" prop="memo">
        {{ detailData.memo }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="创建人 Id； sys_user.id" prop="creatorId">
        {{ detailData.creatorId }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="修改人 Id； sys_user.id" prop="modifierId">
        {{ detailData.modifierId }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="创建时间" prop="createTime">
        {{ detailData.createTime }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="修改时间" prop="modifyTime">
        {{ detailData.modifyTime }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="是否删除； 0-->未删除、1-->已删除" prop="deleted">
        {{ detailData.deleted }}
      </ElDescriptionsItem>
    </ElDescriptions>
    <template #footer>
      <ElButton @click="showDialog = false" type="primary">关闭</ElButton>
    </template>
  </ElDialog>
</template>

<script lang="ts" setup>
import PurchaseOrderApi from '@/pages/wh/purchase-order/purchase-order-api.ts'
import Utils from '@/common/utils'

const showDialog = ref(false)

const detailData = Utils.resetAble(reactive<PurchaseOrderTypes.SearchPurchaseOrderResult>({}))

function dialogCloseHandler() {
  detailData.$reset()
}

defineExpose({
  open(data: PurchaseOrderTypes.SearchPurchaseOrderResult) {
    showDialog.value = true
    PurchaseOrderApi.detail(data.id!)
      .then(res => {
        detailData.$reset(res.data)
      })
  }
})
</script>

<style lang="stylus" scoped>

</style>
