<template>
  <div class="page_container">
    <bg-breadcrumb></bg-breadcrumb>
    <div class="page_content apaas_scroll">
      <div class="info_row">
        <div class="title">
          <div><span class="icon_box"></span> 基础信息</div>
          <div class="dashed_line"></div>
        </div>
        <div class="info_content">
          <div class="img_box">
            <img v-if="logo" :src="logo" style="height: 96px; width: 96px; border-radius: 99px" alt="" />
            <img
              v-else
              src="/src/assets/imgs/home_ic_user.png"
              style="height: 96px; width: 96px; border-radius: 99px"
              alt="" />
          </div>
          <div class="info_box">
            <bg-info :data="baseInfo"></bg-info>
          </div>
        </div>
      </div>
      <div>
        <div class="title">
          <div><span class="icon_box"></span> 联系人信息</div>
          <div class="dashed_line"></div>
        </div>
        <div class="info_content">
          <div class="img_box"></div>
          <div class="info_box">
            <bg-info :data="contactInfo"></bg-info>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { reactive, toRefs, ref, onBeforeMount } from "vue";
import { useRoute, useRouter } from "vue-router";
import axios from "@/request/http.js";
import { ElMessage } from "element-plus";
import bgBreadcrumb from "@/components/bg-breadcrumb.vue";
const route = useRoute();
const baseInfo = reactive([
  {
    name: "所属机构",
    value: "",
    nameWidth: 130,
  },
  {
    name: "业务系统编码",
    value: "",
    nameWidth: 130,
  },
  {
    name: "业务系统名称",
    value: "",
    nameWidth: 130,
  },
  {
    name: "账号",
    value: "",
    nameWidth: 130,
  },
  {
    name: "AppID",
    value: "",
    nameWidth: 130,
  },
  {
    name: "AppSecret",
    value: "",
    copy_icon: true,
    secret: true,
    nameWidth: 130,
  },
  {
    name: "创建人",
    value: "",
    nameWidth: 130,
  },
  {
    name: "创建时间",
    value: "",
    nameWidth: 130,
  },
  {
    name: "是否启用",
    value: "",
    state: "",
    nameWidth: 130,
  },
  {
    name: "开发厂商名称",
    value: "",
    nameWidth: 130,
  },
  {
    name: "访问地址",
    value: "",
    full: true,
    nameWidth: 130,
  },
  {
    name: "业务系统描述",
    value: "",
    full: true,
    nameWidth: 130,
  },
]);

const contactInfo = reactive([
  {
    name: "联系人姓名",
    value: "",
    nameWidth: 130,
  },
  {
    name: "联系人手机号",
    value: "",
    nameWidth: 130,
  },
  {
    name: "联系人邮箱",
    value: "",
    full: true,
    nameWidth: 130,
  },
  {
    name: "备注",
    value: "",
    full: true,
    nameWidth: 130,
  },
]);
const logo = ref("");

const getDetail = () => {
  axios.get(`/apaas/system/v5/user/detail/${route.query.id}`).then((res) => {
    if (res.data.code == 200) {
      const detail = res.data.data;
      baseInfo[0].value = detail.organization_name;
      baseInfo[1].value = detail.business_code;
      baseInfo[2].value = detail.business_name;
      baseInfo[3].value = detail.system_account;
      baseInfo[4].value = detail.app_id;
      baseInfo[5].value = detail.app_secret;
      baseInfo[6].value =
        detail.created_by + "(" + (detail.created_user_role ? detail.created_user_role.join("、") : "") + ")";
      baseInfo[7].value = detail.created_time;
      baseInfo[8].value = detail.state === 1 ? "是" : "否";
      baseInfo[8].state = detail.state === 1 ? "success" : "default";
      baseInfo[9].value = detail.develop_name;
      baseInfo[10].value = detail.access_address;
      baseInfo[11].value = detail.business_desc;

      contactInfo[0].value = detail.contact_name;
      contactInfo[1].value = detail.contact_phone;
      contactInfo[2].value = detail.contact_email;
      contactInfo[3].value = detail.remark;

      logo.value = detail.logo;
    } else {
      ElMessage.error(res.data.data);
    }
  });
};

onBeforeMount(() => {
  getDetail();
});
</script>

<style scoped>
.page_content {
  padding: 15px;
  overflow: auto;
}
.info_content {
  display: flex;
}
.info_row {
  margin-bottom: 40px;
}
.img_box {
  width: 120px;
}
.info_box {
  width: 60%;
}

.title {
  font-size: 18px;
  color: #1a1a1a;
  font-weight: bold;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
}
.dashed_line {
  flex: 1;
  height: 1px;
  margin: 0 10px;
  border-bottom: dashed 1px #dadee7;
}

.icon_box {
  display: inline-block;
  width: 4px;
  height: 14px;
  background-color: #3759be;
  border-radius: 2px;
  margin-right: 5px;
}
</style>
