Browse Source

筛选框类别添加“包含”、“包括“逻辑

zhuth 7 years ago
parent
commit
1c47d33bbc

+ 1 - 0
src/components/chartDesigner/sections/toolbar.less

@@ -18,6 +18,7 @@
                 text-overflow: ellipsis;
                 border-style: dashed;
                 margin: 6px 2px 0 2px;
+                white-space: nowrap;
             }
             .filter-tag-using {
                 border-style: solid;

+ 32 - 14
src/components/common/filterBox/filterBox.jsx

@@ -222,20 +222,38 @@ class FilterBox extends React.Component {
             field = <InputNumber onBlur={(e) => {this.changeFilterValue(filter, e.target.value, index)}}/>
         }else if(type === 'time') {
             field = <DatePicker onChange={(value) => {this.changeFilterValue(filter, value, index)}}/>
-        }else if(type === 'categorical') {
-            field = (<Select 
-                mode={(operator==='contain' || operator === 'notContain' ) ? 'multiple' : 'single'}
-                showSearch
-                dropdownMatchSelectWidth={false}
-                notFoundContent={fetching ? <Spin size="small" /> : '无'}
-                onSearch={(value) => {this.fetchColumnData(column, value, true)}}
-                onFocus={() => {this.fetchColumnData(column)}}
-                onChange={(value) => {this.changeFilterValue(filter, value, index)}}
-            >
-                { columnData.map((s, i) => {
-                    return <SelectOption key={i} value={s}>{s}</SelectOption>
-                }) }
-            </Select>)
+        }else if(type === 'categorical') { // 类别
+            if(operator === 'include' || operator==='notInclude') { // 包含/不包含
+                field = <Input onBlur={(e) => {this.changeFilterValue(filter, e.target.value, index)}}/>
+            }else if(operator === 'contain' || operator === 'notContain') { // 包括/不包括
+                field = (<Select 
+                    mode='multiple'
+                    showSearch
+                    dropdownMatchSelectWidth={false}
+                    notFoundContent={fetching ? <Spin size="small" /> : '无'}
+                    onSearch={(value) => {this.fetchColumnData(column, value, true)}}
+                    onFocus={() => {this.fetchColumnData(column)}}
+                    onChange={(value) => {this.changeFilterValue(filter, value, index)}}
+                >
+                    { columnData.map((s, i) => {
+                        return <SelectOption key={i} value={s}>{s}</SelectOption>
+                    }) }
+                </Select>)
+            }else { // 等于/不等于
+                field = (<Select 
+                    mode='single'
+                    showSearch
+                    dropdownMatchSelectWidth={false}
+                    notFoundContent={fetching ? <Spin size="small" /> : '无'}
+                    onSearch={(value) => {this.fetchColumnData(column, value, true)}}
+                    onFocus={() => {this.fetchColumnData(column)}}
+                    onChange={(value) => {this.changeFilterValue(filter, value, index)}}
+                >
+                    { columnData.map((s, i) => {
+                        return <SelectOption key={i} value={s}>{s}</SelectOption>
+                    }) }
+                </Select>)
+            }
         }else {
             field = <Input onBlur={(e) => {this.changeFilterValue(filter, e.target.value, index)}}/> 
         }

+ 10 - 4
src/components/common/filterBox/filterOperators.js

@@ -1,9 +1,9 @@
 export default {
     index: [{
-        value: "contain",
+        value: "include",
         label: "包含"
     }, {
-        value: "notContain",
+        value: "notInclude",
         label: "不包含"
     }, {
         value: "startsWith",
@@ -25,10 +25,10 @@ export default {
         label: "不为空"
     }],
     string: [{
-        value: "contain",
+        value: "include",
         label: "包含"
     }, {
-        value: "notContain",
+        value: "notInclude",
         label: "不包含"
     }, {
         value: "startsWith",
@@ -101,12 +101,18 @@ export default {
         label: "等于"
     }, {
         value: "contain",
+        label: "包括"
+    }, {
+        value: "include",
         label: "包含"
     }, {
         value: "<>",
         label: "不等于"
     }, {
         value: "notContain",
+        label: "不包括"
+    }, {
+        value: "notInclude",
         label: "不包含"
     }, {
         value: "null",

+ 8 - 6
src/components/common/login/relogin.jsx

@@ -90,16 +90,18 @@ class Relogin extends React.Component {
                 <Checkbox defaultChecked={autoLogin} onChange={this.onRemanberChange}>记住密码</Checkbox>
             </div>
             <div className="relogin-item buttons">
-                <Button disabled={fetching} type="primary" onClick={() => {
-                    dispatch({ type: 'main/logout' });
-                }}>
-                    切换用户
-                </Button>
-                <Button disabled={fetching} type="primary" onClick={this.onLogin} style={{ marginLeft: '16px' }}>
+                <Button disabled={fetching} type="primary" onClick={this.onLogin}>
                     {fetching && <Icon type="loading" theme="outlined" />}
                     重新登录
                 </Button>
             </div>
+            <div>
+                <a style={{ textDecoration: 'underline' }} onClick={() => {
+                    dispatch({ type: 'main/logout' });
+                }}>
+                    切换用户
+                </a>
+            </div>
         </Modal>
     }
 }