mirror of https://gitee.com/xiaonuobase/snowy
【修复】修复issues中单页管理-新增单页报错(https://gitee.com/xiaonuobase/snowy/issues/I5TZ60)
parent
e9199c5485
commit
57a3bf84f3
|
@ -149,14 +149,12 @@
|
||||||
const param = parameterChanges(formData.value)
|
const param = parameterChanges(formData.value)
|
||||||
submitLoading.value = true
|
submitLoading.value = true
|
||||||
spaApi.submitForm(param, !param.id).then(() => {
|
spaApi.submitForm(param, !param.id).then(() => {
|
||||||
submitLoading.value = false
|
|
||||||
visible = false
|
visible = false
|
||||||
emit('successful')
|
emit('successful')
|
||||||
|
}).finally(() => {
|
||||||
|
submitLoading.value = false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(() => {
|
|
||||||
submitLoading.value = false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
const parameterChanges = (data) => {
|
const parameterChanges = (data) => {
|
||||||
if (!data.component) {
|
if (!data.component) {
|
||||||
|
|
|
@ -41,7 +41,6 @@ public class SysSpaAddParam {
|
||||||
|
|
||||||
/** 别名 */
|
/** 别名 */
|
||||||
@ApiModelProperty(value = "别名", required = true, position = 3)
|
@ApiModelProperty(value = "别名", required = true, position = 3)
|
||||||
@NotBlank(message = "name不能为空")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 路径 */
|
/** 路径 */
|
||||||
|
@ -51,12 +50,10 @@ public class SysSpaAddParam {
|
||||||
|
|
||||||
/** 组件 */
|
/** 组件 */
|
||||||
@ApiModelProperty(value = "组件", required = true, position = 5)
|
@ApiModelProperty(value = "组件", required = true, position = 5)
|
||||||
@NotBlank(message = "component不能为空")
|
|
||||||
private String component;
|
private String component;
|
||||||
|
|
||||||
/** 图标 */
|
/** 图标 */
|
||||||
@ApiModelProperty(value = "图标", required = true, position = 6)
|
@ApiModelProperty(value = "图标", required = true, position = 6)
|
||||||
@NotBlank(message = "icon不能为空")
|
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/** 排序码 */
|
/** 排序码 */
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class SysSpaEditParam {
|
||||||
|
|
||||||
/** 别名 */
|
/** 别名 */
|
||||||
@ApiModelProperty(value = "别名", required = true, position = 4)
|
@ApiModelProperty(value = "别名", required = true, position = 4)
|
||||||
@NotBlank(message = "name不能为空")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 路径 */
|
/** 路径 */
|
||||||
|
@ -56,12 +55,10 @@ public class SysSpaEditParam {
|
||||||
|
|
||||||
/** 组件 */
|
/** 组件 */
|
||||||
@ApiModelProperty(value = "组件", required = true, position = 6)
|
@ApiModelProperty(value = "组件", required = true, position = 6)
|
||||||
@NotBlank(message = "component不能为空")
|
|
||||||
private String component;
|
private String component;
|
||||||
|
|
||||||
/** 图标 */
|
/** 图标 */
|
||||||
@ApiModelProperty(value = "图标", required = true, position = 7)
|
@ApiModelProperty(value = "图标", required = true, position = 7)
|
||||||
@NotBlank(message = "icon不能为空")
|
|
||||||
private String icon;
|
private String icon;
|
||||||
|
|
||||||
/** 排序码 */
|
/** 排序码 */
|
||||||
|
|
|
@ -28,6 +28,7 @@ import vip.xiaonuo.common.page.CommonPageRequest;
|
||||||
import vip.xiaonuo.sys.core.enums.SysBuildInEnum;
|
import vip.xiaonuo.sys.core.enums.SysBuildInEnum;
|
||||||
import vip.xiaonuo.sys.modular.resource.entity.SysSpa;
|
import vip.xiaonuo.sys.modular.resource.entity.SysSpa;
|
||||||
import vip.xiaonuo.sys.modular.resource.enums.SysResourceCategoryEnum;
|
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.mapper.SysSpaMapper;
|
||||||
import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaAddParam;
|
import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaAddParam;
|
||||||
import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaEditParam;
|
import vip.xiaonuo.sys.modular.resource.param.spa.SysSpaEditParam;
|
||||||
|
@ -66,6 +67,7 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(SysSpaAddParam sysSpaAddParam) {
|
public void add(SysSpaAddParam sysSpaAddParam) {
|
||||||
|
checkParam(sysSpaAddParam);
|
||||||
SysSpa sysSpa = BeanUtil.toBean(sysSpaAddParam, SysSpa.class);
|
SysSpa sysSpa = BeanUtil.toBean(sysSpaAddParam, SysSpa.class);
|
||||||
boolean repeatTitle = this.count(new LambdaQueryWrapper<SysSpa>().eq(SysSpa::getCategory,
|
boolean repeatTitle = this.count(new LambdaQueryWrapper<SysSpa>().eq(SysSpa::getCategory,
|
||||||
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())) > 0;
|
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())) > 0;
|
||||||
|
@ -77,9 +79,30 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> impleme
|
||||||
this.save(sysSpa);
|
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
|
@Override
|
||||||
public void edit(SysSpaEditParam sysSpaEditParam) {
|
public void edit(SysSpaEditParam sysSpaEditParam) {
|
||||||
SysSpa sysSpa = this.queryEntity(sysSpaEditParam.getId());
|
SysSpa sysSpa = this.queryEntity(sysSpaEditParam.getId());
|
||||||
|
checkParam(sysSpaEditParam);
|
||||||
BeanUtil.copyProperties(sysSpaEditParam, sysSpa);
|
BeanUtil.copyProperties(sysSpaEditParam, sysSpa);
|
||||||
boolean repeatTitle = this.count(new LambdaQueryWrapper<SysSpa>().eq(SysSpa::getCategory,
|
boolean repeatTitle = this.count(new LambdaQueryWrapper<SysSpa>().eq(SysSpa::getCategory,
|
||||||
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())
|
SysResourceCategoryEnum.SPA.getValue()).eq(SysSpa::getTitle, sysSpa.getTitle())
|
||||||
|
@ -90,6 +113,26 @@ public class SysSpaServiceImpl extends ServiceImpl<SysSpaMapper, SysSpa> impleme
|
||||||
this.updateById(sysSpa);
|
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
|
@Override
|
||||||
public void delete(List<SysSpaIdParam> sysSpaIdParamList) {
|
public void delete(List<SysSpaIdParam> sysSpaIdParamList) {
|
||||||
List<String> sysSpaIdList = CollStreamUtil.toList(sysSpaIdParamList, SysSpaIdParam::getId);
|
List<String> sysSpaIdList = CollStreamUtil.toList(sysSpaIdParamList, SysSpaIdParam::getId);
|
||||||
|
|
Loading…
Reference in New Issue