Skip to content

Commit

Permalink
be: 审批流程强制保存
Browse files Browse the repository at this point in the history
  • Loading branch information
getrebuild committed Jan 22, 2025
1 parent efaf53e commit db3ae9b
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.rebuild.core.privileges.AdminGuard;
import com.rebuild.core.service.DataSpecificationException;
import com.rebuild.core.support.i18n.Language;
import org.springframework.core.NamedThreadLocal;
import org.springframework.stereotype.Service;

/**
Expand Down Expand Up @@ -52,7 +53,9 @@ public Record update(Record record) {
if (record.hasValue("flowDefinition")) {
int inUsed = ApprovalHelper.checkInUsed(record.getPrimary());
if (inUsed > 0) {
throw new DataSpecificationException(Language.L("有 %d 条记录正在使用此流程,禁止修改", inUsed));
Boolean force40 = _FORCESAVE.get();
if (force40 != null) _FORCESAVE.remove();
else throw new DataSpecificationException(Language.L("有 %d 条记录正在使用此流程,禁止修改", inUsed));
}
}
return super.update(record);
Expand Down Expand Up @@ -87,4 +90,11 @@ protected void cleanCache(ID cfgid) {
RobotApprovalManager.instance.clean(entity);
}
}

private static final ThreadLocal<Boolean> _FORCESAVE = new NamedThreadLocal<>("Force save on used");
/**
*/
public static void setForceSave() {
_FORCESAVE.set(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.rebuild.core.metadata.MetadataSorter;
import com.rebuild.core.metadata.easymeta.DisplayType;
import com.rebuild.core.service.DataSpecificationException;
import com.rebuild.core.service.approval.RobotApprovalConfigService;
import com.rebuild.core.service.query.AdvFilterParser;
import com.rebuild.core.service.query.ParseHelper;
import com.rebuild.core.service.query.QueryHelper;
Expand Down Expand Up @@ -68,6 +69,12 @@ record = EntityHelper.parse((JSONObject) formJson, getRequestUser(request));
return RespBody.error(known.getLocalizedMessage());
}

// 特殊处理
if (getBoolParameter(request, "force")
&& record.getEntity().getEntityCode() == EntityHelper.RobotApprovalConfig) {
RobotApprovalConfigService.setForceSave();
}

return saveRecord(record);
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/web/admin/metadata/entity-advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ <h5 class="font-weight-bold">[[${bundle.L('卡片模式')}]]</h5>
</div>
<div>
<button type="button" class="btn btn-danger J_drop-confirm" disabled="disabled"><i class="zmdi zmdi-delete icon"></i> [[${bundle.L('确定')}]]</button>
<button type="button" class="btn btn-warning J_truncate-confirm ml-2 bosskey-show" disabled="disabled">
<i class="mdi mdi-flask-empty-remove icon"></i> [[${bundle.L('清空数据')}]]
</button>
<button type="button" class="btn btn-warning J_truncate-confirm ml-2 bosskey-show" disabled="disabled"><i class="mdi mdi-alert-outline icon"></i> [[${bundle.L('清空数据')}]]</button>
<div class="alert alert-warning alert-icon hide col-sm-6 mb-0">
<div class="icon"><span class="zmdi zmdi-alert-triangle"></span></div>
<div class="message">[[${bundle.L('系统内置,不允许删除')}]]</div>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/web/admin/robot/approval-design.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<button class="btn btn-primary dropdown-toggle w-auto" type="button" data-toggle="dropdown"><i class="icon zmdi zmdi-chevron-down"></i></button>
<div class="dropdown-menu dropdown-menu-primary dropdown-menu-right">
<a class="dropdown-item J_copy"><i class="icon zmdi zmdi-copy"></i> [[${bundle.L('另存为')}]]</a>
<a class="dropdown-item J_save bosskey-show" data-force="true"><i class="icon mdi mdi-alert-outline"></i> [[${bundle.L('强制保存')}]]</a>
</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/web/assets/css/rb-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,11 @@ a.btn {
cursor: default;
}

.btn .icon {
min-width: 12px;
transform: translateY(-1px);
}

.btn .icon.x14 {
font-size: 1.431rem;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/web/assets/js/admin/approval-design.js
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ class RbFlowCanvas extends NodeGroupSpec {
$('.box-scale').draggable({ cursor: 'move', axis: 'x', scroll: false })
$('#rbflow').removeClass('rb-loading-active')

const $btn = $('.J_save').on('click', () => {
const $btn = $('.J_save').on('click', (e) => {
const s = this.serialize()
if (!s) return

Expand All @@ -1104,7 +1104,7 @@ class RbFlowCanvas extends NodeGroupSpec {
const noApproverNode = !data.includes('"approver"')

$btn.button('loading')
$.post('/app/entity/common-save', data, (res) => {
$.post(`/app/entity/common-save?force=${!!$(e.target).data('force')}`, data, (res) => {
if (res.error_code === 0) {
const msg = (
<RF>
Expand Down

0 comments on commit db3ae9b

Please sign in to comment.