| | |
| | | </div> |
| | | <div class="login"> |
| | | |
| | | <a-form |
| | | <a-form-model |
| | | layout="horizontal" |
| | | :form="form" |
| | | @submit="handleSubmit" |
| | | :model="form" |
| | | ref="ruleForm" |
| | | :rules="rules" |
| | | class="login-form" |
| | | > |
| | | <a-tabs default-active-key="1" @change="callback"> |
| | | <a-tab-pane key="1" tab="用户名登录"> |
| | | <a-form-item> |
| | | <a-input |
| | | placeholder="请输入用户" |
| | | size="large" |
| | | > |
| | | <a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)" /> |
| | | </a-input> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <a-input-password |
| | | type="password" |
| | | placeholder="请输入密码" |
| | | size="large" |
| | | > |
| | | <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" /> |
| | | </a-input-password> |
| | | </a-form-item> |
| | | </a-tab-pane> |
| | | <a-tab-pane key="2" tab="验证码登录" force-render> |
| | | <a-form-item> |
| | | <a-input |
| | | placeholder="手机号" |
| | | size="large" |
| | | > |
| | | <a-icon slot="prefix" type="mobile" style="color:rgba(0,0,0,.25)" /> |
| | | </a-input> |
| | | </a-form-item> |
| | | <a-form-item> |
| | | <a-row :gutter="8"> |
| | | <a-col :span="17"> |
| | | <a-input placeholder="验证码"> |
| | | <a-icon slot="prefix" type="mobile" style="color:rgba(0,0,0,.25)" /> |
| | | </a-input> |
| | | </a-col> |
| | | <a-col :span="7"> |
| | | <a-button style="width: 100%">获取验证码</a-button> |
| | | </a-col> |
| | | </a-row> |
| | | </a-form-item> |
| | | </a-tab-pane> |
| | | </a-tabs> |
| | | <a-form-model-item ref="name" prop="name"> |
| | | <a-input |
| | | placeholder="请输入用户名" |
| | | size="large" |
| | | v-model="form.name" |
| | | autocomplete="new-password" |
| | | > |
| | | <a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)" /> |
| | | </a-input> |
| | | </a-form-model-item> |
| | | <a-form-model-item ref="pwd" prop="pwd"> |
| | | <a-input-password |
| | | type="password" |
| | | placeholder="请输入密码" |
| | | size="large" |
| | | v-model="form.pwd" |
| | | autocomplete="new-password" |
| | | > |
| | | <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" /> |
| | | </a-input-password> |
| | | </a-form-model-item> |
| | | <!-- <a-tabs default-active-key="1" @change="callback">--> |
| | | <!-- <a-tab-pane key="1" tab="用户名登录">--> |
| | | <!-- <a-form-item>--> |
| | | <!-- <a-input--> |
| | | <!-- placeholder="请输入用户"--> |
| | | <!-- size="large"--> |
| | | <!-- v-model="form.name"--> |
| | | <!-- >--> |
| | | <!-- <a-icon slot="prefix" type="user" style="color:rgba(0,0,0,.25)" />--> |
| | | <!-- </a-input>--> |
| | | <!-- </a-form-item>--> |
| | | <!-- <a-form-item>--> |
| | | <!-- <a-input-password--> |
| | | <!-- type="password"--> |
| | | <!-- placeholder="请输入密码"--> |
| | | <!-- size="large"--> |
| | | <!-- v-model="form.pwd"--> |
| | | <!-- >--> |
| | | <!-- <a-icon slot="prefix" type="lock" style="color:rgba(0,0,0,.25)" />--> |
| | | <!-- </a-input-password>--> |
| | | <!-- </a-form-item>--> |
| | | <!-- </a-tab-pane>--> |
| | | <!-- <a-tab-pane key="2" tab="验证码登录" force-render>--> |
| | | <!-- <a-form-item>--> |
| | | <!-- <a-input--> |
| | | <!-- placeholder="手机号"--> |
| | | <!-- size="large"--> |
| | | <!-- >--> |
| | | <!-- <a-icon slot="prefix" type="mobile" style="color:rgba(0,0,0,.25)" />--> |
| | | <!-- </a-input>--> |
| | | <!-- </a-form-item>--> |
| | | <!-- <a-form-item>--> |
| | | <!-- <a-row :gutter="8">--> |
| | | <!-- <a-col :span="17">--> |
| | | <!-- <a-input placeholder="验证码">--> |
| | | <!-- <a-icon slot="prefix" type="mobile" style="color:rgba(0,0,0,.25)" />--> |
| | | <!-- </a-input>--> |
| | | <!-- </a-col>--> |
| | | <!-- <a-col :span="7">--> |
| | | <!-- <a-button style="width: 100%">获取验证码</a-button>--> |
| | | <!-- </a-col>--> |
| | | <!-- </a-row>--> |
| | | <!-- </a-form-item>--> |
| | | <!-- </a-tab-pane>--> |
| | | <!-- </a-tabs>--> |
| | | <div style="margin-bottom: 20px"> |
| | | <a-checkbox :checked="true" style="color:#fff;">自动登录</a-checkbox> |
| | | <a style="float: right">忘记密码</a> |
| | | <a-checkbox :checked="saveAccount" style="color:#fff;" @change="isSave">记住密码</a-checkbox> |
| | | <!-- <a style="float: right">忘记密码</a>--> |
| | | </div> |
| | | <a-form-item style="text-align: center"> |
| | | <a-button |
| | |
| | | html-type="submit" |
| | | style="width: 100%" |
| | | size="large" |
| | | @click="handleSubmit" |
| | | :loading="isLoading" |
| | | v-preventReClick="1500" |
| | | > |
| | | 登录 |
| | | </a-button> |
| | | </a-form-item> |
| | | <center><p>技术支持:中国科学院</p></center> |
| | | </a-form> |
| | | <center><p>技术支持:技术保障部</p></center> |
| | | </a-form-model> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | |
| | | import { login, getMenuAdmin } from "@/api/login"; |
| | | import Cookies from 'js-cookie'; |
| | | import {Base64} from "js-base64"; |
| | | import {getAreaWithUserIfo} from "@/api/user"; |
| | | |
| | | |
| | | export default { |
| | | name: "login", |
| | | data() { |
| | | return { |
| | | isLoading: false, |
| | | saveAccount: false, |
| | | // hasErrors, |
| | | form: this.$form.createForm(this), |
| | | // form: this.$form.createForm(this), |
| | | form: { |
| | | name: '', |
| | | pwd: '' |
| | | }, |
| | | rules: { |
| | | name: [{ required: true, message: '请输入用户名', trigger: 'blur' }], |
| | | pwd: [{ required: true, message: '请输入用户密码', trigger: 'blur' }] |
| | | }, |
| | | menu: [] |
| | | }; |
| | | }, |
| | | mounted() { |
| | | this.$nextTick(() => { |
| | | this.form.validateFields(); |
| | | }); |
| | | created() { |
| | | // this.$nextTick(() => { |
| | | // this.form.validateFields(); |
| | | // }); |
| | | this.hasUserCodeOrPassword() |
| | | }, |
| | | methods: { |
| | | handleSubmit(e) { |
| | | e.preventDefault(); |
| | | this.form.validateFields((err, values) => { |
| | | if (!err) { |
| | | console.log("Received values of form: ", values); |
| | | this.$router.push({ name: "default" }); |
| | | hasUserCodeOrPassword(){ |
| | | if (localStorage.getItem('userName') && localStorage.getItem('userPassword')) { |
| | | this.form.name = localStorage.getItem('userName') |
| | | this.form.pwd = Base64.decode(localStorage.getItem('userPassword'))//解密 |
| | | this.saveAccount = true |
| | | } |
| | | }, |
| | | |
| | | isSave(e){ |
| | | const t = this |
| | | t.saveAccount = !t.saveAccount |
| | | }, |
| | | |
| | | handleSubmit() { |
| | | this.$refs.ruleForm.validate(async (valid) => { |
| | | if (valid) { |
| | | this.isLoading = true |
| | | const res = await login(this.form) |
| | | if (res.data.code === 100) { |
| | | Cookies.set('resTk', res.data.data.tk); |
| | | Cookies.set('resUid', res.data.data.uid); |
| | | Cookies.set('userInfo',JSON.stringify(res.data.data),{expires: 7}) |
| | | await this.getAreaUsers(res.data.data.districtId) |
| | | if (this.saveAccount) { |
| | | localStorage.setItem('userName', this.form.name) |
| | | localStorage.setItem('userPassword', Base64.encode(this.form.pwd)) |
| | | } else { |
| | | localStorage.removeItem('userName') |
| | | localStorage.removeItem('userPassword') |
| | | } |
| | | this.$router.push('/home') |
| | | } else { |
| | | this.$message.warning(res.data.msg); |
| | | } |
| | | this.isLoading = false |
| | | } else { |
| | | console.log('error submit!!'); |
| | | return false; |
| | | } |
| | | }); |
| | | }, |
| | | callback(key) { |
| | | console.log(key); |
| | | |
| | | async getAreaUsers(districtId) { |
| | | let t = this |
| | | let res = await getAreaWithUserIfo() |
| | | if (res.data.code == 100) { |
| | | if (res.data.data) { |
| | | t.userTitTree(res.data.data) |
| | | const areaUsers = t.findNodeById(res.data.data, districtId).children |
| | | localStorage.removeItem('areaUsers') |
| | | localStorage.setItem('areaUsers',JSON.stringify(areaUsers)) |
| | | } else { |
| | | console.log('暂无数据') |
| | | } |
| | | } else { |
| | | this.$message.warning(res.data.msg); |
| | | } |
| | | }, |
| | | |
| | | // 根据id查对象 |
| | | findNodeById(data, value) { |
| | | for (const node of data) { |
| | | if (node.id === value) { |
| | | return node; |
| | | } |
| | | if (node.children) { |
| | | const foundNode = this.findNodeById(node.children, value); |
| | | if (foundNode) { |
| | | return foundNode; |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | }, |
| | | |
| | | // 将树状数据name字段放入users的姓名电话 |
| | | userTitTree(treeData) { |
| | | for (const node of treeData) { |
| | | if (node.users) { |
| | | node.users = node.users.filter(i => i.roleId == 3) |
| | | node.users = node.users.map((i) => { |
| | | return { |
| | | ...i, |
| | | unittype: node.type, |
| | | districtId: node.id |
| | | } |
| | | }) |
| | | node.name = node.name + '(' + node.users.map(i => i.realName + ' ' + i.phone).join(',') + ')' |
| | | } |
| | | if (node.children) { |
| | | this.userTitTree(node.children) |
| | | } |
| | | } |
| | | return treeData |
| | | } |
| | | }, |
| | | }; |
| | | </script> |
| | |
| | | } |
| | | .hedaer { |
| | | margin: 0px auto; |
| | | padding-top:100px; |
| | | padding-top:200px; |
| | | width: 1000px; |
| | | text-align: center; |
| | | text-shadow:0 0 1px #000; |