diff --git a/src/main/java/com/rebuild/server/portals/FormsManager.java b/src/main/java/com/rebuild/server/portals/FormsManager.java index 9ceaa7e9a..85710b5e2 100644 --- a/src/main/java/com/rebuild/server/portals/FormsManager.java +++ b/src/main/java/com/rebuild/server/portals/FormsManager.java @@ -278,6 +278,10 @@ public class FormsManager extends BaseLayoutManager { model.put("slaveMeta", EasyMeta.getEntityShows(entityMeta.getSlaveEntity())); } + if (data != null && data.hasValue(EntityHelper.ModifiedOn)) { + model.put("lastModified", data.getDate(EntityHelper.ModifiedOn).getTime()); + } + model.remove("id"); // form's ID of config return model; } @@ -328,7 +332,13 @@ public class FormsManager extends BaseLayoutManager { ajql.append(field).append(','); } - ajql.deleteCharAt(ajql.length() - 1); + + if (entity.containsField(EntityHelper.ModifiedOn)) { + ajql.append(EntityHelper.ModifiedOn); + } else { + ajql.deleteCharAt(ajql.length() - 1); + } + ajql.append(" from ").append(entity.getName()) .append(" where ").append(entity.getPrimaryField().getName()) .append(" = '").append(id).append("'"); diff --git a/src/main/java/com/rebuild/web/base/entity/GeneralEntityRecordControll.java b/src/main/java/com/rebuild/web/base/entity/GeneralEntityRecordControll.java index 95b097620..f5380735d 100644 --- a/src/main/java/com/rebuild/web/base/entity/GeneralEntityRecordControll.java +++ b/src/main/java/com/rebuild/web/base/entity/GeneralEntityRecordControll.java @@ -353,6 +353,21 @@ public class GeneralEntityRecordControll extends BaseControll { writeSuccess(response, ret); } + @RequestMapping("record-lastModified") + public void fetchRecordLastModified(HttpServletRequest request, HttpServletResponse response) throws IOException { + final ID id = getIdParameterNotNull(request, "id"); + 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) { + writeFailure(response, "记录不存在"); + return; + } + writeSuccess(response, ((Date) recordMeta[0]).getTime()); + } + @RequestMapping("shared-list") public void fetchSharedList(HttpServletRequest request, HttpServletResponse response) throws IOException { ID id = getIdParameterNotNull(request, "id"); diff --git a/src/main/webapp/assets/js/rb-forms.jsx b/src/main/webapp/assets/js/rb-forms.jsx index cee9d0c51..d5c36b54c 100644 --- a/src/main/webapp/assets/js/rb-forms.jsx +++ b/src/main/webapp/assets/js/rb-forms.jsx @@ -55,6 +55,7 @@ class RbFormModal extends React.Component { that.setState({ formComponent: FORM, __formModel: res.data }, function () { that.setState({ inLoad: false }) }) + that.__lastModified = res.data.lastModified || 0 }) } renderFromError(message) { @@ -63,31 +64,32 @@ class RbFormModal extends React.Component {