新增 稿件管理
This commit is contained in:
parent
5744f7be34
commit
778968620e
|
|
@ -7,6 +7,6 @@ public interface ErrorCodeConstants extends cn.hangtag.module.system.enums.Erro
|
|||
// ========== 产品资料 TODO 补充编号 ==========
|
||||
ErrorCode PRODUCT_INFO_NOT_EXISTS = new ErrorCode(3200, "产品资料 不存在");
|
||||
ErrorCode CUSTOMER_NOT_EXISTS = new ErrorCode(3300, "客户不存在");
|
||||
ErrorCode SHAPE_TEMPLATE_NOT_EXISTS = new ErrorCode(3200, "图形模板管理 不存在");
|
||||
|
||||
ErrorCode SHAPE_TEMPLATE_NOT_EXISTS = new ErrorCode(3400, "图形模板管理 不存在");
|
||||
ErrorCode DRAFT_DESIGN_DATA_NOT_EXISTS = new ErrorCode(3500, "稿件模板数据 不存在");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
package cn.hangtag.module.oms.controller.admin.draftdesigndata;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import javax.validation.*;
|
||||
import javax.servlet.http.*;
|
||||
import java.util.*;
|
||||
import java.io.IOException;
|
||||
|
||||
import cn.hangtag.framework.common.pojo.PageParam;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
import cn.hangtag.framework.common.pojo.CommonResult;
|
||||
import cn.hangtag.framework.common.util.object.BeanUtils;
|
||||
import static cn.hangtag.framework.common.pojo.CommonResult.success;
|
||||
|
||||
import cn.hangtag.framework.excel.core.util.ExcelUtils;
|
||||
|
||||
import cn.hangtag.framework.apilog.core.annotation.ApiAccessLog;
|
||||
import static cn.hangtag.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||
|
||||
import cn.hangtag.module.oms.controller.admin.draftdesigndata.vo.*;
|
||||
import cn.hangtag.module.oms.dal.dataobject.draftdesigndata.DraftDesignDataDO;
|
||||
import cn.hangtag.module.oms.service.draftdesigndata.DraftDesignDataService;
|
||||
|
||||
@Tag(name = "管理后台 - 稿件模板数据 ")
|
||||
@RestController
|
||||
@RequestMapping("/oms/draft-design-data")
|
||||
@Validated
|
||||
public class DraftDesignDataController {
|
||||
|
||||
@Resource
|
||||
private DraftDesignDataService draftDesignDataService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建稿件模板数据 ")
|
||||
@PreAuthorize("@ss.hasPermission('oms:draft-design-data:create')")
|
||||
public CommonResult<Long> createDraftDesignData(@Valid @RequestBody DraftDesignDataSaveReqVO createReqVO) {
|
||||
return success(draftDesignDataService.createDraftDesignData(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新稿件模板数据 ")
|
||||
@PreAuthorize("@ss.hasPermission('oms:draft-design-data:update')")
|
||||
public CommonResult<Boolean> updateDraftDesignData(@Valid @RequestBody DraftDesignDataSaveReqVO updateReqVO) {
|
||||
draftDesignDataService.updateDraftDesignData(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除稿件模板数据 ")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('oms:draft-design-data:delete')")
|
||||
public CommonResult<Boolean> deleteDraftDesignData(@RequestParam("id") Long id) {
|
||||
draftDesignDataService.deleteDraftDesignData(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得稿件模板数据 ")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('oms:draft-design-data:query')")
|
||||
public CommonResult<DraftDesignDataRespVO> getDraftDesignData(@RequestParam("id") Long id) {
|
||||
DraftDesignDataDO draftDesignData = draftDesignDataService.getDraftDesignData(id);
|
||||
return success(BeanUtils.toBean(draftDesignData, DraftDesignDataRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得稿件模板数据 分页")
|
||||
@PreAuthorize("@ss.hasPermission('oms:draft-design-data:query')")
|
||||
public CommonResult<PageResult<DraftDesignDataRespVO>> getDraftDesignDataPage(@Valid DraftDesignDataPageReqVO pageReqVO) {
|
||||
PageResult<DraftDesignDataDO> pageResult = draftDesignDataService.getDraftDesignDataPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, DraftDesignDataRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出稿件模板数据 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('oms:draft-design-data:export')")
|
||||
@ApiAccessLog(operateType = EXPORT)
|
||||
public void exportDraftDesignDataExcel(@Valid DraftDesignDataPageReqVO pageReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||
List<DraftDesignDataDO> list = draftDesignDataService.getDraftDesignDataPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "稿件模板数据 .xls", "数据", DraftDesignDataRespVO.class,
|
||||
BeanUtils.toBean(list, DraftDesignDataRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
package cn.hangtag.module.oms.controller.admin.draftdesigndata.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.hangtag.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hangtag.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 稿件模板数据 分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class DraftDesignDataPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "设计稿名称", example = "赵六")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "语言标识 字典-language_locale")
|
||||
private String locale;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "稿件详情 json数据")
|
||||
private String details;
|
||||
|
||||
@Schema(description = "动态属性")
|
||||
private String propDefault;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
package cn.hangtag.module.oms.controller.admin.draftdesigndata.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.excel.annotation.*;
|
||||
import cn.hangtag.framework.excel.core.annotations.DictFormat;
|
||||
import cn.hangtag.framework.excel.core.convert.DictConvert;
|
||||
|
||||
@Schema(description = "管理后台 - 稿件模板数据 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class DraftDesignDataRespVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1098")
|
||||
@ExcelProperty("id")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "设计稿名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@ExcelProperty("设计稿名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "作者")
|
||||
@ExcelProperty("作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "版本")
|
||||
@ExcelProperty("版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "语言标识 字典-language_locale")
|
||||
@ExcelProperty(value = "语言标识 字典-language_locale", converter = DictConvert.class)
|
||||
@DictFormat("language_locale") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中
|
||||
private String locale;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
@ExcelProperty("启用状态")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "稿件详情 json数据")
|
||||
@ExcelProperty("稿件详情 json数据")
|
||||
private String details;
|
||||
|
||||
@Schema(description = "动态属性")
|
||||
@ExcelProperty("动态属性")
|
||||
private String propDefault;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package cn.hangtag.module.oms.controller.admin.draftdesigndata.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 稿件模板数据 新增/修改 Request VO")
|
||||
@Data
|
||||
public class DraftDesignDataSaveReqVO {
|
||||
|
||||
@Schema(description = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "1098")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "编码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String code;
|
||||
|
||||
@Schema(description = "设计稿名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@NotEmpty(message = "设计稿名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "作者")
|
||||
private String author;
|
||||
|
||||
@Schema(description = "版本")
|
||||
private Integer version;
|
||||
|
||||
@Schema(description = "语言标识 字典-language_locale")
|
||||
private String locale;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "备注", example = "你猜")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "稿件详情 json数据")
|
||||
private String details;
|
||||
|
||||
@Schema(description = "动态属性")
|
||||
private String propDefault;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package cn.hangtag.module.oms.dal.dataobject.draftdesigndata;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import cn.hangtag.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
/**
|
||||
* 稿件模板数据 DO
|
||||
*
|
||||
* @author YuanFeng
|
||||
*/
|
||||
@TableName("oms_draft_design_data")
|
||||
@KeySequence("oms_draft_design_data_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DraftDesignDataDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 设计稿名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 作者
|
||||
*/
|
||||
private String author;
|
||||
/**
|
||||
* 版本
|
||||
*/
|
||||
private Integer version;
|
||||
/**
|
||||
* 语言标识 字典-language_locale
|
||||
*
|
||||
* 枚举 {@link TODO language_locale 对应的类}
|
||||
*/
|
||||
private String locale;
|
||||
/**
|
||||
* 启用状态
|
||||
*/
|
||||
private Boolean enabled;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
/**
|
||||
* 稿件详情 json数据
|
||||
*/
|
||||
private String details;
|
||||
/**
|
||||
* 动态属性
|
||||
*/
|
||||
private String propDefault;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package cn.hangtag.module.oms.dal.mysql.draftdesigndata;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
import cn.hangtag.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.hangtag.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.hangtag.module.oms.dal.dataobject.draftdesigndata.DraftDesignDataDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import cn.hangtag.module.oms.controller.admin.draftdesigndata.vo.*;
|
||||
|
||||
/**
|
||||
* 稿件模板数据 Mapper
|
||||
*
|
||||
* @author YuanFeng
|
||||
*/
|
||||
@Mapper
|
||||
public interface DraftDesignDataMapper extends BaseMapperX<DraftDesignDataDO> {
|
||||
|
||||
default PageResult<DraftDesignDataDO> selectPage(DraftDesignDataPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<DraftDesignDataDO>()
|
||||
.eqIfPresent(DraftDesignDataDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(DraftDesignDataDO::getName, reqVO.getName())
|
||||
.likeIfPresent(DraftDesignDataDO::getAuthor, reqVO.getAuthor())
|
||||
.eqIfPresent(DraftDesignDataDO::getVersion, reqVO.getVersion())
|
||||
.eqIfPresent(DraftDesignDataDO::getLocale, reqVO.getLocale())
|
||||
.eqIfPresent(DraftDesignDataDO::getEnabled, reqVO.getEnabled())
|
||||
.eqIfPresent(DraftDesignDataDO::getRemark, reqVO.getRemark())
|
||||
.eqIfPresent(DraftDesignDataDO::getDetails, reqVO.getDetails())
|
||||
.eqIfPresent(DraftDesignDataDO::getPropDefault, reqVO.getPropDefault())
|
||||
.betweenIfPresent(DraftDesignDataDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(DraftDesignDataDO::getId));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package cn.hangtag.module.oms.service.draftdesigndata;
|
||||
|
||||
import java.util.*;
|
||||
import javax.validation.*;
|
||||
import cn.hangtag.module.oms.controller.admin.draftdesigndata.vo.*;
|
||||
import cn.hangtag.module.oms.dal.dataobject.draftdesigndata.DraftDesignDataDO;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
import cn.hangtag.framework.common.pojo.PageParam;
|
||||
|
||||
/**
|
||||
* 稿件模板数据 Service 接口
|
||||
*
|
||||
* @author YuanFeng
|
||||
*/
|
||||
public interface DraftDesignDataService {
|
||||
|
||||
/**
|
||||
* 创建稿件模板数据
|
||||
*
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createDraftDesignData(@Valid DraftDesignDataSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新稿件模板数据
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateDraftDesignData(@Valid DraftDesignDataSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除稿件模板数据
|
||||
*
|
||||
* @param id 编号
|
||||
*/
|
||||
void deleteDraftDesignData(Long id);
|
||||
|
||||
/**
|
||||
* 获得稿件模板数据
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 稿件模板数据
|
||||
*/
|
||||
DraftDesignDataDO getDraftDesignData(Long id);
|
||||
|
||||
/**
|
||||
* 获得稿件模板数据 分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 稿件模板数据 分页
|
||||
*/
|
||||
PageResult<DraftDesignDataDO> getDraftDesignDataPage(DraftDesignDataPageReqVO pageReqVO);
|
||||
|
||||
String getNewCode();
|
||||
}
|
||||
|
|
@ -0,0 +1,140 @@
|
|||
package cn.hangtag.module.oms.service.draftdesigndata;
|
||||
|
||||
import cn.hangtag.framework.common.exception.ServiceException;
|
||||
import cn.hangtag.framework.common.exception.enums.GlobalErrorCodeConstants;
|
||||
import cn.hangtag.framework.common.util.FuncUtil;
|
||||
import cn.hangtag.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.hangtag.module.oms.dal.dataobject.brand.BrandDO;
|
||||
import cn.hangtag.module.oms.serialnumber.CodingRulesUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import cn.hangtag.module.oms.controller.admin.draftdesigndata.vo.*;
|
||||
import cn.hangtag.module.oms.dal.dataobject.draftdesigndata.DraftDesignDataDO;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
import cn.hangtag.framework.common.pojo.PageParam;
|
||||
import cn.hangtag.framework.common.util.object.BeanUtils;
|
||||
|
||||
import cn.hangtag.module.oms.dal.mysql.draftdesigndata.DraftDesignDataMapper;
|
||||
|
||||
import static cn.hangtag.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.hangtag.module.oms.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 稿件模板数据 Service 实现类
|
||||
*
|
||||
* @author YuanFeng
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class DraftDesignDataServiceImpl implements DraftDesignDataService {
|
||||
|
||||
@Resource
|
||||
private DraftDesignDataMapper draftDesignDataMapper;
|
||||
|
||||
@Override
|
||||
public Long createDraftDesignData(DraftDesignDataSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
DraftDesignDataDO draftDesignData = BeanUtils.toBean(createReqVO, DraftDesignDataDO.class);
|
||||
String code = draftDesignData.getCode();
|
||||
if(FuncUtil.isNotEmpty(code)){
|
||||
checkCode(draftDesignData.getId(),code);
|
||||
}else {
|
||||
draftDesignData.setCode(getNewCode());
|
||||
}
|
||||
draftDesignData.setVersion(1);
|
||||
draftDesignDataMapper.insert(draftDesignData);
|
||||
// 返回
|
||||
return draftDesignData.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDraftDesignData(DraftDesignDataSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
DraftDesignDataDO designDataDO = draftDesignDataMapper.selectById(updateReqVO.getId());
|
||||
if(designDataDO == null){
|
||||
throw exception(DRAFT_DESIGN_DATA_NOT_EXISTS);
|
||||
}
|
||||
Integer version = designDataDO.getVersion();
|
||||
// 更新
|
||||
DraftDesignDataDO updateObj = BeanUtils.toBean(updateReqVO, DraftDesignDataDO.class);
|
||||
String code = updateObj.getCode();
|
||||
if(FuncUtil.isNotEmpty(code)){
|
||||
checkCode(updateObj.getId(),code);
|
||||
}else {
|
||||
updateObj.setCode(getNewCode());
|
||||
}
|
||||
updateObj.setVersion(version+1);
|
||||
draftDesignDataMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDraftDesignData(Long id) {
|
||||
// 校验存在
|
||||
validateDraftDesignDataExists(id);
|
||||
// 删除
|
||||
draftDesignDataMapper.deleteById(id);
|
||||
}
|
||||
|
||||
private void validateDraftDesignDataExists(Long id) {
|
||||
if (draftDesignDataMapper.selectById(id) == null) {
|
||||
throw exception(DRAFT_DESIGN_DATA_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DraftDesignDataDO getDraftDesignData(Long id) {
|
||||
return draftDesignDataMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<DraftDesignDataDO> getDraftDesignDataPage(DraftDesignDataPageReqVO pageReqVO) {
|
||||
return draftDesignDataMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewCode() {
|
||||
String s = "";
|
||||
int count = 10;
|
||||
while (true){
|
||||
count --;
|
||||
try {
|
||||
s = CodingRulesUtils.generateCode(3L, false);
|
||||
checkCode(null,s);
|
||||
return s;
|
||||
}catch (ServiceException e){
|
||||
log.warn("重复或者下一个编码");
|
||||
if(count < 0){
|
||||
log.error("编码获取失败");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void checkCode(Long id,String code){
|
||||
if(FuncUtil.isNotEmpty(code)){
|
||||
LambdaQueryWrapper<DraftDesignDataDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(DraftDesignDataDO::getId,DraftDesignDataDO::getCode, BaseDO::getDeleted);
|
||||
lambdaQueryWrapper.eq(DraftDesignDataDO::getCode, code);
|
||||
lambdaQueryWrapper.eq(DraftDesignDataDO::getDeleted,false);
|
||||
List<DraftDesignDataDO> dos = draftDesignDataMapper.selectList(lambdaQueryWrapper);
|
||||
if(FuncUtil.isEmpty(id) && FuncUtil.isNotEmpty(dos)){
|
||||
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
|
||||
}
|
||||
if (FuncUtil.isNotEmpty(id) && FuncUtil.isNotEmpty(dos)) {
|
||||
for (DraftDesignDataDO aDo : dos) {
|
||||
// 出现重复并当前id 不一致
|
||||
if(!FuncUtil.equals(aDo.getId(), id)){
|
||||
throw exception(GlobalErrorCodeConstants.DATA_DUPLICATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.hangtag.module.oms.dal.mysql.draftdesigndata.DraftDesignDataMapper">
|
||||
|
||||
<!--
|
||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||
-->
|
||||
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,166 @@
|
|||
package cn.hangtag.module.oms.service.draftdesigndata;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import cn.hangtag.framework.test.core.ut.BaseDbUnitTest;
|
||||
|
||||
import cn.hangtag.module.oms.controller.admin.draftdesigndata.vo.*;
|
||||
import cn.hangtag.module.oms.dal.dataobject.draftdesigndata.DraftDesignDataDO;
|
||||
import cn.hangtag.module.oms.dal.mysql.draftdesigndata.DraftDesignDataMapper;
|
||||
import cn.hangtag.framework.common.pojo.PageResult;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.hutool.core.util.RandomUtil.*;
|
||||
import static cn.hangtag.module.oms.enums.ErrorCodeConstants.*;
|
||||
import static cn.hangtag.framework.test.core.util.AssertUtils.*;
|
||||
import static cn.hangtag.framework.test.core.util.RandomUtils.*;
|
||||
import static cn.hangtag.framework.common.util.date.LocalDateTimeUtils.*;
|
||||
import static cn.hangtag.framework.common.util.object.ObjectUtils.*;
|
||||
import static cn.hangtag.framework.common.util.date.DateUtils.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* {@link DraftDesignDataServiceImpl} 的单元测试类
|
||||
*
|
||||
* @author YuanFeng
|
||||
*/
|
||||
@Import(DraftDesignDataServiceImpl.class)
|
||||
public class DraftDesignDataServiceImplTest extends BaseDbUnitTest {
|
||||
|
||||
@Resource
|
||||
private DraftDesignDataServiceImpl draftDesignDataService;
|
||||
|
||||
@Resource
|
||||
private DraftDesignDataMapper draftDesignDataMapper;
|
||||
|
||||
@Test
|
||||
public void testCreateDraftDesignData_success() {
|
||||
// 准备参数
|
||||
DraftDesignDataSaveReqVO createReqVO = randomPojo(DraftDesignDataSaveReqVO.class).setId(null);
|
||||
|
||||
// 调用
|
||||
Long draftDesignDataId = draftDesignDataService.createDraftDesignData(createReqVO);
|
||||
// 断言
|
||||
assertNotNull(draftDesignDataId);
|
||||
// 校验记录的属性是否正确
|
||||
DraftDesignDataDO draftDesignData = draftDesignDataMapper.selectById(draftDesignDataId);
|
||||
assertPojoEquals(createReqVO, draftDesignData, "id");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateDraftDesignData_success() {
|
||||
// mock 数据
|
||||
DraftDesignDataDO dbDraftDesignData = randomPojo(DraftDesignDataDO.class);
|
||||
draftDesignDataMapper.insert(dbDraftDesignData);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
DraftDesignDataSaveReqVO updateReqVO = randomPojo(DraftDesignDataSaveReqVO.class, o -> {
|
||||
o.setId(dbDraftDesignData.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
// 调用
|
||||
draftDesignDataService.updateDraftDesignData(updateReqVO);
|
||||
// 校验是否更新正确
|
||||
DraftDesignDataDO draftDesignData = draftDesignDataMapper.selectById(updateReqVO.getId()); // 获取最新的
|
||||
assertPojoEquals(updateReqVO, draftDesignData);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateDraftDesignData_notExists() {
|
||||
// 准备参数
|
||||
DraftDesignDataSaveReqVO updateReqVO = randomPojo(DraftDesignDataSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> draftDesignDataService.updateDraftDesignData(updateReqVO), DRAFT_DESIGN_DATA_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteDraftDesignData_success() {
|
||||
// mock 数据
|
||||
DraftDesignDataDO dbDraftDesignData = randomPojo(DraftDesignDataDO.class);
|
||||
draftDesignDataMapper.insert(dbDraftDesignData);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
Long id = dbDraftDesignData.getId();
|
||||
|
||||
// 调用
|
||||
draftDesignDataService.deleteDraftDesignData(id);
|
||||
// 校验数据不存在了
|
||||
assertNull(draftDesignDataMapper.selectById(id));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteDraftDesignData_notExists() {
|
||||
// 准备参数
|
||||
Long id = randomLongId();
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> draftDesignDataService.deleteDraftDesignData(id), DRAFT_DESIGN_DATA_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetDraftDesignDataPage() {
|
||||
// mock 数据
|
||||
DraftDesignDataDO dbDraftDesignData = randomPojo(DraftDesignDataDO.class, o -> { // 等会查询到
|
||||
o.setCode(null);
|
||||
o.setName(null);
|
||||
o.setAuthor(null);
|
||||
o.setVersion(null);
|
||||
o.setLocale(null);
|
||||
o.setEnabled(null);
|
||||
o.setRemark(null);
|
||||
o.setDetails(null);
|
||||
o.setPropDefault(null);
|
||||
o.setCreateTime(null);
|
||||
});
|
||||
draftDesignDataMapper.insert(dbDraftDesignData);
|
||||
// 测试 code 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setCode(null)));
|
||||
// 测试 name 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setName(null)));
|
||||
// 测试 author 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setAuthor(null)));
|
||||
// 测试 version 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setVersion(null)));
|
||||
// 测试 locale 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setLocale(null)));
|
||||
// 测试 enabled 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setEnabled(null)));
|
||||
// 测试 remark 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setRemark(null)));
|
||||
// 测试 details 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setDetails(null)));
|
||||
// 测试 propDefault 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setPropDefault(null)));
|
||||
// 测试 createTime 不匹配
|
||||
draftDesignDataMapper.insert(cloneIgnoreId(dbDraftDesignData, o -> o.setCreateTime(null)));
|
||||
// 准备参数
|
||||
DraftDesignDataPageReqVO reqVO = new DraftDesignDataPageReqVO();
|
||||
reqVO.setCode(null);
|
||||
reqVO.setName(null);
|
||||
reqVO.setAuthor(null);
|
||||
reqVO.setVersion(null);
|
||||
reqVO.setLocale(null);
|
||||
reqVO.setEnabled(null);
|
||||
reqVO.setRemark(null);
|
||||
reqVO.setDetails(null);
|
||||
reqVO.setPropDefault(null);
|
||||
reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28));
|
||||
|
||||
// 调用
|
||||
PageResult<DraftDesignDataDO> pageResult = draftDesignDataService.getDraftDesignDataPage(reqVO);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getTotal());
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbDraftDesignData, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
// 稿件模板数据 VO
|
||||
export interface DraftDesignDataVO {
|
||||
id: number // id
|
||||
code: string // 编码
|
||||
name: string // 设计稿名称
|
||||
author: string // 作者
|
||||
version: number // 版本
|
||||
locale: string // 语言标识 字典-language_locale
|
||||
enabled: boolean // 启用状态
|
||||
remark: string // 备注
|
||||
details: string // 稿件详情 json数据
|
||||
propDefault: string // 动态属性
|
||||
}
|
||||
|
||||
// 稿件模板数据 API
|
||||
export const DraftDesignDataApi = {
|
||||
// 查询稿件模板数据 分页
|
||||
getDraftDesignDataPage: async (params: any) => {
|
||||
return await request.get({ url: `/oms/draft-design-data/page`, params })
|
||||
},
|
||||
|
||||
// 查询稿件模板数据 详情
|
||||
getDraftDesignData: async (id: number) => {
|
||||
return await request.get({ url: `/oms/draft-design-data/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增稿件模板数据
|
||||
createDraftDesignData: async (data: DraftDesignDataVO) => {
|
||||
return await request.post({ url: `/oms/draft-design-data/create`, data })
|
||||
},
|
||||
|
||||
// 修改稿件模板数据
|
||||
updateDraftDesignData: async (data: DraftDesignDataVO) => {
|
||||
return await request.put({ url: `/oms/draft-design-data/update`, data })
|
||||
},
|
||||
|
||||
// 删除稿件模板数据
|
||||
deleteDraftDesignData: async (id: number) => {
|
||||
return await request.delete({ url: `/oms/draft-design-data/delete?id=` + id })
|
||||
},
|
||||
|
||||
// 导出稿件模板数据 Excel
|
||||
exportDraftDesignData: async (params) => {
|
||||
return await request.download({ url: `/oms/draft-design-data/export-excel`, params })
|
||||
},
|
||||
}
|
||||
|
|
@ -188,6 +188,13 @@
|
|||
<i class="icon-lk_save"></i>
|
||||
</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<el-button
|
||||
@click="btnChange('clearData',true)"
|
||||
>
|
||||
<i class="icon-lk_delete"></i>
|
||||
</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<el-button
|
||||
@click="btnChange('canUndo',!that.btnState.canUndo)"
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import {
|
|||
mergeDeepObject,
|
||||
nextId
|
||||
} from "@/components/DraftDesign/utils/FuncUtil";
|
||||
import {getDraftDesign, getDraftDesignState} from "@/components/DraftDesign/config";
|
||||
import {getDraftDesignState} from "@/components/DraftDesign/config";
|
||||
|
||||
|
||||
export default defineComponent({
|
||||
|
|
@ -53,7 +53,7 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,12 +222,11 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -140,12 +140,11 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
@ -182,7 +181,7 @@ export default defineComponent({
|
|||
// this.cellInfo.showInput = val
|
||||
},
|
||||
changSize(size: any) {
|
||||
console.log("cellInfo.label", this.cellInfo.label)
|
||||
|
||||
this.sizeWInfo.width = size.width;
|
||||
this.sizeWInfo.height = size.height;
|
||||
this.minSize = Math.min(size.height, size.width)
|
||||
|
|
@ -195,9 +194,6 @@ export default defineComponent({
|
|||
} else if (s >= 1000) {
|
||||
s = 1000
|
||||
}
|
||||
|
||||
// this.nodeInfo.store.data.size.width = size.width;
|
||||
console.log(" this.nodeInfo.width", this.nodeInfo)
|
||||
this.fontSize = s;
|
||||
this.changeFontSize();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -149,13 +149,10 @@ export default defineComponent({
|
|||
mounted() {
|
||||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
@ -192,7 +189,7 @@ export default defineComponent({
|
|||
// this.cellInfo.showInput = val
|
||||
},
|
||||
changSize(size: any) {
|
||||
console.log("cellInfo.label", this.cellInfo.label)
|
||||
|
||||
this.sizeWInfo.width = size.width;
|
||||
this.sizeWInfo.height = size.height;
|
||||
this.minSize = Math.min(size.height, size.width)
|
||||
|
|
@ -206,8 +203,6 @@ export default defineComponent({
|
|||
s = 1000
|
||||
}
|
||||
|
||||
// this.nodeInfo.store.data.size.width = size.width;
|
||||
console.log(" this.nodeInfo.width", this.nodeInfo)
|
||||
this.fontSize = s;
|
||||
this.changeFontSize();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -154,12 +154,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ export default defineComponent({
|
|||
// this.cellInfo.showInput = val
|
||||
},
|
||||
changSize(size: any) {
|
||||
console.log("cellInfo.label", this.cellInfo.label)
|
||||
|
||||
this.sizeWInfo.width = size.width;
|
||||
this.sizeWInfo.height = size.height;
|
||||
this.minSize = Math.min(size.height, size.width)
|
||||
|
|
@ -211,7 +211,6 @@ export default defineComponent({
|
|||
}
|
||||
|
||||
// this.nodeInfo.store.data.size.width = size.width;
|
||||
console.log(" this.nodeInfo.width", this.nodeInfo)
|
||||
this.fontSize = s;
|
||||
this.changeFontSize();
|
||||
},
|
||||
|
|
@ -226,7 +225,6 @@ export default defineComponent({
|
|||
}
|
||||
}
|
||||
}
|
||||
console.log("text##", info)
|
||||
this.cellInfo = mergeDeepObject({
|
||||
showInput: false,
|
||||
id: nextId(),
|
||||
|
|
|
|||
|
|
@ -143,12 +143,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -177,12 +177,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -154,12 +154,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -183,12 +183,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -167,12 +167,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -168,12 +168,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -101,12 +101,12 @@ export default defineComponent({
|
|||
const node = (this as any).getNode()
|
||||
this.nodeInfo = node
|
||||
|
||||
console.log("自定义节点", node.data)
|
||||
|
||||
if (node && node.data) {
|
||||
this.setCellInfo(node.data)
|
||||
}
|
||||
node.on('change:data', ({current}) => {
|
||||
console.log("change:data", current)
|
||||
|
||||
this.setCellInfo(current)
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ register({
|
|||
})
|
||||
const TeleportContainer = defineComponent(getTeleport());
|
||||
|
||||
const emit = defineEmits(["save"])
|
||||
const {t} = useI18n() // 国际化
|
||||
let graph: Graph = null
|
||||
let history = null
|
||||
|
|
@ -407,6 +408,12 @@ const rightKeyMenu = computed(() => {
|
|||
|
||||
return arr;
|
||||
});
|
||||
|
||||
const clearData = ()=>{
|
||||
if(graph){
|
||||
graph.fromJSON({})
|
||||
}
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param isDesignMode
|
||||
|
|
@ -441,7 +448,6 @@ const init = (isDesignMode: boolean, bgConfig: any, data = {}, propDataInfo = {}
|
|||
autoResize: false,
|
||||
propList: [],
|
||||
}, bgConfig) as any
|
||||
|
||||
let options = {
|
||||
...graphOptions(that.containerId, !that.editState),
|
||||
...that.pageConfig,
|
||||
|
|
@ -941,23 +947,23 @@ const addDrawRuler = () => {
|
|||
};
|
||||
|
||||
onMounted(() => {
|
||||
const r = localStorage.getItem("tem_data")
|
||||
if (r) {
|
||||
const conf = JSON.parse(r)
|
||||
const test = {
|
||||
g_kn7c4vzgf9a:{
|
||||
dataInfo: [
|
||||
{
|
||||
url: '',
|
||||
label: '100%聚酯纤维',
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
init(true, conf.pageConfig, conf.data, test);
|
||||
} else {
|
||||
init(true, {});
|
||||
}
|
||||
// const r = localStorage.getItem("tem_data")
|
||||
// if (r) {
|
||||
// const conf = JSON.parse(r)
|
||||
// const test = {
|
||||
// g_kn7c4vzgf9a:{
|
||||
// dataInfo: [
|
||||
// {
|
||||
// url: '',
|
||||
// label: '100%聚酯纤维',
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
// }
|
||||
// init(true, conf.pageConfig, conf.data, test);
|
||||
// } else {
|
||||
// }
|
||||
// init(true, {});
|
||||
})
|
||||
const btnEventHandler = {
|
||||
'canUndo': (val) => {
|
||||
|
|
@ -969,9 +975,18 @@ const btnEventHandler = {
|
|||
if (graph.canRedo()) {
|
||||
graph.redo()
|
||||
}
|
||||
}, 'canSave': (val) => {
|
||||
getJson()
|
||||
},
|
||||
'canSave': (val) => {
|
||||
const data = getJson();
|
||||
emit("save",data);
|
||||
console.log("doSave")
|
||||
},
|
||||
'clearData': (val) => {
|
||||
useMessage().confirm("是否清空数据?").then((res)=>{
|
||||
if(res){
|
||||
clearData()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
const btnChange = (val) => {
|
||||
|
|
@ -1310,6 +1325,11 @@ const submitProp = (data) => {
|
|||
that.pageConfig.propList.push(data)
|
||||
dynamicPropRef.value.updateVisible(false)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
init,
|
||||
clearData
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<DraftDesign />
|
||||
<el-card shadow="never">
|
||||
|
||||
|
||||
<el-skeleton :loading="loading" animated>
|
||||
<el-row :gutter="16" justify="space-between">
|
||||
<el-col :xl="12" :lg="12" :md="12" :sm="24" :xs="24">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,143 @@
|
|||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="设计稿名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入设计稿名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="作者" prop="author">
|
||||
<el-input v-model="formData.author" placeholder="请输入作者" />
|
||||
</el-form-item>
|
||||
<el-form-item label="版本" prop="version">
|
||||
<el-input v-model="formData.version" placeholder="请输入版本" />
|
||||
</el-form-item>
|
||||
<el-form-item label="语言标识 字典-language_locale" prop="locale">
|
||||
<el-select v-model="formData.locale" placeholder="请选择语言标识 字典-language_locale">
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.LANGUAGE_LOCALE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用状态" prop="enabled">
|
||||
<el-radio-group v-model="formData.enabled">
|
||||
<el-radio label="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
<el-form-item label="稿件详情 json数据" prop="details">
|
||||
<el-input v-model="formData.details" placeholder="请输入稿件详情 json数据" />
|
||||
</el-form-item>
|
||||
<el-form-item label="动态属性" prop="propDefault">
|
||||
<el-input v-model="formData.propDefault" placeholder="请输入动态属性" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { DraftDesignDataApi, DraftDesignDataVO } from '@/api/oms/draftdesigndata'
|
||||
|
||||
/** 稿件模板数据 表单 */
|
||||
defineOptions({ name: 'DraftDesignDataForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
author: undefined,
|
||||
version: undefined,
|
||||
locale: undefined,
|
||||
enabled: undefined,
|
||||
remark: undefined,
|
||||
details: undefined,
|
||||
propDefault: undefined,
|
||||
})
|
||||
const formRules = reactive({
|
||||
code: [{ required: true, message: '编码不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '设计稿名称不能为空', trigger: 'blur' }],
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await DraftDesignDataApi.getDraftDesignData(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as DraftDesignDataVO
|
||||
if (formType.value === 'create') {
|
||||
await DraftDesignDataApi.createDraftDesignData(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await DraftDesignDataApi.updateDraftDesignData(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
author: undefined,
|
||||
version: undefined,
|
||||
locale: undefined,
|
||||
enabled: undefined,
|
||||
remark: undefined,
|
||||
details: undefined,
|
||||
propDefault: undefined,
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,181 @@
|
|||
<template>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<div>
|
||||
<DraftDesign ref="draftDesignRef" @save="submitForm"/>
|
||||
</div>
|
||||
<el-row>
|
||||
<el-col :span="8" :xs="24">
|
||||
<el-form-item label="编码" prop="code">
|
||||
<el-input :disabled=true v-model="formData.code" placeholder="系统生成" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" :xs="24">
|
||||
<el-form-item label="设计稿名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入设计稿名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8" :xs="24">
|
||||
<el-form-item label="作者" prop="author">
|
||||
<el-input v-model="formData.author" placeholder="请输入作者" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="6" :xs="24">
|
||||
<el-form-item label="语言标识" prop="locale">
|
||||
<el-select v-model="formData.locale" placeholder="请选择语言标识">
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.LANGUAGE_LOCALE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="6" :xs="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input :rows="1" type="textarea" v-model="formData.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6" :xs="24">
|
||||
<el-form-item label="启用状态" prop="enabled">
|
||||
<el-checkbox v-model="formData.enabled" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6" :xs="24">
|
||||
<el-form-item label="版本" prop="version">
|
||||
<el-input v-model="formData.version" :disabled=true placeholder="请输入版本" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
</el-form>
|
||||
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { DraftDesignDataApi, DraftDesignDataVO } from '@/api/oms/draftdesigndata'
|
||||
import DraftDesign from "@/components/DraftDesign/index.vue";
|
||||
|
||||
/** 稿件模板数据 表单 */
|
||||
defineOptions({ name: 'DraftDesignDataForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
const route = useRoute() // 路由
|
||||
const draftDesignRef = ref()
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('create') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: route.params.id,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
author: undefined,
|
||||
version: 1,
|
||||
locale: 'zh-CN',
|
||||
enabled: undefined,
|
||||
remark: undefined,
|
||||
details: undefined,
|
||||
propDefault: undefined,
|
||||
})
|
||||
const formRules = reactive({
|
||||
code: [{ required: false, message: '编码不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '设计稿名称不能为空', trigger: 'blur' }],
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
onMounted(()=>{
|
||||
formData.value.id = route.query.id
|
||||
formType.value = formData.value.id ? 'update' : 'create'
|
||||
open(formType.value,formData.value.id)
|
||||
|
||||
})
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
const res = await DraftDesignDataApi.getDraftDesignData(id)
|
||||
if(res){
|
||||
formData.value = res
|
||||
const j = formData.value.details || "{}"
|
||||
const d = JSON.parse(j)
|
||||
// true, conf.pageConfig, conf.data, test
|
||||
draftDesignRef.value.init(true, d.pageConfig, d.data, {})
|
||||
}else {
|
||||
useMessage().error('获取数据不存在:'+id)
|
||||
}
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}else {
|
||||
draftDesignRef.value.init(true, {})
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async (detailsData) => {
|
||||
// 校验表单
|
||||
await formRef.value.validate().catch(e=>{
|
||||
useMessage().error("存在必填项未填写")
|
||||
return
|
||||
})
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as DraftDesignDataVO
|
||||
data.propDefault = JSON.stringify(detailsData.pageConfig.propDefault)
|
||||
data.details = JSON.stringify(detailsData)
|
||||
console.log("data",data)
|
||||
if (formType.value === 'create') {
|
||||
await DraftDesignDataApi.createDraftDesignData(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
resetForm()
|
||||
} else {
|
||||
await DraftDesignDataApi.updateDraftDesignData(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
author: undefined,
|
||||
version: 1,
|
||||
locale: 'zh-CN',
|
||||
enabled: undefined,
|
||||
remark: undefined,
|
||||
details: undefined,
|
||||
propDefault: undefined,
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
draftDesignRef.value.clearData()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="编码" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.code"
|
||||
placeholder="请输入编码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="设计稿名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入设计稿名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="作者" prop="author">
|
||||
<el-input
|
||||
v-model="queryParams.author"
|
||||
placeholder="请输入作者"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="语言标识" prop="locale">
|
||||
<el-select
|
||||
v-model="queryParams.locale"
|
||||
placeholder="请选择语言"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getStrDictOptions(DICT_TYPE.LANGUAGE_LOCALE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="启用状态" prop="enabled">
|
||||
<el-checkbox
|
||||
v-model="queryParams.enabled"
|
||||
placeholder="请选择启用状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
|
||||
<router-link v-hasPermi="['oms:draft-design-data:create']" :to="'/base/oms/draftdesigndata/detials'">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
</router-link>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['oms:draft-design-data:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
|
||||
<el-table-column label="id" align="center" prop="id" />
|
||||
<el-table-column label="编码" align="center" prop="code" />
|
||||
<el-table-column label="设计稿名称" align="center" prop="name" />
|
||||
<el-table-column label="作者" align="center" prop="author" />
|
||||
<el-table-column label="版本" align="center" prop="version" />
|
||||
<el-table-column label="语言标识" align="center" prop="locale">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.LANGUAGE_LOCALE" :value="scope.row.locale" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="启用状态" align="center" prop="enabled" />
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
:formatter="dateFormatter"
|
||||
width="180px"
|
||||
/>
|
||||
<el-table-column label="操作" align="center">
|
||||
<template #default="scope">
|
||||
|
||||
<router-link v-hasPermi="['oms:draft-design-data:update']" :to="'/base/oms/draftdesigndata/detials?id='+ scope.row.id">
|
||||
<el-button
|
||||
link
|
||||
type="primary">
|
||||
编辑
|
||||
</el-button>
|
||||
</router-link>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['oms:draft-design-data:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<DraftDesignDataForm ref="formRef" @success="getList" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getStrDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { DraftDesignDataApi, DraftDesignDataVO } from '@/api/oms/draftdesigndata'
|
||||
import DraftDesignDataForm from './DraftDesignDataForm.vue'
|
||||
|
||||
/** 稿件模板数据 列表 */
|
||||
defineOptions({ name: 'DraftDesignData' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<DraftDesignDataVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
author: undefined,
|
||||
version: undefined,
|
||||
locale: undefined,
|
||||
enabled: undefined,
|
||||
remark: undefined,
|
||||
details: undefined,
|
||||
propDefault: undefined,
|
||||
createTime: [],
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await DraftDesignDataApi.getDraftDesignDataPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await DraftDesignDataApi.deleteDraftDesignData(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await DraftDesignDataApi.exportDraftDesignData(queryParams)
|
||||
download.excel(data, '稿件模板数据 .xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
<!-- eslint-disable vue/this-in-template -->
|
||||
<template>
|
||||
<Dialog :title="dialogTitle"
|
||||
width="60vw"
|
||||
v-model="dialogVisible">
|
||||
<Dialog
|
||||
:title="dialogTitle"
|
||||
width="60vw"
|
||||
v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
|
|
@ -11,39 +13,42 @@
|
|||
>
|
||||
<el-form-item v-if="formData.id" label="id" prop="id">
|
||||
<div class="flex">
|
||||
<el-input v-model="formData.id" :disabled="true" />
|
||||
<el-button @click="copyData(formData.id)" type="primary">
|
||||
复制
|
||||
</el-button>
|
||||
<el-input v-model="formData.id" :disabled="true"/>
|
||||
<el-button @click="copyData(formData.id)" type="primary">
|
||||
复制
|
||||
</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入名称" />
|
||||
<el-input v-model="formData.name" placeholder="请输入名称"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="规则配置 json" prop="config">
|
||||
<div class="flex w-full flex-col">
|
||||
<div class="flex w-full flex-col">
|
||||
<div>
|
||||
<el-button @click="that.configList.push({})" type="primary">添加编码段</el-button>
|
||||
<el-button @click="previewCode" type="primary">测试</el-button>
|
||||
<div>
|
||||
<el-button @click="that.configList.push({})" type="primary">添加编码段</el-button>
|
||||
<el-button @click="previewCode" type="primary">测试</el-button>
|
||||
<div>
|
||||
<div v-for="c in that.testCodeList" :key="c">
|
||||
{{c}}
|
||||
</div>
|
||||
<el-button v-if="that.testCodeList.length > 0" @click="that.testCodeList = []" type="primary">清空预览</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div v-for="(item,index) in that.configList" :key=index>
|
||||
<CodingRulesEditItem :title="`编码${index+1}段`" v-model="that.configList[index]" />
|
||||
<el-button @click="that.configList.splice(index,1)" type="danger" link>删除</el-button>
|
||||
<div v-for="c in that.testCodeList" :key="c">
|
||||
{{ c }}
|
||||
</div>
|
||||
<el-button v-if="that.testCodeList.length > 0" @click="that.testCodeList = []"
|
||||
type="primary">清空预览
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div v-for="(item,index) in that.configList" :key=index>
|
||||
<CodingRulesEditItem :title="`编码${index+1}段`" v-model="that.configList[index]"/>
|
||||
<el-button @click="that.configList.splice(index,1)" type="danger" link>删除
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" />
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注"/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
|
|
@ -53,13 +58,14 @@
|
|||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { CodingRulesApi, CodingRulesVO } from '@/api/system/codingrules'
|
||||
import {CodingRulesApi, CodingRulesVO} from '@/api/system/codingrules'
|
||||
import CodingRulesEditItem from './components/edit-item.vue'
|
||||
import {copyToClip} from "@/utils";
|
||||
/** 系统编码规则 表单 */
|
||||
defineOptions({ name: 'CodingRulesForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
/** 系统编码规则 表单 */
|
||||
defineOptions({name: 'CodingRulesForm'})
|
||||
|
||||
const {t} = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
|
|
@ -73,16 +79,16 @@ const formData = ref({
|
|||
remark: undefined,
|
||||
})
|
||||
const formRules = reactive({
|
||||
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
|
||||
name: [{required: true, message: '名称不能为空', trigger: 'blur'}],
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const that =reactive({
|
||||
const that = reactive({
|
||||
configList: [],
|
||||
testCodeList: [],
|
||||
})
|
||||
|
||||
const copyData = (str:string) => {
|
||||
copyToClip(str,()=>{
|
||||
const copyData = (str: string) => {
|
||||
copyToClip(str, () => {
|
||||
message.success('复制成功')
|
||||
})
|
||||
}
|
||||
|
|
@ -97,7 +103,7 @@ const open = async (type: string, id?: number) => {
|
|||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await CodingRulesApi.getCodingRules(id)
|
||||
if(formData.value.config){
|
||||
if (formData.value.config) {
|
||||
that.configList = JSON.parse(formData.value.config)
|
||||
}
|
||||
} finally {
|
||||
|
|
@ -105,28 +111,28 @@ const open = async (type: string, id?: number) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
defineExpose({open}) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
|
||||
|
||||
const previewCode = ()=>{
|
||||
const previewCode = () => {
|
||||
|
||||
if(that.configList.length === 0){
|
||||
if (that.configList.length === 0) {
|
||||
message.error('请添加编码段')
|
||||
return
|
||||
}
|
||||
const data = {...formData.value} as unknown as CodingRulesVO
|
||||
data.config = JSON.stringify(that.configList)
|
||||
data.name = 'test'
|
||||
CodingRulesApi.previewCode(data).then(res=>{
|
||||
CodingRulesApi.previewCode(data).then(res => {
|
||||
console.log(res)
|
||||
that.testCodeList = res
|
||||
})
|
||||
}
|
||||
const submitForm = async () => {
|
||||
if(that.configList.length === 0){
|
||||
if (that.configList.length === 0) {
|
||||
message.error('请添加编码段')
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<!-- eslint-disable vue/this-in-template -->
|
||||
<template>
|
||||
<div class="w-full">
|
||||
<div>
|
||||
<label >
|
||||
<el-divider content-position="left"><span class="font-bold color__4073fa" >{{ title }}</span></el-divider>
|
||||
<label>
|
||||
<el-divider content-position="left"><span class="font-bold color__4073fa">{{ title }}</span>
|
||||
</el-divider>
|
||||
</label>
|
||||
</div>
|
||||
<el-form label-width="100px" label-position="top" :disabled="disabled">
|
||||
|
|
@ -22,30 +24,31 @@
|
|||
|
||||
<el-form-item :label="showText">
|
||||
<div class="min-w-[200px]">
|
||||
<el-input-number v-if="that.modelData.type === 'serialNumber'"
|
||||
:max=9999999 :min="-9999999"
|
||||
v-model="that.modelData.value" @change="changInput"
|
||||
:placeholder="'请输入'+showText" />
|
||||
<el-input-number
|
||||
v-if="that.modelData.type === 'serialNumber'"
|
||||
:max=9999999 :min="-9999999"
|
||||
v-model="that.modelData.value" @change="changInput"
|
||||
:placeholder="'请输入'+showText"/>
|
||||
|
||||
<el-input v-else v-model="that.modelData.value" @change="changInput"
|
||||
:placeholder="'请输入'+showText" />
|
||||
<el-input v-else v-model="that.modelData.value" @change="changInput"
|
||||
:placeholder="'请输入'+showText"/>
|
||||
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<div v-show="showSerialNumber">
|
||||
<div class="min-w-[30px]">
|
||||
<el-form-item label="长度">
|
||||
<el-input-number v-model="that.modelData.length" @change="changInput" />
|
||||
</el-form-item>
|
||||
<el-form-item label="长度">
|
||||
<el-input-number v-model="that.modelData.length" @change="changInput"/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-show="showSerialNumber">
|
||||
<div class="min-w-[30px]">
|
||||
<el-form-item label="步长">
|
||||
<el-input-number v-model="that.modelData.step" :min="1" @change="changInput" />
|
||||
</el-form-item>
|
||||
<el-form-item label="步长">
|
||||
<el-input-number v-model="that.modelData.step" :min="1" @change="changInput"/>
|
||||
</el-form-item>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -56,11 +59,11 @@
|
|||
<template #content>根据所选择的日期或业务字段编码的变化重新开始新的流水号递增。<br/>
|
||||
例如:日期作为编码段,流水号起始值为0001,日期显示格式为yyyyMMdd,那么,2019年1月1日新增的单据,<br/>
|
||||
其单据编号从201901010001开始递增,2019年1月2日新增的单据,其流水号则会重置为起始值,单据编号从201901020001开始递增。<br/>
|
||||
若不开启此参数,流水号会一直递增。</template>
|
||||
若不开启此参数,流水号会一直递增。
|
||||
</template>
|
||||
<div>
|
||||
<div style="margin-left: 10px">
|
||||
<el-checkbox v-model="that.modelData.resetSerialNumber"
|
||||
@change="changInput" />
|
||||
<el-checkbox v-model="that.modelData.resetSerialNumber" @change="changInput"/>
|
||||
</div>
|
||||
</div>
|
||||
</el-tooltip>
|
||||
|
|
@ -74,7 +77,7 @@
|
|||
</template>
|
||||
<script lang="ts" setup name="CodingRulesEditItem">
|
||||
|
||||
const newId = (len = 5)=>{
|
||||
const newId = (len = 5) => {
|
||||
return Math.random().toString(36).substring(2, 2 + len).padEnd(len, 's');
|
||||
}
|
||||
const typeList = [
|
||||
|
|
@ -101,7 +104,7 @@ const props = defineProps({
|
|||
modelKey: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ()=>{
|
||||
default: () => {
|
||||
return Math.random().toString(36).substring(2, 6).padEnd(6, 's');
|
||||
}
|
||||
},
|
||||
|
|
@ -115,7 +118,7 @@ const props = defineProps({
|
|||
default: () => ('编码')
|
||||
}
|
||||
})
|
||||
const emit = defineEmits(['change','update:modelValue'])
|
||||
const emit = defineEmits(['change', 'update:modelValue'])
|
||||
|
||||
const showText = computed(() => {
|
||||
if (that.modelData.type === 'serialNumber') {
|
||||
|
|
@ -127,7 +130,7 @@ const showText = computed(() => {
|
|||
return '常量值'
|
||||
})
|
||||
|
||||
const toInt =(obj: any, defaultVal = 0): number => {
|
||||
const toInt = (obj: any, defaultVal = 0): number => {
|
||||
try {
|
||||
const parsedInt = parseInt(obj, 10);
|
||||
if (!isNaN(parsedInt)) {
|
||||
|
|
@ -163,7 +166,7 @@ onMounted(() => {
|
|||
initData(props.modelValue)
|
||||
changInput(null)
|
||||
})
|
||||
const initData = (val:object)=>{
|
||||
const initData = (val: object) => {
|
||||
that.modelData = {
|
||||
type: 'constant',
|
||||
value: '',
|
||||
|
|
@ -179,20 +182,20 @@ const initData = (val:object)=>{
|
|||
// changInput(null)
|
||||
}
|
||||
const initModelData = {
|
||||
serialNumber: ()=>{
|
||||
serialNumber: () => {
|
||||
that.modelData.resetSerialNumber = false
|
||||
that.modelData.length = that.modelData.length || 4
|
||||
that.modelData.length = that.modelData.length || 4
|
||||
that.modelData.step = that.modelData.step || 1
|
||||
that.modelData.value = toInt(that.modelData.value)
|
||||
|
||||
},
|
||||
constant: ()=>{
|
||||
constant: () => {
|
||||
that.modelData.lastValue = ''
|
||||
},
|
||||
javaBeanQuery: ()=>{
|
||||
javaBeanQuery: () => {
|
||||
that.modelData.lastValue = ''
|
||||
},
|
||||
dateTime: ()=>{
|
||||
dateTime: () => {
|
||||
that.modelData.length = 0
|
||||
that.modelData.step = 0
|
||||
that.modelData.value = that.modelData.value || 'yyyymmdd'
|
||||
|
|
@ -200,35 +203,35 @@ const initModelData = {
|
|||
}
|
||||
// 重置数据
|
||||
const resetData = {
|
||||
serialNumber: ()=>{
|
||||
serialNumber: () => {
|
||||
that.modelData.resetSerialNumber = false
|
||||
that.modelData.lastValue = ''
|
||||
that.modelData.length = that.modelData.length || 4
|
||||
that.modelData.length = that.modelData.length || 4
|
||||
that.modelData.step = that.modelData.step || 1
|
||||
that.modelData.value = toInt(that.modelData.value)
|
||||
},
|
||||
constant: ()=>{
|
||||
constant: () => {
|
||||
that.modelData.resetSerialNumber = false
|
||||
that.modelData.length = 0
|
||||
that.modelData.step = 0
|
||||
that.modelData.lastValue = ''
|
||||
},
|
||||
dateTime: ()=>{
|
||||
dateTime: () => {
|
||||
that.modelData.length = 0
|
||||
that.modelData.step = 0
|
||||
that.modelData.lastValue = ''
|
||||
const d = toInt(that.modelData.value)
|
||||
const d = toInt(that.modelData.value)
|
||||
if (!isNaN(d)) {
|
||||
that.modelData.value = 'yyyymmdd'
|
||||
}
|
||||
}
|
||||
}
|
||||
const changInput = (val:any) => {
|
||||
const changInput = (val: any) => {
|
||||
const {modelData} = getModelData();
|
||||
emit("change",props.modelKey,modelData)
|
||||
emit("update:modelValue",modelData)
|
||||
emit("change", props.modelKey, modelData)
|
||||
emit("update:modelValue", modelData)
|
||||
}
|
||||
const getModelData = ()=>{
|
||||
const getModelData = () => {
|
||||
//@ts-ignore
|
||||
resetData[that.modelData.type]()
|
||||
return {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue