refactor: 优化页面刷新代码

This commit is contained in:
Captain.B 2021-06-05 21:28:50 +08:00 committed by 刘瑞斌
parent aa620032f1
commit ace55e4ed1
6 changed files with 28 additions and 10 deletions

View File

@ -77,6 +77,9 @@ export default {
MsMainContainer, MsMainContainer,
MsChangeHistory MsChangeHistory
}, },
inject: [
'reload'
],
data() { data() {
return { return {
result: {}, result: {},
@ -107,7 +110,7 @@ export default {
'$route'(to) { '$route'(to) {
// //
if (to.name === 'createPerTest') { if (to.name === 'createPerTest') {
window.location.reload(); this.reload();
return; return;
} }

View File

@ -120,6 +120,9 @@ export default {
scenarios: Array, scenarios: Array,
isReadOnly: Boolean, isReadOnly: Boolean,
}, },
inject: [
'reload'
],
data() { data() {
return { return {
loadFileVisible: false, loadFileVisible: false,
@ -321,7 +324,7 @@ export default {
this.getProjectFiles(); this.getProjectFiles();
// 线 // 线
if (this.tableData.filter(f => f.id === this.currentRow.id).length > 0) { if (this.tableData.filter(f => f.id === this.currentRow.id).length > 0) {
window.location.reload(); this.reload();
} }
this.currentRow = null; this.currentRow = null;
}); });

View File

@ -232,6 +232,9 @@ export default {
return getCurrentWorkspaceId(); return getCurrentWorkspaceId();
} }
}, },
inject: [
'reload'
],
methods: { methods: {
create() { create() {
this.dialogWsAddVisible = true; this.dialogWsAddVisible = true;
@ -249,7 +252,7 @@ export default {
this.dialogWsUpdateVisible = false; this.dialogWsUpdateVisible = false;
if (saveType == 'add') { if (saveType == 'add') {
Message.success(this.$t('commons.save_success')); Message.success(this.$t('commons.save_success'));
window.location.reload(); this.reload();
} else if (saveType == 'update') { } else if (saveType == 'update') {
Message.success(this.$t('commons.modify_success')); Message.success(this.$t('commons.modify_success'));
this.list(); this.list();

View File

@ -93,6 +93,9 @@ import {EMAIL_REGEX, PHONE_REGEX} from "@/common/js/regex";
export default { export default {
name: "MsPersonSetting", name: "MsPersonSetting",
components: {MsDialogFooter, MsTableOperatorButton}, components: {MsDialogFooter, MsTableOperatorButton},
inject: [
'reload'
],
data() { data() {
return { return {
result: {}, result: {},
@ -192,7 +195,7 @@ export default {
localStorage.setItem(TokenKey, JSON.stringify(response.data)); localStorage.setItem(TokenKey, JSON.stringify(response.data));
this.updateVisible = false; this.updateVisible = false;
this.initTableData(); this.initTableData();
window.location.reload(); this.reload();
}); });
} else { } else {
return false; return false;
@ -210,7 +213,7 @@ export default {
this.$success(this.$t('commons.modify_success')); this.$success(this.$t('commons.modify_success'));
this.editPasswordVisible = false; this.editPasswordVisible = false;
this.initTableData(); this.initTableData();
window.location.reload(); this.reload();
}); });
} else { } else {
return false; return false;

View File

@ -142,13 +142,16 @@ export default {
UserCascader, UserCascader,
ShowMoreBtn ShowMoreBtn
}, },
inject: [
'reload'
],
data() { data() {
const validateConfirmPwd = (rule, value, callback) => { const validateConfirmPwd = (rule, value, callback) => {
if(value === ''){ if (value === '') {
callback(new Error(this.$t('user.input_password'))); callback(new Error(this.$t('user.input_password')));
}else if((value !== this.ruleForm.newpassword)){ } else if ((value !== this.ruleForm.newpassword)) {
callback(new Error(this.$t('member.inconsistent_passwords'))); callback(new Error(this.$t('member.inconsistent_passwords')));
}else{ } else {
callback(); callback();
} }
}; };
@ -325,7 +328,7 @@ export default {
this.$success(this.$t('commons.modify_success')); this.$success(this.$t('commons.modify_success'));
this.editPasswordVisible = false; this.editPasswordVisible = false;
this.search(); this.search();
window.location.reload(); this.reload();
}); });
} else { } else {
return false; return false;

View File

@ -298,6 +298,9 @@ export default {
MsMainContainer, MsRolesTag, MsMainContainer, MsRolesTag,
MsContainer, MsTableOperator, MsCreateBox, MsTablePagination, MsTableHeader, MsDialogFooter MsContainer, MsTableOperator, MsCreateBox, MsTablePagination, MsTableHeader, MsDialogFooter
}, },
inject: [
'reload'
],
data() { data() {
return { return {
createVisible: false, createVisible: false,
@ -431,7 +434,7 @@ export default {
this.createVisible = false; this.createVisible = false;
Message.success(this.$t('commons.save_success')); Message.success(this.$t('commons.save_success'));
if (saveType === 'add') { if (saveType === 'add') {
window.location.reload(); this.reload();
} else { } else {
this.list(); this.list();
} }