Skip to content

Commit

Permalink
Fix 3.3-beta3 (getrebuild#615)
Browse files Browse the repository at this point in the history
* be: nodata for reports

* fix: replace cell

* GA:G-ZCZHJPMEG7

* be: convertPdf

* feat: 每周归零

* ntext copy

* fix: $mp._mp

* lang
  • Loading branch information
getrebuild authored May 18, 2023
1 parent 2131ef1 commit 15cd20d
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 62 deletions.
2 changes: 1 addition & 1 deletion @rbv
Submodule @rbv updated from d7f414 to af7508
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ REBUILD 侧重于业务需求实现,而非基础技术框架或项目启动模

> **福利:加入 REBUILD QQ 交流群 819865721(满) 1013051587 GET 使用技能**
## V3.2 新特性
## V3.3 新特性

本次更新为你带来众多功能增强与优化。

1. [新增] 用户离职继任
2. [新增] 审批流程审批支持“加签”、“转审”
3. [新增] “取消共享”、“新建动态”触发器
4. [新增] 小数字段支持显示“格式”(数字、百分比、货币)
5. [新增] 文本字段、引用字段支持“启用扫码”
6. [新增] 数据列表导出支持 CSV、Excel、报表模板三种格式
7. [优化] 全局搜索与新建样式调整
8. [优化] 25+ 细节/BUG/安全性更新
1. [新增] 标签字段
2. [新增] 顶部一级菜单
3. [新增] 普通用户支持数据导入
4. [新增] 文件支持目录权限配置
5. [新增] 触发器字段聚合新增“连接”聚合方式(支持多引用字段)
6. [新增] 触发器字段更新支持“源字段为空时置空目标字段”选项
7. [优化] 明细编辑支持一次选择多个记录并带入
8. [优化] 30+ 细节/BUG/安全性更新
9. ...

更多新特性请参见 [更新日志](https://getrebuild.com/docs/dev/changelog)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected void mergePrivileges() {
}
}

if (log.isDebugEnabled() || Application.devMode()) {
if (log.isDebugEnabled()) {
for (Privileges p : getAllPrivileges()) {
if (p instanceof ZeroPrivileges) continue;
System.out.println();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.core.DefinedException;
import com.rebuild.core.RebuildException;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.metadata.easymeta.DisplayType;
Expand Down Expand Up @@ -112,12 +113,15 @@ public File export(String csvOrExcel) {
head4Excel.add(Collections.singletonList(h));
}

List<List<String>> datas = this.buildData(builder, Boolean.FALSE);
if (datas.isEmpty()) throw new DefinedException(Language.L("暂无数据"));

EasyExcel.write(file)
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
.registerWriteHandler(this.buildExcelStyle())
.sheet("Sheet1")
.head(head4Excel)
.doWrite(this.buildData(builder, Boolean.FALSE));
.doWrite(datas);
return file;
}

Expand All @@ -130,7 +134,10 @@ public File export(String csvOrExcel) {
writer.write("\ufeff");
writer.write(mergeLine(head));

for (List<String> row : this.buildData(builder, Boolean.TRUE)) {
List<List<String>> datas = this.buildData(builder, Boolean.TRUE);
if (datas.isEmpty()) throw new DefinedException(Language.L("暂无数据"));

for (List<String> row : datas) {
writer.newLine();
writer.write(mergeLine(row));
count++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.rebuild.core.Application;
import com.rebuild.core.DefinedException;
import com.rebuild.core.metadata.EntityHelper;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.metadata.easymeta.DisplayType;
Expand Down Expand Up @@ -96,8 +97,7 @@ public File generate() {
System.currentTimeMillis(), template.getName().endsWith(".xlsx") ? "xlsx" : "xls"));

List<Map<String, Object>> datas = buildData();
// 无数据
if (datas.isEmpty()) return null;
if (datas.isEmpty()) throw new DefinedException(Language.L("暂无数据"));

Map<String, Object> main = null;
if (this.hasMain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;

import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -42,9 +44,14 @@ private void setCellFormula(CellWriteHandlerContext context) {

String cellFormula = cellValue.substring(2, cellValue.length() - 1);
Matcher m = PATT_CELLNO.matcher(cellValue);
Set<String> set = new HashSet<>();
while (m.find()) {
String cellNo = m.group(1);
String cellNoNew = cellNo.replaceAll("[0-9]+", rowIndex + "");
// 避免多次替换出错
if (set.contains(cellNo)) continue;
set.add(cellNo);

String cellNoNew = cellNo.replaceAll("[0-9]+", String.valueOf(rowIndex));
cellFormula = cellFormula.replace(cellNo, cellNoNew);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,20 @@ public class SeriesZeroResetJob extends DistributedJobLock {
protected void executeJob() {
if (!tryLock()) return;

final Calendar now = CalendarUtils.getInstance();

boolean isFirstDayOfYear = false;
boolean isFirstDayOfMonth = false;
final Calendar now = CalendarUtils.getInstance();
if (now.get(Calendar.DAY_OF_MONTH) == 1) {
isFirstDayOfMonth = true;
if (now.get(Calendar.MONTH) == Calendar.JANUARY) {
isFirstDayOfYear = true;
}
}

// 周一
boolean isFirstDayOfWeek = now.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY;

for (Entity entity : MetadataHelper.getEntities()) {
for (Field field : entity.getFields()) {
EasyField easyField = EasyMetaFactory.valueOf(field);
Expand All @@ -60,6 +64,9 @@ protected void executeJob() {
} else if ("Y".equalsIgnoreCase(zeroMode) && isFirstDayOfYear) {
SeriesGeneratorFactory.zero(field);
log.info("Zero field by [Y] : " + field);
} else if ("W".equalsIgnoreCase(zeroMode) && isFirstDayOfWeek) {
SeriesGeneratorFactory.zero(field);
log.info("Zero field by [W] : " + field);
}
}
}
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/rebuild/web/general/ReportsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.rebuild.api.RespBody;
import com.rebuild.api.user.AuthTokenManager;
import com.rebuild.core.Application;
import com.rebuild.core.DefinedException;
import com.rebuild.core.configuration.ConfigBean;
import com.rebuild.core.metadata.MetadataHelper;
import com.rebuild.core.metadata.easymeta.EasyMetaFactory;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void reportGenerate(@PathVariable String entity,
final String outputType = getParameter(request, "output");
// PDF
if ("pdf".equals(outputType) || isOnlyPdf(entity, reportId)) {
output = PdfConverter.convert(output.toPath()).toFile();
output = convertPdf(output);
}

final String fileName = getReportName(entity, reportId, recordId, output);
Expand Down Expand Up @@ -148,14 +149,8 @@ public RespBody export(@PathVariable String entity, HttpServletRequest request)

// PDF
if ("PDF".equalsIgnoreCase(getParameter(request, "output")) || isOnlyPdf(entity, useReport)) {
try {
output = PdfConverter.convert(output.toPath()).toFile();
} catch (PdfConverterException ex) {
log.error(null, ex);
return RespBody.errorl("无法输出 PDF 文件");
}
output = convertPdf(output);
}

} else {
output = exporter.export(reportType);
}
Expand Down Expand Up @@ -214,4 +209,13 @@ private boolean isOnlyPdf(String entity, ID reportId) {
}
return false;
}

private File convertPdf(File source) throws DefinedException {
try {
return PdfConverter.convert(source.toPath()).toFile();
} catch (PdfConverterException ex) {
log.error(null, ex);
throw new DefinedException(Language.L("无法输出 PDF 文件"));
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ server:
tracking-modes: cookie
cookie:
same-site: lax
name: RBSESSION
error:
whitelabel.enabled: false
tomcat:
Expand Down
20 changes: 19 additions & 1 deletion src/main/resources/i18n/lang.zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2597,5 +2597,23 @@
"是否删除所有未布局字段?":"是否删除所有未布局字段?",
"查看如何使用":"查看如何使用",
"明细不允许为空":"明细不允许为空",
"短信与邮件":"短信与邮件"
"短信与邮件":"短信与邮件",
"分配成功":"分配成功",
"成功分配 %d 条记录":"成功分配 %d 条记录",
"(无授权码无需填写)":"(无授权码无需填写)",
"无法共享记录":"无法共享记录",
"验证授权":"验证授权",
"成功取消共享 %d 条记录":"成功取消共享 %d 条记录",
"推送到":"推送到",
"共享成功":"共享成功",
"我有商业授权码":"我有商业授权码",
"更新时默认只推送修改的字段/数据,启用后会推送全部字段/数据":"更新时默认只推送修改的字段/数据,启用后会推送全部字段/数据",
"推送测试":"推送测试",
"无法分配记录":"无法分配记录",
"推送全量数据":"推送全量数据",
"成功共享 %d 条记录":"成功共享 %d 条记录",
"每周归零":"每周归零",
"无法取消共享":"无法取消共享",
"启用后,调用返回结果必须为 `SUCCESS`,否则将视为调用失败":"启用后,调用返回结果必须为 `SUCCESS`,否则将视为调用失败",
"无效商业授权码":"无效商业授权码"
}
1 change: 1 addition & 0 deletions src/main/resources/web/admin/metadata/field-edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ <h5>[[${bundle.L('常用')}]]</h5>
<select class="form-control form-control-sm" id="seriesZero">
<option value="N" selected="selected">[[${bundle.L('不归零')}]]</option>
<option value="D">[[${bundle.L('每天归零')}]]</option>
<option value="W">[[${bundle.L('每周归零')}]]</option>
<option value="M">[[${bundle.L('每月归零')}]]</option>
<option value="Y">[[${bundle.L('每年归零')}]]</option>
</select>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/css/rb-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -4034,7 +4034,7 @@ a.select-lang:hover {
}

.rbv {
color: #b07219;
color: #fc9a00;
font-size: 11px;
font-weight: bold;
font-style: italic;
Expand Down
44 changes: 42 additions & 2 deletions src/main/resources/web/assets/css/view-page.css
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,44 @@ body {
max-height: 1001px;
}

.rbview-form .type-NTEXT .ntext-action {
position: absolute;
top: 5px;
right: 5px;
opacity: 0;
transition: opacity 0.4s;
}

.rbview-form .type-NTEXT.editable .ntext-action {
right: 24px;
}

.rbview-form .type-NTEXT .ntext-action > a {
background-color: #eee;
background-color: #f8f9fa;
color: #aaa;
width: 24px;
height: 24px;
display: inline-block;
margin-right: 5px;
font-size: 16px;
text-align: center;
padding-top: 2px;
border-radius: 2px;
}

.rbview-form .type-NTEXT .col-form-control:hover .ntext-action {
opacity: 1;
}

.rbview-form .type-NTEXT .ps-container.ntext-expand {
max-height: unset !important;
}

.rbview-form .type-NTEXT .ps-container.ntext-expand + .ntext-action .mdi-arrow-expand::before {
content: '\F0615';
}

.nav-tabs > li.nav-item a.nav-link {
padding: 11px 10px;
overflow: hidden;
Expand Down Expand Up @@ -405,11 +443,13 @@ body {
display: inline-block;
}

.rbview-form .form-group.editable a.edit:hover {
.rbview-form .form-group.editable a.edit:hover,
.rbview-form .type-NTEXT .ntext-action > a:hover {
color: #4285f4;
}

.rbview-form .form-group.editable a.edit:active {
.rbview-form .form-group.editable a.edit:active,
.rbview-form .type-NTEXT .ntext-action > a:active {
box-shadow: inset 0 2px 0 #e6e6e6;
background-color: #f0f0f0;
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/web/assets/js/rb-approval.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ class ApprovalSubmitForm extends ApprovalUsersForm {
const selectUsers = this.getSelectUsers()
if (!selectUsers) return

this.disabled(true, true)
this.disabled(true)
$.post(`/app/entity/approval/submit?record=${this.props.id}&approval=${this.state.useApproval}`, JSON.stringify(selectUsers), (res) => {
if (res.error_code > 0) RbHighbar.error(res.error_msg)
else _reload(this, $L('审批已提交'))
Expand Down Expand Up @@ -530,7 +530,7 @@ class ApprovalApproveForm extends ApprovalUsersForm {
post(state) {
const that = this
if (state === 11 && this.state.isRejectStep) {
this.disabled(true, true)
this.disabled(true)
$.get(`/app/entity/approval/fetch-backsteps?record=${this.props.id}`, (res) => {
this.disabled()

Expand Down Expand Up @@ -607,7 +607,7 @@ class ApprovalApproveForm extends ApprovalUsersForm {
} else if (res.error_code > 0) {
RbHighbar.error(res.error_msg)
} else {
_alert && _alert.hide()
_alert && _alert.hide(true)
_reload(this, state === 10 ? $L('审批已同意') : $L('审批已驳回'))
typeof this.props.call === 'function' && this.props.call()
}
Expand Down Expand Up @@ -897,7 +897,7 @@ class ApprovalStepViewer extends React.Component {

// 刷新页面
const _reload = function (dlg, msg) {
dlg && dlg.hide()
dlg && dlg.hide(true)
msg && RbHighbar.success(msg)

setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/js/rb-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ See LICENSE and COMMERCIAL in the project root for license information.
}

rb.commercial = ~~rb.commercial
if (rb.commercial > 1) $('html').addClass('commercial')
if (rb.env === 'dev') $('.dev-show').removeClass('dev-show')
else if (rb.commercial > 1) $('html').addClass('commercial')

if (rb.appName && rb.appName !== document.title) document.title = document.title + ' · ' + rb.appName
setTimeout(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/web/assets/js/rb-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class RbAlert extends React.Component {
$(this._dlg)
.off('hide.bs.modal')
.on('hide.bs.modal', function () {
RbHighbar.create($L('请等待请求执行完毕'))
if ($(event.target).hasClass('zmdi-close')) RbHighbar.create($L('请等待请求执行完毕'))
return false
})
}
Expand Down
Loading

0 comments on commit 15cd20d

Please sign in to comment.