| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- import { routerRedux } from 'dva/router'
- import * as service from '../services/index'
- import { delay } from '../utils/baseUtils'
- import URLS from '../constants/url'
- export default {
- namespace: 'chartDesigner',
- state: {
- columns: [{
- label: '编号',
- name: 'ID',
- type: 'index'
- }, {
- label: '姓名',
- name: 'name',
- type: 'string'
- }, {
- label: '出生日期',
- name: 'BIRTH',
- type: 'time'
- }, {
- label: '性别',
- name: 'GENDER',
- type: 'categorical',
- selection: ['男', '女']
- }, {
- label: '部门',
- name: 'DEPARTMENT',
- type: 'categorical',
- selection: ['开发部', '测试部', '实施部']
- }, {
- label: '入职日期',
- name: 'ENTRYDATE',
- type: 'time'
- }, {
- label: '当月工作时数',
- name: 'WORKHOURS',
- type: 'scale'
- }, {
- label: '基本薪资',
- name: 'BASICSALARY',
- type: 'scale'
- }, {
- label: '绩效薪资',
- name: 'PERFORMANCE',
- type: 'scale'
- }, {
- label: '实发薪资',
- name: 'SALARY',
- type: 'scale'
- }],
- allPermission: [
- { value: 'owner', name: '创建人' },
- { value: 'anyone', name: '所有人' }
- ],
- header: {
- label: '标题'
- },
- baseConfig: {
- dataSource: {
- key: '',
- label: ''
- },
- viewType: {
- key: '',
- label: ''
- }
- },
- preparing: {
- groupBy: []
- },
- barConfig: {
- xAxis: {
- column: {},
- granularity: {}
- },
- yAxis: {
- column: {},
- gauge: {}
- }
- },
- aggregateTable: {
- },
- dataView: {
- },
- style: {
- },
- filters: [],
- chartOption: {}
- },
- reducers: {
- setModel(state, action) {
- const { name, value } = action;
- let obj = {};
- obj[name] = value;
- let newState = Object.assign({}, state, obj);
- return newState;
- },
- setChartOption(state, action) {
- const { option } = action;
- let obj = {};
- obj['chartOption'] = option;
- let newState = Object.assign({}, state, obj);
- return newState;
- }
- },
- effects: {
- *['fetchChartData'](action, { select, call, put }) {
- try {
- const chartDesigner = yield select(state => state.present.chartDesigner);
- const { barConfig, preparing } = chartDesigner;
- const res = yield call(service.fetch, {
- url: URLS.CHART_BAR_OPTION,
- body: {
- "tableName": "TEST_BI_DATA",
- "groups": preparing.groupBy.map(g => g.key),
- "xAxis": {
- "columnRename": barConfig.xAxis.column.value,
- "columnType": barConfig.xAxis.column.type,
- "dataType": barConfig.xAxis.granularity.value
- },
- "yAxis": {
- "columnRename": barConfig.yAxis.column.value,
- "dataType": barConfig.yAxis.gauge.value
- }
- }
- });
- console.log({
- "tableName": "TEST_BI_DATA",
- "groups": preparing.groupBy.map(g => g.key),
- "xAxis": {
- "columnRename": barConfig.xAxis.column.value,
- "columnType": barConfig.xAxis.column.type,
- "dataType": barConfig.xAxis.granularity.value
- },
- "yAxis": {
- "columnRename": barConfig.yAxis.column.value,
- "dataType": barConfig.yAxis.gauge.value
- }
- })
-
- res.viewType = 'bar';
- res.data.data.xTitle = barConfig.xAxis?`${barConfig.xAxis.column.label}${barConfig.xAxis.granularity.value?'('+barConfig.xAxis.granularity.label+')':''}`:null
- res.data.data.yTitle = barConfig.yAxis?barConfig.yAxis.column.label:null;
- res.data.data.gauge = barConfig.yAxis?barConfig.yAxis.gauge.label:null;
- yield put({ type: 'setChartOption', option: res });
- }catch(e) {
- yield put({ type: 'setChartOption', option: {} });
- }
- // if(!res.err && res.data.code > 0) {
- // res.viewType = 'bar';
- // res.data.data.xTitle = barConfig.xAxis?`${barConfig.xAxis.column.label}${barConfig.xAxis.granularity.value?'('+barConfig.xAxis.granularity.label+')':''}`:null
- // res.data.data.yTitle = barConfig.yAxis?barConfig.yAxis.column.label:null;
- // res.data.data.gauge = barConfig.yAxis?barConfig.yAxis.gauge.label:null;
- // yield put({ type: 'setChartOption', option: res });
- // }else {
- // yield put({ type: 'setChartOption', option: {} });
- // // 弹出错误提示
- // }
- }
- },
- subscriptions: {
- setup({ dispatch, history }) {
- return history.listen(({ pathname, query }) => {
- if (pathname === '/home') {
- console.log(111);
- dispatch({ type: 'redirect'});
- }
- });
- },
- },
- };
|