初始代码

This commit is contained in:
wangmingwei
2026-04-21 17:19:25 +08:00
parent ac9bea0b65
commit fb2bc3165b
1320 changed files with 17009 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View 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

View 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

View 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

View 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

File diff suppressed because it is too large Load Diff

View 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

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/app/form.vue.vm")

View File

@@ -0,0 +1 @@
#parse("TemplateCode5/html/Form.vue.vm")

View File

@@ -0,0 +1,443 @@
#parse("PublicMacro/AppFormMarco.vm")
<template>
<view class="zero-wrap zero-wrap-form dynamicModel-form-v" v-if="!loading">
<u-form :model="${context.formModel}" :rules="${context.formRules}" ref="${context.formModel}" :errorType="['toast']"
#set($position='left')
#if(${context.labelPosition}=='top')
#set($position='top')
#end
#set($align='left')
#if(${context.labelPosition}=='right')
#set($align='right')
#end
label-position="${position}" label-align="${align}" :label-width="labelwidth" class="zero-form">
#AppDetailRendering()
</u-form>
<view class="buttom-actions" >
<template v-if="btnList.includes('btn_edit')">
<CustomButton :btnText="$t('common.cancelText')" btnIcon="icon-ym icon-ym-add-cancel" customIcon />
<u-button class="buttom-btn" type="primary" @click.stop="submitForm">{{$t('common.editText','编辑')}}</u-button>
</template>
<u-button v-else class="buttom-btn" @click="resetForm">{{$t('common.cancelText','取消')}}</u-button>
</view>
<u-modal v-model="show" :content="content" width='70%' border-radius="16" :content-style="{fontSize: '28rpx',padding: '20rpx',lineHeight: '44rpx',textAlign: 'left'}"
:titleStyle="{padding: '20rpx'}" :confirm-style="{height: '80rpx',lineHeight: '80rpx'}" :title="title" confirm-text="确定">
</u-modal>
</view>
</template>
<script>
import {
getDictionaryDataSelector,
getDataInterfaceRes
} from '@/api/common'
import {
getRelationFormDetail,
getDataInterfaceDataInfoByIds
} from '@/api/common.js'
import request from '@/utils/request'
import DisplayList from '@/components/displayList'
import CustomButton from '@/components/CustomButton'
export default {
components:{
DisplayList,
CustomButton
},
data(){
return{
btnLoading: false,
loading: false,
text: '提示:测试文本',
tableKey:'',
timeKey : +new Date(),
${context.formModel}:{
${pKeyName}:"",
},
${context.formRules}:{},
#foreach($fieLdsModel in ${context.form})
#set($zerokey = "${fieLdsModel.zeroKey}")
#set($isEnd = "${fieLdsModel.isEnd}")
#set($formModel = ${fieLdsModel.formModel})
#set($model = "${formModel.model}")
#set($outermost = ${formModel.outermost})
#set($children = ${formModel.children})
#if(${layoutList.contains($zerokey)})
#if(${isEnd}=='0')
#if(${outermost}=='0')
#if($zerokey=='collapse')
${model}active: #if($formModel.accordion) '${formModel.active}' #else ${formModel.active} #end,
#end
${model}Current:${formModel.activeIndex},
${model}Data:[
#foreach($childrenList in $children)
{
title: #if(${childrenList.titleI18nCode}) this.$t('${childrenList.titleI18nCode}')#else "${childrenList.title}" #end
},
#end
],
#end
#end
#end
#end
interfaceRes:{
#foreach($html in ${context.fields})
#set($fieLdsModel = $html.formColumnModel.fieLdsModel)
#faceRes($fieLdsModel,'')
#end
#foreach($masetkey in $mastTableList.entrySet())
#set($fieldsAll = $masetkey.value)
#foreach($html in ${fieldsAll})
#set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
#faceRes($fieLdsModel,'')
#end
#end
#foreach($child in ${context.children})
#set($className = "${child.className}")
#foreach($childList in ${child.childList})
#set($fieLdsModel = $childList.fieLdsModel)
#faceRes($fieLdsModel,$className)
#end
#end
},
extraOptions:{
#foreach($html in ${context.fields})
#set($fieLdsModel = $html.formColumnModel.fieLdsModel)
#extraOptions($fieLdsModel,'')
#end
#foreach($masetkey in $mastTableList.entrySet())
#set($fieldsAll = $masetkey.value)
#foreach($html in ${fieldsAll})
#set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
#extraOptions($fieLdsModel,'')
#end
#end
#foreach($child in ${context.children})
#set($className = "${child.className}")
#foreach($childList in ${child.childList})
#set($fieLdsModel = $childList.fieLdsModel)
#extraOptions($fieLdsModel,$className)
#end
#end
},
extraData:{
#foreach($fieLdsModel in ${context.fields})
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
#set($vModel = "${html.vModel}")
#if($vModel)
$!{vModel} : {},
#end
#end
#foreach($masetkey in $mastTableList.entrySet())
#set($fieldsAll = $masetkey.value)
#foreach($fieLdsModel in ${fieldsAll})
#set($mastTableModel = $fieLdsModel.formMastTableModel)
#set($html = $fieLdsModel.formMastTableModel.mastTable.fieLdsModel)
#set($vModel = "${mastTableModel.vModel}")
#if($vModel)
$!{vModel} : {},
#end
#end
#end
},
maskConfig:{
#foreach($html in ${context.fields})
#set($fieLdsModel = $html.formColumnModel.fieLdsModel)
#maskConfig($fieLdsModel,'')
#end
#foreach($masetkey in $mastTableList.entrySet())
#set($fieldsAll = $masetkey.value)
#foreach($html in ${fieldsAll})
#set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
#maskConfig($fieLdsModel,'')
#end
#end
#foreach($child in ${context.children})
#set($className = "${child.className}")
#foreach($childList in ${child.childList})
#set($fieLdsModel = $childList.fieLdsModel)
#maskConfig($fieLdsModel,$className)
#end
#end
},
labelwidth:${context.labelWidth}*1.5,
menuId:'',
btnList:[],
idList:[],
ruleList:{},
childIndex:-1,
content:'',
title:'',
show:false,
}
},
onLoad(option) {
this.menuId=option.menuId
this.btnList=option.btnList.split(",")
uni.setNavigationBarTitle({
title: this.$t('common.detailText','详情')
})
this.${context.formModel}.${pKeyName} = option.id || 0
this.idList = option.idList?option.idList.split(","):[]
this.initData()
uni.$on('refresh', () => {
#foreach($fieLdsModel in ${context.form})
#set($zerokey = "${fieLdsModel.zeroKey}")
#set($isEnd = "${fieLdsModel.isEnd}")
#set($formModel = ${fieLdsModel.formModel})
#set($model = "${formModel.model}")
#set($outermost = ${formModel.outermost})
#set($children = ${formModel.children})
#if(${layoutList.contains($zerokey)})
#if(${isEnd}=='0')
#if(${outermost}=='0')
#if($zerokey=='collapse')
this.${model}active=#if($formModel.accordion) '${formModel.active}' #else ${formModel.active} #end
#end
this.${model}Current=${formModel.activeIndex}
#end
#end
#end
#end
//执行接口更新数据
this.initData()
})
uni.$on('initCollapse', () => {
//初始化折叠面板高度高度
this.collapse()
})
},
beforeDestroy() {
uni.$off('refresh')
},
onReady() {
#set($rulesAll = "this."+${context.formRules})
this.$refs.${context.formModel}.setRules(${rulesAll});
},
onShow(){
this.collapse()
},
watch:{
dataForm: {
handler(val, oldVal) {
#foreach($child in ${context.children})
#set($className = "${child.className}")
this.${className}()
#end
},
deep: true
}
},
methods:{
getParamList(key) {
let templateJson = this.interfaceRes[key];
if (!templateJson || !templateJson.length || !this.dataForm) return templateJson;
for (let i = 0; i < templateJson.length; i++) {
if (templateJson[i].relationField && templateJson[i].sourceType == 1) {
templateJson[i].defaultValue = this.dataForm[templateJson[i].relationField + '_id'] || '';
}
}
return templateJson;
},
#foreach($html in ${context.fields})
#set($fieLdsModel = $html.formColumnModel.fieLdsModel)
#extraData($fieLdsModel,'','data')
#end
#foreach($masetkey in $mastTableList.entrySet())
#set($fieldsAll = $masetkey.value)
#foreach($html in ${fieldsAll})
#set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
#extraData($fieLdsModel,'','data')
#end
#end
doPreviewImage(url,imagesList) {
const images = imagesList.map(item => this.define.baseURL + item.url);
uni.previewImage({
urls: images,
current: url,
success: () => {},
fail: () => {
uni.showToast({
title: '预览图片失败',
icon: 'none'
});
}
});
},
onCollapseChange() {
uni.$emit('initCollapse')
},
toDetail(id, modelId) {
if (!id) return
let config = {
modelId: modelId,
id: id,
formTitle: this.$t('common.detailText','详情'),
noShowBtn: 1,
noDataLog: 1,
}
this.$nextTick(() => {
const url ='/pages/apply/dynamicModel/detail?config=' + this.com.zero.base64.encode(JSON.stringify(config),"UTF-8")
uni.navigateTo({
url: url
})
})
},
clickIcon(label,tipLabel) {
this.content = tipLabel
this.title = label
this.show = true
},
checkChildRule() {
let title = [];
let _ruleList = this.ruleList
for (let k in _ruleList) {
let childData = this.${context.formModel}[k]
childData.forEach((item, index) => {
for (let model in _ruleList[k]) {
if (item[model] instanceof Array) {
if (item[model].length == 0) {
title.push(_ruleList[k][model])
}
} else if (!item[model]) {
title.push(_ruleList[k][model])
}
}
})
}
if (title.length > 0) {
return title[0]
}
},
resetForm(){
uni.navigateBack()
},
dataAll(){
},
#foreach($child in ${context.children})
#set($tableModel = "${child.tableModel}")
#set($className = "${child.className}")
${className}(){
let table = this.${context.formModel}.${tableModel}
let summaryField =${child.summaryField}
let summaryFieldName =${child.summaryFieldName}
#if($useFormPermission)
for(let i=0;i<summaryField.length;i++){
if(!this.${setPermission}.hasFormP("${tableModel}-"+summaryField[i],this.menuId)){
summaryField.splice(i)
}
}
#end
let data ={}
if(!table) return data
let thousandsField = ${child.thousandsField}
for (let i in summaryField) {
let map = {}
let val = 0
for (let j = 0; j < table.length; j++) {
let summary = table[j][summaryField[i]];
if (summary) {
let data = isNaN(summary) ? 0 : Number(summary)
val += data
}
}
map.id = summaryField[i];
map.name = summaryFieldName[summaryField[i]+"_i18n"] ? this.$t(summaryFieldName[summaryField[i]+"_i18n"]):summaryFieldName[summaryField[i]];
map.val = (thousandsField.includes(summaryField[i]))? Number(val).toLocaleString('zh', {
maximumFractionDigits: '2',
minimumFractionDigits: '2'
}): val.toFixed(2);
data[summaryField[i]]=map;
}
return data;
},
#end
#foreach($fieLdsModel in ${context.form})
#set($zerokey = "${fieLdsModel.zeroKey}")
#set($isEnd = "${fieLdsModel.isEnd}")
#set($formModel = ${fieLdsModel.formModel})
#set($outermost = ${formModel.outermost})
#if($zerokey=='tab' || $zerokey=='steps')
#if(${isEnd}=='0')
#if(${outermost}=='0')
${formModel.model}(index) {
this.${formModel.model}Current = index;
this.timeKey = +new Date()
#if($zerokey=='tab')
this.collapse()
setTimeout(() => {
uni.$emit('initCollapse')
}, 1000)
#end
},
#end
#end
#end
#end
initData(){
#set($nextTick='$'+"nextTick")
this.$nextTick(function(){
if (this.${context.formModel}.${pKeyName}) {
this.loading = true
request({
url: '/api/${context.module}/${context.className}/'+'detail/'+this.${context.formModel}.${pKeyName},
method: 'get',
}).then(res => {
this.dataInfo(res.data)
this.loading = false
})
}
})
},
submitForm(){
uni.navigateTo({
url: "./form?menuId=" + this.menuId + "&jurisdictionType=btn_edit&id="+this.${context.formModel}.${pKeyName}+"&idList="+this.idList
})
},
selfInit() {
this.$store.commit('base/UPDATE_RELATION_DATA', {})
},
dataInfo(dataAll){
let _dataAll =dataAll
this.${context.formModel}=_dataAll
#foreach($html in ${context.fields})
#set($fieLdsModel = $html.formColumnModel.fieLdsModel)
#extraData($fieLdsModel,'','')
#end
#foreach($masetkey in $mastTableList.entrySet())
#set($fieldsAll = $masetkey.value)
#foreach($html in ${fieldsAll})
#set($fieLdsModel = $html.formMastTableModel.mastTable.fieLdsModel)
#extraData($fieLdsModel,'','')
#end
#end
this.collapse()
},
collapse(){
setTimeout(()=> {
#foreach($fieLdsModel in ${context.form})
#set($zerokey = "${fieLdsModel.zeroKey}")
#set($isEnd = "${fieLdsModel.isEnd}")
#set($formModel = ${fieLdsModel.formModel})
#set($outermost = ${formModel.outermost})
#set($config=$formModel.config)
#if(${layoutList.contains($zerokey)})
#if(${config.app}==true)
#if(${isEnd}=='0')
#if(${outermost}=='0')
this.$refs.${formModel.model}Current && this.$refs.${formModel.model}Current.init()
#end
#end
#end
#end
#end
}, 1000);
},
},
}
</script>
<style>
page{
background-color: #f0f2f6;
}
</style>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,361 @@
#parse("PublicMacro/DetailMarco.vm")
#parse("PublicMacro/ConstantMarco.vm")
##参数
#ConstantParams()
<template>
## 全屏弹窗
#if(${context.popupType}=="fullScreen")
<BasicPopup v-bind="$attrs" @register="registerPopup" :title="title" destroyOnClose>
<template #insertToolbar>
#if(${context.HasPrintBtn})
<a-button type="primary" @click="handlePrint">#if(${context.printButtonTextI18nCode}){{t('${context.printButtonTextI18nCode}','${context.printButtonText}')}}#else${context.printButtonText}#end</a-button>
#end
</template>
<a-row class="p-10px dynamic-form ${context.formStyle}" :style="{ margin: '0 auto', width: '${context.fullScreenWidth}' }">
<!-- 表单 -->
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" ref="formRef" >
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#DetailFormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicPopup>
#end
## 普通弹窗
#if(${context.popupType}=="general")
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="${context.generalWidth}"
:minHeight="100" :showOkBtn="false">
<template #insertFooter>
#if(${context.HasPrintBtn})
<a-button type="primary" @click="handlePrint">#if(${context.printButtonTextI18nCode}){{t('${context.printButtonTextI18nCode}','${context.printButtonText}')}}#else${context.printButtonText}#end</a-button>
#end
</template>
<!-- 表单 -->
<a-row class="dynamic-form ${context.formStyle}">
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" ref="formRef">
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#DetailFormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicModal>
#end
## 右侧弹窗
#if(${context.popupType}=="drawer")
<BasicDrawer v-bind="$attrs" @register="registerDrawer" :title="title" width="${context.drawerWidth}" showFooter
:showOkBtn="false">
<template #insertFooter>
#if(${context.HasPrintBtn})
<a-button type="primary" @click="handlePrint">#if(${context.printButtonTextI18nCode}){{t('${context.printButtonTextI18nCode}','${context.printButtonText}')}}#else${context.printButtonText}#end</a-button>
#end
</template>
<a-row class="p-10px dynamic-form ${context.formStyle}">
<!-- 表单 -->
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" ref="formRef" >
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#DetailFormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicDrawer>
#end
<!-- 有关联表单详情:开始 -->
<RelationDetail ref="relationDetailRef" />
<!-- 有关联表单详情:结束 -->
#if(${context.HasPrintBtn})
<PrintSelect @register="registerPrintSelect" @change="handleShowBrowse" />
<PrintBrowse @register="registerPrintBrowse" />
#end
</template>
<script lang="ts" setup>
import { getDetailInfo } from './helper/api';
import { getConfigData } from '@/api/onlineDev/visualDev';
import { reactive, toRefs, nextTick, ref, computed, unref ,toRaw} from 'vue';
#if(${context.popupType}=="fullScreen")
import { BasicPopup, usePopup } from '@/components/Popup';
#end
import { BasicModal, useModal } from '@/components/Modal';
#if(${context.popupType}=="drawer")
import { BasicDrawer, useDrawer } from '@/components/Drawer';
#end
#if($childSummary == true)
import { thousandsFormat } from '@/utils/yunzhupaas';
#end
// 有关联表单详情
import RelationDetail from '@/views/common/dynamicModel/list/detail/index.vue';
// 表单权限
import { usePermission } from '@/hooks/web/usePermission';
#if(${context.HasPrintBtn})
// 打印模板多条生成PrintSelect
import PrintSelect from '@/components/PrintDesign/printSelect/index.vue';
import PrintBrowse from '@/components/PrintDesign/printBrowse/index.vue';
#end
import { useMessage } from '@/hooks/web/useMessage';
import { CaretRightOutlined } from '@ant-design/icons-vue';
import { buildUUID } from '@/utils/uuid';
import { useI18n } from '@/hooks/web/useI18n';
import { getDataChange } from '@/api/onlineDev/visualDev';
import { getDataInterfaceDataInfoByIds } from '@/api/systemData/dataInterface';
import ExtraRelationInfo from '@/components/yunzhupaas/RelationForm/src/ExtraRelationInfo.vue';
interface State {
dataForm: any;
title: string;
maskConfig: any;
interfaceRes: any;
locationScope: any;
extraOptions: any;
extraData: any;
## 活动面板参数
#foreach($fieLdsModel in ${context.form})
#set($yunzhupaasKey = "${fieLdsModel.yunzhupaasKey}")
#set($formModel = ${fieLdsModel.formModel})
#set($outermost = ${formModel.outermost})
#set($isEnd = "${fieLdsModel.isEnd}")
#if(${isEnd}=='0')
#if($yunzhupaasKey=='collapse')
#if(${outermost}=='0')
${formModel.model}:any;
#end
#end
#if($yunzhupaasKey=='tab')
#if(${outermost}=='0')
${formModel.model}:any;
#end
#end
#if($yunzhupaasKey=='steps')
#if(${outermost}=='0')
${formModel.model}:any;
#end
#end
#end
#end
## 子表平铺活动面板变量
#foreach($children in ${context.children})
#set($aliasname = "${children.aliasLowName}")
#if($!{children.layoutType} == 'list')
${aliasname}outerActiveKey: any;
${aliasname}innerActiveKey: any;
#end
#end
}
defineOptions({ name: 'Detail' });
const { createMessage, createConfirm } = useMessage();
#if(${context.popupType}=="fullScreen")
const [registerPopup, { openPopup, setPopupProps, closePopup }] = usePopup();
#end
#if(${context.popupType}=="general")
const [registerModal, { openModal, setModalProps, closeModal }] = useModal();
#end
#if(${context.popupType}=="drawer")
const [registerDrawer, { openDrawer, setDrawerProps, closeDrawer }] = useDrawer();
#end
#if(${context.HasPrintBtn})
const [registerPrintSelect, { openModal: openPrintSelect }] = useModal();
const [registerPrintBrowse, { openModal: openPrintBrowse }] = useModal();
#end
##子表列表字段-及合计方法
#DetailChildTableColumns()
const { t } = useI18n();
const relationDetailRef = ref<any>(null);
const state = reactive<State>({
dataForm:{},
title: t('common.detailText','详情'),
maskConfig:#CreateMaskConfig(),
interfaceRes: ${context.templateJsonAll},
locationScope:#CreateLocationScope(),
extraOptions: #CreateExtraOptions(),
extraData: #CreateExtraData(),
## 活动面板参数
#foreach($fieLdsModel in ${context.form})
#set($yunzhupaasKey = "${fieLdsModel.yunzhupaasKey}")
#set($formModel = ${fieLdsModel.formModel})
#set($outermost = ${formModel.outermost})
#set($isEnd = "${fieLdsModel.isEnd}")
#if(${isEnd}=='0')
#if($yunzhupaasKey=='collapse')
#if(${outermost}=='0')
${formModel.model}:${formModel.active},
#end
#end
#if($yunzhupaasKey=='tab')
#if(${outermost}=='0')
${formModel.model}:'${formModel.active}',
#end
#end
#if($yunzhupaasKey=='steps')
#if(${outermost}=='0')
${formModel.model}:${formModel.active},
#end
#end
#end
#end
## 子表平铺活动面板变量
#foreach($children in ${context.children})
#set($aliasname = "${children.aliasLowName}")
#if($!{children.layoutType} == 'list')
${aliasname}outerActiveKey: [0],
${aliasname}innerActiveKey: [],
#end
#end
});
const { title, dataForm, maskConfig } = toRefs(state);
// 表单权限
const { hasFormP } = usePermission();
defineExpose({ init });
function init(data) {
state.dataForm.id = data.id;
#if(${context.popupType}=="fullScreen")
openPopup();
#end
#if(${context.popupType}=="general")
openModal();
#end
#if(${context.popupType}=="drawer")
openDrawer();
#end
nextTick(() => {
setTimeout(initData, 0);
});
}
function initData() {
changeLoading(true);
#InitActiveValue()
if (state.dataForm.id) {
getData(state.dataForm.id);
} else {
#if(${context.popupType}=="fullScreen")
closePopup();
#end
#if(${context.popupType}=="general")
closeModal();
#end
#if(${context.popupType}=="drawer")
closeDrawer();
#end
}
}
function getData(id) {
getDetailInfo(id).then((res) => {
state.dataForm = res.data || {};
nextTick(() => {
## 子表平铺,默认展开
#foreach($itemModel in ${context.children})
#set($aliasname =$itemModel.aliasLowName)
#if($!{itemModel.layoutType} == 'list')
if (state.dataForm.${aliasname}List) {
for (let i = 0; i < state.dataForm.${aliasname}List.length; i++) {
state.dataForm.${aliasname}List[i].yunzhupaasId = buildUUID();
}
}
set${aliasname}ActiveKey();
#end
#end
#runAllExtraFun()
changeLoading(false);
});
});
}
## 平铺布局时设置默认展开
#foreach($itemModel in ${context.children})
#if(${itemModel.layoutType} == 'list')
#set($aliasname =$itemModel.aliasLowName)
// 平铺布局时设置默认展开
function set${aliasname}ActiveKey() {
state.${aliasname}outerActiveKey = [0];
state.${aliasname}innerActiveKey = [];
#if(${itemModel.defaultExpandAll})
state.${aliasname}innerActiveKey = ['summary'];
if (!state.dataForm.${aliasname}List.length) return;
for (let i = 0; i < state.dataForm.${aliasname}List.length; i++) {
state.${aliasname}innerActiveKey.push(state.dataForm.${aliasname}List[i].yunzhupaasId);
}
#end
}
#end
#end
function toDetail(modelId, id, propsValue) {
if (!id) return;
getConfigData(modelId).then((res) => {
if (!res.data || !res.data.formData) return;
const formConf = JSON.parse(res.data.formData);
formConf.popupType = 'general';
formConf.hasPrintBtn = false;
formConf.customBtns = [];
const data = { id, formConf, modelId, propsValue};
relationDetailRef.value?.init(data);
});
}
#if($context.HasPrintBtn)
function handlePrint() {
let printId=#if(${context.PrintId})${context.PrintId}#else [] #end
if (!printId?.length) return createMessage.error('未配置打印模板');
if (printId?.length === 1) return handleShowBrowse(printId[0]);
openPrintSelect(true, printId);
}
function handleShowBrowse(id) {
openPrintBrowse(true, { id, formInfo: [{ formId: state.dataForm.id }] });
}
#end
function setFormProps(data) {
#if(${context.popupType}=="fullScreen")
setPopupProps(data);
#end
#if(${context.popupType}=="general")
setModalProps(data);
#end
#if(${context.popupType}=="drawer")
setDrawerProps(data);
#end
}
function changeLoading(loading) {
setFormProps({ loading });
}
##合计方法
#if($childSummary==true)
//子表合计方法
function getCmpValOfRow(row, key, summaryField) {
if (!summaryField.length) return '';
const isSummary = key => summaryField.includes(key);
const target = row[key];
if (!target) return '';
let data = isNaN(target) ? 0 : Number(target);
if (isSummary(key)) return data || 0;
return '';
}
#end
function getParamList(key) {
let templateJson: any[] = state.interfaceRes[key];
if (!templateJson || !templateJson.length || !state.dataForm) return templateJson;
for (let i = 0; i < templateJson.length; i++) {
if (templateJson[i].relationField && templateJson[i].sourceType == 1) {
templateJson[i].defaultValue = state.dataForm[templateJson[i].relationField + '_id'] || '';
}
}
return templateJson;
}
## 生成关联表单弹窗初始化数据方法
#ExtraInfoFun()
</script>

View File

@@ -0,0 +1,169 @@
#parse("PublicMacro/FormMarco.vm")
## 行内-弹窗编辑生成表单字段
#macro(FormRenderingExtra)
#foreach($html in ${context.columnList})
#set($vModel = "${html.vModel}")
#set($beforeVmodel = "${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 && !$html.prop.toLowerCase().startsWith("tablefield"))
<a-col :span="24" class="ant-col-item" #if($context.isFlow) v-if="judgeShow('${beforeVmodel}')"
#elseif(${context.columnData.useFormPermission}) #if(${vModel}) v-if="com.yunzhupaas.hasFormP('${beforeVmodel}')"
#elseif($mastKey == 'relationFormAttr' || $mastKey == 'popupAttr') v-if="com.yunzhupaas.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>
<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>
#CreateFieldTag($mastKey,$html,$config,$mastModel,$beforeVmodel,-1,false)
</a-form-item>
</a-col>
#end
#end
#end
<template>
##
##<!-- 普通弹窗 -->
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="${context.generalWidth}"
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
:minHeight="100" @ok="handleSubmit(0)" @continue="handleSubmit(1)" :closeFunc="onClose">
<a-row class="dynamic-form ${context.formStyle}">
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" :rules="dataRule" ref="formRef" class="${context.formStyle}">
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#FormRenderingExtra()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicModal>
##<!-- 普通弹窗 -->
</template>
<script lang="ts" setup>
import { create, update, getInfo } from './helper/api';
import { reactive, toRefs, nextTick, ref, unref, computed } from 'vue';
import { BasicModal, useModal } from '@/components/Modal';
import { useMessage } from '@/hooks/web/useMessage';
import { useUserStore } from '@/store/modules/user';
import type { FormInstance } from 'ant-design-vue';
import { yunzhupaasRelationForm } from '@/components/yunzhupaas';
import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/yunzhupaas';
import dayjs from 'dayjs';
import { useI18n } from '@/hooks/web/useI18n';
interface State {
#createStateParam("any")
title: string;
}
const emit = defineEmits(['reload']);
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { createMessage } = useMessage();
const { t } = useI18n();
const [registerModal, { openModal, setModalProps }] = useModal();
const formRef = ref<FormInstance>();
const state = reactive<State>({
#createStateParam()
title: '',
});
const { title, dataRule, dataForm, optionsObj, ableAll, maskConfig } = toRefs(state);
defineExpose({ init });
function init(data) {
state.title = !data.id || data.id === 'yunzhupaasAdd' ? t('common.add2Text','新增') : t('common.editText','编辑');
setFormProps({ continueLoading: false });
openModal();
##主表options
#foreach($fieLdsModel in ${context.fields})
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
#set($vModel = "${html.vModel}")
#set($config = $html.config)
#set($dataType = "$!{config.dataType}")
#if($!{config.dataType}=='dictionary'||$!{config.dataType}=='dynamic')
get${vModel}Options();
#end
#end
##副表options
#foreach($ColumnFieldModel in ${context.mastTable})
#set($html =${ColumnFieldModel.formMastTableModel})
#set($vModel = "${html.vModel}")
#set($config = $html.mastTable.fieLdsModel.config)
#if($!{config.dataType}=='dictionary'||$!{config.dataType}=='dynamic')
get${vModel}Options();
#end
#end
nextTick(() => {
getForm().resetFields();
state.dataForm = JSON.parse(JSON.stringify(data.formData));
state.dataForm.id = !data.id || data.id === 'yunzhupaasAdd' ? '' :data.id;
});
}
function getForm() {
const form = unref(formRef);
if (!form) {
throw new Error('form is null!');
}
return form;
}
async function handleSubmit() {
try {
const values = await getForm()?.validate();
if (!values) return;
setFormProps({ continueLoading: true });
const formMethod = state.dataForm.id ? update : create;
formMethod(state.dataForm)
.then((res) => {
createMessage.success(res.msg);
setFormProps({ continueLoading: false });
setFormProps({ open: false });
emit('reload');
})
.catch(() => {
setFormProps({ continueLoading: false });
});
} catch (_) {}
}
function setFormProps(data) {
setModalProps(data);
}
function changeLoading(loading) {
setModalProps({ loading });
}
async function onClose() {
if (state.isContinue) emit('reload');
return true;
}
//option方法
#GetDataOptionsMethod()
##动态时间处理
#GetRelationDate()
</script>

View File

@@ -0,0 +1,416 @@
#parse("PublicMacro/FormMarco.vm")
<template>
## 全屏弹窗
#if(${context.popupType}=="fullScreen")
##<!-- 全屏弹窗 -->
<BasicPopup v-bind="$attrs" @register="registerPopup" showOkBtn destroyOnClose
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
@ok="handleSubmit" :closeFunc="onClose">
<template #title>
<a-space :size="10">
<div class="text-16px font-medium">{{ title }}</div>
## <!-- 分组和树形不展示 -->
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
<a-space-compact size="small" block v-if="dataForm.id">
<a-tooltip :title="t('common.prevRecord')">
<a-button size="small" :disabled="getPrevDisabled" @click="handlePrev">
<i class="icon-ym icon-ym-caret-left text-10px"></i>
</a-button>
</a-tooltip>
<a-tooltip :title="t('common.nextRecord')">
<a-button size="small" :disabled="getNextDisabled" @click="handleNext">
<i class="icon-ym icon-ym-caret-right text-10px"></i>
</a-button>
</a-tooltip>
</a-space-compact>
#end
</a-space>
</template>
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
## <!-- 分组和树形不展示 -->
<template #insertToolbar>
<yunzhupaasCheckboxSingle v-model:value="submitType" :label="continueText" v-if="showContinueBtn" />
</template>
## <!-- 分组和树形不展示 -->
#end
<a-row class="p-10px dynamic-form ${context.formStyle}" :style="{ margin: '0 auto', width: '${context.fullScreenWidth}' }">
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" :rules="dataRule" ref="formRef" >
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#FormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicPopup>
##<!-- 全屏弹窗 -->
#end
## 普通弹窗
#if(${context.popupType}=="general")
##<!-- 普通弹窗 -->
<BasicModal v-bind="$attrs" @register="registerModal" width="${context.generalWidth}"
:minHeight="100"
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
@ok="handleSubmit" :closeFunc="onClose">
<template #title>
<a-space :size="10">
<div class="text-16px font-medium">{{ title }}</div>
## <!-- 分组和树形不展示 -->
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
<a-space-compact size="small" block v-if="dataForm.id">
<a-tooltip :title="t('common.prevRecord')">
<a-button size="small" :disabled="getPrevDisabled" @click="handlePrev">
<i class="icon-ym icon-ym-caret-left text-10px"></i>
</a-button>
</a-tooltip>
<a-tooltip :title="t('common.nextRecord')">
<a-button size="small" :disabled="getNextDisabled" @click="handleNext">
<i class="icon-ym icon-ym-caret-right text-10px"></i>
</a-button>
</a-tooltip>
</a-space-compact>
#end
</a-space>
</template>
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
## <!-- 分组和树形不展示 -->
<template #insertFooter>
<div class="float-left mt-5px">
<yunzhupaasCheckboxSingle v-model:value="submitType" :label="continueText" />
</div>
</template>
## <!-- 分组和树形不展示 -->
#end
<a-row class="dynamic-form ${context.formStyle}">
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" :rules="dataRule" ref="formRef">
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#FormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicModal>
##<!-- 普通弹窗 -->
#end
## 右侧弹窗
#if(${context.popupType}=="drawer")
##<!-- 右侧弹窗 -->
<BasicDrawer v-bind="$attrs" @register="registerDrawer" width="${context.drawerWidth}" showFooter
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
@ok="handleSubmit" :closeFunc="onClose">
<template #title>
<a-space :size="10">
<div class="text-16px font-medium">{{ title }}</div>
## <!-- 分组和树形不展示 -->
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
<a-space-compact size="small" block v-if="dataForm.id">
<a-tooltip :title="t('common.prevRecord')">
<a-button size="small" :disabled="getPrevDisabled" @click="handlePrev">
<i class="icon-ym icon-ym-caret-left text-10px"></i>
</a-button>
</a-tooltip>
<a-tooltip :title="t('common.nextRecord')">
<a-button size="small" :disabled="getNextDisabled" @click="handleNext">
<i class="icon-ym icon-ym-caret-right text-10px"></i>
</a-button>
</a-tooltip>
</a-space-compact>
#end
</a-space>
</template>
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
## <!-- 分组和树形不展示 -->
<template #insertFooter>
<div class="float-left mt-5px">
<yunzhupaasCheckboxSingle v-model:value="submitType" :label="continueText" />
</div>
</template>
## <!-- 分组和树形不展示 -->
#end
<a-row class="p-10px dynamic-form ${context.formStyle}">
<!-- 表单 -->
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" :rules="dataRule" ref="formRef" >
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#FormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicDrawer>
##<!-- 右侧弹窗 -->
#end
#if($isSelectDialog == true)
<SelectModal :config="state.currTableConf" :formData="state.dataForm" ref="selectModal" @select="addForSelect"/>
#end
</template>
<script lang="ts" setup>
import { create, update, getInfo } from './helper/api';
import { reactive, toRefs, nextTick, ref, unref, computed,toRaw, inject } from 'vue';
#if(${context.popupType}=="fullScreen")
import { BasicPopup, usePopup } from '@/components/Popup';
#end
#if(${context.popupType}=="general")
import { BasicModal, useModal } from '@/components/Modal';
#end
#if(${context.popupType}=="drawer")
import { BasicDrawer, useDrawer } from '@/components/Drawer';
#end
import { yunzhupaasRelationForm } from '@/components/yunzhupaas';
import { useMessage } from '@/hooks/web/useMessage';
import { useI18n } from '@/hooks/web/useI18n';
import { useUserStore } from '@/store/modules/user';
import type { FormInstance } from 'ant-design-vue';
#if($isSelectDialog == true)
import SelectModal from '@/components/CommonModal/src/SelectModal.vue';
#end
import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/yunzhupaas';
import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
import dayjs from 'dayjs';
// 表单权限
import { usePermission } from '@/hooks/web/usePermission';
import { cloneDeep } from 'lodash-es';
import { buildUUID } from '@/utils/uuid';
import { CaretRightOutlined } from '@ant-design/icons-vue';
interface State {
#createStateParam("any")
title: string;
#if(${context.hasConfirmAndAddBtn})continueText: string; #end
allList: any[];
currIndex: number;
isContinue: boolean;
submitType: number;
showContinueBtn: boolean;
}
const emit = defineEmits(['reload']);
const getLeftTreeActiveInfo: (() => any) | null = inject('getLeftTreeActiveInfo', null);
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { createMessage, createConfirm } = useMessage();
const { t } = useI18n();
#if(${context.popupType}=="fullScreen")
const [registerPopup, { openPopup, setPopupProps }] = usePopup();
#end
#if(${context.popupType}=="general")
const [registerModal, { openModal, setModalProps }] = useModal();
#end
#if(${context.popupType}=="drawer")
const [registerDrawer, { openDrawer, setDrawerProps }] = useDrawer();
#end
const formRef = ref<FormInstance>();
#if($isSelectDialog == true)
// 子表弹窗数据
const selectModal = ref(null);
#end
#GetChildTableColumns()
const state = reactive<State>({
#createStateParam()
title: "",
#if(${context.hasConfirmAndAddBtn}) continueText: "", #end
allList: [],
currIndex: 0,
isContinue: false,
submitType: 0,
showContinueBtn: #if(${context.hasConfirmAndAddBtn}) true #else false #end,
});
const { title, #if(${context.hasConfirmAndAddBtn}) continueText, #end showContinueBtn, dataRule, dataForm, optionsObj, ableAll, maskConfig,submitType } = toRefs(state);
const getPrevDisabled = computed(() => state.currIndex === 0);
const getNextDisabled = computed(() => state.currIndex === state.allList.length - 1);
// 表单权限
const { hasFormP } = usePermission();
defineExpose({ init });
function init(data) {
state.submitType = 0;
state.isContinue = false;
state.title = !data.id ? t('common.add2Text','新增') : t('common.editText','编辑');
#if(${context.hasConfirmAndAddBtn}) state.continueText = !data.id ? t('common.continueAndAddText','确定并新增') : t('common.continueText','确定并继续'); #end
setFormProps({ continueLoading: false });
state.dataForm.id = data.id;
#if(${context.popupType}=="fullScreen")
openPopup();
#end
#if(${context.popupType}=="general")
openModal();
#end
#if(${context.popupType}=="drawer")
openDrawer();
#end
state.allList = data.allList;
state.currIndex = state.allList.length && data.id ? state.allList.findIndex((item) => item.id === data.id) : 0;
nextTick(() => {
getForm().resetFields();
#foreach($child in ${context.children})
state.dataForm.${child.aliasLowName}List = [];
#end
setTimeout(initData, 0);
});
}
function initData() {
changeLoading(true);
#InitActiveValue()
if (state.dataForm.id) {
getData(state.dataForm.id);
} else {
//初始化options
#EditGetOption(false)
// 设置默认值
state.dataForm={
#CreateDataform()
};
if (getLeftTreeActiveInfo) state.dataForm = {...state.dataForm, ...(getLeftTreeActiveInfo() || {}) };
state.childIndex = -1;
changeLoading(false);
}
}
function getForm() {
const form = unref(formRef);
if (!form) {
throw new Error('form is null!');
}
return form;
}
function getData(id) {
getInfo(id).then((res) => {
state.dataForm = res.data || {};
## 初始化options
#EditGetOption(true)
state.childIndex = -1;
changeLoading(false);
});
}
async function handleSubmit(type) {
try {
const values = await getForm()?.validate();
if (!values) return;
### 非流程子表字段验证
#if(!$context.isFlow)
#foreach($itemModel in ${context.children})
if(!$!{itemModel.aliasLowName}Exist()) return;
#end
#end
setFormProps({ confirmLoading: true });
const formMethod = state.dataForm.id ? update : create;
formMethod(state.dataForm)
.then((res) => {
createMessage.success(res.msg);
setFormProps({ confirmLoading: false });
if (state.submitType == 1) {
initData();
state.isContinue = true;
} else {
setFormProps({ open: false });
emit('reload');
}
})
.catch(() => {
setFormProps({ confirmLoading: false });
});
} catch (_) {}
}
function handlePrev() {
state.currIndex--;
handleGetNewInfo();
}
function handleNext() {
state.currIndex++;
handleGetNewInfo();
}
function handleGetNewInfo() {
changeLoading(true);
getForm().resetFields();
const id = state.allList[state.currIndex].id;
getData(id);
}
function setFormProps(data) {
#if(${context.popupType}=="fullScreen")
setPopupProps(data);
#end
#if(${context.popupType}=="general")
setModalProps(data);
#end
#if(${context.popupType}=="drawer")
setDrawerProps(data);
#end
}
function changeLoading(loading) {
#if(${context.popupType}=="fullScreen")
setPopupProps({ loading });
#end
#if(${context.popupType}=="general")
setModalProps({ loading });
#end
#if(${context.popupType}=="drawer")
setDrawerProps({ loading });
#end
}
async function onClose() {
if (state.isContinue) emit('reload');
return true;
}
##合计方法
#if($childSummary==true)
//子表合计方法
function getCmpValOfRow(row, key, summaryField) {
if (!summaryField.length) return '';
const isSummary = key => summaryField.includes(key);
const target = row[key];
if (!target) return '';
let data = isNaN(target) ? 0 : Number(target);
if (isSummary(key)) return data || 0;
return '';
}
#end
##数据联动changeData方法
#ChangeData()
##子表其他方法
#CreateChildTableMethod()
##子表弹窗数据方法
#if($isSelectDialog == true)
#ChildDialogMethod()
#end
##数据选项--数据字典和远端数据初始化方法
#GetDataOptionsMethod()
##动态时间处理
#GetRelationDate()
</script>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/app/form.vue.vm")

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/app/index.vue.vm")

View File

@@ -0,0 +1 @@
#parse("TemplateCode5/html/Form.vue.vm")

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/html/index.vue.vm")

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/html/indexEdit.vue.vm")

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/app/form.vue.vm")

View File

@@ -0,0 +1,144 @@
#parse("PublicMacro/FormMarco.vm")
<template>
<BasicPopup v-bind="$attrs" @register="registerPopup" :show-back-icon="false" :show-cancel-btn="false" title="${context.formModelName}">
<template #insertToolbar>
<a-button type="primary" @click="handleSubmit" :loading="btnLoading">{{t('common.saveText','保存')}}</a-button>
<a-button type="warning" class="ml-10px" @click="handleReset">{{t('component.cropper.btn_reset','重置')}}</a-button>
</template>
<a-row class="p-10px dynamic-form ${context.formStyle}" :style="{ margin: '0 auto', width: '100%' }">
<!-- 表单 -->
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" :rules="dataRule" ref="formRef" >
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#FormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
#if($isSelectDialog == true)
<SelectModal :config="state.currTableConf" :formData="state.dataForm" ref="selectModal" @select="addForSelect"/>
#end
</BasicPopup>
</template>
<script lang="ts" setup>
import { create } from './helper/api';
import { reactive, toRefs, nextTick, ref, unref, computed, toRaw} from 'vue';
import { BasicPopup, usePopupInner } from '@/components/Popup';
import { useUserStore } from '@/store/modules/user';
import type { FormInstance } from 'ant-design-vue';
import { useMessage } from '@/hooks/web/useMessage';
import { useI18n } from '@/hooks/web/useI18n';
import { ZeroRelationForm } from '@/components/Zero';
#if($isSelectDialog == true)
import SelectModal from '@/components/CommonModal/src/SelectModal.vue';
#end
import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/zero';
import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
// 表单权限
import { usePermission } from '@/hooks/web/usePermission';
import dayjs from 'dayjs';
import { cloneDeep } from 'lodash-es';
import { buildUUID } from '@/utils/uuid';
import { CaretRightOutlined } from '@ant-design/icons-vue';
interface State {
btnLoading: boolean;
#createStateParam("any")
}
defineEmits(['register']);
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { createMessage, createConfirm } = useMessage();
const { t } = useI18n();
const [registerPopup, { changeLoading }] = usePopupInner(init);
const formRef = ref<FormInstance>();
#if($isSelectDialog == true)
// 子表弹窗数据
const selectModal = ref(null);
#end
const state = reactive<State>({
btnLoading: false,
#createStateParam()
});
const { dataForm, dataRule, btnLoading, optionsObj, ableAll, maskConfig } = toRefs(state);
// 表单权限
const { hasFormP } = usePermission();
#GetChildTableColumns()
function init() {
changeLoading(true);
#EditGetOption(false)
#InitActiveValue()
nextTick(() => {
changeLoading(false);
});
}
async function handleSubmit() {
try {
const values = await getForm()?.validate();
if (!values) return;
### 非流程子表字段验证
#if(!$context.isFlow)
#foreach($itemModel in ${context.children})
if(!$!{itemModel.aliasLowName}Exist()) return;
#end
#end
state.btnLoading = true;
create(state.dataForm)
.then(res => {
createMessage.success(res.msg);
state.btnLoading = false;
handleReset();
})
.catch(() => {
state.btnLoading = false;
});
} catch (_) {}
}
function handleReset() {
getForm().resetFields();
#foreach($child in ${context.children})
state.dataForm.${child.aliasLowName}List = [];
#end
init();
}
function getForm() {
const form = unref(formRef);
if (!form) {
throw new Error('form is null!');
}
return form;
}
##数据联动changeData方法
#ChangeData()
##子表其他方法
#CreateChildTableMethod()
##子表弹窗数据方法
#if($isSelectDialog == true)
#ChildDialogMethod()
#end
##合计方法
#if($childSummary==true)
//子表合计方法
function getCmpValOfRow(row, key, summaryField) {
if (!summaryField.length) return '';
const isSummary = key => summaryField.includes(key);
const target = row[key];
if (!target) return '';
let data = isNaN(target) ? 0 : Number(target);
if (isSummary(key)) return data || 0;
return '';
}
#end
##数据选项--数据字典和远端数据初始化方法
#GetDataOptionsMethod()
##动态时间处理
#GetRelationDate()
</script>

View File

@@ -0,0 +1,21 @@
<template>
<div class="zero-content-wrapper bg-white">
<FormPopup @register="registerFormPopup" />
</div>
</template>
<script lang="ts" setup>
import { onMounted } from 'vue';
import { usePopup } from '@/components/Popup';
import FormPopup from './FormPopup.vue';
const [registerFormPopup, { openPopup: openFormPopup }] = usePopup();
function init() {
openFormPopup(true, {});
}
onMounted(() => {
init();
});
</script>

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/app/form.vue.vm")

View File

@@ -0,0 +1,60 @@
<template>
<view class="zero-wrap zero-wrap-form">
<FlowBox v-if="flowVisible" ref="FlowBox" ></FlowBox>
</view>
</template>
<script>
import FlowBox from '@/pages/workFlow/flowBefore/index.vue'
import {
getFlowStartFormId
} from "@/api/workFlow/flowEngine";
export default {
components: {
FlowBox,
},
data() {
return {
flowId : '',//请在此处填写流程id
flowVisible:false,
}
},
onLoad(e) {
this.getFlowId()
},
methods: {
getFlowId(){
if(!this.flowId)return this.$u.toast("流程模板的flowId未填写")
getFlowStartFormId(this.flowId).then(res=>{
this.flow()
}).catch(()=>{
})
},
flow() {
const config = {
flowId: this.flowId,
opType: '-1',
hideSaveBtn: true,
}
if (!this.flowId) return this.$u.toast("该功能未配置流程不可用!")
this.flowVisible = true
this.$nextTick(()=>{
this.$refs.FlowBox.handleCodeGeneration(config)
})
},
},
}
</script>
<style lang="scss">
page {
background-color: #f0f2f6;
height: 100%;
/* #ifdef MP-ALIPAY */
position: absolute;
top: 0;
left: 0;
width: 100%;
/* #endif */
}
</style>

View File

@@ -0,0 +1,111 @@
#parse("PublicMacro/FormMarco.vm")
<template>
<div class="flow-form ${context.formStyle}">
<a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
#if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
:model="dataForm" :rules="dataRule" ref="formRef" :disabled="config.disabled">
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#FormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
#if($isSelectDialog == true)
<SelectModal :config="state.currTableConf" :formData="state.dataForm" ref="selectModal" @select="addForSelect"/>
#end
</div>
</template>
<script lang="ts" setup>
import { reactive, toRefs, onMounted, ref , unref , computed, nextTick, toRaw, inject} from 'vue';
import { useFlowForm } from '@/views/workFlow/workFlowForm/hooks/useFlowForm';
import type { FormInstance } from 'ant-design-vue';
import { ZeroRelationForm } from '@/components/Zero';
import { useMessage } from '@/hooks/web/useMessage';
import { useUserStore } from '@/store/modules/user';
#if($isSelectDialog == true)
import SelectModal from '@/components/CommonModal/src/SelectModal.vue';
#end
import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/zero';
import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
import dayjs from 'dayjs';
import { cloneDeep } from 'lodash-es';
import { buildUUID } from '@/utils/uuid';
import { CaretRightOutlined } from '@ant-design/icons-vue';
import { useI18n } from '@/hooks/web/useI18n';
interface State {
#createStateParam("any")
}
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { t } = useI18n();
const props = defineProps(['config']);
const emit = defineEmits(['setPageLoad', 'eventReceiver']);
const getLeftTreeActiveInfo: (() => any) | null = inject('getLeftTreeActiveInfo', null);
const formRef = ref<FormInstance>();
const state = reactive<State>({
#createStateParam()
});
const { createMessage, createConfirm } = useMessage();
const { dataForm, dataRule, optionsObj, ableAll, maskConfig } = toRefs(state);
const { init, judgeShow, judgeWrite,judgeRequired, dataFormSubmit } = useFlowForm({
config: props.config,
selfState: state,
emit,
formRef,
selfInit,
selfGetInfo,
});
defineExpose({ dataFormSubmit });
##新增初始化数据
function selfInit() {
#EditGetOption(false)
#InitActiveValue()
state.childIndex = -1;
if (getLeftTreeActiveInfo) state.dataForm = {...state.dataForm, ...(getLeftTreeActiveInfo() || {}) };
}
##编辑和详情初始化数据
function selfGetInfo(dataForm) {
#EditGetOption(true)
#InitActiveValue()
}
onMounted(() => {
init();
});
#if($isSelectDialog == true)
// 子表弹窗数据
const selectModal = ref(null);
#end
#GetChildTableColumns()
##数据联动changeData方法
#ChangeData()
##子表其他方法
#CreateChildTableMethod()
##子表弹窗数据方法
#if($isSelectDialog == true)
#ChildDialogMethod()
#end
##合计方法
#if($childSummary==true)
//子表合计方法
function getCmpValOfRow(row, key, summaryField) {
if (!summaryField.length) return '';
const isSummary = key => summaryField.includes(key);
const target = row[key];
if (!target) return '';
let data = isNaN(target) ? 0 : Number(target);
if (isSummary(key)) return data || 0;
return '';
}
#end
##数据选项--数据字典和远端数据初始化方法
#GetDataOptionsMethod()
##动态时间处理
#GetRelationDate()
</script>

View File

@@ -0,0 +1,62 @@
<template>
<div class="zero-content-wrapper bg-white">
<FlowParser @register="registerFlowParser" @reload="init()" />
</div>
</template>
<script lang="ts" setup>
import { reactive, onMounted, toRefs} from 'vue';
import { useMessage } from '@/hooks/web/useMessage';
import { usePopup } from '@/components/Popup';
import FlowParser from '@/views/workFlow/components/FlowParser.vue';
import { getFlowStartFormId } from '@/api/workFlow/template';
import { useTabs } from '@/hooks/web/useTabs';
import { useRouter } from 'vue-router';
interface State {
flowId: string;
}
const { close } = useTabs();
const router = useRouter();
const { createMessage } = useMessage();
const [registerFlowParser, { openPopup: openFlowParser }] = usePopup();
const state = reactive<State>({
flowId: '',//请在此处填写流程模板id
});
function init() {
const data = {
id: '',
flowId: state.flowId,
opType: '-1',
hideCancelBtn: true,
hideSaveBtn: true,
};
openFlowParser(true, data);
}
#if(${context.isFlow})
function getFlowId(){
if(!state.flowId){
createMessage.error('流程模板的flowId未填写')
close();
router.replace('/404');
return
}
getFlowStartFormId(state.flowId).then(res => {
init()
}).catch(() => {
close();
router.replace('/404');
});
}
#end
onMounted(() => {
#if(${context.isFlow})
getFlowId()
#else
init();
#end
});
</script>

View File

@@ -0,0 +1,86 @@
#set($className = "${context.className}")
#set($Name = "${className.substring(0,1).toUpperCase()}${className.substring(1)}")
#set($name = "${className.substring(0,1).toLowerCase()}${className.substring(1)}")
## 获取列表信息
#macro(GetList)
/**
* 列表
*
* @param ${name}Pagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody ${Name}Pagination ${name}Pagination) {
boolean isPc = "pc".equals(ServletUtil.getHeader("zero-origin" ));
String columnData = !isPc ? ${Name}Constant.getAppColumnData() : ${Name}Constant.getColumnData();
PageListVO interfaceData = generaterSwapUtil.getInterfaceData(${Name}Constant.INTERFACE_ID, ${Name}Constant.INTERFACE_PARAM, ${name}Pagination, columnData, isPc);
return ActionResult.success(interfaceData);
}
#end
## 导出
#macro(ExportMethod)
/**
* 导出Excel
*
* @return
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody ${Name}Pagination ${name}Pagination) {
if (StringUtil.isEmpty(${name}Pagination.getSelectKey())){
return ActionResult.fail("请选择导出字段");
}
boolean isPc = "pc".equals(ServletUtil.getHeader("zero-origin" ));
String columnData = !isPc ? ${Name}Constant.getAppColumnData() : ${Name}Constant.getColumnData();
DownloadVO vo = generaterSwapUtil.exportInterfaceData(${Name}Constant.INTERFACE_ID, ${Name}Constant.INTERFACE_PARAM, ${name}Pagination, columnData);
return ActionResult.success(vo);
}
#end
package ${context.package}.controller;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.zero.base.ActionResult;
import com.zero.base.vo.DownloadVO;
import com.zero.base.vo.PageListVO;
import com.zero.model.$!{name.toLowerCase()}.$!{Name}Constant;
import com.zero.model.$!{name.toLowerCase()}.$!{Name}Pagination;
import com.zero.util.GeneraterSwapUtil;
import com.zero.util.ServletUtil;
import com.zero.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* ${context.genInfo.description}
* @版本: ${context.genInfo.version}
* @版权: ${context.genInfo.copyright}
* @作者: ${context.genInfo.createUser}
* @日期: ${context.genInfo.createDate}
*/
@Slf4j
@RestController
@Tag(name = "${context.genInfo.description}" , description = "${context.module}")
#if(${context.isCloud}=="cloud")
@RequestMapping("/${Name}")
#else
@RequestMapping("/api/${context.module}/${className}")
#end
public class ${className}Controller {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
## 获取列表信息
#GetList()
## 导出数据
#if(${context.hasDownloadBtn})
#ExportMethod()
#end
}

View File

@@ -0,0 +1 @@
#parse("TemplateCode2/html/index.vue.vm")

View File

@@ -0,0 +1,44 @@
## api接口
#set($url="import { defHttp } from '@/utils/http/axios';")
$url
// 获取列表
export function getList(data) {
#set($getListReq=".post({ url: '/api/"+${context.module}+"/"+${context.className}+"/getList', data })")
return defHttp$getListReq;
}
// 新建
export function create(data) {
#set($createReq=".post({ url:'/api/"+${context.module}+"/"+${context.className}+"', data })")
return defHttp$createReq;
}
// 修改
export function update(data) {
#set($updateReq=".put({ url: '/api/"+${context.module}+"/"+${context.className}+"/'+ data.id, data })")
return defHttp$updateReq;
}
// 详情(无转换数据)
export function getInfo(id) {
#set($getInfoReq=".get({ url: '/api/"+${context.module}+"/"+${context.className}+"/' + id })")
return defHttp$getInfoReq;
}
// 获取(转换数据)
export function getDetailInfo(id) {
#set($getDetailInfoReq=".get({ url: '/api/"+${context.module}+"/"+${context.className}+"/detail/' + id })")
return defHttp$getDetailInfoReq;
}
// 删除
export function del(id) {
#set($delReq=".delete({ url: '/api/"+${context.module}+"/"+${context.className}+"/' + id })")
return defHttp$delReq;
}
// 批量删除数据
export function batchDelete(data) {
#set($batchDeleteReq=".delete({ url: '/api/"+${context.module}+"/"+${context.className}+"/batchRemove', data })")
return defHttp$batchDeleteReq;
}
// 导出
export function exportData(data) {
#set($exportDataReq=".post({ url: '/api/"+${context.module}+"/"+${context.className}+"/Actions/Export', data })")
return defHttp$exportDataReq;
}

View File

@@ -0,0 +1,101 @@
#set($name = "${context.className.substring(0,1).toUpperCase()}${context.className.substring(1)}")
#macro(GetLongStr $longStr)
#set($num=${longStr.length()}/65000)
#if($num>0)
#foreach($foo in [0..$num])
#if($foo==0)
#set($endstr='");')
#if(${longStr.substring(0,65000).endsWith('\')})
#set($endstr='"");')
#end
sb.append(${longStr.substring(0,65000)}$endstr
#elseif($foo==$num)
#set($startIndex=$foo*65000)
#set($startstr='"')
#if(${longStr.substring($startIndex).startsWith('"')})
#set($startstr='')
#end
sb.append($startstr${longStr.substring($startIndex)});
#else
#set($startIndex=$foo*65000)
#set($endIndex=($foo+1)*65000)
#set($endstr='");')
#if(${longStr.substring($startIndex,$endIndex).endsWith('\')})
#set($endstr='"");')
#end
#if(${longStr.substring($startIndex,$endIndex).endsWith('\\')})
#set($endstr='");')
#end
#set($startstr='"')
#if(${longStr.substring($startIndex,$endIndex).startsWith('"')})
#set($startstr='')
#end
sb.append($startstr${longStr.substring($startIndex,$endIndex)}$endstr
#end
#end
#else
#if($longStr)sb.append($longStr);#end
#end
#end
package ${context.package}.model.$!{name.toLowerCase()};
import com.yunzhupaas.util.JsonUtil;
import java.util.*;
/**
* ${context.genInfo.description}配置json
*
* @版本: ${context.genInfo.version}
* @版权: ${context.genInfo.copyright}
* @作者: ${context.genInfo.createUser}
* @日期: ${context.genInfo.createDate}
*/
public class $!{name}Constant{
#if($context.webType == 4)
/** 接口信息 */
public static final String INTERFACE_ID = "${context.interfaceId}";
public static final String INTERFACE_PARAM = #if(${context.interfaceParam}) ${context.interfaceParam} #else ""#end;
#else
/** 数据库链接 */
public static final String DBLINKID = "${context.dbLinkId}";
/** 表别名 map */
public static final Map<String,String> TABLERENAMES = JsonUtil.getJsonToBean(${context.tableRenames},Map.class);
/** 子表model map */
public static final Map<String,String> TABLEFIELDKEY = JsonUtil.getJsonToBean(${context.childKeyTableNameMap},Map.class);
/** 整个表单配置json */
public static final String getFormData(){
StringBuilder sb = new StringBuilder();
#GetLongStr(${context.formDataStr})
return sb.toString();
}
#end
#if($context.isList)
/** 列表字段配置json */
public static final String getColumnData(){
StringBuilder sb = new StringBuilder();
#GetLongStr(${context.columnDataStr})
return sb.toString();
}
/** app列表字段配置json */
public static final String getAppColumnData(){
StringBuilder sb = new StringBuilder();
#GetLongStr(${context.appColumnDataStr})
return sb.toString();
}
#if($context.webType!=4)
/** 表列表 */
public static final String getTableList(){
StringBuilder sb = new StringBuilder();
#GetLongStr(${context.tableListStr})
return sb.toString();
}
#end
#end
#if($context.billRule)
/** 单据规则 */
#foreach($key in ${context.billRule.keySet()})
public static final String $key = ${context.billRule.get($key)};
#end
#end
}

View File

@@ -0,0 +1,203 @@
#parse("PublicMacro/ControllerMarco.vm")
package ${package.Controller};
#set($peimaryKeyName = "${pKeyName.substring(0,1).toUpperCase()}${pKeyName.substring(1)}")
#set($peimaryKeyname = "${pKeyName.substring(0,1).toLowerCase()}${pKeyName.substring(1)}")
#set($serviceName = "${table.serviceName.substring(0,1).toLowerCase()}${table.serviceName.substring(1)}")
#set($Name = "${genInfo.className.substring(0,1).toUpperCase()}${genInfo.className.substring(1)}")
#set($name = "${genInfo.className.substring(0,1).toLowerCase()}${genInfo.className.substring(1)}")
#set($packName = "${genInfo.className.toLowerCase()}")
#set($searchListSize =$!{searchList})
#set($columnListSize=$!{columnList})
#set($serverHasUpload = false)
#set($serverHasDownload = false)
#foreach($btn in ${btnsList})
#if(${btn.value}=='upload' && ${btn.show})
#set($serverHasUpload = true)
#end
#if(${btn.value}=='download' && ${btn.show})
#set($serverHasDownload = true)
#end
#end
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.yunzhupaas.base.ActionResult;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.permission.entity.UserEntity;
import com.yunzhupaas.constant.MsgCode;
import ${package.Service}.*;
import ${package.Entity}.*;
import com.yunzhupaas.util.*;
import ${modulePackageName}.model.${packName}.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.yunzhupaas.flowable.entity.TaskEntity;
#if(${springVersion.startsWith("2")})
import javax.validation.Valid;
#else
import jakarta.validation.Valid;
#end
import java.util.*;
import com.yunzhupaas.model.ExcelModel;
import com.yunzhupaas.excel.ExcelExportStyler;
import com.yunzhupaas.excel.ExcelHelper;
#if($isList)
import com.yunzhupaas.annotation.yunzhupaasField;
import com.yunzhupaas.base.vo.PageListVO;
import com.yunzhupaas.base.vo.PaginationVO;
import com.yunzhupaas.base.vo.DownloadVO;
import com.yunzhupaas.config.ConfigValueUtil;
import com.yunzhupaas.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import com.yunzhupaas.flowable.entity.TaskEntity;
import com.yunzhupaas.exception.WorkFlowException;
import com.yunzhupaas.model.visualJson.UploaderTemplateModel;
import com.yunzhupaas.base.util.FormExecelUtils;
#end
#if(${serverHasUpload} || ${serverHasDownload})
import org.springframework.web.multipart.MultipartFile;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import com.yunzhupaas.onlinedev.model.ExcelImFieldModel;
import com.yunzhupaas.base.model.OnlineImport.ImportDataModel;
import com.yunzhupaas.base.model.OnlineImport.ImportFormCheckUniqueModel;
import com.yunzhupaas.base.model.OnlineImport.ExcelImportModel;
import com.yunzhupaas.base.model.OnlineImport.VisualImportModel;
import cn.xuyanwu.spring.file.storage.FileInfo;
import lombok.Cleanup;
import com.yunzhupaas.model.visualJson.config.HeaderModel;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.yunzhupaas.base.util.VisualUtils;
#end
#if(${DS})
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
#else
import org.springframework.transaction.annotation.Transactional;
#end
#if(${isCloud}=="cloud")
import com.yunzhupaas.model.upload.UploadFileModel;
import com.yunzhupaas.file.FileApi;
import com.yunzhupaas.constant.FileTypeConstant;
import java.io.ByteArrayOutputStream;
import com.yunzhupaas.file.FileUploadApi;
import org.apache.dubbo.config.annotation.DubboReference;
#end
/**
* ${genInfo.description}
* @版本: ${genInfo.version}
* @版权: ${genInfo.copyright}
* @作者: ${genInfo.createUser}
* @日期: ${genInfo.createDate}
*/
@Slf4j
@RestController
@Tag(name = "${genInfo.description}" , description = "${module}")
#if(${isCloud}=="cloud")
#if(${module}=="form")
@RequestMapping("/${module}/${genInfo.className}")
#else
@RequestMapping("/${genInfo.className}")
#end
#else
#if(${module}=="form")
##添加流程表单模块名称
@RequestMapping("/api/workflow/${module}/${genInfo.className}")
#else
@RequestMapping("/api/${module}/${genInfo.className}")
#end
#end
public class ${table.controllerName} {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private ${table.serviceName} ${serviceName};
#foreach($tableModel in ${childTableHandle})
@Autowired
private ${tableModel.aliasUpName}Service ${tableModel.aliasLowName}Service;
#end
#foreach($cl in ${columnTableHandle})
@Autowired
private ${cl.modelUpName}Service ${cl.modelLowName}Service;
#end
#if(${serverHasUpload} || ${serverHasDownload})
@Autowired
private ConfigValueUtil configValueUtil;
#if(${isCloud}=="cloud")
@Autowired
private FileUploadApi fileUploadApi;
@Autowired
private FileApi fileApi;
#end
#end
##表头按钮接口
#if(!${isList})## 纯表单方法
#CreateMethod()
#UpdateMethod()
#DeleteMethod()
#else## 列表方法
## 获取列表信息
#GetList()
## 表头按键接口
#foreach($btn in ${btnsList})
#if(${btn.value}=='add' && ${btn.show})
#CreateMethod(${table.comment})
#end
#if(${btn.value}=='upload' && ${btn.show})
#UploaderMethod()
#end
#if(${btn.value}=='download' && ${btn.show})
#ExportMethod()
#end
#if(${btn.value}=='batchRemove' && ${btn.show})
#end
#if(${btn.value}=='batchPrint' && ${btn.show})
#BatchPrintMethod()
#end
#end
## 删除全部走批量删除方法。(必生成)
#DeleteMethod()
#BatchRemoveMethod()
## 行内按钮接口
#foreach($column in ${columnBtnsList})
#if(${column.value}=='detail' && ${column.show} && ${isList})
#GetDetailMethod()
#end
#if(${column.value}=='remove' && ${column.show} && ${isList})
## #DeleteMethod()
#end
#if(${column.value}=='edit' && ${column.show} && ${isList})
#UpdateMethod(${table.comment})
#end
#end
#end
## 获取数据接口(不转换数据)
#GetInfoMethod()
}

View File

@@ -0,0 +1,92 @@
package ${package.Entity};
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
#foreach($field in ${table.fields})
#if(${field.propertyType} =='BigDecimal')
import java.math.BigDecimal;
#elseif(${field.propertyType} == 'BigInteger')
import java.math.BigInteger;
#elseif(${field.propertyType} == 'LocalTime')
import java.sql.Time;
#end
#end
/**
* ${table.comment}
*
* @版本: ${genInfo.version}
* @版权: ${genInfo.copyright}
* @作者: ${genInfo.createUser}
* @日期: ${genInfo.createDate}
*/
@Data
#if(${table.convert})
@TableName("${table.name}")
#end
#if(${activeRecord})
public class ${table.entity} extends Model<${table.entity}> {
#else
public class ${table.entityName} {
#end
#foreach($field in ${table.fields})
#set($tableField = "${field.name}")
#set($Property = "${field.propertyName}")
#if('f_tenant_id'==${tableField} || 'F_TENANT_ID'==${tableField})
@TableField(value = "${tableField}",fill = FieldFill.INSERT_UPDATE)
#elseif(${field.keyFlag}=='true')
@TableId(value ="${tableField}" #if(${field.keyIdentityFlag}),type = IdType.AUTO #end)
#else
#if(${tableNotSystemField.contains(${Property.toUpperCase()})})
@TableField(value = "${tableField}" , updateStrategy = FieldStrategy.IGNORED)
#else
@TableField("${tableField}")
#end
#end
#if('f_version'==${tableField.toLowerCase()})
@Version
@JSONField(name = "f_version")
#else
@JSONField(name = "${tableField}")
#end
#if(${field.propertyType} =='LocalDateTime' || ${field.propertyType} =='datePicker' || ${field.propertyType} =='LocalDate')
private Date ${Property};
#elseif(${field.propertyType} =='Clob')
private String ${Property};
#elseif(${field.propertyType} == 'LocalTime')
private Time ${Property};
#elseif(${field.type} =='datetime')
private Date ${Property};
#elseif(${field.type} =='datetime')
private Date ${Property};
#else
## 删除标记和版本字段强制int
#if(${tableField.toLowerCase()} =='f_version' || ${tableField.toLowerCase()} =='f_delete_mark')
private Integer ${Property};
#else
private ${field.propertyType} ${Property};
#end
#end
#end
#if(${main})
#foreach($item in $allTableNameList)
#set($TableEntity = "${item.table.substring(0,1).toUpperCase()}${item.table.substring(1)}")
#set($tableEntity = "${item.table.substring(0,1).toLowerCase()}${item.table.substring(1)}")
## 副表一对一
#if(${item.tableTag} =='sub-yunzhupaas')
@JSONField(name = "${tableEntity}")
@TableField(exist = false)
private ${TableEntity}Entity $tableEntity;
#end
## 子表一对多
#if(${item.tableTag} =='sub')
@JSONField(name = "${tableEntity}")
@TableField(exist = false)
private List<${TableEntity}Entity> $tableEntity;
#end
#end
#end
}

View File

@@ -0,0 +1,26 @@
#set($name = "${context.className.substring(0,1).toLowerCase()}${context.className.substring(1)}")
#set($pKeyName =${context.pKeyName})
#set($peimaryKeyName = "${pKeyName.substring(0,1).toUpperCase()}${pKeyName.substring(1)}")
#set($peimaryKeyname = "${pKeyName.substring(0,1).toLowerCase()}${pKeyName.substring(1)}")
package ${context.package}.model.$!{name.toLowerCase()};
import lombok.Data;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.fastjson.annotation.JSONField;
/**
*
* ${context.genInfo.description}
* @版本: ${context.genInfo.version}
* @版权: ${context.genInfo.copyright}
* @作者: ${context.genInfo.createUser}
* @日期: ${context.genInfo.createDate}
*/
@Data
public class $!{context.className}ExcelErrorVO extends $!{context.className}ExcelVO{
@Excel(name = "异常原因",orderNum = "-999")
@JSONField(name = "errorsInfo")
private String errorsInfo;
}

View File

@@ -0,0 +1,79 @@
#parse("PublicMacro/ExcelMarco.vm")
##通用参数
#parse("PublicMacro/ConstantMarco.vm")
#ConstantParams()
#set($moduleName = "${context.genInfo.className.toLowerCase()}")
package ${context.package}.model.${moduleName};
import lombok.Data;
import java.sql.Time;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
import java.math.BigDecimal;
import java.util.List;
/**
*
* ${context.genInfo.description}
* @版本: ${context.genInfo.version}
* @版权: ${context.genInfo.copyright}
* @作者: ${context.genInfo.createUser}
* @日期: ${context.genInfo.createDate}
*/
@Data
public class $!{context.className}ExcelVO{
#if(${context.isMain} && !${context.isComplexVo})
## 复杂表头对象
#foreach($item in ${context.complexHeaderList})
#if(${item.childColumns.size()}>0)
@JsonProperty("${item.id}")
@ExcelCollection(name="${item.fullName}(${item.id})",orderNum = "0")
private List<Complex${item.id}ExcelVO> ${item.id};
#end
#end
#foreach($fieLdsModel in ${context.importFields})
#set($html = $fieLdsModel)
#set($vModel = "${html.vModel}")
#set($config = $html.config)
#set($yunzhupaaskey = "${config.yunzhupaasKey}")
## 判断是否子表
#if(${vModel.toLowerCase().startsWith("tablefield")} )
@JsonProperty("${vModel}")
@ExcelCollection(name="${html.label}(${vModel})",orderNum = "${html.childList.size()}")
private List<${html.aliasUpName}ExcelVO> ${vModel};
#else
#if(!${context.complexFieldList.contains(${vModel})})
#CreateExcelFields($html,${foreach.index})
#end
#end
#end
#elseif(${context.isMain} && ${context.isComplexVo})
#foreach($fieLdsModel in ${context.importFields})
#set($html = $fieLdsModel)
#set($vModel = "${html.vModel}")
#set($config = $html.config)
#set($yunzhupaaskey = "${config.yunzhupaasKey}")
##复杂表头字段
#if(${context.complexList.contains(${vModel})} )
#CreateExcelFields($html,${foreach.index})
#end
#end
#else
#foreach($html in ${context.children.childList})
#set($fieLdsModel = ${html.fieLdsModel})
#set($config = ${fieLdsModel.config})
#set($yunzhupaaskey = ${config.yunzhupaasKey})
#set($vModel = "${fieLdsModel.vModel}")
#set($fieldName=${config.label})
#if($!vModel && ${fieLdsModel.needImport} && !$DownLoadSkipUint.contains($yunzhupaaskey))
#CreateExcelFields($fieLdsModel,${foreach.index})
#end
#end
#end
}

View File

@@ -0,0 +1,98 @@
##通用参数
#parse("PublicMacro/ConstantMarco.vm")
#ConstantParams()
#set($modelPath = "model."+${context.modelPathName})
#set($pKeyName =${context.pKeyName})
#set($pKeyNameOriginal =${context.pKeyNameOriginal})
#set($peimaryKeyname = "${pKeyName.substring(0,1).toLowerCase()}${pKeyName.substring(1)}")
package ${context.package}.${modelPath};
import lombok.Data;
import java.util.*;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* ${context.genInfo.description}
* @版本: ${context.genInfo.version}
* @版权: ${context.genInfo.copyright}
* @作者: ${context.genInfo.createUser}
* @日期: ${context.genInfo.createDate}
*/
@Data
@Schema(description = "表单参数")
public class $!{context.className}Form {
/** 主键 */
@Schema(description = "主键")
@JSONField(name = "${pKeyNameOriginal}")
private String $!{peimaryKeyname};
#if(${context.version})
/** 乐观锁 **/
@Schema(description = "乐观锁")
@JsonProperty("f_version")
@JSONField(name = "f_version")
private Integer version;
#end
#if(${context.isFlow})
/** 流程id **/
@Schema(description = "流程id")
@JsonProperty("flowId")
@JSONField(name = "f_flow_id")
private String flowId;
/** 流程权限列表 **/
@JsonProperty("formOperates")
private List<Map<String,Object>> formOperates = new ArrayList<>();
#end
## 主副表字段
#foreach($item in ${context.form})
#if($item.yunzhupaasKey=='mast' || $item.yunzhupaasKey=='mastTable')
#set($html = $item.formColumnModel.fieLdsModel)
#set($vModel = "${html.vModel}")
#set($fieldAlias = "${html.fieldAlias}")
#if($item.yunzhupaasKey=='mastTable')
#set($html = $item.formMastTableModel.mastTable.fieLdsModel)
#set($vModel = "${item.formMastTableModel.vModel}")
#set($fieldAlias = "yunzhupaas_"+"${html.tableAlias}"+"_yunzhupaas_"+ "${html.fieldAlias}")
#end
#set($resultType = "String")
#if($vModel!='')
#set($config = $html.config)
#set($yunzhupaaskey = "${config.yunzhupaasKey}")
#set($fieldName=${config.label})
#if(${yunzhupaaskey}!='text' && ${yunzhupaaskey}!='divider')
#if(${yunzhupaaskey}=='inputNumber' || ${yunzhupaaskey}=='calculate')
#if(${fieLdsModel.formColumnModel.fieLdsModel.precision}==0)
#set($resultType = "Integer")
#else
#set($resultType = "BigDecimal")
#end
#elseif(${yunzhupaaskey}=='slider' || ${yunzhupaaskey} == 'rate')
#set($resultType = "BigDecimal")
#elseif(${yunzhupaaskey} == 'switch')
#set($resultType = "Integer")
#elseif(${multipleUnit.contains(${yunzhupaaskey})} || ${UploadFileUnit.contains(${yunzhupaaskey})})
#set($resultType = "Object")
#else
#set($resultType = "String")
#end
/** ${fieldName} **/
@Schema(description = "${fieldName}")
@JsonProperty("${vModel}")
@JSONField(name = "${vModel}")
private ${resultType} ${fieldAlias};
#end
#end
#end
#end
#foreach($html in ${context.children})
/** 子表数据 **/
@Schema(description = "${html.aliasLowName}子表数据")
@JsonProperty("${html.aliasLowName}List")
private List<${html.aliasUpName}Model> ${html.aliasLowName}List;
#end
}

View File

@@ -0,0 +1,17 @@
package ${package.Mapper};
import ${package.Entity}.${table.entityName};
import ${superMapperClassPackage};
import com.yunzhupaas.base.mapper.SuperMapper;
/**
* ${genInfo.description}
* 版本: ${genInfo.version}
* 版权: ${genInfo.copyright}
* 作者: ${genInfo.createUser}
* 日期: ${genInfo.createDate}
*/
public interface ${table.mapperName} extends SuperMapper<${table.entityName}> {
}

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package.Mapper}.${table.mapperName}">
</mapper>

View File

@@ -0,0 +1,83 @@
#parse("PublicMacro/ConstantMarco.vm")
#ConstantParams()
#set($moduleName = "${context.genInfo.className.toLowerCase()}")
#if($context.isForm)
#set($package = "package ${context.package}.${context.isForm}.model.${moduleName};")
#else
#set($package = "package ${context.package}.model.${moduleName};")
#end
${package}
import lombok.Data;
import java.util.List;
import java.util.Date;
import java.math.BigDecimal;
import com.alibaba.fastjson.annotation.JSONField;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
*
* ${context.genInfo.description}
* 版本: ${context.genInfo.version}
* 版权: ${context.genInfo.copyright}
* 作者: ${context.genInfo.createUser}
* 日期: ${context.genInfo.createDate}
*/
@Data
@Schema(description = "${context.className}子表参数")
public class ${context.className}Model {
#if($!{context.thisKeyFields})
#set($keyField =${context.thisKeyFields.field})
/** 子表:${context.className} 主键:${keyField} **/
@Schema(description = "主键")
@JsonProperty("${keyField}")
#if(${context.thisKeyFields.dataType} =="int")
private Integer ${keyField};
#elseif(${context.thisKeyFields.dataType} == "bigint")
private Long ${keyField};
#else
private String ${keyField};
#end
#end
#foreach($html in ${context.children.childList})
#set($fieLdsModel = ${html.fieLdsModel})
#set($config = ${fieLdsModel.config})
#set($yunzhupaaskey = ${config.yunzhupaasKey})
#set($vModel = "${fieLdsModel.vModel}")
#set($fieldName=${config.label})
#set($fieldAlias="${fieLdsModel.fieldAlias}")
#if($vModel)
#if(${yunzhupaaskey}=='datePicker')
#set($resultType="Long")
#elseif(${yunzhupaaskey}=='inputNumber' || ${yunzhupaaskey}=='calculate')
#if(${fieLdsModel.precision}==0)
#set($resultType="Integer")
#else
#set($resultType="BigDecimal")
#end
#elseif(${yunzhupaaskey}=='slider'|| ${yunzhupaaskey}=='rate')
#set($resultType="BigDecimal")
#elseif(${yunzhupaaskey}=='relationFormAttr'|| ${yunzhupaaskey}=='popupAttr' ||${yunzhupaaskey}=='relationForm' )
#set($resultType="String")
#elseif(${multipleUnit.contains($yunzhupaaskey)} || ${UploadFileUnit.contains(${yunzhupaaskey})})
#set($resultType="Object")
#else
#set($resultType="String")
#end
/** ${fieldName} **/
@Schema(description = "${fieldName}")
#if($fieLdsModel.needImport)
@Excel(name = "${fieldName}",orderNum = "1",isImportField = "true")
#end
@JsonProperty("${vModel}")
@JSONField(name = "${vModel}")
private ${resultType} ${fieldAlias};
#if(${yunzhupaaskey}=='relationForm')
private String ${vModel}_id;
#end
#end
#end
}

View File

@@ -0,0 +1,77 @@
#set($name = "${context.className.substring(0,1).toUpperCase()}${context.className.substring(1)}")
package ${context.package}.model.$!{name.toLowerCase()};
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import com.yunzhupaas.base.Pagination;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
/**
*
* ${context.genInfo.description}
* @版本: ${context.genInfo.version}
* @版权: ${context.genInfo.copyright}
* @作者: ${context.genInfo.createUser}
* @日期: ${context.genInfo.createDate}
*/
@Data
@Schema(description = "列表查询参数")
public class $!{name}Pagination extends Pagination {
#if($!{context.isFlow})
/** 流程模板id */
@Schema(description = "流程模板id")
private String flowId;
#end
/** 关键词搜索 */
@Schema(description = "关键词搜索")
private String yunzhupaasKeyword;
/** 查询key */
@Schema(description = "查询key")
private String[] selectKey;
/** 选中数据数组id */
@Schema(description = "选中数据数组id")
private Object[] selectIds;
/** json */
@Schema(description = "json")
private String json;
/** 数据类型 0-当前页1-全部数据 */
@Schema(description = "数据类型 0-当前页1-全部数据")
private String dataType;
/** 高级查询 */
@Schema(description = "高级查询")
private String superQueryJson;
/** 功能id */
@Schema(description = "功能id")
private String moduleId;
/** 菜单id */
@Schema(description = "菜单id")
private String menuId;
#foreach($search in ${context.searchListAll})
#set($jsonKey =${search.id})
#set($label = ${search.label})
#set($fieldAliasName = "${search.afterVModel}")
#set($tableAliasName = "${search.tableAliasName}")
#if($jsonKey.contains("_yunzhupaas_"))
#set($fieldAliasName = "yunzhupaas_${tableAliasName}_yunzhupaas_${fieldAliasName}")
#elseif($jsonKey.toLowerCase().startsWith("tablefield"))
#set($fieldAliasName = "${search.tableAliasName}_${fieldAliasName}")
#end
/** ${label} */
@Schema(description = "${label}")
@JsonProperty("$jsonKey")
@JSONField(name = "${fieldAliasName}")
private Object ${fieldAliasName};
#end
#if(${context.treeTable} == true)
/**
* 树形异步父级字段传值
*/
private String treeParentValue;
/**
* 是否有参数
*/
private boolean hasParam=false;
#end
}

View File

@@ -0,0 +1,43 @@
package ${package.Service};
#set($moduleName = "${mainModelName.substring(0,1).toLowerCase()}${mainModelName.substring(1).toLowerCase()}")
import ${package.Entity}.*;
import com.yunzhupaas.base.service.SuperService;
#if(${main})
import ${modulePackageName}.model.${moduleName}.*;
import java.util.*;
#end
/**
* ${genInfo.description}
* 版本: ${genInfo.version}
* 版权: ${genInfo.copyright}
* 作者: ${genInfo.createUser}
* 日期: ${genInfo.createDate}
*/
public interface ${table.serviceName} extends SuperService<${table.entityName}> {
#if(${main})
#if(${pKeyName.toLowerCase().startsWith('f_')})
#set($peimaryKeyname = "${pKeyName.substring(2,3).toLowerCase()}${pKeyName.substring(3)}")
#else
#set($peimaryKeyname = "${pKeyName.substring(0,1).toLowerCase()}${pKeyName.substring(1).toLowerCase()}")
#end
#if($isList)
List<${table.entityName}> getList(${Name}Pagination ${name}Pagination);
List<${table.entityName}> getTypeList(${Name}Pagination ${name}Pagination,String dataType);
#end
${table.entityName} getInfo(String ${peimaryKeyname});
void delete(${table.entityName} entity);
void create(${table.entityName} entity);
boolean update(String ${peimaryKeyname}, ${table.entityName} entity);
String checkForm(${Name}Form form,int i);
void saveOrUpdate(${Name}Form ${name}Form,String id, boolean isSave) throws Exception;
#end
}

View File

@@ -0,0 +1,109 @@
#parse("PublicMacro/ServiceImpMarco.vm")
#set($moduleName = "${mainModelName.substring(0,1).toLowerCase()}${mainModelName.substring(1).toLowerCase()}")
#set($peimaryKeyName="${pKeyName.substring(0,1).toUpperCase()}${pKeyName.substring(1)}")
package ${package.ServiceImpl};
import ${package.Entity}.*;
import ${package.Mapper}.${table.mapperName};
import ${package.Service}.*;
import ${superServiceImplClassPackage};
import ${modulePackageName}.model.${moduleName}.*;
import org.springframework.stereotype.Service;
import com.yunzhupaas.base.service.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import com.yunzhupaas.util.GeneraterSwapUtil;
import java.sql.Connection;
import java.sql.SQLException;
import lombok.Cleanup;
import com.yunzhupaas.database.plugins.DynamicSourceGeneratorInterface;
import com.yunzhupaas.database.util.DynamicDataSourceUtil;
import org.apache.commons.collections4.CollectionUtils;
import com.yunzhupaas.i18n.util.I18nUtil;
import com.yunzhupaas.exception.DataException;
import com.yunzhupaas.constant.MsgCode;
#if(${DS})
import com.baomidou.dynamic.datasource.annotation.DS;
import com.yunzhupaas.database.util.DataSourceUtil;
import com.yunzhupaas.database.model.entity.DbLinkEntity;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
#end
#if(${main})
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import com.yunzhupaas.base.model.ColumnDataModel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.yunzhupaas.model.QueryAllModel;
import java.text.SimpleDateFormat;
import com.yunzhupaas.util.*;
import java.util.*;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.permission.entity.UserEntity;
import com.github.pagehelper.PageHelper;
#end
/**
*
* ${genInfo.description}
* 版本: ${genInfo.version}
* 版权: ${genInfo.copyright}
* 作者: ${genInfo.createUser}
* 日期: ${genInfo.createDate}
*/
@Service
#if(${DS})
@DS("${DS}")
#end
public class ${table.serviceImplName} extends SuperServiceImpl<${table.mapperName}, ${table.entityName}> implements ${table.serviceName}#if(${DS}),DynamicSourceGeneratorInterface #end{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
#if(${main})
@Autowired
private UserProvider userProvider;
#foreach($child in ${columnTableHandle})
@Autowired
private ${child.modelUpName}Service ${child.modelLowName}Service;
#end
#foreach($subfield in ${childTableHandle})
@Autowired
private ${subfield.aliasUpName}Service ${subfield.aliasLowName}Service;
#end
## 通用变量
#set($Name = "${genInfo.className.substring(0,1).toUpperCase()}${genInfo.className.substring(1)}")
#set($name = "${genInfo.className.substring(0,1).toLowerCase()}${genInfo.className.substring(1)}")
#set($QueryWrapper = "${name}QueryWrapper")
#set($serviceName = "${table.serviceName.substring(0,1).toLowerCase()}${table.serviceName.substring(1)}")
#set($Entity = "${table.entityName}")
#set($searchListSize =$!{searchList})
#if($isList)
## 列表接口
#GetTypeList()
#end
## 增删改查接口
#CrudMethod()
## 表单验证
#CheckForm()
## 业务主键验证
#if(${useBusinessKey})
#CheckBusinessKey()
#end
## 保存修改事务方法
#SaveOrUpdate()
#end
## 数据源切换
#if(${DS})
@Override
public DataSourceUtil getDataSource() {
return generaterSwapUtil.getDataSource(this.getClass().getAnnotation(DS.class).value());
}
#end
}

View File

@@ -0,0 +1,17 @@
TemplateCode1 -> 发起表单(流程表单)
TemplateCode2 -> 功能表单(表单列表)
TemplateCode3 -> 功能流程(表单列表流程)
TemplateCode4 -> 纯表单
TemplateCode5 -> 纯表单+流程
TemplateCode6 -> 视图代码生成
helper-> 前端调用api接口
java -> 后端模板,各表单类型使用同一套模板
PublicMacro -> 公用宏(通用方法和变量)