mirror of
https://github.com/getrebuild/rebuild.git
synced 2024-09-20 15:35:55 +08:00
Check data of modal lastModified
This commit is contained in:
parent
bc5b6ed5fd
commit
fc2f60acfe
|
@ -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("'");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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) => {
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue