This commit is contained in:
xuyucheng 2022-05-20 13:57:33 +08:00
parent 01dcb93cb6
commit 02643e95a7
4 changed files with 93 additions and 28 deletions

View File

@ -24,7 +24,7 @@ class AnalysisDetails extends Component {
api.post("/admin/manage/industry/get_primary_industry_data", { 行业: this.props.value })
.then(res => {
this.setState({
data: res
data: res.result
})
}).catch(err => {
console.log(err)

View File

@ -4,6 +4,11 @@ import api from "@/api/request"
import FeTable from "@/components/table"
import { UploadOutlined } from '@ant-design/icons';
var status = {
name: '',
sort: ''
}
class IndustryData extends Component {
constructor(props) {
super(props)
@ -11,31 +16,36 @@ class IndustryData extends Component {
data: [],
columns: [],
MacroDataVisible: false,
total: 0,
form: {
search: {},
sort: {},
page_no: 1,
page_size: 10
},
}
}
componentDidMount() {
this.onSearch("")
this.init()
}
onSearch = (value) => {
api.post("/admin/macro/search_macro_data", {
"一级行业": value['一级行业'],
"skip": 1,
"limit": 10
}).then(res => {
init = () => {
api.post("/admin/macro/search_macro_data", this.state.form).then(res => {
if (res.result.total !== 0) {
this.setState({
data: res.result.data,
columns: Object.keys(res.result.data[0]).map((key, i) => {
total: res.result.total,
data: res.result.records,
columns: Object.keys(res.result.records[0]).map((key, i) => {
return key === "数据" || key === "数据单位" ? {
title: key+"(回车修改)",
title: key + "(回车修改)",
dataIndex: key,
key: i,
align: 'center',
render: (record) => <Input defaultValue={record} onPressEnter={this.onEdit.bind(this,key)}></Input>,
sorter: (a, b, c) => { this.sort(c, key) }, defaultSortOrder: 'descend',
render: (record) => <Input value={record} onPressEnter={this.onEdit.bind(this, key)}></Input>,
} : {
title: key, dataIndex: key, align: 'center', key: i
title: key, dataIndex: key, align: 'center', key: i,sorter: (a, b, c) => { this.sort(c, key) }, defaultSortOrder: 'descend',
}
})
})
@ -50,6 +60,39 @@ class IndustryData extends Component {
})
}
onSearch = (value) => {
const search = { search: {}, page_no: 1 }
value && Object.keys(value).forEach(key => {
if (value[key] && value[key].length !== 0) {
search.search[key] = value[key]
}
})
this.setState({
form: Object.assign(this.state.form, search)
}, () => {
this.init()
})
}
sort = (c, item, search) => {
if (status.name === item && status.sort === c) {
return false
} else {
status = {
name: item,
sort: c
}
this.setState({
form: Object.assign(this.state.form, {
sort: { [item]: c === 'ascend' ? 'asc' : 'desc' }
})
}, () => {
this.onSearch()
})
}
}
macroDataForm = React.createRef()
setMacroDataVisible = () => {
@ -69,6 +112,7 @@ class IndustryData extends Component {
api.post("/admin/macro/upload_macro_data", form)
.then(res => {
message.success(res.info)
this.init()
}).catch(err => {
console.log(err)
})
@ -76,17 +120,38 @@ class IndustryData extends Component {
editValue = {}
callback(value) {
callback(e,value) {
this.editValue = value
}
onEdit(key,e){
onEdit(key, e) {
this.editValue[key] = e.target.value
api.post("/admin/macro/edit_macro_data",this.editValue).then(res=>{
api.post("/admin/macro/edit_macro_data", this.editValue).then(res => {
message.success(res.info)
})
}
pageChange = (current, pageSize) => {
this.setState({
form: Object.assign(this.state.form, {
page_no: current,
page_size: pageSize
})
}, () => {
this.init()
})
}
onShowSizeChange = (current, pageSize) => {
this.setState({
form: Object.assign(this.state.form, {
page_no: current,
page_size: pageSize
})
}, () => {
this.init()
})
}
render() {
return (
@ -143,11 +208,9 @@ class IndustryData extends Component {
>
上传宏观数据
</Button>
</Space>
</Row>
<FeTable data={this.state.data} columns={this.state.columns} callback={this.callback.bind(this)}></FeTable>
<FeTable data={this.state.data} columns={this.state.columns} current={this.state.form.page_no} callback={this.callback.bind(this)} total={this.state.total} pageChange={this.pageChange.bind(this)} onShowSizeChange={this.onShowSizeChange.bind(this)} />
</React.Fragment>
)
}

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react';
import { Row, Input, Button, Form, Upload, Modal, notification, Space } from "antd";
import { Row, Input, Button, Form, Upload, Modal, notification, Space, message } from "antd";
import api from "@/api/request"
import FeTable from "@/components/table"
import { UploadOutlined} from '@ant-design/icons';
@ -19,22 +19,20 @@ class IndustryReport extends Component {
macroFileForm = React.createRef()
componentDidMount() {
this.onSearch({industry:"",time:""})
}
componentDidMount() {}
onSearch = (value) => {
api.post("/admin/macro/search_macroscopic_report", {
"industry": value.industry,
"time": value.time,
"skip": 1,
"limit": 10
// "time": value.time,
// "skip": 1,
// "limit": 10
}).then(res => {
if (res.result.total !== 0) {
this.setState({
data: res.result.data,
columns: Object.keys(res.result.data[0]).map((key, i) => {
data: res.result,
columns: Object.keys(res.result[0]).map((key, i) => {
return key === "报告fid" ? {
title: key,
dataIndex: key,
@ -45,6 +43,8 @@ class IndustryReport extends Component {
title: key, dataIndex: key, align: 'center', key: i
}
})
},()=>{
message.info(res.info)
})
} else {
this.setState({

View File

@ -51,6 +51,8 @@ class Threshold extends Component {
.then(res => {
this.setState({
questionnaire: res.data?res.data:{}
},()=>{
message.info(res.info)
})
})
.catch((err)=>{