From 074963d86ffb5076c462a4b71f2d153b0638410b Mon Sep 17 00:00:00 2001 From: xuyucheng Date: Fri, 18 Mar 2022 15:49:54 +0800 Subject: [PATCH] mode --- .../branch/manage/company/companyDetails.js | 1 - .../branch/manage/industry/branch/analysis.js | 1 - .../branch/manage/rate/branch/editReport.js | 155 ++++++++++++++---- .../branch/manage/rate/branch/fillDetails.js | 86 +++++++++- .../branch/manage/rate/branch/rateProcess.js | 3 - .../branch/manage/rate/branch/rateResult.js | 59 ++++--- .../branch/manage/rate/branch/riskData.js | 16 +- src/pages/home/content.js | 1 - 8 files changed, 248 insertions(+), 74 deletions(-) diff --git a/src/pages/home/branch/manage/company/companyDetails.js b/src/pages/home/branch/manage/company/companyDetails.js index 722a6ea..97c1687 100644 --- a/src/pages/home/branch/manage/company/companyDetails.js +++ b/src/pages/home/branch/manage/company/companyDetails.js @@ -70,7 +70,6 @@ class CompanyDetails extends Component { } handleClick(value) { - console.log(value) this.isJump = true this.setState({ visible: true, diff --git a/src/pages/home/branch/manage/industry/branch/analysis.js b/src/pages/home/branch/manage/industry/branch/analysis.js index 001b4af..bcd48d1 100644 --- a/src/pages/home/branch/manage/industry/branch/analysis.js +++ b/src/pages/home/branch/manage/industry/branch/analysis.js @@ -71,7 +71,6 @@ class IndustryAnalysis extends Component { onSubmit = () => { const form = this.form.current - console.log(form.getFieldsValue()) const data = { "行业": form.getFieldsValue()['行业'], "行业简介": form.getFieldsValue()['行业简介'], diff --git a/src/pages/home/branch/manage/rate/branch/editReport.js b/src/pages/home/branch/manage/rate/branch/editReport.js index 2faef76..c240c8e 100644 --- a/src/pages/home/branch/manage/rate/branch/editReport.js +++ b/src/pages/home/branch/manage/rate/branch/editReport.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import api from "@/api/request" -import { Input, Button, Row, Col, Tree, BackTop, Tag, Empty } from 'antd' +import { Input, Button, Row, Col, Tree, BackTop, Tag, Empty, message } from 'antd' import "@/assets/style/editReport.css" class EditReport extends Component { @@ -8,7 +8,8 @@ class EditReport extends Component { super(props) this.state = { data: [], - tree: [] + tree: [], + type: 0 } } @@ -17,13 +18,15 @@ class EditReport extends Component { api.post(url, { rid: this.props.value.rid }) .then(res => { this.setState({ - data: res.result['text_model']?res.result['text_model']:[], - tree: res.result['text_model']?this.createTree(res.result):[] + data: res.result['text_model'] ? res.result['text_model'] : [], + tree: res.result['text_model'] ? this.createTree(res.result) : [], + type: this.props.value.types === "综合评价流程" ? 0 : 1 }) }) } createTree = (val) => { + if (this.props.value.types === "综合评价流程") { const data = val['text_model'].map((item, index) => { return { title: item['章节'], key: index.toString(), children: item["章节内容"].map((item_1, index_1) => { @@ -36,6 +39,18 @@ class EditReport extends Component { } }) return data + } else { + const data = val['text_model'].map((item, index) => { + return { + title: item['章节'], key: index.toString(), children: item["章节内容"].map((_, index_1) => { + return { + title: "段落", key: index.toString() + index_1.toString() + } + }) + } + }) + return data + } } onSelect = (value) => { @@ -90,51 +105,89 @@ class EditReport extends Component { } onFinish = () => { - api.post("/admin/rating/report_edit_save_delete", { rid: this.props.id, text_model: this.state.data }) + const url = this.state.type === 0 ? "/admin/rating/report_edit_save_delete" : "/admin/rating/esg_report_edit_save_delete" + const form = { + cid: this.props.value.cid, + rid: this.props.value.rid, + text_model: this.state.data + } + api.post(url, form) .then(res => { - console.log(res) + message.info(res.info) }) } onOutput = (a, b, c, d, e) => { - const data = this.state.data.filter((item, i) => { - if (a === i) { - return item["章节内容"].filter((ele, j) => { - if (b === j) { - return ele["小节内容"].filter((child, m) => { - if (c === m) { - return Object.keys(child).filter((key, index) => { - if (d === index) { - return child[key] = e.target.value - } else { - return child[key] - } - }) + if (this.state.type === 0) { + const data = this.state.data.filter((item, i) => { + if (a === i) { + return item["章节内容"].filter((ele, j) => { + if (b === j) { + return ele["小节内容"].filter((child, m) => { + if (c === m) { + return Object.keys(child).filter((key, index) => { + if (d === index) { + return child[key] = e.target.value + } else { + return child[key] + } + }) + } else { + return child + } + }) + } else { + return ele + } + }) + } else { + return item + } + }) + + this.setState({ + data: data + }) + } else { + if (typeof b !== 'number') { + const data = this.state.data.filter((item, i) => { + if (a === i) { + return item['章节'] = b.target.value + } else { + return item + } + }) + + this.setState({ + data + }) + } else { + const data = this.state.data.filter((item, i) => { + if (a === i) { + return item['章节内容'].filter((ele, j) => { + if (b === j) { + return ele['段落'] = c.target.value } else { - return child + return ele } }) } else { - return ele + return item } }) - } else { - return item - } - }) - this.setState({ - data: data - }) + this.setState({ + data + }) + } + } + } render() { - - return ( - {this.state.data.length !== 0 ? <> -
UP
+ {this.state.data.length !== 0 && this.state.type === 0 ? <>
UP
- : } + : this.state.data.length !== 0 && this.state.type === 1 ? + <> +
UP
+ + + + {this.state.data.map((item, i) => { + return +

章节

+

+ +

+

章节内容

+ {item["章节内容"].map((item_child, j) => { + return <> +

段落

+

+ +

+ + })} +
+ })} + +
+ + : }
) } diff --git a/src/pages/home/branch/manage/rate/branch/fillDetails.js b/src/pages/home/branch/manage/rate/branch/fillDetails.js index 3f5c423..7f22cbc 100644 --- a/src/pages/home/branch/manage/rate/branch/fillDetails.js +++ b/src/pages/home/branch/manage/rate/branch/fillDetails.js @@ -7,8 +7,9 @@ class FillDetails extends Component { constructor(props) { super(props) this.state = { - data: [], - financialFill: {} + data: {}, + financialFill: {}, + type: 0 } } @@ -17,8 +18,8 @@ class FillDetails extends Component { api.post(url, { rid: this.props.value.rid }) .then(res => { this.setState({ - data: res.result.length !== 0 ? res.result[0] : [], - financialFill: res.result.length !== 0 ? res.result[0]['财务填报'] : [] + data: res.result.length !== 0 ? res.result[0] : {}, + type: this.props.value.types === "综合评价流程" ? 0 : 1 }) }).catch(err => { console.log(err) @@ -84,18 +85,89 @@ class FillDetails extends Component { } } + analysisArray = (params) => { + + var columns = [] + const matrixData = params.map((row) => { + var arr = []; + for (var i in row) { + columns.push(i) + arr.push(row[i]); + } + return arr; + }); + + const transData = matrixData[0].map((col, i) => { + return [ + columns[i], + ...matrixData.map((row) => { + return row[i]; + }), + ]; + }); + + const transTitle = transData[0].map((item, i) => { + return { + title: item, dataIndex: item, align: 'center', key: i + } + } + ); + + const data = transData.map((item, i) => { + var obj = {} + item.forEach((child, j) => { + Object.assign(obj, { + [transTitle[j].title]: child, + key: j + }) + }) + return obj + }) + + data.shift() + + return 近三年企业数据 + + } + render() { return ( - {this.state.data.length!==0 ? <> + {this.state.data && this.state.type === 0 ? <> 企业ID:{this.state.data["企业ID"]}}>

评价年度:{this.state.data["评价年度"]}{(() => { if ("行业选择" in this.state.data && this.state.data["行业选择"] !== null) { return this.state.data["行业选择"].join("/") } else { return null } })()}

经营问卷 {this.analysisQuestion(this.state.data["经营问卷"])} - {this.analysisObject(this.state.financialFill)} - : } + {this.state.data['财务填报'] && this.analysisObject(this.state.data['财务填报'])} + + : this.state.data && this.state.type === 1 ? + <> + 企业ID:{this.state.data["企业ID"]}}> +

评价年度:{this.state.data["评价年度"]}{(() => { if ("所属行业" in this.state.data && this.state.data["所属行业"] !== null) { return this.state.data["所属行业"].join("/") } else { return null } })()}

+ 公司当年收入(万元) + + {this.state.data['公司当年收入(万元)'] && Object.keys(this.state.data['公司当年收入(万元)']).map((key, i) => { + return {this.state.data["公司当年收入(万元)"][key]} + })} + + { + ['环境问卷', '社会问卷', '治理问卷'].map(item => { + return <>{item} +
其他类型问卷
+ + {this.state.data[item]['其他类型问卷'].map((key, i) => { + return {key} + })} + + {this.state.data[item] && this.state.data[item]['近三年公司数据'] && this.analysisArray(this.state.data[item]['近三年公司数据'])} + + + }) + } + + : }
) diff --git a/src/pages/home/branch/manage/rate/branch/rateProcess.js b/src/pages/home/branch/manage/rate/branch/rateProcess.js index b42bdd1..554eed1 100644 --- a/src/pages/home/branch/manage/rate/branch/rateProcess.js +++ b/src/pages/home/branch/manage/rate/branch/rateProcess.js @@ -13,15 +13,12 @@ class RateProcess extends Component { } componentDidMount() { - console.log(this.props) api.post("/admin/rating/get_company_process", this.state.form) .then(res => { this.setState({ data: res.info }, () => { - console.log(this.state.data) }) - console.log(res) }) } diff --git a/src/pages/home/branch/manage/rate/branch/rateResult.js b/src/pages/home/branch/manage/rate/branch/rateResult.js index 54ff9eb..3b802d2 100644 --- a/src/pages/home/branch/manage/rate/branch/rateResult.js +++ b/src/pages/home/branch/manage/rate/branch/rateResult.js @@ -7,6 +7,7 @@ class RateResult extends Component { super(props) this.state = { data: {}, + type: 0, } } @@ -16,6 +17,7 @@ class RateResult extends Component { .then(res => { this.setState({ data: res.result[0], + type: this.props.value.types === "综合评价流程" ? 0 : 1 }) }).catch(err => { console.log(err) @@ -26,7 +28,7 @@ class RateResult extends Component { render() { return ( - {this.state.data ? <> + {this.state.data && this.state.type === 0 ? <> 企业ID:{this.state.data["企业ID"]}} style={{ marginTop: 20 }}> {Object.keys(this.state.data).map((key, i) => { if (!['经营评分', '财务评分', '风险评分', "企业ID", "企业名称"].includes(key)) { @@ -45,29 +47,13 @@ class RateResult extends Component { 财务评分 - - {this.state.data["财务评分"] && Object.keys(this.state.data["财务评分"]["盈利能力"]).map((key, i) => { - return {this.state.data["财务评分"]["盈利能力"][key]} - })} - - - {this.state.data["财务评分"] && Object.keys(this.state.data["财务评分"]["债务风险"]).map((key, i) => { - return {this.state.data["财务评分"]["债务风险"][key]} - })} - - - {this.state.data["财务评分"] && Object.keys(this.state.data["财务评分"]["经营增长"]).map((key, i) => { - return {this.state.data["财务评分"]["经营增长"][key]} - })} - - - {this.state.data["财务评分"] && Object.keys(this.state.data["财务评分"]["资产质量"]).map((key, i) => { - return {this.state.data["财务评分"]["资产质量"][key]} - })} - - - {this.state.data["财务评分"] && this.state.data["财务评分"]["合计"]} - + {['盈利能力', '债务风险', '经营增长', '资产质量', '财务合计'].map(item => { + return + {this.state.data["财务评分"] && this.state.data["财务评分"][item] && Object.keys(this.state.data["财务评分"][item]).map((key, i) => { + return {this.state.data["财务评分"][item][key]} + })} + + })} 风险评分 @@ -92,7 +78,30 @@ class RateResult extends Component { {this.state.data["风险评分"] && this.state.data["风险评分"]["合计"]} - : } + + : this.state.data && this.state.type === 1 ? + <> + 企业ID:{this.state.data["企业ID"]}} style={{ marginTop: 20 }}> + {Object.keys(this.state.data).map((key, i) => { + if (!['公司治理得分', '环境得分', '社会得分'].includes(key)) { + return {this.state.data[key]} + } else { + return null + } + })} + + {['公司治理得分', '环境得分', '社会得分'].map(item => { + return <> + {item} + + {this.state.data[item] && Object.keys(this.state.data[item]).map((key, i) => { + return {this.state.data[item][key]} + })} + + + })} + + : } ) } diff --git a/src/pages/home/branch/manage/rate/branch/riskData.js b/src/pages/home/branch/manage/rate/branch/riskData.js index b22e15a..31427ad 100644 --- a/src/pages/home/branch/manage/rate/branch/riskData.js +++ b/src/pages/home/branch/manage/rate/branch/riskData.js @@ -6,7 +6,8 @@ class RiskData extends Component { constructor(props) { super(props) this.state = { - data: [] + data: {}, + type: 0 } } @@ -15,7 +16,8 @@ class RiskData extends Component { api.post(url, { rid: this.props.value.rid }) .then(res => { this.setState({ - data: res.result.length !== 0 ? res.result[0] : [] + data: res.result.length !== 0 ? res.result[0] : {}, + type: this.props.value.types === "综合评价流程" ? 0 : 1 }) }).catch(err => { console.log(err) @@ -50,7 +52,15 @@ class RiskData extends Component { render() { return ( - {this.state.data.length !== 0 ? this.analysisObject(this.state.data) : } + {this.state.data && this.state.type === 0 ? this.analysisObject(this.state.data) : this.state.data && this.state.type === 1 ? + <> + 更新日期:{this.state.data["更新日期"]}}> + {Object.keys(this.state.data).map((key, i) => { + return ["更新日期","企业ID","评价ID"].includes(key) ? null : {this.state.data[key]} + })} + + + : } ) } diff --git a/src/pages/home/content.js b/src/pages/home/content.js index ee5a172..e691afb 100644 --- a/src/pages/home/content.js +++ b/src/pages/home/content.js @@ -92,7 +92,6 @@ class Main extends Component { } getBranch = (props, name, params) => { - console.log(params) switch (props) { case '/dashboard': return