|
@@ -89,7 +89,35 @@ class ReportDetail extends Component {
|
|
|
}
|
|
|
// AI一键生成
|
|
|
getGeneratePlus = () => {
|
|
|
- const { chapters, reportName } = this.state.data;
|
|
|
+ const { chapters } = this.state;
|
|
|
+ if (!chapters.length) {
|
|
|
+ let defaultChapters = ["国内外研究现状与发展趋势", "立项背景与意义", "项目主要研究内容"];
|
|
|
+ let chaptersArr = [];
|
|
|
+ defaultChapters.map((item, idx) => {
|
|
|
+ let obj = this.state.chapterType.find(typeItem => item == typeItem.title);
|
|
|
+ let chapterData = {
|
|
|
+ chapterType: obj.key,
|
|
|
+ content: "",
|
|
|
+ fullTitle: this.getTitleWithChineseNum(idx, obj.title),
|
|
|
+ keywords: obj.keywords,
|
|
|
+ title: obj.title,
|
|
|
+ };
|
|
|
+
|
|
|
+ chaptersArr.push(chapterData);
|
|
|
+ });
|
|
|
+ this.setState({ chapters: chaptersArr }, () => {
|
|
|
+ this.requestGeneratePlus();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.requestGeneratePlus();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ requestGeneratePlus() {
|
|
|
+ const { chapters } = this.state;
|
|
|
+ const { reportName } = this.state.data;
|
|
|
+
|
|
|
const allTitle = chapters.map(item => item.title);
|
|
|
const payload = {
|
|
|
chapterTitle: allTitle.join(","),
|
|
@@ -101,7 +129,6 @@ class ReportDetail extends Component {
|
|
|
})
|
|
|
|
|
|
this.props.generatePlus(payload).then((res) => {
|
|
|
- console.log(res)
|
|
|
Taro.hideLoading()
|
|
|
chapters.forEach(item => {
|
|
|
item.content = marked.parse(res[item.title])
|
|
@@ -112,7 +139,8 @@ class ReportDetail extends Component {
|
|
|
Taro.hideLoading()
|
|
|
})
|
|
|
}
|
|
|
- // Al生成
|
|
|
+
|
|
|
+ // AI生成
|
|
|
getGenerate(title, i) {
|
|
|
const { data } = this.state
|
|
|
let payload = {
|
|
@@ -199,7 +227,7 @@ class ReportDetail extends Component {
|
|
|
keywords: obj.keywords,
|
|
|
title: obj.title,
|
|
|
}
|
|
|
- list.push(data)
|
|
|
+ list.push(data);
|
|
|
this.setState({
|
|
|
chapters: list
|
|
|
})
|