正在显示
23 个修改的文件
包含
1928 行增加
和
0 行删除
ant-design-pro/Analysis/.gitignore
0 → 100644
ant-design-pro/Analysis/.umirc.js
0 → 100644
| 1 | +import React, { PureComponent } from 'react'; | |
| 2 | +import { connect } from 'dva'; | |
| 3 | +import styles from './GridContent.less'; | |
| 4 | + | |
| 5 | +class GridContent extends PureComponent { | |
| 6 | + render() { | |
| 7 | + const { contentWidth, children } = this.props; | |
| 8 | + let className = `${styles.main}`; | |
| 9 | + if (contentWidth === 'Fixed') { | |
| 10 | + className = `${styles.main} ${styles.wide}`; | |
| 11 | + } | |
| 12 | + return <div className={className}>{children}</div>; | |
| 13 | + } | |
| 14 | +} | |
| 15 | + | |
| 16 | +export default connect(({ setting }) => ({ | |
| 17 | + contentWidth: setting.contentWidth, | |
| 18 | +}))(GridContent); | ... | ... |
| 1 | +import React from 'react'; | |
| 2 | +import { Spin } from 'antd'; | |
| 3 | + | |
| 4 | +// loading components from code split | |
| 5 | +// https://umijs.org/plugin/umi-plugin-react.html#dynamicimport | |
| 6 | +export default () => ( | |
| 7 | + <div style={{ paddingTop: 100, textAlign: 'center' }}> | |
| 8 | + <Spin size="large" /> | |
| 9 | + </div> | |
| 10 | +); | ... | ... |
ant-design-pro/Analysis/@/services/api.js
0 → 100644
| 1 | +import { stringify } from 'qs'; | |
| 2 | +import request from '@/utils/request'; | |
| 3 | + | |
| 4 | +export async function queryProjectNotice() { | |
| 5 | + return request('/api/project/notice'); | |
| 6 | +} | |
| 7 | + | |
| 8 | +export async function queryActivities() { | |
| 9 | + return request('/api/activities'); | |
| 10 | +} | |
| 11 | + | |
| 12 | +export async function queryRule(params) { | |
| 13 | + return request(`/api/rule?${stringify(params)}`); | |
| 14 | +} | |
| 15 | + | |
| 16 | +export async function removeRule(params) { | |
| 17 | + return request('/api/rule', { | |
| 18 | + method: 'POST', | |
| 19 | + body: { | |
| 20 | + ...params, | |
| 21 | + method: 'delete', | |
| 22 | + }, | |
| 23 | + }); | |
| 24 | +} | |
| 25 | + | |
| 26 | +export async function addRule(params) { | |
| 27 | + return request('/api/rule', { | |
| 28 | + method: 'POST', | |
| 29 | + body: { | |
| 30 | + ...params, | |
| 31 | + method: 'post', | |
| 32 | + }, | |
| 33 | + }); | |
| 34 | +} | |
| 35 | + | |
| 36 | +export async function updateRule(params) { | |
| 37 | + return request('/api/rule', { | |
| 38 | + method: 'POST', | |
| 39 | + body: { | |
| 40 | + ...params, | |
| 41 | + method: 'update', | |
| 42 | + }, | |
| 43 | + }); | |
| 44 | +} | |
| 45 | + | |
| 46 | +export async function fakeSubmitForm(params) { | |
| 47 | + return request('/api/forms', { | |
| 48 | + method: 'POST', | |
| 49 | + body: params, | |
| 50 | + }); | |
| 51 | +} | |
| 52 | + | |
| 53 | +export async function fakeChartData() { | |
| 54 | + return request('/api/fake_chart_data'); | |
| 55 | +} | |
| 56 | + | |
| 57 | +export async function queryTags() { | |
| 58 | + return request('/api/tags'); | |
| 59 | +} | |
| 60 | + | |
| 61 | +export async function queryBasicProfile() { | |
| 62 | + return request('/api/profile/basic'); | |
| 63 | +} | |
| 64 | + | |
| 65 | +export async function queryAdvancedProfile() { | |
| 66 | + return request('/api/profile/advanced'); | |
| 67 | +} | |
| 68 | + | |
| 69 | +export async function queryFakeList(params) { | |
| 70 | + return request(`/api/fake_list?${stringify(params)}`); | |
| 71 | +} | |
| 72 | + | |
| 73 | +export async function removeFakeList(params) { | |
| 74 | + const { count = 5, ...restParams } = params; | |
| 75 | + return request(`/api/fake_list?count=${count}`, { | |
| 76 | + method: 'POST', | |
| 77 | + body: { | |
| 78 | + ...restParams, | |
| 79 | + method: 'delete', | |
| 80 | + }, | |
| 81 | + }); | |
| 82 | +} | |
| 83 | + | |
| 84 | +export async function addFakeList(params) { | |
| 85 | + const { count = 5, ...restParams } = params; | |
| 86 | + return request(`/api/fake_list?count=${count}`, { | |
| 87 | + method: 'POST', | |
| 88 | + body: { | |
| 89 | + ...restParams, | |
| 90 | + method: 'post', | |
| 91 | + }, | |
| 92 | + }); | |
| 93 | +} | |
| 94 | + | |
| 95 | +export async function updateFakeList(params) { | |
| 96 | + const { count = 5, ...restParams } = params; | |
| 97 | + return request(`/api/fake_list?count=${count}`, { | |
| 98 | + method: 'POST', | |
| 99 | + body: { | |
| 100 | + ...restParams, | |
| 101 | + method: 'update', | |
| 102 | + }, | |
| 103 | + }); | |
| 104 | +} | |
| 105 | + | |
| 106 | +export async function fakeAccountLogin(params) { | |
| 107 | + return request('/api/login/account', { | |
| 108 | + method: 'POST', | |
| 109 | + body: params, | |
| 110 | + }); | |
| 111 | +} | |
| 112 | + | |
| 113 | +export async function fakeRegister(params) { | |
| 114 | + return request('/api/register', { | |
| 115 | + method: 'POST', | |
| 116 | + body: params, | |
| 117 | + }); | |
| 118 | +} | |
| 119 | + | |
| 120 | +export async function queryNotices() { | |
| 121 | + return request('/api/notices'); | |
| 122 | +} | |
| 123 | + | |
| 124 | +export async function getFakeCaptcha(mobile) { | |
| 125 | + return request(`/api/captcha?mobile=${mobile}`); | |
| 126 | +} | ... | ... |
ant-design-pro/Analysis/@/utils/Yuan.js
0 → 100644
| 1 | +import React from 'react'; | |
| 2 | +import { yuan } from 'ant-design-pro/lib/Charts'; | |
| 3 | +/** | |
| 4 | + * 减少使用 dangerouslySetInnerHTML | |
| 5 | + */ | |
| 6 | +export default class Yuan extends React.PureComponent { | |
| 7 | + componentDidMount() { | |
| 8 | + this.rendertoHtml(); | |
| 9 | + } | |
| 10 | + | |
| 11 | + componentDidUpdate() { | |
| 12 | + this.rendertoHtml(); | |
| 13 | + } | |
| 14 | + | |
| 15 | + rendertoHtml = () => { | |
| 16 | + const { children } = this.props; | |
| 17 | + if (this.main) { | |
| 18 | + this.main.innerHTML = yuan(children); | |
| 19 | + } | |
| 20 | + }; | |
| 21 | + | |
| 22 | + render() { | |
| 23 | + return ( | |
| 24 | + <span | |
| 25 | + ref={ref => { | |
| 26 | + this.main = ref; | |
| 27 | + }} | |
| 28 | + /> | |
| 29 | + ); | |
| 30 | + } | |
| 31 | +} | ... | ... |
ant-design-pro/Analysis/@/utils/request.js
0 → 100644
| 1 | +import fetch from 'dva/fetch'; | |
| 2 | +import { notification } from 'antd'; | |
| 3 | +import router from 'umi/router'; | |
| 4 | +import hash from 'hash.js'; | |
| 5 | +import { isAntdPro } from './utils'; | |
| 6 | + | |
| 7 | +const codeMessage = { | |
| 8 | + 200: '服务器成功返回请求的数据。', | |
| 9 | + 201: '新建或修改数据成功。', | |
| 10 | + 202: '一个请求已经进入后台排队(异步任务)。', | |
| 11 | + 204: '删除数据成功。', | |
| 12 | + 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。', | |
| 13 | + 401: '用户没有权限(令牌、用户名、密码错误)。', | |
| 14 | + 403: '用户得到授权,但是访问是被禁止的。', | |
| 15 | + 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。', | |
| 16 | + 406: '请求的格式不可得。', | |
| 17 | + 410: '请求的资源被永久删除,且不会再得到的。', | |
| 18 | + 422: '当创建一个对象时,发生一个验证错误。', | |
| 19 | + 500: '服务器发生错误,请检查服务器。', | |
| 20 | + 502: '网关错误。', | |
| 21 | + 503: '服务不可用,服务器暂时过载或维护。', | |
| 22 | + 504: '网关超时。', | |
| 23 | +}; | |
| 24 | + | |
| 25 | +const checkStatus = response => { | |
| 26 | + if (response.status >= 200 && response.status < 300) { | |
| 27 | + return response; | |
| 28 | + } | |
| 29 | + const errortext = codeMessage[response.status] || response.statusText; | |
| 30 | + notification.error({ | |
| 31 | + message: `请求错误 ${response.status}: ${response.url}`, | |
| 32 | + description: errortext, | |
| 33 | + }); | |
| 34 | + const error = new Error(errortext); | |
| 35 | + error.name = response.status; | |
| 36 | + error.response = response; | |
| 37 | + throw error; | |
| 38 | +}; | |
| 39 | + | |
| 40 | +const cachedSave = (response, hashcode) => { | |
| 41 | + /** | |
| 42 | + * Clone a response data and store it in sessionStorage | |
| 43 | + * Does not support data other than json, Cache only json | |
| 44 | + */ | |
| 45 | + const contentType = response.headers.get('Content-Type'); | |
| 46 | + if (contentType && contentType.match(/application\/json/i)) { | |
| 47 | + // All data is saved as text | |
| 48 | + response | |
| 49 | + .clone() | |
| 50 | + .text() | |
| 51 | + .then(content => { | |
| 52 | + sessionStorage.setItem(hashcode, content); | |
| 53 | + sessionStorage.setItem(`${hashcode}:timestamp`, Date.now()); | |
| 54 | + }); | |
| 55 | + } | |
| 56 | + return response; | |
| 57 | +}; | |
| 58 | + | |
| 59 | +/** | |
| 60 | + * Requests a URL, returning a promise. | |
| 61 | + * | |
| 62 | + * @param {string} url The URL we want to request | |
| 63 | + * @param {object} [option] The options we want to pass to "fetch" | |
| 64 | + * @return {object} An object containing either "data" or "err" | |
| 65 | + */ | |
| 66 | +export default function request(url, option) { | |
| 67 | + const options = { | |
| 68 | + expirys: isAntdPro(), | |
| 69 | + ...option, | |
| 70 | + }; | |
| 71 | + /** | |
| 72 | + * Produce fingerprints based on url and parameters | |
| 73 | + * Maybe url has the same parameters | |
| 74 | + */ | |
| 75 | + const fingerprint = url + (options.body ? JSON.stringify(options.body) : ''); | |
| 76 | + const hashcode = hash | |
| 77 | + .sha256() | |
| 78 | + .update(fingerprint) | |
| 79 | + .digest('hex'); | |
| 80 | + | |
| 81 | + const defaultOptions = { | |
| 82 | + credentials: 'include', | |
| 83 | + }; | |
| 84 | + const newOptions = { ...defaultOptions, ...options }; | |
| 85 | + if ( | |
| 86 | + newOptions.method === 'POST' || | |
| 87 | + newOptions.method === 'PUT' || | |
| 88 | + newOptions.method === 'DELETE' | |
| 89 | + ) { | |
| 90 | + if (!(newOptions.body instanceof FormData)) { | |
| 91 | + newOptions.headers = { | |
| 92 | + Accept: 'application/json', | |
| 93 | + 'Content-Type': 'application/json; charset=utf-8', | |
| 94 | + ...newOptions.headers, | |
| 95 | + }; | |
| 96 | + newOptions.body = JSON.stringify(newOptions.body); | |
| 97 | + } else { | |
| 98 | + // newOptions.body is FormData | |
| 99 | + newOptions.headers = { | |
| 100 | + Accept: 'application/json', | |
| 101 | + ...newOptions.headers, | |
| 102 | + }; | |
| 103 | + } | |
| 104 | + } | |
| 105 | + | |
| 106 | + const expirys = options.expirys && 60; | |
| 107 | + // options.expirys !== false, return the cache, | |
| 108 | + if (options.expirys !== false) { | |
| 109 | + const cached = sessionStorage.getItem(hashcode); | |
| 110 | + const whenCached = sessionStorage.getItem(`${hashcode}:timestamp`); | |
| 111 | + if (cached !== null && whenCached !== null) { | |
| 112 | + const age = (Date.now() - whenCached) / 1000; | |
| 113 | + if (age < expirys) { | |
| 114 | + const response = new Response(new Blob([cached])); | |
| 115 | + return response.json(); | |
| 116 | + } | |
| 117 | + sessionStorage.removeItem(hashcode); | |
| 118 | + sessionStorage.removeItem(`${hashcode}:timestamp`); | |
| 119 | + } | |
| 120 | + } | |
| 121 | + return fetch(url, newOptions) | |
| 122 | + .then(checkStatus) | |
| 123 | + .then(response => cachedSave(response, hashcode)) | |
| 124 | + .then(response => { | |
| 125 | + // DELETE and 204 do not return data by default | |
| 126 | + // using .json will report an error. | |
| 127 | + if (newOptions.method === 'DELETE' || response.status === 204) { | |
| 128 | + return response.text(); | |
| 129 | + } | |
| 130 | + return response.json(); | |
| 131 | + }) | |
| 132 | + .catch(e => { | |
| 133 | + const status = e.name; | |
| 134 | + if (status === 401) { | |
| 135 | + // @HACK | |
| 136 | + /* eslint-disable no-underscore-dangle */ | |
| 137 | + window.g_app._store.dispatch({ | |
| 138 | + type: 'login/logout', | |
| 139 | + }); | |
| 140 | + return; | |
| 141 | + } | |
| 142 | + // environment should not be used | |
| 143 | + if (status === 403) { | |
| 144 | + router.push('/exception/403'); | |
| 145 | + return; | |
| 146 | + } | |
| 147 | + if (status <= 504 && status >= 500) { | |
| 148 | + router.push('/exception/500'); | |
| 149 | + return; | |
| 150 | + } | |
| 151 | + if (status >= 404 && status < 422) { | |
| 152 | + router.push('/exception/404'); | |
| 153 | + } | |
| 154 | + }); | |
| 155 | +} | ... | ... |
ant-design-pro/Analysis/@/utils/utils.js
0 → 100644
| 1 | +import moment from 'moment'; | |
| 2 | +import React from 'react'; | |
| 3 | +import nzh from 'nzh/cn'; | |
| 4 | +import { parse, stringify } from 'qs'; | |
| 5 | + | |
| 6 | +export function fixedZero(val) { | |
| 7 | + return val * 1 < 10 ? `0${val}` : val; | |
| 8 | +} | |
| 9 | + | |
| 10 | +export function getTimeDistance(type) { | |
| 11 | + const now = new Date(); | |
| 12 | + const oneDay = 1000 * 60 * 60 * 24; | |
| 13 | + | |
| 14 | + if (type === 'today') { | |
| 15 | + now.setHours(0); | |
| 16 | + now.setMinutes(0); | |
| 17 | + now.setSeconds(0); | |
| 18 | + return [moment(now), moment(now.getTime() + (oneDay - 1000))]; | |
| 19 | + } | |
| 20 | + | |
| 21 | + if (type === 'week') { | |
| 22 | + let day = now.getDay(); | |
| 23 | + now.setHours(0); | |
| 24 | + now.setMinutes(0); | |
| 25 | + now.setSeconds(0); | |
| 26 | + | |
| 27 | + if (day === 0) { | |
| 28 | + day = 6; | |
| 29 | + } else { | |
| 30 | + day -= 1; | |
| 31 | + } | |
| 32 | + | |
| 33 | + const beginTime = now.getTime() - day * oneDay; | |
| 34 | + | |
| 35 | + return [moment(beginTime), moment(beginTime + (7 * oneDay - 1000))]; | |
| 36 | + } | |
| 37 | + | |
| 38 | + if (type === 'month') { | |
| 39 | + const year = now.getFullYear(); | |
| 40 | + const month = now.getMonth(); | |
| 41 | + const nextDate = moment(now).add(1, 'months'); | |
| 42 | + const nextYear = nextDate.year(); | |
| 43 | + const nextMonth = nextDate.month(); | |
| 44 | + | |
| 45 | + return [ | |
| 46 | + moment(`${year}-${fixedZero(month + 1)}-01 00:00:00`), | |
| 47 | + moment(moment(`${nextYear}-${fixedZero(nextMonth + 1)}-01 00:00:00`).valueOf() - 1000), | |
| 48 | + ]; | |
| 49 | + } | |
| 50 | + | |
| 51 | + const year = now.getFullYear(); | |
| 52 | + return [moment(`${year}-01-01 00:00:00`), moment(`${year}-12-31 23:59:59`)]; | |
| 53 | +} | |
| 54 | + | |
| 55 | +export function getPlainNode(nodeList, parentPath = '') { | |
| 56 | + const arr = []; | |
| 57 | + nodeList.forEach(node => { | |
| 58 | + const item = node; | |
| 59 | + item.path = `${parentPath}/${item.path || ''}`.replace(/\/+/g, '/'); | |
| 60 | + item.exact = true; | |
| 61 | + if (item.children && !item.component) { | |
| 62 | + arr.push(...getPlainNode(item.children, item.path)); | |
| 63 | + } else { | |
| 64 | + if (item.children && item.component) { | |
| 65 | + item.exact = false; | |
| 66 | + } | |
| 67 | + arr.push(item); | |
| 68 | + } | |
| 69 | + }); | |
| 70 | + return arr; | |
| 71 | +} | |
| 72 | + | |
| 73 | +export function digitUppercase(n) { | |
| 74 | + return nzh.toMoney(n); | |
| 75 | +} | |
| 76 | + | |
| 77 | +function getRelation(str1, str2) { | |
| 78 | + if (str1 === str2) { | |
| 79 | + console.warn('Two path are equal!'); // eslint-disable-line | |
| 80 | + } | |
| 81 | + const arr1 = str1.split('/'); | |
| 82 | + const arr2 = str2.split('/'); | |
| 83 | + if (arr2.every((item, index) => item === arr1[index])) { | |
| 84 | + return 1; | |
| 85 | + } | |
| 86 | + if (arr1.every((item, index) => item === arr2[index])) { | |
| 87 | + return 2; | |
| 88 | + } | |
| 89 | + return 3; | |
| 90 | +} | |
| 91 | + | |
| 92 | +function getRenderArr(routes) { | |
| 93 | + let renderArr = []; | |
| 94 | + renderArr.push(routes[0]); | |
| 95 | + for (let i = 1; i < routes.length; i += 1) { | |
| 96 | + // 去重 | |
| 97 | + renderArr = renderArr.filter(item => getRelation(item, routes[i]) !== 1); | |
| 98 | + // 是否包含 | |
| 99 | + const isAdd = renderArr.every(item => getRelation(item, routes[i]) === 3); | |
| 100 | + if (isAdd) { | |
| 101 | + renderArr.push(routes[i]); | |
| 102 | + } | |
| 103 | + } | |
| 104 | + return renderArr; | |
| 105 | +} | |
| 106 | + | |
| 107 | +/** | |
| 108 | + * Get router routing configuration | |
| 109 | + * { path:{name,...param}}=>Array<{name,path ...param}> | |
| 110 | + * @param {string} path | |
| 111 | + * @param {routerData} routerData | |
| 112 | + */ | |
| 113 | +export function getRoutes(path, routerData) { | |
| 114 | + let routes = Object.keys(routerData).filter( | |
| 115 | + routePath => routePath.indexOf(path) === 0 && routePath !== path | |
| 116 | + ); | |
| 117 | + // Replace path to '' eg. path='user' /user/name => name | |
| 118 | + routes = routes.map(item => item.replace(path, '')); | |
| 119 | + // Get the route to be rendered to remove the deep rendering | |
| 120 | + const renderArr = getRenderArr(routes); | |
| 121 | + // Conversion and stitching parameters | |
| 122 | + const renderRoutes = renderArr.map(item => { | |
| 123 | + const exact = !routes.some(route => route !== item && getRelation(route, item) === 1); | |
| 124 | + return { | |
| 125 | + exact, | |
| 126 | + ...routerData[`${path}${item}`], | |
| 127 | + key: `${path}${item}`, | |
| 128 | + path: `${path}${item}`, | |
| 129 | + }; | |
| 130 | + }); | |
| 131 | + return renderRoutes; | |
| 132 | +} | |
| 133 | + | |
| 134 | +export function getPageQuery() { | |
| 135 | + return parse(window.location.href.split('?')[1]); | |
| 136 | +} | |
| 137 | + | |
| 138 | +export function getQueryPath(path = '', query = {}) { | |
| 139 | + const search = stringify(query); | |
| 140 | + if (search.length) { | |
| 141 | + return `${path}?${search}`; | |
| 142 | + } | |
| 143 | + return path; | |
| 144 | +} | |
| 145 | + | |
| 146 | +/* eslint no-useless-escape:0 */ | |
| 147 | +const reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/; | |
| 148 | + | |
| 149 | +export function isUrl(path) { | |
| 150 | + return reg.test(path); | |
| 151 | +} | |
| 152 | + | |
| 153 | +export function formatWan(val) { | |
| 154 | + const v = val * 1; | |
| 155 | + if (!v || Number.isNaN(v)) return ''; | |
| 156 | + | |
| 157 | + let result = val; | |
| 158 | + if (val > 10000) { | |
| 159 | + result = Math.floor(val / 10000); | |
| 160 | + result = ( | |
| 161 | + <span> | |
| 162 | + {result} | |
| 163 | + <span | |
| 164 | + style={{ | |
| 165 | + position: 'relative', | |
| 166 | + top: -2, | |
| 167 | + fontSize: 14, | |
| 168 | + fontStyle: 'normal', | |
| 169 | + marginLeft: 2, | |
| 170 | + }} | |
| 171 | + > | |
| 172 | + 万 | |
| 173 | + </span> | |
| 174 | + </span> | |
| 175 | + ); | |
| 176 | + } | |
| 177 | + return result; | |
| 178 | +} | |
| 179 | + | |
| 180 | +// 给官方演示站点用,用于关闭真实开发环境不需要使用的特性 | |
| 181 | +export function isAntdPro() { | |
| 182 | + return window.location.hostname === 'preview.pro.ant.design'; | |
| 183 | +} | ... | ... |
ant-design-pro/Analysis/@/utils/utils.less
0 → 100644
| 1 | +.textOverflow() { | |
| 2 | + overflow: hidden; | |
| 3 | + text-overflow: ellipsis; | |
| 4 | + word-break: break-all; | |
| 5 | + white-space: nowrap; | |
| 6 | +} | |
| 7 | + | |
| 8 | +.textOverflowMulti(@line: 3, @bg: #fff) { | |
| 9 | + overflow: hidden; | |
| 10 | + position: relative; | |
| 11 | + line-height: 1.5em; | |
| 12 | + max-height: @line * 1.5em; | |
| 13 | + text-align: justify; | |
| 14 | + margin-right: -1em; | |
| 15 | + padding-right: 1em; | |
| 16 | + &:before { | |
| 17 | + background: @bg; | |
| 18 | + content: '...'; | |
| 19 | + padding: 0 1px; | |
| 20 | + position: absolute; | |
| 21 | + right: 14px; | |
| 22 | + bottom: 0; | |
| 23 | + } | |
| 24 | + &:after { | |
| 25 | + background: white; | |
| 26 | + content: ''; | |
| 27 | + margin-top: 0.2em; | |
| 28 | + position: absolute; | |
| 29 | + right: 14px; | |
| 30 | + width: 1em; | |
| 31 | + height: 1em; | |
| 32 | + } | |
| 33 | +} | |
| 34 | + | |
| 35 | +// mixins for clearfix | |
| 36 | +// ------------------------ | |
| 37 | +.clearfix() { | |
| 38 | + zoom: 1; | |
| 39 | + &:before, | |
| 40 | + &:after { | |
| 41 | + content: ' '; | |
| 42 | + display: table; | |
| 43 | + } | |
| 44 | + &:after { | |
| 45 | + clear: both; | |
| 46 | + visibility: hidden; | |
| 47 | + font-size: 0; | |
| 48 | + height: 0; | |
| 49 | + } | |
| 50 | +} | ... | ... |
ant-design-pro/Analysis/README.md
0 → 100644
ant-design-pro/Analysis/package.json
0 → 100644
| 1 | +{ | |
| 2 | + "name": "@umi-block/analysis", | |
| 3 | + "version": "0.0.1", | |
| 4 | + "description": "Analysis", | |
| 5 | + "main": "src/index.js", | |
| 6 | + "scripts": { | |
| 7 | + "dev": "umi dev" | |
| 8 | + }, | |
| 9 | + "repository": { | |
| 10 | + "type": "git", | |
| 11 | + "url": "https://github.com/umijs/umi-blocks/analysis" | |
| 12 | + }, | |
| 13 | + "dependencies": { | |
| 14 | + "react": "^16.6.3", | |
| 15 | + "dva": "^2.4.0", | |
| 16 | + "antd": "^3.10.9", | |
| 17 | + "moment": "^2.22.2", | |
| 18 | + "nzh": "^1.0.3", | |
| 19 | + "qs": "^6.6.0", | |
| 20 | + "ant-design-pro": "^2.1.1", | |
| 21 | + "numeral": "^2.0.6", | |
| 22 | + "hash.js": "^1.1.5" | |
| 23 | + }, | |
| 24 | + "devDependencies": { | |
| 25 | + "umi": "^2.3.0-beta.1", | |
| 26 | + "umi-plugin-react": "^1.3.0-beta.1", | |
| 27 | + "umi-plugin-block-dev": "^1.0.0" | |
| 28 | + }, | |
| 29 | + "license": "ISC" | |
| 30 | +} | ... | ... |
ant-design-pro/Analysis/src/Analysis.less
0 → 100644
| 1 | +@import '~antd/lib/style/themes/default.less'; | |
| 2 | +@import '~@/utils/utils.less'; | |
| 3 | + | |
| 4 | +.iconGroup { | |
| 5 | + i { | |
| 6 | + transition: color 0.32s; | |
| 7 | + color: @text-color-secondary; | |
| 8 | + cursor: pointer; | |
| 9 | + margin-left: 16px; | |
| 10 | + &:hover { | |
| 11 | + color: @text-color; | |
| 12 | + } | |
| 13 | + } | |
| 14 | +} | |
| 15 | + | |
| 16 | +.rankingList { | |
| 17 | + margin: 25px 0 0; | |
| 18 | + padding: 0; | |
| 19 | + list-style: none; | |
| 20 | + li { | |
| 21 | + .clearfix(); | |
| 22 | + margin-top: 16px; | |
| 23 | + display: flex; | |
| 24 | + align-items: center; | |
| 25 | + span { | |
| 26 | + color: @text-color; | |
| 27 | + font-size: 14px; | |
| 28 | + line-height: 22px; | |
| 29 | + } | |
| 30 | + .rankingItemNumber { | |
| 31 | + background-color: @background-color-base; | |
| 32 | + border-radius: 20px; | |
| 33 | + display: inline-block; | |
| 34 | + font-size: 12px; | |
| 35 | + font-weight: 600; | |
| 36 | + margin-right: 16px; | |
| 37 | + height: 20px; | |
| 38 | + line-height: 20px; | |
| 39 | + width: 20px; | |
| 40 | + text-align: center; | |
| 41 | + margin-top: 1.5px; | |
| 42 | + &.active { | |
| 43 | + background-color: #314659; | |
| 44 | + color: #fff; | |
| 45 | + } | |
| 46 | + } | |
| 47 | + .rankingItemTitle { | |
| 48 | + flex: 1; | |
| 49 | + white-space: nowrap; | |
| 50 | + text-overflow: ellipsis; | |
| 51 | + overflow: hidden; | |
| 52 | + margin-right: 8px; | |
| 53 | + } | |
| 54 | + } | |
| 55 | +} | |
| 56 | + | |
| 57 | +.salesExtra { | |
| 58 | + display: inline-block; | |
| 59 | + margin-right: 24px; | |
| 60 | + a { | |
| 61 | + color: @text-color; | |
| 62 | + margin-left: 24px; | |
| 63 | + &:hover { | |
| 64 | + color: @primary-color; | |
| 65 | + } | |
| 66 | + &.currentDate { | |
| 67 | + color: @primary-color; | |
| 68 | + } | |
| 69 | + } | |
| 70 | +} | |
| 71 | + | |
| 72 | +.salesCard { | |
| 73 | + .salesBar { | |
| 74 | + padding: 0 0 32px 32px; | |
| 75 | + } | |
| 76 | + .salesRank { | |
| 77 | + padding: 0 32px 32px 72px; | |
| 78 | + } | |
| 79 | + :global { | |
| 80 | + .ant-tabs-bar { | |
| 81 | + padding-left: 16px; | |
| 82 | + .ant-tabs-nav .ant-tabs-tab { | |
| 83 | + padding-top: 16px; | |
| 84 | + padding-bottom: 14px; | |
| 85 | + line-height: 24px; | |
| 86 | + } | |
| 87 | + } | |
| 88 | + .ant-tabs-extra-content { | |
| 89 | + padding-right: 24px; | |
| 90 | + line-height: 55px; | |
| 91 | + } | |
| 92 | + .ant-card-head { | |
| 93 | + position: relative; | |
| 94 | + } | |
| 95 | + .ant-card-head-title { | |
| 96 | + align-items: normal; | |
| 97 | + } | |
| 98 | + } | |
| 99 | +} | |
| 100 | + | |
| 101 | +.salesCardExtra { | |
| 102 | + height: inherit; | |
| 103 | +} | |
| 104 | + | |
| 105 | +.salesTypeRadio { | |
| 106 | + position: absolute; | |
| 107 | + right: 54px; | |
| 108 | + bottom: 12px; | |
| 109 | +} | |
| 110 | + | |
| 111 | +.offlineCard { | |
| 112 | + :global { | |
| 113 | + .ant-tabs-ink-bar { | |
| 114 | + bottom: auto; | |
| 115 | + } | |
| 116 | + .ant-tabs-bar { | |
| 117 | + border-bottom: none; | |
| 118 | + } | |
| 119 | + .ant-tabs-nav-container-scrolling { | |
| 120 | + padding-left: 40px; | |
| 121 | + padding-right: 40px; | |
| 122 | + } | |
| 123 | + .ant-tabs-tab-prev-icon:before { | |
| 124 | + position: relative; | |
| 125 | + left: 6px; | |
| 126 | + } | |
| 127 | + .ant-tabs-tab-next-icon:before { | |
| 128 | + position: relative; | |
| 129 | + right: 6px; | |
| 130 | + } | |
| 131 | + .ant-tabs-tab-active h4 { | |
| 132 | + color: @primary-color; | |
| 133 | + } | |
| 134 | + } | |
| 135 | +} | |
| 136 | + | |
| 137 | +.trendText { | |
| 138 | + margin-left: 8px; | |
| 139 | + color: @heading-color; | |
| 140 | +} | |
| 141 | + | |
| 142 | +@media screen and (max-width: @screen-lg) { | |
| 143 | + .salesExtra { | |
| 144 | + display: none; | |
| 145 | + } | |
| 146 | + | |
| 147 | + .rankingList { | |
| 148 | + li { | |
| 149 | + span:first-child { | |
| 150 | + margin-right: 8px; | |
| 151 | + } | |
| 152 | + } | |
| 153 | + } | |
| 154 | +} | |
| 155 | + | |
| 156 | +@media screen and (max-width: @screen-md) { | |
| 157 | + .rankingTitle { | |
| 158 | + margin-top: 16px; | |
| 159 | + } | |
| 160 | + | |
| 161 | + .salesCard .salesBar { | |
| 162 | + padding: 16px; | |
| 163 | + } | |
| 164 | +} | |
| 165 | + | |
| 166 | +@media screen and (max-width: @screen-sm) { | |
| 167 | + .salesExtraWrap { | |
| 168 | + display: none; | |
| 169 | + } | |
| 170 | + | |
| 171 | + .salesCard { | |
| 172 | + :global { | |
| 173 | + .ant-tabs-content { | |
| 174 | + padding-top: 30px; | |
| 175 | + } | |
| 176 | + } | |
| 177 | + } | |
| 178 | +} | ... | ... |
ant-design-pro/Analysis/src/IntroduceRow.js
0 → 100755
| 1 | +import React, { memo } from 'react'; | |
| 2 | +import { Row, Col, Icon, Tooltip } from 'antd'; | |
| 3 | +import { FormattedMessage } from 'umi/locale'; | |
| 4 | +import styles from './Analysis.less'; | |
| 5 | +import { ChartCard, MiniArea, MiniBar, MiniProgress, Field } from 'ant-design-pro/lib/Charts'; | |
| 6 | +import Trend from 'ant-design-pro/lib/Trend'; | |
| 7 | +import numeral from 'numeral'; | |
| 8 | +import Yuan from '@/utils/Yuan'; | |
| 9 | + | |
| 10 | +const topColResponsiveProps = { | |
| 11 | + xs: 24, | |
| 12 | + sm: 12, | |
| 13 | + md: 12, | |
| 14 | + lg: 12, | |
| 15 | + xl: 6, | |
| 16 | + style: { marginBottom: 24 }, | |
| 17 | +}; | |
| 18 | + | |
| 19 | +const IntroduceRow = memo(({ loading, visitData }) => ( | |
| 20 | + <Row gutter={24}> | |
| 21 | + <Col {...topColResponsiveProps}> | |
| 22 | + <ChartCard | |
| 23 | + bordered={false} | |
| 24 | + title={<FormattedMessage id="app.analysis.total-sales" defaultMessage="Total Sales" />} | |
| 25 | + action={ | |
| 26 | + <Tooltip | |
| 27 | + title={<FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />} | |
| 28 | + > | |
| 29 | + <Icon type="info-circle-o" /> | |
| 30 | + </Tooltip> | |
| 31 | + } | |
| 32 | + loading={loading} | |
| 33 | + total={() => <Yuan>126560</Yuan>} | |
| 34 | + footer={ | |
| 35 | + <Field | |
| 36 | + label={<FormattedMessage id="app.analysis.day-sales" defaultMessage="Daily Sales" />} | |
| 37 | + value={`¥${numeral(12423).format('0,0')}`} | |
| 38 | + /> | |
| 39 | + } | |
| 40 | + contentHeight={46} | |
| 41 | + > | |
| 42 | + <Trend flag="up" style={{ marginRight: 16 }}> | |
| 43 | + <FormattedMessage id="app.analysis.week" defaultMessage="Weekly Changes" /> | |
| 44 | + <span className={styles.trendText}>12%</span> | |
| 45 | + </Trend> | |
| 46 | + <Trend flag="down"> | |
| 47 | + <FormattedMessage id="app.analysis.day" defaultMessage="Daily Changes" /> | |
| 48 | + <span className={styles.trendText}>11%</span> | |
| 49 | + </Trend> | |
| 50 | + </ChartCard> | |
| 51 | + </Col> | |
| 52 | + | |
| 53 | + <Col {...topColResponsiveProps}> | |
| 54 | + <ChartCard | |
| 55 | + bordered={false} | |
| 56 | + loading={loading} | |
| 57 | + title={<FormattedMessage id="app.analysis.visits" defaultMessage="Visits" />} | |
| 58 | + action={ | |
| 59 | + <Tooltip | |
| 60 | + title={<FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />} | |
| 61 | + > | |
| 62 | + <Icon type="info-circle-o" /> | |
| 63 | + </Tooltip> | |
| 64 | + } | |
| 65 | + total={numeral(8846).format('0,0')} | |
| 66 | + footer={ | |
| 67 | + <Field | |
| 68 | + label={<FormattedMessage id="app.analysis.day-visits" defaultMessage="Daily Visits" />} | |
| 69 | + value={numeral(1234).format('0,0')} | |
| 70 | + /> | |
| 71 | + } | |
| 72 | + contentHeight={46} | |
| 73 | + > | |
| 74 | + <MiniArea color="#975FE4" data={visitData} /> | |
| 75 | + </ChartCard> | |
| 76 | + </Col> | |
| 77 | + <Col {...topColResponsiveProps}> | |
| 78 | + <ChartCard | |
| 79 | + bordered={false} | |
| 80 | + loading={loading} | |
| 81 | + title={<FormattedMessage id="app.analysis.payments" defaultMessage="Payments" />} | |
| 82 | + action={ | |
| 83 | + <Tooltip | |
| 84 | + title={<FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />} | |
| 85 | + > | |
| 86 | + <Icon type="info-circle-o" /> | |
| 87 | + </Tooltip> | |
| 88 | + } | |
| 89 | + total={numeral(6560).format('0,0')} | |
| 90 | + footer={ | |
| 91 | + <Field | |
| 92 | + label={ | |
| 93 | + <FormattedMessage | |
| 94 | + id="app.analysis.conversion-rate" | |
| 95 | + defaultMessage="Conversion Rate" | |
| 96 | + /> | |
| 97 | + } | |
| 98 | + value="60%" | |
| 99 | + /> | |
| 100 | + } | |
| 101 | + contentHeight={46} | |
| 102 | + > | |
| 103 | + <MiniBar data={visitData} /> | |
| 104 | + </ChartCard> | |
| 105 | + </Col> | |
| 106 | + <Col {...topColResponsiveProps}> | |
| 107 | + <ChartCard | |
| 108 | + loading={loading} | |
| 109 | + bordered={false} | |
| 110 | + title={ | |
| 111 | + <FormattedMessage | |
| 112 | + id="app.analysis.operational-effect" | |
| 113 | + defaultMessage="Operational Effect" | |
| 114 | + /> | |
| 115 | + } | |
| 116 | + action={ | |
| 117 | + <Tooltip | |
| 118 | + title={<FormattedMessage id="app.analysis.introduce" defaultMessage="Introduce" />} | |
| 119 | + > | |
| 120 | + <Icon type="info-circle-o" /> | |
| 121 | + </Tooltip> | |
| 122 | + } | |
| 123 | + total="78%" | |
| 124 | + footer={ | |
| 125 | + <div style={{ whiteSpace: 'nowrap', overflow: 'hidden' }}> | |
| 126 | + <Trend flag="up" style={{ marginRight: 16 }}> | |
| 127 | + <FormattedMessage id="app.analysis.week" defaultMessage="Weekly Changes" /> | |
| 128 | + <span className={styles.trendText}>12%</span> | |
| 129 | + </Trend> | |
| 130 | + <Trend flag="down"> | |
| 131 | + <FormattedMessage id="app.analysis.day" defaultMessage="Weekly Changes" /> | |
| 132 | + <span className={styles.trendText}>11%</span> | |
| 133 | + </Trend> | |
| 134 | + </div> | |
| 135 | + } | |
| 136 | + contentHeight={46} | |
| 137 | + > | |
| 138 | + <MiniProgress percent={78} strokeWidth={8} target={80} color="#13C2C2" /> | |
| 139 | + </ChartCard> | |
| 140 | + </Col> | |
| 141 | + </Row> | |
| 142 | +)); | |
| 143 | + | |
| 144 | +export default IntroduceRow; | ... | ... |
ant-design-pro/Analysis/src/OfflineData.js
0 → 100755
| 1 | +import React, { memo } from 'react'; | |
| 2 | +import { Card, Tabs, Row, Col } from 'antd'; | |
| 3 | +import { formatMessage, FormattedMessage } from 'umi/locale'; | |
| 4 | +import { TimelineChart, Pie } from 'ant-design-pro/lib/Charts'; | |
| 5 | +import NumberInfo from 'ant-design-pro/lib/NumberInfo'; | |
| 6 | +import styles from './Analysis.less'; | |
| 7 | + | |
| 8 | +const CustomTab = ({ data, currentTabKey: currentKey }) => ( | |
| 9 | + <Row gutter={8} style={{ width: 138, margin: '8px 0' }}> | |
| 10 | + <Col span={12}> | |
| 11 | + <NumberInfo | |
| 12 | + title={data.name} | |
| 13 | + subTitle={ | |
| 14 | + <FormattedMessage id="app.analysis.conversion-rate" defaultMessage="Conversion Rate" /> | |
| 15 | + } | |
| 16 | + gap={2} | |
| 17 | + total={`${data.cvr * 100}%`} | |
| 18 | + theme={currentKey !== data.name && 'light'} | |
| 19 | + /> | |
| 20 | + </Col> | |
| 21 | + <Col span={12} style={{ paddingTop: 36 }}> | |
| 22 | + <Pie | |
| 23 | + animate={false} | |
| 24 | + color={currentKey !== data.name && '#BDE4FF'} | |
| 25 | + inner={0.55} | |
| 26 | + tooltip={false} | |
| 27 | + margin={[0, 0, 0, 0]} | |
| 28 | + percent={data.cvr * 100} | |
| 29 | + height={64} | |
| 30 | + /> | |
| 31 | + </Col> | |
| 32 | + </Row> | |
| 33 | +); | |
| 34 | + | |
| 35 | +const { TabPane } = Tabs; | |
| 36 | + | |
| 37 | +const OfflineData = memo( | |
| 38 | + ({ activeKey, loading, offlineData, offlineChartData, handleTabChange }) => ( | |
| 39 | + <Card | |
| 40 | + loading={loading} | |
| 41 | + className={styles.offlineCard} | |
| 42 | + bordered={false} | |
| 43 | + style={{ marginTop: 32 }} | |
| 44 | + > | |
| 45 | + <Tabs activeKey={activeKey} onChange={handleTabChange}> | |
| 46 | + {offlineData.map(shop => ( | |
| 47 | + <TabPane tab={<CustomTab data={shop} currentTabKey={activeKey} />} key={shop.name}> | |
| 48 | + <div style={{ padding: '0 24px' }}> | |
| 49 | + <TimelineChart | |
| 50 | + height={400} | |
| 51 | + data={offlineChartData} | |
| 52 | + titleMap={{ | |
| 53 | + y1: formatMessage({ id: 'app.analysis.traffic' }), | |
| 54 | + y2: formatMessage({ id: 'app.analysis.payments' }), | |
| 55 | + }} | |
| 56 | + /> | |
| 57 | + </div> | |
| 58 | + </TabPane> | |
| 59 | + ))} | |
| 60 | + </Tabs> | |
| 61 | + </Card> | |
| 62 | + ) | |
| 63 | +); | |
| 64 | + | |
| 65 | +export default OfflineData; | ... | ... |
| 1 | +import React, { memo } from 'react'; | |
| 2 | +import { Card, Radio } from 'antd'; | |
| 3 | +import { FormattedMessage } from 'umi/locale'; | |
| 4 | +import styles from './Analysis.less'; | |
| 5 | +import { Pie } from 'ant-design-pro/lib/Charts'; | |
| 6 | +import Yuan from '@/utils/Yuan'; | |
| 7 | + | |
| 8 | +const ProportionSales = memo( | |
| 9 | + ({ dropdownGroup, salesType, loading, salesPieData, handleChangeSalesType }) => ( | |
| 10 | + <Card | |
| 11 | + loading={loading} | |
| 12 | + className={styles.salesCard} | |
| 13 | + bordered={false} | |
| 14 | + title={ | |
| 15 | + <FormattedMessage | |
| 16 | + id="app.analysis.the-proportion-of-sales" | |
| 17 | + defaultMessage="The Proportion of Sales" | |
| 18 | + /> | |
| 19 | + } | |
| 20 | + bodyStyle={{ padding: 24 }} | |
| 21 | + extra={ | |
| 22 | + <div className={styles.salesCardExtra}> | |
| 23 | + {dropdownGroup} | |
| 24 | + <div className={styles.salesTypeRadio}> | |
| 25 | + <Radio.Group value={salesType} onChange={handleChangeSalesType}> | |
| 26 | + <Radio.Button value="all"> | |
| 27 | + <FormattedMessage id="app.analysis.channel.all" defaultMessage="ALL" /> | |
| 28 | + </Radio.Button> | |
| 29 | + <Radio.Button value="online"> | |
| 30 | + <FormattedMessage id="app.analysis.channel.online" defaultMessage="Online" /> | |
| 31 | + </Radio.Button> | |
| 32 | + <Radio.Button value="stores"> | |
| 33 | + <FormattedMessage id="app.analysis.channel.stores" defaultMessage="Stores" /> | |
| 34 | + </Radio.Button> | |
| 35 | + </Radio.Group> | |
| 36 | + </div> | |
| 37 | + </div> | |
| 38 | + } | |
| 39 | + style={{ marginTop: 24 }} | |
| 40 | + > | |
| 41 | + <div | |
| 42 | + style={{ | |
| 43 | + minHeight: 380, | |
| 44 | + }} | |
| 45 | + > | |
| 46 | + <h4 style={{ marginTop: 8, marginBottom: 32 }}> | |
| 47 | + <FormattedMessage id="app.analysis.sales" defaultMessage="Sales" /> | |
| 48 | + </h4> | |
| 49 | + <Pie | |
| 50 | + hasLegend | |
| 51 | + subTitle={<FormattedMessage id="app.analysis.sales" defaultMessage="Sales" />} | |
| 52 | + total={() => <Yuan>{salesPieData.reduce((pre, now) => now.y + pre, 0)}</Yuan>} | |
| 53 | + data={salesPieData} | |
| 54 | + valueFormat={value => <Yuan>{value}</Yuan>} | |
| 55 | + height={248} | |
| 56 | + lineWidth={4} | |
| 57 | + /> | |
| 58 | + </div> | |
| 59 | + </Card> | |
| 60 | + ) | |
| 61 | +); | |
| 62 | + | |
| 63 | +export default ProportionSales; | ... | ... |
ant-design-pro/Analysis/src/SalesCard.js
0 → 100755
| 1 | +import React, { memo } from 'react'; | |
| 2 | +import { Row, Col, Card, Tabs, DatePicker } from 'antd'; | |
| 3 | +import { FormattedMessage, formatMessage } from 'umi/locale'; | |
| 4 | +import numeral from 'numeral'; | |
| 5 | +import { Bar } from 'ant-design-pro/lib/Charts'; | |
| 6 | +import styles from './Analysis.less'; | |
| 7 | + | |
| 8 | +const { RangePicker } = DatePicker; | |
| 9 | +const { TabPane } = Tabs; | |
| 10 | + | |
| 11 | +const rankingListData = []; | |
| 12 | +for (let i = 0; i < 7; i += 1) { | |
| 13 | + rankingListData.push({ | |
| 14 | + title: formatMessage({ id: 'app.analysis.test' }, { no: i }), | |
| 15 | + total: 323234, | |
| 16 | + }); | |
| 17 | +} | |
| 18 | + | |
| 19 | +const SalesCard = memo( | |
| 20 | + ({ rangePickerValue, salesData, isActive, handleRangePickerChange, loading, selectDate }) => ( | |
| 21 | + <Card loading={loading} bordered={false} bodyStyle={{ padding: 0 }}> | |
| 22 | + <div className={styles.salesCard}> | |
| 23 | + <Tabs | |
| 24 | + tabBarExtraContent={ | |
| 25 | + <div className={styles.salesExtraWrap}> | |
| 26 | + <div className={styles.salesExtra}> | |
| 27 | + <a className={isActive('today')} onClick={() => selectDate('today')}> | |
| 28 | + <FormattedMessage id="app.analysis.all-day" defaultMessage="All Day" /> | |
| 29 | + </a> | |
| 30 | + <a className={isActive('week')} onClick={() => selectDate('week')}> | |
| 31 | + <FormattedMessage id="app.analysis.all-week" defaultMessage="All Week" /> | |
| 32 | + </a> | |
| 33 | + <a className={isActive('month')} onClick={() => selectDate('month')}> | |
| 34 | + <FormattedMessage id="app.analysis.all-month" defaultMessage="All Month" /> | |
| 35 | + </a> | |
| 36 | + <a className={isActive('year')} onClick={() => selectDate('year')}> | |
| 37 | + <FormattedMessage id="app.analysis.all-year" defaultMessage="All Year" /> | |
| 38 | + </a> | |
| 39 | + </div> | |
| 40 | + <RangePicker | |
| 41 | + value={rangePickerValue} | |
| 42 | + onChange={handleRangePickerChange} | |
| 43 | + style={{ width: 256 }} | |
| 44 | + /> | |
| 45 | + </div> | |
| 46 | + } | |
| 47 | + size="large" | |
| 48 | + tabBarStyle={{ marginBottom: 24 }} | |
| 49 | + > | |
| 50 | + <TabPane | |
| 51 | + tab={<FormattedMessage id="app.analysis.sales" defaultMessage="Sales" />} | |
| 52 | + key="sales" | |
| 53 | + > | |
| 54 | + <Row> | |
| 55 | + <Col xl={16} lg={12} md={12} sm={24} xs={24}> | |
| 56 | + <div className={styles.salesBar}> | |
| 57 | + <Bar | |
| 58 | + height={295} | |
| 59 | + title={ | |
| 60 | + <FormattedMessage | |
| 61 | + id="app.analysis.sales-trend" | |
| 62 | + defaultMessage="Sales Trend" | |
| 63 | + /> | |
| 64 | + } | |
| 65 | + data={salesData} | |
| 66 | + /> | |
| 67 | + </div> | |
| 68 | + </Col> | |
| 69 | + <Col xl={8} lg={12} md={12} sm={24} xs={24}> | |
| 70 | + <div className={styles.salesRank}> | |
| 71 | + <h4 className={styles.rankingTitle}> | |
| 72 | + <FormattedMessage | |
| 73 | + id="app.analysis.sales-ranking" | |
| 74 | + defaultMessage="Sales Ranking" | |
| 75 | + /> | |
| 76 | + </h4> | |
| 77 | + <ul className={styles.rankingList}> | |
| 78 | + {rankingListData.map((item, i) => ( | |
| 79 | + <li key={item.title}> | |
| 80 | + <span | |
| 81 | + className={`${styles.rankingItemNumber} ${i < 3 ? styles.active : ''}`} | |
| 82 | + > | |
| 83 | + {i + 1} | |
| 84 | + </span> | |
| 85 | + <span className={styles.rankingItemTitle} title={item.title}> | |
| 86 | + {item.title} | |
| 87 | + </span> | |
| 88 | + <span className={styles.rankingItemValue}> | |
| 89 | + {numeral(item.total).format('0,0')} | |
| 90 | + </span> | |
| 91 | + </li> | |
| 92 | + ))} | |
| 93 | + </ul> | |
| 94 | + </div> | |
| 95 | + </Col> | |
| 96 | + </Row> | |
| 97 | + </TabPane> | |
| 98 | + <TabPane | |
| 99 | + tab={<FormattedMessage id="app.analysis.visits" defaultMessage="Visits" />} | |
| 100 | + key="views" | |
| 101 | + > | |
| 102 | + <Row> | |
| 103 | + <Col xl={16} lg={12} md={12} sm={24} xs={24}> | |
| 104 | + <div className={styles.salesBar}> | |
| 105 | + <Bar | |
| 106 | + height={292} | |
| 107 | + title={ | |
| 108 | + <FormattedMessage | |
| 109 | + id="app.analysis.visits-trend" | |
| 110 | + defaultMessage="Visits Trend" | |
| 111 | + /> | |
| 112 | + } | |
| 113 | + data={salesData} | |
| 114 | + /> | |
| 115 | + </div> | |
| 116 | + </Col> | |
| 117 | + <Col xl={8} lg={12} md={12} sm={24} xs={24}> | |
| 118 | + <div className={styles.salesRank}> | |
| 119 | + <h4 className={styles.rankingTitle}> | |
| 120 | + <FormattedMessage | |
| 121 | + id="app.analysis.visits-ranking" | |
| 122 | + defaultMessage="Visits Ranking" | |
| 123 | + /> | |
| 124 | + </h4> | |
| 125 | + <ul className={styles.rankingList}> | |
| 126 | + {rankingListData.map((item, i) => ( | |
| 127 | + <li key={item.title}> | |
| 128 | + <span | |
| 129 | + className={`${styles.rankingItemNumber} ${i < 3 ? styles.active : ''}`} | |
| 130 | + > | |
| 131 | + {i + 1} | |
| 132 | + </span> | |
| 133 | + <span className={styles.rankingItemTitle} title={item.title}> | |
| 134 | + {item.title} | |
| 135 | + </span> | |
| 136 | + <span>{numeral(item.total).format('0,0')}</span> | |
| 137 | + </li> | |
| 138 | + ))} | |
| 139 | + </ul> | |
| 140 | + </div> | |
| 141 | + </Col> | |
| 142 | + </Row> | |
| 143 | + </TabPane> | |
| 144 | + </Tabs> | |
| 145 | + </div> | |
| 146 | + </Card> | |
| 147 | + ) | |
| 148 | +); | |
| 149 | + | |
| 150 | +export default SalesCard; | ... | ... |
ant-design-pro/Analysis/src/TopSearch.js
0 → 100755
| 1 | +import React, { memo } from 'react'; | |
| 2 | +import { Row, Col, Table, Tooltip, Card, Icon } from 'antd'; | |
| 3 | +import { FormattedMessage } from 'umi/locale'; | |
| 4 | +import Trend from 'ant-design-pro/lib/Trend'; | |
| 5 | +import numeral from 'numeral'; | |
| 6 | +import NumberInfo from 'ant-design-pro/lib/NumberInfo'; | |
| 7 | +import { MiniArea } from 'ant-design-pro/lib/Charts'; | |
| 8 | +import styles from './Analysis.less'; | |
| 9 | + | |
| 10 | +const columns = [ | |
| 11 | + { | |
| 12 | + title: <FormattedMessage id="app.analysis.table.rank" defaultMessage="Rank" />, | |
| 13 | + dataIndex: 'index', | |
| 14 | + key: 'index', | |
| 15 | + }, | |
| 16 | + { | |
| 17 | + title: ( | |
| 18 | + <FormattedMessage id="app.analysis.table.search-keyword" defaultMessage="Search keyword" /> | |
| 19 | + ), | |
| 20 | + dataIndex: 'keyword', | |
| 21 | + key: 'keyword', | |
| 22 | + render: text => <a href="/">{text}</a>, | |
| 23 | + }, | |
| 24 | + { | |
| 25 | + title: <FormattedMessage id="app.analysis.table.users" defaultMessage="Users" />, | |
| 26 | + dataIndex: 'count', | |
| 27 | + key: 'count', | |
| 28 | + sorter: (a, b) => a.count - b.count, | |
| 29 | + className: styles.alignRight, | |
| 30 | + }, | |
| 31 | + { | |
| 32 | + title: <FormattedMessage id="app.analysis.table.weekly-range" defaultMessage="Weekly Range" />, | |
| 33 | + dataIndex: 'range', | |
| 34 | + key: 'range', | |
| 35 | + sorter: (a, b) => a.range - b.range, | |
| 36 | + render: (text, record) => ( | |
| 37 | + <Trend flag={record.status === 1 ? 'down' : 'up'}> | |
| 38 | + <span style={{ marginRight: 4 }}>{text}%</span> | |
| 39 | + </Trend> | |
| 40 | + ), | |
| 41 | + align: 'right', | |
| 42 | + }, | |
| 43 | +]; | |
| 44 | + | |
| 45 | +const TopSearch = memo(({ loading, visitData2, searchData, dropdownGroup }) => ( | |
| 46 | + <Card | |
| 47 | + loading={loading} | |
| 48 | + bordered={false} | |
| 49 | + title={ | |
| 50 | + <FormattedMessage id="app.analysis.online-top-search" defaultMessage="Online Top Search" /> | |
| 51 | + } | |
| 52 | + extra={dropdownGroup} | |
| 53 | + style={{ marginTop: 24 }} | |
| 54 | + > | |
| 55 | + <Row gutter={68}> | |
| 56 | + <Col sm={12} xs={24} style={{ marginBottom: 24 }}> | |
| 57 | + <NumberInfo | |
| 58 | + subTitle={ | |
| 59 | + <span> | |
| 60 | + <FormattedMessage id="app.analysis.search-users" defaultMessage="search users" /> | |
| 61 | + <Tooltip | |
| 62 | + title={<FormattedMessage id="app.analysis.introduce" defaultMessage="introduce" />} | |
| 63 | + > | |
| 64 | + <Icon style={{ marginLeft: 8 }} type="info-circle-o" /> | |
| 65 | + </Tooltip> | |
| 66 | + </span> | |
| 67 | + } | |
| 68 | + gap={8} | |
| 69 | + total={numeral(12321).format('0,0')} | |
| 70 | + status="up" | |
| 71 | + subTotal={17.1} | |
| 72 | + /> | |
| 73 | + <MiniArea line height={45} data={visitData2} /> | |
| 74 | + </Col> | |
| 75 | + <Col sm={12} xs={24} style={{ marginBottom: 24 }}> | |
| 76 | + <NumberInfo | |
| 77 | + subTitle={ | |
| 78 | + <span> | |
| 79 | + <FormattedMessage | |
| 80 | + id="app.analysis.per-capita-search" | |
| 81 | + defaultMessage="Per Capita Search" | |
| 82 | + /> | |
| 83 | + <Tooltip | |
| 84 | + title={<FormattedMessage id="app.analysis.introduce" defaultMessage="introduce" />} | |
| 85 | + > | |
| 86 | + <Icon style={{ marginLeft: 8 }} type="info-circle-o" /> | |
| 87 | + </Tooltip> | |
| 88 | + </span> | |
| 89 | + } | |
| 90 | + total={2.7} | |
| 91 | + status="down" | |
| 92 | + subTotal={26.2} | |
| 93 | + gap={8} | |
| 94 | + /> | |
| 95 | + <MiniArea line height={45} data={visitData2} /> | |
| 96 | + </Col> | |
| 97 | + </Row> | |
| 98 | + <Table | |
| 99 | + rowKey={record => record.index} | |
| 100 | + size="small" | |
| 101 | + columns={columns} | |
| 102 | + dataSource={searchData} | |
| 103 | + pagination={{ | |
| 104 | + style: { marginBottom: 0 }, | |
| 105 | + pageSize: 5, | |
| 106 | + }} | |
| 107 | + /> | |
| 108 | + </Card> | |
| 109 | +)); | |
| 110 | + | |
| 111 | +export default TopSearch; | ... | ... |
ant-design-pro/Analysis/src/_mock.js
0 → 100644
| 1 | +import moment from 'moment'; | |
| 2 | + | |
| 3 | +// mock data | |
| 4 | +const visitData = []; | |
| 5 | +const beginDay = new Date().getTime(); | |
| 6 | + | |
| 7 | +const fakeY = [7, 5, 4, 2, 4, 7, 5, 6, 5, 9, 6, 3, 1, 5, 3, 6, 5]; | |
| 8 | +for (let i = 0; i < fakeY.length; i += 1) { | |
| 9 | + visitData.push({ | |
| 10 | + x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'), | |
| 11 | + y: fakeY[i], | |
| 12 | + }); | |
| 13 | +} | |
| 14 | + | |
| 15 | +const visitData2 = []; | |
| 16 | +const fakeY2 = [1, 6, 4, 8, 3, 7, 2]; | |
| 17 | +for (let i = 0; i < fakeY2.length; i += 1) { | |
| 18 | + visitData2.push({ | |
| 19 | + x: moment(new Date(beginDay + 1000 * 60 * 60 * 24 * i)).format('YYYY-MM-DD'), | |
| 20 | + y: fakeY2[i], | |
| 21 | + }); | |
| 22 | +} | |
| 23 | + | |
| 24 | +const salesData = []; | |
| 25 | +for (let i = 0; i < 12; i += 1) { | |
| 26 | + salesData.push({ | |
| 27 | + x: `${i + 1}月`, | |
| 28 | + y: Math.floor(Math.random() * 1000) + 200, | |
| 29 | + }); | |
| 30 | +} | |
| 31 | +const searchData = []; | |
| 32 | +for (let i = 0; i < 50; i += 1) { | |
| 33 | + searchData.push({ | |
| 34 | + index: i + 1, | |
| 35 | + keyword: `搜索关键词-${i}`, | |
| 36 | + count: Math.floor(Math.random() * 1000), | |
| 37 | + range: Math.floor(Math.random() * 100), | |
| 38 | + status: Math.floor((Math.random() * 10) % 2), | |
| 39 | + }); | |
| 40 | +} | |
| 41 | +const salesTypeData = [ | |
| 42 | + { | |
| 43 | + x: '家用电器', | |
| 44 | + y: 4544, | |
| 45 | + }, | |
| 46 | + { | |
| 47 | + x: '食用酒水', | |
| 48 | + y: 3321, | |
| 49 | + }, | |
| 50 | + { | |
| 51 | + x: '个护健康', | |
| 52 | + y: 3113, | |
| 53 | + }, | |
| 54 | + { | |
| 55 | + x: '服饰箱包', | |
| 56 | + y: 2341, | |
| 57 | + }, | |
| 58 | + { | |
| 59 | + x: '母婴产品', | |
| 60 | + y: 1231, | |
| 61 | + }, | |
| 62 | + { | |
| 63 | + x: '其他', | |
| 64 | + y: 1231, | |
| 65 | + }, | |
| 66 | +]; | |
| 67 | + | |
| 68 | +const salesTypeDataOnline = [ | |
| 69 | + { | |
| 70 | + x: '家用电器', | |
| 71 | + y: 244, | |
| 72 | + }, | |
| 73 | + { | |
| 74 | + x: '食用酒水', | |
| 75 | + y: 321, | |
| 76 | + }, | |
| 77 | + { | |
| 78 | + x: '个护健康', | |
| 79 | + y: 311, | |
| 80 | + }, | |
| 81 | + { | |
| 82 | + x: '服饰箱包', | |
| 83 | + y: 41, | |
| 84 | + }, | |
| 85 | + { | |
| 86 | + x: '母婴产品', | |
| 87 | + y: 121, | |
| 88 | + }, | |
| 89 | + { | |
| 90 | + x: '其他', | |
| 91 | + y: 111, | |
| 92 | + }, | |
| 93 | +]; | |
| 94 | + | |
| 95 | +const salesTypeDataOffline = [ | |
| 96 | + { | |
| 97 | + x: '家用电器', | |
| 98 | + y: 99, | |
| 99 | + }, | |
| 100 | + { | |
| 101 | + x: '食用酒水', | |
| 102 | + y: 188, | |
| 103 | + }, | |
| 104 | + { | |
| 105 | + x: '个护健康', | |
| 106 | + y: 344, | |
| 107 | + }, | |
| 108 | + { | |
| 109 | + x: '服饰箱包', | |
| 110 | + y: 255, | |
| 111 | + }, | |
| 112 | + { | |
| 113 | + x: '其他', | |
| 114 | + y: 65, | |
| 115 | + }, | |
| 116 | +]; | |
| 117 | + | |
| 118 | +const offlineData = []; | |
| 119 | +for (let i = 0; i < 10; i += 1) { | |
| 120 | + offlineData.push({ | |
| 121 | + name: `Stores ${i}`, | |
| 122 | + cvr: Math.ceil(Math.random() * 9) / 10, | |
| 123 | + }); | |
| 124 | +} | |
| 125 | +const offlineChartData = []; | |
| 126 | +for (let i = 0; i < 20; i += 1) { | |
| 127 | + offlineChartData.push({ | |
| 128 | + x: new Date().getTime() + 1000 * 60 * 30 * i, | |
| 129 | + y1: Math.floor(Math.random() * 100) + 10, | |
| 130 | + y2: Math.floor(Math.random() * 100) + 10, | |
| 131 | + }); | |
| 132 | +} | |
| 133 | + | |
| 134 | +const radarOriginData = [ | |
| 135 | + { | |
| 136 | + name: '个人', | |
| 137 | + ref: 10, | |
| 138 | + koubei: 8, | |
| 139 | + output: 4, | |
| 140 | + contribute: 5, | |
| 141 | + hot: 7, | |
| 142 | + }, | |
| 143 | + { | |
| 144 | + name: '团队', | |
| 145 | + ref: 3, | |
| 146 | + koubei: 9, | |
| 147 | + output: 6, | |
| 148 | + contribute: 3, | |
| 149 | + hot: 1, | |
| 150 | + }, | |
| 151 | + { | |
| 152 | + name: '部门', | |
| 153 | + ref: 4, | |
| 154 | + koubei: 1, | |
| 155 | + output: 6, | |
| 156 | + contribute: 5, | |
| 157 | + hot: 7, | |
| 158 | + }, | |
| 159 | +]; | |
| 160 | + | |
| 161 | +const radarData = []; | |
| 162 | +const radarTitleMap = { | |
| 163 | + ref: '引用', | |
| 164 | + koubei: '口碑', | |
| 165 | + output: '产量', | |
| 166 | + contribute: '贡献', | |
| 167 | + hot: '热度', | |
| 168 | +}; | |
| 169 | +radarOriginData.forEach(item => { | |
| 170 | + Object.keys(item).forEach(key => { | |
| 171 | + if (key !== 'name') { | |
| 172 | + radarData.push({ | |
| 173 | + name: item.name, | |
| 174 | + label: radarTitleMap[key], | |
| 175 | + value: item[key], | |
| 176 | + }); | |
| 177 | + } | |
| 178 | + }); | |
| 179 | +}); | |
| 180 | + | |
| 181 | +const getFakeChartData = { | |
| 182 | + visitData, | |
| 183 | + visitData2, | |
| 184 | + salesData, | |
| 185 | + searchData, | |
| 186 | + offlineData, | |
| 187 | + offlineChartData, | |
| 188 | + salesTypeData, | |
| 189 | + salesTypeDataOnline, | |
| 190 | + salesTypeDataOffline, | |
| 191 | + radarData, | |
| 192 | +}; | |
| 193 | + | |
| 194 | +export default { | |
| 195 | + 'GET /api/fake_chart_data': getFakeChartData, | |
| 196 | +}; | ... | ... |
| 1 | +module.exports = { | |
| 2 | + navTheme: 'dark', // theme for nav menu | |
| 3 | + primaryColor: '#1890FF', // primary color of ant design | |
| 4 | + layout: 'sidemenu', // nav menu position: sidemenu or topmenu | |
| 5 | + contentWidth: 'Fluid', // layout of content: Fluid or Fixed, only works when layout is topmenu | |
| 6 | + fixedHeader: false, // sticky header | |
| 7 | + autoHideHeader: false, // auto hide header | |
| 8 | + fixSiderbar: false, // sticky siderbar | |
| 9 | +}; | ... | ... |
ant-design-pro/Analysis/src/index.js
0 → 100644
| 1 | +import React, { Component, Suspense } from 'react'; | |
| 2 | +import { connect } from 'dva'; | |
| 3 | +import { Row, Col, Icon, Menu, Dropdown } from 'antd'; | |
| 4 | + | |
| 5 | +import GridContent from '@/components/PageHeaderWrapper/GridContent'; | |
| 6 | +import { getTimeDistance } from '@/utils/utils'; | |
| 7 | + | |
| 8 | +import styles from './Analysis.less'; | |
| 9 | +import PageLoading from '@/components/PageLoading'; | |
| 10 | + | |
| 11 | +const IntroduceRow = React.lazy(() => import('./IntroduceRow')); | |
| 12 | +const SalesCard = React.lazy(() => import('./SalesCard')); | |
| 13 | +const TopSearch = React.lazy(() => import('./TopSearch')); | |
| 14 | +const ProportionSales = React.lazy(() => import('./ProportionSales')); | |
| 15 | +const OfflineData = React.lazy(() => import('./OfflineData')); | |
| 16 | + | |
| 17 | +@connect(({ chart, loading }) => ({ | |
| 18 | + chart, | |
| 19 | + loading: loading.effects['chart/fetch'], | |
| 20 | +})) | |
| 21 | +class Analysis extends Component { | |
| 22 | + state = { | |
| 23 | + salesType: 'all', | |
| 24 | + currentTabKey: '', | |
| 25 | + rangePickerValue: getTimeDistance('year'), | |
| 26 | + }; | |
| 27 | + | |
| 28 | + componentDidMount() { | |
| 29 | + const { dispatch } = this.props; | |
| 30 | + this.reqRef = requestAnimationFrame(() => { | |
| 31 | + dispatch({ | |
| 32 | + type: 'chart/fetch', | |
| 33 | + }); | |
| 34 | + }); | |
| 35 | + } | |
| 36 | + | |
| 37 | + componentWillUnmount() { | |
| 38 | + const { dispatch } = this.props; | |
| 39 | + dispatch({ | |
| 40 | + type: 'chart/clear', | |
| 41 | + }); | |
| 42 | + cancelAnimationFrame(this.reqRef); | |
| 43 | + clearTimeout(this.timeoutId); | |
| 44 | + } | |
| 45 | + | |
| 46 | + handleChangeSalesType = e => { | |
| 47 | + this.setState({ | |
| 48 | + salesType: e.target.value, | |
| 49 | + }); | |
| 50 | + }; | |
| 51 | + | |
| 52 | + handleTabChange = key => { | |
| 53 | + this.setState({ | |
| 54 | + currentTabKey: key, | |
| 55 | + }); | |
| 56 | + }; | |
| 57 | + | |
| 58 | + handleRangePickerChange = rangePickerValue => { | |
| 59 | + const { dispatch } = this.props; | |
| 60 | + this.setState({ | |
| 61 | + rangePickerValue, | |
| 62 | + }); | |
| 63 | + | |
| 64 | + dispatch({ | |
| 65 | + type: 'chart/fetchSalesData', | |
| 66 | + }); | |
| 67 | + }; | |
| 68 | + | |
| 69 | + selectDate = type => { | |
| 70 | + const { dispatch } = this.props; | |
| 71 | + this.setState({ | |
| 72 | + rangePickerValue: getTimeDistance(type), | |
| 73 | + }); | |
| 74 | + | |
| 75 | + dispatch({ | |
| 76 | + type: 'chart/fetchSalesData', | |
| 77 | + }); | |
| 78 | + }; | |
| 79 | + | |
| 80 | + isActive = type => { | |
| 81 | + const { rangePickerValue } = this.state; | |
| 82 | + const value = getTimeDistance(type); | |
| 83 | + if (!rangePickerValue[0] || !rangePickerValue[1]) { | |
| 84 | + return ''; | |
| 85 | + } | |
| 86 | + if ( | |
| 87 | + rangePickerValue[0].isSame(value[0], 'day') && | |
| 88 | + rangePickerValue[1].isSame(value[1], 'day') | |
| 89 | + ) { | |
| 90 | + return styles.currentDate; | |
| 91 | + } | |
| 92 | + return ''; | |
| 93 | + }; | |
| 94 | + | |
| 95 | + render() { | |
| 96 | + const { rangePickerValue, salesType, currentTabKey } = this.state; | |
| 97 | + const { chart, loading } = this.props; | |
| 98 | + const { | |
| 99 | + visitData, | |
| 100 | + visitData2, | |
| 101 | + salesData, | |
| 102 | + searchData, | |
| 103 | + offlineData, | |
| 104 | + offlineChartData, | |
| 105 | + salesTypeData, | |
| 106 | + salesTypeDataOnline, | |
| 107 | + salesTypeDataOffline, | |
| 108 | + } = chart; | |
| 109 | + let salesPieData; | |
| 110 | + if (salesType === 'all') { | |
| 111 | + salesPieData = salesTypeData; | |
| 112 | + } else { | |
| 113 | + salesPieData = salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; | |
| 114 | + } | |
| 115 | + const menu = ( | |
| 116 | + <Menu> | |
| 117 | + <Menu.Item>操作一</Menu.Item> | |
| 118 | + <Menu.Item>操作二</Menu.Item> | |
| 119 | + </Menu> | |
| 120 | + ); | |
| 121 | + | |
| 122 | + const dropdownGroup = ( | |
| 123 | + <span className={styles.iconGroup}> | |
| 124 | + <Dropdown overlay={menu} placement="bottomRight"> | |
| 125 | + <Icon type="ellipsis" /> | |
| 126 | + </Dropdown> | |
| 127 | + </span> | |
| 128 | + ); | |
| 129 | + | |
| 130 | + const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name); | |
| 131 | + | |
| 132 | + return ( | |
| 133 | + <GridContent> | |
| 134 | + <Suspense fallback={<PageLoading />}> | |
| 135 | + <IntroduceRow loading={loading} visitData={visitData} /> | |
| 136 | + </Suspense> | |
| 137 | + <Suspense fallback={null}> | |
| 138 | + <SalesCard | |
| 139 | + rangePickerValue={rangePickerValue} | |
| 140 | + salesData={salesData} | |
| 141 | + isActive={this.isActive} | |
| 142 | + handleRangePickerChange={this.handleRangePickerChange} | |
| 143 | + loading={loading} | |
| 144 | + selectDate={this.selectDate} | |
| 145 | + /> | |
| 146 | + </Suspense> | |
| 147 | + <Row gutter={24}> | |
| 148 | + <Col xl={12} lg={24} md={24} sm={24} xs={24}> | |
| 149 | + <Suspense fallback={null}> | |
| 150 | + <TopSearch | |
| 151 | + loading={loading} | |
| 152 | + visitData2={visitData2} | |
| 153 | + selectDate={this.selectDate} | |
| 154 | + searchData={searchData} | |
| 155 | + dropdownGroup={dropdownGroup} | |
| 156 | + /> | |
| 157 | + </Suspense> | |
| 158 | + </Col> | |
| 159 | + <Col xl={12} lg={24} md={24} sm={24} xs={24}> | |
| 160 | + <Suspense fallback={null}> | |
| 161 | + <ProportionSales | |
| 162 | + dropdownGroup={dropdownGroup} | |
| 163 | + salesType={salesType} | |
| 164 | + loading={loading} | |
| 165 | + salesPieData={salesPieData} | |
| 166 | + handleChangeSalesType={this.handleChangeSalesType} | |
| 167 | + /> | |
| 168 | + </Suspense> | |
| 169 | + </Col> | |
| 170 | + </Row> | |
| 171 | + <Suspense fallback={null}> | |
| 172 | + <OfflineData | |
| 173 | + activeKey={activeKey} | |
| 174 | + loading={loading} | |
| 175 | + offlineData={offlineData} | |
| 176 | + offlineChartData={offlineChartData} | |
| 177 | + handleTabChange={this.handleTabChange} | |
| 178 | + /> | |
| 179 | + </Suspense> | |
| 180 | + </GridContent> | |
| 181 | + ); | |
| 182 | + } | |
| 183 | +} | |
| 184 | + | |
| 185 | +export default Analysis; | ... | ... |
ant-design-pro/Analysis/src/models/chart.js
0 → 100644
| 1 | +import { fakeChartData } from '@/services/api'; | |
| 2 | + | |
| 3 | +export default { | |
| 4 | + namespace: 'chart', | |
| 5 | + | |
| 6 | + state: { | |
| 7 | + visitData: [], | |
| 8 | + visitData2: [], | |
| 9 | + salesData: [], | |
| 10 | + searchData: [], | |
| 11 | + offlineData: [], | |
| 12 | + offlineChartData: [], | |
| 13 | + salesTypeData: [], | |
| 14 | + salesTypeDataOnline: [], | |
| 15 | + salesTypeDataOffline: [], | |
| 16 | + radarData: [], | |
| 17 | + loading: false, | |
| 18 | + }, | |
| 19 | + | |
| 20 | + effects: { | |
| 21 | + *fetch(_, { call, put }) { | |
| 22 | + const response = yield call(fakeChartData); | |
| 23 | + yield put({ | |
| 24 | + type: 'save', | |
| 25 | + payload: response, | |
| 26 | + }); | |
| 27 | + }, | |
| 28 | + *fetchSalesData(_, { call, put }) { | |
| 29 | + const response = yield call(fakeChartData); | |
| 30 | + yield put({ | |
| 31 | + type: 'save', | |
| 32 | + payload: { | |
| 33 | + salesData: response.salesData, | |
| 34 | + }, | |
| 35 | + }); | |
| 36 | + }, | |
| 37 | + }, | |
| 38 | + | |
| 39 | + reducers: { | |
| 40 | + save(state, { payload }) { | |
| 41 | + return { | |
| 42 | + ...state, | |
| 43 | + ...payload, | |
| 44 | + }; | |
| 45 | + }, | |
| 46 | + clear() { | |
| 47 | + return { | |
| 48 | + visitData: [], | |
| 49 | + visitData2: [], | |
| 50 | + salesData: [], | |
| 51 | + searchData: [], | |
| 52 | + offlineData: [], | |
| 53 | + offlineChartData: [], | |
| 54 | + salesTypeData: [], | |
| 55 | + salesTypeDataOnline: [], | |
| 56 | + salesTypeDataOffline: [], | |
| 57 | + radarData: [], | |
| 58 | + }; | |
| 59 | + }, | |
| 60 | + }, | |
| 61 | +}; | ... | ... |
| 1 | +import { message } from 'antd'; | |
| 2 | +import defaultSettings from '../defaultSettings'; | |
| 3 | + | |
| 4 | +let lessNodesAppended; | |
| 5 | +const updateTheme = primaryColor => { | |
| 6 | + // Don't compile less in production! | |
| 7 | + if (APP_TYPE !== 'site') { | |
| 8 | + return; | |
| 9 | + } | |
| 10 | + // Determine if the component is remounted | |
| 11 | + if (!primaryColor) { | |
| 12 | + return; | |
| 13 | + } | |
| 14 | + const hideMessage = message.loading('正在编译主题!', 0); | |
| 15 | + function buildIt() { | |
| 16 | + if (!window.less) { | |
| 17 | + return; | |
| 18 | + } | |
| 19 | + setTimeout(() => { | |
| 20 | + window.less | |
| 21 | + .modifyVars({ | |
| 22 | + '@primary-color': primaryColor, | |
| 23 | + }) | |
| 24 | + .then(() => { | |
| 25 | + hideMessage(); | |
| 26 | + }) | |
| 27 | + .catch(() => { | |
| 28 | + message.error('Failed to update theme'); | |
| 29 | + hideMessage(); | |
| 30 | + }); | |
| 31 | + }, 200); | |
| 32 | + } | |
| 33 | + if (!lessNodesAppended) { | |
| 34 | + // insert less.js and color.less | |
| 35 | + const lessStyleNode = document.createElement('link'); | |
| 36 | + const lessConfigNode = document.createElement('script'); | |
| 37 | + const lessScriptNode = document.createElement('script'); | |
| 38 | + lessStyleNode.setAttribute('rel', 'stylesheet/less'); | |
| 39 | + lessStyleNode.setAttribute('href', '/color.less'); | |
| 40 | + lessConfigNode.innerHTML = ` | |
| 41 | + window.less = { | |
| 42 | + async: true, | |
| 43 | + env: 'production', | |
| 44 | + javascriptEnabled: true | |
| 45 | + }; | |
| 46 | + `; | |
| 47 | + lessScriptNode.src = 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js'; | |
| 48 | + lessScriptNode.async = true; | |
| 49 | + lessScriptNode.onload = () => { | |
| 50 | + buildIt(); | |
| 51 | + lessScriptNode.onload = null; | |
| 52 | + }; | |
| 53 | + document.body.appendChild(lessStyleNode); | |
| 54 | + document.body.appendChild(lessConfigNode); | |
| 55 | + document.body.appendChild(lessScriptNode); | |
| 56 | + lessNodesAppended = true; | |
| 57 | + } else { | |
| 58 | + buildIt(); | |
| 59 | + } | |
| 60 | +}; | |
| 61 | + | |
| 62 | +const updateColorWeak = colorWeak => { | |
| 63 | + document.body.className = colorWeak ? 'colorWeak' : ''; | |
| 64 | +}; | |
| 65 | + | |
| 66 | +export default { | |
| 67 | + namespace: 'setting', | |
| 68 | + state: defaultSettings, | |
| 69 | + reducers: { | |
| 70 | + getSetting(state) { | |
| 71 | + const setting = {}; | |
| 72 | + const urlParams = new URL(window.location.href); | |
| 73 | + Object.keys(state).forEach(key => { | |
| 74 | + if (urlParams.searchParams.has(key)) { | |
| 75 | + const value = urlParams.searchParams.get(key); | |
| 76 | + setting[key] = value === '1' ? true : value; | |
| 77 | + } | |
| 78 | + }); | |
| 79 | + const { primaryColor, colorWeak } = setting; | |
| 80 | + if (state.primaryColor !== primaryColor) { | |
| 81 | + updateTheme(primaryColor); | |
| 82 | + } | |
| 83 | + updateColorWeak(colorWeak); | |
| 84 | + return { | |
| 85 | + ...state, | |
| 86 | + ...setting, | |
| 87 | + }; | |
| 88 | + }, | |
| 89 | + changeSetting(state, { payload }) { | |
| 90 | + const urlParams = new URL(window.location.href); | |
| 91 | + Object.keys(defaultSettings).forEach(key => { | |
| 92 | + if (urlParams.searchParams.has(key)) { | |
| 93 | + urlParams.searchParams.delete(key); | |
| 94 | + } | |
| 95 | + }); | |
| 96 | + Object.keys(payload).forEach(key => { | |
| 97 | + if (key === 'collapse') { | |
| 98 | + return; | |
| 99 | + } | |
| 100 | + let value = payload[key]; | |
| 101 | + if (value === true) { | |
| 102 | + value = 1; | |
| 103 | + } | |
| 104 | + if (defaultSettings[key] !== value) { | |
| 105 | + urlParams.searchParams.set(key, value); | |
| 106 | + } | |
| 107 | + }); | |
| 108 | + const { primaryColor, colorWeak, contentWidth } = payload; | |
| 109 | + if (state.primaryColor !== primaryColor) { | |
| 110 | + updateTheme(primaryColor); | |
| 111 | + } | |
| 112 | + if (state.contentWidth !== contentWidth && window.dispatchEvent) { | |
| 113 | + window.dispatchEvent(new Event('resize')); | |
| 114 | + } | |
| 115 | + updateColorWeak(colorWeak); | |
| 116 | + window.history.replaceState(null, 'setting', urlParams.href); | |
| 117 | + return { | |
| 118 | + ...state, | |
| 119 | + ...payload, | |
| 120 | + }; | |
| 121 | + }, | |
| 122 | + }, | |
| 123 | +}; | ... | ... |
请
注册
或
登录
后发表评论