【修复】修复issues中单页管理-新增单页报错(https://gitee.com/xiaonuobase/snowy/issues/I5TZ60)

pull/41/head
小诺 2022-10-01 15:18:49 +08:00 committed by 俞宝山
parent e9199c5485
commit 57a3bf84f3
4 changed files with 45 additions and 10 deletions

View File

@ -149,14 +149,12 @@
const param = parameterChanges(formData.value)
submitLoading.value = true
spaApi.submitForm(param, !param.id).then(() => {
submitLoading.value = false
visible = false
emit('successful')
}).finally(() => {
submitLoading.value = false
})
})
.catch(() => {
submitLoading.value = false
})
}
const parameterChanges = (data) => {
if (!data.component) {

View File

@ -41,7 +41,6 @@ public class SysSpaAddParam {
/** 别名 */
@ApiModelProperty(value = "别名", required = true, position = 3)
@NotBlank(message = "name不能为空")
private String name;
/** 路径 */
@ -51,12 +50,10 @@ public class SysSpaAddParam {
/** 组件 */
@ApiModelProperty(value = "组件", required = true, position = 5)
@NotBlank(message = "component不能为空")
private String component;
/** 图标 */
@ApiModelProperty(value = "图标", required = true, position = 6)
@NotBlank(message = "icon不能为空")
private String icon;
/** 排序码 */

View File

@ -46,7 +46,6 @@ public class SysSpaEditParam {
/** 别名 */
@ApiModelProperty(value = "别名", required = true, position = 4)
@NotBlank(message = "name不能为空")
private String name;
/** 路径 */
@ -56,12 +55,10 @@ public class SysSpaEditParam {
/** 组件 */
@ApiModelProperty(value = "组件", required = true, position = 6)
@NotBlank(message = "component不能为空")
private String component;
/** 图标 */
@ApiModelProperty(value = "图标", required = true, position = 7)
@NotBlank(message = "icon不能为空")
private String icon;
/** 排序码 */

View File

@ -28,6 +28,7 @@ import vip.xiaonuo.common.page.CommonPageRequest;
import vip.xiaonuo.sys.core.enums.SysBuildInEnum;
import vip.xiaonuo.sys.modular.resource.entity.SysSpa;
import vip.xiaonuo.sys.modular.resource.enums.SysResourceCategoryEnum;
import vip.xiaonuo.sys.modular.resource.enums.SysResourceMenuTypeEnum;
import vip.xiaonuo.sys.modular.resource.mapper.SysSpaMapper;
import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaAddParam;
import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaEditParam;
@ -66,6 +67,7 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> impleme
@Override
public void add(SysSpaAddParam sysSpaAddParam) {
checkParam(sysSpaAddParam);
SysSpa sysSpa = BeanUtil.toBean(sysSpaAddParam, SysSpa.class);
boolean repeatTitle = this.count(new LambdaQueryWrapper<SysSpa>().eq(SysSpa::getCategory,
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())) > 0;
@ -77,9 +79,30 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> impleme
this.save(sysSpa);
}
@SuppressWarnings("all")
private void checkParam(SysSpaAddParam sysSpaAddParam) {
SysResourceMenuTypeEnum.validate(sysSpaAddParam.getMenuType());
if(SysResourceMenuTypeEnum.MENU.getValue().equals(sysSpaAddParam.getMenuType())) {
if(ObjectUtil.isEmpty(sysSpaAddParam.getName())) {
throw new CommonException("name不能为空");
}
if(ObjectUtil.isEmpty(sysSpaAddParam.getComponent())) {
throw new CommonException("component不能为空");
}
} else if(SysResourceMenuTypeEnum.IFRAME.getValue().equals(sysSpaAddParam.getMenuType()) ||
SysResourceMenuTypeEnum.LINK.getValue().equals(sysSpaAddParam.getMenuType())) {
sysSpaAddParam.setName(RandomUtil.randomNumbers(10));
sysSpaAddParam.setComponent(null);
} else {
sysSpaAddParam.setName(null);
sysSpaAddParam.setComponent(null);
}
}
@Override
public void edit(SysSpaEditParam sysSpaEditParam) {
SysSpa sysSpa = this.queryEntity(sysSpaEditParam.getId());
checkParam(sysSpaEditParam);
BeanUtil.copyProperties(sysSpaEditParam, sysSpa);
boolean repeatTitle = this.count(new LambdaQueryWrapper<SysSpa>().eq(SysSpa::getCategory,
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())
@ -90,6 +113,26 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> impleme
this.updateById(sysSpa);
}
@SuppressWarnings("all")
private void checkParam(SysSpaEditParam sysSpaEditParam) {
SysResourceMenuTypeEnum.validate(sysSpaEditParam.getMenuType());
if(SysResourceMenuTypeEnum.MENU.getValue().equals(sysSpaEditParam.getMenuType())) {
if(ObjectUtil.isEmpty(sysSpaEditParam.getName())) {
throw new CommonException("name不能为空");
}
if(ObjectUtil.isEmpty(sysSpaEditParam.getComponent())) {
throw new CommonException("component不能为空");
}
} else if(SysResourceMenuTypeEnum.IFRAME.getValue().equals(sysSpaEditParam.getMenuType()) ||
SysResourceMenuTypeEnum.LINK.getValue().equals(sysSpaEditParam.getMenuType())) {
sysSpaEditParam.setName(RandomUtil.randomNumbers(10));
sysSpaEditParam.setComponent(null);
} else {
sysSpaEditParam.setName(null);
sysSpaEditParam.setComponent(null);
}
}
@Override
public void delete(List<SysSpaIdParam> sysSpaIdParamList) {
List<String> sysSpaIdList = CollStreamUtil.toList(sysSpaIdParamList, SysSpaIdParam::getId);