Check data of modal lastModified

This commit is contained in:
devezhao 2019-05-06 18:13:40 +08:00
parent bc5b6ed5fd
commit fc2f60acfe
3 changed files with 40 additions and 13 deletions

View file

@ -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("'");

View file

@ -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");

View file

@ -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 {
<div className="message" dangerouslySetInnerHTML={{ __html: '<strong>抱歉!</strong> ' + message }}></div>
</div>
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) => {
})
}