This commit is contained in:
xiaozhiyong
2023-02-14 14:31:14 +08:00
parent e4b34f6d63
commit 81c21b48f6
2 changed files with 22 additions and 65 deletions

View File

@@ -62,38 +62,6 @@
<span> password: any</span>
</div>
</el-form>
<el-dialog
:visible.sync="companySelectDialog"
:close-on-click-modal="false"
:close-on-press-escape="false"
width="500px"
title="请选择登录企业"
>
<el-table :data="companyList">
<el-table-column property="companyName" label="公司名称" width="200" />
<el-table-column property="parentMark" label="公司性质">
<template slot-scope="{ row }">
<el-tag v-if="row.parentMark === 0" effect="dark" size="normal"
>主体公司</el-tag
>
<el-tag v-else effect="dark" type="info" size="normal"
>分公司</el-tag
>
</template>
</el-table-column>
<el-table-column property="name" label="操作">
<template slot-scope="scope">
<el-button
type="text"
size="small"
@click="loginAgain(scope.row.companyId)"
>登录</el-button
>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
@@ -113,8 +81,6 @@ export default {
loading: false,
passwordType: "",
companyList: [],
companySelectDialog: false,
loginForm: {
username: "",
password: "",
@@ -140,30 +106,27 @@ export default {
});
},
handleLogin() {
this.loading = true;
let { username, password, networkId } = this.loginForm;
serve
.login({
username,
password: md5(password),
networkId,
})
.then((res) => {
if (res && res.code === 42014) {
serve
.getRefineryByCustomerId(this.loginForm.username)
.then((res) => {
this.companyList = res.data;
this.companySelectDialog = true;
return;
});
}
localStorage.setItem("token", res.data.accessToken);
this.$router.replace("/");
})
.catch(() => {
this.loading = false;
});
this.$refs["loginForm"].validate((valid) => {
if (valid) {
this.loading = true;
let { username, password, networkId } = this.loginForm;
serve
.login({
username,
password: md5(password),
networkId,
})
.then((res) => {
if (res.data.accessToken) {
localStorage.setItem("token", res.data.accessToken);
this.$router.replace("/");
}
})
.catch(() => {
this.loading = false;
});
}
});
},
},
};