<template>
  <div class="admin-login">
    <div class="title">管理员登录</div>
    <div class="tip">输入账号和密码</div>
    <qm-low-form
      :fields="fields"
      :params="params"
      :labelWidth="1"
    ></qm-low-form>
    <div class="text-center">
      <qm-button type="link" @click="emit('toIndex', 2)"
        >返回选择登录身份</qm-button
      >
    </div>
    <qm-button
      :icon="h(GlobalOutlined)"
      class="reset-btn"
      @click="emit('toIndex', 0)"
    >
      连接设置</qm-button
    >
  </div>
</template>
<script name="AdminLogin" lang="ts" setup>
import { reactive, ref, h } from "vue";
import { useRouter } from "vue-router";
import { GlobalOutlined } from "@ant-design/icons-vue";
const emit = defineEmits(["toIndex"]);
//todo 入参名非正式
const params = reactive({ a: "" });
const router = useRouter();
const fields = ref([
  {
    prop: "a",
    colSpan: 24,
    attrs: {
      placeholder: "输入你的账号",
      allowClear: true,
      size: "large",
    },
  },
  {
    prop: "b",
    type: "password",
    colSpan: 24,
    attrs: {
      placeholder: "输入你的密码",
      size: "large",
    },
  },
  {
    type: "button",
    colSpan: 24,
    text: "登录",
    attrs: {
      block: true,
      size: "large",
      onClick: () => {
        //todo模拟登录请求...
        if (params.a === "audit") {
          router.push({ name: "Audit" });
          window.electronApi.changeWinSize("big");
          return;
        }
        router.push({ name: "CurExam" });
        window.electronApi.changeWinSize("big");
      },
    },
  },
]);
</script>
<style lang="less" scoped>
.admin-login {
  padding: 88px 80px 0 80px;
  position: relative;
  :deep(.reset-btn) {
    position: absolute;
    top: 25px;
    right: 65px;
    z-index: 1;
  }
  .title {
    color: @text-color1;
    font-weight: bold;
    line-height: 32px;
    font-size: 24px;
  }
  .tip {
    color: @text-color3;
    line-height: 26px;
    font-size: 18px;
    margin-top: 4px;
    margin-bottom: 28px;
  }
}
</style>
