<template>
  <div id="testIndex">
    <el-row>
      <el-col :span="24" class="main animate__animated animate__backInRight">
        <el-col :span="12" class="one">
          <cForm :span="24" :fields="formFields" :form="form" :rules="rules" @save="onSubmit"></cForm>
        </el-col>
      </el-col>
    </el-row>
  </div>
</template>
<script setup lang="ts">
import type { FormRules } from 'element-plus';
import type { Ref } from 'vue';
import { ref, reactive, onMounted } from 'vue';
import { ElMessage } from 'element-plus';
import { AdminStore } from '@common/src/stores/admins/admin'; // 角色
import type { IQueryResult } from '@/util/types.util';
const admin = AdminStore();
let form: Ref<any> = ref({});
// 表单
let formFields: Ref<any[]> = ref([
  { label: '账号', model: 'account' },
  { label: '密码', model: 'password' }
]);
const rules = reactive<FormRules>({});
onMounted(async () => {
  await search();
});
const search = async () => {};
// 提交
const onSubmit = async (data) => {
  let res: IQueryResult = await admin.login(data);
  if (res.errcode == 0) {
    ElMessage({ type: `success`, message: `登陆成功` });
    localStorage.setItem('token', `${res.data}`);
    console.log(res.data);
  }
};
</script>
<style scoped lang="scss"></style>
