<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="仓库 Id" prop="warehouseId">
        {{ detailData.warehouseId }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="产品 Id" prop="goodsId">
        {{ detailData.goodsId }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="存放位置" prop="location">
        {{ detailData.location }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="当前库存数量" prop="stockQuantity">
        {{ detailData.stockQuantity }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="锁定数量" prop="lockQuantity">
        {{ detailData.lockQuantity }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="总量" prop="totalQuantity">
        {{ detailData.totalQuantity }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="剩余量" prop="remainingQuantity">
        {{ detailData.remainingQuantity }}
      </ElDescriptionsItem>
       <ElDescriptionsItem label="计量单位；字典代码：unit" prop="unit">
        {{ detailData.unit }}
      </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 InventoryApi from '@/pages/wh/inventory/inventory-api.ts'
import Utils from '@/common/utils'

const showDialog = ref(false)

const detailData = Utils.resetAble(reactive<InventoryTypes.SearchInventoryResult>({}))

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

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

<style lang="stylus" scoped>

</style>
