v3.8.0 新增通用方法简化模态/缓存使用

This commit is contained in:
YunaiV
2022-02-17 13:11:21 +08:00
parent 433056d5ea
commit 38ac5270d6
60 changed files with 366 additions and 452 deletions

View File

@ -291,13 +291,13 @@ export default {
if (valid) {
if (this.form.id !== undefined) {
updateDept(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDept(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -307,15 +307,11 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
this.$confirm('是否确认删除名称为"' + row.name + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除名称为"' + row.name + '"的数据项?').then(function() {
return delDept(row.id);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}

View File

@ -266,13 +266,13 @@ export default {
if (valid) {
if (this.form.id !== undefined) {
updateData(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addData(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -283,25 +283,17 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id;
this.$confirm('是否确认删除字典编码为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除字典编码为"' + ids + '"的数据项?').then(function() {
return delData(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有数据项?').then(() => {
this.exportLoading = true;
return exportData(queryParams);
}).then(response => {

View File

@ -214,13 +214,13 @@ export default {
if (valid) {
if (this.form.id !== undefined) {
updateType(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addType(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -231,15 +231,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除字典编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除字典编号为"' + ids + '"的数据项?').then(function() {
return delType(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
@ -250,11 +246,7 @@ export default {
params.pageSize = undefined;
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行导出
this.$confirm('是否确认导出所有字典类型数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有字典类型数据项?').then(() => {
this.exportLoading = true;
return exportType(params);
}).then(response => {

View File

@ -207,7 +207,7 @@ export default {
// 修改的提交
if (this.form.id != null) {
updateErrorCode(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
@ -215,7 +215,7 @@ export default {
}
// 添加的提交
createErrorCode(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -224,15 +224,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$confirm('是否确认删除错误码编号为"' + id + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除错误码编号为"' + id + '"的数据项?').then(function() {
return deleteErrorCode(id);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
@ -243,11 +239,7 @@ export default {
params.pageSize = undefined;
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行导出
this.$confirm('是否确认导出所有错误码数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有错误码数据项?').then(() => {
this.exportLoading = true;
return exportErrorCodeExcel(params);
}).then(response => {

View File

@ -122,11 +122,7 @@ export default {
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => {
this.exportLoading = true;
return exportLoginLog(queryParams);
}).then(response => {

View File

@ -298,10 +298,10 @@ export default {
if (path.indexOf('http://') === -1 || path.indexOf('https://') === -1) {
// 父权限为根节点path 必须以 / 开头
if (this.form.parentId === 0 && path.charAt(0) !== '/') {
this.msgSuccess('前端必须以 / 开头')
this.$modal.msgSuccess('前端必须以 / 开头')
return
} else if (this.form.parentId !== 0 && path.charAt(0) === '/') {
this.msgSuccess('前端不能以 / 开头')
this.$modal.msgSuccess('前端不能以 / 开头')
return
}
}
@ -310,13 +310,13 @@ export default {
// 提交
if (this.form.id !== undefined) {
updateMenu(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addMenu(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -326,15 +326,11 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
this.$confirm('是否确认删除名称为"' + row.name + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除名称为"' + row.name + '"的数据项?').then(function() {
return delMenu(row.id);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}

View File

@ -219,13 +219,13 @@ export default {
if (valid) {
if (this.form.id !== undefined) {
updateNotice(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addNotice(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -236,15 +236,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids
this.$confirm('是否确认删除公告编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除公告编号为"' + ids + '"的数据项?').then(function() {
return delNotice(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}

View File

@ -202,11 +202,7 @@ export default {
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
])
this.$confirm('是否确认导出所有操作日志数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有操作日志数据项?').then(() => {
this.exportLoading = true;
return exportOperateLog(queryParams);
}).then(response => {

View File

@ -205,13 +205,13 @@ export default {
if (valid) {
if (this.form.id !== undefined) {
updatePost(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addPost(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -222,25 +222,17 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id;
this.$confirm('是否确认删除岗位编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除岗位编号为"' + ids + '"的数据项?').then(function() {
return delPost(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有岗位数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有岗位数据项?').then(() => {
this.exportLoading = true;
return exportPost(queryParams);
}).then(response => {

View File

@ -277,14 +277,10 @@ export default {
handleStatusChange(row) {
// 此时row 已经变成目标状态了,所以可以直接提交请求和提示
let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用";
this.$confirm('确认要"' + text + '""' + row.name + '"角色吗?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('确认要"' + text + '""' + row.name + '"角色吗?').then(function() {
return changeRoleStatus(row.id, row.status);
}).then(() => {
this.msgSuccess(text + "成功");
this.$modal.msgSuccess(text + "成功");
}).catch(function() {
// 异常时,需要将 row.status 状态重置回之前的
row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
@ -442,13 +438,13 @@ export default {
if (valid) {
if (this.form.id !== undefined) {
updateRole(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addRole(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -465,7 +461,7 @@ export default {
dataScopeDeptIds: this.form.dataScope !== SystemDataScopeEnum.DEPT_CUSTOM ? [] :
this.$refs.dept.getCheckedKeys()
}).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.openDataScope = false;
this.getList();
});
@ -478,7 +474,7 @@ export default {
roleId: this.form.id,
menuIds: [...this.$refs.menu.getCheckedKeys(), ...this.$refs.menu.getHalfCheckedKeys()]
}).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.openMenu = false;
this.getList();
});
@ -487,25 +483,17 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除角色编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除角色编号为"' + ids + '"的数据项?').then(function() {
return delRole(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
this.$confirm('是否确认导出所有角色数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认导出所有角色数据项?').then(function() {
this.exportLoading = true;
return exportRole(queryParams);
}).then(response => {

View File

@ -83,15 +83,11 @@ export default {
},
/** 强退按钮操作 */
handleForceLogout(row) {
this.$confirm('是否确认强退名称为"' + row.username + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认强退名称为"' + row.username + '"的数据项?').then(function() {
return forceLogout(row.id);
}).then(() => {
this.getList();
this.msgSuccess("强退成功");
this.$modal.msgSuccess("强退成功");
}).catch(() => {});
}
}

View File

@ -216,7 +216,7 @@ export default {
// 修改的提交
if (this.form.id != null) {
updateSmsChannel(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
@ -224,7 +224,7 @@ export default {
}
// 添加的提交
createSmsChannel(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -233,15 +233,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$confirm('是否确认删除短信渠道编号为"' + id + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除短信渠道编号为"' + id + '"的数据项?').then(function() {
return deleteSmsChannel(id);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
}
}

View File

@ -278,11 +278,7 @@ export default {
this.addBeginAndEndTime(params, this.dateRangeSendTime, 'sendTime');
this.addBeginAndEndTime(params, this.dateRangeReceiveTime, 'receiveTime');
// 执行导出
this.$confirm('是否确认导出所有短信日志数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有短信日志数据项?').then(() => {
this.exportLoading = true;
return exportSmsLogExcel(params);
}).then(response => {

View File

@ -298,7 +298,7 @@ export default {
// 修改的提交
if (this.form.id != null) {
updateSmsTemplate(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
@ -306,7 +306,7 @@ export default {
}
// 添加的提交
createSmsTemplate(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -315,15 +315,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$confirm('是否确认删除短信模板编号为"' + id + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除短信模板编号为"' + id + '"的数据项?').then(function() {
return deleteSmsTemplate(id);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
@ -334,11 +330,7 @@ export default {
params.pageSize = undefined;
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行导出
this.$confirm('是否确认导出所有短信模板数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有短信模板数据项?', "警告").then(() => {
this.exportLoading = true;
return exportSmsTemplateExcel(params);
}).then(response => {
@ -390,7 +382,7 @@ export default {
}
// 添加的提交
sendSms(this.sendSmsForm).then(response => {
this.msgSuccess("提交发送成功!发送结果,见发送日志编号:" + response.data);
this.$modal.msgSuccess("提交发送成功!发送结果,见发送日志编号:" + response.data);
this.sendSmsOpen = false;
});
});

View File

@ -210,7 +210,7 @@ export default {
// 修改的提交
if (this.form.id != null) {
updateTenant(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
@ -218,7 +218,7 @@ export default {
}
// 添加的提交
createTenant(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -227,15 +227,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$confirm('是否确认删除租户编号为"' + id + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除租户编号为"' + id + '"的数据项?').then(function() {
return deleteTenant(id);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
@ -246,11 +242,7 @@ export default {
params.pageSize = undefined;
this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
// 执行导出
this.$confirm('是否确认导出所有租户数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有租户数据项?').then(() => {
this.exportLoading = true;
return exportTenantExcel(params);
}).then(response => {

View File

@ -429,14 +429,10 @@ export default {
// 用户状态修改
handleStatusChange(row) {
let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用";
this.$confirm('确认要"' + text + '""' + row.username + '"用户吗?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('确认要"' + text + '""' + row.username + '"用户吗?').then(function() {
return changeUserStatus(row.id, row.status);
}).then(() => {
this.msgSuccess(text + "成功");
this.$modal.msgSuccess(text + "成功");
}).catch(function() {
row.status = row.status === CommonStatusEnum.ENABLE ? CommonStatusEnum.DISABLE
: CommonStatusEnum.ENABLE;
@ -510,7 +506,7 @@ export default {
cancelButtonText: "取消"
}).then(({ value }) => {
resetUserPwd(row.id, value).then(response => {
this.msgSuccess("修改成功,新密码是:" + value);
this.$modal.msgSuccess("修改成功,新密码是:" + value);
});
}).catch(() => {});
},
@ -542,13 +538,13 @@ export default {
if (valid) {
if (this.form.id !== undefined) {
updateUser(this.form).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addUser(this.form).then(response => {
this.msgSuccess("新增成功");
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
@ -563,7 +559,7 @@ export default {
userId: this.form.id,
roleIds: this.form.roleIds,
}).then(response => {
this.msgSuccess("分配角色成功");
this.$modal.msgSuccess("分配角色成功");
this.openRole = false;
this.getList();
});
@ -572,15 +568,11 @@ export default {
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除用户编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
this.$modal.confirm('是否确认删除用户编号为"' + ids + '"的数据项?').then(function() {
return delUser(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
@ -589,11 +581,7 @@ export default {
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
]);
this.$confirm('是否确认导出所有用户数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(() => {
this.$modal.confirm('是否确认导出所有用户数据项?').then(() => {
this.exportLoading = true;
return exportUser(queryParams);
}).then(response => {
@ -619,7 +607,7 @@ export default {
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
if (response.code !== 0) {
this.msgError(response.msg)
this.$modal.msgError(response.msg)
return;
}
this.upload.open = false;

View File

@ -57,7 +57,7 @@ export default {
if (valid) {
updateUserPwd(this.user.oldPassword, this.user.newPassword).then(
response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
}
);
}

View File

@ -110,7 +110,7 @@ export default {
// 上传预处理
beforeUpload(file) {
if (file.type.indexOf("image/") == -1) {
this.msgError("文件格式错误,请上传图片类型,如JPGPNG后缀的文件。");
this.$modal.msgError("文件格式错误,请上传图片类型,如JPGPNG后缀的文件。");
} else {
const reader = new FileReader();
reader.readAsDataURL(file);
@ -128,7 +128,7 @@ export default {
this.open = false;
// this.options.img = process.env.VUE_APP_BASE_API + response.imgUrl;
store.commit('SET_AVATAR', resp.data);
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
this.visible = false;
});
});

View File

@ -62,7 +62,7 @@ export default {
this.$refs["form"].validate(valid => {
if (valid) {
updateUserProfile(this.user).then(response => {
this.msgSuccess("修改成功");
this.$modal.msgSuccess("修改成功");
});
}
});

View File

@ -68,7 +68,7 @@ export default {
return;
}
socialBind(type, code, state).then(resp => {
this.msgSuccess("绑定成功");
this.$modal.msgSuccess("绑定成功");
this.$router.replace('/user/profile');
// 调用父组件, 刷新
this.getUser();
@ -87,7 +87,7 @@ export default {
},
unbind(socialUser) {
socialUnbind(socialUser.type, socialUser.unionId).then(resp => {
this.msgSuccess("解绑成功");
this.$modal.msgSuccess("解绑成功");
socialUser.unionId = undefined;
});
},