fix: 根据项目code个性化定制的bug

This commit is contained in:
caoqianming 2024-02-26 18:46:18 +08:00
parent 4918d99218
commit 8629e1bf61
6 changed files with 152 additions and 125 deletions

View File

@ -6,6 +6,7 @@ NODE_ENV = development
# VUE_APP_TITLE = '托克逊能源管理平台'
# VUE_APP_TITLE = '中建材光子科技有限公司'
VUE_APP_TITLE = '超低排放系统'
VUE_APP_PJ = 'pf'
# 接口地址
#VUE_APP_API_BASEURL = http://1.203.161.103:2800/api

View File

@ -406,9 +406,10 @@ export default {
},
config: {
base: {
url: `${config.API_URL}/system/base_config/`,
name: "账户信息",
req: async function(project){
return await http.get(`${config.API_URL}/system/base_config${project}`);
req: async function(data){
return await http.get(this.url, data);
}
},
getInfo: {

View File

@ -10,8 +10,7 @@ const routes = [
"meta": {
"title": "工作台",
"icon": "el-icon-home-filled",
"type": "menu",
"perms": ["photon"]
"type": "menu"
},
"children": [
//首页

View File

@ -128,19 +128,33 @@ export default {
var res1 = await that.$API.auth.info.get();
that.$TOOL.data.set("USER_INFO", res1);
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
let base_name_short = this.$TOOL.data.get('BASE_INFO').base.base_name_short;
console.log(this.$TOOL.data.get('BASE_INFO'))
if (base_name_short == '托克逊能管') {
let base_dashboard = this.$TOOL.data.get('BASE_INFO').base.base_dashboard;
if (base_dashboard == null || base_dashboard == undefined) {
base_dashboard = '/dashboard'
}
if (this.$TOOL.data.get('BASE_INFO').base.base_name_short.indexOf('曲阳') != -1) {
that.$API.am.area.list.req({ page_size: 999 }).then(res => {
if (res.err_msg) {
} else {
debugger;
let areaList = res.results;
that.$TOOL.data.set("qyjyAreaList", areaList);
if (res1.type === 'employee') {
this.$router.replace({
path: "/",
});
} else {
this.$router.replace({
path: "/rpm/rpj",
});
}
that.$message.success("Login Success 登录成功");
that.islogin = false;
}
})
} else {
this.$router.replace({
path: "/dashboard_enm",
});
} else if (base_name_short == '光子科技') {
this.$router.replace({
path: "/dashboard_photon",
});
} else if (base_name_short == '超低排放') {
this.$router.replace({
path: "/dashboard_enp",
path: base_dashboard,
});
}
// if(this.$TOOL.data.get('BASE_INFO').base.base_name_short==''){//
@ -175,6 +189,8 @@ export default {
} catch (err) {
that.islogin = false;
console.log(err);
} finally {
that.islogin = false;
}
// var res = await this.$API.auth.token.post(data)
// console.log(res, err)

View File

@ -1,18 +1,22 @@
<template>
<el-form ref="loginForm" :model="form" :rules="rules" label-width="0" size="large" @keyup.enter="login">
<el-form-item prop="phone" style="margin-bottom: 25px;">
<el-input v-model="form.phone" prefix-icon="el-icon-iphone" clearable :placeholder="$t('login.mobilePlaceholder')">
<el-input v-model="form.phone" prefix-icon="el-icon-iphone" clearable
:placeholder="$t('login.mobilePlaceholder')">
<template #prepend>+86</template>
</el-input>
</el-form-item>
<el-form-item prop="code" style="margin-bottom: 35px;">
<el-form-item prop="code" style="margin-bottom: 35px;">
<div class="login-msg-yzm">
<el-input v-model="form.code" prefix-icon="el-icon-unlock" clearable :placeholder="$t('login.smsPlaceholder')"></el-input>
<el-button @click="getYzm" :disabled="disabled">{{this.$t('login.smsGet')}}<span v-if="disabled"> ({{time}})</span></el-button>
<el-input v-model="form.code" prefix-icon="el-icon-unlock" clearable
:placeholder="$t('login.smsPlaceholder')"></el-input>
<el-button @click="getYzm" :disabled="disabled">{{ this.$t('login.smsGet') }}<span v-if="disabled">
({{ time }})</span></el-button>
</div>
</el-form-item>
<el-form-item>
<el-button type="primary" style="width: 100%;" :loading="islogin" round @click="login">{{ $t('login.signIn') }}</el-button>
<el-button type="primary" style="width: 100%;" :loading="islogin" round @click="login">{{ $t('login.signIn')
}}</el-button>
</el-form-item>
<!-- <div class="login-reg">
{{$t('login.noAccount')}} <router-link to="/user_register">{{$t('login.createAccount')}}</router-link>
@ -21,112 +25,116 @@
</template>
<script>
export default {
data() {
return {
form: {
phone: "",
code: "",
},
rules: {
phone: [
{required: true, message: this.$t('login.mobileError')},
{validator: (rule, value, callback) => {
export default {
data() {
return {
form: {
phone: "",
code: "",
},
rules: {
phone: [
{ required: true, message: this.$t('login.mobileError') },
{
validator: (rule, value, callback) => {
let reg = /^1[3456789]\d{9}$/;
if (reg.test(value)) {
callback();
}else{
callback(new Error('请输入正确的手机号'));
} else {
callback(new Error('请输入正确的手机号'));
}
}}
],
code: [
{ required: true, message: "请输入验证码" }
]
},
disabled: false,
time: 0,
islogin: false,
}
},
mounted() {
},
methods: {
async getYzm(){
let that = this;
var validate = await this.$refs.loginForm.validateField("phone").catch(()=>{})
if(!validate){ return false }
this.$API.auth.sms_code.req({phone:that.form.phone}).then(res=>{
this.$message.success(this.$t('login.smsSent'))
this.disabled = true;
this.time = 60
var t = setInterval(() => {
this.time -= 1
if(this.time < 1){
clearInterval(t)
this.disabled = false
this.time = 0
}
},1000)
}).catch(err=>{
this.disabled = false;
this.$message.warning(err)
})
},
async login(){
let that = this;
this.$refs.loginForm.validate(async (valid) => {
if (valid) {
this.$API.auth.login_sms_code.req(that.form).then(res=>{
that.$TOOL.cookie.set("TOKEN", res.access, {
expires: that.form.autologin ? 24 * 60 * 60 : 0,
});
that.$TOOL.data.set("TOKEN", res.access);
that.$TOOL.data.set("TOKEN_REFRESH", res.refresh);
that.$TOOL.cookie.set("TOKEN_REFRESH", res.refresh);
that.$TOOL.data.set("TOKEN_TIME", new Date().getTime());
that.$API.auth.info.get().then(res1=>{
that.$TOOL.data.set("USER_INFO", res1);
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
if(this.$TOOL.data.get('BASE_INFO').base.base_name_short=='托克逊能管'){//
this.$router.replace({
path: "/dashboard_enm",
});
}else{//
that.$API.am.area.list.req({page_size:999}).then(res => {
if (res.err_msg) {
} else {
debugger;
let areaList = res.results;
that.$TOOL.data.set("qyjyAreaList", areaList);
if(res1.type==='employee'){
this.$router.replace({
path: "/",
});
}else{
this.$router.replace({
path: "/rpm/rpj",
});
}
that.$message.success("Login Success 登录成功");
that.islogin = false;
}
})
}
})
}).catch(err=>{
this.disabled = false;
this.$message.warning(err)
})
}
})
}
],
code: [
{ required: true, message: "请输入验证码" }
]
},
disabled: false,
time: 0,
islogin: false,
}
},
mounted() {
},
methods: {
async getYzm() {
let that = this;
var validate = await this.$refs.loginForm.validateField("phone").catch(() => { })
if (!validate) { return false }
this.$API.auth.sms_code.req({ phone: that.form.phone }).then(res => {
this.$message.success(this.$t('login.smsSent'))
this.disabled = true;
this.time = 60
var t = setInterval(() => {
this.time -= 1
if (this.time < 1) {
clearInterval(t)
this.disabled = false
this.time = 0
}
}, 1000)
}).catch(err => {
this.disabled = false;
this.$message.warning(err)
})
},
async login() {
let that = this;
this.$refs.loginForm.validate(async (valid) => {
if (valid) {
this.$API.auth.login_sms_code.req(that.form).then(res => {
that.$TOOL.cookie.set("TOKEN", res.access, {
expires: that.form.autologin ? 24 * 60 * 60 : 0,
});
that.$TOOL.data.set("TOKEN", res.access);
that.$TOOL.data.set("TOKEN_REFRESH", res.refresh);
that.$TOOL.cookie.set("TOKEN_REFRESH", res.refresh);
that.$TOOL.data.set("TOKEN_TIME", new Date().getTime());
that.$API.auth.info.get().then(res1 => {
that.$TOOL.data.set("USER_INFO", res1);
that.$TOOL.data.set("PERMISSIONS", Object.keys(res1.perms));
let base_dashboard = this.$TOOL.data.get('BASE_INFO').base.base_dashboard;
if (base_dashboard == null || base_dashboard == undefined) {
base_dashboard = '/dashboard'
}
if (this.$TOOL.data.get('BASE_INFO').base.base_name_short.indexOf('曲阳') != -1) {
that.$API.am.area.list.req({ page_size: 999 }).then(res => {
if (res.err_msg) {
} else {
debugger;
let areaList = res.results;
that.$TOOL.data.set("qyjyAreaList", areaList);
if (res1.type === 'employee') {
this.$router.replace({
path: "/",
});
} else {
this.$router.replace({
path: "/rpm/rpj",
});
}
that.$message.success("Login Success 登录成功");
that.islogin = false;
}
})
} else {
this.$router.replace({
path: base_dashboard,
});
}
})
}).catch(err => {
this.disabled = false;
this.$message.warning(err)
})
}
})
}
}
}
</script>
<style>
</style>
<style></style>

View File

@ -158,13 +158,15 @@ export default {
methods: {
getDept() {
let that = this;
let project = '';
if (that.project_code == undefined) {
project = '/';
let req = {};
if (that.project_code == undefined || that.project_code == '#') {
if (process.env.NODE_ENV == 'development') {
req.project_code = process.env.VUE_APP_PJ;
}
} else {
project = '?project_code=' + that.project_code;
req.project_code = that.project_code;
}
that.$API.system.config.base.req(project).then((res) => {
that.$API.system.config.base.req(req).then((res) => {
that.baseConfig = res.base;
that.$store.commit("SET_baseName", res.base.base_name);
that.$store.commit("SET_baseLogo", res.base.base_logo);