139 lines
3.3 KiB
Vue
139 lines
3.3 KiB
Vue
<template>
|
|
<v-dialog
|
|
v-model="menuAuthDialog"
|
|
persistent
|
|
width="400"
|
|
>
|
|
<template v-slot:activator="{ props }">
|
|
<v-btn
|
|
v-bind="props"
|
|
append-icon="mdi-login"
|
|
color="black_and_white"
|
|
>
|
|
<template v-slot:prepend>
|
|
<v-icon color="black_and_white"></v-icon>
|
|
</template>
|
|
Войти
|
|
<template v-slot:append>
|
|
<v-icon color="black_and_white"/>
|
|
</template>
|
|
</v-btn>
|
|
</template>
|
|
|
|
<v-card>
|
|
<v-card-title>
|
|
<span class="text-h5">Вход в портал</span>
|
|
</v-card-title>
|
|
<v-card-text>
|
|
<v-container>
|
|
<v-row>
|
|
<v-col cols="12" class="py-0">
|
|
<v-text-field
|
|
v-model="anon.username"
|
|
color="black_and_white"
|
|
label="Логин"
|
|
variant="underlined"
|
|
:error-messages="errorer('username')"
|
|
/>
|
|
</v-col>
|
|
<v-col cols="12" class="py-0">
|
|
<v-text-field
|
|
v-model="anon.password"
|
|
label="Пароль"
|
|
variant="underlined"
|
|
type="password"
|
|
:error-messages="errorer('password')"
|
|
/>
|
|
</v-col>
|
|
</v-row>
|
|
</v-container>
|
|
</v-card-text>
|
|
<v-card-actions>
|
|
<v-spacer/>
|
|
<v-btn
|
|
color="modal_btn"
|
|
variant="text"
|
|
@click="menuAuthDialog = false"
|
|
>
|
|
Отмена
|
|
</v-btn>
|
|
<v-btn
|
|
color="modal_btn"
|
|
variant="text"
|
|
@click="logging"
|
|
>
|
|
Войти
|
|
</v-btn>
|
|
</v-card-actions>
|
|
<v-progress-linear v-show="AppStore.loading" indeterminate></v-progress-linear>
|
|
</v-card>
|
|
</v-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
import {useAccountStore} from '@/store/AccountStore'
|
|
import {useAppStore} from '@/store/app'
|
|
import { useVuelidate } from '@vuelidate/core'
|
|
import { required, helpers } from '@vuelidate/validators'
|
|
import { ref, reactive, computed, onMounted } from 'vue'
|
|
|
|
const req= helpers.withMessage('Обязательное поле', required)
|
|
|
|
export default {
|
|
|
|
setup(){
|
|
|
|
const accountStore = useAccountStore()
|
|
const AppStore= useAppStore()
|
|
const menuAuthDialog = ref(false)
|
|
|
|
const anon=reactive({
|
|
username:"9966-00-125",
|
|
password:""
|
|
})
|
|
|
|
const rules = computed(()=> {
|
|
return {
|
|
username: { req, latin: helpers.withMessage(()=> 'Логин имееет вид "0000-00-000"', (value) => /(\d{4,4}[-]\d{2,2}[-]\d{3,3})+$/.test(value.toString()))}, // Matches state.firstName
|
|
password: { req } // Matches state.lastName
|
|
}
|
|
}
|
|
)
|
|
|
|
const v$ = useVuelidate(rules, anon)
|
|
|
|
const errorer = (field) => {
|
|
let errors = v$.value[field].$error?v$.value[field].$errors[0].$message:''
|
|
return errors
|
|
}
|
|
|
|
const logging=async()=>{
|
|
if (!v$.value.$error) {
|
|
await accountStore.logging(anon)
|
|
}
|
|
else {
|
|
console.log(true);
|
|
}
|
|
}
|
|
|
|
onMounted(() => {
|
|
v$.value.$validate()
|
|
})
|
|
|
|
return {
|
|
accountStore,
|
|
AppStore,
|
|
menuAuthDialog,
|
|
anon,
|
|
v$,
|
|
logging,
|
|
errorer,
|
|
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
|
|
</style> |