|
@@ -1,5 +1,8 @@
|
|
|
import { routerRedux } from 'dva/router'
|
|
import { routerRedux } from 'dva/router'
|
|
|
import { message } from 'antd'
|
|
import { message } from 'antd'
|
|
|
|
|
+import * as service from '../services/index'
|
|
|
|
|
+import URLS from '../constants/url'
|
|
|
|
|
+
|
|
|
|
|
|
|
|
const code = window.localStorage.getItem('usercode');
|
|
const code = window.localStorage.getItem('usercode');
|
|
|
const account = window.localStorage.getItem('account');
|
|
const account = window.localStorage.getItem('account');
|
|
@@ -19,6 +22,8 @@ export default {
|
|
|
role,
|
|
role,
|
|
|
},
|
|
},
|
|
|
currentPage: '',
|
|
currentPage: '',
|
|
|
|
|
+ recentChart: [],
|
|
|
|
|
+ recentDashboard: []
|
|
|
},
|
|
},
|
|
|
reducers: {
|
|
reducers: {
|
|
|
setPage(state, action) {
|
|
setPage(state, action) {
|
|
@@ -37,6 +42,14 @@ export default {
|
|
|
setAuthenticated(state, action) {
|
|
setAuthenticated(state, action) {
|
|
|
const { authenticated } = action;
|
|
const { authenticated } = action;
|
|
|
return { ...state, authenticated };
|
|
return { ...state, authenticated };
|
|
|
|
|
+ },
|
|
|
|
|
+ listRecentChart(state, action) {
|
|
|
|
|
+ const { recentChart } = action;
|
|
|
|
|
+ return { ...state, recentChart };
|
|
|
|
|
+ },
|
|
|
|
|
+ listRecentDashboard(state, action) {
|
|
|
|
|
+ const { recentDashboard } = action;
|
|
|
|
|
+ return { ...state, recentDashboard };
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
effects: {
|
|
effects: {
|
|
@@ -76,6 +89,93 @@ export default {
|
|
|
console.log(e);
|
|
console.log(e);
|
|
|
message.error('注销失败: ' + e);
|
|
message.error('注销失败: ' + e);
|
|
|
}
|
|
}
|
|
|
|
|
+ },
|
|
|
|
|
+ *fetchRecentChart(action, { select, call, put }) {
|
|
|
|
|
+ const body = {};
|
|
|
|
|
+ try {
|
|
|
|
|
+ const main = yield select(state => state.present.main);
|
|
|
|
|
+ if(!action.mandatory && main.recentChart.length > 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = yield call(service.fetch, {
|
|
|
|
|
+ url: URLS.HOMEPAGE_RECENT_CHART_GET,
|
|
|
|
|
+ body
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ console.log('请求最近访问图表', body, res);
|
|
|
|
|
+ if(!res.err && res.data.code > 0) {
|
|
|
|
|
+ let recentChart = res.data.data.map((r, i) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ key: r.chartId,
|
|
|
|
|
+ code: r.chartId,
|
|
|
|
|
+ name: r.chartName,
|
|
|
|
|
+ type: r.chartType,
|
|
|
|
|
+ createBy: r.createBy,
|
|
|
|
|
+ chartOption: r.chartOption,
|
|
|
|
|
+ description: r.describes || "",
|
|
|
|
|
+ createTime: r.createDate,
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ yield put({ type: 'listRecentChart', recentChart });
|
|
|
|
|
+ }else {
|
|
|
|
|
+ message.error('读取最近访问图表列表错误: ' + (res.err || res.data.msg));
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch(e) {
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ message.error('读取最近访问图表列表错误: ' + e);
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ *fetchRecentDashboard(action, { select, call, put }) {
|
|
|
|
|
+ const body = {};
|
|
|
|
|
+ try {
|
|
|
|
|
+ const main = yield select(state => state.present.main);
|
|
|
|
|
+ if(!action.mandatory && main.recentDashboard.length > 0) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ const res = yield call(service.fetch, {
|
|
|
|
|
+ url: URLS.HOMEPAGE_RECENT_DASHBOARD_GET,
|
|
|
|
|
+ body
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log('请求最近访问看板', body, res);
|
|
|
|
|
+ if(!res.err && res.data.code > 0) {
|
|
|
|
|
+ let recentDashboard = res.data.data.map((r, i) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ key: r.id,
|
|
|
|
|
+ code: r.id,
|
|
|
|
|
+ name: r.bdName,
|
|
|
|
|
+ thumbnail: r.thumbnail,
|
|
|
|
|
+ createBy: r.createBy,
|
|
|
|
|
+ description: r.bdNote || ""
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ yield put({ type: 'listRecentDashboard', recentDashboard });
|
|
|
|
|
+ }else {
|
|
|
|
|
+ message.error('读取最近访问看板列表错误: ' + (res.err || res.data.msg));
|
|
|
|
|
+ }
|
|
|
|
|
+ }catch(e) {
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ message.error('读取最近访问看板列表错误: ' + e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ },
|
|
|
|
|
+ *addRecentRecord(action, { call }) {
|
|
|
|
|
+ const { tarId, recordType } = action
|
|
|
|
|
+ console.log(tarId, recordType)
|
|
|
|
|
+ try {
|
|
|
|
|
+ const res = yield call(service.fetch, {
|
|
|
|
|
+ url: URLS.HOMEPAGE_ADD_RECENT_RECORD,
|
|
|
|
|
+ body: {
|
|
|
|
|
+ tarId: tarId,
|
|
|
|
|
+ type: recordType
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log("添加访问记录: " + res + tarId, recordType)
|
|
|
|
|
+ }catch(e) {
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+ message.error('添加访问记录错误: ' + e);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
subscriptions: {
|
|
subscriptions: {
|