From 5daba9fd632a6772df8560a0e1fff2672e716266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?REBUILD=20=E4=BC=81=E4=B8=9A=E7=AE=A1=E7=90=86=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F?= <42044143+getrebuild@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:56:30 +0800 Subject: [PATCH] Fix 3.8.2 (#820) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 分组父级字段 * 3.8.2 * Update ApprovalStepService.java * be: 重复记录/弱校验 --- pom.xml | 2 +- .../java/com/rebuild/core/Application.java | 4 ++-- .../general/DataListCategory38.java | 5 ++++- .../general/EasyActionManager.java | 7 ++++++- .../service/approval/ApprovalStepService.java | 1 + .../robot/approval/ApprovalController.java | 19 ++++++++++++++++-- .../web/assets/js/general/rb-approval.js | 20 +++++++++++++++---- .../web/assets/js/general/rb-forms.append.js | 16 +++++++++++++-- .../web/assets/js/metadata/field-formula.js | 20 ++++++++++++++----- 9 files changed, 76 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index 4612a108e..a079b12cd 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.rebuild rebuild - 3.8.1 + 3.8.2 rebuild Building your business-systems freely! https://getrebuild.com/ diff --git a/src/main/java/com/rebuild/core/Application.java b/src/main/java/com/rebuild/core/Application.java index 9599dddb6..edd4d17ad 100644 --- a/src/main/java/com/rebuild/core/Application.java +++ b/src/main/java/com/rebuild/core/Application.java @@ -74,11 +74,11 @@ public class Application implements ApplicationListener /** * Rebuild Version */ - public static final String VER = "3.8.1"; + public static final String VER = "3.8.2"; /** * Rebuild Build [MAJOR]{1}[MINOR]{2}[PATCH]{2}[BUILD]{2} */ - public static final int BUILD = 3080106; + public static final int BUILD = 3080207; static { // Driver for DB diff --git a/src/main/java/com/rebuild/core/configuration/general/DataListCategory38.java b/src/main/java/com/rebuild/core/configuration/general/DataListCategory38.java index ab1fa7ccc..c4ba33165 100644 --- a/src/main/java/com/rebuild/core/configuration/general/DataListCategory38.java +++ b/src/main/java/com/rebuild/core/configuration/general/DataListCategory38.java @@ -249,11 +249,14 @@ protected String buildParentFilters(Entity entity, List categoryFields // v3.8-b4 包括子级 Set thisAndChild = new HashSet<>(); Collection parent = Collections.singletonList(new Item(ID.valueOf(fieldValue), null)); + boolean hasParentField = ff.length > 1 && StringUtils.isNotBlank(ff[1]); while (true) { Collection parentNew = new HashSet<>(); for (Item item : parent) { thisAndChild.add((ID) item.id); - parentNew.addAll(datasReference(fieldMeta, ff[1], item.id)); + if (hasParentField) { + parentNew.addAll(datasReference(fieldMeta, ff[1], item.id)); + } } if (parentNew.isEmpty()) break; diff --git a/src/main/java/com/rebuild/core/configuration/general/EasyActionManager.java b/src/main/java/com/rebuild/core/configuration/general/EasyActionManager.java index b1f1f2616..5938b24a5 100644 --- a/src/main/java/com/rebuild/core/configuration/general/EasyActionManager.java +++ b/src/main/java/com/rebuild/core/configuration/general/EasyActionManager.java @@ -34,7 +34,12 @@ public JSON getEasyAction(String entity, ID user) { ConfigBean cb = getLayout(UserService.SYSTEM_USER, entity, TYPE_EASYACTION, null); if (cb == null) return null; - JSONArray items = (JSONArray) cb.getJSON("config"); + JSONArray items; + try { + items = (JSONArray) cb.getJSON("config"); + } catch (Exception ignored) { + return null; + } if (items == null || items.isEmpty()) return null; JSONArray items4User = new JSONArray(); diff --git a/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java b/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java index 5c944006b..42019fba9 100644 --- a/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java +++ b/src/main/java/com/rebuild/core/service/approval/ApprovalStepService.java @@ -692,6 +692,7 @@ private void setApprovalStepX37(Record record, Object nextApprovers) { // clear if (nextApproversFix == null) { + // NOTE 保留不清空??? record.setNull(EntityHelper.ApprovalStepUsers); record.setNull(EntityHelper.ApprovalStepNodeName); return; diff --git a/src/main/java/com/rebuild/web/robot/approval/ApprovalController.java b/src/main/java/com/rebuild/web/robot/approval/ApprovalController.java index c858da254..9d59de473 100644 --- a/src/main/java/com/rebuild/web/robot/approval/ApprovalController.java +++ b/src/main/java/com/rebuild/web/robot/approval/ApprovalController.java @@ -21,7 +21,6 @@ import com.rebuild.core.metadata.EntityHelper; import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.privileges.UserHelper; -import com.rebuild.core.privileges.bizz.ZeroEntry; import com.rebuild.core.service.DataSpecificationException; import com.rebuild.core.service.DataSpecificationNoRollbackException; import com.rebuild.core.service.approval.ApprovalException; @@ -34,6 +33,8 @@ import com.rebuild.core.service.approval.FlowNode; import com.rebuild.core.service.approval.FlowNodeGroup; import com.rebuild.core.service.approval.RobotApprovalManager; +import com.rebuild.core.service.trigger.DataValidateException; +import com.rebuild.utils.CommonsUtils; import com.rebuild.utils.JSONUtils; import com.rebuild.web.BaseController; import com.rebuild.web.IdParam; @@ -228,7 +229,8 @@ public RespBody doApprove(HttpServletRequest request, @IdParam(name = "record") // 可编辑字段 JSONObject aformData = post.getJSONObject("aformData"); Record addedRecord = null; - // 没有或无更新 + // v3.9 弱校验 + final ID weakMode = getIdParameter(request, "weakMode"); if (aformData != null && aformData.size() > 1) { try { addedRecord = EntityHelper.parse(aformData, getRequestUser(request)); @@ -236,6 +238,11 @@ public RespBody doApprove(HttpServletRequest request, @IdParam(name = "record") log.warn(">>>>> {}", known.getLocalizedMessage()); return RespBody.error(known.getLocalizedMessage()); } + + if (!Application.getEntityService(addedRecord.getEntity().getEntityCode()).getAndCheckRepeated(addedRecord, 1).isEmpty()) { + return RespBody.errorl("存在重复记录"); + } + if (weakMode != null) CommonsUtils.invokeMethod("com.rebuild.rbv.trigger.DataValidate#setWeakMode", weakMode); } try { @@ -247,9 +254,17 @@ public RespBody doApprove(HttpServletRequest request, @IdParam(name = "record") return RespBody.error(ex.getLocalizedMessage(), DefinedException.CODE_APPROVE_WARN); } catch (ApprovalException ex) { return RespBody.error(ex.getLocalizedMessage()); + } catch (DataValidateException known) { + if (known.isWeakMode()) { + String msg = known.getLocalizedMessage() + "$$$$" + known.getWeakModeTriggerId(); + return RespBody.error(msg, DefinedException.CODE_WEAK_VALIDATE); + } + return RespBody.error(known.getLocalizedMessage()); } catch (UnexpectedRollbackException rolledback) { log.error("ROLLEDBACK", rolledback); return RespBody.error("ROLLEDBACK OCCURED"); + } finally { + if (weakMode != null) CommonsUtils.invokeMethod("com.rebuild.rbv.trigger.DataValidate#getWeakMode", true); } } diff --git a/src/main/resources/web/assets/js/general/rb-approval.js b/src/main/resources/web/assets/js/general/rb-approval.js index fcb847b62..6877b57e5 100644 --- a/src/main/resources/web/assets/js/general/rb-approval.js +++ b/src/main/resources/web/assets/js/general/rb-approval.js @@ -594,7 +594,7 @@ class ApprovalApproveForm extends ApprovalUsersForm { onConfirm: function () { this.disabled(true, true) const node = $(this._element).find('select').val() - that.post2(state, node === '0' ? null : node, this) + that._post(state, node === '0' ? null : node, this) }, onRendered: function () { $(this._element).find('select').select2({ @@ -605,11 +605,11 @@ class ApprovalApproveForm extends ApprovalUsersForm { ) }) } else { - this.post2(state, null) + this._post(state, null) } } - post2(state, rejectNode, _alert) { + _post(state, rejectNode, _alert, weakMode) { let aformData = {} if (this.state.aform && state === 10) { aformData = this._LiteForm.buildFormData() @@ -632,13 +632,25 @@ class ApprovalApproveForm extends ApprovalUsersForm { _alert && _alert.disabled(true, true) this.disabled(true) - $.post(`/app/entity/approval/approve?record=${this.props.id}&state=${state}&rejectNode=${rejectNode || ''}`, JSON.stringify(data), (res) => { + let url = `/app/entity/approval/approve?record=${this.props.id}&state=${state}&rejectNode=${rejectNode || ''}` + if (weakMode) url += '&weakMode=' + weakMode + $.post(url, JSON.stringify(data), (res) => { _alert && _alert.disabled() this.disabled() if (res.error_code === 498) { this.setState({ bizMessage: res.error_msg }) this.getNextStep() + } else if (res.error_code === 497) { + // 弱校验 + const that = this + const msg_id = res.error_msg.split('$$$$') + RbAlert.create(msg_id[0], { + onConfirm: function () { + this.hide() + that._post(state, rejectNode, _alert, msg_id[1]) + }, + }) } else if (res.error_code > 0) { RbHighbar.error(res.error_msg) } else { diff --git a/src/main/resources/web/assets/js/general/rb-forms.append.js b/src/main/resources/web/assets/js/general/rb-forms.append.js index 0b4323c75..8e6c86523 100644 --- a/src/main/resources/web/assets/js/general/rb-forms.append.js +++ b/src/main/resources/web/assets/js/general/rb-forms.append.js @@ -831,7 +831,7 @@ class LiteFormModal extends RbModalHandler { ) } - _handleSave() { + _handleSave(weakMode) { const data = this._LiteForm.buildFormData() if (data === false) return @@ -850,7 +850,9 @@ class LiteFormModal extends RbModalHandler { } this.disabled(true) - $.post('/app/entity/liteform/record-save', JSON.stringify(data2), (res) => { + let url = '/app/entity/liteform/record-save' + if (weakMode) url += '?weakMode=' + weakMode + $.post(url, JSON.stringify(data2), (res) => { this.disabled() if (res.error_code === 0) { RbHighbar.success($L('保存成功')) @@ -862,6 +864,16 @@ class LiteFormModal extends RbModalHandler { if (window.RbViewPage) window.RbViewPage.reload() // 关闭 this.hide() + } else if (res.error_code === 497) { + // 弱校验 + const that = this + const msg_id = res.error_msg.split('$$$$') + RbAlert.create(msg_id[0], { + onConfirm: function () { + this.hide() + that._handleSave(msg_id[1]) + }, + }) } else { RbHighbar.error(res.error_msg) } diff --git a/src/main/resources/web/assets/js/metadata/field-formula.js b/src/main/resources/web/assets/js/metadata/field-formula.js index d6c6bd98d..0c1893a03 100644 --- a/src/main/resources/web/assets/js/metadata/field-formula.js +++ b/src/main/resources/web/assets/js/metadata/field-formula.js @@ -333,12 +333,22 @@ class MatchFields extends React.Component { this.state.targetFields = this.reset(props, true) } + // fix:3.8.2 + _groupFields38() { + let groupFields = this.state.groupFields + if (groupFields && typeof groupFields === 'string') { + eval(`groupFields = ${groupFields}`) + } + return groupFields + } + render() { + const groupFields = this._groupFields38() return (
- {this.state.groupFields && this.state.groupFields.length > 0 && ( + {groupFields && groupFields.length > 0 && (
- {this.state.groupFields.map((item) => { + {groupFields.map((item) => { return ( @@ -429,7 +439,7 @@ class MatchFields extends React.Component { if (!item.targetField) return RbHighbar.create($L('请选择目标匹配字段')) if (!item.sourceField) return RbHighbar.create($L('请选择源匹配字段')) - const groupFields = this.state.groupFields || [] + const groupFields = this._groupFields38() let exists = groupFields.find((x) => item.targetField === x.targetField) if (exists) return RbHighbar.create($L('目标匹配字段已添加')) exists = groupFields.find((x) => item.sourceField === x.sourceField) @@ -440,7 +450,7 @@ class MatchFields extends React.Component { } _delGroupField(TF) { - const groupFields = this.state.groupFields.filter((x) => x.targetField !== TF) + const groupFields = this._groupFields38().filter((x) => x.targetField !== TF) this.setState({ groupFields }) } @@ -462,7 +472,7 @@ class MatchFields extends React.Component { } val() { - return this.state.groupFields || [] + return this._groupFields38() || [] } }