approval no-privi

This commit is contained in:
RB 2022-06-02 10:57:44 +08:00
parent a95ef8d1c3
commit 8f18c44f91
3 changed files with 26 additions and 4 deletions

View file

@ -11,7 +11,9 @@ import cn.devezhao.persist4j.Entity;
import cn.devezhao.persist4j.Record;
import cn.devezhao.persist4j.engine.ID;
import com.alibaba.fastjson.JSONArray;
import com.rebuild.core.DefinedException;
import com.rebuild.core.configuration.general.FormsBuilder;
import com.rebuild.core.support.i18n.Language;
/**
* 审批可修改字段表单
@ -39,6 +41,10 @@ public class FormBuilder {
*/
public JSONArray build(JSONArray elements) {
Record data = UseFormsBuilder.instance.findRecord(record, user, elements);
if (data == null) {
throw new DefinedException(403, Language.L("无法读取审批记录"));
}
UseFormsBuilder.instance.buildModelElements(elements, data.getEntity(), data, user);
return elements;
}

View file

@ -7,6 +7,7 @@ See LICENSE and COMMERCIAL in the project root for license information.
package com.rebuild.web;
import cn.devezhao.bizz.security.AccessDeniedException;
import cn.devezhao.commons.ThrowableUtils;
import cn.devezhao.commons.web.ServletUtils;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
@ -41,7 +42,6 @@ import org.thymeleaf.spring5.view.ThymeleafViewResolver;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.nio.file.AccessDeniedException;
import java.util.List;
import java.util.Map;
@ -184,6 +184,8 @@ public class RebuildWebConfigurer implements WebMvcConfigurer, ErrorViewResolver
}
}
if (StringUtils.isBlank(errorMsg)) errorMsg = Language.L("系统繁忙,请稍后重试");
error.getModel().put("error_code", errorCode);
error.getModel().put("error_msg", errorMsg);

View file

@ -219,6 +219,14 @@ class ApprovalUsersForm extends RbFormHandler {
}
renderUsers() {
if (this.state.hasError) {
return (
<div className="form-group">
<RbAlertBox message={this.state.hasError} type="danger" />
</div>
)
}
const approverHas = (this.state.nextApprovers || []).length > 0 || this.state.approverSelfSelecting
const ccHas = (this.state.nextCcs || []).length > 0 || this.state.ccSelfSelecting
@ -284,7 +292,13 @@ class ApprovalUsersForm extends RbFormHandler {
}
getNextStep(approval) {
$.get(`/app/entity/approval/fetch-nextstep?record=${this.props.id}&approval=${approval || this.props.approval}`, (res) => this.setState(res.data))
$.get(`/app/entity/approval/fetch-nextstep?record=${this.props.id}&approval=${approval || this.props.approval}`, (res) => {
if (res.error_code === 0) {
this.setState({ ...res.data, hasError: null })
} else {
this.setState({ hasError: res.error_msg })
}
})
}
}
@ -398,10 +412,10 @@ class ApprovalApproveForm extends ApprovalUsersForm {
</div>
{this.renderUsers()}
<div className="dialog-footer" ref={(c) => (this._btns = c)}>
<button type="button" className="btn btn-primary btn-space" onClick={() => this.post(10)}>
<button type="button" className="btn btn-primary btn-space" onClick={() => this.post(10)} disabled={!!this.state.hasError}>
{$L('同意')}
</button>
<button type="button" className="btn btn-danger btn-outline btn-space" onClick={() => this.post(11)}>
<button type="button" className="btn btn-danger btn-outline btn-space" onClick={() => this.post(11)} disabled={!!this.state.hasError}>
{$L('驳回')}
</button>
</div>