Skip to content

Commit

Permalink
Fix 3.8.2 (#820)
Browse files Browse the repository at this point in the history
* fix: 分组父级字段

* 3.8.2

* Update ApprovalStepService.java

* be: 重复记录/弱校验
  • Loading branch information
getrebuild authored Oct 14, 2024
1 parent 101b89b commit 5daba9f
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<version>3.8.1</version>
<version>3.8.2</version>
<name>rebuild</name>
<description>Building your business-systems freely!</description>
<url>https://getrebuild.com/</url>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/rebuild/core/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public class Application implements ApplicationListener<ApplicationStartedEvent>
/**
* 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ protected String buildParentFilters(Entity entity, List<String[]> categoryFields
// v3.8-b4 包括子级
Set<ID> thisAndChild = new HashSet<>();
Collection<Item> parent = Collections.singletonList(new Item(ID.valueOf(fieldValue), null));
boolean hasParentField = ff.length > 1 && StringUtils.isNotBlank(ff[1]);
while (true) {
Collection<Item> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -228,14 +229,20 @@ 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));
} catch (DataSpecificationException known) {
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 {
Expand All @@ -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);
}
}

Expand Down
20 changes: 16 additions & 4 deletions src/main/resources/web/assets/js/general/rb-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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()
Expand All @@ -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 {
Expand Down
16 changes: 14 additions & 2 deletions src/main/resources/web/assets/js/general/rb-forms.append.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ class LiteFormModal extends RbModalHandler {
)
}
_handleSave() {
_handleSave(weakMode) {
const data = this._LiteForm.buildFormData()
if (data === false) return
Expand All @@ -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('保存成功'))
Expand All @@ -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)
}
Expand Down
20 changes: 15 additions & 5 deletions src/main/resources/web/assets/js/metadata/field-formula.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className="group-fields">
{this.state.groupFields && this.state.groupFields.length > 0 && (
{groupFields && groupFields.length > 0 && (
<div className="mb-1">
{this.state.groupFields.map((item) => {
{groupFields.map((item) => {
return (
<span className="d-inline-block mb-1" key={item.targetField}>
<span className="badge badge-primary badge-close m-0 mr-1">
Expand Down Expand Up @@ -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)
Expand All @@ -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 })
}

Expand All @@ -462,7 +472,7 @@ class MatchFields extends React.Component {
}

val() {
return this.state.groupFields || []
return this._groupFields38() || []
}
}

Expand Down

0 comments on commit 5daba9f

Please sign in to comment.