<template>
  <sd-config-provider>
    <a-modal
      v-model="visible"
      :title="
        code === 2051 ? '您的帐号在另一设备登录，您被迫下线！请重新登录' : '会话已过期,请重新登录'
      "
      :footer="null"
      @cancel="handleCancel"
    >
      <sd-login-form v-if="visible" ref="form" :class="$style.form" @loginSuccess="loginSuccess" />
    </a-modal>
  </sd-config-provider>
</template>

<script>
import { sdSessionStorage } from '@/common/services/storage-service'
import sdLogin from './sd-login.vue'
import components from './_import-components/sd-login-modal-import'
export default {
  name: 'SdLoginModal',
  components,
  metaInfo: null, // 覆盖sdloging的meataInfo
  mixins: [sdLogin],
  data() {
    return {
      visible: true,
    }
  },
  mounted() {
    this.$nextTick().then(() => {
      this.$refs?.form?.setFieldValue('userName', sdSessionStorage.getItem('loginName'))
    })
  },
  methods: {},
}
</script>

<style module lang="scss">
@use '@/common/design' as *;
.form > form {
  > div:first-child {
    pointer-events: none;
    cursor: not-allowed;
    input {
      color: $disabled-color;
      cursor: not-allowed;
      background-color: $input-disabled-bg;
      opacity: 1;
    }
  }
  > div:last-child button {
    float: right;
    width: 90px;
  }
}
</style>
