<template>
  <a-drawer
    v-model:visible="vdata.visible"
    :title=" true ? '详情' : '' "
    :body-style="{ paddingBottom: '80px' }"
    width="30%"
    placement="right"
    @close="onClose"
  >
    <a-row justify="space-between" type="flex">
      <a-col :sm="24">
        <a-descriptions>
          <a-descriptions-item label="客户端类型">
            {{ vdata.detailData['clientType'] === 'MCH_APP'?'商户APP':vdata.detailData['clientType'] === 'AGENT_APP'?'代理商APP':'' }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="版本名称">
            {{ vdata.detailData['versionName'] }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="版本序列号">
            {{ vdata.detailData['versionSerialNumber'] }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="是否强制更新">
            {{ vdata.detailData['forceUpdate'] == '1'?'是':'否' }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="12">
        <a-descriptions>
          <a-descriptions-item label="文件大小">
            {{ vdata.detailData['fileSize'] }} M
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
      <a-col :sm="24">
        <a-descriptions>
          <a-descriptions-item label="下载地址">
            {{ vdata.detailData['downloadUrl'] }}
          </a-descriptions-item>
        </a-descriptions>
      </a-col>
    </a-row>
    <a-row type="flex">
      <a-col :sm="24">
        <a-form-item label="描述信息">
          <a-textarea
            v-model:value="vdata.detailData['versionDesc']"
            disabled="disabled"
            style="height: 60px"
          />
        </a-form-item>
      </a-col>
    </a-row>
  </a-drawer>
</template>

<script lang="ts" setup>
import { API_URL_CLIENT_VERSION_LIST, req } from '@/api/manage'
import {defineProps,reactive} from 'vue'

    const props = defineProps({
      callbackFunc: { type: Function,default:null }
    })

    const vdata = reactive({
      btnLoading: false,
      detailData: {}, // 数据对象
      recordId: null, // 更新对象ID
      visible: false, // 是否显示弹层/抽屉
    })

    function show (recordId) { // 弹层打开事件
      vdata.detailData = { } // 数据清空

      vdata.recordId = recordId
      req.getById(API_URL_CLIENT_VERSION_LIST, recordId).then(res => {
        vdata.detailData = res
      })
      vdata.visible = true
    }

    function onClose () {
      vdata.visible = false
    }

    defineExpose({
      show //抛出show函数给父组件
    })
</script>
