Browse Source

钻取层级设置限制时间类型维度分段不重复

zhuth 6 years ago
parent
commit
9722aad6db

+ 10 - 2
src/components/chartDesigner/sections/drillList.jsx

@@ -5,10 +5,18 @@ import './drillList.less'
 
 const DrillList = ({ className, list, value, onChange }) => {
     let newValue = value.map(v => v);
-    const nOptions = list.filter(l => l.type === 'time' || !value.find(vi => vi.column.value === l.name));
+    let nOptions = list.filter(l => l.type === 'time' || !value.find(vi => vi.column.value === l.name));
+    nOptions = nOptions.map(o => o.type === 'time' ? {
+        ...o,
+        granularityList: value.filter(fv => fv.column.value === o.name).map(mv => mv.granularity.value)
+    } : o);
     return <div className={`drill-list ${className || ''}`}>
         {value.map((v, i) => {
-            const options = list.filter(l => l.type === 'time' || !value.find(vi => vi.column.value !== v.column.value && vi.column.value === l.name));
+            let options = list.filter(l => l.type === 'time' || !value.find(vi => vi.column.value !== v.column.value && vi.column.value === l.name));
+            options = options.map(o => o.type === 'time' ? {
+                ...o,
+                granularityList: value.filter(fv => fv.column.value === o.name && fv.granularity.value !== v.granularity.value).map(mv => mv.granularity.value)
+            } : o);
             return <Row key={i}>
                 <Col span={20}>
                     <XAxisItem value={v} allowClear={false} disabled={i === 0} options={options} onChange={v => {

+ 2 - 2
src/components/chartDesigner/sections/xAxisItem.jsx

@@ -35,9 +35,9 @@ const XAxisItem = ({ value: _propsValue, allowClear, disabled, options, onChange
                 type: c.type,
                 value: c.name,
                 label: c.label,
-                children: GRANULARITY[c.type]
+                children: GRANULARITY[c.type].filter(g => !!c.granularityList ? (c.granularityList.indexOf(g.value) === -1) : true)
             }
-        })}
+        }).filter(o => o.type !== 'time' || o.children.length > 0)}
         onChange={(value, items) => {
             let column = {};
             let granularity = {};