提交 cc0d3611 编写于 作者: RedPig97's avatar RedPig97

update: 更新

上级 551d4acd
......@@ -12,23 +12,23 @@
* @param {*} [srfParentDeName] 父实体名称
*/
public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) {
if (actionContext.viewType === 'APPLOGINVIEW') {
const length = Object.keys(actionContext.layoutData).length;
if (this.viewType === 'APPLOGINVIEW') {
const length = Object.keys(this.layoutData).length;
for (let i = length - 1; i >= 0; i--) {
const name = Object.keys(actionContext.layoutData)[i];
if (actionContext.layoutData.hasOwnProperty(name) && !Object.is(actionContext.layoutModelDetails[name].itemType, 'CONTAINER')) {
actionContext.handleValueChange({ name, value: null });
const name = Object.keys(this.layoutData)[i];
if (this.layoutData.hasOwnProperty(name) && !Object.is(this.layoutModelDetails[name].itemType, 'CONTAINER')) {
this.handleValueChange({ name, value: null });
}
}
actionContext.$nextTick(() => {
actionContext.$forceUpdate();
this.$nextTick(() => {
this.$forceUpdate();
})
} else {
const parentRef = actionContext.$parent;
const parentRef: any = this.$parent;
if (parentRef.closeView && (parentRef.closeView instanceof Function)) {
parentRef.closeView(args);
} else if (actionContext.closeView && (actionContext.closeView instanceof Function)) {
actionContext.closeView(args);
} else if (this.closeView && (this.closeView instanceof Function)) {
this.closeView(args);
}
}
}
......
......@@ -12,59 +12,61 @@
* @param {*} [srfParentDeName] 父实体名称
*/
public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) {
const layoutData = args.length > 0 ? args[0] : {};
const layoutModelDetails: any = actionContext.layoutModelDetails || {};
let userNameKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_USERID')) || '';
let passwordKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_PASSWORD')) || '';
let messageKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_LOGINMSG')) || '';
if (!userNameKey || !passwordKey) {
actionContext.$message({ message: '用户名或密码未配置!',type: 'warning'});
if (messageKey) {
actionContext.handleValueChange({ name: messageKey, value: '用户名或密码未配置!' });
}
}
const loginname: any = layoutData[userNameKey];
const password: any = layoutData[passwordKey];
if (!loginname || !password) {
actionContext.$message({ message: '请输入用户名与密码',type: 'warning'});
if (messageKey) {
actionContext.handleValueChange({ name: messageKey, value: '请输入用户名与密码' });
}
}
// 清除cookie
let leftTime = new Date();
leftTime.setTime(leftTime.getSeconds() - 1000);
document.cookie = "ibzuaa-token=;expires=" + leftTime.toUTCString();
const data = { loginname, password };
const post: Promise<any> = actionContext.$http.post('/v7/login', data, true);
post.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
if (data && data.token) {
localStorage.setItem('token', data.token);
Util.setCookie('ibzuaa-token',data.token,0);
}
if(data && data.user){
localStorage.setItem('user', JSON.stringify(data.user));
}
// 设置cookie,保存账号密码7天
Util.setCookie("loginname",loginname, 7);
// 跳转首页
const url: any = actionContext.$route.query.redirect ? actionContext.$route.query.redirect : '*';
actionContext.$router.push({path: url});
}
}).catch((error: any) => {
// 登录提示
const data = error.data;
if (data && data.message) {
if (this.viewType === 'APPLOGINVIEW') {
const layoutData = args.length > 0 ? args[0] : {};
const layoutModelDetails: any = this.layoutModelDetails || {};
let userNameKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_USERID')) || '';
let passwordKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_PASSWORD')) || '';
let messageKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_LOGINMSG')) || '';
if (!userNameKey || !passwordKey) {
if (messageKey) {
actionContext.handleValueChange({ name: messageKey, value: data.message });
this.handleValueChange({ name: messageKey, value: '用户名或密码未配置!' });
} else {
this.$message({ message: '用户名或密码未配置!',type: 'warning'});
}
} else {
}
const loginname: any = layoutData[userNameKey];
const password: any = layoutData[passwordKey];
if (!loginname || !password) {
if (messageKey) {
actionContext.handleValueChange({ name: messageKey, value: actionContext.$t('components.login.loginfailed') });
this.handleValueChange({ name: messageKey, value: '请输入用户名与密码' });
} else {
this.$message({ message: '请输入用户名与密码',type: 'warning'});
}
}
});
// 清除cookie
let leftTime = new Date();
leftTime.setTime(leftTime.getSeconds() - 1000);
document.cookie = "ibzuaa-token=;expires=" + leftTime.toUTCString();
const data = { loginname, password };
const post: Promise<any> = this.$http.post('/v7/login', data, true);
post.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
if (data && data.token) {
localStorage.setItem('token', data.token);
Util.setCookie('ibzuaa-token',data.token,0);
}
if(data && data.user){
localStorage.setItem('user', JSON.stringify(data.user));
}
// 设置cookie,保存账号密码7天
Util.setCookie("loginname",loginname, 7);
// 跳转首页
const url: any = this.$route.query.redirect ? this.$route.query.redirect : '*';
this.$router.push({path: url});
}
}).catch((error: any) => {
// 登录提示
const data = error.data;
if (data) {
if (messageKey) {
this.handleValueChange({ name: messageKey, value: data.message || this.$t('components.login.loginfailed') });
}
}
});
} else {
this.$router.push({ path: "/login", query: { redirect: window.location.hash.replace("#", '') } });
}
}
</#macro>
\ No newline at end of file
......@@ -12,13 +12,13 @@
* @param {*} [srfParentDeName] 父实体名称
*/
public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) {
actionContext.$Modal.confirm({
this.$Modal.confirm({
title: '提示',
content: '确认要退出登录?',
okText: '确认',
cancelText: '取消',
onOk: () => {
actionContext.$http
this.$http
.get("/v7/logout")
.then((response: any) => {
if (response && response.status === 200) {
......@@ -27,7 +27,7 @@
let leftTime = new Date();
leftTime.setTime(leftTime.getSeconds() - 1);
document.cookie = "ibzuaa-token=;expires=" + leftTime.toUTCString();
actionContext.$router.push({ name: "login" });
this.$router.push({ path: "/login", query: { redirect: window.location.hash.replace("#", '') } });
}
})
.catch((error: any) => {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册