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 {
抱歉! ' + message }}>
- let that = this - that.setState({ formComponent: error }, function () { - that.setState({ inLoad: false }) + this.setState({ formComponent: error }, () => { + this.setState({ inLoad: false }) }) } show(state) { state = state || {} - let that = this if ((state.id !== this.state.id || state.entity !== this.state.entity) || this.state.isDestroy === true) { state = { ...state, isDestroy: true, formComponent: null, inLoad: true, id: state.id, entity: state.entity } - this.setState(state, function () { - that.showAfter({ ...state, isDestroy: false }, true) + this.setState(state, () => { + this.showAfter({ ...state, isDestroy: false }, true) }) } else { this.showAfter({ ...state, isDestroy: false }) + this.checkDrityData() } } showAfter(state, modelChanged) { - let that = this - this.setState(state, function () { - $(that.refs['rbmodal']).modal({ show: true, backdrop: 'static' }) - if (modelChanged === true) { - that.getFormModel() - } + this.setState(state, () => { + $(this.refs['rbmodal']).modal({ show: true, backdrop: 'static' }) + if (modelChanged === true) this.getFormModel() + }) + } + checkDrityData() { + if (!this.__lastModified || !this.state.id) return + $.get(`${rb.baseUrl}/app/entity/record-lastModified?id=${this.state.id}`, (res) => { }) }