diff --git a/module-activiti/src/main/java/ink/wgink/module/activiti/pojo/bos/oa/OaFormReportUnWantedValueBO.java b/module-activiti/src/main/java/ink/wgink/module/activiti/pojo/bos/oa/OaFormReportUnWantedValueBO.java index 32fe5512..5ae05508 100644 --- a/module-activiti/src/main/java/ink/wgink/module/activiti/pojo/bos/oa/OaFormReportUnWantedValueBO.java +++ b/module-activiti/src/main/java/ink/wgink/module/activiti/pojo/bos/oa/OaFormReportUnWantedValueBO.java @@ -1,5 +1,6 @@ package ink.wgink.module.activiti.pojo.bos.oa; +import ink.wgink.module.activiti.pojo.vos.oa.OaDocNoVO; import ink.wgink.module.activiti.pojo.vos.oa.OaFormReportRecordFieldVO; import java.util.ArrayList; @@ -38,6 +39,10 @@ public class OaFormReportUnWantedValueBO { * 抄送列表 */ private List ccs; + /** + * 文号列表 + */ + private List oaDocNos; public List getAssignees() { return assignees == null ? new ArrayList() : assignees; @@ -86,4 +91,12 @@ public class OaFormReportUnWantedValueBO { public void setCcs(List ccs) { this.ccs = ccs; } + + public List getOaDocNos() { + return oaDocNos == null ? new ArrayList() : oaDocNos; + } + + public void setOaDocNos(List oaDocNos) { + this.oaDocNos = oaDocNos; + } } diff --git a/module-activiti/src/main/java/ink/wgink/module/activiti/pojo/vos/oa/OaDocNoVO.java b/module-activiti/src/main/java/ink/wgink/module/activiti/pojo/vos/oa/OaDocNoVO.java new file mode 100644 index 00000000..0db277b9 --- /dev/null +++ b/module-activiti/src/main/java/ink/wgink/module/activiti/pojo/vos/oa/OaDocNoVO.java @@ -0,0 +1,42 @@ +package ink.wgink.module.activiti.pojo.vos.oa; + +import java.io.Serializable; + +/** + * @ClassName: OaDocNoVO + * @Description: oa文号 + * @Author: wanggeng + * @Date: 2022/7/5 15:34 + * @Version: 1.0 + */ +public class OaDocNoVO implements Serializable { + + private static final long serialVersionUID = 4605522411547509429L; + private String fieldName; + private String docNoId; + private String docNoText; + + public String getFieldName() { + return fieldName == null ? "" : fieldName.trim(); + } + + public void setFieldName(String fieldName) { + this.fieldName = fieldName; + } + + public String getDocNoId() { + return docNoId == null ? "" : docNoId.trim(); + } + + public void setDocNoId(String docNoId) { + this.docNoId = docNoId; + } + + public String getDocNoText() { + return docNoText == null ? "" : docNoText.trim(); + } + + public void setDocNoText(String docNoText) { + this.docNoText = docNoText; + } +} diff --git a/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/IOaFormReportService.java b/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/IOaFormReportService.java index e40ecf77..56ca9869 100644 --- a/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/IOaFormReportService.java +++ b/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/IOaFormReportService.java @@ -31,6 +31,10 @@ public interface IOaFormReportService { * 抄送 */ String KEY_CCS = "ccs"; + /** + * 文号列表 + */ + String KEY_DOC_NOS = "docNos"; String KEY_REASON = "reason"; /** * 签批关键字后缀 @@ -187,6 +191,7 @@ public interface IOaFormReportService { /** * 更新任务 + * * @param token * @param processInstanceId * @param taskId @@ -196,6 +201,7 @@ public interface IOaFormReportService { /** * 更新任务 + * * @param userId * @param userName * @param processInstanceId diff --git a/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/impl/OaFormReportServiceImpl.java b/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/impl/OaFormReportServiceImpl.java index 0d7c7bc9..db0ff40e 100644 --- a/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/impl/OaFormReportServiceImpl.java +++ b/module-activiti/src/main/java/ink/wgink/module/activiti/service/oa/impl/OaFormReportServiceImpl.java @@ -12,13 +12,17 @@ import ink.wgink.module.activiti.enums.oa.TaskCommentTypeEnum; import ink.wgink.module.activiti.enums.oa.field.FieldEditRecordEnum; import ink.wgink.module.activiti.pojo.bos.oa.OaFormReportUnWantedValueBO; import ink.wgink.module.activiti.pojo.bos.oa.TaskCommentBO; +import ink.wgink.module.activiti.pojo.vos.oa.OaDocNoVO; import ink.wgink.module.activiti.pojo.vos.oa.OaFormReportRecordFieldVO; import ink.wgink.module.activiti.pojo.vos.oa.UpdateTaskAssigneeVO; import ink.wgink.module.activiti.service.activiti.IActivitiModelService; import ink.wgink.module.activiti.service.oa.IOaCcService; import ink.wgink.module.activiti.service.oa.IOaFormReportService; +import ink.wgink.module.form.enums.docno.DocNoTypeEnum; +import ink.wgink.module.form.pojo.pos.docno.DocNoPO; import ink.wgink.module.form.service.design.IFormDesignService; import ink.wgink.module.form.service.design.IFormFieldService; +import ink.wgink.module.form.service.docno.IDocNoService; import ink.wgink.module.form.service.report.IFormReportService; import ink.wgink.pojo.ListPage; import ink.wgink.pojo.app.AppTokenUser; @@ -68,6 +72,8 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo private IActivitiModelService activitiModelService; @Autowired private IOaCcService formCcService; + @Autowired + private IDocNoService docNoService; @Override public void save(String processDefinitionId, String formCode, Integer formVersion, Map params) { @@ -84,7 +90,8 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo @Override public void saveByUserIdAndUserName(String userId, String userName, String processDefinitionId, String formCode, Integer formVersion, Map params) { OaFormReportUnWantedValueBO oaFormReportUnWantedValueBO = getOaFormReportUnWantedValue(params); - + LOG.debug("设置文号"); + setDocNo(oaFormReportUnWantedValueBO.getOaDocNos(), formCode, formVersion, params); LOG.debug("保存表单"); String uid = formReportService.saveByUserIdAndReturnId(userId, formCode, formVersion, params); LOG.debug("定义流程发起人"); @@ -136,6 +143,8 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo throw new SearchException("任务不存在或已被处理"); } OaFormReportUnWantedValueBO oaFormReportUnWantedValueBO = getOaFormReportUnWantedValue(params); + LOG.debug("设置文号"); + setDocNo(oaFormReportUnWantedValueBO.getOaDocNos(), formCode, formVersion, params); formReportService.updateByUserId(userId, formCode, formVersion, uid, params); if (isNeedClaim == 1) { LOG.debug("认领任务"); @@ -394,6 +403,28 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo taskService.addComment(taskId, processInstanceId, TaskCommentTypeEnum.TRANSFER.getValue(), JSONObject.toJSONString(taskCommentBO)); } + /** + * 设置文号 + * + * @param oaDocNos + * @param reportParams + */ + private void setDocNo(List oaDocNos, String formCode, Integer formVersion, Map reportParams) { + if (oaDocNos.isEmpty()) { + return; + } + oaDocNos.forEach(oaDocNoVO -> { + DocNoPO docNoPO = docNoService.getPO(oaDocNoVO.getDocNoId()); + if (StringUtils.equals(DocNoTypeEnum.MANUAL.getValue(), docNoPO.getType())) { + LOG.debug("文号类型为手动生成"); + reportParams.put(oaDocNoVO.getFieldName() + IFormDesignService.SUFFIX_DOC_NO, oaDocNoVO.getDocNoText()); + } else { + String latestDocNo = docNoService.saveAndReturnLatestDocNo(oaDocNoVO.getDocNoId(), String.format("df_%s_v%d", formCode, formVersion)); + reportParams.put(oaDocNoVO.getFieldName() + IFormDesignService.SUFFIX_DOC_NO, latestDocNo); + } + }); + } + /** * 保存记录的字段列表 * @@ -408,14 +439,14 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo if (oaFormReportRecordFieldVOs.isEmpty()) { return; } - String currentTime = DateUtil.getTime(); + String currentDay = DateUtil.getDay(); for (OaFormReportRecordFieldVO oaFormReportRecordFieldVO : oaFormReportRecordFieldVOs) { Object reportRecordObject = reportParams.get(oaFormReportRecordFieldVO.getFieldName()); String reportRecordValue = reportRecordObject == null ? "" : reportRecordObject.toString(); // 创建批注 if (StringUtils.equals(oaFormReportRecordFieldVO.getEditHistory(), FieldEditRecordEnum.LATEST.getValue())) { - // 签批批注,存入流程变量 - reportParams.put(oaFormReportRecordFieldVO.getFieldName() + EDIT_SIGN_KEY_SUFFIX, String.format("姓名:%s。 内容:%s。 时间:%s。", userName, reportRecordValue, currentTime)); + // 签批批注,存入流程变量, 内容、姓名、时间 + reportParams.put(oaFormReportRecordFieldVO.getFieldName() + EDIT_SIGN_KEY_SUFFIX, String.format("%s。 %s。 %s。", reportRecordValue, userName, currentDay)); continue; } if (StringUtils.equals(oaFormReportRecordFieldVO.getEditHistory(), FieldEditRecordEnum.ALL.getValue())) { @@ -424,7 +455,7 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo taskCommentBO.setUserId(userId); taskCommentBO.setUserName(userName); taskCommentBO.setContent(reportRecordValue); - taskCommentBO.setTime(currentTime); + taskCommentBO.setTime(currentDay); taskCommentBO.setFieldName(oaFormReportRecordFieldVO.getFieldName()); taskCommentBO.setFieldExplain(oaFormReportRecordFieldVO.getFieldExplain()); taskCommentBO.setType(TaskCommentTypeEnum.JOINTLY_SIGN); @@ -448,6 +479,7 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo Object excObj = reportParams.get(IActivitiModelService.EXCLUSIVE_GATEWAY_CONDITION_KEY); List oaFormReportRecordFieldVOs = JSONArray.parseArray(JSON.toJSONString(reportParams.get(IOaFormReportService.KEY_RECORD_FIELDS)), OaFormReportRecordFieldVO.class); List ccVOs = (List) reportParams.get(IOaFormReportService.KEY_CCS); + List docNoVOS = JSONArray.parseArray(JSONArray.toJSONString(reportParams.get(IOaFormReportService.KEY_DOC_NOS)), OaDocNoVO.class); // 移除无效的内容 reportParams.remove(IOaFormReportService.KEY_ASSIGNEES); reportParams.remove(IOaFormReportService.KEY_SELECT_TYPE); @@ -455,6 +487,7 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo reportParams.remove(IOaFormReportService.KEY_RECORD_FIELDS); reportParams.remove(IActivitiModelService.EXCLUSIVE_GATEWAY_CONDITION_KEY); reportParams.remove(IOaFormReportService.KEY_CCS); + reportParams.remove(IOaFormReportService.KEY_DOC_NOS); // 归类到对象 OaFormReportUnWantedValueBO oaFormReportUnWantedValueBO = new OaFormReportUnWantedValueBO(); oaFormReportUnWantedValueBO.setAssignees(assignees); @@ -463,6 +496,7 @@ public class OaFormReportServiceImpl extends DefaultBaseService implements IOaFo oaFormReportUnWantedValueBO.setExc(excObj == null ? "" : excObj.toString()); oaFormReportUnWantedValueBO.setRecordFields(oaFormReportRecordFieldVOs); oaFormReportUnWantedValueBO.setCcs(ccVOs); + oaFormReportUnWantedValueBO.setOaDocNos(docNoVOS); return oaFormReportUnWantedValueBO; } diff --git a/module-form/src/main/java/ink/wgink/module/form/controller/api/docno/DocNoController.java b/module-form/src/main/java/ink/wgink/module/form/controller/api/docno/DocNoController.java index a3a3acb1..e34ae5b5 100644 --- a/module-form/src/main/java/ink/wgink/module/form/controller/api/docno/DocNoController.java +++ b/module-form/src/main/java/ink/wgink/module/form/controller/api/docno/DocNoController.java @@ -2,7 +2,9 @@ package ink.wgink.module.form.controller.api.docno; import ink.wgink.annotation.CheckRequestBodyAnnotation; import ink.wgink.common.base.DefaultBaseController; +import ink.wgink.exceptions.ParamsException; import ink.wgink.interfaces.consts.ISystemConstant; +import ink.wgink.module.form.enums.docno.DocNoTypeEnum; import ink.wgink.module.form.pojo.bos.docno.DocNoBO; import ink.wgink.module.form.pojo.dtos.docno.DocNoDTO; import ink.wgink.module.form.pojo.vos.docno.DocNoVO; @@ -13,6 +15,7 @@ import ink.wgink.pojo.result.SuccessResult; import ink.wgink.pojo.result.SuccessResultData; import ink.wgink.pojo.result.SuccessResultList; import io.swagger.annotations.*; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -40,6 +43,7 @@ public class DocNoController extends DefaultBaseController { @PostMapping("save") @CheckRequestBodyAnnotation public SuccessResult save(@RequestBody DocNoVO docNoVO) { + checkField(docNoVO); docNoService.save(docNoVO); return new SuccessResult(); } @@ -63,6 +67,7 @@ public class DocNoController extends DefaultBaseController { @PutMapping("update/{docNoId}") @CheckRequestBodyAnnotation public SuccessResult update(@PathVariable("docNoId") String docNoId, @RequestBody DocNoVO docNoVO) { + checkField(docNoVO); docNoService.update(docNoId, docNoVO); return new SuccessResult(); } @@ -114,9 +119,9 @@ public class DocNoController extends DefaultBaseController { @ApiImplicitParam(name = "docNoId", value = "文号ID", paramType = "path") }) @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)}) - @GetMapping("get-latest-doc-no/{docNoId}") - public SuccessResultData getLatestDocNo(@PathVariable("docNoId") String docNoId) { - DocNoBO latestNewDocNoBO = docNoService.getLatestNewDocNoBO(docNoId); + @GetMapping("get-latest-doc-no/{docNoId}/{docNoUsedId}") + public SuccessResultData getLatestDocNo(@PathVariable("docNoId") String docNoId, @PathVariable("docNoUsedId") String docNoUsedId) { + DocNoBO latestNewDocNoBO = docNoService.getLatestNewDocNoBO(docNoId, docNoUsedId); String latestDocNo; if (latestNewDocNoBO == null) { latestDocNo = ""; @@ -126,4 +131,18 @@ public class DocNoController extends DefaultBaseController { return new SuccessResultData<>(latestDocNo); } + /** + * 验证模板 + * + * @param docNoVO + */ + private void checkField(DocNoVO docNoVO) { + if (StringUtils.equals(docNoVO.getType(), DocNoTypeEnum.MANUAL.getValue())) { + return; + } + if (StringUtils.isBlank(docNoVO.getTemplate())) { + throw new ParamsException("模板不能为空"); + } + } + } \ No newline at end of file diff --git a/module-form/src/main/java/ink/wgink/module/form/controller/route/docno/DocNoRouteController.java b/module-form/src/main/java/ink/wgink/module/form/controller/route/docno/DocNoRouteController.java index ef9975ff..6b3e42e2 100644 --- a/module-form/src/main/java/ink/wgink/module/form/controller/route/docno/DocNoRouteController.java +++ b/module-form/src/main/java/ink/wgink/module/form/controller/route/docno/DocNoRouteController.java @@ -35,4 +35,9 @@ public class DocNoRouteController extends DefaultBaseController { return new ModelAndView("doc-no/list"); } + @GetMapping("select/list") + public ModelAndView selectList() { + return new ModelAndView("doc-no/select/list"); + } + } \ No newline at end of file diff --git a/module-form/src/main/java/ink/wgink/module/form/enums/design/FormFieldTypeEnum.java b/module-form/src/main/java/ink/wgink/module/form/enums/design/FormFieldTypeEnum.java index 60f86ff3..e82143e6 100644 --- a/module-form/src/main/java/ink/wgink/module/form/enums/design/FormFieldTypeEnum.java +++ b/module-form/src/main/java/ink/wgink/module/form/enums/design/FormFieldTypeEnum.java @@ -33,7 +33,8 @@ public enum FormFieldTypeEnum { UPLOAD_AUDIO("uploadAudio", "上传音频"), TEXTAREA("textarea", "多行文本"), EDITOR("editor", "编辑器"), - GRID("grid", "布局网格"); + GRID("grid", "布局网格"), + DOC_NO("docno", "文号"); private String type; private String label; diff --git a/module-form/src/main/java/ink/wgink/module/form/pojo/dtos/docno/DocNoDTO.java b/module-form/src/main/java/ink/wgink/module/form/pojo/dtos/docno/DocNoDTO.java index 9a5cafe2..9feee6d1 100644 --- a/module-form/src/main/java/ink/wgink/module/form/pojo/dtos/docno/DocNoDTO.java +++ b/module-form/src/main/java/ink/wgink/module/form/pojo/dtos/docno/DocNoDTO.java @@ -28,8 +28,6 @@ public class DocNoDTO { private Integer startNu; @ApiModelProperty(name = "nuLength", value = "编号长度") private Integer nuLength; - @ApiModelProperty(name = "latestDocNo", value = "最新文号") - private String latestDocNo; @ApiModelProperty(name = "isActive", value = "是否激活") private Integer isActive; @ApiModelProperty(name = "gmtCreate", value = "创建时间") @@ -95,14 +93,6 @@ public class DocNoDTO { this.nuLength = nuLength; } - public String getLatestDocNo() { - return latestDocNo == null ? "" : latestDocNo.trim(); - } - - public void setLatestDocNo(String latestDocNo) { - this.latestDocNo = latestDocNo; - } - public Integer getIsActive() { return isActive == null ? 0 : isActive; } diff --git a/module-form/src/main/java/ink/wgink/module/form/pojo/vos/docno/DocNoVO.java b/module-form/src/main/java/ink/wgink/module/form/pojo/vos/docno/DocNoVO.java index 6adddfd4..1cd8266f 100644 --- a/module-form/src/main/java/ink/wgink/module/form/pojo/vos/docno/DocNoVO.java +++ b/module-form/src/main/java/ink/wgink/module/form/pojo/vos/docno/DocNoVO.java @@ -24,7 +24,6 @@ public class DocNoVO { @CheckEmptyAnnotation(name = "类型", types = {"always", "year", "month", "day", "manual"}) private String type; @ApiModelProperty(name = "template", value = "模板") - @CheckEmptyAnnotation(name = "模板") private String template; @ApiModelProperty(name = "startNu", value = "开始编号") @CheckNumberAnnotation(name = "开始编号") diff --git a/module-form/src/main/java/ink/wgink/module/form/service/design/IFormDesignService.java b/module-form/src/main/java/ink/wgink/module/form/service/design/IFormDesignService.java index 950b7092..14879110 100644 --- a/module-form/src/main/java/ink/wgink/module/form/service/design/IFormDesignService.java +++ b/module-form/src/main/java/ink/wgink/module/form/service/design/IFormDesignService.java @@ -31,6 +31,7 @@ public interface IFormDesignService { String PARAM_INSERTS = "inserts"; String PARAM_VALUES = "values"; String PARAM_KV_LIST = "kvList"; + String SUFFIX_DOC_NO = "_text"; /** * 保存表单 diff --git a/module-form/src/main/java/ink/wgink/module/form/service/design/impl/FormDesignServiceImpl.java b/module-form/src/main/java/ink/wgink/module/form/service/design/impl/FormDesignServiceImpl.java index 18691a6c..58304c4e 100644 --- a/module-form/src/main/java/ink/wgink/module/form/service/design/impl/FormDesignServiceImpl.java +++ b/module-form/src/main/java/ink/wgink/module/form/service/design/impl/FormDesignServiceImpl.java @@ -322,7 +322,12 @@ public class FormDesignServiceImpl extends DefaultBaseService implements IFormDe } } else { FormFieldVO formField = new FormFieldVO(); - formField.setFieldName(id); + // 文号,加后后缀保存 + if (StringUtils.equals(FormFieldTypeEnum.DOC_NO.getType(), tag)) { + formField.setFieldName(id + SUFFIX_DOC_NO); + } else { + formField.setFieldName(id); + } formField.setFieldTag(tag); formField.setFieldExplain(label); formField.setFieldType(getSingleFieldType(tag)); @@ -377,6 +382,8 @@ public class FormDesignServiceImpl extends DefaultBaseService implements IFormDe return "LONGTEXT"; } else if (StringUtils.equals(FormFieldTypeEnum.SIGN.getType(), fieldTag)) { return "VARCHAR(255)"; + } else if (StringUtils.equals(FormFieldTypeEnum.DOC_NO.getType(), fieldTag)) { + return "VARCHAR(255)"; } return null; } diff --git a/module-form/src/main/java/ink/wgink/module/form/service/docno/IDocNoService.java b/module-form/src/main/java/ink/wgink/module/form/service/docno/IDocNoService.java index c1f5f768..65507d1a 100644 --- a/module-form/src/main/java/ink/wgink/module/form/service/docno/IDocNoService.java +++ b/module-form/src/main/java/ink/wgink/module/form/service/docno/IDocNoService.java @@ -165,15 +165,25 @@ public interface IDocNoService { * 获取最新文号 * * @param docNoId + * @param docNoUsedId 使用ID * @return */ - DocNoBO getLatestNewDocNoBO(String docNoId); + DocNoBO getLatestNewDocNoBO(String docNoId, String docNoUsedId); + + /** + * 获取最新文号 + * + * @param docNoPO + * @param docNoUsedId 使用ID + * @return + */ + DocNoBO getLatestNewDocNoBO(DocNoPO docNoPO, String docNoUsedId); /** * 保存并返回新的文号 * * @param docNoId - * @param docNoUsedId + * @param docNoUsedId 文号的使用ID,由调用方确定(每种文号确定唯一,动态表单用表名处理) * @return */ String saveAndReturnLatestDocNo(String docNoId, String docNoUsedId); diff --git a/module-form/src/main/java/ink/wgink/module/form/service/docno/impl/DocNoServiceImpl.java b/module-form/src/main/java/ink/wgink/module/form/service/docno/impl/DocNoServiceImpl.java index 08d642ea..9e21379a 100644 --- a/module-form/src/main/java/ink/wgink/module/form/service/docno/impl/DocNoServiceImpl.java +++ b/module-form/src/main/java/ink/wgink/module/form/service/docno/impl/DocNoServiceImpl.java @@ -161,7 +161,7 @@ public class DocNoServiceImpl extends DefaultBaseService implements IDocNoServic } @Override - public DocNoBO getLatestNewDocNoBO(String docNoId) { + public DocNoBO getLatestNewDocNoBO(String docNoId, String docNoUsedId) { DocNoPO docNoPO = getPO(docNoId); if (docNoPO == null) { throw new SearchException("文号不存在"); @@ -170,12 +170,17 @@ public class DocNoServiceImpl extends DefaultBaseService implements IDocNoServic LOG.debug("文号类型为手动生成"); return null; } + return getLatestNewDocNoBO(docNoPO, docNoUsedId); + } + + @Override + public DocNoBO getLatestNewDocNoBO(DocNoPO docNoPO, String docNoUsedId) { int startNu = docNoPO.getStartNu(); int nuLength = docNoPO.getNuLength(); // 文号模板 String template = docNoPO.getTemplate(); // 获取最新的文号 - DocNoLogPO latestDocNoLogPO = docNoLogService.getLatestPOByDocNoId(docNoId); + DocNoLogPO latestDocNoLogPO = docNoLogService.getLatestPOByDocNoIdAndUsedId(docNoPO.getDocNoId(), docNoUsedId); DateTime dateTime = DateTime.now(); int fullYearIndex = template.indexOf("yyyy"); @@ -224,13 +229,13 @@ public class DocNoServiceImpl extends DefaultBaseService implements IDocNoServic } } docNoBO.setDocNoNu(currentDocNoNu); - docNoBO.setDocNoFull(generateDocNo(template, dateTime, String.format("%0" + nuLength + "d", currentDocNoNu))); + docNoBO.setDocNoFull(docNoPO.getTitle() + generateDocNo(template, dateTime, String.format("%0" + nuLength + "d", currentDocNoNu))); return docNoBO; } @Override public synchronized String saveAndReturnLatestDocNo(String docNoId, String docNoUsedId) { - DocNoBO latestNewDocNoBO = getLatestNewDocNoBO(docNoId); + DocNoBO latestNewDocNoBO = getLatestNewDocNoBO(docNoId, docNoUsedId); if (latestNewDocNoBO == null) { return null; } diff --git a/module-form/src/main/java/ink/wgink/module/form/service/docnolog/IDocNoLogService.java b/module-form/src/main/java/ink/wgink/module/form/service/docnolog/IDocNoLogService.java index be461892..57befb9d 100644 --- a/module-form/src/main/java/ink/wgink/module/form/service/docnolog/IDocNoLogService.java +++ b/module-form/src/main/java/ink/wgink/module/form/service/docnolog/IDocNoLogService.java @@ -77,9 +77,10 @@ public interface IDocNoLogService { * 获取最新的文号日志 * * @param docNoId + * @param docNoUsedId * @return */ - DocNoLogPO getLatestPOByDocNoId(String docNoId); + DocNoLogPO getLatestPOByDocNoIdAndUsedId(String docNoId, String docNoUsedId); /** * 文号日志列表 diff --git a/module-form/src/main/java/ink/wgink/module/form/service/docnolog/impl/DocNoLogServiceImpl.java b/module-form/src/main/java/ink/wgink/module/form/service/docnolog/impl/DocNoLogServiceImpl.java index f9f77c47..9c4c5f4b 100644 --- a/module-form/src/main/java/ink/wgink/module/form/service/docnolog/impl/DocNoLogServiceImpl.java +++ b/module-form/src/main/java/ink/wgink/module/form/service/docnolog/impl/DocNoLogServiceImpl.java @@ -78,9 +78,10 @@ public class DocNoLogServiceImpl extends DefaultBaseService implements IDocNoLog } @Override - public DocNoLogPO getLatestPOByDocNoId(String docNoId) { + public DocNoLogPO getLatestPOByDocNoIdAndUsedId(String docNoId, String docNoUsedId) { Map params = getHashMap(2); params.put("docNoId", docNoId); + params.put("docNoUsedId", docNoUsedId); return docNoLogDao.getLatestPO(params); } diff --git a/module-form/src/main/resources/mybatis/mapper/doc-no-log/doc-no-log-mapper.xml b/module-form/src/main/resources/mybatis/mapper/doc-no-log/doc-no-log-mapper.xml index 62df90de..426d3c12 100644 --- a/module-form/src/main/resources/mybatis/mapper/doc-no-log/doc-no-log-mapper.xml +++ b/module-form/src/main/resources/mybatis/mapper/doc-no-log/doc-no-log-mapper.xml @@ -250,6 +250,10 @@ t1.doc_no_id = #{docNoId} + + AND + t1.doc_no_used_id = #{docNoUsedId} + ORDER BY t1.gmt_create DESC diff --git a/module-form/src/main/resources/static/assets/js/doc-no/doc-no.js b/module-form/src/main/resources/static/assets/js/doc-no/doc-no.js index 490101a3..925a8341 100644 --- a/module-form/src/main/resources/static/assets/js/doc-no/doc-no.js +++ b/module-form/src/main/resources/static/assets/js/doc-no/doc-no.js @@ -70,15 +70,22 @@ function DocNo($, form) { }, addSelect: function() { var self = this; - form.on('select(typeSelect)', function(data){ + form.on('select(typeSelect)', function(data) { var options = $(data.elem).children(); + var isManual = true; for(var i = 0, option; option = options[i++];) { if(option.value == data.value) { - $('#template').val(option.dataset.template) + if(option.value != 'manual') { + isManual = false; + } + $('#template').val(option.dataset.template); break; } } self.refreshDocNoDemo(); + if(isManual) { + $('#template').removeAttr('lay-verify'); + } }); } } diff --git a/module-form/src/main/resources/static/form-design/modules/components/docno.js b/module-form/src/main/resources/static/form-design/modules/components/docno.js new file mode 100644 index 00000000..fab6c3f5 --- /dev/null +++ b/module-form/src/main/resources/static/form-design/modules/components/docno.js @@ -0,0 +1,97 @@ +layui.define(['jquery', 'laydate', 'formUtils'], function(exports) { + var $ = layui.jquery; + var form = layui.form; + var laydate = layui.laydate; + var utils = layui.formUtils; + var formField = layui.formField; + + var HTML_ARRAY = [ + '
', + ' ', + '
', + '
', + ' ', + '
', + '
', + ' ', + '
', + '
', + '
' + ]; + + var docno = { + /** + * 根据json对象生成html对象 + * @param {object} json + * @param {boolean} selected true 表示选择当前 + * */ + render: function (json, selected) { + if (selected === undefined) { + selected = false; + } + var _html = HTML_ARRAY[0].format(json.id, json.tag, selected ? 'active' : '', json.index); + _html += HTML_ARRAY[1].format(json.label, json.labelWidth); + _html += HTML_ARRAY[2].format(json.id, json.labelWidth); + _html += HTML_ARRAY[3]; + _html += HTML_ARRAY[4].format(json.id); + _html += ''; + // 渲染列表 + for (var i = 0, item; item = json.docNoOptions[i++];) { + _html += ''.format(item.value, item.type, item.template, item.text, item.checked ? 'checked="checked"' : ''); + } + _html += HTML_ARRAY[5]; + _html += HTML_ARRAY[6]; + _html += HTML_ARRAY[7]; + _html += HTML_ARRAY[8].format(json.id); + _html += HTML_ARRAY[9]; + _html += HTML_ARRAY[10]; + _html += HTML_ARRAY[11]; + return _html; + }, + update: function (json) { + var $select = $('#' + json.id + 'Box .layui-input-block .select'); + var $label = $('#' + json.id + 'Box .layui-form-label'); + $select.empty(); + $label.empty(); + var _html = ''; + _html += ''; + $select.append(_html); + $('#'+ json.id +'Block').css("margin-left", json.labelWidth); + $label.css("width", json.labelWidth); + $label.append(json.label + ":"); + form.render('select', json.id); + $('#' + json.id + 'Box .layui-input-block div.layui-unselect.layui-form-select').css({ + width: '{0}'.format(json.width) + }); + }, + /* 获取对象 */ + jsonData: function (id, index, columncount) { + //分配一个新的ID + var _json = JSON.parse(JSON.stringify(formField.docno)); + _json.id = id == undefined ? utils.guid() : id; + _json.index = index; + return _json; + }, + /* 根据 json 对象显示对应的属性 */ + property: function (json) { + $('#columnProperty').empty(); + var _html = ''; + _html = utils.renderCommonProperty(json); //获取通用属性HTML字符串 + //处理特殊字符串 + for (var key in json) { + if (key === 'index') { + continue; + } + } + $('#columnProperty').append(_html); + }, + }; + + exports('docno', docno); +}); \ No newline at end of file diff --git a/module-form/src/main/resources/static/form-design/modules/consts.js b/module-form/src/main/resources/static/form-design/modules/consts.js index 4da0348d..5edf926c 100644 --- a/module-form/src/main/resources/static/form-design/modules/consts.js +++ b/module-form/src/main/resources/static/form-design/modules/consts.js @@ -91,7 +91,8 @@ layui.define([], function (exports) { uploadVideo: '视频上传', uploadAudio: '音频上传', listShow: '列表显示', - count: '总数' + count: '总数', + docno: '文号', }; var expressions = [ { diff --git a/module-form/src/main/resources/static/form-design/modules/formDesigner.js b/module-form/src/main/resources/static/form-design/modules/formDesigner.js index 2c9b6ff1..d16714b2 100644 --- a/module-form/src/main/resources/static/form-design/modules/formDesigner.js +++ b/module-form/src/main/resources/static/form-design/modules/formDesigner.js @@ -19,12 +19,13 @@ layui.config({ uploadVideo: 'components/uploadVideo', uploadAudio: 'components/uploadAudio', laySign: 'components/laySign', + docno: 'components/docno', }).define(["layer", "laytpl", "element", "form", "slider", "laydate", "rate", "colorpicker", "layedit", "carousel", "upload", "formField", "iconPicker", "cron", "labelGeneration", 'consts', 'input', 'numberInput', 'password', 'grid', 'textarea', 'select', 'radio', 'checkbox', 'laySwitch', 'laySlider', 'date', 'layRate', 'layCarousel', 'uploadImage', 'uploadFile', 'uploadVideo', 'uploadAudio', - 'laySign' + 'laySign', 'docno' ], function (exports) { var $ = layui.jquery, layer = layui.layer, @@ -54,6 +55,7 @@ layui.config({ uploadVideo = layui.uploadVideo, uploadAudio = layui.uploadAudio, laySign = layui.laySign, + docno = layui.docno, consts = layui.consts, lang = consts.lang, @@ -308,6 +310,8 @@ layui.config({ grid: grid, laySign: laySign, + + docno: docno, }; /* 如果是grid布局控件 就显示不一样的样式 */ Class.prototype.addClick = function (evt) { @@ -682,8 +686,8 @@ layui.config({ //同步到设计视图radio _html += ''.format(_json.tag, 'option'); $('#' + _json.id + 'Box .layui-input-block').append(_html); - } else if (_json.tag === 'carousel') { - } + } else if (_json.tag === 'carousel') {} + if (_json.tag === 'checkbox') { form.render('checkbox'); } else if (_json.tag === 'radio') { @@ -773,6 +777,48 @@ layui.config({ //向 .option .layui-inline 添加drag事件并且必须设在 select-option-drag 中才能拖动 }); } + // 文号 + if(_json.hasOwnProperty('docNoOptions')) { + $('.select-doc-no-btn').on('click', function() { + var id = this.dataset.id; + var boxId = '#'+ id +'OptionsBox'; + top.dialog.open({ + // 打开页面,指定选择框类型 + url: 'route/doc-no/select/list?selectType=checkbox', + title: '选择文号选项', + width: '800px', + height: '400px', + onClose: function() { + $(boxId).empty(); + // 获取选择后的列表 + var newSelectedArray = top.dialog.dialogData.newSelectedArray; + if(newSelectedArray && newSelectedArray.length != 0) { + // 处理选择结果 + var _htmloption = ''; + var docNoOptions = []; + for(var i = 0, item; item = newSelectedArray[i++];) { + docNoOptions.push({ + text: item.title, + value: item.docNoId, + template: item.template, + type: item.type, + checked: i == 1 ? true : false + }); + _htmloption += '
'.format(i - 1); + _htmloption += '
'; + _htmloption += ' '.format(_json.tag, item.title + item.template); + _htmloption += '
'; + _htmloption += '
'; + } + $(boxId).append(_htmloption); + form.render('radio'); + _json.docNoOptions = docNoOptions; + that.components[_json.tag].update(_json); + } + } + }); + }) + } $(document).off('click', '.select-options input[type=checkbox]').on('click', '.select-options input[type=checkbox]', function (e) { // console.log(e); //判断是否选中 diff --git a/module-form/src/main/resources/static/form-design/modules/formField.js b/module-form/src/main/resources/static/form-design/modules/formField.js index 8e6a8e61..c96848c1 100644 --- a/module-form/src/main/resources/static/form-design/modules/formField.js +++ b/module-form/src/main/resources/static/form-design/modules/formField.js @@ -431,6 +431,19 @@ layui.define(['layer'], function (exports) { document: '', listShow: true }, + docno: { + id: '-1', + index: '-1', + label: "文号", + tag: "docno", + tagIcon: 'docno', + labelWidth: 110, + width: "100%", + document: '', + docNoUrl: 'api/doc-no/list', + docNoOptions: [], + listShow: true + }, grid: { id: '-1', index: '-1', @@ -462,7 +475,7 @@ layui.define(['layer'], function (exports) { }, c5: { name: "扩展组件", - list: [/*'laySign'*/] + list: ['docno', /*'laySign'*/] } }; exports('formField', field); diff --git a/module-form/src/main/resources/static/form-design/modules/formUtils.js b/module-form/src/main/resources/static/form-design/modules/formUtils.js index 6af9ffe0..0affac50 100644 --- a/module-form/src/main/resources/static/form-design/modules/formUtils.js +++ b/module-form/src/main/resources/static/form-design/modules/formUtils.js @@ -374,6 +374,21 @@ layui.define(['form', 'laytpl', 'restajax', 'dialog', 'consts'], function (expor _html += '
'.format(json.tag + json.id + "property"); _html += ''; _html += ''; + } else if(key === 'docNoOptions') { + _html += '
'.format(key + json.id); + _html += ''; + _html += '
'; + _html += ''.format(key + json.id); + _html += '
'; + _html += '
'.format(key + json.id); + for(var i = 0, item; item = json.docNoOptions[i++];) { + _html += '
'.format(i - 1); + _html += '
'; + _html += ' '.format(json.tag, item.text + item.template); + _html += '
'; + _html += '
'; + } + _html += '
'; } } return _html; diff --git a/module-form/src/main/resources/static/form/js/oa-docno.js b/module-form/src/main/resources/static/form/js/oa-docno.js new file mode 100644 index 00000000..da550271 --- /dev/null +++ b/module-form/src/main/resources/static/form/js/oa-docno.js @@ -0,0 +1,129 @@ +function OaDocNo(layui) { + var $ = layui.$; + var layer = layui.layer; + var form = layui.form + var restAjax = layui.restajax; + + /** + * 获取option + * @param select + * @param selectedValue + * @return {null|*} + */ + function getSelectOption(select, selectedValue) { + if (!selectedValue) { + return null; + } + var options = $(select).find('option'); + for (var i = 0, option; option = options[i++];) { + if (option.value === selectedValue) { + return option; + } + } + return null; + } + + /** + * 获取最新文号 + * @param selectId + * @param docnoId + * @param isApp + * @param token + */ + function getLatestDocNo(selectId, docNoId, isApp, headers) { + var url; + if (!isApp) { + url = 'api/doc-no/get-latest-doc-no/{docNoId}/{docNoUsedId}'; + } else { + url = 'app/doc-no/get-latest-doc-no/{docNoId}/{docNoUsedId}'; + } + restAjax.get(restAjax.path(url, [docNoId, 'df_'+ $('#formCode').val() +'_v'+ $('#formVersion').val()]), {}, { + headers: headers + }, function (code, data) { + $('#' + selectId + 'Text').val(data.data); + }, function (code, data) { + layer.msg(data.msg); + }) + } + + // 初始化 + this.init = function (opt) { + var isApp = opt && opt.isApp ? opt.isApp : false; + var headers = opt && opt.headers ? opt.headers : {}; + // 获取全部的文号组件 + var docnos = $('.docno'); + if (docnos.length == 0) { + return; + } + + // 添加监听事件 + $.each(docnos, function (index, item) { + var selects = $(item).find('select'); + var select = selects[0]; + var selectId = select.id; + form.on('select(' + selectId + 'Filter)', function (data) { + $('#' + selectId + 'Text').val(''); + var docNoId = data.value; + var option = getSelectOption(data.elem, docNoId); + if (!option) { + return; + } + var type = option.dataset.type; + if (type === 'manual') { + $('#' + selectId + 'Text').removeAttr('readonly'); + return; + } + getLatestDocNo(data.elem.id, docNoId, isApp, headers); + }); + }); + } + + /** + * 设置文号字段 + * @param data + */ + this.initDocNo = function (data) { + var docnos = $('.docno'); + if (docnos.length == 0) { + return; + } + $.each(docnos, function (index, item) { + var selects = $(item).find('select'); + var select = selects[0]; + var docNoField = select.id; + for(var key in data) { + if(key == docNoField) { + docNoField[key +'Text'] = docNoField[key]; + delete docNoField[key]; + break; + } + } + }) + } + + /** + * 设置文号 + * @param formData + */ + this.setDocNo = function (formData) { + var docnos = $('.docno'); + if (docnos.length == 0) { + return; + } + var docNoArray = []; + $.each(docnos, function (index, item) { + var selects = $(item).find('select'); + var select = selects[0]; + var docNoId = select.value; + docNoArray.push({ + fieldName: select.id, + docNoId: docNoId, + docNoText: $('#' + select.id + 'Text').val() + }) + delete formData.field[select.id]; + delete formData.field[select.id + 'Text']; + }); + formData.field.docNos = docNoArray; + } + +} \ No newline at end of file diff --git a/module-form/src/main/resources/static/form/js/oa-form-util.js b/module-form/src/main/resources/static/form/js/oa-form-util.js index fbeee467..d6edaeb7 100644 --- a/module-form/src/main/resources/static/form/js/oa-form-util.js +++ b/module-form/src/main/resources/static/form/js/oa-form-util.js @@ -6,6 +6,11 @@ function OaFormUtil(layui) { var form = layui.form; var restAjax = layui.restajax; var processImageEnlargeScale = 0; + // 全屏 + function fullPage() { + $('.layui-card-body').css('height', (win.height() - 75) +'px'); + } + fullPage(); // 消息位置 function getMsgOffset(isApp) { @@ -391,13 +396,29 @@ function OaFormUtil(layui) { this.disableFields = function (fields) { for (var i = 0, item; item = fields[i++];) { if (parseInt(item.isEditable) === 0) { + // 普通控件 var boxId = '#' + item.fieldName + 'Box'; - $(boxId).css('position', 'relative'); - $(boxId).append('
'); - var doms = $(boxId).find('input,button,textarea,select'); - doms.removeAttr('name'); - doms.attr('disabled', 'disabled'); - doms.attr('lay-verify', ''); + var blockId = '#'+ item.fieldName + 'Block'; + // 文号控件 + if($(boxId).hasClass('docno')) { + // 移除文号标识 + $(boxId).removeClass('docno'); + // 获取文本输入框 + var docNoTextInput = $('#'+ item.fieldName +'Text'); + docNoTextInput.removeAttr('name'); + docNoTextInput.attr('disabled', 'disabled'); + docNoTextInput.attr('lay-verify', ''); + // 重新添加文本 + $(blockId).empty(); + $(blockId).append(docNoTextInput) + } else { + $(boxId).css('position', 'relative'); + $(boxId).append('
'); + var doms = $(boxId).find('input,button,textarea,select'); + doms.removeAttr('name'); + doms.attr('disabled', 'disabled'); + doms.attr('lay-verify', ''); + } } } } diff --git a/module-form/src/main/resources/templates/doc-no/select/list.html b/module-form/src/main/resources/templates/doc-no/select/list.html new file mode 100644 index 00000000..b17f5fc2 --- /dev/null +++ b/module-form/src/main/resources/templates/doc-no/select/list.html @@ -0,0 +1,295 @@ + + + + + + + + + + + + + +
+
+
+
+
+
+
+ +
+ + + + +
+
+
+
+
+
+
+ + + + + \ No newline at end of file diff --git a/module-form/src/main/resources/templates/form/get-app-save-page-code.html b/module-form/src/main/resources/templates/form/get-app-save-page-code.html index 34171fe7..c74af328 100644 --- a/module-form/src/main/resources/templates/form/get-app-save-page-code.html +++ b/module-form/src/main/resources/templates/form/get-app-save-page-code.html @@ -12,6 +12,9 @@ +
@@ -65,6 +68,8 @@ theme: 'dracula', matchBrackets: true, indentUnit: 4, + indentWithTabs: 4, + flattenSpans: false, tabSize: 4, smartIndent: true, extraKeys: { diff --git a/module-form/src/main/resources/templates/form/get-app-show-page-code.html b/module-form/src/main/resources/templates/form/get-app-show-page-code.html index 2ada24b9..abe93929 100644 --- a/module-form/src/main/resources/templates/form/get-app-show-page-code.html +++ b/module-form/src/main/resources/templates/form/get-app-show-page-code.html @@ -11,6 +11,9 @@ +
@@ -64,6 +67,8 @@ theme: 'dracula', matchBrackets: true, indentUnit : 4, + indentWithTabs: 4, + flattenSpans: false, tabSize : 4, smartIndent: true, extraKeys: { diff --git a/module-form/src/main/resources/templates/form/get-app-update-page-code.html b/module-form/src/main/resources/templates/form/get-app-update-page-code.html index c2ec89f8..fc6e7235 100644 --- a/module-form/src/main/resources/templates/form/get-app-update-page-code.html +++ b/module-form/src/main/resources/templates/form/get-app-update-page-code.html @@ -11,6 +11,9 @@ +
@@ -64,6 +67,8 @@ theme: 'dracula', matchBrackets: true, indentUnit : 4, + indentWithTabs: 4, + flattenSpans: false, tabSize : 4, smartIndent: true, extraKeys: { diff --git a/module-form/src/main/resources/templates/form/get-form-source-data.html b/module-form/src/main/resources/templates/form/get-form-source-data.html index 124eb792..a092c9f5 100644 --- a/module-form/src/main/resources/templates/form/get-form-source-data.html +++ b/module-form/src/main/resources/templates/form/get-form-source-data.html @@ -11,6 +11,9 @@ +
@@ -48,6 +51,8 @@ matchBrackets: true, readOnly: true, indentUnit : 4, + indentWithTabs: 4, + flattenSpans: false, tabSize : 4, smartIndent: true, mode: 'application/json', diff --git a/module-form/src/main/resources/templates/form/get-print-page-code.html b/module-form/src/main/resources/templates/form/get-print-page-code.html index c6e34b5d..f156fbb3 100644 --- a/module-form/src/main/resources/templates/form/get-print-page-code.html +++ b/module-form/src/main/resources/templates/form/get-print-page-code.html @@ -11,6 +11,9 @@ +
@@ -64,6 +67,8 @@ theme: 'dracula', matchBrackets: true, indentUnit : 4, + indentWithTabs: 4, + flattenSpans: false, tabSize : 4, smartIndent: true, extraKeys: { diff --git a/module-form/src/main/resources/templates/form/get-save-page-code.html b/module-form/src/main/resources/templates/form/get-save-page-code.html index 483bfcdb..a9bb7bb5 100644 --- a/module-form/src/main/resources/templates/form/get-save-page-code.html +++ b/module-form/src/main/resources/templates/form/get-save-page-code.html @@ -11,6 +11,9 @@ +
@@ -39,6 +42,7 @@
+ @@ -64,8 +68,11 @@ theme: 'dracula', matchBrackets: true, indentUnit : 4, + indentWithTabs: 4, + flattenSpans: false, tabSize : 4, smartIndent: true, + mode: 'text/html', extraKeys: { 'Shift-Tab': function (cm) { if (cm.somethingSelected()) { diff --git a/module-form/src/main/resources/templates/form/get-show-page-code.html b/module-form/src/main/resources/templates/form/get-show-page-code.html index 4cc9dbf8..f002c8b5 100644 --- a/module-form/src/main/resources/templates/form/get-show-page-code.html +++ b/module-form/src/main/resources/templates/form/get-show-page-code.html @@ -11,6 +11,9 @@ +
@@ -64,6 +67,8 @@ theme: 'dracula', matchBrackets: true, indentUnit : 4, + indentWithTabs: 4, + flattenSpans: false, tabSize : 4, smartIndent: true, extraKeys: { diff --git a/module-form/src/main/resources/templates/form/get-update-page-code.html b/module-form/src/main/resources/templates/form/get-update-page-code.html index 8c038d4c..78763a83 100644 --- a/module-form/src/main/resources/templates/form/get-update-page-code.html +++ b/module-form/src/main/resources/templates/form/get-update-page-code.html @@ -11,6 +11,9 @@ +
@@ -64,6 +67,8 @@ theme: 'dracula', matchBrackets: true, indentUnit : 4, + indentWithTabs: 4, + flattenSpans: false, tabSize : 4, smartIndent: true, extraKeys: { diff --git a/module-form/src/main/resources/templates/ftl/page/app/app-form-save.ftl b/module-form/src/main/resources/templates/ftl/page/app/app-form-save.ftl index d2412de7..cfd8717b 100644 --- a/module-form/src/main/resources/templates/ftl/page/app/app-form-save.ftl +++ b/module-form/src/main/resources/templates/ftl/page/app/app-form-save.ftl @@ -20,9 +20,13 @@
+ <#list fields as field> + ${field.html} + +