This commit is contained in:
timorls 2022-03-29 16:23:19 +08:00
parent dcf8f39144
commit aaed196e4c
3 changed files with 137 additions and 38 deletions

View File

@ -15,17 +15,21 @@ class Dashboard extends Component {
constructor(props) {
super(props)
this.state = {
data: [],
monitor: {}, //检测数据
rating: {}, //评价记录
industry: [], //行业分布
company: [], //新增企业
columns: [
{ title: '企业ID', dataIndex: '企业ID', key: 0 },
{ title: '企业名称', dataIndex: '企业名称', key: 1 },
{ title: '注册时间', dataIndex: '注册时间', key: 2 },
{ title: '邮箱', dataIndex: '邮箱', key: 2 },
{ title: '注册时间', dataIndex: '注册时间', key: 3 },
{
title: '详 情',
dataIndex: '详 情',
key: 3,
key: 4,
align: 'center',
render: () => <span style={{ color: '#108ee9',cursor:'pointer' }}> </span>
render: () => <span style={{ color: '#108ee9', cursor: 'pointer' }}> </span>
},
]
}
@ -38,14 +42,37 @@ class Dashboard extends Component {
}
init() {
api.get("/admin/board/get_dashboard_data").then(res => {
// 监测数据
api.get("/admin/board/get_monitor_data").then(res => {
this.setState({
data: res.result
}, () => {
monitor: res.result
})
})
// 评级记录
api.get("/admin/board/get_rating_static").then(res => {
this.setState({
rating: res.result
},()=>{
this.initChart()
})
})
// 行业分布
api.get("/admin/board/get_industry_distribute").then(res => {
this.setState({
industry: res.result
},()=>{
this.initPie()
})
})
// 新增企业
api.get("/admin/board/get_new_companies",{page_no:1,page_size:10}).then(res => {
this.setState({
company: res.result
})
})
}
initChart = () => {
@ -55,7 +82,7 @@ class Dashboard extends Component {
show: true,
trigger: "item",
showContent: true,
borderColor:"#fff",
borderColor: "#fff",
formatter: (params) => {
return `<span>${params.data}</span>`
}
@ -69,7 +96,7 @@ class Dashboard extends Component {
xAxis: {
type: 'category',
boundaryGap: false,
data: this.state.data['服务次数'] && this.state.data['服务次数']['日期'],
data: this.state.rating && this.state.rating['日期'],
axisLine: {
show: false
},
@ -91,7 +118,7 @@ class Dashboard extends Component {
},
series: [
{
data: this.state.data['服务次数'] && this.state.data['服务次数']['次数'],
data: this.state.rating && this.state.rating['次数'],
type: 'line',
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
@ -117,7 +144,7 @@ class Dashboard extends Component {
initPie() {
const data = []
this.state.data['行业分布'].forEach(item => {
this.state.industry.forEach(item => {
Object.keys(item).forEach(key => {
data.push({ name: key, value: item[key] })
})
@ -128,7 +155,7 @@ class Dashboard extends Component {
show: true,
trigger: "item",
showContent: true,
borderColor:"#fff",
borderColor: "#fff",
formatter: (params) => {
return `<span>${params.data.name}</span>`
}
@ -142,8 +169,8 @@ class Dashboard extends Component {
height: '100%'
},
color: ['#377AE4', '#F4C100', '#FF3525'],
label:{
show:false
label: {
show: false
},
series: [
{
@ -189,18 +216,18 @@ class Dashboard extends Component {
<Row gutter={32} style={{ marginBottom: '20px' }}>
<Col span={4}>
<Card title='异常日志' style={{ marginBottom: '40px' }}>
<p className='content-p'>{this.state.data['监测数据'] && this.state.data['监测数据']['异常日志']}<span style={{ marginLeft: 2 }}>/</span></p>
<p className='content-p'>{this.state.monitor['异常日志']}<span style={{ marginLeft: 2 }}>/</span></p>
</Card>
<Card title='服务次数'>
<p className='content-p'>{this.state.data['监测数据'] && this.state.data['监测数据']['服务次数']}<span style={{ marginLeft: 2 }}>/</span></p>
<p className='content-p'>{this.state.monitor['服务次数']}<span style={{ marginLeft: 2 }}>/</span></p>
</Card>
</Col>
<Col span={4}>
<Card title='留言反馈' style={{ marginBottom: '40px' }}>
<p className='content-p'>{this.state.data['监测数据'] && this.state.data['监测数据']['留言反馈']}<span style={{ marginLeft: 2 }}>/</span></p>
<p className='content-p'>{this.state.monitor['留言反馈']}<span style={{ marginLeft: 2 }}>/</span></p>
</Card>
<Card title="认证企业">
<p className='content-p'>{this.state.data['监测数据'] && this.state.data['监测数据']['认证企业']}<span style={{ marginLeft: 2 }}>/</span></p>
<p className='content-p'>{this.state.monitor['认证企业']}<span style={{ marginLeft: 2 }}>/</span></p>
</Card>
</Col>
<Col span={16}>
@ -214,7 +241,7 @@ class Dashboard extends Component {
<Card title='行业分布'>
<div id='pie' style={{ width: '100%', height: '300px' }}></div>
{
this.state.data['行业分布'] && this.state.data['行业分布'].map(item => {
this.state.industry && this.state.industry.map(item => {
return Object.keys(item).map((key, index) => {
return <p className='space-word' key={index}><span>{key}</span><span>{item[key]}</span></p>
})
@ -224,7 +251,7 @@ class Dashboard extends Component {
</Col>
<Col span={16}>
<Card title="新增企业信息">
<FeTable data={this.state.data['新增企业信息']} columns={this.state.columns} callback={this.callback.bind(this)}></FeTable>
<FeTable data={this.state.company} columns={this.state.columns} callback={this.callback.bind(this)}></FeTable>
</Card>
</Col>
</Row>

View File

@ -48,16 +48,6 @@ class FillDetails extends Component {
})
}
analysisQuestion(val) {
if ("经营问卷" in this.state.data) {
return val.map((key, i) => {
return <Descriptions.Item label={i + 1 + "题"} key={i} span={0.4}>{key}</Descriptions.Item>
})
} else {
return null
}
}
analysisObject(val) {
if (Object.keys(val).length !== 0) {
return Object.keys(val).map(key => {

View File

@ -1,10 +1,10 @@
import React, { Component } from 'react';
import { withRouter } from "react-router-dom";
import { Row, Input, Button, Form, Tag, Modal, Select, Card, Col, message } from 'antd';
import { PlusOutlined,MinusOutlined } from '@ant-design/icons';
import { Row, Input, Button, Form, Tag, Modal, Select, Card, Col, message, Space, Empty } from 'antd';
import { PlusOutlined, MinusOutlined } from '@ant-design/icons';
import api from "@/api/request"
const { Search, TextArea } = Input
const { TextArea } = Input
const { Option } = Select
@ -12,14 +12,20 @@ class Threshold extends Component {
constructor(props) {
super(props)
this.state = {
visible: true,
visible: false,
data: {
行业: "",
评价类型: "",
问卷内容: [
{ label: "", children: [{ label: "", type: "", option: [{ index: "", label: "" }, { index: "", label: "" }] }] },
]
}
},
questionnaire: {},
questionVisible: [
{ name: '环境', disabled: false },
{ name: '社会', disabled: true },
{ name: '治理', disabled: true }
]
}
}
@ -33,8 +39,35 @@ class Threshold extends Component {
})
}
onSearch = e => {
submit = e => {
const form = {
type: e['评价类型'] || '综合信用评价',
industry: e['一级行业']
}
api.post("/admin/model/questionnaire/get_questionnaire", form)
.then(res => {
this.setState({
questionnaire: res.data?res.data:{}
})
})
.catch((err)=>{
message.warning("未检索到问卷")
this.setState({
questionnaire:{}
})
})
}
onChangeDisabled = e => {
const data = [
{ name: '环境', disabled: true },
{ name: '社会', disabled: true },
{ name: '治理', disabled: true }
]
data[e].disabled = false
this.setState({
questionVisible: data
})
}
setVisible = () => {
@ -58,6 +91,7 @@ class Threshold extends Component {
}
render() {
var sum = 0
return (
<>
<Modal
@ -72,7 +106,7 @@ class Threshold extends Component {
<Form name="dynamic_form_nest_item" ref={this.form} layout="vertical" autoComplete="off">
<Tag color="#108ee9">行业</Tag>
<Form.Item name="行业">
<Input/>
<Input />
</Form.Item>
<Tag color="#108ee9">评价类型</Tag>
<Form.Item name="评价类型">
@ -169,7 +203,21 @@ class Threshold extends Component {
</Form>
</Modal>
<Row justify='space-between'>
<Search placeholder="检索问卷" onSearch={this.onSearch} enterButton style={{ width: 300, marginBottom: 20 }} />
<Form layout='inline' onFinish={this.submit}>
<Form.Item name="评价类型">
<Select style={{ width: 150, marginBottom: 20 }} defaultValue="综合信用评价">
<Option value="综合信用评价">综合信用评价</Option>
<Option value="ESG评价">ESG评价</Option>
</Select>
</Form.Item>
<Form.Item name="一级行业">
<Input placeholder="行业" style={{ width: 150, marginBottom: 20 }} />
</Form.Item>
<Button type="primary" htmlType="submit">
检索
</Button>
</Form>
<Button
type="primary"
onClick={this.setVisible}
@ -177,6 +225,40 @@ class Threshold extends Component {
新增问卷
</Button>
</Row>
{
this.state.questionnaire['问卷内容'] ? <Card title={this.state.questionnaire['行业']} extra={<><Space><Tag color="#108ee9">{this.state.questionnaire['评价类型']}</Tag><Tag color="#87d068">ID:{this.state.questionnaire['ID']}</Tag></Space></>}>
<Tag color="#108ee9" style={{ marginBottom: 20 }}>经营问卷</Tag>
<p>{this.state.questionVisible.map((item, index) => {
return <Tag color={!item.disabled ? '#f50' : '#909399'} style={{ marginBottom: 20, cursor: 'pointer' }} onClick={this.onChangeDisabled.bind(this, index)}>{item.name}</Tag>
})}</p>
{this.state.questionnaire['问卷内容'] && this.state.questionnaire['问卷内容'].map((item, i) => {
if (i !== 0) {
sum = sum + this.state.questionnaire['问卷内容'][i - 1].children.length;
}
if (!this.state.questionVisible[i].disabled) {
return <p>
{item.children.map((child, j) => {
return <>
<p><span>{child.label}</span></p>
<p>
{child.type === '单选题' ? child.option.map(e => {
return <span style={{ color: '#108ee9', marginRight: 10 }}>{e.index}.{e.label}</span>
}) : child.type === '多选题' ? child.option.map((e) => {
return <span style={{ color: '#108ee9', marginRight: 10 }}>{e.index}.{e.label}</span>
}) : <span style={{ color: '#108ee9', marginRight: 5 }}>单位{child.unit}</span>
}
</p>
</>
})}
</p>
} else {
return null
}
})
}
</Card> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="请检索" />
}
</>
)
}