From 8598ed01753f4e1f7a99ed30e74ff6a954cdac66 Mon Sep 17 00:00:00 2001 From: FangfangZhao Date: Thu, 8 Nov 2018 17:54:06 +0800 Subject: [PATCH] advfilter --- .../rebuild/server/query/AdvFilterParser.java | 1 + .../com/rebuild/web/base/MetadataGet.java | 18 ++- src/main/webapp/assets/css/rb-base.css | 3 +- src/main/webapp/assets/css/rb-page.css | 55 ++++--- src/main/webapp/assets/js/rb-advfilter.jsx | 148 ++++++++++++++---- src/main/webapp/me/profile.jsp | 12 -- 6 files changed, 160 insertions(+), 77 deletions(-) delete mode 100644 src/main/webapp/me/profile.jsp diff --git a/src/main/java/com/rebuild/server/query/AdvFilterParser.java b/src/main/java/com/rebuild/server/query/AdvFilterParser.java index 9296d5396..61449fb95 100644 --- a/src/main/java/com/rebuild/server/query/AdvFilterParser.java +++ b/src/main/java/com/rebuild/server/query/AdvFilterParser.java @@ -186,6 +186,7 @@ public class AdvFilterParser { else if ("LK".equalsIgnoreCase(op)) return "like"; else if ("NLK".equalsIgnoreCase(op)) return "not like"; else if ("IN".equalsIgnoreCase(op)) return "in"; + else if ("NIN".equalsIgnoreCase(op)) return "not in"; else if ("BW".equalsIgnoreCase(op)) return "between"; else if ("BFD".equalsIgnoreCase(op)) return "$before_day(%d)"; else if ("BFM".equalsIgnoreCase(op)) return "$before_month(%d)"; diff --git a/src/main/java/com/rebuild/web/base/MetadataGet.java b/src/main/java/com/rebuild/web/base/MetadataGet.java index 2a883baaf..bc4404d97 100644 --- a/src/main/java/com/rebuild/web/base/MetadataGet.java +++ b/src/main/java/com/rebuild/web/base/MetadataGet.java @@ -33,6 +33,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.alibaba.fastjson.JSON; +import com.rebuild.server.entityhub.DisplayType; import com.rebuild.server.entityhub.EasyMeta; import com.rebuild.server.helper.manager.PickListManager; import com.rebuild.server.metadata.MetadataHelper; @@ -70,13 +71,18 @@ public class MetadataGet extends BaseControll { String entity = getParameterNotNull(request, "entity"); Entity entityBase = MetadataHelper.getEntity(entity); - List> list = new ArrayList<>(); - for (Field e : PortalMetaSorter.sortFields(entityBase)) { - Map map = new HashMap<>(); - map.put("name", e.getName()); - EasyMeta easyMeta = new EasyMeta(e); + List> list = new ArrayList<>(); + for (Field field : PortalMetaSorter.sortFields(entityBase)) { + Map map = new HashMap<>(); + map.put("name", field.getName()); + EasyMeta easyMeta = new EasyMeta(field); map.put("label", easyMeta.getLabel()); - map.put("type", easyMeta.getDisplayType(false)); + DisplayType dt = easyMeta.getDisplayType(); + map.put("type", dt.name()); + if (dt == DisplayType.REFERENCE) { + Entity ref = field.getReferenceEntities()[0]; + map.put("ref", new String[] { ref.getName(), EasyMeta.getDisplayType(ref.getNameField()).name() }); + } list.add(map); } writeSuccess(response, list); diff --git a/src/main/webapp/assets/css/rb-base.css b/src/main/webapp/assets/css/rb-base.css index 64b782a85..0bf1e0dbd 100644 --- a/src/main/webapp/assets/css/rb-base.css +++ b/src/main/webapp/assets/css/rb-base.css @@ -18128,10 +18128,11 @@ form.dropzone .dz-preview .dz-error-message { } .select2-container--default .select2-selection--single, .select2-container--default .select2-selection--multiple { height: 37px + min-height: 37px; + font-size: 0; } .select2-container--default .select2-selection--single .select2-selection__rendered, .select2-container--default .select2-selection--multiple .select2-selection__rendered { padding: 0 10px; - height: 37px; line-height: 37px; font-size: 1rem; color: #404040 diff --git a/src/main/webapp/assets/css/rb-page.css b/src/main/webapp/assets/css/rb-page.css index 4a5ccc4f1..779b8d1a6 100644 --- a/src/main/webapp/assets/css/rb-page.css +++ b/src/main/webapp/assets/css/rb-page.css @@ -156,6 +156,13 @@ body.view-body { .select2.select2-container { width: 100%; } +.select2-container--default .select2-selection--multiple .select2-selection__rendered { + line-height: 30px; +} +.select2-container--default .select2-selection--multiple .select2-selection__choice { + margin-top: 4px; + margin-right: 4px; +} textarea.row2x { height: 52px !important; resize: none; @@ -836,31 +843,31 @@ i.split.ui-draggable-dragging { .adv-filter .item .val .val-range>span.end { top: 46px; } -.adv-filter .select2-container--default .select2-selection--single, .adv-filter .select2-container--default .select2-selection--multiple { - height: 34px; -} -.adv-filter .select2-container--default .select2-selection--multiple { - min-height: 34px; -} -.adv-filter .select2-container--default .select2-selection--single .select2-selection__rendered, .adv-filter .select2-container--default .select2-selection--multiple .select2-selection__rendered, .adv-filter .form-control-sm { - height: 34px; - line-height: 34px; - padding-left: 8px; - padding-right: 8px; -} -.adv-filter .form-control-sm { - height: 34px !important; - padding-top: 2px; - padding-bottom: 2px; -} -.adv-filter .select2-container .select2-search--inline .select2-search__field, .adv-filter .select2-container--default .select2-selection--multiple .select2-selection__choice { - margin-top: 3px; -} -.adv-filter .select2-container--default .select2-selection--single .select2-selection__arrow b:after { - line-height: 34px; -} .adv-filter+.adv-filter { border-top: 1px solid #eee; padding-top: 8px; margin-top: 8px; -} \ No newline at end of file +} + +.adv-filter .form-control-sm,.adv-filter .select2-container--default .select2-selection--single .select2-selection__rendered, .adv-filter .select2-container--default .select2-selection--multiple .select2-selection__rendered { + padding-left: 8px; + padding-right: 8px; +} + +/* height = 34px +.adv-filter .select2-container--default .select2-selection--single, .adv-filter .select2-container--default .select2-selection--multiple { + min-height: 34px; +} +.adv-filter .select2-container--default .select2-selection--single .select2-selection__rendered, .adv-filter .select2-container--default .select2-selection--multiple .select2-selection__rendered { + line-height: 34px; + padding: 0 8px; +} +.adv-filter .select2-container--default .select2-selection--single .select2-selection__arrow { + height: 34px; + top: -1px; +} +.adv-filter .form-control-sm { + height: 34px !important; + padding: 3px 8px; +} +*/ \ No newline at end of file diff --git a/src/main/webapp/assets/js/rb-advfilter.jsx b/src/main/webapp/assets/js/rb-advfilter.jsx index f1d2e096c..7253c541a 100644 --- a/src/main/webapp/assets/js/rb-advfilter.jsx +++ b/src/main/webapp/assets/js/rb-advfilter.jsx @@ -5,9 +5,7 @@ class AdvFilter extends React.Component { // TODO parse exists items let items = [] - this.filterItems = {} this.state = { ...props, items: items } - this.childrenRef = [] } render() { @@ -19,7 +17,6 @@ class AdvFilter extends React.Component {
{this.state.items.map((item)=>{ return item - //return React.cloneElement(item, { ref: item.id }) })}
@@ -47,15 +44,18 @@ class AdvFilter extends React.Component { } componentDidMount() { let that = this - $.get(rb.baseUrl + '/commons/metadata/fields?entity=' + this.state.entity, function(res){ + $.get(rb.baseUrl + '/commons/metadata/fields?entity=' + this.props.entity, function(res){ that.fields = res.data.map((item) => { - if (item.type == 'DATETIME') item.type = 'DATE' + if (item.type == 'DATETIME') { + item.type = 'DATE' + } else if (item.type == 'REFERENCE') { + REFFIELD_CACHE[that.props.entity + '.' + item.name] = item.ref + } return item }) }) } onRef = (child) => { - console.log('onRef ... ' + child) this.childrenRef.push(child) } handleChange(event) { @@ -110,29 +110,32 @@ class AdvFilter extends React.Component { } if (hasError){ rb.notice('部分条件设置有误,请检查'); return } - let adv = { items: filters } + let adv = { entity: this.props.entity, items: filters } if (this.state.enableAdvexp == true) adv.equation = this.state.advexp console.log(JSON.stringify(adv)) } } -const OP_TYPE = { LK:'包含', NLK:'不包含', EQ:'等于', NEQ:'不等于', GT:'大于', LT:'小于', BW:'区间', NL:'为空', NT:'不为空', BFD:'...天前', BFM:'...月前', AFD:'...天后', AFM:'...月后' } +const OP_TYPE = { LK:'包含', NLK:'不包含', IN:'包含', NIN:'不包含', EQ:'等于', NEQ:'不等于', GT:'大于', LT:'小于', BW:'区间', NL:'为空', NT:'不为空', BFD:'...天前', BFM:'...月前', AFD:'...天后', AFM:'...月后' } const OP_DATE_NOPICKER = ['BFD','BFM','AFD','AFM'] const PICKLIST_CACHE = {} +const REFFIELD_CACHE = {} class FilterItem extends React.Component { constructor(props) { super(props) this.state = { ...props } console.log(props) + this.__entity = this.props.$$$parent.props.entity - this.handleChange = this.handleChange.bind(this) + this.valueHandle = this.valueHandle.bind(this) + this.valueCheck = this.valueCheck.bind(this) } render() { return (
- {this.state.index} + {this.state.index} this.props.$$$parent.removeItem(this.props.id)}> + let val = if (this.state.op == 'BW'){ val = (
- - + +
) @@ -188,17 +193,36 @@ class FilterItem extends React.Component { return })} ) + } else if (this.isBizzField()){ + val =