|
@@ -2,7 +2,14 @@
|
|
|
<div class="clearfix" id="login_wrap">
|
|
|
<div class="login">
|
|
|
<h2 class="title">管理服务登录平台</h2>
|
|
|
- <my-form class="content" :formList="formList" :formValue="formValue">
|
|
|
+ <my-form
|
|
|
+ labelWidth="80px"
|
|
|
+ class="content"
|
|
|
+ :formList="formList"
|
|
|
+ :formValue="formValue"
|
|
|
+ :rules="rules"
|
|
|
+ ref="myForm"
|
|
|
+ >
|
|
|
<template slot="handle" slot-scope="scope">
|
|
|
<el-button type="primary" @click="login(scope.formData)"
|
|
|
>登录</el-button
|
|
@@ -14,33 +21,49 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { login } from "../../api";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
formList: [
|
|
|
- { type: "input", prop: "account", label: "姓名", width: "280px" },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ prop: "account",
|
|
|
+ label: "姓名",
|
|
|
+ width: "280px",
|
|
|
+ placeholder: "请输入账号",
|
|
|
+ },
|
|
|
{
|
|
|
type: "input",
|
|
|
prop: "password",
|
|
|
label: "密码",
|
|
|
width: "280px",
|
|
|
style: "password",
|
|
|
+ placeholder: "请输入密码",
|
|
|
},
|
|
|
],
|
|
|
formValue: {
|
|
|
account: "",
|
|
|
password: "",
|
|
|
},
|
|
|
+
|
|
|
+ rules: {
|
|
|
+ account: [{ required: true, message: "请填写账号", trigger: "change" }],
|
|
|
+ password: [
|
|
|
+ { required: true, message: "请填写密码", trigger: "change" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
- async login() {
|
|
|
- let result = await this.$api.basic.login(this.formValue);
|
|
|
- let { token, name } = result.data;
|
|
|
- this.$store.commit("LOGIN_IN", token);
|
|
|
- this.$store.commit("UERINFO", name);
|
|
|
- this.$router.replace("/");
|
|
|
+ login() {
|
|
|
+ this.$refs.myForm.$refs.formData.validate(async (valid) => {
|
|
|
+ if (!valid) return;
|
|
|
+ let result = await this.$api.basic.login(this.formValue);
|
|
|
+ let { token, name } = result.data;
|
|
|
+ this.$store.commit("LOGIN_IN", token);
|
|
|
+ this.$store.commit("UERINFO", name);
|
|
|
+ this.$router.replace("/");
|
|
|
+ });
|
|
|
},
|
|
|
},
|
|
|
mounted() {},
|