gtsoft-snail-job-admin/src/views/_builtin/login/modules/pwd-login.vue

57 lines
1.5 KiB
Vue
Raw Normal View History

2024-03-08 17:59:45 +08:00
<script setup lang="ts">
import { reactive } from 'vue';
import { $t } from '@/locales';
import { useAntdForm, useFormRules } from '@/hooks/common/form';
import { useAuthStore } from '@/store/modules/auth';
defineOptions({
name: 'PwdLogin'
});
const authStore = useAuthStore();
const { formRef, validate } = useAntdForm();
const { constantRules } = useFormRules();
interface FormModel {
userName: string;
password: string;
}
const model: FormModel = reactive({
userName: 'Soybean',
password: '123456'
});
const rules: Record<keyof FormModel, App.Global.FormRule[]> = {
userName: constantRules.userName,
password: constantRules.pwd
};
async function handleSubmit() {
await validate();
await authStore.login(model.userName, model.password);
}
</script>
<template>
<AForm ref="formRef" :model="model" :rules="rules">
<AFormItem name="userName">
<AInput v-model:value="model.userName" size="large" :placeholder="$t('page.login.common.userNamePlaceholder')" />
</AFormItem>
<AFormItem name="password">
<AInputPassword
v-model:value="model.password"
size="large"
:placeholder="$t('page.login.common.passwordPlaceholder')"
/>
</AFormItem>
<ASpace direction="vertical" size="large" class="w-full">
<AButton type="primary" block size="large" shape="round" :loading="authStore.loginLoading" @click="handleSubmit">
{{ $t('page.login.common.confirm') }}
</AButton>
</ASpace>
</AForm>
</template>
<style scoped></style>