Commit 97aefe49 by chenshu

Merge branch 'feature/chenshu/graphics'

parents 9157df99 b40dac56
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
"homepage": "./", "homepage": "./",
"dependencies": { "dependencies": {
"@antv/data-set": "^0.11.8", "@antv/data-set": "^0.11.8",
"@antv/g2": "^3.5.13", "@antv/g2": "^3.5.17",
"@babel/core": "7.9.0", "@babel/core": "7.9.0",
"@babel/plugin-transform-typescript": "^7.11.0", "@babel/plugin-transform-typescript": "^7.11.0",
"@babel/preset-typescript": "^7.10.4", "@babel/preset-typescript": "^7.10.4",
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
"babel-plugin-jsx-control-statements": "^4.1.0", "babel-plugin-jsx-control-statements": "^4.1.0",
"babel-plugin-named-asset-import": "^0.3.6", "babel-plugin-named-asset-import": "^0.3.6",
"babel-preset-react-app": "^9.1.2", "babel-preset-react-app": "^9.1.2",
"bizcharts": "^4.1.7", "bizcharts": "^3.3.0",
"camelcase": "^5.3.1", "camelcase": "^5.3.1",
"case-sensitive-paths-webpack-plugin": "2.3.0", "case-sensitive-paths-webpack-plugin": "2.3.0",
"classnames": "^2.2.6", "classnames": "^2.2.6",
......
/* /*
* @Author: 吴文洁 * @Author: 吴文洁
* @Date: 2020-07-15 17:29:12 * @Date: 2020-07-15 17:29:12
* @Last Modified by: 吴文洁 * @Last Modified by: chenshu
* @Last Modified time: 2020-07-15 18:16:05 * @Last Modified time: 2021-03-29 16:19:49
* @Description: 新建/编辑直播课-基本信息 * @Description: 新建/编辑直播课-基本信息
*/ */
...@@ -241,7 +241,7 @@ class AddLiveBasic extends React.Component { ...@@ -241,7 +241,7 @@ class AddLiveBasic extends React.Component {
className={`default-btn ${isDefaultCover ? 'disabled' : ''}`} className={`default-btn ${isDefaultCover ? 'disabled' : ''}`}
onClick={this.handleResetCoverUrl} onClick={this.handleResetCoverUrl}
>使用默认图</span> >使用默认图</span>
<div className="tips">建议尺寸1280*720像素,图片支持jpg、jpeg、png格式。</div> <div className="tips">建议尺寸1280*720px,图片支持jpg、jpeg、png格式。</div>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -156,7 +156,6 @@ class GraphicsEditor extends React.Component { ...@@ -156,7 +156,6 @@ class GraphicsEditor extends React.Component {
const videoCount = ((html || '').match(/<iframe/g) || []).length; const videoCount = ((html || '').match(/<iframe/g) || []).length;
const imageCount = ((html || '').match(/<img/g) || []).length; const imageCount = ((html || '').match(/<img/g) || []).length;
const textLength = this.editorInt.txt.text().replace(/\&nbsp\;/ig, ' ').length + videoCount + imageCount; const textLength = this.editorInt.txt.text().replace(/\&nbsp\;/ig, ' ').length + videoCount + imageCount;
console.log(html, 777777)
this.setState({ textLength }, () => { this.setState({ textLength }, () => {
onChange(html, this.state.textLength); onChange(html, this.state.textLength);
}) })
......
...@@ -17,13 +17,13 @@ ...@@ -17,13 +17,13 @@
} }
.editor-box { .editor-box {
height: 100%; height: 100%;
width: 100%;
} }
.w-e-toolbar { .w-e-toolbar {
background-color: #fff !important; background-color: #fff !important;
border: none !important; border: none !important;
border-bottom: 1px solid #E8E8E8 !important; border-bottom: 1px solid #E8E8E8 !important;
width: 700px;
} }
.w-e-text-container { .w-e-text-container {
......
import React from 'react'; import React from 'react';
import { Select, Tooltip } from 'antd'; import { Select, Tooltip } from 'antd';
import { Chart } from '@antv/g2'; import DataSet from "@antv/data-set";
import { Chart as G2Chart } from '@antv/g2';
import {
G2,
Chart,
Geom,
Axis,
Tooltip as G2Tooltip,
Coord,
Label,
Legend,
View,
Guide,
Shape,
Facet,
Util
} from "bizcharts";
import moment from 'moment' import moment from 'moment'
import Service from "@/common/js/service"; import Service from "@/common/js/service";
import User from '@/common/js/user'; import User from '@/common/js/user';
...@@ -21,8 +37,11 @@ class Home extends React.Component { ...@@ -21,8 +37,11 @@ class Home extends React.Component {
liveCourseNum: 0, liveCourseNum: 0,
totalCustomerNum: 0, totalCustomerNum: 0,
videoCourseNum: 0, videoCourseNum: 0,
pictureCourseNum: 0,
timeRange: '7', timeRange: '7',
studyTimeRange: '7', studyTimeRange: '7',
completeNum: 0,
unfinishedNum: 0,
} }
this._chart = null; this._chart = null;
} }
...@@ -31,6 +50,15 @@ class Home extends React.Component { ...@@ -31,6 +50,15 @@ class Home extends React.Component {
this.getPanelInfo(); this.getPanelInfo();
this.getStudyInfo(); this.getStudyInfo();
this.getHotCourse(); this.getHotCourse();
this.getTrainingInfo();
}
getTrainingInfo() {
Service.Hades('public/hades/planOverview', { storeId: User.getStoreId() }).then((res) => {
if (res.success) {
this.setState(res.result)
}
});
} }
getHotCourse() { getHotCourse() {
...@@ -72,10 +100,12 @@ class Home extends React.Component { ...@@ -72,10 +100,12 @@ class Home extends React.Component {
incLiveCourseNum: res.result.incLiveCourseNum, incLiveCourseNum: res.result.incLiveCourseNum,
incVideoCourseNum: res.result.incVideoCourseNum, incVideoCourseNum: res.result.incVideoCourseNum,
incPictureCourseNum: res.result.incPictureCourseNum, incPictureCourseNum: res.result.incPictureCourseNum,
incTrainingPlanNum: res.result.incTrainingPlanNum,
liveCourseNum: res.result.liveCourseNum, liveCourseNum: res.result.liveCourseNum,
totalCustomerNum: res.result.totalCustomerNum, totalCustomerNum: res.result.totalCustomerNum,
videoCourseNum: res.result.videoCourseNum, videoCourseNum: res.result.videoCourseNum,
pictureCourseNum: res.result.pictureCourseNum, pictureCourseNum: res.result.pictureCourseNum,
trainingPlanNum: res.result.trainingPlanNum,
}) })
} }
}) })
...@@ -97,7 +127,7 @@ class Home extends React.Component { ...@@ -97,7 +127,7 @@ class Home extends React.Component {
createChart = (data) => { createChart = (data) => {
if (!this._chart) { if (!this._chart) {
this._chart = new Chart({ this._chart = new G2Chart({
container: 'chart-id', container: 'chart-id',
forceFit: true, forceFit: true,
height: 290, height: 290,
...@@ -192,7 +222,39 @@ class Home extends React.Component { ...@@ -192,7 +222,39 @@ class Home extends React.Component {
timeRange, timeRange,
scheduleType, scheduleType,
studyTimeRange, studyTimeRange,
trainingPlanNum,
incTrainingPlanNum,
unfinishedNum,
completeNum,
planCustomerNum,
} = this.state; } = this.state;
const data = [
{
item: '已完成培训',
count: completeNum,
}, {
item: '未完成培训',
count: unfinishedNum,
}
];
const { DataView } = DataSet;
const { Html } = Guide;
const sum = data[0].count + data[1].count;
const dv = new DataView();
sum && dv.source(data).transform({
type: "percent",
field: "count",
dimension: "item",
as: "percent"
});
const cols = {
percent: {
formatter: val => {
val = val * 100 + "%";
return val;
}
}
};
return ( return (
<div className="home-page"> <div className="home-page">
<div className="home-title">数据概况</div> <div className="home-title">数据概况</div>
...@@ -269,13 +331,13 @@ class Home extends React.Component { ...@@ -269,13 +331,13 @@ class Home extends React.Component {
<img className="header-icon" src="https://image.xiaomaiketang.com/xm/jZf3GNY5tY.png" /> <img className="header-icon" src="https://image.xiaomaiketang.com/xm/jZf3GNY5tY.png" />
<span className="header-word">培训计划总数 (个)</span> <span className="header-word">培训计划总数 (个)</span>
</div> </div>
<div className="data-number">0</div> <div className="data-number">{trainingPlanNum}</div>
<div className="data-footer"> <div className="data-footer">
<span className="footer-word">本月新增</span> <span className="footer-word">本月新增</span>
{false && {incTrainingPlanNum > 0 &&
<span className="icon iconfont">&#xe635;</span> <span className="icon iconfont">&#xe635;</span>
} }
<span className="footer-number">0</span> <span className="footer-number">{incTrainingPlanNum}</span>
</div> </div>
</div> </div>
<div className="data-item"> <div className="data-item">
...@@ -358,24 +420,78 @@ class Home extends React.Component { ...@@ -358,24 +420,78 @@ class Home extends React.Component {
</Tooltip> </Tooltip>
<span className="tip">(本月)</span> <span className="tip">(本月)</span>
</div> </div>
<div className="circle-box"> {(unfinishedNum || completeNum) ?
<div
className="left-graph-container"
id="mountNode"
style={{ width: '100%', marginLeft: '-20%', marginTop: -30 }}
ref={e => e && (this.width = e.clientWidth)}
>
{this.width && <div>
<Chart
height={400}
width={this.width}
data={dv}
scale={cols}
padding={20}
>
<Coord type={"theta"} radius={0.75} innerRadius={0.6} />
<Axis name="percent" />
<G2Tooltip
showTitle={false}
itemTpl="<li><span style=&quot;background-color:{color};&quot; class=&quot;g2-tooltip-marker&quot;></span>{name}: {value}</li>"
/>
<Guide>
<Html
position={['50%', "50%"]}
html={`<div style="color:#8c8c8c;font-size:14px;text-align: center;width: ${this.width}px;"><span style="color:#333;font-size:20px">${planCustomerNum}人</span><br>新增培训人数</div>`}
alignX="middle"
alignY="middle"
/>
</Guide>
<Geom
type="intervalStack"
position="percent"
color={['item', ['#FDB513', '#5289FA']]}
tooltip={[
"item*percent",
(item, percent) => {
percent = Math.round(percent * 100) + "%";
return {
name: item,
value: percent,
};
}
]}
style={{
lineWidth: 1,
stroke: "#fff"
}}
>
</Geom>
</Chart>
</div>
}
</div>
: <div className="circle-box">
<div className="big-circle"> <div className="big-circle">
<div className="small-circle"> <div className="small-circle">
<div className="tip-box"> <div className="tip-box">
<div style={{ color: '#333', fontSize: '20px', marginBottom: 4 }}>0</div> <div style={{ color: '#333', fontSize: '20px', marginBottom: 4 }}>{planCustomerNum}</div>
<div style={{ color: '#999' }}>新增培训人数</div> <div style={{ color: '#999' }}>新增培训人数</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
}
<div className="circle-tip unfinished"> <div className="circle-tip unfinished">
<div className="spot"></div> <div className="spot"></div>
<div className="number">0</div> <div className="number">{unfinishedNum}</div>
<div className="word">未完成培训</div> <div className="word">未完成培训</div>
</div> </div>
<div className="circle-tip finished"> <div className="circle-tip finished">
<div className="spot"></div> <div className="spot"></div>
<div className="number">0</div> <div className="number">{completeNum}</div>
<div className="word">完成培训</div> <div className="word">完成培训</div>
</div> </div>
</div> </div>
...@@ -406,6 +522,10 @@ class Home extends React.Component { ...@@ -406,6 +522,10 @@ class Home extends React.Component {
<div>人均学习时长(分钟)</div> <div>人均学习时长(分钟)</div>
</div> </div>
<div id="chart-id"></div> <div id="chart-id"></div>
<div className="chart-bottom-tip">
<div className="tip-item" style={{ marginRight: 100 }}><span className="student-dot"></span>学习人数</div>
<div className="tip-item"><span className="time-dot"></span>人均学习时长</div>
</div>
</div> </div>
</div> </div>
) )
......
.home-page { .home-page {
padding: 0 16px 16px; padding: 0 16px 16px;
min-width: 1100px; min-width: 1100px;
.g2-tooltip-marker {
border-radius: 50% !important;
}
.home-title { .home-title {
height: 44px; height: 44px;
line-height: 44px; line-height: 44px;
...@@ -282,10 +285,11 @@ ...@@ -282,10 +285,11 @@
} }
.study-chart { .study-chart {
width: 100%; width: 100%;
height: 396px; height: 432px;
background: #fff; background: #fff;
padding: 16px; padding: 16px;
margin-top: 16px; margin-top: 16px;
padding-bottom: 32px;
.study-title { .study-title {
font-size: 16px; font-size: 16px;
color: #333; color: #333;
...@@ -315,6 +319,29 @@ ...@@ -315,6 +319,29 @@
} }
} }
} }
.chart-bottom-tip {
display: flex;
justify-content: center;
.tip-item {
display: flex;
align-items: center;
color: #666;
.student-dot {
background: #5289FA;
height: 8px;
width: 8px;
border-radius: 50%;
margin-right: 8px;
}
.time-dot {
background: #FEB613;
height: 8px;
width: 8px;
border-radius: 50%;
margin-right: 8px;
}
}
}
} }
} }
......
...@@ -30,9 +30,11 @@ const App: React.FC = (props: any) => { ...@@ -30,9 +30,11 @@ const App: React.FC = (props: any) => {
useEffect(() => { useEffect(() => {
getStoreAndUserInfo(); getStoreAndUserInfo();
// window.RCHistory.push({ if (window.location.hash === "#/") {
// pathname: `/switch-route`, window.RCHistory.replace({
// }) pathname: '/home',
})
}
}, []) }, [])
async function getStoreAndUserInfo() { async function getStoreAndUserInfo() {
......
...@@ -377,7 +377,7 @@ class StoreH5Decoration extends React.Component { ...@@ -377,7 +377,7 @@ class StoreH5Decoration extends React.Component {
<div className="banner-setting"> <div className="banner-setting">
<div className="title">banner设置</div> <div className="title">banner设置</div>
<div className="tip"> <div className="tip">
图片支持bmp、jpeg、jpg、png、gif格式,最大5M,最多可添加5张,拖动可排序。建议尺寸750x252像素 图片支持bmp、jpeg、jpg、png、gif格式,最大5M,最多可添加5张,拖动可排序。建议尺寸750*252px
</div> </div>
</div> </div>
<Button <Button
......
...@@ -375,7 +375,7 @@ class StoreWebDecoration extends React.Component { ...@@ -375,7 +375,7 @@ class StoreWebDecoration extends React.Component {
<div className="banner-setting"> <div className="banner-setting">
<div className="title">banner设置</div> <div className="title">banner设置</div>
<div className="tip"> <div className="tip">
图片支持bmp、jpeg、jpg、png、gif格式,最大5M,最多可添加5张,拖动可排序。建议尺寸1232*212像素 图片支持bmp、jpeg、jpg、png、gif格式,最大5M,最多可添加5张,拖动可排序。建议尺寸1232*212px
</div> </div>
</div> </div>
<Button <Button
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment