<script setup lang="ts">
import Panel from "@/components/common/Panel.vue";
import {post} from "@/utils/request.ts";
import {onMounted, ref, defineModel} from "vue";
import {formatDate} from "@/utils/dateUtils.ts";
import {loadConfig} from "@/utils/config.ts";

const decryptedText = ref<any>({})
const ciphertext = ref<any>('')
const list = ref<any>([])
const init = async () => {
  ciphertext.value = await post("common/auth/get");
  decryptedText.value = await post("common/auth/check");
  list.value = await post("common/config/list")
  list.value.forEach((item: any) => {
    if (item.k == "logoUrl") {
      loadConfig().then((res: any) => {
        imageUrl.value = res.base_url + 'file/getImage/' + item.val
      })
    }
  })
}
onMounted(async () => {
  await init()
})
const userMessage = defineModel<any>()
const imageUrl = ref<any>()
</script>

<template>
  <Panel title="药房基本信息" class="info">
    <div class="info-content">
      <img class="image" :src="imageUrl? imageUrl:userMessage.logo" alt="app">
      <div class="app_info-content-text">
        <el-tooltip
            effect="dark"
            :content="userMessage.name"
            placement="bottom-start"
        >
          <div class="app_info-title">{{ userMessage.name }}</div>
        </el-tooltip>
        <div>软件版本：{{ userMessage.version }}</div>
        <div style="margin: 10px 0">授权到期：{{ formatDate(decryptedText.expiryDate) }}</div>
        <div>版本类型： {{ decryptedText.rule == 1 ? "禁用医保" : decryptedText.rule == 2 ? "全部开放" : "暂无" }}</div>
      </div>
    </div>
  </Panel>
</template>

<style scoped lang="scss">
.info {
  height: 208px;

  .info-content {
    display: flex;

    .image {
      width: 88px;
      height: 88px;
      margin: 0 24px;
    }

    .app_info-content-text {
      font-weight: 500;
      font-size: 16px;
      color: #333333;
      font-style: normal;

      .app_info-title {
        max-width: 220px;
        font-weight: bold;
        font-size: 20px;
        margin-bottom: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
}
</style>