zhuth 7 years ago
parent
commit
d4eabf3b24

+ 23 - 9
src/components/chartDesigner/sections/dataViewConfigForm.jsx

@@ -1,26 +1,34 @@
 import React from 'react'
-import { Form, Select } from 'antd'
+import { Form, Select, InputNumber  } from 'antd'
 import { connect } from 'dva'
-import '../../../models/chartDesigner'
 const FormItem = Form.Item
 const { Option } = Select
 
 class DataViewConfigForm extends React.Component {
 	render() {
-		const props = this.props;
-        const columns = props.chartDesigner.columns;
-		const { formItemLayout } = props
+		const { dispatch, chartDesigner, formItemLayout } = this.props;
+		const columns = chartDesigner.columns;
         
 		return (
             <Form layout='horizontal'>
 				<FormItem label='分析目标' {...formItemLayout}>
 					<Select
-						key='hf'
+						value={chartDesigner.dataViewConfig.targetColumn}
+						onChange={(value) => {
+							dispatch({ type: 'chartDesigner/changeField', name: 'dataViewConfig', value: { ...chartDesigner.dataViewConfig, targetColumn: value }});
+						}}
+					>
+						{columns.filter(c => c.type === 'scale').map((c, i)=>{
+							return <Option key={i} value={c.name}>{c.label}</Option>
+						})}
+					</Select>
+				</FormItem>
+				<FormItem label="展示列" {...formItemLayout}>
+					<Select
 						mode='multiple'
-						value={props.chartDesigner.dataViewConfig.targetColumn}
-						labelInValue={true}
+						value={chartDesigner.dataViewConfig.viewColumns}
 						onChange={(value) => {
-							props.dispatch({ type: 'chartDesigner/changeField', name: 'dataViewConfig', value: { ...props.chartDesigner.dataViewConfig, targetColumn: value }});
+							dispatch({ type: 'chartDesigner/changeField', name: 'dataViewConfig', value: { ...chartDesigner.dataViewConfig, viewColumns: value }});
 						}}
 					>
 						{columns.map((c, i)=>{
@@ -28,6 +36,12 @@ class DataViewConfigForm extends React.Component {
 						})}
 					</Select>
 				</FormItem>
+				<FormItem label='最大显示行数' {...formItemLayout}>
+					<InputNumber min={1} precision={0} value={chartDesigner.dataViewConfig.maxRows} onChange={(e) => {
+						console.log(e);
+					}}>
+					</InputNumber >
+				</FormItem>
 			</Form>
         );
 	}

+ 2 - 1
src/components/chartDesigner/sections/filterBox.jsx

@@ -159,7 +159,8 @@ class FilterBox extends React.Component {
     }
 
     getFilterValueField = (key, type, operator, index) => {
-        let field = <Input />, { columns } = this.state;
+        const { columns } = this.state;
+        let field;
         const { form } = this.props;
         const filters = form.getFieldValue('filters');
         let filter = filters.filter((f) => {return f.key === key})[0];

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

@@ -51,6 +51,7 @@ class Toolbar extends React.Component {
     createFilterLabel = (filter) => {
         let { label, operator, operatorLabel, type, value1, value2 } = filter;
         let filterLabel;
+
         if(type === 'string' || type === 'index') {
             if(operator === 'null') {
                 filterLabel = `${label} ${operatorLabel}`;

+ 3 - 1
src/constants/url.js

@@ -49,7 +49,9 @@ const URLS = {
 
     CHART_LINE_OPTION: BASE_URL + '/showLine', // 请求折线图展示数据
 
-    CHART_SCATTER_OPTION: BASE_URL + '/showScatter', // 请求散点图展示四数据
+    CHART_SCATTER_OPTION: BASE_URL + '/showScatter', // 请求散点图展示数据
+
+    CHART_DATAVIEW_OPTION: BASE_URL + 'showIndividual', // 请求个体统计数据
 
     /***************************************分组***************************************/
 

+ 20 - 0
src/models/chartDesigner.js

@@ -278,6 +278,8 @@ export default {
                 yield put({ type: 'fetchLineData' });
             }else if(viewType === 'scatter') {
                 yield put({ type: 'fetchScatterData' })
+            }else if(viewType === 'dataView') {
+                yield put({ type: 'fetchDataViewData' });
             }else {
                 console.log('nothing.......')
             }
@@ -420,6 +422,24 @@ export default {
                 yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
             }
         },
+        *fetchDataViewData(action, { select, call, put }) {
+            try {
+                const chartDesigner = yield select(state => state.present.chartDesigner);
+                const { code, dataViewConfig } = chartDesigner;
+                const body = {
+                    id: code,
+                    columnName: dataViewConfig.targetColumn,
+                    columnListName: dataViewConfig.viewColumns,
+                    sort: "desc",
+                    showLine: dataViewConfig.maxRows,
+                    operation: ''
+                };
+                console.log(body);return;
+            }catch(e) {
+                console.error(e);
+                yield put({ type: 'silentSetField', name: 'chartOption', value: {} });
+            }
+        },
     },
     subscriptions: {
         setup({ dispatch, history }) {