初始代码
This commit is contained in:
1520
TemplateCodeVue3/PublicMacro/AppFormMarco.vm
Normal file
1520
TemplateCodeVue3/PublicMacro/AppFormMarco.vm
Normal file
File diff suppressed because it is too large
Load Diff
28
TemplateCodeVue3/PublicMacro/ConstantMarco.vm
Normal file
28
TemplateCodeVue3/PublicMacro/ConstantMarco.vm
Normal file
@@ -0,0 +1,28 @@
|
||||
## 需要使用常量 引入此方法
|
||||
#macro(ConstantParams )
|
||||
##多选控件--popupTableSelect:下拉表格
|
||||
#set($multipleUnit =['select','depSelect','roleSelect','userSelect','usersSelect','organizeSelect','treeSelect',
|
||||
'posSelect','groupSelect','areaSelect' ,'cascader','currOrganize','treeSelect','checkbox','popupTableSelect'])
|
||||
##多选二维数组
|
||||
#set($multipleTwoUnit = ['organizeSelect', 'cascader', 'areaSelect'])
|
||||
#set($multipleTwoUnitStr = "['organizeSelect', 'cascader', 'areaSelect']")
|
||||
##多选动态
|
||||
#set($needDynamic=['treeSelect','cascader'])
|
||||
##静态需要转json
|
||||
#set($needToJsonStatic = ['cascader','checkbox'])
|
||||
##静态需要转json(并且需要判断多选)
|
||||
#set($needToJsonMultiple = ['select','treeSelect'])
|
||||
##详情页需要生成标签的控件
|
||||
#set($DetailTag= ['text','uploadFile','uploadImg','colorPicker','rate','slider','inputNumber','sign','iframe','input','location','signature'])
|
||||
##上传类控件
|
||||
#set($UploadFileUnit=['uploadFile','uploadImg'])
|
||||
##导入过滤掉字段
|
||||
#set($DownLoadSkipUint=['divider', 'text', 'link', 'alert', 'groupTitle', 'button', 'barcode', 'qrcode', 'relationFormAttr', 'popupAttr', 'calculate',
|
||||
'uploadFile', 'uploadImg', 'colorPicker', 'popupTableSelect', 'relationForm', 'popupSelect', 'calculate'])
|
||||
##系统控件yunzhupaaskey
|
||||
#set($systemyunzhupaasKey=['createUser','createTime','modifyUser','modifyTime','currOrganize','currPosition','billRule'])
|
||||
##不生成必填判断
|
||||
#set($DonotJudgeNull= ['text','divider','switch','rate','slider'])
|
||||
##远端数据联动,有templatejson控件
|
||||
#set($InterfaceHasJson =['radio','checkbox','select','cascader','treeSelect','popupSelect','popupTableSelect','autoComplete','relationForm'])
|
||||
#end
|
||||
825
TemplateCodeVue3/PublicMacro/ControllerMarco.vm
Normal file
825
TemplateCodeVue3/PublicMacro/ControllerMarco.vm
Normal file
@@ -0,0 +1,825 @@
|
||||
#set($mapObject ="Map<String, Object>")
|
||||
## 导入实例信息添加
|
||||
#macro(TemlateDownloadDemo $MapName $Field)
|
||||
#set($key = $Field.config.yunzhupaasKey)
|
||||
#set($mul = $Field.multiple)
|
||||
#set($level = $Field.level)
|
||||
#set($vModelThis = $Field.vModel)
|
||||
#if($Field.beforeVmodel)
|
||||
#set($vModelThis = $Field.beforeVmodel)
|
||||
#end
|
||||
#if($key == "createUser" || $key == "modifyUser" || $key == "createTime" || $key == "modifyTime" || $key == "currOrganize" || $key == "currPosition" || $key == "currDept" || $key == "billRule")
|
||||
${MapName}.put("${vModelThis}", "系统自动生成");
|
||||
#elseif($key == 'organizeSelect')
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:yunzhupaas信息/产品部,yunzhupaas信息/技术部");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:yunzhupaas信息/技术部");
|
||||
#end
|
||||
#elseif($key == "depSelect")
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:产品部/部门编码,技术部/部门编码");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:技术部/部门编码");
|
||||
#end
|
||||
#elseif($key == "posSelect")
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:技术经理/岗位编码,技术员/岗位编码");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:技术员/岗位编码");
|
||||
#end
|
||||
#elseif($key == "userSelect")
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:张三/账号,李四/账号");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:张三/账号");
|
||||
#end
|
||||
#elseif($key == "usersSelect")
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:方方/账号,技术部/部门编码");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:方方/账号");
|
||||
#end
|
||||
#elseif($key == "roleSelect")
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:研发人员/角色编码,测试人员/角色编码");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:研发人员/角色编码");
|
||||
#end
|
||||
#elseif($key == "groupSelect")
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:A分组/分组编码,B分组/分组编码");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:A分组/分组编码");
|
||||
#end
|
||||
#elseif($key == 'datePicker')
|
||||
${MapName}.put("${vModelThis}", "例: ${Field.format}");
|
||||
#elseif($key == 'timePicker')
|
||||
${MapName}.put("${vModelThis}", "例: ${Field.format}");
|
||||
#elseif($key == 'areaSelect')
|
||||
#if($level==0)
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:福建省,广东省");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:福建省");
|
||||
#end
|
||||
#elseif($level==1)
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:福建省/莆田市,广东省/广州市");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:福建省/莆田市");
|
||||
#end
|
||||
#elseif($level==2)
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:福建省/莆田市/城厢区,广东省/广州市/荔湾区");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:福建省/莆田市/城厢区");
|
||||
#end
|
||||
#elseif($level==3)
|
||||
#if($mul)
|
||||
${MapName}.put("${vModelThis}", "例:福建省/莆田市/城厢区/霞林街道,广东省/广州市/荔湾区/沙面街道");
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "例:福建省/莆田市/城厢区/霞林街道");
|
||||
#end
|
||||
#end
|
||||
#else
|
||||
${MapName}.put("${vModelThis}", "");
|
||||
#end
|
||||
#end
|
||||
## 主子副,entity转成map isGetInfo是否不转换数据详情 isDetail 是否转换数据的详情
|
||||
#macro(EntityToMap)
|
||||
${mapObject} ${name}Map=JsonUtil.entityToMap(entity);
|
||||
${name}Map.put("id", ${name}Map.get("${pKeyNameOriginal}"));
|
||||
//副表数据
|
||||
#foreach($child in ${columnTableHandle})
|
||||
${child.modelUpName}Entity ${child.modelLowName}Entity = entity.get${child.modelUpName}();
|
||||
if(ObjectUtil.isNotEmpty(${child.modelLowName}Entity)){
|
||||
${mapObject} ${child.modelLowName}Map=JsonUtil.entityToMap(${child.modelLowName}Entity);
|
||||
for(String key:${child.modelLowName}Map.keySet()){
|
||||
${name}Map.put("yunzhupaas_${child.tableName}_yunzhupaas_"+key,${child.modelLowName}Map.get(key));
|
||||
}
|
||||
}
|
||||
#end
|
||||
//子表数据
|
||||
#foreach($grid in ${childTableHandle})
|
||||
List<${grid.aliasUpName}Entity> ${grid.aliasLowName}List = entity.get${grid.aliasUpName}();
|
||||
${name}Map.put("${grid.tableModel}",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(${grid.aliasLowName}List)));
|
||||
${name}Map.put("${grid.aliasLowName}List",JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(${grid.aliasLowName}List)));
|
||||
#end
|
||||
#end
|
||||
###########################以上为通用宏,以下是controller方法#################################
|
||||
## 获取列表信息
|
||||
#macro(GetList)
|
||||
/**
|
||||
* 列表
|
||||
*
|
||||
* @param ${name}Pagination
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取列表")
|
||||
@PostMapping("/getList")
|
||||
public ActionResult list(@RequestBody ${Name}Pagination ${name}Pagination)throws Exception{
|
||||
List<${table.entityName}> list= ${serviceName}.getList(${name}Pagination);
|
||||
List<${mapObject}> realList=new ArrayList<>();
|
||||
for (${Name}Entity entity : list) {
|
||||
#EntityToMap()
|
||||
realList.add(${name}Map);
|
||||
}
|
||||
//数据转换
|
||||
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
|
||||
realList = generaterSwapUtil.swapDataList(realList, ${Name}Constant.getFormData(), ${Name}Constant.getColumnData(), ${name}Pagination.getModuleId(),isPc?${lineEdit}:false);
|
||||
|
||||
#if($isFlow)
|
||||
//流程状态添加
|
||||
generaterSwapUtil.getFlowStatus(realList);
|
||||
#end
|
||||
#if($treeTable || $groupTable)
|
||||
if(isPc){
|
||||
//分组和树形的树形数据转换
|
||||
realList = generaterSwapUtil.swapDataList(realList, ${Name}Constant.getColumnData(), "${peimaryKeyname}");
|
||||
}
|
||||
#end
|
||||
//返回对象
|
||||
PageListVO vo = new PageListVO();
|
||||
vo.setList(realList);
|
||||
PaginationVO page = JsonUtil.getJsonToBean(${name}Pagination, PaginationVO.class);
|
||||
vo.setPagination(page);
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
#end
|
||||
## 新增
|
||||
#macro(CreateMethod $leiName)
|
||||
/**
|
||||
* 创建
|
||||
*
|
||||
* @param ${name}Form
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(#if($isFlow)"/{id}"#end)
|
||||
@Operation(summary = "创建")
|
||||
public ActionResult create(#if($isFlow)@PathVariable("id") String id, #end@RequestBody @Valid ${Name}Form ${name}Form) {
|
||||
String b = ${serviceName}.checkForm(${name}Form,0);
|
||||
if (StringUtil.isNotEmpty(b)){
|
||||
return ActionResult.fail(b );
|
||||
}
|
||||
try{
|
||||
${name}Service.saveOrUpdate(${name}Form,#if($isFlow) id #else null #end,true);
|
||||
}catch(Exception e){
|
||||
log.error("【${leiName}创建接口异常】参数:{}", ${name}Form, e);
|
||||
return ActionResult.fail(MsgCode.FA028.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU001.get());
|
||||
}
|
||||
#end
|
||||
## 编辑
|
||||
#macro(UpdateMethod $leiName)
|
||||
/**
|
||||
* 编辑
|
||||
* @param id
|
||||
* @param ${name}Form
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{id}")
|
||||
@Operation(summary = "更新")
|
||||
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid ${Name}Form ${name}Form,
|
||||
@RequestParam(value = "isImport", required = false) boolean isImport){
|
||||
${Name}Entity entity= ${name}Service.getInfo(id);
|
||||
if(entity!=null){
|
||||
${name}Form.set${peimaryKeyName}(String.valueOf(entity.get${peimaryKeyName}()));
|
||||
|
||||
if (!isImport) {
|
||||
String b = ${name}Service.checkForm(${name}Form,1);
|
||||
if (StringUtil.isNotEmpty(b)){
|
||||
return ActionResult.fail(b );
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
${name}Service.saveOrUpdate(${name}Form,id,false);
|
||||
}catch (DataException e1){
|
||||
return ActionResult.fail(e1.getMessage());
|
||||
}catch(Exception e){
|
||||
log.error("【${leiName}编辑接口异常】参数:{}", ${name}Form, e);
|
||||
return ActionResult.fail(MsgCode.FA029.get());
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU004.get());
|
||||
}else{
|
||||
return ActionResult.fail(MsgCode.FA002.get());
|
||||
}
|
||||
}
|
||||
#end
|
||||
## 获取详情(不转数据)
|
||||
#macro(GetInfoMethod)
|
||||
/**
|
||||
* 获取详情(编辑页)
|
||||
* 编辑页面使用-不转换数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "信息")
|
||||
@GetMapping("/{id}")
|
||||
public ActionResult info(@PathVariable("id") String id){
|
||||
${Name}Entity entity= ${name}Service.getInfo(id);
|
||||
if(entity==null){
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
##
|
||||
#EntityToMap()
|
||||
${name}Map = generaterSwapUtil.swapDataForm(${name}Map,${Name}Constant.getFormData(),${Name}Constant.TABLEFIELDKEY,${Name}Constant.TABLERENAMES);
|
||||
return ActionResult.success(${name}Map);
|
||||
}
|
||||
#end
|
||||
## 详情(转换数据)
|
||||
#macro(GetDetailMethod)
|
||||
/**
|
||||
* 表单信息(详情页)
|
||||
* 详情页面使用-转换数据
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "表单信息(详情页)")
|
||||
@GetMapping("/detail/{id}")
|
||||
public ActionResult detailInfo(@PathVariable("id") String id){
|
||||
${Name}Entity entity= ${name}Service.getInfo(id);
|
||||
if(entity==null){
|
||||
return ActionResult.fail(MsgCode.FA001.get());
|
||||
}
|
||||
#EntityToMap()
|
||||
boolean isPc = "pc".equals(ServletUtil.getHeader("yunzhupaas-origin" ));
|
||||
${name}Map = generaterSwapUtil.swapDataDetail(${name}Map,${Name}Constant.getFormData(),"${VisualDevId}",isPc?${lineEdit}:false);
|
||||
//子表数据
|
||||
#foreach($grid in ${childTableHandle})
|
||||
${name}Map.put("${grid.aliasLowName}List",${name}Map.get("${grid.tableModel}"));
|
||||
#end
|
||||
return ActionResult.success(${name}Map);
|
||||
}
|
||||
#end
|
||||
## 删除
|
||||
#macro(DeleteMethod)
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除")
|
||||
@DeleteMapping("/{id}")
|
||||
#if(${DS})
|
||||
@DSTransactional
|
||||
#else
|
||||
@Transactional
|
||||
#end
|
||||
public ActionResult delete(@PathVariable("id") String id,@RequestParam(name = "forceDel",defaultValue = "false") boolean forceDel) throws Exception{
|
||||
${Name}Entity entity= ${name}Service.getInfo(id);
|
||||
if(entity!=null){
|
||||
#if($isFlow)
|
||||
if(!forceDel){
|
||||
String errMsg = generaterSwapUtil.deleteFlowTask(entity.getFlowTaskId());
|
||||
if (StringUtil.isNotEmpty(errMsg)) {
|
||||
throw new DataException(errMsg);
|
||||
}
|
||||
}
|
||||
#end
|
||||
#if($logicalDelete)
|
||||
//假删除
|
||||
entity.setDeleteMark(1);
|
||||
entity.setDeleteUserId(userProvider.get().getUserId());
|
||||
entity.setDeleteTime(new Date());
|
||||
${name}Service.setIgnoreLogicDelete().updateById(entity);
|
||||
#else
|
||||
//主表数据删除
|
||||
${name}Service.delete(entity);
|
||||
## 副表
|
||||
#if(${columnTableHandle.size()}>0)
|
||||
#foreach($cl in ${columnTableHandle})
|
||||
QueryWrapper<${cl.modelUpName}Entity> queryWrapper${cl.modelUpName}=new QueryWrapper<>();
|
||||
queryWrapper${cl.modelUpName}.lambda().eq(${cl.modelUpName}Entity::get${cl.relationUpField},entity.get${cl.mainUpKey}());
|
||||
//副表数据删除
|
||||
${cl.modelLowName}Service.remove(queryWrapper${cl.modelUpName});
|
||||
#end
|
||||
#end
|
||||
## 子表
|
||||
#foreach($tableModel in ${childTableHandle})
|
||||
#set($mainFeild="${tableModel.relationField}")
|
||||
#set($MainFeild="${tableModel.relationField.substring(0,1).toUpperCase()}${tableModel.relationField.substring(1)}")
|
||||
#set($childFeild="${tableModel.tablefield}")
|
||||
#set($ChildFeild="${tableModel.tablefield.substring(0,1).toUpperCase()}${tableModel.tablefield.substring(1)}")
|
||||
QueryWrapper<${tableModel.aliasUpName}Entity> queryWrapper${tableModel.aliasUpName}=new QueryWrapper<>();
|
||||
queryWrapper${tableModel.aliasUpName}.lambda().eq(${tableModel.aliasUpName}Entity::get${ChildFeild},entity.get${MainFeild}());
|
||||
//子表数据删除
|
||||
${tableModel.aliasLowName}Service.remove(queryWrapper${tableModel.aliasUpName});
|
||||
#end
|
||||
#end
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
#end
|
||||
## 批量删除
|
||||
#macro(BatchRemoveMethod)
|
||||
/**
|
||||
* 批量删除
|
||||
* @param obj
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/batchRemove")
|
||||
#if(${DS})
|
||||
@DSTransactional
|
||||
#else
|
||||
@Transactional
|
||||
#end
|
||||
@Operation(summary = "批量删除")
|
||||
public ActionResult batchRemove(@RequestBody Object obj){
|
||||
$mapObject objectMap = JsonUtil.entityToMap(obj);
|
||||
List<String> idList = JsonUtil.getJsonToList(objectMap.get("ids"), String.class);
|
||||
String errInfo = "";
|
||||
List<String> successList = new ArrayList<>();
|
||||
for (String allId : idList){
|
||||
try {
|
||||
this.delete(allId,false);
|
||||
successList.add(allId);
|
||||
} catch (Exception e) {
|
||||
errInfo = e.getMessage();
|
||||
}
|
||||
}
|
||||
if (successList.size() == 0 && StringUtil.isNotEmpty(errInfo)){
|
||||
return ActionResult.fail(errInfo);
|
||||
}
|
||||
return ActionResult.success(MsgCode.SU003.get());
|
||||
}
|
||||
#end
|
||||
## 批量打印
|
||||
#macro(BatchPrintMethod)
|
||||
#end
|
||||
## 导入
|
||||
#macro(UploaderMethod)
|
||||
@Operation(summary = "上传文件")
|
||||
@PostMapping("/Uploader")
|
||||
public ActionResult<Object> Uploader() {
|
||||
List<MultipartFile> list = UpUtil.getFileAll();
|
||||
MultipartFile file = list.get(0);
|
||||
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
|
||||
String filePath = XSSEscape.escape(configValueUtil.getTemporaryFilePath());
|
||||
String fileName = XSSEscape.escape(RandomUtil.uuId() + "." + UpUtil.getFileType(file));
|
||||
//上传文件
|
||||
#if(${isCloud}=="cloud")
|
||||
FileInfo fileInfo = fileUploadApi.uploadFile(file, filePath, fileName);
|
||||
#else
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(file, filePath, fileName);
|
||||
#end
|
||||
DownloadVO vo = DownloadVO.builder().build();
|
||||
vo.setName(fileInfo.getFilename());
|
||||
return ActionResult.success(vo);
|
||||
} else {
|
||||
return ActionResult.fail(MsgCode.FA017.get());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模板下载
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "模板下载")
|
||||
@GetMapping("/TemplateDownload")
|
||||
public ActionResult<DownloadVO> TemplateDownload(@RequestParam("menuId") String menuId){
|
||||
DownloadVO vo = DownloadVO.builder().build();
|
||||
UserInfo userInfo = userProvider.get();
|
||||
String menuFullName = generaterSwapUtil.getMenuName(menuId);
|
||||
//主表对象
|
||||
List<ExcelExportEntity> entitys = new ArrayList<>();
|
||||
List<String> selectKeys = new ArrayList<>();
|
||||
//以下添加字段
|
||||
## 导入字段添加到entity
|
||||
#foreach($fieldModel in $importFields)
|
||||
#set($config = $fieldModel.config)
|
||||
#set($vModel = ${fieldModel.vModel})
|
||||
#if($vModel.toLowerCase().startsWith("tablefield"))
|
||||
//${vModel}子表对象
|
||||
ExcelExportEntity ${vModel}ExcelEntity = new ExcelExportEntity("${fieldModel.label}(${vModel})","${vModel}");
|
||||
List<ExcelExportEntity> ${vModel}ExcelEntityList = new ArrayList<>();
|
||||
#foreach($child in ${fieldModel.childList})
|
||||
#set($itemFields =$child.fieLdsModel)
|
||||
${vModel}ExcelEntityList.add(new ExcelExportEntity("${itemFields.config.label}($vModel-${itemFields.vModel})" ,"${itemFields.vModel}"));
|
||||
selectKeys.add("$vModel-${itemFields.vModel}");
|
||||
#end
|
||||
${vModel}ExcelEntity.setList(${vModel}ExcelEntityList);
|
||||
if(${vModel}ExcelEntityList.size() > 0){
|
||||
entitys.add(${vModel}ExcelEntity);
|
||||
}
|
||||
#else
|
||||
entitys.add(new ExcelExportEntity("${config.label}($vModel)" ,"$vModel"));
|
||||
selectKeys.add("${vModel}");
|
||||
#end
|
||||
#end
|
||||
ExcelModel excelModel = generaterSwapUtil.getExcelParams(${Name}Constant.getFormData(),selectKeys);
|
||||
List<${mapObject}> list = new ArrayList<>();
|
||||
list.add(excelModel.getDataMap());
|
||||
|
||||
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
|
||||
exportParams.setStyle(ExcelExportStyler.class);
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
try{
|
||||
@Cleanup Workbook workbook = new HSSFWorkbook();
|
||||
if (entitys.size()>0){
|
||||
if (list.size()==0){
|
||||
list.add(new HashMap<>());
|
||||
}
|
||||
//复杂表头-表头和数据处理
|
||||
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(${Name}Constant.getColumnData(), ColumnDataModel.class);
|
||||
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
|
||||
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
|
||||
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
|
||||
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
|
||||
}
|
||||
## excel处理
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
|
||||
ExcelHelper helper = new ExcelHelper();
|
||||
helper.init(workbook, exportParams, entitys, excelModel);
|
||||
helper.doPreHandle();
|
||||
helper.doPostHandle();
|
||||
}
|
||||
String fileName = menuFullName + "导入模板.xls";
|
||||
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
||||
#if(${isCloud}=="cloud")
|
||||
String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY);
|
||||
FileInfo fileInfo = fileUploadApi.uploadFile(multipartFile, temporaryFilePath, fileName);
|
||||
#else
|
||||
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
|
||||
#end
|
||||
vo.setName(fileInfo.getFilename());
|
||||
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
||||
} catch (Exception e) {
|
||||
log.error("模板信息导出Excel错误:{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入预览
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导入预览" )
|
||||
@GetMapping("/ImportPreview")
|
||||
public ActionResult<${mapObject}> ImportPreview(String fileName) throws Exception {
|
||||
${mapObject} headAndDataMap = new HashMap<>(2);
|
||||
#if(${isCloud}=="cloud")
|
||||
String filePath = fileApi.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
|
||||
UploadFileModel uploadFileModel =new UploadFileModel();
|
||||
uploadFileModel.setFolderName(filePath);
|
||||
uploadFileModel.setObjectName(fileName);
|
||||
fileUploadApi.downToLocal(uploadFileModel);
|
||||
#else
|
||||
String filePath = FileUploadUtils.getLocalBasePath() + configValueUtil.getTemporaryFilePath();
|
||||
FileUploadUtils.downLocal(configValueUtil.getTemporaryFilePath(), filePath, fileName);
|
||||
#end
|
||||
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
|
||||
#if($importHasChildren || ${complexFieldList.size()} > 0)
|
||||
int headerRowIndex = 2;
|
||||
#else
|
||||
int headerRowIndex = 1;
|
||||
#end
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(0);
|
||||
params.setHeadRows(headerRowIndex);
|
||||
params.setNeedVerify(true);
|
||||
try {
|
||||
InputStream inputStream = ExcelUtil.solveOrginTitle(temporary, headerRowIndex);
|
||||
List<Map> excelDataList = ExcelUtil.importExcelByInputStream(inputStream, 0, headerRowIndex, Map.class);
|
||||
//数据超过1000条
|
||||
if(excelDataList != null && excelDataList.size() > 1000) {
|
||||
return ActionResult.fail(MsgCode.ETD117.get());
|
||||
}
|
||||
|
||||
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(${Name}Constant.getColumnData(), ColumnDataModel.class);
|
||||
UploaderTemplateModel uploaderTemplateModel = JsonUtil.getJsonToBean(columnDataModel.getUploaderTemplateJson(), UploaderTemplateModel.class);
|
||||
List<String> selectKey = uploaderTemplateModel.getSelectKey();
|
||||
//子表合并
|
||||
List<$mapObject> results = FormExecelUtils.dataMergeChildTable(excelDataList,selectKey);
|
||||
// 导入字段
|
||||
List<ExcelImFieldModel> columns = new ArrayList<>();
|
||||
## 添加导入所有字段信息
|
||||
#foreach($fieldModel in $importFieldsNew)
|
||||
#set($config = $fieldModel.config)
|
||||
#set($vModel = ${fieldModel.vModel})
|
||||
#if($vModel.toLowerCase().startsWith("tablefield"))
|
||||
#if(${fieldModel.childList.size()}>0)
|
||||
//${vModel}子表对象
|
||||
List<ExcelImFieldModel> ${vModel}columns = new ArrayList<>();
|
||||
#foreach($child in ${fieldModel.childList})
|
||||
#set($itemFields =$child.fieLdsModel)
|
||||
${vModel}columns.add(new ExcelImFieldModel("${itemFields.vModel}" ,"#if(${itemFields.config.required})*#end${itemFields.config.label}"));
|
||||
#end
|
||||
columns.add(new ExcelImFieldModel("${vModel}","${fieldModel.label}","table",${vModel}columns));
|
||||
#end
|
||||
#elseif($vModel.contains("complexHeader"))
|
||||
#set($item = ${fieldModel})
|
||||
#if(${item.childColumns.size()}>0 && ${item.uploadFieldList.size()}>0)
|
||||
//${item.fullName} 复杂表头对象
|
||||
List<ExcelImFieldModel> ${item.id}columns = new ArrayList<>();
|
||||
#foreach($itemFields in ${item.uploadFieldList})
|
||||
${item.id}columns.add(new ExcelImFieldModel("${itemFields.vModel}" ,"#if(${itemFields.config.required})*#end${itemFields.label}"));
|
||||
#end
|
||||
columns.add(new ExcelImFieldModel("${item.id}","${item.fullName}","complexHeader",${item.id}columns));
|
||||
#end
|
||||
#else
|
||||
columns.add(new ExcelImFieldModel("${vModel}","${config.label}","${config.yunzhupaasKey}"));
|
||||
#end
|
||||
#end
|
||||
headAndDataMap.put("dataRow" , results);
|
||||
headAndDataMap.put("headerRow" , JsonUtil.getJsonToList(JsonUtil.getListToJsonArray(columns)));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return ActionResult.fail(MsgCode.VS407.get());
|
||||
}
|
||||
return ActionResult.success(headAndDataMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入数据
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导入数据" )
|
||||
@PostMapping("/ImportData")
|
||||
public ActionResult<ExcelImportModel> ImportData(@RequestBody VisualImportModel visualImportModel) throws Exception {
|
||||
List<$mapObject> listData = visualImportModel.getList();
|
||||
ImportFormCheckUniqueModel uniqueModel = new ImportFormCheckUniqueModel();
|
||||
uniqueModel.setDbLinkId(${Name}Constant.DBLINKID);
|
||||
uniqueModel.setUpdate(Objects.equals("${importType}", "2"));
|
||||
#if($isFlow)uniqueModel.setFlowId(visualImportModel.getFlowId()); #end
|
||||
|
||||
Map<String,String> tablefieldkey = new HashMap<>();
|
||||
for(String key:${Name}Constant.TABLEFIELDKEY.keySet()){
|
||||
tablefieldkey.put(key,${Name}Constant.TABLERENAMES.get(${Name}Constant.TABLEFIELDKEY.get(key)));
|
||||
}
|
||||
ExcelImportModel excelImportModel = generaterSwapUtil.importData(${Name}Constant.getFormData(),listData,uniqueModel, tablefieldkey,${Name}Constant.getTableList());
|
||||
List<ImportDataModel> importDataModel = uniqueModel.getImportDataModel();
|
||||
for (ImportDataModel model : importDataModel) {
|
||||
String id = model.getId();
|
||||
$mapObject result = model.getResultData();
|
||||
if(StringUtil.isNotEmpty(id)){
|
||||
update(id, JsonUtil.getJsonToBean(result,${Name}Form.class), true);
|
||||
}else {
|
||||
create(#if($isFlow)RandomUtil.uuId(),#end JsonUtil.getJsonToBean(result,${Name}Form.class));
|
||||
}
|
||||
}
|
||||
return ActionResult.success(excelImportModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出异常报告
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出异常报告")
|
||||
@PostMapping("/ImportExceptionData")
|
||||
public ActionResult<DownloadVO> ImportExceptionData(@RequestBody VisualImportModel visualImportModel) {
|
||||
DownloadVO vo = DownloadVO.builder().build();
|
||||
UserInfo userInfo = userProvider.get();
|
||||
String menuFullName = generaterSwapUtil.getMenuName(visualImportModel.getMenuId());
|
||||
//主表对象
|
||||
List<ExcelExportEntity> entitys = new ArrayList<>();
|
||||
entitys.add(new ExcelExportEntity("异常原因", "errorsInfo",30));
|
||||
List<String> selectKeys = new ArrayList<>();
|
||||
//以下添加字段
|
||||
## 导入字段添加到entity
|
||||
#foreach($fieldModel in $importFields)
|
||||
#set($config = $fieldModel.config)
|
||||
#set($vModel = ${fieldModel.vModel})
|
||||
#if($vModel.toLowerCase().startsWith("tablefield"))
|
||||
//${vModel}子表对象
|
||||
ExcelExportEntity ${vModel}ExcelEntity = new ExcelExportEntity("${fieldModel.label}(${vModel})","${vModel}");
|
||||
List<ExcelExportEntity> ${vModel}ExcelEntityList = new ArrayList<>();
|
||||
#foreach($child in ${fieldModel.childList})
|
||||
#set($itemFields =$child.fieLdsModel)
|
||||
${vModel}ExcelEntityList.add(new ExcelExportEntity("${itemFields.config.label}($vModel-${itemFields.vModel})" ,"${itemFields.vModel}"));
|
||||
selectKeys.add("$vModel-${itemFields.vModel}");
|
||||
#end
|
||||
${vModel}ExcelEntity.setList(${vModel}ExcelEntityList);
|
||||
entitys.add(${vModel}ExcelEntity);
|
||||
#else
|
||||
entitys.add(new ExcelExportEntity("${config.label}($vModel)" ,"$vModel"));
|
||||
selectKeys.add("${vModel}");
|
||||
#end
|
||||
#end
|
||||
ExcelModel excelModel = generaterSwapUtil.getExcelParams(${Name}Constant.getFormData(),selectKeys);
|
||||
List<${mapObject}> list = new ArrayList<>();
|
||||
list.addAll(visualImportModel.getList());
|
||||
|
||||
ExportParams exportParams = new ExportParams(null, menuFullName + "模板");
|
||||
exportParams.setStyle(ExcelExportStyler.class);
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
exportParams.setFreezeCol(1);
|
||||
try{
|
||||
@Cleanup Workbook workbook = new HSSFWorkbook();
|
||||
if (entitys.size()>0){
|
||||
if (list.size()==0){
|
||||
list.add(new HashMap<>());
|
||||
}
|
||||
//复杂表头-表头和数据处理
|
||||
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(${Name}Constant.getColumnData(), ColumnDataModel.class);
|
||||
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
|
||||
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
|
||||
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, false);
|
||||
list = VisualUtils.complexHeaderDataHandel(list, complexHeaderList, false);
|
||||
}
|
||||
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, list);
|
||||
ExcelHelper helper = new ExcelHelper();
|
||||
helper.init(workbook, exportParams, entitys, excelModel);
|
||||
helper.doPreHandle();
|
||||
helper.doPostHandle();
|
||||
}
|
||||
|
||||
String fileName = menuFullName + "错误报告_" + DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
|
||||
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
||||
#if(${isCloud}=="cloud")
|
||||
String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY);
|
||||
FileInfo fileInfo = fileUploadApi.uploadFile(multipartFile, temporaryFilePath, fileName);
|
||||
#else
|
||||
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
|
||||
#end
|
||||
vo.setName(fileInfo.getFilename());
|
||||
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
#end
|
||||
## 导出
|
||||
#macro(ExportMethod)
|
||||
/**
|
||||
* 导出Excel
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "导出Excel")
|
||||
@PostMapping("/Actions/Export")
|
||||
public ActionResult Export(@RequestBody ${Name}Pagination ${name}Pagination) throws IOException {
|
||||
if (StringUtil.isEmpty(${name}Pagination.getSelectKey())){
|
||||
return ActionResult.fail(MsgCode.IMP011.get());
|
||||
}
|
||||
List<${table.entityName}> list= ${serviceName}.getList(${name}Pagination);
|
||||
List<${mapObject}> realList=new ArrayList<>();
|
||||
for (${Name}Entity entity : list) {
|
||||
#EntityToMap()
|
||||
realList.add(${name}Map);
|
||||
}
|
||||
//数据转换
|
||||
realList = generaterSwapUtil.swapDataList(realList, ${Name}Constant.getFormData(), ${Name}Constant.getColumnData(), ${name}Pagination.getModuleId(),${lineEdit});
|
||||
String[]keys=!StringUtil.isEmpty(${name}Pagination.getSelectKey())?${name}Pagination.getSelectKey():new String[0];
|
||||
UserInfo userInfo=userProvider.get();
|
||||
String menuFullName = generaterSwapUtil.getMenuName(${name}Pagination.getMenuId());
|
||||
|
||||
#if(${isCloud}=="cloud")
|
||||
DownloadVO vo=this.creatModelExcel(fileApi.getPath(FileTypeConstant.TEMPORARY),realList,keys,userInfo,menuFullName);
|
||||
#else
|
||||
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo,menuFullName);
|
||||
#end
|
||||
return ActionResult.success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出表格方法
|
||||
*/
|
||||
public DownloadVO creatModelExcel(String path,List<${mapObject}>list,String[]keys,UserInfo userInfo,String menuFullName){
|
||||
DownloadVO vo=DownloadVO.builder().build();
|
||||
List<ExcelExportEntity> entitys=new ArrayList<>();
|
||||
if(keys.length>0){
|
||||
## 子表对象
|
||||
#foreach($cl in $childTableHandle)
|
||||
ExcelExportEntity ${cl.tableModel}ExcelEntity = new ExcelExportEntity("${cl.label}(${cl.tableModel})","${cl.tableModel}");
|
||||
List<ExcelExportEntity> ${cl.tableModel}List = new ArrayList<>();
|
||||
#end
|
||||
#set($lineEditName = "#if(${lineEdit})_name#end")
|
||||
for(String key:keys){
|
||||
switch(key){
|
||||
#if($columnListSize.size()>0)
|
||||
## 主表
|
||||
#foreach($fieldModel in ${mastTableHandle})
|
||||
#set($config = $fieldModel.config)
|
||||
#set($vModel = ${fieldModel.vModel})
|
||||
#if($vModel)
|
||||
case "${vModel}" :
|
||||
entitys.add(new ExcelExportEntity("${config.label}" ,"${vModel}${lineEditName}"));
|
||||
break;
|
||||
#end
|
||||
#end
|
||||
## 副表
|
||||
#foreach($clid in $columnTableHandle)
|
||||
#set($fieLdsModelList = $clid.fieLdsModelList)
|
||||
#foreach($cf in $fieLdsModelList)
|
||||
#set($field = ${cf.field})
|
||||
#if($field)
|
||||
#set($label = $cf.mastTable.fieLdsModel.config.label)
|
||||
#set($lowName= ${cf.table.toLowerCase()})
|
||||
case "${cf.vModel}" :
|
||||
entitys.add(new ExcelExportEntity("${label}" ,"${cf.vModel}${lineEditName}"));
|
||||
break;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
## 子表
|
||||
#foreach($cl in $childTableHandle)
|
||||
#set($clForm = $cl.childList)
|
||||
#foreach($clField in $clForm)
|
||||
#set($clForm = $clField.fieLdsModel)
|
||||
#if($!{clField.fieLdsModel.vModel})
|
||||
case "${cl.tableModel}-${clField.fieLdsModel.vModel}":
|
||||
${cl.tableModel}List.add(new ExcelExportEntity("${clField.fieLdsModel.config.label}" ,"${clField.fieLdsModel.vModel}${lineEditName}"));
|
||||
break;
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
default:
|
||||
break;
|
||||
#end
|
||||
}
|
||||
}
|
||||
#foreach($cl in $childTableHandle)
|
||||
if(${cl.tableModel}List.size() > 0){
|
||||
${cl.tableModel}ExcelEntity.setList(${cl.tableModel}List);
|
||||
entitys.add(${cl.tableModel}ExcelEntity);
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
ExportParams exportParams = new ExportParams(null, "表单信息");
|
||||
exportParams.setType(ExcelType.XSSF);
|
||||
try{
|
||||
@Cleanup Workbook workbook = new HSSFWorkbook();
|
||||
if (entitys.size()>0){
|
||||
if (list.size()==0){
|
||||
list.add(new HashMap<>());
|
||||
}
|
||||
//去除空数据
|
||||
List<$mapObject> dataList = new ArrayList<>();
|
||||
for ($mapObject map : list) {
|
||||
int i = 0;
|
||||
for (String key : keys) {
|
||||
//子表
|
||||
if (key.toLowerCase().startsWith("tablefield")) {
|
||||
String tableField = key.substring(0, key.indexOf("-" ));
|
||||
String field = key.substring(key.indexOf("-" ) + 1);
|
||||
Object o = map.get(tableField);
|
||||
if (o != null) {
|
||||
List<$mapObject> childList = (List<$mapObject>) o;
|
||||
for ($mapObject childMap : childList) {
|
||||
if (childMap.get(field) != null) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Object o = map.get(key);
|
||||
if (o != null) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (i > 0) {
|
||||
dataList.add(map);
|
||||
}
|
||||
}
|
||||
List<ExcelExportEntity> mergerEntitys = new ArrayList<>(entitys);
|
||||
List<$mapObject> mergerList=new ArrayList<>(dataList);
|
||||
//复杂表头-表头和数据处理
|
||||
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(${Name}Constant.getColumnData(), ColumnDataModel.class);
|
||||
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
|
||||
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
|
||||
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
|
||||
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList, Objects.equals(columnDataModel.getType(), 4));
|
||||
}
|
||||
|
||||
exportParams.setStyle(ExcelExportStyler.class);
|
||||
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
|
||||
VisualUtils.mergerVertical(workbook, mergerEntitys, mergerList);
|
||||
## 表格样式添加
|
||||
ExcelModel excelModel = generaterSwapUtil.getExcelParams(${Name}Constant.getFormData(),Arrays.asList(keys));
|
||||
ExcelHelper helper = new ExcelHelper();
|
||||
helper.init(workbook, exportParams, entitys, excelModel);
|
||||
helper.doPreHandle();
|
||||
helper.doPostHandle();
|
||||
}
|
||||
String fileName = menuFullName +"_"+ DateUtil.dateNow("yyyyMMddHHmmss") + ".xls";
|
||||
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
|
||||
#if(${isCloud}=="cloud")
|
||||
String temporaryFilePath = fileApi.getPath(FileTypeConstant.TEMPORARY);
|
||||
FileInfo fileInfo = fileUploadApi.uploadFile(multipartFile, temporaryFilePath, fileName);
|
||||
#else
|
||||
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
|
||||
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
|
||||
#end
|
||||
vo.setName(fileInfo.getFilename());
|
||||
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
|
||||
} catch (Exception e) {
|
||||
log.error("信息导出Excel错误:{}", e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
#end
|
||||
811
TemplateCodeVue3/PublicMacro/DetailMarco.vm
Normal file
811
TemplateCodeVue3/PublicMacro/DetailMarco.vm
Normal file
@@ -0,0 +1,811 @@
|
||||
##详情-表单生成
|
||||
#macro(DetailFormRendering)
|
||||
#foreach($fieLdsModel in ${context.form})
|
||||
#set($yunzhupaasKey = "${fieLdsModel.yunzhupaasKey}")
|
||||
#set($isEnd = "${fieLdsModel.isEnd}")
|
||||
#set($formModel = ${fieLdsModel.formModel})
|
||||
#set($config= $formModel.config)
|
||||
#set($span=$config.span)
|
||||
#set($outermost = ${formModel.outermost})
|
||||
#set($borderType = ${formModel.borderType})
|
||||
#set($borderColor = ${formModel.borderColor})
|
||||
#set($borderWidth = ${formModel.borderWidth})
|
||||
#set($pcshow = $config.pc)
|
||||
#if(${yunzhupaasKey}=='row' && $pcshow == true)
|
||||
#if(${isEnd}=='0')
|
||||
<a-col :span="${formModel.span}" class="ant-col-item">
|
||||
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
|
||||
#else
|
||||
</a-row>
|
||||
</a-col>
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='card' && $pcshow == true)
|
||||
#if(${isEnd}=='0')
|
||||
<a-col #if(${span}) :span="${span}" #else :span="24" #end class="ant-col-item">
|
||||
<a-card class="mb-20" #if(${formModel.shadow}=='hover') hoverable #end>
|
||||
#if(${formModel.header} || ${formModel.headerI18nCode} )
|
||||
<template #title>#if(${formModel.headerI18nCode}) {{t('${formModel.headerI18nCode}','${formModel.header}')}} #else ${formModel.header} #end
|
||||
#if((${formModel.header} || ${formModel.headerI18nCode}) && (${config.tipLabel} || ${config.tipLabelI18nCode}))
|
||||
<BasicHelp #if(${config.tipLabelI18nCode}) :text="t('${config.tipLabelI18nCode}','${config.tipLabel}')" #end text="${config.tipLabel}" />#end
|
||||
</template>
|
||||
#end
|
||||
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
|
||||
#else
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-col>
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='tab' && $pcshow == true)
|
||||
#set($tabs = "a-tabs")
|
||||
#if(${outermost}=='1')
|
||||
#set($tabs = "a-tab-pane")
|
||||
#end
|
||||
#if(${isEnd}=='0')
|
||||
#if(${outermost}=='0')
|
||||
<a-col :span="${formModel.span}" class="ant-col-item">
|
||||
<${tabs} v-model:activeKey="state.${formModel.model}" #if($formModel.type)type="${formModel.type}"#end tabPosition="${formModel.tabPosition}" class="mb-20" >
|
||||
#else
|
||||
<${tabs} #if(${formModel.titleI18nCode}):tab="t('${formModel.titleI18nCode}','${formModel.title}')" #else tab="${formModel.title}"#end key="${formModel.name}" forceRender>
|
||||
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
|
||||
#end
|
||||
#else
|
||||
#if(${outermost}=='0')
|
||||
</${tabs}>
|
||||
</a-col>
|
||||
#else
|
||||
</a-row>
|
||||
</${tabs} >
|
||||
#end
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='tableGrid' || ${yunzhupaasKey}=='tableGridTd' || ${yunzhupaasKey}=='tableGridTr')
|
||||
#set($tabs = "tbody")
|
||||
#set($tableGrid = "table")
|
||||
#if(${yunzhupaasKey}=='tableGridTr')
|
||||
#set($tabs = "tr")
|
||||
#elseif(${yunzhupaasKey}=='tableGridTd')
|
||||
#set($tabs = "")
|
||||
#if(${config.merged}==false)
|
||||
#set($tabs = "td")
|
||||
#end
|
||||
#end
|
||||
#if(${config.pc}==true)
|
||||
#if(${isEnd}=='0')
|
||||
#if(${yunzhupaasKey}=='tableGrid')
|
||||
<${tableGrid} class="table-grid-box" :style='{"--borderType":"${borderType}","--borderColor":"${borderColor}","--borderWidth":"${borderWidth}px"}'>
|
||||
#end
|
||||
#if($tabs)
|
||||
<${tabs}#if(${config.colspan}) colspan="${config.colspan}"#end#if(${config.rowspan}) rowspan="${config.rowspan}"#end>
|
||||
#end
|
||||
#else
|
||||
#if($tabs)
|
||||
</${tabs}>
|
||||
#end
|
||||
#if(${yunzhupaasKey}=='tableGrid')
|
||||
</${tableGrid}>
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='groupTitle' || ${yunzhupaasKey}=='text'|| ${yunzhupaasKey} == 'button' || ${yunzhupaasKey} == 'link' || ${yunzhupaasKey} == 'alert'|| ${yunzhupaasKey} == 'divider')
|
||||
#if($pcshow== true)
|
||||
<a-col :span="${span}" class="ant-col-item">
|
||||
<a-form-item>
|
||||
<${config.tag}
|
||||
#if($formModel.style) :style='${formModel.style}'#end
|
||||
#if($formModel.href) href= "$formModel.href"#end
|
||||
#if($formModel.target) target= "$formModel.target"#end
|
||||
#if($formModel.showIcon) :show-icon= "$formModel.showIcon"#end
|
||||
#if($formModel.align) align="${formModel.align}" #end
|
||||
#if($formModel.disabled) :disabled="${formModel.disabled}" #end
|
||||
#if($formModel.buttonText || $formModel.buttonTextI18nCode) #if(${formModel.buttonTextI18nCode}) :buttonText="t('${formModel.buttonTextI18nCode}', '${formModel.buttonText}')"
|
||||
#else buttonText="${formModel.buttonText}" #end#end
|
||||
#if($formModel.type) type="${formModel.type}" #end
|
||||
#if($formModel.textStyle) :textStyle='${formModel.textStyle}'#end
|
||||
#if($formModel.contentPosition) contentPosition="${formModel.contentPosition}" #end
|
||||
#if(${yunzhupaasKey} == 'alert' && $!{formModel.closable}) :closable= "$formModel.closable" #end
|
||||
#if($formModel.title || $formModel.titleI18nCode) #if(${formModel.titleI18nCode}) :title="t('${formModel.titleI18nCode}', '${formModel.title}')"
|
||||
#else title="${formModel.title}" #end#end
|
||||
#if($formModel.closeText || $formModel.closeTextI18nCode) #if(${formModel.closeTextI18nCode}) :closeText="t('${formModel.closeTextI18nCode}', '${formModel.closeText}')"
|
||||
#else closeText="${formModel.closeText}" #end#end
|
||||
#if($formModel.description || $formModel.descriptionI18nCode) #if(${formModel.descriptionI18nCode}) :description="t('${formModel.descriptionI18nCode}', '${formModel.description}')"
|
||||
#else description="${formModel.description}" #end#end
|
||||
#if(${formModel.helpMessage} || ${formModel.helpMessageI18nCode}) #if(${formModel.helpMessageI18nCode}) :helpMessage ="t('${formModel.helpMessageI18nCode}', '${formModel.helpMessage}')"
|
||||
#else helpMessage="${formModel.helpMessage}" #end #end
|
||||
#if(${formModel.content} || ${formModel.contentI18nCode}) #if(${formModel.contentI18nCode}) :content="t('${formModel.contentI18nCode}', '${formModel.content}')"
|
||||
#else content="${formModel.content}" #end #end>
|
||||
</${config.tag}>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='qrcode' || ${yunzhupaasKey}=='barcode')
|
||||
#if($pcshow== true)
|
||||
<a-col :span="${span}" class="ant-col-item">
|
||||
<a-form-item>
|
||||
#if($config.showLabel)<template #label>#if(${config.labelI18nCode}) {{t('${config.labelI18nCode}','${config.label}')}} #else${config.label} #end
|
||||
#if((${config.label} || ${config.labelI18nCode}) && ${context.labelSuffix})${context.labelSuffix}#end
|
||||
#if((${config.label} || ${config.labelI18nCode}) && (${config.tipLabel} || ${config.tipLabelI18nCode}))
|
||||
<BasicHelp #if(${config.tipLabelI18nCode}) :text="t('${config.tipLabelI18nCode}','${config.tipLabel}')" #else text="${config.tipLabel}" #end />#end</template> #end
|
||||
<${config.tag} #if(${formModel.format}) format='${formModel.format}'#end
|
||||
#if(${formModel.lineColor}) lineColor = "${formModel.lineColor}"#end
|
||||
#if(${formModel.colorLight}) colorLight = "${formModel.colorLight}"#end
|
||||
#if(${formModel.colorDark}) colorDark = "${formModel.colorDark}"#end
|
||||
#if(${formModel.background}) background = "${formModel.background}"#end
|
||||
#if(${formModel.width}) width = "${formModel.width}"#end
|
||||
#if(${formModel.height}) height = "${formModel.height}"#end
|
||||
#if(${formModel.relationField}) :staticText = "dataForm.${formModel.relationField}_id"
|
||||
#else staticText = "${formModel.staticText}"#end >
|
||||
</${config.tag}>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='collapse' && $pcshow == true)
|
||||
#set($collapse = "a-collapse")
|
||||
#if(${outermost}=='1')
|
||||
#set($collapse = "a-collapse-panel")
|
||||
#end
|
||||
#if(${isEnd}=='0')
|
||||
#if(${outermost}=='0')
|
||||
<a-col :span="${formModel.span}" class="ant-col-item">
|
||||
<${collapse} ghost expandIconPosition="right" :accordion="${formModel.accordion}" v-model:activeKey="state.${formModel.model}" class="mb-20">
|
||||
#else
|
||||
<${collapse} #if(${formModel.titleI18nCode}):header="t('${formModel.titleI18nCode}','${formModel.title}')" #else header="${formModel.title}"#end key="${formModel.name}" forceRender>
|
||||
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
|
||||
#end
|
||||
#else
|
||||
#if(${outermost}=='0')
|
||||
</${collapse}>
|
||||
</a-col>
|
||||
#else
|
||||
</a-row>
|
||||
</${collapse}>
|
||||
#end
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='steps' && $pcshow == true)
|
||||
#set($step = "a-steps")
|
||||
#if(${outermost}=='1')
|
||||
#set($step = "a-step")
|
||||
#end
|
||||
#if(${isEnd}=='0')
|
||||
#if(${outermost}=='0')
|
||||
<a-col :span="${formModel.span}" class="ant-col-item">
|
||||
<a-steps type=#if($!{formModel.simple}) 'navigation' #else 'default' #end status="${formModel.processStatus}" v-model:current="state.${formModel.model}" class="mb-10px">
|
||||
#foreach($itemStep in $config.children)
|
||||
<a-step #if(${itemStep.titleI18nCode}) :title="t('${itemStep.titleI18nCode}','${itemStep.title}')" #else title="${itemStep.title}" #end key="${itemStep.name}">
|
||||
#if($!{itemStep.icon})
|
||||
<template #icon>
|
||||
<span class="${itemStep.icon} custom-icon"></span>
|
||||
</template>
|
||||
#end
|
||||
</a-step>
|
||||
#end
|
||||
</a-steps>
|
||||
#else
|
||||
<a-row key="${formModel.name}" class="!pt-12px w-full" v-show="${config.childNum} == state.${formModel.model}" :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
|
||||
#end
|
||||
#else
|
||||
#if(${outermost}=='0')
|
||||
</a-col>
|
||||
#else
|
||||
</a-row>
|
||||
#end
|
||||
#end
|
||||
#elseif(${yunzhupaasKey}=='mast' || ${yunzhupaasKey}=='mastTable')
|
||||
#DetailMastTable(${yunzhupaasKey})
|
||||
#elseif($yunzhupaasKey == 'table')
|
||||
#DetailChildTable()
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
##详情-主副标签生成
|
||||
#macro(DetailMastTable $tableType)
|
||||
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
|
||||
#set($beforeVmodel =${html.vModel})
|
||||
## 副表参数
|
||||
#if($tableType=='mastTable')
|
||||
#set($html = $fieLdsModel.formMastTableModel.mastTable.fieLdsModel)
|
||||
#set($beforeVmodel =${fieLdsModel.formMastTableModel.vModel})
|
||||
#end
|
||||
#set($vModel = "${html.vModel}")
|
||||
#set($mastModel="${context.formModel}.${beforeVmodel}")
|
||||
#set($config = $html.config)
|
||||
#set($mastKey = "${config.yunzhupaasKey}")
|
||||
#set($show = $config.noShow)
|
||||
#set($pcshow = $config.pc)
|
||||
#set($startTime=${html.startTime})
|
||||
#set($endTime=${html.endTime})
|
||||
## 时间处理
|
||||
#if(${mastKey}=='datePicker'||${mastKey}=='timePicker')
|
||||
## #GetStartAndEndTime($mastKey,$config,$html,$startTime,$endTime)
|
||||
#end
|
||||
#if($show == false && $pcshow == true && ${mastKey}!='calculate')
|
||||
<a-col :span="${config.span}" class="ant-col-item" #if(${context.columnData.useFormPermission}) #if(${vModel}) v-if="hasFormP('${beforeVmodel}')"
|
||||
#elseif($mastKey == 'relationFormAttr' || $mastKey == 'popupAttr') v-if="hasFormP('${html.relationField}')" #end #end >
|
||||
<a-form-item #if($config.showLabel == true) #if($config.labelWidth && ${context.labelPosition}!="top") :labelCol="{ style: { width: '${config.labelWidth}px' } }"#end
|
||||
#else :labelCol="{ style: { width: '0px' } }"#end #if($vModel) name="${beforeVmodel}" #end>
|
||||
#if($config.showLabel)<template #label>#if(${config.labelI18nCode}) {{t('${config.labelI18nCode}','${config.label}')}} #else${config.label} #end
|
||||
#if((${config.label} || ${config.labelI18nCode}) && ${context.labelSuffix})${context.labelSuffix}#end
|
||||
#if((${config.label} || ${config.labelI18nCode}) && (${config.tipLabel} || ${config.tipLabelI18nCode}))
|
||||
<BasicHelp #if(${config.tipLabelI18nCode}) :text="t('${config.tipLabelI18nCode}','${config.tipLabel}')" #else text="${config.tipLabel}" #end />#end</template> #end
|
||||
#DetailFieldTag($mastKey,$html,$config,$mastModel,$beforeVmodel,-1)
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
#end
|
||||
#end
|
||||
## 详情-生成字段标签
|
||||
#macro(DetailFieldTag $mastKey,$html,$config,$mastModel,$beforeVmodel,$index)
|
||||
#if($DetailTag.contains($mastKey))
|
||||
<${config.tag} #if($mastModel && $mastKey!='iframe') v-model:value="${mastModel}"#end
|
||||
#if($mastKey!='text')
|
||||
#if(${html.placeholder} || ${html.placeholderI18nCode}) #if(${html.placeholderI18nCode}) :placeholder="t('${html.placeholderI18nCode}', '${html.placeholder}')"
|
||||
#else placeholder="${html.placeholder}" #end #end
|
||||
#else
|
||||
#if($config.defaultValue) value="${config.defaultValue}"#end
|
||||
#end
|
||||
#if($html.maxlength) :maxlength="${html.maxlength}" #end disabled
|
||||
#if($mastKey =='uploadFile' || $mastKey =='uploadImg' || $mastKey =='inputNumber' || $mastKey =='calculate'
|
||||
|| $mastKey =='sign' || $mastKey =='input' || $mastKey =='location' || $mastKey =='signature') detailed #end
|
||||
#if($html.readonly == true ) readonly #end
|
||||
#if($html.clearable == true ) allowClear #end
|
||||
#if($html.prefixIcon) prefix-icon='${html.prefixIcon}' #end
|
||||
#if($html.suffixIcon) suffix-icon='${html.suffixIcon}' #end
|
||||
#if($html.style) :style='${html.style}'#end
|
||||
#if($html.showWordLimit == true ) ${html.showWordLimit} #end
|
||||
#if($html.size) size="${html.size}" #end
|
||||
#if($html.min) :min="${html.min}" #end
|
||||
#if($html.max) :max="${html.max}" #end
|
||||
#if($html.count) :count="${html.count}" #end
|
||||
#if($html.type) type="${html.type}" #end
|
||||
#if($html.autoSize) :autoSize='${html.autoSize}' #end
|
||||
#if($html.step) :step="${html.step}" #end
|
||||
#if($html.precision) :precision="${html.precision}" #end
|
||||
#if($html.stepstrictly==true) stepstrictly #end
|
||||
#if($html.textStyle) :textStyle='${html.textStyle}' #end
|
||||
#if($html.lineHeight) :lineHeight="${html.lineHeight}" #end
|
||||
#if($html.fontSize) :fontSize="${html.fontSize}" #end
|
||||
#if($html.controls) :controls="${html.controls}" #end
|
||||
#if($html.showChinese) :showChinese="${html.showChinese}" #end
|
||||
#if($html.showPassword) show-password #end
|
||||
#if($html.filterable || $html.filterable=='false') :showSearch='${html.filterable}' #end
|
||||
#if($html.multiple) :multiple="${html.multiple}" #end
|
||||
#if($html.separator) separator="${html.separator}" #end
|
||||
#if($html.isrange==true) is-range #end
|
||||
#if($html.rangeseparator) range-separator="${html.rangeseparator}" #end
|
||||
## #if($html.startplaceholder) start-placeholder="${html.startplaceholder}" #end
|
||||
## #if($html.endplaceholder) end-placeholder="${html.endplaceholder}" #end
|
||||
#if($html.format) format="${html.format}" #end
|
||||
#if($html.colorformat) color-format="${html.colorformat}" #end
|
||||
#if($html.valueformat) value-format="${html.valueformat}" #end
|
||||
#if($html.activetext) active-text="${html.activetext}" #end
|
||||
#if($html.inactivetext) inactive-text="${html.inactivetext}" #end
|
||||
#if($html.activecolor) active-color="${html.activecolor}" #end
|
||||
#if($html.inactivecolor) inactive-color="${html.inactivecolor}" #end
|
||||
#if($html.activevalue) :active-value="${html.activevalue}" #end
|
||||
#if($html.inactivevalue) :inactive-value="${html.inactivevalue}" #end
|
||||
#if($html.pickeroptions) :picker-options='${html.pickeroptions}'#end
|
||||
#if($html.showScore == true ) show-score #end
|
||||
#if($html.showText == true ) show-text #end
|
||||
#if($html.allowhalf == true ) allow-half #end
|
||||
#if($html.showAlpha == true ) show-alpha #end
|
||||
#if($html.showStops == true ) show-stops #end
|
||||
#if($html.range == true ) range #end
|
||||
#if($html.showTip == true ) :showTip="${html.showTip}" #end
|
||||
#if($html.accept) accept="${html.accept}" #end
|
||||
#if($html.fileSize) :fileSize="${html.fileSize}" #end
|
||||
#if($html.sizeUnit) sizeUnit="${html.sizeUnit}" #end
|
||||
#if($html.limit) :limit="${html.limit}" #end
|
||||
#if($html.pathType) pathType="${html.pathType}" #end
|
||||
#if($html.sortRule) :sortRule='${html.sortRule}' #end
|
||||
#if($html.timeFormat) timeFormat="${html.timeFormat}" #end
|
||||
#if($html.folder) folder="${html.folder}" #end
|
||||
#if($html.buttonText || $html.buttonTextI18nCode) #if(${html.buttonTextI18nCode}) :buttonText="t('${html.buttonTextI18nCode}', '${html.buttonText}')"
|
||||
#else buttonText="${html.buttonText}" #end#end
|
||||
#if($html.contentposition) content-position="${html.contentposition}" #end
|
||||
#if($html.isAmountChinese) isAmountChinese #end
|
||||
#if($html.thousands) thousands #end
|
||||
#if($html.addonAfter) addonAfter="${html.addonAfter}" #end
|
||||
#if($html.addonBefore) addonBefore="${html.addonBefore}" #end
|
||||
#if($html.level || $html.level=='0') :level=${html.level} #end
|
||||
#if($html.href) href = "$html.href"#end
|
||||
#if($html.height) :height = "$html.height"#end
|
||||
#if($html.useMask) :useMask = "${html.useMask}"#end
|
||||
#if($html.maskConfig) :maskConfig = "maskConfig.${beforeVmodel}"#end
|
||||
#if($html.autoLocation) :autoLocation = "$html.autoLocation" #end
|
||||
#if($html.enableLocationScope) :enableLocationScope = "$html.enableLocationScope" #end
|
||||
#if($html.adjustmentScope) :adjustmentScope = "$html.adjustmentScope" #end
|
||||
#if($html.enableDesktopLocation) :enableDesktopLocation = "$html.enableDesktopLocation" #end
|
||||
#if($html.locationScope) :locationScope = "state.locationScope.${beforeVmodel}" #end
|
||||
#if($html.borderType) borderType = "$html.borderType" #end
|
||||
#if($html.borderColor) borderColor = "$html.borderColor" #end
|
||||
#if($html.borderWidth) :borderWidth = "$html.borderWidth" #end
|
||||
>
|
||||
</${config.tag}>
|
||||
#else
|
||||
#if(${mastKey} == 'relationFormAttr' || ${mastKey} == 'popupAttr')
|
||||
#if(${html.isStorage} == 0)
|
||||
#if($index=="index")
|
||||
#set($mastModel = "record.${html.relationField}_${html.showField}")
|
||||
#else
|
||||
#set($mastModel = "${context.formModel}.${html.relationField}_${html.showField}")
|
||||
#end
|
||||
|
||||
#end
|
||||
#end
|
||||
#if($dataType=='static')
|
||||
<p>{{ ${mastModel} }} </p>
|
||||
#else
|
||||
#if(${mastKey} == 'relationForm')
|
||||
<p class="link-text leading-32px" @click="toDetail('${html.modelId}', ${mastModel}_id,'${html.propsValue}')">{{ ${mastModel} }}</p>
|
||||
#elseif(${mastKey} == 'popupSelect')
|
||||
<p class="leading-32px">{{${mastModel}}}</p>
|
||||
#elseif(${mastKey} == 'input')
|
||||
<p>#if($html.slot.prepend)${html.slot.prepend}#end{{${mastModel}}}#if($html.slot.append)${html.slot.append}#end</p>
|
||||
#elseif(${mastKey} == 'editor')
|
||||
## 副文本内放标签
|
||||
<div v-html="${mastModel}"></div>
|
||||
#elseif(${mastKey} == 'calculate' && ${html.isStorage} == 0)
|
||||
<${config.tag}
|
||||
#if($index == 'index') :rowIndex="index"#end :formData="${context.formModel}"
|
||||
#if($html.expression) :expression ='${html.expression}' #end
|
||||
#if($html.isAmountChinese) isAmountChinese #end
|
||||
#if($html.thousands) thousands #end
|
||||
#if($html.precision) :precision="${html.precision}" #end
|
||||
detailed ></${config.tag}>
|
||||
#else
|
||||
<p>{{${mastModel}}}</p>
|
||||
#end
|
||||
## 关联表单和弹窗选择 展示详情
|
||||
#if($index!="index" && (${mastKey} == 'relationForm' || ${mastKey} == 'popupSelect'))
|
||||
<ExtraRelationInfo :extraOptions="state.extraOptions.${beforeVmodel}" :data="state.extraData.${beforeVmodel}"
|
||||
v-if="state.extraOptions.${beforeVmodel}?.length && state.extraData.${beforeVmodel} && JSON.stringify(state.extraData.${beforeVmodel}) !== '{}'" />
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
##详情-子表生成
|
||||
#macro(DetailChildTable)
|
||||
#set($child = $fieLdsModel.childList)
|
||||
#set($aliasname = "")
|
||||
#foreach($children in ${context.children})
|
||||
#if(${children.tableModel}==${child.tableModel})
|
||||
#set($aliasname = "${children.aliasLowName}")
|
||||
#set($aliasName = "${children.aliasUpName}")
|
||||
#end
|
||||
#end
|
||||
<a-col :span="${child.span}" class="ant-col-item mb-20px" #if(${context.columnData.useFormPermission})v-if="hasFormP('${child.tableModel}')"#end>
|
||||
#if($!{child.layoutType} == 'list')
|
||||
## 子表平铺
|
||||
<div class="yunzhupaas-child-list" >
|
||||
<a-collapse expandIconPosition="right" :bordered="false" class="outer-collapse" v-model:activeKey="state.${aliasname}outerActiveKey">
|
||||
<a-collapse-panel forceRender>
|
||||
<template #header>
|
||||
<span class="min-h-22px inline-block">#if($child.showTitle== true)#if(${child.labelI18nCode}) {{t('${child.labelI18nCode}','${child.label}')}} #else ${child.label} #end#end</span>
|
||||
#if($child.showTitle== true && $child.tipLabel)<BasicHelp #if(${child.tipLabelI18nCode}) :text="t('${child.tipLabelI18nCode}','${child.tipLabel}')" #else text="${child.tipLabel}" #end />#end
|
||||
</template>
|
||||
<a-collapse :bordered="false" v-model:activeKey="state.${aliasname}innerActiveKey">
|
||||
<template #expandIcon="{ isActive }">
|
||||
<CaretRightOutlined :rotate="isActive ? 90 : 0" />
|
||||
</template>
|
||||
<a-collapse-panel v-for="(record, index) in dataForm.${aliasname}List" :key="record.yunzhupaasId" forceRender>
|
||||
<template #header>
|
||||
<span class="min-h-22px inline-block">#if(${child.labelI18nCode}) {{t('${child.labelI18nCode}','${child.label}')}} #else ${child.label} #end({{ index + 1 }})</span>
|
||||
</template>
|
||||
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
|
||||
#foreach($itemModel in ${child.childList})
|
||||
#set($fieLdsModel = ${itemModel.fieLdsModel})
|
||||
#set($config = ${fieLdsModel.config})
|
||||
#set($mastKey = "${config.yunzhupaasKey}")
|
||||
#set($vModel="${fieLdsModel.vModel}")
|
||||
#set($mastModel="dataForm.${aliasname}List[index].${vModel}")
|
||||
#set($beforeVmodel ="${aliasname}${fieLdsModel.vModel}")
|
||||
#set($startTime=${fieLdsModel.startTime})
|
||||
#set($endTime=${fieLdsModel.endTime})
|
||||
#if(${mastKey}=='datePicker'||${mastKey}=='timePicker')
|
||||
#GetStartAndEndTime($mastKey,$config,$fieLdsModel,$startTime,$endTime)
|
||||
#end
|
||||
#if(${config.noShow} == false && ${config.pc}==true && ${config.yunzhupaasKey}!='calculate')
|
||||
<a-col :span="${config.span}" class="ant-col-item" #if(${context.columnData.useFormPermission})v-if="hasFormP('${child.tableModel}-${fieLdsModel.vModel}')"#end>
|
||||
<a-form-item #if($config.labelWidth && ${context.labelPosition}!="top") :labelCol="{ style: { width: '${config.labelWidth}px' } }"#end
|
||||
#if($vModel) :name="['${aliasname}List', index, '${vModel}']" #end>
|
||||
<template #label>#if(${config.labelI18nCode}) {{t('${config.labelI18nCode}','${config.label}')}} #else ${config.label} #end
|
||||
#if((${config.label} || ${config.labelI18nCode}) && (${config.tipLabel} || ${config.tipLabelI18nCode}))
|
||||
<BasicHelp #if(${config.tipLabelI18nCode}) :text="t('${config.tipLabelI18nCode}','${config.tipLabel}')"#else text="${config.tipLabel}"#end />#end
|
||||
</template>
|
||||
## 子表标签生成
|
||||
#DetailFieldTag($mastKey,$fieLdsModel,$config,$mastModel,$beforeVmodel,'index',true)
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
#end
|
||||
#end
|
||||
</a-row>
|
||||
</a-collapse-panel>
|
||||
#if($child.showSummary)
|
||||
#set($childSummary=true)
|
||||
#set($summaryField = '[]')
|
||||
#if(${child.summaryField})
|
||||
#set($summaryField = ${child.summaryField})
|
||||
#end
|
||||
<a-collapse-panel key="summary" v-if="dataForm.${aliasname}List?.length">
|
||||
<template #header>
|
||||
<span class="min-h-22px inline-block">{{ t('component.table.summary') }}</span>
|
||||
</template>
|
||||
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
|
||||
<template v-for="(column, cIndex) in ${aliasname}Columns" :key="column.key">
|
||||
<a-col :span="column.span" class="ant-col-item" v-if='${summaryField}.includes(column.key)'>
|
||||
<a-form-item #if(${context.labelPosition}!="top") :labelCol="{ style: { width: (column.labelWidth||'${context.labelWidth}')+'px' } }"#end>
|
||||
<template #label>{{column.title}}<BasicHelp v-if="column.title && column.tipLabel" :text="column.tipLabel" /></template>
|
||||
<yunzhupaasInput :value="get${aliasName}ColumnSum[cIndex]" disabled detailed :style="column.style" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</template>
|
||||
</a-row>
|
||||
</a-collapse-panel>
|
||||
#end
|
||||
</a-collapse>
|
||||
</a-collapse-panel>
|
||||
</a-collapse>
|
||||
</div>
|
||||
#else
|
||||
## 子表表格
|
||||
<a-form-item>
|
||||
#if($child.showTitle== true)
|
||||
<yunzhupaasGroupTitle #if(${child.labelI18nCode}) :content="t('${child.labelI18nCode}', '${child.label}')" #else content="${child.label}" #end :bordered="false"
|
||||
#if(${child.tipLabelI18nCode}) :helpMessage="t('${child.tipLabelI18nCode}', '${child.tipLabel}')" #else helpMessage="${child.tipLabel}" #end />
|
||||
#end
|
||||
<a-table :data-source="dataForm.${child.tableModel}" #if(${child.complexHeaderList.size()}>0) :bordered="true" #end
|
||||
:columns="${aliasname}Columns" size="small" :pagination="false" :scroll="{ x: 'max-content' }">
|
||||
<template #headerCell="{ column }">
|
||||
<span class="required-sign" v-if="column.required">*</span>
|
||||
{{ column.title }}
|
||||
<BasicHelp :text="column.tipLabel" v-if="column.tipLabel && column.title" />
|
||||
</template>
|
||||
## 子表字段
|
||||
<template #bodyCell="{ column, index, record }">
|
||||
<template v-if="column.key === 'index'">{{ index + 1 }}</template>
|
||||
#foreach($itemModel in ${child.childList})
|
||||
#set($fieLdsModel = ${itemModel.fieLdsModel})
|
||||
#set($config = ${fieLdsModel.config})
|
||||
#set($mastKey = "${config.yunzhupaasKey}")
|
||||
#set($beforeVmodel ="${aliasname}${fieLdsModel.vModel}")
|
||||
#set($mastModel="record.${fieLdsModel.vModel}")
|
||||
#if(${mastKey}!='calculate')
|
||||
<template v-if="column.key === #if($!{fieLdsModel.vModel}) '${fieLdsModel.vModel}' #else '${config.formId}' #end">
|
||||
## 子表标签生成
|
||||
#DetailFieldTag($mastKey,$fieLdsModel,$config,$mastModel,$beforeVmodel,'index')
|
||||
</template>
|
||||
#end
|
||||
#end
|
||||
</template>
|
||||
## 子表合计
|
||||
#if($child.showSummary)
|
||||
#set($childSummary=true)
|
||||
<template #summary v-if="dataForm.${child.tableModel}?.length">
|
||||
<a-table-summary fixed>
|
||||
<a-table-summary-row>
|
||||
<a-table-summary-cell :index="0">{{ t('component.table.summary') }}</a-table-summary-cell>
|
||||
<a-table-summary-cell v-for="(item, index) in get${aliasName}ColumnSum" :key="index" :index="index + 1" :align="get${aliasName}SummaryCellAlign(index)">{{ item }}</a-table-summary-cell>
|
||||
<a-table-summary-cell :index="get${aliasName}ColumnSum.length + 1"></a-table-summary-cell>
|
||||
</a-table-summary-row>
|
||||
</a-table-summary>
|
||||
</template>
|
||||
#end
|
||||
</a-table>
|
||||
</a-form-item>
|
||||
#end
|
||||
</a-col>
|
||||
#end
|
||||
## 子表字段对象列表生成
|
||||
#macro(DetailChildTableColumns)
|
||||
## 子表列表字段属性
|
||||
#foreach($itemModel in ${context.children})
|
||||
const ${itemModel.aliasLowName}Columns: any[] = computed(() => {
|
||||
let list = [
|
||||
#set($childList = ${itemModel.childList})
|
||||
#foreach($html in ${childList})
|
||||
#set($fieLdsModel = ${html.fieLdsModel})
|
||||
#set($config = ${fieLdsModel.config})
|
||||
#if(!${config.noShow} && ${config.yunzhupaasKey}!='calculate')
|
||||
{
|
||||
title: #if(${config.labelI18nCode}) t('${config.labelI18nCode}','${config.label}') #else '${config.label}' #end,
|
||||
dataIndex: #if($!{fieLdsModel.vModel}) '${fieLdsModel.vModel}' #else '${config.formId}' #end,
|
||||
key: #if($!{fieLdsModel.vModel}) '${fieLdsModel.vModel}' #else '${config.formId}' #end,
|
||||
#if($!{config.columnWidth})
|
||||
width: $!{config.columnWidth},
|
||||
#end
|
||||
labelWidth:#if($!{config.labelWidth})'$!{config.labelWidth}' #else '' #end,
|
||||
span:'$!{config.span}',
|
||||
tipLabel: #if($!{config.tipLabel}|| ${config.tipLabelI18nCode})#if(${config.tipLabelI18nCode}) t('${config.tipLabelI18nCode}','${config.tipLabel}') #else '${config.tipLabel}' #end #else '' #end,
|
||||
#set($vModelRequired="#if($!{fieLdsModel.vModel})${itemModel.aliasLowName}List-${fieLdsModel.vModel}#else${itemModel.aliasLowName}List-${config.formId}#end")
|
||||
required: false,
|
||||
#if($!{fieLdsModel.thousands}==true)
|
||||
thousands: ${fieLdsModel.thousands},
|
||||
#end
|
||||
style: #if(${fieLdsModel.style})${fieLdsModel.style} #else ''#end,
|
||||
align: #if($!{config.tableAlign}) '$!{config.tableAlign}'#else 'left'#end,
|
||||
fixed: #if($!{config.tableFixed} == 'left' || $!{config.tableFixed} == 'right') '$!{config.tableFixed}' #else false #end,
|
||||
formP: #if($!{fieLdsModel.vModel}) '${fieLdsModel.vModel}' #else '${fieLdsModel.relationField}' #end,
|
||||
},
|
||||
#end
|
||||
#end
|
||||
];
|
||||
##子表行内按键操作字段判断是否生成。及其宽度
|
||||
#if($context.isFlow)
|
||||
list = list.filter(o => judgeShow('${itemModel.aliasLowName}List-' + o.formP));
|
||||
#else
|
||||
#if(${context.columnData.useFormPermission})list = list.filter(o => hasFormP('${itemModel.tableModel}-' + o.formP)); #end
|
||||
#end
|
||||
## 表格子表和平铺子表代码区别
|
||||
#if($!{itemModel.layoutType} == 'list')
|
||||
return list;
|
||||
#else
|
||||
const indexColumn = { title: '序号', showLabel: true, dataIndex: 'index', key: 'index', align: 'center', fixed: 'left', width: 50 };
|
||||
//子表复杂表头-处理
|
||||
let columnList = list;
|
||||
let complexHeaderList: any[] = #if(${itemModel.complexHeaderList}) ${itemModel.complexHeaderList}; #else []; #end
|
||||
if (complexHeaderList.length) {
|
||||
let childColumns: any[] = [];
|
||||
let firstChildColumns: string[] = [];
|
||||
for (let i = 0; i < complexHeaderList.length; i++) {
|
||||
const e = complexHeaderList[i];
|
||||
e.title = e.fullNameI18nCode ? t(e.fullNameI18nCode,e.fullName) : e.fullName;
|
||||
e.align = e.align;
|
||||
e.children = [];
|
||||
e.yunzhupaasKey = 'complexHeader';
|
||||
if (e.childColumns?.length) {
|
||||
childColumns.push(...e.childColumns);
|
||||
for (let k = 0; k < e.childColumns.length; k++) {
|
||||
const item = e.childColumns[k];
|
||||
for (let j = 0; j < list.length; j++) {
|
||||
const o = list[j];
|
||||
if (o.key == item && o.fixed !== 'left' && o.fixed !== 'right') e.children.push({ ...o });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.children.length) firstChildColumns.push(e.children[0].key);
|
||||
}
|
||||
complexHeaderList = complexHeaderList.filter(o => o.children.length);
|
||||
let newList: any[] = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
const e = list[i];
|
||||
if (!childColumns.includes(e.key) || e.fixed === 'left' || e.fixed === 'right') {
|
||||
newList.push(e);
|
||||
} else {
|
||||
if (firstChildColumns.includes(e.key)) {
|
||||
const item = complexHeaderList.find(o => o.childColumns.includes(e.key));
|
||||
newList.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
columnList = newList;
|
||||
}
|
||||
let columns = [indexColumn, ...columnList]
|
||||
const leftFixedList = columns.filter(o => o.fixed === 'left');
|
||||
const rightFixedList = columns.filter(o => o.fixed === 'right');
|
||||
const noFixedList = columns.filter(o => o.fixed !== 'left' && o.fixed !== 'right');
|
||||
return [...leftFixedList, ...noFixedList, ...rightFixedList];
|
||||
#end
|
||||
});
|
||||
## 子表合计参数
|
||||
#if($itemModel.showSummary)
|
||||
//子表合计字段
|
||||
const ${itemModel.aliasLowName}SummaryColumn = computed(() => {
|
||||
let defaultColumns = unref(${itemModel.aliasLowName}Columns);//子表字段
|
||||
let columns: any[] = [];
|
||||
for (let i = 0; i < defaultColumns.length; i++) {
|
||||
const e = defaultColumns[i];
|
||||
if (e.yunzhupaasKey === 'table' || e.yunzhupaasKey === 'complexHeader') {
|
||||
if (e.children?.length) columns.push(...e.children);
|
||||
} else {
|
||||
columns.push(e);
|
||||
}
|
||||
if (e.fixed && e.children?.length) {
|
||||
for (let j = 0; j < e.children.length; j++) {
|
||||
e.children[j].fixed = e.fixed;
|
||||
}
|
||||
}
|
||||
}
|
||||
return columns.filter(o => o?.key != 'index' && o?.key != 'action');
|
||||
});
|
||||
//合计方法
|
||||
const get${itemModel.aliasUpName}ColumnSum = computed(() => {
|
||||
const sums: any[] = [];
|
||||
const summaryField: any[] = #if(${itemModel.summaryField}) ${itemModel.summaryField} #else [] #end;
|
||||
const useThousands = key => unref(${itemModel.aliasLowName}SummaryColumn).some(o => o.key === key && o.thousands);
|
||||
const isSummary = key => summaryField.includes(key);
|
||||
const list = unref(${itemModel.aliasLowName}SummaryColumn).filter(o => o.key !== 'index' && o.key !== 'action');
|
||||
list.forEach((column, index) => {
|
||||
let sumVal = state.dataForm.${itemModel.tableModel}.reduce((sum, d) => sum + + Number(getCmpValOfRow(d, column.key, summaryField || [])), 0);
|
||||
if (!isSummary(column.key)) sumVal = '';
|
||||
sumVal = Number.isNaN(sumVal) ? '' : sumVal;
|
||||
const realVal = sumVal && !Number.isInteger(Number(sumVal)) ? Number(sumVal).toFixed(2) : sumVal;
|
||||
sums[index] = useThousands(column.key) ? thousandsFormat(realVal) : realVal.toString();
|
||||
});
|
||||
return sums;
|
||||
});
|
||||
|
||||
//合计对齐
|
||||
function get${itemModel.aliasUpName}SummaryCellAlign(index) {
|
||||
if (!unref(${itemModel.aliasLowName}SummaryColumn).length) return;
|
||||
return unref(${itemModel.aliasLowName}SummaryColumn)[index]?.align || 'left';
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
## 生成掩码配置
|
||||
#macro(CreateMaskConfig)
|
||||
{
|
||||
#foreach($fieLdsModel in ${context.fields})
|
||||
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
|
||||
#set($vModel = "${html.vModel}")
|
||||
#set($config = $html.config)
|
||||
#set($yunzhupaaskey = $config.yunzhupaasKey)
|
||||
#if($yunzhupaaskey == "input")
|
||||
${vModel}:#if(${html.maskConfig}) ${html.maskConfig} #else {}#end,
|
||||
#end
|
||||
#end
|
||||
#foreach($child in ${context.children})
|
||||
#set($aliasname = "${child.aliasLowName}")
|
||||
#foreach($fieLdsModel in ${child.childList})
|
||||
#set($html = $fieLdsModel.fieLdsModel)
|
||||
#set($vModel = "${html.vModel}")
|
||||
#set($config = $html.config)
|
||||
#set($yunzhupaaskey = $config.yunzhupaasKey)
|
||||
#if($yunzhupaaskey == "input")
|
||||
${aliasname}${vModel}:#if(${html.maskConfig}) ${html.maskConfig} #else {}#end,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#foreach($ChildField in ${context.columnChildren})
|
||||
#foreach($FormMastTableModel in ${ChildField.fieLdsModelList})
|
||||
#set($html = ${FormMastTableModel.mastTable.fieLdsModel})
|
||||
#set($yunzhupaasKey = ${html.config.yunzhupaasKey})
|
||||
#set($ChildVmodel =${FormMastTableModel.vModel})
|
||||
#if(${yunzhupaasKey} == "input")
|
||||
${ChildVmodel}:#if(${html.maskConfig}) ${html.maskConfig} #else {}#end,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
## 生成定位配置
|
||||
#macro(CreateLocationScope)
|
||||
{
|
||||
#foreach($fieLdsModel in ${context.fields})
|
||||
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
|
||||
#set($vModel = "${html.vModel}")
|
||||
#set($config = $html.config)
|
||||
#set($yunzhupaaskey = $config.yunzhupaasKey)
|
||||
#if($yunzhupaaskey == "location")
|
||||
${vModel}:#if(${html.locationScope}) ${html.locationScope} #else []#end,
|
||||
#end
|
||||
#end
|
||||
#foreach($child in ${context.children})
|
||||
#set($aliasname = "${child.aliasLowName}")
|
||||
#foreach($fieLdsModel in ${child.childList})
|
||||
#set($html = $fieLdsModel.fieLdsModel)
|
||||
#set($vModel = "${html.vModel}")
|
||||
#set($config = $html.config)
|
||||
#set($yunzhupaaskey = $config.yunzhupaasKey)
|
||||
#if($yunzhupaaskey == "location")
|
||||
${aliasname}${vModel}:#if(${html.locationScope}) ${html.locationScope} #else []#end,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#foreach($ChildField in ${context.columnChildren})
|
||||
#foreach($FormMastTableModel in ${ChildField.fieLdsModelList})
|
||||
#set($html = ${FormMastTableModel.mastTable.fieLdsModel})
|
||||
#set($yunzhupaasKey = ${html.config.yunzhupaasKey})
|
||||
#set($ChildVmodel =${FormMastTableModel.vModel})
|
||||
#if(${yunzhupaasKey} == "location")
|
||||
${ChildVmodel}:#if(${html.locationScope}) ${html.locationScope} #else []#end,
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
## 生成关联表单和弹窗展示配置
|
||||
#macro(CreateExtraOptions)
|
||||
{
|
||||
#foreach($fieLdsModel in ${context.fields})
|
||||
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
|
||||
#set($vModel = "${html.vModel}")
|
||||
#set($yunzhupaaskey = $html.config.yunzhupaasKey)
|
||||
#if($yunzhupaaskey == "relationForm" || $yunzhupaaskey == "popupSelect")
|
||||
${vModel}:[#foreach($options in ${html.extraOptions}) {"label":"${options.label}","value":"${options.value}"},#end],
|
||||
#end
|
||||
#end
|
||||
#foreach($ChildField in ${context.columnChildren})
|
||||
#foreach($FormMastTableModel in ${ChildField.fieLdsModelList})
|
||||
#set($html = ${FormMastTableModel.mastTable.fieLdsModel})
|
||||
#set($yunzhupaasKey = ${html.config.yunzhupaasKey})
|
||||
#set($ChildVmodel =${FormMastTableModel.vModel})
|
||||
#if(${yunzhupaasKey} == "relationForm" || ${yunzhupaasKey} == "popupSelect")
|
||||
${ChildVmodel}:[#foreach($options in ${html.extraOptions}) {"label":"${options.label}","value":"${options.value}"},#end],
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
## 生成关联表单和弹窗展示配置
|
||||
#macro(CreateExtraData)
|
||||
{
|
||||
#foreach($fieLdsModel in ${context.fields})
|
||||
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
|
||||
#set($vModel = "${html.vModel}")
|
||||
#set($yunzhupaaskey = $html.config.yunzhupaasKey)
|
||||
#if($yunzhupaaskey == "relationForm" || $yunzhupaaskey == "popupSelect")
|
||||
${vModel}:{},
|
||||
#end
|
||||
#end
|
||||
#foreach($ChildField in ${context.columnChildren})
|
||||
#foreach($FormMastTableModel in ${ChildField.fieLdsModelList})
|
||||
#set($html = ${FormMastTableModel.mastTable.fieLdsModel})
|
||||
#set($yunzhupaasKey = ${html.config.yunzhupaasKey})
|
||||
#set($ChildVmodel =${FormMastTableModel.vModel})
|
||||
#if(${yunzhupaasKey} == "relationForm" || ${yunzhupaasKey} == "popupSelect")
|
||||
${ChildVmodel}:{},
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#macro(ExtraInfoFun)
|
||||
#foreach($fieLdsModel in ${context.form})
|
||||
#if($fieLdsModel.yunzhupaasKey != 'table')
|
||||
#if($fieLdsModel.yunzhupaasKey =='mast')
|
||||
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
|
||||
#set($vModel =${html.vModel})
|
||||
#else
|
||||
#set($html = ${fieLdsModel.formMastTableModel.mastTable.fieLdsModel})
|
||||
#set($vModel =${fieLdsModel.formMastTableModel.vModel})
|
||||
#end
|
||||
#set($yunzhupaaskey = ${html.config.yunzhupaasKey})
|
||||
#if($yunzhupaaskey == "relationForm")
|
||||
function get${vModel}ExtraInfo(){
|
||||
if (!state.dataForm.${vModel}_id) return;
|
||||
let query: any = {
|
||||
id: state.dataForm.${vModel}_id,
|
||||
#if(${html.propsValue})propsValue: '${html.propsValue}'#end
|
||||
};
|
||||
getDataChange('${html.modelId}', query).then(res => {
|
||||
if (!res.data || !res.data.data) return;
|
||||
const data = JSON.parse(res.data.data);
|
||||
state.extraData.${vModel} = data;
|
||||
});
|
||||
}
|
||||
#end
|
||||
#if($yunzhupaaskey == "popupSelect")
|
||||
function get${vModel}ExtraInfo() {
|
||||
if (!state.dataForm.${vModel}_id) return;
|
||||
const paramList = getParamList('${vModel}');
|
||||
const query = {
|
||||
ids: [state.dataForm.${vModel}_id],
|
||||
interfaceId: '${html.interfaceId}',
|
||||
propsValue: '${html.propsValue}',
|
||||
relationField: '${html.relationField}',
|
||||
paramList,
|
||||
};
|
||||
getDataInterfaceDataInfoByIds('${html.interfaceId}', query).then(res => {
|
||||
const data = res.data && res.data.length ? res.data[0] : {};
|
||||
state.extraData.${vModel} = data;
|
||||
});
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#macro(runAllExtraFun)
|
||||
#foreach($fieLdsModel in ${context.form})
|
||||
#if($fieLdsModel.yunzhupaasKey != 'table')
|
||||
#if($fieLdsModel.yunzhupaasKey =='mast')
|
||||
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
|
||||
#set($vModel =${html.vModel})
|
||||
#else
|
||||
#set($html = ${fieLdsModel.formMastTableModel.mastTable.fieLdsModel})
|
||||
#set($vModel =${fieLdsModel.formMastTableModel.vModel})
|
||||
#end
|
||||
#set($yunzhupaaskey = ${html.config.yunzhupaasKey})
|
||||
#if($yunzhupaaskey == "relationForm" || $yunzhupaaskey == "popupSelect")
|
||||
get${vModel}ExtraInfo();
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
33
TemplateCodeVue3/PublicMacro/ExcelMarco.vm
Normal file
33
TemplateCodeVue3/PublicMacro/ExcelMarco.vm
Normal file
@@ -0,0 +1,33 @@
|
||||
#macro(CreateExcelFields $html,$index)
|
||||
#set($vModel = ${html.vModel})
|
||||
#set($config = ${html.config})
|
||||
#set($yunzhupaaskey = "${config.yunzhupaasKey}")
|
||||
/** ${config.label} **/
|
||||
@JSONField(name = "${vModel}")
|
||||
@Excel(name = "${config.label}(${vModel})",orderNum = "1", isImportField = "true" )
|
||||
#if(${yunzhupaaskey}=='inputNumber' || ${yunzhupaaskey}=='calculate' )
|
||||
#if($!{fieLdsModel.formColumnModel.fieLdsModel.precision})
|
||||
private String ${vModel};
|
||||
|
||||
#else
|
||||
private String ${vModel};
|
||||
|
||||
#end
|
||||
#elseif(${yunzhupaaskey}=='slider'|| ${yunzhupaaskey}=='rate')
|
||||
private String ${vModel};
|
||||
|
||||
#elseif(${yunzhupaaskey}=='modifyTime' || ${yunzhupaaskey}=='createTime')
|
||||
private String ${vModel};
|
||||
|
||||
#elseif(${yunzhupaaskey}=='datePicker')
|
||||
#set($pattern = "yyyy-MM-dd")
|
||||
#if(${html.format})
|
||||
#set($pattern = "${html.format}")
|
||||
#end
|
||||
private String ${vModel};
|
||||
|
||||
#else
|
||||
private String ${vModel};
|
||||
|
||||
#end
|
||||
#end
|
||||
1955
TemplateCodeVue3/PublicMacro/FormMarco.vm
Normal file
1955
TemplateCodeVue3/PublicMacro/FormMarco.vm
Normal file
File diff suppressed because it is too large
Load Diff
972
TemplateCodeVue3/PublicMacro/ServiceImpMarco.vm
Normal file
972
TemplateCodeVue3/PublicMacro/ServiceImpMarco.vm
Normal file
@@ -0,0 +1,972 @@
|
||||
##通用参数
|
||||
#parse("PublicMacro/ConstantMarco.vm")
|
||||
#ConstantParams()
|
||||
#set($mapObject ="Map<String, Object>")
|
||||
##创建QueryWrapper
|
||||
#macro(CreateWrapper)
|
||||
MPJLambdaWrapper<${Entity}> wrapper = JoinWrappers
|
||||
#foreach($item in $allTableNameList)
|
||||
#set($TableEntity = "${item.table.substring(0,1).toUpperCase()}${item.table.substring(1)}")
|
||||
#if(${item.tableTag} =='main')
|
||||
.lambda("${item.initName}",${TableEntity}Entity.class)
|
||||
#end
|
||||
#if(${item.tableTag} =='sub-yunzhupaas')
|
||||
.selectAssociation(${TableEntity}Entity.class,${Entity}::get${TableEntity})
|
||||
.leftJoin(${TableEntity}Entity.class,"${item.initName}",${TableEntity}Entity::get${item.tableField},${Entity}::get${item.relationField})
|
||||
#end
|
||||
#if(${item.tableTag} =='sub')
|
||||
.selectCollection(${TableEntity}Entity.class,${Entity}::get${TableEntity})
|
||||
.leftJoin(${TableEntity}Entity.class,"${item.initName}",${TableEntity}Entity::get${item.tableField},${Entity}::get${item.relationField})
|
||||
#end
|
||||
#end
|
||||
.selectAll(${Name}Entity.class);
|
||||
#end
|
||||
##创建QueryWrapper2
|
||||
#macro(CreateWrapper2)
|
||||
MPJLambdaWrapper<${Entity}> wrapper2 = JoinWrappers
|
||||
#foreach($item in $allTableNameList)
|
||||
#set($TableEntity = "${item.table.substring(0,1).toUpperCase()}${item.table.substring(1)}")
|
||||
#if(${item.tableTag} =='main')
|
||||
.lambda("${item.initName}",${TableEntity}Entity.class)
|
||||
#end
|
||||
#if(${item.tableTag} =='sub-yunzhupaas')
|
||||
.leftJoin(${TableEntity}Entity.class,"${item.initName}",${TableEntity}Entity::get${item.tableField},${Entity}::get${item.relationField})
|
||||
#end
|
||||
#if(${item.tableTag} =='sub')
|
||||
.leftJoin(${TableEntity}Entity.class,"${item.initName}",${TableEntity}Entity::get${item.tableField},${Entity}::get${item.relationField})
|
||||
#end
|
||||
#end
|
||||
.distinct().select(${Name}Entity::get${peimaryKeyName});
|
||||
#end
|
||||
##权限查询条件拼接
|
||||
#macro(CreateDataPermission $menuIdModel)
|
||||
boolean pcPermission = ${pcDataPermisson};
|
||||
boolean appPermission = ${appDataPermisson};
|
||||
if(isPc && pcPermission){
|
||||
if (!userProvider.get().getIsAdministrator()){
|
||||
#foreach($child in ${allTableNameList})
|
||||
#set($ModelName= "${child.table.substring(0,1).toUpperCase()}${child.table.substring(1)}")
|
||||
#set($modelName ="${child.table.substring(0,1).toLowerCase()}${child.table.substring(1)}")
|
||||
#set($modelNum = "${modelName}Num")
|
||||
#set($initName = "${child.initName}")
|
||||
#set($modelQueryWrapper = "${modelName}QueryWrapper")
|
||||
#if(!${child.tableField})
|
||||
Object ${modelName}Obj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(${modelQueryWrapper},${ModelName}Entity.class,${menuIdModel}.getMenuId(),#if(${DS})"${DS}"#else"0"#end));
|
||||
if (ObjectUtil.isEmpty(${modelName}Obj)){
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
${modelQueryWrapper} = (QueryWrapper<${ModelName}Entity>)${modelName}Obj;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
}
|
||||
}
|
||||
if(!isPc && appPermission){
|
||||
if (!userProvider.get().getIsAdministrator()){
|
||||
#foreach($child in ${allTableNameList})
|
||||
#set($ModelName= "${child.table.substring(0,1).toUpperCase()}${child.table.substring(1)}")
|
||||
#set($modelName ="${child.table.substring(0,1).toLowerCase()}${child.table.substring(1)}")
|
||||
#set($modelNum = "${modelName}Num")
|
||||
#set($modelQueryWrapper = "${modelName}QueryWrapper")
|
||||
#if($child.tableTag =='main')
|
||||
Object ${modelName}Obj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(${modelQueryWrapper},${ModelName}Entity.class,${menuIdModel}.getMenuId(),#if(${DS})"${DS}"#else"0"#end));
|
||||
if (ObjectUtil.isEmpty(${modelName}Obj)){
|
||||
return new ArrayList<>();
|
||||
} else {
|
||||
${modelQueryWrapper} = (QueryWrapper<${ModelName}Entity>)${modelName}Obj;
|
||||
}
|
||||
#end
|
||||
|
||||
#end
|
||||
}
|
||||
}
|
||||
#end
|
||||
##普通查询条件拼接
|
||||
#macro(PaginationSerach)
|
||||
#if($groupModels.size()>0)
|
||||
if(isPc){
|
||||
#foreach($Group in ${groupModels})
|
||||
#set($ModelName= "${Group.modelName.substring(0,1).toUpperCase()}${Group.modelName.substring(1)}")
|
||||
#set($ModelNameEntity = "${ModelName}Entity")
|
||||
#set($modelName ="${Group.modelName.substring(0,1).toLowerCase()}${Group.modelName.substring(1)}")
|
||||
#set($modelQueryWrapper ="wrapper")
|
||||
#set($modelNum = "${modelName}Num")
|
||||
#set($ForeignKey =${Group.ForeignKey})
|
||||
#PaginationQuery(${Group.searchTypeModelList},${modelQueryWrapper},${ModelNameEntity},${modelNum})
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#if($groupAppModels.size()>0)
|
||||
if(!isPc){
|
||||
#foreach($appGroup in ${groupAppModels})
|
||||
#set($ModelName= "${appGroup.modelName.substring(0,1).toUpperCase()}${appGroup.modelName.substring(1)}")
|
||||
#set($ModelNameEntity = "${ModelName}Entity")
|
||||
#set($modelName ="${appGroup.modelName.substring(0,1).toLowerCase()}${appGroup.modelName.substring(1)}")
|
||||
#set($modelQueryWrapper ="wrapper")
|
||||
#set($modelNum = "${modelName}Num")
|
||||
#set($ForeignKey =${appGroup.ForeignKey})
|
||||
#PaginationQuery(${appGroup.searchTypeModelList},${modelQueryWrapper},${ModelNameEntity},${modelNum})
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
##普通查询条件拼接
|
||||
#macro(PaginationQuery $searchListSizes $queryWrapper $ModelNameEntity,$modelNum)
|
||||
#if($searchListSizes)
|
||||
#foreach($SearchTypeModel in ${searchListSizes})
|
||||
#set($vModelName = "${SearchTypeModel.afterVModel}")
|
||||
#set($fieldAliasName = "${SearchTypeModel.afterVModel}")
|
||||
#set($tableAliasName = "${SearchTypeModel.tableAliasName}")
|
||||
#if($SearchTypeModel.id.contains("_yunzhupaas_"))
|
||||
#set($fieldAliasName = "yunzhupaas_${tableAliasName}_yunzhupaas_${vModelName}")
|
||||
#elseif($SearchTypeModel.id.toLowerCase().startsWith("tablefield"))
|
||||
#set($fieldAliasName = "${tableAliasName}_${vModelName}")
|
||||
#end
|
||||
#set($fieldName = "${vModelName.substring(0,1).toUpperCase()}${vModelName.substring(1)}")
|
||||
#set($paginationName ="${fieldAliasName.substring(0,1).toUpperCase()}${fieldAliasName.substring(1)}")
|
||||
if(ObjectUtil.isNotEmpty(${name}Pagination.get${paginationName}())){
|
||||
#if(${SearchTypeModel.searchType}==1)
|
||||
#set($yunzhupaasKey=${SearchTypeModel.yunzhupaasKey})
|
||||
## 多选统一处理
|
||||
#MultipleHandle("${name}Pagination")
|
||||
#elseif(${SearchTypeModel.searchType}==2)
|
||||
String value = ${name}Pagination.get${paginationName}() instanceof List ?
|
||||
JsonUtil.getObjectToString(${name}Pagination.get${paginationName}()) :
|
||||
String.valueOf(${name}Pagination.get${paginationName}());
|
||||
${queryWrapper}.like(${ModelNameEntity}::get${fieldName},value);
|
||||
#elseif(${SearchTypeModel.searchType}==3)
|
||||
List ${fieldName}List = JsonUtil.getJsonToList(${name}Pagination.get${paginationName}(),String.class);
|
||||
for(int i=0;i<${fieldName}List.size();i++){
|
||||
String id = String.valueOf(${fieldName}List.get(i));
|
||||
boolean idAll = StringUtil.isNotEmpty(id) && !id.equals("null");
|
||||
if(idAll){
|
||||
#set($dataValues= "id;")
|
||||
#if(${SearchTypeModel.yunzhupaasKey}=="dateTime" || ${SearchTypeModel.yunzhupaasKey}=='datePicker' || ${SearchTypeModel.yunzhupaasKey}=="createTime" || ${SearchTypeModel.yunzhupaasKey}=="modifyTime")
|
||||
#set($dataValues= "new Date(Long.valueOf(id));")
|
||||
#elseif(${SearchTypeModel.yunzhupaasKey}=="inputNumber" || ${SearchTypeModel.yunzhupaasKey}=="calculate")
|
||||
#set($dataValues= "new BigDecimal(id);")
|
||||
#end
|
||||
Object b= ${dataValues}
|
||||
if(i==0){
|
||||
${queryWrapper}.ge(${ModelNameEntity}::get${fieldName},b);
|
||||
}else{
|
||||
${queryWrapper}.le(${ModelNameEntity}::get${fieldName},b);
|
||||
}
|
||||
}
|
||||
}
|
||||
#end
|
||||
}
|
||||
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
##多选统一处理
|
||||
#macro(MultipleHandle $pagination)
|
||||
#if(${multipleUnit.contains(${yunzhupaasKey})})
|
||||
List<String> idList = new ArrayList<>();
|
||||
try {
|
||||
String[][] ${vModelName} = JsonUtil.getJsonToBean(${pagination}.get${paginationName}(),String[][].class);
|
||||
for(int i=0;i<${vModelName}.length;i++){
|
||||
if(${vModelName}[i].length>0){
|
||||
idList.add(JsonUtil.getObjectToString(Arrays.asList(${vModelName}[i])));
|
||||
}
|
||||
}
|
||||
}catch (Exception e1){
|
||||
try {
|
||||
List<String> ${vModelName} = JsonUtil.getJsonToList(${pagination}.get${paginationName}(),String.class);
|
||||
if(${vModelName}.size()>0){
|
||||
#if(${multipleTwoUnit.contains(${yunzhupaasKey})})
|
||||
idList.add(JsonUtil.getObjectToString(${vModelName}));
|
||||
#elseif(${yunzhupaasKey} =='currOrganize')
|
||||
idList.add(${vModelName}.get(${vModelName}.size()-1));
|
||||
#else
|
||||
idList.addAll(${vModelName});
|
||||
#end
|
||||
}
|
||||
}catch (Exception e2){
|
||||
idList.add(String.valueOf(${pagination}.get${paginationName}()));
|
||||
}
|
||||
}
|
||||
${queryWrapper}.and(t->{
|
||||
idList.forEach(tt->{
|
||||
if(StringUtil.isNotEmpty(tt) && "Microsoft SQL Server".equalsIgnoreCase(databaseName)){
|
||||
tt = tt.replaceFirst("\\[","[[]");
|
||||
}
|
||||
t.like(${ModelNameEntity}::get${fieldName}, tt).or();
|
||||
});
|
||||
});
|
||||
#else
|
||||
${queryWrapper}.eq(${ModelNameEntity}::get${fieldName},${pagination}.get${paginationName}());
|
||||
#end
|
||||
#end
|
||||
##关键词搜索
|
||||
#macro(yunzhupaasKeywordSerach)
|
||||
if(ObjectUtil.isNotEmpty(${name}Pagination.getYunzhupaasKeyword())){
|
||||
#if($!{keywordModels})
|
||||
if(isPc){
|
||||
wrapper.and(t -> {
|
||||
#foreach($Group in ${groupModels})
|
||||
#set($ModelName= "${Group.modelName.substring(0,1).toUpperCase()}${Group.modelName.substring(1)}")
|
||||
#set($ModelNameEntity = "${ModelName}Entity")
|
||||
#foreach($item in ${Group.searchTypeModelList})
|
||||
#if($item.afterVModel)
|
||||
#set($vModelName = $item.afterVModel)
|
||||
#else
|
||||
#set($vModelName = $item.id)
|
||||
#end
|
||||
#set($fieldName = "${vModelName.substring(0,1).toUpperCase()}${vModelName.substring(1)}")
|
||||
#if(${item.isKeyword})
|
||||
t.like(${ModelName}Entity::get${fieldName},${name}Pagination.getyunzhupaasKeyword()).or();
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
});
|
||||
}
|
||||
#end
|
||||
#if($!{keywordAppModels})
|
||||
if(!isPc){
|
||||
wrapper.and(t -> {
|
||||
#foreach($Group in ${groupAppModels})
|
||||
#set($ModelName= "${Group.modelName.substring(0,1).toUpperCase()}${Group.modelName.substring(1)}")
|
||||
#set($ModelNameEntity = "${ModelName}Entity")
|
||||
#foreach($item in ${Group.searchTypeModelList})
|
||||
#if($item.afterVModel)
|
||||
#set($vModelName = $item.afterVModel)
|
||||
#else
|
||||
#set($vModelName = $item.id)
|
||||
#end
|
||||
#set($fieldName = "${vModelName.substring(0,1).toUpperCase()}${vModelName.substring(1)}")
|
||||
#if(${item.isKeyword})
|
||||
t.like(${ModelName}Entity::get${fieldName},${name}Pagination.getyunzhupaasKeyword()).or();
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
});
|
||||
|
||||
}
|
||||
#end
|
||||
}
|
||||
#end
|
||||
##获取系统参数
|
||||
#macro(GetSystemData $isSave $chidKeyName)
|
||||
#if(${systemyunzhupaasKey.contains(${key})})
|
||||
#set($opFlag = true)
|
||||
#if((${key}=='createUser' && !$isSave)
|
||||
||(${key}=='createTime' && !$isSave)
|
||||
||(${key}=='modifyUser' && $isSave)
|
||||
||(${key}=='modifyTime' && $isSave)
|
||||
||(${key}=='currOrganize' && !$isSave)
|
||||
||(${key}=='currPosition' && !$isSave))
|
||||
#set($opFlag = false)
|
||||
#end
|
||||
#if($isFlow && $opFlag)
|
||||
if(hasOperate.contains("${realVmodel}") || noOperate){
|
||||
#end
|
||||
#if(${key}=='createUser')
|
||||
#if($isSave)
|
||||
${nameEntity}.set${model}(userInfo.getUserId());
|
||||
#else
|
||||
${nameEntity}.set${model}(null);
|
||||
#end
|
||||
#elseif(${key}=='createTime')
|
||||
#if($isSave)
|
||||
${nameEntity}.set${model}(DateUtil.getNowDate());
|
||||
#else
|
||||
${nameEntity}.set${model}(null);
|
||||
#end
|
||||
#elseif(${key}=='modifyUser')
|
||||
#if($isSave)
|
||||
${nameEntity}.set${model}(null);
|
||||
#else
|
||||
${nameEntity}.set${model}(userInfo.getUserId());
|
||||
#end
|
||||
#elseif(${key}=='modifyTime')
|
||||
#if($isSave)
|
||||
${nameEntity}.set${model}(null);
|
||||
#else
|
||||
${nameEntity}.set${model}(DateUtil.getNowDate());
|
||||
#end
|
||||
#elseif(${key}=='currOrganize')
|
||||
#if($isSave)
|
||||
${nameEntity}.set${model}(generaterSwapUtil.getCurrentOrgIds(userInfo.getOrganizeId(),#if(${showLevel})"${showLevel}"#else"all"#end));
|
||||
#else
|
||||
${nameEntity}.set${model}(null);
|
||||
#end
|
||||
#elseif(${key}=='currPosition')
|
||||
#if($isSave)
|
||||
${nameEntity}.set${model}(StringUtil.isNotEmpty(userEntity.getPositionId()) ? userEntity.getPositionId() : null);
|
||||
#else
|
||||
${nameEntity}.set${model}(null);
|
||||
#end
|
||||
#elseif(${key}=='billRule')
|
||||
#if($isSave)
|
||||
#if($config.ruleType == 2)
|
||||
${nameEntity}.set${model}(generaterSwapUtil.getBillNumber2("${VisualDevId}","${config.formId}",${Name}Constant.${constantVmodel}, ${name}Form));
|
||||
#else
|
||||
${nameEntity}.set${model}(generaterSwapUtil.getBillNumber("${rule}", false));
|
||||
#end
|
||||
#else
|
||||
if(StringUtil.isEmpty(${nameEntity}.get${model}()) #if(${chidKeyName})|| ${nameEntity}.get${chidKeyName}() == null #end){
|
||||
#if($config.ruleType == 2)
|
||||
${nameEntity}.set${model}(generaterSwapUtil.getBillNumber2("${VisualDevId}","${config.formId}",${Name}Constant.${constantVmodel}, ${name}Form));
|
||||
#else
|
||||
${nameEntity}.set${model}(generaterSwapUtil.getBillNumber("${rule}", false));
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#if($isFlow && $opFlag)
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
## 正则验证方法
|
||||
#macro(RegMethod $yunzhupaasKey,$param $config)
|
||||
#if(!${lineEdit})
|
||||
#if($yunzhupaasKey == 'input' && ${config.regList} && ${config.regList.size()}>0)
|
||||
if(StringUtil.isNotEmpty($param)){
|
||||
#foreach($regItem in ${config.regList})
|
||||
#set($pattern=$regItem.pattern.replace("\","\\").replace("/",""))
|
||||
if(!Pattern.compile("$pattern").matcher(String.valueOf($param)).matches()){
|
||||
return #if(${regItem.messageI18nCode})I18nUtil.getMessageStr("${regItem.messageI18nCode}", "${regItem.message}"); #else "${regItem.message}"; #end
|
||||
}
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
##########################以上为宏调用,以下为实际方法##########################
|
||||
## 列表接口
|
||||
#macro(GetTypeList)
|
||||
@Override
|
||||
public List<${Entity}> getList(${Name}Pagination ${name}Pagination){
|
||||
return getTypeList(${name}Pagination,${name}Pagination.getDataType());
|
||||
}
|
||||
/** 列表查询 */
|
||||
@Override
|
||||
public List<${Entity}> getTypeList(${Name}Pagination ${name}Pagination,String dataType){
|
||||
String userId=userProvider.get().getUserId();
|
||||
Map<String,Class> tableClassMap=new HashMap<>();
|
||||
#foreach($item in $allTableNameList)
|
||||
#set($TableEntity = "${item.table.substring(0,1).toUpperCase()}${item.table.substring(1)}")
|
||||
tableClassMap.put("${item.initName}",${TableEntity}Entity.class);
|
||||
#end
|
||||
|
||||
## 生成MPJLambdaWrapper对象
|
||||
#CreateWrapper()
|
||||
#CreateWrapper2()
|
||||
|
||||
QueryAllModel queryAllModel = new QueryAllModel();
|
||||
queryAllModel.setWrapper(wrapper);
|
||||
queryAllModel.setClassMap(tableClassMap);
|
||||
queryAllModel.setDbLink(${Name}Constant.DBLINKID);
|
||||
## 数据过滤
|
||||
//数据过滤
|
||||
boolean isPc = ServletUtil.getHeader("yunzhupaas-origin").equals("pc");
|
||||
String columnData = !isPc ? ${Name}Constant.getAppColumnData() : ${Name}Constant.getColumnData();
|
||||
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
|
||||
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
|
||||
queryAllModel.setRuleJson(ruleJson);
|
||||
## 高级查询
|
||||
//高级查询
|
||||
boolean hasSuperQuery = #if($superQuery) true#else false#end;
|
||||
if (hasSuperQuery) {
|
||||
queryAllModel.setSuperJson(${name}Pagination.getSuperQueryJson());
|
||||
}
|
||||
## 数据权限
|
||||
//数据权限
|
||||
boolean pcPermission = ${pcDataPermisson};
|
||||
boolean appPermission = ${appDataPermisson};
|
||||
if (isPc && pcPermission) {
|
||||
queryAllModel.setModuleId(${name}Pagination.getMenuId());
|
||||
}
|
||||
if (!isPc && appPermission) {
|
||||
queryAllModel.setModuleId(${name}Pagination.getMenuId());
|
||||
}
|
||||
//拼接复杂条件
|
||||
wrapper = generaterSwapUtil.getConditionAllTable(queryAllModel);
|
||||
if(wrapper == null) return new ArrayList<>();
|
||||
queryAllModel.setWrapper(wrapper2);
|
||||
wrapper2 = generaterSwapUtil.getConditionAllTable(queryAllModel);
|
||||
## 普通查询
|
||||
//其他条件拼接
|
||||
otherConditions(${name}Pagination, wrapper, isPc);
|
||||
otherConditions(${name}Pagination, wrapper2, isPc);
|
||||
|
||||
#if(${groupTable} == true || ${treeTable} == true || ${hasPage} == false)
|
||||
//分组和树形生成这个代码,pc端返回全部数据 !"2".equals(dataType)导出选中数据
|
||||
if(isPc && !"2".equals(dataType)){
|
||||
dataType = "1";
|
||||
}
|
||||
#end
|
||||
if("0".equals(dataType)){
|
||||
com.github.pagehelper.Page<Object> objects = PageHelper.startPage((int) ${name}Pagination.getCurrentPage(), (int) ${name}Pagination.getPageSize(), true);
|
||||
List<${Entity}> userIPage = this.selectJoinList(${Entity}.class, wrapper2);
|
||||
List<Object> collect = userIPage.stream().map(t -> t.get${peimaryKeyName}()).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(collect)){
|
||||
wrapper.in(${Entity}::get${peimaryKeyName},collect);
|
||||
}
|
||||
List<${Entity}> result = this.selectJoinList(${Entity}.class, wrapper);
|
||||
return ${name}Pagination.setData(result,objects.getTotal());
|
||||
}else{
|
||||
List<${Entity}> list = this.selectJoinList(${Entity}.class, wrapper);
|
||||
if("2".equals(dataType)){
|
||||
List<Object> selectIds = Arrays.asList(${name}Pagination.getSelectIds());
|
||||
return list.stream().filter(t -> selectIds.contains(t.get$peimaryKeyName())).collect(Collectors.toList());
|
||||
}else{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 其他条件拼接
|
||||
*/
|
||||
private void otherConditions(${Name}Pagination ${name}Pagination, MPJLambdaWrapper<${Entity}> wrapper, boolean isPc) {
|
||||
String databaseName;
|
||||
try {
|
||||
@Cleanup Connection cnn = DynamicDataSourceUtil.getCurrentConnection();
|
||||
databaseName = cnn.getMetaData().getDatabaseProductName().trim();
|
||||
} catch (SQLException e) {
|
||||
throw new DataException(e.getMessage());
|
||||
}
|
||||
#if($logicalDelete)
|
||||
//假删除标志
|
||||
wrapper.isNull(${Entity}::getDeleteMark);
|
||||
|
||||
#end
|
||||
#if($isFlow)
|
||||
//流程数据隔离
|
||||
List<String> flowIds = generaterSwapUtil.getFlowIds(${name}Pagination.getFlowId());
|
||||
wrapper.in(${Entity}::getFlowId,flowIds);
|
||||
#else
|
||||
wrapper.isNull(${Entity}::getFlowId);
|
||||
#end
|
||||
//关键词
|
||||
#yunzhupaasKeywordSerach()
|
||||
//普通查询
|
||||
#PaginationSerach()
|
||||
//排序
|
||||
if(StringUtil.isEmpty(${name}Pagination.getSidx())){
|
||||
#if(${defaultSidx})
|
||||
#set($model = "${defaultSidx.substring(0,1).toUpperCase()}${defaultSidx.substring(1)}")
|
||||
#set($Sort = "${sort.substring(0,1).toUpperCase()}${sort.substring(1)}")
|
||||
wrapper.orderBy${Sort}(${Entity}::get${model});
|
||||
#else
|
||||
wrapper.orderByDesc(${Entity}::get${peimaryKeyName});
|
||||
#end
|
||||
}else{
|
||||
try {
|
||||
String[] split = ${name}Pagination.getSidx().split(",");
|
||||
for(String sidx:split){
|
||||
#if($lineEdit)
|
||||
sidx = sidx.split("_name")[0];
|
||||
#end
|
||||
${Entity} ${name}Entity = new ${Entity}();
|
||||
String oderTableField = ${name}Entity.getClass().getAnnotation(TableName.class).value();
|
||||
boolean descFlag = sidx.startsWith("-");
|
||||
String sidxField = descFlag ? sidx.substring(1) : sidx;
|
||||
try{
|
||||
Field declaredField = ${name}Entity.getClass().getDeclaredField(sidxField);
|
||||
declaredField.setAccessible(true);
|
||||
sidxField = declaredField.getAnnotation(TableField.class).value();
|
||||
}catch (Exception e){
|
||||
}
|
||||
String finalOderTableField = oderTableField;
|
||||
String finalSidxField = sidxField;
|
||||
Object select = wrapper.getSelectColumns().stream().filter(t -> Objects.equals(finalOderTableField, t.getTableAlias())
|
||||
&& Objects.equals(finalSidxField, t.getColumn())).findFirst().orElse(null);
|
||||
oderTableField = oderTableField + "." + sidxField;
|
||||
if (select == null) {
|
||||
wrapper.select(oderTableField);
|
||||
}
|
||||
if (descFlag) {
|
||||
wrapper.orderByDesc(oderTableField);
|
||||
} else {
|
||||
wrapper.orderByAsc(oderTableField);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
#end
|
||||
## 增删改查接口
|
||||
#macro(CrudMethod)
|
||||
@Override
|
||||
public ${Entity} getInfo(String ${peimaryKeyname}){
|
||||
## 生成MPJLambdaWrapper对象
|
||||
#CreateWrapper()
|
||||
wrapper.and(
|
||||
t->t.eq(${Entity}::get${peimaryKeyName}, #if($snowflake)${peimaryKeyname} #else Long.parseLong(${peimaryKeyname})#end)
|
||||
.or().eq(${Entity}::getFlowTaskId, ${peimaryKeyname})
|
||||
);
|
||||
return this.selectJoinOne(${Entity}.class,wrapper);
|
||||
}
|
||||
@Override
|
||||
public void create(${Entity} entity){
|
||||
this.save(entity);
|
||||
}
|
||||
@Override
|
||||
public boolean update(String ${peimaryKeyname}, ${Entity} entity){
|
||||
return this.updateById(entity);
|
||||
}
|
||||
@Override
|
||||
public void delete(${Entity} entity){
|
||||
if(entity!=null){
|
||||
this.removeById(entity.get${peimaryKeyName}());
|
||||
}
|
||||
}
|
||||
#end
|
||||
## 表单验证
|
||||
#macro(CheckForm)
|
||||
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
|
||||
@Override
|
||||
public String checkForm(${Name}Form form,int i) {
|
||||
#if(${isFlow})
|
||||
List<String> flowIds = generaterSwapUtil.getFlowIds(form.getFlowId());
|
||||
#end
|
||||
boolean isUp =StringUtil.isNotEmpty(form.get${peimaryKeyName}()) && !form.get${peimaryKeyName}().equals("0");
|
||||
Object id= null;
|
||||
String countRecover = "";
|
||||
String fieldTipName = "";
|
||||
String canNotNull = I18nUtil.getMessageStr("sys.validate.textRequiredSuffix", "不能为空");
|
||||
String canNotRepeated = I18nUtil.getMessageStr("EXIST103", "不能重复");
|
||||
if (isUp){
|
||||
#if($snowflake)
|
||||
id = form.get${peimaryKeyName}();
|
||||
#else
|
||||
id = Long.parseLong(form.get${peimaryKeyName}());
|
||||
#end
|
||||
}
|
||||
## 验证业务主键
|
||||
#if(${useBusinessKey})
|
||||
//验证业务主键
|
||||
String businessErr = checkBusinessKey(form, isUp ? id : null,#if($isFlow)flowIds#else null#end);
|
||||
if (StringUtil.isNotEmpty(businessErr)) {
|
||||
return businessErr;
|
||||
}
|
||||
#end
|
||||
## 主表字段验证
|
||||
//主表字段验证
|
||||
#foreach($mastField in ${mastTableHandle})
|
||||
#set($Field = $mastField)
|
||||
#set($config = $Field.config)
|
||||
#set($unique = $config.unique)
|
||||
#set($required = $config.required)
|
||||
#set($yunzhupaasKey = $config.yunzhupaasKey)
|
||||
#set($vModel = ${Field.vModel})
|
||||
#set($upName = "${Field.fieldAlias.substring(0,1).toUpperCase()}${Field.fieldAlias.substring(1)}")
|
||||
fieldTipName = #if(${config.labelI18nCode}) I18nUtil.getMessageStr("${config.labelI18nCode}", "${config.label}"); #else "${config.label}"; #end
|
||||
#if($yunzhupaasKey == 'input' && $required ==true && !${lineEdit})
|
||||
if(StringUtil.isEmpty(form.get${upName}())){
|
||||
return fieldTipName + canNotNull;
|
||||
}
|
||||
#end
|
||||
#if($yunzhupaasKey == 'input' && $unique ==true)
|
||||
if(StringUtil.isNotEmpty(form.get${upName}())){
|
||||
form.set${upName}(form.get${upName}()#if($yunzhupaasKey == 'input').trim()#end);
|
||||
QueryWrapper<${Name}Entity> ${vModel}Wrapper=new QueryWrapper<>();
|
||||
${vModel}Wrapper.lambda().eq(${Name}Entity::get${upName},form.get${upName}());
|
||||
#if(${isFlow})
|
||||
${vModel}Wrapper.lambda().in(${Name}Entity::getFlowId, flowIds);
|
||||
#else
|
||||
${vModel}Wrapper.lambda().isNull(${Name}Entity::getFlowId);
|
||||
#end
|
||||
#if($logicalDelete)
|
||||
//假删除标志
|
||||
${vModel}Wrapper.lambda().isNull(${Name}Entity::getDeleteMark);
|
||||
#end
|
||||
if (isUp){
|
||||
${vModel}Wrapper.lambda().ne(${Name}Entity::get${peimaryKeyName}, id);
|
||||
}
|
||||
if((int) this.count(${vModel}Wrapper)>0){
|
||||
countRecover = fieldTipName + canNotRepeated;
|
||||
}
|
||||
}
|
||||
#end
|
||||
## 正则判断
|
||||
#RegMethod($yunzhupaasKey,"form.get${upName}()",$config)
|
||||
#end
|
||||
## 副表字段验证
|
||||
#if(${columnTableHandle.size()}>0)
|
||||
//副表字段验证
|
||||
#foreach($cl in ${columnTableHandle})
|
||||
#set($columnTableName = "${cl.modelUpName}")
|
||||
#set($columnTableName = "${cl.modelLowName}")
|
||||
#foreach($clModel in ${cl.fieLdsModelList})
|
||||
#set($fieLdsModel = ${clModel.mastTable.fieLdsModel})
|
||||
#set($config = ${fieLdsModel.config})
|
||||
#set($fileRenameUp = "${fieLdsModel.fieldAlias.substring(0,1).toUpperCase()}${fieLdsModel.fieldAlias.substring(1)}")
|
||||
#set($fullName = "yunzhupaas_${fieLdsModel.tableAlias}_yunzhupaas_${fieLdsModel.fieldAlias}")
|
||||
#set($key = ${config.yunzhupaasKey})
|
||||
#set($unique = $config.unique)
|
||||
#set($required = $config.required)
|
||||
fieldTipName = #if(${config.labelI18nCode}) I18nUtil.getMessageStr("${config.labelI18nCode}", "${config.label}"); #else "${config.label}"; #end
|
||||
#if($required ==true && !${lineEdit})
|
||||
if(#if($key =='input') StringUtil.isEmpty(form.get${fullName}()) #else form.get${fullName}() == null #end){
|
||||
return fieldTipName + canNotNull;
|
||||
}
|
||||
#end
|
||||
#if($unique ==true)
|
||||
if(#if($key =='input') StringUtil.isNotEmpty(form.get${fullName}())#else form.get${fullName}() ==null #end ){
|
||||
form.set${fullName}(form.get${fullName}()#if($key == 'input').trim()#end);
|
||||
MPJLambdaWrapper<${Name}Entity> ${cl.modelLowName}${fileRenameUp}Wrapper = new MPJLambdaWrapper<>(${Name}Entity.class)
|
||||
.leftJoin(${cl.modelUpName}Entity.class, ${cl.modelUpName}Entity::get${cl.relationUpField}, ${Name}Entity::get${cl.mainUpKey})
|
||||
.select(${Name}Entity::get${peimaryKeyName});
|
||||
#if(${isFlow})
|
||||
${cl.modelLowName}${fileRenameUp}Wrapper.in(${Name}Entity::getFlowId, flowIds);
|
||||
#else
|
||||
${cl.modelLowName}${fileRenameUp}Wrapper.isNull(${Name}Entity::getFlowId);
|
||||
#end
|
||||
#if($logicalDelete)
|
||||
//假删除标志
|
||||
${cl.modelLowName}${fileRenameUp}Wrapper.isNull(${Name}Entity::getDeleteMark);
|
||||
#end
|
||||
${cl.modelLowName}${fileRenameUp}Wrapper.eq(${cl.modelUpName}Entity::get${fileRenameUp},form.get${fullName}());
|
||||
if (isUp){
|
||||
${cl.modelLowName}${fileRenameUp}Wrapper.ne(${cl.modelUpName}Entity::get${cl.relationUpField}, id);
|
||||
}
|
||||
if((int) this.count(${cl.modelLowName}${fileRenameUp}Wrapper)>0){
|
||||
countRecover = fieldTipName + canNotRepeated;
|
||||
}
|
||||
}
|
||||
#end
|
||||
## 正则判断
|
||||
#RegMethod($key,"form.get${fullName}()",$config)
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
## 子表字段验证
|
||||
#if(${childTableHandle.size()}>0)
|
||||
//子表字段验证
|
||||
#foreach($grid in ${childTableHandle})
|
||||
if (form.get${grid.aliasUpName}List()!=null){
|
||||
#foreach($yunzhupaaskey in ${grid.childList})
|
||||
#if(${yunzhupaaskey.fieLdsModel.vModel} != '')
|
||||
#set($fieLdsModel = ${yunzhupaaskey.fieLdsModel})
|
||||
#set($config = ${fieLdsModel.config})
|
||||
#set($key = ${config.yunzhupaasKey})
|
||||
#set($model = "${fieLdsModel.fieldAlias.substring(0,1).toUpperCase()}${fieLdsModel.fieldAlias.substring(1)}")
|
||||
#set($unique = ${config.unique})
|
||||
#set($required = ${config.required})
|
||||
|
||||
fieldTipName = #if(${grid.labelI18nCode}) I18nUtil.getMessageStr("${grid.labelI18nCode}", "${grid.label}")#else "${grid.label}" #end
|
||||
+ "-" + #if(${config.labelI18nCode}) I18nUtil.getMessageStr("${config.labelI18nCode}", "${config.label}");#else "${config.label}"; #end
|
||||
|
||||
#if($required ==true || $unique ==true || ${config.regList})
|
||||
for(${grid.aliasUpName}Model t : form.get${grid.aliasUpName}List()){
|
||||
if(#if($key =='input') StringUtil.isNotEmpty(t.get${model}()) #else t.get${model}() != null #end){
|
||||
t.set${model}(t.get${model}()#if($key == 'input').trim()#end);
|
||||
}
|
||||
#if($required ==true && !${lineEdit})
|
||||
else{
|
||||
return fieldTipName + canNotNull;
|
||||
}
|
||||
#end
|
||||
## 子表正则
|
||||
#RegMethod($key,"t.get${model}()",$config)
|
||||
}
|
||||
#end
|
||||
#if($key =='input' && $unique ==true)
|
||||
List<String> ${model}List = form.get${grid.aliasUpName}List().stream().filter(f->StringUtil.isNotEmpty(f.get${model}())).map(f -> f.get${model}()).collect(Collectors.toList());
|
||||
HashSet<String> ${model}Set = new HashSet<>(${model}List);
|
||||
if(${model}Set.size() != ${model}List.size()){
|
||||
countRecover = fieldTipName + canNotRepeated;
|
||||
}
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#end
|
||||
return countRecover;
|
||||
}
|
||||
#end
|
||||
|
||||
#macro(CheckBusinessKey)
|
||||
/**
|
||||
* 验证业务主键
|
||||
*/
|
||||
private String checkBusinessKey(${Name}Form form, Object id, List<String> flowIds){
|
||||
QueryWrapper<${Name}Entity> wrapper = new QueryWrapper<>();
|
||||
//修改
|
||||
if (id != null){
|
||||
wrapper.lambda().ne(${Name}Entity::get${peimaryKeyName}, id);
|
||||
}
|
||||
//是否流程
|
||||
if(flowIds == null){
|
||||
wrapper.lambda().isNull(${Name}Entity::getFlowId);
|
||||
}else{
|
||||
wrapper.lambda().in(${Name}Entity::getFlowId, flowIds);
|
||||
}
|
||||
#if($logicalDelete)
|
||||
//假删除标志
|
||||
wrapper.lambda().isNull(${Name}Entity::getDeleteMark);
|
||||
#end
|
||||
#set($notToJson=['inputNumber','input','textarea','radio','timePicker','createUser','modifyUser','location','currPosition'])
|
||||
#foreach($item in ${businessKeyList})
|
||||
#set($yunzhupaasKey = $item.config.yunzhupaasKey)
|
||||
#set($fieldNameUp = "${item.fieldAlias.substring(0,1).toUpperCase()}${item.fieldAlias.substring(1)}")
|
||||
//${item.config.label}字段判断
|
||||
#if($yunzhupaasKey == 'datePicker')
|
||||
if(form.get${fieldNameUp}() == null || form.get${fieldNameUp}().trim().isEmpty()){
|
||||
wrapper.lambda().isNull(${Name}Entity::get${fieldNameUp});
|
||||
}else{
|
||||
Object obj = new Date(Long.parseLong(form.get${fieldNameUp}()));
|
||||
wrapper.lambda().eq(${Name}Entity::get${fieldNameUp}, obj);
|
||||
}
|
||||
#elseif(${notToJson.contains(${yunzhupaasKey})})
|
||||
if(form.get${fieldNameUp}() == null || form.get${fieldNameUp}().toString().trim().isEmpty()){
|
||||
wrapper.lambda().isNull(${Name}Entity::get${fieldNameUp});
|
||||
}else{
|
||||
wrapper.lambda().eq(${Name}Entity::get${fieldNameUp}, form.get${fieldNameUp}());
|
||||
}
|
||||
#else
|
||||
if(form.get${fieldNameUp}() == null || form.get${fieldNameUp}().toString().trim().isEmpty()
|
||||
||(form.get${fieldNameUp}() instanceof List && ((List) form.get${fieldNameUp}()).size() == 0)){
|
||||
wrapper.lambda().isNull(${Name}Entity::get${fieldNameUp});
|
||||
}else{
|
||||
Object obj = form.get${fieldNameUp}() instanceof List ?JsonUtil.getObjectToString(form.get${fieldNameUp}()):form.get${fieldNameUp}();
|
||||
wrapper.lambda().eq(${Name}Entity::get${fieldNameUp}, obj);
|
||||
}
|
||||
#end
|
||||
#end
|
||||
if((int) this.count(wrapper)>0){
|
||||
return "${businessKeyTip}";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
#end
|
||||
## 保存或者修改事务方法
|
||||
#macro(SaveOrUpdate)
|
||||
/**
|
||||
* 新增修改数据(事务回滚)
|
||||
* @param id
|
||||
* @param ${name}Form
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
#if(${DS})
|
||||
@DSTransactional
|
||||
#else
|
||||
@Transactional
|
||||
#end
|
||||
public void saveOrUpdate(${Name}Form ${name}Form,String id, boolean isSave) throws Exception{
|
||||
#if($isFlow)
|
||||
List<$mapObject> formOperates = ${name}Form.getFormOperates();
|
||||
List<String> hasOperate = new ArrayList<>();
|
||||
boolean noOperate = false;
|
||||
if(CollectionUtils.isNotEmpty(formOperates)){
|
||||
for ($mapObject formOperate : formOperates) {
|
||||
String formOperateId = formOperate.get("id").toString();
|
||||
boolean formOperateWrite = formOperate.get("write") ==null? false : (boolean) formOperate.get("write");
|
||||
if(formOperateWrite){
|
||||
hasOperate.add(formOperateId);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
noOperate = true;
|
||||
}
|
||||
#end
|
||||
UserInfo userInfo=userProvider.get();
|
||||
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
|
||||
${name}Form = JsonUtil.getJsonToBean(
|
||||
generaterSwapUtil.swapDatetime(${Name}Constant.getFormData(),${name}Form,${Name}Constant.TABLERENAMES),${Name}Form.class);
|
||||
${Name}Entity entity = JsonUtil.getJsonToBean(${name}Form, ${Name}Entity.class);
|
||||
#set($peimaryKeyName="${pKeyName.substring(0,1).toUpperCase()}${pKeyName.substring(1)}")
|
||||
String mainUuid = StringUtil.isEmpty(id) ? RandomUtil.uuId() : id;
|
||||
#if($isFlow)
|
||||
entity.setFlowId(${name}Form.getFlowId());
|
||||
#end
|
||||
##主表保存修改判断是否有系统控件
|
||||
#foreach($field in ${mastTableHandle})
|
||||
#set($key = ${field.config.yunzhupaasKey})
|
||||
#if(${systemyunzhupaasKey.contains(${key})})
|
||||
#set($mainHasSysFields =true)
|
||||
#end
|
||||
#end
|
||||
if(isSave){
|
||||
entity.setFlowTaskId(mainUuid);
|
||||
#foreach($field in ${mastTableHandle})
|
||||
#set($model = "${field.fieldAlias.substring(0,1).toUpperCase()}${field.fieldAlias.substring(1)}")
|
||||
#set($key = ${field.config.yunzhupaasKey})
|
||||
#set($nameEntity = "entity")
|
||||
#set($rule ="${field.config.rule}")
|
||||
#set($showLevel ="${field.showLevel}")
|
||||
#set($realVmodel ="${field.vModel}")
|
||||
#set($config =${field.config})
|
||||
#set($constantVmodel ="${field.vModel}")
|
||||
#GetSystemData(true)
|
||||
#end
|
||||
#if($snowflake)
|
||||
entity.set${peimaryKeyName}(mainUuid);
|
||||
#end
|
||||
#if($version)
|
||||
#if(${versionType} == "bigint")
|
||||
entity.setVersion(0l);
|
||||
#else
|
||||
entity.setVersion(0);
|
||||
#end
|
||||
#end
|
||||
} else {
|
||||
#foreach($field in ${mastTableHandle})
|
||||
#set($model = "${field.fieldAlias.substring(0,1).toUpperCase()}${field.fieldAlias.substring(1)}")
|
||||
#set($key = ${field.config.yunzhupaasKey})
|
||||
#set($nameEntity = "entity")
|
||||
#set($rule ="${field.config.rule}")
|
||||
#set($showLevel ="${field.showLevel}")
|
||||
#set($realVmodel ="${field.vModel}")
|
||||
#set($config =${field.config})
|
||||
#set($constantVmodel ="${field.vModel}")
|
||||
#GetSystemData(false)
|
||||
#end
|
||||
}
|
||||
boolean b = this.saveOrUpdate(entity);
|
||||
#if($version)
|
||||
if(!b){
|
||||
throw new DataException("当前表单原数据已被调整,请重新进入该页面编辑并提交数据");
|
||||
}
|
||||
#end
|
||||
${Name}Entity info = this.getInfo(mainUuid);
|
||||
if (info == null) throw new RuntimeException(MsgCode.FA001.get());
|
||||
#if(!$snowflake)
|
||||
entity.set${peimaryKeyName}(info.get${peimaryKeyName}());
|
||||
#end
|
||||
|
||||
##子表数据新增修改
|
||||
#if(${childTableHandle.size()}>0)
|
||||
#foreach($grid in ${childTableHandle})
|
||||
#set($tableField = "${grid.tablefield.substring(0,1).toUpperCase()}${grid.tablefield.substring(1)}")
|
||||
#set($relationField = "${grid.relationField.substring(0,1).toUpperCase()}${grid.relationField.substring(1)}")
|
||||
#set($chidKeyName = "${grid.chidKeyName.substring(0,1).toUpperCase()}${grid.chidKeyName.substring(1)}")
|
||||
//${grid.aliasUpName}子表数据新增修改
|
||||
QueryWrapper<${grid.aliasUpName}Entity> ${grid.aliasUpName}queryWrapper = new QueryWrapper<>();
|
||||
${grid.aliasUpName}queryWrapper.lambda().eq(${grid.aliasUpName}Entity::get${tableField}, info.get${relationField}());
|
||||
if(!isSave && !CollectionUtils.isNotEmpty(${name}Form.get${grid.aliasUpName}List())){
|
||||
${grid.aliasLowName}Service.remove(${grid.aliasUpName}queryWrapper);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(${name}Form.get${grid.aliasUpName}List())){
|
||||
List<${grid.aliasUpName}Entity> ${grid.tableModel} = JsonUtil.getJsonToList(${name}Form.get${grid.aliasUpName}List(),${grid.aliasUpName}Entity.class);
|
||||
//移除的数据
|
||||
List<Object> childIds = ${grid.tableModel}.stream().filter(t->t.get${chidKeyName}()!=null).map(${grid.aliasUpName}Entity::get${chidKeyName}).collect(Collectors.toList());
|
||||
if(CollectionUtils.isNotEmpty(childIds)){
|
||||
${grid.aliasUpName}queryWrapper.lambda().notIn(${grid.aliasUpName}Entity::get${chidKeyName},childIds);
|
||||
}
|
||||
${grid.aliasLowName}Service.remove(${grid.aliasUpName}queryWrapper);
|
||||
for(${grid.aliasUpName}Entity entitys : ${grid.tableModel}){
|
||||
entitys.set${tableField}(entity.get${relationField}());
|
||||
##子表保存修改判断是否有系统控件
|
||||
#set($childHasSysFields =false)
|
||||
#foreach($yunzhupaaskey in ${grid.childList})
|
||||
#if(${yunzhupaaskey.fieLdsModel.vModel} != '')
|
||||
#set($key = ${yunzhupaaskey.fieLdsModel.config.yunzhupaasKey})
|
||||
#if(${systemyunzhupaasKey.contains(${key})})
|
||||
#set($childHasSysFields =true)
|
||||
#end
|
||||
#end
|
||||
#end
|
||||
#if($childHasSysFields)
|
||||
if(isSave || entitys.get${chidKeyName}()==null){
|
||||
#foreach($yunzhupaaskey in ${grid.childList})
|
||||
#if(${yunzhupaaskey.fieLdsModel.vModel} != '')
|
||||
#set($key = ${yunzhupaaskey.fieLdsModel.config.yunzhupaasKey})
|
||||
#set($rule = ${yunzhupaaskey.fieLdsModel.config.rule})
|
||||
#set($showLevel ="${yunzhupaaskey.fieLdsModel.showLevel}")
|
||||
#set($model = "${yunzhupaaskey.fieLdsModel.fieldAlias.substring(0,1).toUpperCase()}${yunzhupaaskey.fieLdsModel.fieldAlias.substring(1)}")
|
||||
#set($nameEntity = "entitys")
|
||||
#set($realVmodel ="${grid.aliasLowName}List-${yunzhupaaskey.fieLdsModel.vModel}")
|
||||
#set($config =${yunzhupaaskey.fieLdsModel.config})
|
||||
#set($constantVmodel ="${grid.aliasLowName}_${yunzhupaaskey.fieLdsModel.vModel}")
|
||||
#GetSystemData(true)
|
||||
#end
|
||||
#end
|
||||
}else{
|
||||
#foreach($yunzhupaaskey in ${grid.childList})
|
||||
#if(${yunzhupaaskey.fieLdsModel.vModel} != '')
|
||||
#set($key = ${yunzhupaaskey.fieLdsModel.config.yunzhupaasKey})
|
||||
#set($rule = ${yunzhupaaskey.fieLdsModel.config.rule})
|
||||
#set($showLevel ="${yunzhupaaskey.fieLdsModel.showLevel}")
|
||||
#set($model = "${yunzhupaaskey.fieLdsModel.fieldAlias.substring(0,1).toUpperCase()}${yunzhupaaskey.fieLdsModel.fieldAlias.substring(1)}")
|
||||
#set($nameEntity = "entitys")
|
||||
#set($realVmodel ="${grid.aliasLowName}List-${yunzhupaaskey.fieLdsModel.vModel}")
|
||||
#set($config =${yunzhupaaskey.fieLdsModel.config})
|
||||
#set($constantVmodel ="${grid.aliasLowName}_${yunzhupaaskey.fieLdsModel.vModel}")
|
||||
#GetSystemData(false,${chidKeyName})
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
#if($snowflake)
|
||||
if(entitys.get${chidKeyName}()==null){
|
||||
entitys.set${chidKeyName}(RandomUtil.uuId());
|
||||
}
|
||||
#end
|
||||
${grid.aliasLowName}Service.saveOrUpdate(entitys);
|
||||
}
|
||||
}
|
||||
#end
|
||||
#end
|
||||
##副表数据新增修改
|
||||
#if(${columnTableHandle.size()}>0)
|
||||
#foreach($cl in ${columnTableHandle})
|
||||
##副表保存修改判断是否有系统控件
|
||||
#set($mastHasSysFields =false)
|
||||
#foreach($clModel in ${cl.fieLdsModelList})
|
||||
#set($key = ${clModel.mastTable.fieLdsModel.config.yunzhupaasKey})
|
||||
#if($key!='' && ${systemyunzhupaasKey.contains(${key})})
|
||||
#set($mastHasSysFields =true)
|
||||
#end
|
||||
#end
|
||||
//${cl.tableName}副表数据新增修改
|
||||
#set($mainField = $cl.mainField)
|
||||
#set($mainUpId = "${mainField.substring(0,1).toUpperCase()}${mainField.substring(1)}")
|
||||
$mapObject ${cl.modelName}Map = generaterSwapUtil.getMastTabelData(${name}Form,"${cl.tableName}");
|
||||
${cl.modelName}Entity ${cl.modelLowName}entity = JsonUtil.getJsonToBean(${cl.modelName}Map,${cl.modelName}Entity.class);
|
||||
//自动生成的字段
|
||||
if(isSave){
|
||||
#if($mastHasSysFields)
|
||||
#foreach($clModel in ${cl.fieLdsModelList})
|
||||
#set($model = "${clModel.mastTable.fieLdsModel.fieldAlias.substring(0,1).toUpperCase()}${clModel.mastTable.fieLdsModel.fieldAlias.substring(1)}")
|
||||
#set($key = ${clModel.mastTable.fieLdsModel.config.yunzhupaasKey})
|
||||
#set($nameEntity = "${cl.modelLowName}entity")
|
||||
#set($rule ="${clModel.mastTable.fieLdsModel.config.rule}")
|
||||
#set($showLevel ="${clModel.mastTable.fieLdsModel.showLevel}")
|
||||
#set($realVmodel ="${clModel.vModel}")
|
||||
#set($config =${clModel.mastTable.fieLdsModel.config})
|
||||
#set($constantVmodel ="${clModel.vModel}")
|
||||
#GetSystemData(true)
|
||||
#end
|
||||
#end
|
||||
#if($snowflake)
|
||||
${cl.modelLowName}entity.set${mainUpId}(RandomUtil.uuId());
|
||||
#end
|
||||
${cl.modelLowName}entity.set${cl.relationUpField}(entity.get${cl.mainUpKey}());
|
||||
}else{
|
||||
QueryWrapper<${cl.modelUpName}Entity> queryWrapper${cl.modelUpName} =new QueryWrapper<>();
|
||||
queryWrapper${cl.modelUpName}.lambda().eq(${cl.modelUpName}Entity::get${cl.relationUpField},info.get${cl.mainUpKey}());
|
||||
${cl.modelUpName}Entity ${cl.modelLowName}OneEntity= ${cl.modelLowName}Service.getOne(queryWrapper${cl.modelUpName});
|
||||
#if($mastHasSysFields)
|
||||
#foreach($clModel in ${cl.fieLdsModelList})
|
||||
#set($model = "${clModel.mastTable.fieLdsModel.fieldAlias.substring(0,1).toUpperCase()}${clModel.mastTable.fieLdsModel.fieldAlias.substring(1)}")
|
||||
#set($key = ${clModel.mastTable.fieLdsModel.config.yunzhupaasKey})
|
||||
#set($nameEntity = "${cl.modelLowName}entity")
|
||||
#set($rule ="${clModel.mastTable.fieLdsModel.config.rule}")
|
||||
#set($showLevel ="${clModel.mastTable.fieLdsModel.showLevel}")
|
||||
#set($realVmodel ="${clModel.vModel}")
|
||||
#set($config =${clModel.mastTable.fieLdsModel.config})
|
||||
#set($constantVmodel ="${clModel.vModel}")
|
||||
#GetSystemData(false)
|
||||
#end
|
||||
#end
|
||||
${cl.modelLowName}entity.set${cl.mainField}(${cl.modelLowName}OneEntity.get${cl.mainField}());
|
||||
${cl.modelLowName}entity.set${cl.relationUpField}(entity.get${cl.mainUpKey}());
|
||||
}
|
||||
|
||||
${cl.modelLowName}Service.saveOrUpdate(${cl.modelLowName}entity);
|
||||
#end
|
||||
#end
|
||||
}
|
||||
#end
|
||||
Reference in New Issue
Block a user