mirror of
https://github.com/getrebuild/rebuild.git
synced 2025-02-25 23:05:06 +08:00
some fix
This commit is contained in:
parent
cb149f53d7
commit
2a91325a2f
13 changed files with 36 additions and 32 deletions
|
@ -76,8 +76,7 @@ public class FieldValueWrapper {
|
|||
return wrapDecimal(value, field);
|
||||
} else if (dt == DisplayType.REFERENCE) {
|
||||
return wrapReference(value, field);
|
||||
} else if (dt == DisplayType.PICKLIST
|
||||
|| dt == DisplayType.IMAGE || dt == DisplayType.FILE || dt == DisplayType.LOCATION) {
|
||||
} else if (dt == DisplayType.PICKLIST || dt == DisplayType.IMAGE || dt == DisplayType.FILE || dt == DisplayType.LOCATION) {
|
||||
// 无需处理
|
||||
return value;
|
||||
} else if (dt == DisplayType.BOOL) {
|
||||
|
|
|
@ -61,14 +61,14 @@ public class RelatedListControll extends BaseControll {
|
|||
|
||||
@RequestMapping("related-list")
|
||||
public void relatedList(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
ID masterId = getIdParameterNotNull(request, "master");
|
||||
ID masterId = getIdParameterNotNull(request, "masterId");
|
||||
String related = getParameterNotNull(request, "related");
|
||||
|
||||
Entity relatedEntity = MetadataHelper.getEntity(related);
|
||||
String sql = genMasterSql(masterId, relatedEntity, false);
|
||||
String sql = buildMasterSql(masterId, relatedEntity, false);
|
||||
|
||||
int pn = NumberUtils.toInt(getParameter(request, "pageNo"), 1);
|
||||
int ps = NumberUtils.toInt(getParameter(request, "pageSize"), 100);
|
||||
int ps = NumberUtils.toInt(getParameter(request, "pageSize"), 200);
|
||||
|
||||
// TODO 相关项列表分页
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class RelatedListControll extends BaseControll {
|
|||
for (Object[] o : array) {
|
||||
o[0] = o[0].toString();
|
||||
o[1] = FieldValueWrapper.wrapFieldValue(o[1], relatedEntity.getNameField());
|
||||
if (StringUtils.EMPTY == o[1]) {
|
||||
if (o[1] == null || StringUtils.isEmpty(o[1].toString())) {
|
||||
o[1] = o[0].toString().toUpperCase(); // 使用ID值作为名称字段值
|
||||
}
|
||||
o[2] = CalendarUtils.getUTCDateTimeFormat().format(o[2]);
|
||||
|
@ -90,12 +90,12 @@ public class RelatedListControll extends BaseControll {
|
|||
|
||||
@RequestMapping("related-counts")
|
||||
public void relatedCounts(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
ID masterId = getIdParameterNotNull(request, "master");
|
||||
String relates[] = getParameterNotNull(request, "relates").split(",");
|
||||
ID masterId = getIdParameterNotNull(request, "masterId");
|
||||
String relates[] = getParameterNotNull(request, "relateds").split(",");
|
||||
|
||||
Map<String, Integer> countMap = new HashMap<>();
|
||||
for (String related : relates) {
|
||||
String sql = genMasterSql(masterId, MetadataHelper.getEntity(related), true);
|
||||
String sql = buildMasterSql(masterId, MetadataHelper.getEntity(related), true);
|
||||
Object[] count = Application.createQuery(sql).unique();
|
||||
countMap.put(related, ObjectUtils.toInt(count[0]));
|
||||
}
|
||||
|
@ -103,13 +103,13 @@ public class RelatedListControll extends BaseControll {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param masterId
|
||||
* @param recordOfMain
|
||||
* @param relatedEntity
|
||||
* @param count
|
||||
* @return
|
||||
*/
|
||||
static String genMasterSql(ID masterId, Entity relatedEntity, boolean count) {
|
||||
Entity masterEntity = MetadataHelper.getEntity(masterId.getEntityCode());
|
||||
private String buildMasterSql(ID recordOfMain, Entity relatedEntity, boolean count) {
|
||||
Entity masterEntity = MetadataHelper.getEntity(recordOfMain.getEntityCode());
|
||||
Set<String> relatedFields = new HashSet<>();
|
||||
for (Field field : relatedEntity.getFields()) {
|
||||
if (field.getType() == FieldType.REFERENCE
|
||||
|
@ -119,7 +119,7 @@ public class RelatedListControll extends BaseControll {
|
|||
}
|
||||
|
||||
String masterSql = "(" + StringUtils.join(relatedFields, " or ") + ")";
|
||||
masterSql = MessageFormat.format(masterSql, masterId);
|
||||
masterSql = MessageFormat.format(masterSql, recordOfMain);
|
||||
|
||||
String baseSql = "select %s from " + relatedEntity.getName() + " where " + masterSql;
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@
|
|||
<entity name="User" type-code="001" description="用户" name-field="fullName">
|
||||
<field name="userId" type="primary" />
|
||||
<field name="loginName" type="string" max-length="100" nullable="false" updatable="false" description="登录名" />
|
||||
<field name="password" type="string" max-length="100" nullable="false" updatable="false" description="登录密码" />
|
||||
<field name="email" type="string" max-length="100" description="邮箱" />
|
||||
<field name="password" type="string" max-length="100" description="登录密码" updatable="false" />
|
||||
<field name="fullName" type="string" max-length="100" description="姓名" />
|
||||
<field name="avatarUrl" type="string" max-length="300" description="头像" />
|
||||
<field name="jobTitle" type="string" max-length="100" description="职务" />
|
||||
<field name="deptId" type="reference" ref-entity="Department" cascade="remove-links" nullable="false" description="所在部门" />
|
||||
<field name="roleId" type="reference" ref-entity="Role" cascade="remove-links" nullable="false" description="角色" />
|
||||
<field name="deptId" type="reference" ref-entity="Department" cascade="remove-links" updatable="false" description="所在部门" />
|
||||
<field name="roleId" type="reference" ref-entity="Role" cascade="remove-links" updatable="false" description="角色" />
|
||||
<field name="isDisabled" type="bool" default-value="F" description="是否停用" />
|
||||
<index type="unique" field-list="loginName" />
|
||||
<index type="unique" field-list="email" />
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div class="input-group input-search">
|
||||
<input class="form-control rounded-left J_search-text" placeholder="搜索 ..." type="text">
|
||||
<span class="input-group-btn"><button class="btn btn-secondary J_search-btn" type="button"><i class="icon zmdi zmdi-search"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-playlist-plus"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-more"></i></button></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<button class="btn btn-secondary J_edit" type="button"><i class="icon zmdi zmdi-border-color"></i> 编辑</button>
|
||||
</div>
|
||||
<div class="col-6 pl-1 mb-2 btn-group J_action">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown"><i class="icon zmdi zmdi-more-vert"></i> 更多</button>
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">更多 <i class="icon zmdi zmdi-more-vert"></i></button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item J_delete"><i class="icon zmdi zmdi-delete"></i> 删除</a>
|
||||
</div>
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<div class="input-group input-search">
|
||||
<input class="form-control rounded-left J_search-text" placeholder="搜索 ..." type="text">
|
||||
<span class="input-group-btn"><button class="btn btn-secondary J_search-btn" type="button"><i class="icon zmdi zmdi-search"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-playlist-plus"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-more"></i></button></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<button class="btn btn-secondary J_edit" type="button"><i class="icon zmdi zmdi-border-color"></i> 编辑</button>
|
||||
</div>
|
||||
<div class="col-6 pl-1 mb-2 btn-group J_action">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown"><i class="icon zmdi zmdi-more-vert"></i> 更多</button>
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">更多 <i class="icon zmdi zmdi-more-vert"></i></button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item J_delete"><i class="icon zmdi zmdi-delete"></i> 删除</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
|
|
|
@ -133,13 +133,16 @@ class RbForm extends React.Component {
|
|||
</div>
|
||||
</div>
|
||||
)
|
||||
//saveBtns = <button className="btn btn-primary btn-space" type="button" onClick={()=>this.post()}>保存</button>
|
||||
|
||||
let _entity = this.state.entity
|
||||
if (_entity == 'User' || _entity == 'Department' || _entity == 'Role' || window.pageType == 'SlaveView'){
|
||||
saveBtns = <button className="btn btn-primary btn-space" type="button" onClick={()=>this.post()}>保存</button>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="form-group row footer">
|
||||
<div className="col-12 col-sm-8 offset-sm-3" ref="rbform-action">
|
||||
{saveBtns}
|
||||
|
||||
<button className="btn btn-secondary btn-space" type="button" onClick={()=>this.props.$$$parent.hide()}>取消</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -202,7 +205,7 @@ class RbForm extends React.Component {
|
|||
let sm = that.props.$$$parent.state.__formModel.slaveMeta
|
||||
rb.RbFormModal({ title: `添加${sm[1]}`, entity: sm[0], icon: sm[2], defaultValues: dv })
|
||||
}
|
||||
if (next == 111 && window.RbViewPage) window.RbViewPage.updateVTabs([_entity])
|
||||
//if (next == 111 && window.RbViewPage) window.RbViewPage.updateVTabs([_entity])
|
||||
|
||||
}else{
|
||||
rb.notice(res.error_msg || '保存失败,请稍后重试', 'danger')
|
||||
|
|
|
@ -159,7 +159,7 @@ const RbViewPage = {
|
|||
ReactDOM.render(<RbSpinner/>, pane[0])
|
||||
that.renderRelatedGrid(pane, _this.attr('href').substr(5))
|
||||
} else {
|
||||
ReactDOM.render(<div className="list-nodata"><span className="zmdi zmdi-info-outline"/><p>没有相关数据</p></div>, pane[0])
|
||||
ReactDOM.render(<div className="list-nodata"><span className="zmdi zmdi-info-outline"/><p>暂无数据</p></div>, pane[0])
|
||||
pane.removeClass('rb-loading-active')
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ const RbViewPage = {
|
|||
updateVTabs(es) {
|
||||
es = es || this.__vtab_es
|
||||
if (!!!es || es.length == 0) return
|
||||
$.get(rb.baseUrl + '/app/entity/related-counts?master=' + this.__id + '&relates=' + es.join(','), function(res){
|
||||
$.get(rb.baseUrl + '/app/entity/related-counts?masterId=' + this.__id + '&relateds=' + es.join(','), function(res){
|
||||
for (let k in res.data) {
|
||||
if (~~res.data[k] > 0) {
|
||||
let tab = $('.nav-tabs a[href="#tab-' + k + '"]')
|
||||
|
@ -189,7 +189,7 @@ const RbViewPage = {
|
|||
|
||||
renderRelatedGrid(el, related, page) {
|
||||
page = page || 1
|
||||
$.get(rb.baseUrl + '/app/entity/related-list?master=' + this.__id + '&related=' + related + '&pageNo=' + page, function(res){
|
||||
$.get(rb.baseUrl + '/app/entity/related-list?masterId=' + this.__id + '&related=' + related + '&pageNo=' + page, function(res){
|
||||
el.removeClass('rb-loading-active')
|
||||
$(res.data.data).each(function(){
|
||||
let h = '#!/View/' + related + '/' + this[0]
|
||||
|
|
|
@ -34,14 +34,14 @@
|
|||
<div class="dropdown-menu rb-scroller">
|
||||
<div class="dropdown-item" data-id="$ALL$"><a>所有数据</a></div>
|
||||
<div class="dropdown-divider"></div>
|
||||
<div class="dropdown-item J_advfilter"><i class="icon zmdi zmdi-plus-circle-o"></i>添加过滤项</div>
|
||||
<div class="dropdown-item J_advfilter"><i class="icon zmdi zmdi-plus"></i>添加过滤项</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group input-search">
|
||||
<input class="form-control rounded-left J_search-text" placeholder="搜索 ..." type="text">
|
||||
<span class="input-group-btn"><button class="btn btn-secondary J_search-btn" type="button"><i class="icon zmdi zmdi-search"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-plus-circle-o"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-more"></i></button></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<button class="btn btn-secondary J_edit" type="button"><i class="icon zmdi zmdi-border-color"></i> 编辑</button>
|
||||
</div>
|
||||
<div class="col-6 btn-group J_mores">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown"><i class="icon zmdi zmdi-more-vert"></i> 更多</button>
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">更多 <i class="icon zmdi zmdi-more-vert"></i></button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item J_delete"><i class="icon zmdi zmdi-delete"></i> 删除</a>
|
||||
<a class="dropdown-item J_assign"><i class="icon zmdi zmdi-mail-reply-all"></i> 分派</a>
|
||||
|
|
|
@ -31,14 +31,14 @@
|
|||
<div class="dropdown-menu rb-scroller">
|
||||
<div class="dropdown-item" data-id="$ALL$"><a>所有数据</a></div>
|
||||
<div class="dropdown-divider"></div>
|
||||
<div class="dropdown-item J_advfilter"><i class="icon zmdi zmdi-playlist-plus"></i>添加过滤项</div>
|
||||
<div class="dropdown-item J_advfilter"><i class="icon zmdi zmdi-plus"></i>添加过滤项</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group input-search">
|
||||
<input class="form-control rounded-left J_search-text" placeholder="搜索 ..." type="text">
|
||||
<span class="input-group-btn"><button class="btn btn-secondary J_search-btn" type="button"><i class="icon zmdi zmdi-search"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-playlist-plus"></i></button></span>
|
||||
<span class="input-group-btn plus"><button class="btn btn-secondary J_qfields" type="button" title="设置查询字段"><i class="icon zmdi zmdi-more"></i></button></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -76,6 +76,7 @@
|
|||
<script src="${baseUrl}/assets/js/rb-advfilter.jsx" type="text/babel"></script>
|
||||
<script src="${baseUrl}/assets/js/assign-share.jsx" type="text/babel"></script>
|
||||
<script type="text/babel">
|
||||
window.pageType = 'SlaveList'
|
||||
$(document).ready(function(){
|
||||
RbListPage.init($.parseJSON('${DataListConfig}'), ['${entityName}','${entityLabel}','${entityIcon}'], $.parseJSON('${entityPrivileges}'))
|
||||
rb.AdvFilter.init('.adv-search', '${entityName}')
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<button class="btn btn-secondary J_edit" type="button"><i class="icon zmdi zmdi-border-color"></i> 编辑</button>
|
||||
</div>
|
||||
<div class="col-6 btn-group J_mores">
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown"><i class="icon zmdi zmdi-more-vert"></i> 更多</button>
|
||||
<button class="btn btn-secondary dropdown-toggle" type="button" data-toggle="dropdown">更多 <i class="icon zmdi zmdi-more-vert"></i></button>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item J_delete"><i class="icon zmdi zmdi-delete"></i> 删除</a>
|
||||
</div>
|
||||
|
@ -59,6 +59,7 @@
|
|||
<script src="${baseUrl}/assets/js/rb-forms.jsx" type="text/babel"></script>
|
||||
<script src="${baseUrl}/assets/js/rb-view.jsx" type="text/babel"></script>
|
||||
<script type="text/babel">
|
||||
window.pageType = 'SlaveView'
|
||||
$(document).ready(function(){
|
||||
RbViewPage.init('${id}', ['${entityName}','${entityLabel}','${entityIcon}'], $.parseJSON('${entityPrivileges}'))
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue