LockModal.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <BasicModal
  3. :footer="null"
  4. :title="t('layout.header.lockScreen')"
  5. v-bind="$attrs"
  6. :class="prefixCls"
  7. @register="register"
  8. >
  9. <div :class="`${prefixCls}__entry`">
  10. <div :class="`${prefixCls}__header`">
  11. <img src="/@/assets/images/header.jpg" :class="`${prefixCls}__header-img`" />
  12. <p :class="`${prefixCls}__header-name`">{{ getRealName }}</p>
  13. </div>
  14. <BasicForm @register="registerForm" />
  15. <div :class="`${prefixCls}__footer`">
  16. <a-button type="primary" block class="mt-2" @click="handleLock">
  17. {{ t('layout.header.lockScreenBtn') }}
  18. </a-button>
  19. </div>
  20. </div>
  21. </BasicModal>
  22. </template>
  23. <script lang="ts">
  24. import { defineComponent, computed } from 'vue';
  25. import { useI18n } from '/@/hooks/web/useI18n';
  26. import { useDesign } from '/@/hooks/web/useDesign';
  27. import { BasicModal, useModalInner } from '/@/components/Modal/index';
  28. import { BasicForm, useForm } from '/@/components/Form/index';
  29. import { userStore } from '/@/store/modules/user';
  30. import { lockStore } from '/@/store/modules/lock';
  31. export default defineComponent({
  32. name: 'LockModal',
  33. components: { BasicModal, BasicForm },
  34. setup() {
  35. const { t } = useI18n();
  36. const { prefixCls } = useDesign('header-lock-modal');
  37. const getRealName = computed(() => {
  38. return userStore.getUserInfoState?.realName;
  39. });
  40. const [register, { closeModal }] = useModalInner();
  41. const [registerForm, { validateFields, resetFields }] = useForm({
  42. showActionButtonGroup: false,
  43. schemas: [
  44. {
  45. field: 'password',
  46. label: t('layout.header.lockScreenPassword'),
  47. component: 'InputPassword',
  48. required: true,
  49. },
  50. ],
  51. });
  52. async function handleLock() {
  53. const values = (await validateFields()) as any;
  54. const password: string | undefined = values.password;
  55. closeModal();
  56. lockStore.commitLockInfoState({
  57. isLock: true,
  58. pwd: password,
  59. });
  60. await resetFields();
  61. }
  62. return {
  63. t,
  64. prefixCls,
  65. getRealName,
  66. register,
  67. registerForm,
  68. handleLock,
  69. };
  70. },
  71. });
  72. </script>
  73. <style lang="less">
  74. @import (reference) '../../../../../design/index.less';
  75. @prefix-cls: ~'@{namespace}-header-lock-modal';
  76. .@{prefix-cls} {
  77. &__entry {
  78. position: relative;
  79. height: 240px;
  80. padding: 130px 30px 60px 30px;
  81. background: #fff;
  82. border-radius: 10px;
  83. }
  84. &__header {
  85. position: absolute;
  86. top: 0;
  87. left: calc(50% - 45px);
  88. width: auto;
  89. text-align: center;
  90. &-img {
  91. width: 70px;
  92. border-radius: 50%;
  93. }
  94. &-name {
  95. margin-top: 5px;
  96. }
  97. }
  98. &__footer {
  99. text-align: center;
  100. }
  101. }
  102. </style>