From e6cb818cf8ffe04b9a985865d5ab50dec138e1a8 Mon Sep 17 00:00:00 2001 From: devezhao Date: Sat, 9 Jan 2021 17:08:25 +0800 Subject: [PATCH] history in right side on view --- .eslintrc.js | 1 + .../web/general/FormExtrasController.java | 66 ------- .../web/general/GeneralModelController.java | 67 ------- .../web/general/ModelExtrasController.java | 164 ++++++++++++++++++ src/main/resources/i18n/language.en.json | 3 + src/main/resources/i18n/language.zh_CN.json | 3 + src/main/resources/i18n/language.zh_TW.json | 3 + .../web/admin/bizuser/dept-view.html | 13 ++ .../web/admin/bizuser/role-view.html | 13 ++ .../web/admin/bizuser/team-view.html | 13 ++ .../web/admin/bizuser/user-view.html | 13 ++ .../resources/web/assets/css/view-page.css | 48 ++++- .../web/assets/js/bizuser/user-view.js | 2 +- src/main/resources/web/assets/js/rb-forms.js | 2 +- src/main/resources/web/assets/js/rb-page.js | 23 ++- src/main/resources/web/assets/js/rb-view.js | 67 +++++-- .../resources/web/general/detail-view.html | 6 + .../resources/web/general/record-view.html | 6 + 18 files changed, 351 insertions(+), 162 deletions(-) delete mode 100644 src/main/java/com/rebuild/web/general/FormExtrasController.java create mode 100644 src/main/java/com/rebuild/web/general/ModelExtrasController.java diff --git a/.eslintrc.js b/.eslintrc.js index 2a08ef3ca..3adf921d1 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -104,6 +104,7 @@ module.exports = { $fromNow: true, $expired: true, $L: true, + $LF: true, $isTrue: true, $fieldIsCompatible: true, $unhideDropdown: true diff --git a/src/main/java/com/rebuild/web/general/FormExtrasController.java b/src/main/java/com/rebuild/web/general/FormExtrasController.java deleted file mode 100644 index 2c8956bfe..000000000 --- a/src/main/java/com/rebuild/web/general/FormExtrasController.java +++ /dev/null @@ -1,66 +0,0 @@ -/* -Copyright (c) REBUILD and/or its owners. All rights reserved. - -rebuild is dual-licensed under commercial and open source licenses (GPLv3). -See LICENSE and COMMERCIAL in the project root for license information. -*/ - -package com.rebuild.web.general; - -import cn.devezhao.persist4j.Entity; -import cn.devezhao.persist4j.Field; -import cn.devezhao.persist4j.engine.ID; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; -import com.rebuild.api.RespBody; -import com.rebuild.core.configuration.ConfigBean; -import com.rebuild.core.configuration.general.AutoFillinManager; -import com.rebuild.core.configuration.general.TransformManager; -import com.rebuild.core.metadata.MetadataHelper; -import com.rebuild.core.service.general.transform.RecordTransfomer; -import com.rebuild.web.BaseController; -import com.rebuild.web.EntityParam; -import com.rebuild.web.IdParam; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; - -/** - * 表单功能扩展 - * - * @author devezhao zhaofang123@gmail.com - * @since 2019/05/20 - */ -@RestController -@RequestMapping("/app/entity/extras/") -public class FormExtrasController extends BaseController { - - // 获取表单回填数据 - @RequestMapping("fillin-value") - public JSON getFillinValue(@EntityParam Entity entity, @IdParam(name = "source") ID sourceRecord, - HttpServletRequest request) { - String field = getParameterNotNull(request, "field"); - Field useField = entity.getField(field); - - return AutoFillinManager.instance.getFillinValue(useField, sourceRecord); - } - - // 记录转换 - @RequestMapping("transform") - public RespBody transform(HttpServletRequest request) { - ID transid = getIdParameterNotNull(request, "transid"); - ID sourceRecord = getIdParameterNotNull(request, "source"); - - ConfigBean config = TransformManager.instance.getTransformConfig(transid, null); - Entity targetEntity = MetadataHelper.getEntity(config.getString("target")); - - RecordTransfomer transfomer = new RecordTransfomer(targetEntity, (JSONObject) config.getJSON("config")); - if (!transfomer.checkFilter(sourceRecord)) { - return RespBody.error(getLang(request, "TransformNotAllow"), 400); - } - - ID newId = transfomer.transform(sourceRecord); - return RespBody.ok(newId); - } -} diff --git a/src/main/java/com/rebuild/web/general/GeneralModelController.java b/src/main/java/com/rebuild/web/general/GeneralModelController.java index eadb7b03b..eb1292d4b 100644 --- a/src/main/java/com/rebuild/web/general/GeneralModelController.java +++ b/src/main/java/com/rebuild/web/general/GeneralModelController.java @@ -12,19 +12,13 @@ import cn.devezhao.commons.web.ServletUtils; import cn.devezhao.persist4j.Entity; import cn.devezhao.persist4j.engine.ID; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONAware; import com.alibaba.fastjson.JSONObject; -import com.rebuild.api.RespBody; -import com.rebuild.core.Application; import com.rebuild.core.configuration.general.FormBuilderContextHolder; import com.rebuild.core.configuration.general.FormsBuilder; import com.rebuild.core.configuration.general.TransformManager; import com.rebuild.core.configuration.general.ViewAddonsManager; import com.rebuild.core.metadata.MetadataHelper; import com.rebuild.core.privileges.UserHelper; -import com.rebuild.core.privileges.bizz.User; -import com.rebuild.core.support.i18n.I18nUtils; -import com.rebuild.utils.JSONUtils; import com.rebuild.web.EntityController; import com.rebuild.web.IdParam; import org.springframework.web.bind.annotation.*; @@ -33,9 +27,6 @@ import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; /** * 表单/视图 @@ -115,64 +106,6 @@ public class GeneralModelController extends EntityController { return FormsBuilder.instance.buildView(entity, getRequestUser(request), id); } - @GetMapping("record-meta") - public JSONAware fetchRecordMeta(@IdParam ID id) { - final Entity entity = MetadataHelper.getEntity(id.getEntityCode()); - - String sql = "select createdOn,modifiedOn from %s where %s = '%s'"; - if (MetadataHelper.hasPrivilegesField(entity)) { - sql = sql.replace(",modifiedOn", ",modifiedOn,owningUser"); - } - - sql = String.format(sql, entity.getName(), entity.getPrimaryField().getName(), id); - Object[] recordMeta = Application.createQueryNoFilter(sql).unique(); - if (recordMeta == null) { - return RespBody.errorl("RecordNotExists"); - } - - recordMeta[0] = I18nUtils.formatDate((Date) recordMeta[0]); - recordMeta[1] = I18nUtils.formatDate((Date) recordMeta[1]); - - String[] owning = null; - List sharingList = null; - if (recordMeta.length == 3) { - User user = Application.getUserStore().getUser((ID) recordMeta[2]); - String dept = user.getOwningDept() == null ? null : user.getOwningDept().getName(); - owning = new String[]{user.getIdentity().toString(), user.getFullName(), dept}; - - Object[][] shareTo = Application.createQueryNoFilter( - "select shareTo from ShareAccess where belongEntity = ? and recordId = ?") - .setParameter(1, entity.getName()) - .setParameter(2, id) - .setLimit(9) // 最多显示9个 - .array(); - sharingList = new ArrayList<>(); - for (Object[] st : shareTo) { - sharingList.add(new String[]{st[0].toString(), UserHelper.getName((ID) st[0])}); - } - } - - return JSONUtils.toJSONObject( - new String[] { "createdOn", "modifiedOn", "owningUser", "sharingList" }, - new Object[] { recordMeta[0], recordMeta[1], owning, sharingList }); - } - - @GetMapping("record-lastModified") - public JSONAware fetchRecordLastModified(@IdParam ID id) { - final Entity entity = MetadataHelper.getEntity(id.getEntityCode()); - - String sql = String.format("select modifiedOn from %s where %s = '%s'", - entity.getName(), entity.getPrimaryField().getName(), id); - Object[] recordMeta = Application.createQueryNoFilter(sql).unique(); - if (recordMeta == null) { - return RespBody.errorl("RecordNotExists"); - } - - return JSONUtils.toJSONObject( - new String[] { "lastModified"}, - new Object[] { ((Date) recordMeta[0]).getTime() }); - } - // 打印视图 @GetMapping("print") public ModelAndView printPreview(@PathVariable String entity, @IdParam ID recordId, HttpServletRequest request) { diff --git a/src/main/java/com/rebuild/web/general/ModelExtrasController.java b/src/main/java/com/rebuild/web/general/ModelExtrasController.java new file mode 100644 index 000000000..76a4be6a7 --- /dev/null +++ b/src/main/java/com/rebuild/web/general/ModelExtrasController.java @@ -0,0 +1,164 @@ +/* +Copyright (c) REBUILD and/or its owners. All rights reserved. + +rebuild is dual-licensed under commercial and open source licenses (GPLv3). +See LICENSE and COMMERCIAL in the project root for license information. +*/ + +package com.rebuild.web.general; + +import cn.devezhao.persist4j.Entity; +import cn.devezhao.persist4j.Field; +import cn.devezhao.persist4j.engine.ID; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONAware; +import com.alibaba.fastjson.JSONObject; +import com.rebuild.api.RespBody; +import com.rebuild.core.Application; +import com.rebuild.core.configuration.ConfigBean; +import com.rebuild.core.configuration.general.AutoFillinManager; +import com.rebuild.core.configuration.general.TransformManager; +import com.rebuild.core.metadata.MetadataHelper; +import com.rebuild.core.privileges.UserHelper; +import com.rebuild.core.privileges.bizz.User; +import com.rebuild.core.service.general.transform.RecordTransfomer; +import com.rebuild.core.support.i18n.I18nUtils; +import com.rebuild.core.support.i18n.Language; +import com.rebuild.utils.JSONUtils; +import com.rebuild.web.BaseController; +import com.rebuild.web.EntityParam; +import com.rebuild.web.IdParam; +import org.apache.commons.lang.StringUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.*; + +/** + * 表单/视图 功能扩展 + * + * @author devezhao zhaofang123@gmail.com + * @since 2019/05/20 + */ +@RestController +@RequestMapping("/app/entity/extras/") +public class ModelExtrasController extends BaseController { + + // 获取表单回填数据 + @RequestMapping("fillin-value") + public JSON getFillinValue(@EntityParam Entity entity, @IdParam(name = "source") ID sourceRecord, + HttpServletRequest request) { + String field = getParameterNotNull(request, "field"); + Field useField = entity.getField(field); + + return AutoFillinManager.instance.getFillinValue(useField, sourceRecord); + } + + // 记录转换 + @RequestMapping("transform") + public RespBody transform(HttpServletRequest request) { + ID transid = getIdParameterNotNull(request, "transid"); + ID sourceRecord = getIdParameterNotNull(request, "source"); + + ConfigBean config = TransformManager.instance.getTransformConfig(transid, null); + Entity targetEntity = MetadataHelper.getEntity(config.getString("target")); + + RecordTransfomer transfomer = new RecordTransfomer(targetEntity, (JSONObject) config.getJSON("config")); + if (!transfomer.checkFilter(sourceRecord)) { + return RespBody.error(getLang(request, "TransformNotAllow"), 400); + } + + ID newId = transfomer.transform(sourceRecord); + return RespBody.ok(newId); + } + + @GetMapping("record-last-modified") + public JSONAware fetchRecordLastModified(@IdParam ID id) { + final Entity entity = MetadataHelper.getEntity(id.getEntityCode()); + + String sql = String.format("select modifiedOn from %s where %s = '%s'", + entity.getName(), entity.getPrimaryField().getName(), id); + Object[] recordMeta = Application.createQueryNoFilter(sql).unique(); + if (recordMeta == null) { + return RespBody.errorl("RecordNotExists"); + } + + return JSONUtils.toJSONObject( + new String[] { "lastModified" }, + new Object[] { ((Date) recordMeta[0]).getTime() }); + } + + @GetMapping("record-meta") + public JSONAware fetchRecordMeta(@IdParam ID id) { + final Entity entity = MetadataHelper.getEntity(id.getEntityCode()); + + String sql = "select createdOn,modifiedOn from %s where %s = '%s'"; + if (MetadataHelper.hasPrivilegesField(entity)) { + sql = sql.replace(",modifiedOn", ",modifiedOn,owningUser"); + } + + sql = String.format(sql, entity.getName(), entity.getPrimaryField().getName(), id); + Object[] recordMeta = Application.createQueryNoFilter(sql).unique(); + if (recordMeta == null) { + return RespBody.errorl("RecordNotExists"); + } + + recordMeta[0] = I18nUtils.formatDate((Date) recordMeta[0]); + recordMeta[1] = I18nUtils.formatDate((Date) recordMeta[1]); + + String[] owning = null; + List sharingList = null; + if (recordMeta.length == 3) { + User user = Application.getUserStore().getUser((ID) recordMeta[2]); + String dept = user.getOwningDept() == null ? null : user.getOwningDept().getName(); + owning = new String[]{user.getIdentity().toString(), user.getFullName(), dept}; + + Object[][] shareTo = Application.createQueryNoFilter( + "select shareTo from ShareAccess where belongEntity = ? and recordId = ?") + .setParameter(1, entity.getName()) + .setParameter(2, id) + .setLimit(9) // 最多显示9个 + .array(); + sharingList = new ArrayList<>(); + for (Object[] st : shareTo) { + sharingList.add(new String[]{st[0].toString(), UserHelper.getName((ID) st[0])}); + } + } + + return JSONUtils.toJSONObject( + new String[] { "createdOn", "modifiedOn", "owningUser", "sharingList" }, + new Object[] { recordMeta[0], recordMeta[1], owning, sharingList }); + } + + private static final Map REV_TYPE_LANGS = new HashMap<>(); + static { + REV_TYPE_LANGS.put(1, "Create"); + REV_TYPE_LANGS.put(2, "Delete"); + REV_TYPE_LANGS.put(4, "Update"); + REV_TYPE_LANGS.put(16, "Assign"); + REV_TYPE_LANGS.put(32, "Share"); + REV_TYPE_LANGS.put(64, "UnShare"); + } + + @GetMapping("record-history") + public JSONAware fetchRecordHistory(@IdParam ID id) { + Object[][] array = Application.createQueryNoFilter( + "select revisionType,revisionOn,revisionBy from RevisionHistory where recordId = ? order by revisionOn desc") + .setParameter(1, id) + .setLimit(100) + .array(); + + for (Object[] o : array) { + String type = REV_TYPE_LANGS.get(o[0]); + o[0] = Language.L(StringUtils.defaultString(type, "Unknown")); + o[1] = I18nUtils.formatDate((Date) o[1]); + o[2] = new Object[] { o[2], UserHelper.getName((ID) o[2]) }; + } + + return JSONUtils.toJSONObjectArray( + new String[] { "revisionType", "revisionOn", "revisionBy" }, + array); + } +} diff --git a/src/main/resources/i18n/language.en.json b/src/main/resources/i18n/language.en.json index 94a06da89..95ff14f8f 100644 --- a/src/main/resources/i18n/language.en.json +++ b/src/main/resources/i18n/language.en.json @@ -1291,6 +1291,9 @@ "UploadLogoTips": "Please upload a dark and white LOGO, transparent background, width and height 268 × 54", "FieldNotApply": "Field (type) is not applicable", "AutoTransformOnce": "Transform only once (after the transform, it will not be transformed even if the conditions are met)", + "ViewHistory": "Modification History", + "ViewHistoryContent": "**%s** $ACTION$ by $USER$", + "Unknown": "Unknown", "s.__": "STATE", "s.ApprovalState.DRAFT": "Draft", diff --git a/src/main/resources/i18n/language.zh_CN.json b/src/main/resources/i18n/language.zh_CN.json index 0c2a43ada..3fa2963b6 100644 --- a/src/main/resources/i18n/language.zh_CN.json +++ b/src/main/resources/i18n/language.zh_CN.json @@ -1291,6 +1291,9 @@ "UploadLogoTips": "请分别上传深色与白色 LOGO,透明背景,宽高为 268 × 54", "FieldNotApply": "字段 (类型) 不适用", "AutoTransformOnce": "只转换一次 (转换后即使符合条件也不再转换)", + "ViewHistory": "修改历史", + "ViewHistoryContent": "**%s** 由 $USER$ $ACTION$", + "Unknown": "未知", "s.__": "状态", "s.ApprovalState.DRAFT": "草稿", diff --git a/src/main/resources/i18n/language.zh_TW.json b/src/main/resources/i18n/language.zh_TW.json index 0e879af71..7aedd2dec 100644 --- a/src/main/resources/i18n/language.zh_TW.json +++ b/src/main/resources/i18n/language.zh_TW.json @@ -1291,6 +1291,9 @@ "UploadLogoTips": "請分別上傳深色與白色 LOGO,透明背景,寬高為 268 × 54", "FieldNotApply": "字段 (類型) 不適用", "AutoTransformOnce": "只轉換一次 (轉換後即使符合條件也不再轉換)", + "ViewHistory": "修改歷史", + "ViewHistoryContent": "**%s** 由 $USER$ $ACTION$", + "Unknown": "未知", "s.__": "狀態", "s.ApprovalState.DRAFT": "草稿", diff --git a/src/main/resources/web/admin/bizuser/dept-view.html b/src/main/resources/web/admin/bizuser/dept-view.html index 1a254d2eb..0da369041 100644 --- a/src/main/resources/web/admin/bizuser/dept-view.html +++ b/src/main/resources/web/admin/bizuser/dept-view.html @@ -38,6 +38,19 @@ +
+
+
[[${bundle.L('ViewDate')}]]
+
+
+
[[${bundle.L('f.createdOn')}]]
+
+
+
+
[[${bundle.L('f.modifiedOn')}]]
+
+
+
diff --git a/src/main/resources/web/admin/bizuser/role-view.html b/src/main/resources/web/admin/bizuser/role-view.html index 773c7a1d1..7e7954287 100644 --- a/src/main/resources/web/admin/bizuser/role-view.html +++ b/src/main/resources/web/admin/bizuser/role-view.html @@ -38,6 +38,19 @@ +
+
+
[[${bundle.L('ViewDate')}]]
+
+
+
[[${bundle.L('f.createdOn')}]]
+
+
+
+
[[${bundle.L('f.modifiedOn')}]]
+
+
+
diff --git a/src/main/resources/web/admin/bizuser/team-view.html b/src/main/resources/web/admin/bizuser/team-view.html index 331e03883..0d89e933c 100644 --- a/src/main/resources/web/admin/bizuser/team-view.html +++ b/src/main/resources/web/admin/bizuser/team-view.html @@ -43,6 +43,19 @@ +
+
+
[[${bundle.L('ViewDate')}]]
+
+
+
[[${bundle.L('f.createdOn')}]]
+
+
+
+
[[${bundle.L('f.modifiedOn')}]]
+
+
+
diff --git a/src/main/resources/web/admin/bizuser/user-view.html b/src/main/resources/web/admin/bizuser/user-view.html index e53edc5c0..0132a6f75 100644 --- a/src/main/resources/web/admin/bizuser/user-view.html +++ b/src/main/resources/web/admin/bizuser/user-view.html @@ -51,6 +51,19 @@ +
+
+
[[${bundle.L('ViewDate')}]]
+
+
+
[[${bundle.L('f.createdOn')}]]
+
+
+
+
[[${bundle.L('f.modifiedOn')}]]
+
+
+
diff --git a/src/main/resources/web/assets/css/view-page.css b/src/main/resources/web/assets/css/view-page.css index 191308c63..3ddd6d79b 100644 --- a/src/main/resources/web/assets/css/view-page.css +++ b/src/main/resources/web/assets/css/view-page.css @@ -216,7 +216,7 @@ body { } .view-operating > div.view-user { - margin-bottom: 0 !important; + margin-bottom: 5px !important; } .view-date .col-lg-4, @@ -249,6 +249,7 @@ body { .view-user .row ul > li { margin-bottom: 0; margin-right: 7px; + line-height: 1; } .view-user .row ul > li:last-child { @@ -261,6 +262,10 @@ body { min-height: 36.5px; } +.view-user .user-show { + line-height: 1; +} + .sharing-list ul { margin: 10px 0 21px 10px; } @@ -474,3 +479,44 @@ body { .feeds-list.inview .feeds > .content .rich-content > .appends { font-size: 12px; } + +.view-history .view-history-items { + padding: 0; + margin: 0; + position: relative; +} + +.view-history .view-history-items::before { + content: ''; + position: absolute; + top: 4px; + bottom: 20px; + width: 2px; + background: #ddd; + left: 6px; +} + +.view-history .view-history-items > li { + position: relative; + padding-left: 24px; + height: 28px; + color: #777; +} + +.view-history .view-history-items > li::before { + content: ''; + position: absolute; + top: 4px; + left: 2px; + width: 10px; + height: 10px; + background-color: #ddd; + border-radius: 50px; +} + +.view-history .view-history-items > li b:first-child { + font-weight: normal; + min-width: 60px; + display: inline-block; +} + diff --git a/src/main/resources/web/assets/js/bizuser/user-view.js b/src/main/resources/web/assets/js/bizuser/user-view.js index de1bf4f4e..6c031bf16 100644 --- a/src/main/resources/web/assets/js/bizuser/user-view.js +++ b/src/main/resources/web/assets/js/bizuser/user-view.js @@ -163,7 +163,7 @@ class DlgEnableUser extends RbModalHandler {
(this._roleAppends = c)} /> diff --git a/src/main/resources/web/assets/js/rb-forms.js b/src/main/resources/web/assets/js/rb-forms.js index b8a32df03..e5380d78c 100644 --- a/src/main/resources/web/assets/js/rb-forms.js +++ b/src/main/resources/web/assets/js/rb-forms.js @@ -127,7 +127,7 @@ class RbFormModal extends React.Component { checkDrityData() { if (!this.__lastModified || !this.state.id) return - $.get(`/app/entity/record-lastModified?id=${this.state.id}`, (res) => { + $.get(`/app/entity/extras/record-last-modified?id=${this.state.id}`, (res) => { if (res.error_code === 0) { if (res.data.lastModified !== this.__lastModified) { // this.setState({ alertMessage:

记录已由其他用户编辑过, this.__refresh()}>点击此处查看最新数据

}) diff --git a/src/main/resources/web/assets/js/rb-page.js b/src/main/resources/web/assets/js/rb-page.js index b154d565e..ea0fdc5fd 100644 --- a/src/main/resources/web/assets/js/rb-page.js +++ b/src/main/resources/web/assets/js/rb-page.js @@ -739,22 +739,31 @@ var _$unthy = function (text) { } /** - * 获取语言 + * 获取语言(PH_KEY) */ var $L = function () { var args = arguments.length === 1 ? arguments[0].split(',') : arguments - var lang = _$L(args[0]) + return _$L(args, true) +} +/** + * 获取语言(PH_VALUE) + */ +var $LF = function () { + var args = arguments.length === 1 ? arguments[0].split(',') : arguments + return _$L(args, false) +} +var _$L = function (args, isPhKey) { + var lang = _getLang(args[0]) if (args.length < 2) return lang for (var i = 1; i < args.length; i++) { - if (args[i]) { - var phLang = _$L(args[i]) - lang = lang.replace('{' + (i - 1) + '}', phLang) - } + var phKey = isPhKey ? '{' + (i - 1) + '}' : '%s' + var phLang = isPhKey ? _getLang(args[i]) : args[i] + lang = lang.replace(phKey, phLang) } return lang } -var _$L = function (key) { +var _getLang = function (key) { var lang = (window._LANGBUNDLE || {})[key] if (!lang) { console.warn('Missing lang-key `' + key + '`') diff --git a/src/main/resources/web/assets/js/rb-view.js b/src/main/resources/web/assets/js/rb-view.js index 8545a043f..1060bf151 100644 --- a/src/main/resources/web/assets/js/rb-view.js +++ b/src/main/resources/web/assets/js/rb-view.js @@ -73,7 +73,7 @@ class RbViewForm extends React.Component { // 脏数据检查 checkDrityData(handle) { if (!this.__lastModified || !this.state.id) return - $.get(`/app/entity/record-lastModified?id=${this.state.id}`, (res) => { + $.get(`/app/entity/extras/record-last-modified?id=${this.state.id}`, (res) => { if (res.error_code === 0) { if (res.data.lastModified !== this.__lastModified) { handle && handle.showLoading() @@ -485,13 +485,16 @@ const RbViewPage = { if (ep.S !== true) $('.J_share').remove() } - // Clean + // Clean buttons that.cleanViewActionButton() + + that.initRecordMeta() + that.initHistory() }, // 元数据 initRecordMeta() { - $.get(`/app/entity/record-meta?id=${this.__id}`, (res) => { + $.get(`/app/entity/extras/record-meta?id=${this.__id}`, (res) => { // 如果出错就清空操作区 if (res.error_code !== 0) { $('.view-operating').empty() @@ -500,24 +503,24 @@ const RbViewPage = { for (let k in res.data) { const v = res.data[k] - if (!v) return - const $el = $('.J_' + k) - if ($el.length === 0) return + if (!v) continue + const $el = $(`.J_${k}`) + if ($el.length === 0) continue if (k === 'owningUser') { renderRbcomp( this.clickViewUser(v[0])} />, $el[0]) } else if (k === 'sharingList') { - const list = $('
    ').appendTo('.J_sharingList') - const _this = this + const $list = $('
      ').appendTo($('.J_sharingList').empty()) + const that = this $(v).each(function () { - const $v = this - const item = $('
    • ').appendTo(list) - renderRbcomp( _this.clickViewUser($v[0])} />, item[0]) + const _this = this + const $item = $('
    • ').appendTo($list) + renderRbcomp( that.clickViewUser(_this[0])} />, $item[0]) }) if (this.__ep && this.__ep.S === true) { - const item_op = $('
    • ').appendTo(list)[0] - if (v.length === 0) + const $op = $('
    • ').appendTo($list)[0] + if (v.length === 0) { renderRbcomp( , - item_op + $op ) - else renderRbcomp( DlgShareManager.create(this.__id)} />, item_op) + } else { + renderRbcomp( DlgShareManager.create(this.__id)} />, $op) + } } else if (v.length > 0) { - const item_op = $('
    • ').appendTo(list)[0] - renderRbcomp( DlgShareManager.create(this.__id, false)} />, item_op) + const $op = $('
    • ').appendTo($list)[0] + renderRbcomp( DlgShareManager.create(this.__id, false)} />, $op) } else { $('.J_sharingList').parent().remove() } } else if (k === 'createdOn' || k === 'modifiedOn') { renderRbcomp(, $el[0]) } else { - $('' + v + '').appendTo($el) + $(`${v}`).appendTo($el.empty()) } } @@ -547,6 +552,31 @@ const RbViewPage = { }) }, + // 修改历史 + initHistory() { + const $into = $('.view-history .view-history-items') + if ($into.length === 0) return + + $.get(`/app/entity/extras/record-history?id=${this.__id}`, (res) => { + if (res.error_code !== 0) return + $into.empty() + res.data.forEach((item, idx) => { + const content = $LF('ViewHistoryContent', $fromNow(item.revisionOn)).replace('$USER$', item.revisionBy[1]).replace('$ACTION$', item.revisionType) + const $item = $(`
    • ${content}
    • `).appendTo($into) + $item.find('b:eq(0)').attr('title', item.revisionOn) + if (idx > 9) $item.addClass('hide') + }) + + if (res.data.length > 10) { + $into.after(`${$L('LoadMore')}`) + $('.view-history .J_mores').click(function () { + $into.find('li.hide').removeClass('hide') + $(this).addClass('hide') + }) + } + }) + }, + // 相关项 // 列表 @@ -702,7 +732,6 @@ const RbViewPage = { $(document).ready(function () { if (wpc.entity) { RbViewPage.init(wpc.recordId, wpc.entity, wpc.privileges) - RbViewPage.initRecordMeta() if (wpc.viewTabs) RbViewPage.initVTabs(wpc.viewTabs) if (wpc.viewAdds) RbViewPage.initVAdds(wpc.viewAdds) } diff --git a/src/main/resources/web/general/detail-view.html b/src/main/resources/web/general/detail-view.html index fd50a7d39..d44dca849 100644 --- a/src/main/resources/web/general/detail-view.html +++ b/src/main/resources/web/general/detail-view.html @@ -57,6 +57,12 @@
      +
      +
      +
      [[${bundle.L('ViewHistory')}]]
      +
      +
        +
        diff --git a/src/main/resources/web/general/record-view.html b/src/main/resources/web/general/record-view.html index 9349e7b6f..340b87769 100644 --- a/src/main/resources/web/general/record-view.html +++ b/src/main/resources/web/general/record-view.html @@ -93,6 +93,12 @@
        +
        +
        +
        [[${bundle.L('ViewHistory')}]]
        +
        +
          +