Преглед изворни кода

添加指标看板存在备注字段时的卡片最小高度计算公式(原本是默认的100)

zhuth пре 6 година
родитељ
комит
6c1f61eb4f

+ 10 - 3
src/components/chartDesigner/charts/indicatorView.jsx

@@ -20,6 +20,13 @@ class IndicatorView extends React.Component {
     }
 
     autoLayout = () => {
+        const { chartOption } = this.props;
+        const { data } = chartOption;
+        if(!data || data.length === 0) {
+            return;
+        }
+        let extraRowCount = data[0].others.length;
+        let  cardMinHeight = extraRowCount === 0 ? 100 : (100 + 10 + (extraRowCount-1) * 21);
         let container = this.containerRef;
         if(!container) return;
         let body = container.getElementsByClassName('indicator-body')[0];
@@ -30,14 +37,14 @@ class IndicatorView extends React.Component {
         let maxColNum = cardCount > 4 ? 4 : cardCount; // 列数
         let maxRowNum = Math.ceil(cardCount / maxColNum); // 行数
         let cardHeight = bodyBox.height / maxRowNum - 8;
-        cardHeight = cardHeight < 100 ? 100 : cardHeight;
+        cardHeight = cardHeight < cardMinHeight ? cardMinHeight : cardHeight;
         let inScroll = maxRowNum * (8 + cardHeight) > bodyBox.height;
         let cardWidth = (bodyBox.width - (inScroll ? 12 : 2)) / maxColNum - 8;
         while(cardWidth < 180 && maxColNum > 1) {
             maxColNum--;
             maxRowNum = Math.ceil(cardCount / maxColNum);
             cardHeight = bodyBox.height / maxRowNum - 8;
-            cardHeight = cardHeight < 100 ? 100 : cardHeight;
+            cardHeight = cardHeight < cardMinHeight ? cardMinHeight : cardHeight;
             inScroll = maxRowNum * (8 + cardHeight) > bodyBox.height;
             cardWidth = (bodyBox.width - (inScroll ? 12 : 2)) / maxColNum - 8;
         }
@@ -45,7 +52,7 @@ class IndicatorView extends React.Component {
             maxColNum++;
             maxRowNum = Math.ceil(cardCount / maxColNum);
             cardHeight = bodyBox.height / maxRowNum - 8;
-            cardHeight = cardHeight < 100 ? 100 : cardHeight;
+            cardHeight = cardHeight < cardMinHeight ? cardMinHeight : cardHeight;
             inScroll = maxRowNum * (8 + cardHeight) > bodyBox.height;
             cardWidth = (bodyBox.width - (inScroll ? 12 : 2)) / maxColNum - 8;
         }

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

@@ -127,8 +127,8 @@ const IndicatorConfigForm = ({ autoRefresh, chartDesigner, dispatch }) => {
 					filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
 					allowClear={true}
 					onChange={(value) => {
-						if(value.length > 2) {
-							message.warning('最多支持选择2个备注字段');
+						if(value.length > 4) {
+							message.warning('最多支持选择4个备注字段');
 							return false;
 						}
 						let otherColumn = value.map(v => {