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

update: 更新

上级 551d4acd
...@@ -12,23 +12,23 @@ ...@@ -12,23 +12,23 @@
* @param {*} [srfParentDeName] 父实体名称 * @param {*} [srfParentDeName] 父实体名称
*/ */
public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) { public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) {
if (actionContext.viewType === 'APPLOGINVIEW') { if (this.viewType === 'APPLOGINVIEW') {
const length = Object.keys(actionContext.layoutData).length; const length = Object.keys(this.layoutData).length;
for (let i = length - 1; i >= 0; i--) { for (let i = length - 1; i >= 0; i--) {
const name = Object.keys(actionContext.layoutData)[i]; const name = Object.keys(this.layoutData)[i];
if (actionContext.layoutData.hasOwnProperty(name) && !Object.is(actionContext.layoutModelDetails[name].itemType, 'CONTAINER')) { if (this.layoutData.hasOwnProperty(name) && !Object.is(this.layoutModelDetails[name].itemType, 'CONTAINER')) {
actionContext.handleValueChange({ name, value: null }); this.handleValueChange({ name, value: null });
} }
} }
actionContext.$nextTick(() => { this.$nextTick(() => {
actionContext.$forceUpdate(); this.$forceUpdate();
}) })
} else { } else {
const parentRef = actionContext.$parent; const parentRef: any = this.$parent;
if (parentRef.closeView && (parentRef.closeView instanceof Function)) { if (parentRef.closeView && (parentRef.closeView instanceof Function)) {
parentRef.closeView(args); parentRef.closeView(args);
} else if (actionContext.closeView && (actionContext.closeView instanceof Function)) { } else if (this.closeView && (this.closeView instanceof Function)) {
actionContext.closeView(args); this.closeView(args);
} }
} }
} }
......
...@@ -12,59 +12,61 @@ ...@@ -12,59 +12,61 @@
* @param {*} [srfParentDeName] 父实体名称 * @param {*} [srfParentDeName] 父实体名称
*/ */
public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) { public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) {
const layoutData = args.length > 0 ? args[0] : {}; if (this.viewType === 'APPLOGINVIEW') {
const layoutModelDetails: any = actionContext.layoutModelDetails || {}; const layoutData = args.length > 0 ? args[0] : {};
let userNameKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_USERID')) || ''; const layoutModelDetails: any = this.layoutModelDetails || {};
let passwordKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_PASSWORD')) || ''; let userNameKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_USERID')) || '';
let messageKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_LOGINMSG')) || ''; let passwordKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_PASSWORD')) || '';
if (!userNameKey || !passwordKey) { let messageKey: string = Object.keys(layoutModelDetails).find((key: string) => Object.is(layoutModelDetails[key].predefinedType, 'AUTH_LOGINMSG')) || '';
actionContext.$message({ message: '用户名或密码未配置!',type: 'warning'}); if (!userNameKey || !passwordKey) {
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 (messageKey) { 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) { 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> </#macro>
\ No newline at end of file
...@@ -12,13 +12,13 @@ ...@@ -12,13 +12,13 @@
* @param {*} [srfParentDeName] 父实体名称 * @param {*} [srfParentDeName] 父实体名称
*/ */
public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) { public ${item.getFullCodeName()}(args: any[], contextJO?:any, params?: any, $event?: any, xData?: any, actionContext?:any, srfParentDeName?:string) {
actionContext.$Modal.confirm({ this.$Modal.confirm({
title: '提示', title: '提示',
content: '确认要退出登录?', content: '确认要退出登录?',
okText: '确认', okText: '确认',
cancelText: '取消', cancelText: '取消',
onOk: () => { onOk: () => {
actionContext.$http this.$http
.get("/v7/logout") .get("/v7/logout")
.then((response: any) => { .then((response: any) => {
if (response && response.status === 200) { if (response && response.status === 200) {
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
let leftTime = new Date(); let leftTime = new Date();
leftTime.setTime(leftTime.getSeconds() - 1); leftTime.setTime(leftTime.getSeconds() - 1);
document.cookie = "ibzuaa-token=;expires=" + leftTime.toUTCString(); 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) => { .catch((error: any) => {
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册