Browse Source

版本恢复

chenlei 1 tháng trước cách đây
mục cha
commit
ed855c1fe5

+ 38 - 3
src/api/modules/reportV2.js

@@ -124,10 +124,45 @@ export const reportV2Interface = {
 	 */
 	readReportNotice: params => {
 		return http.post('/report/message/read',params)
-	}
-
-
+	},
 
+	/**
+	 * * 获取报告的标签列表
+	 * @param {*ReportId} params 
+	 * @param {*ReportChapterId} params 
+	 * @returns 
+	 * */
+	reportHistoryList: params => {
+		return http.get('/report_history/list',params)
+	},
+	/**
+	 * * 获取报告的标签列表
+	 * @param {*ReportId} params 
+	 * @param {*id} params 
+	 * @returns 
+	 * */
+	reportHistoryDetail: params => {
+		return http.get('/report_history/detail',params)
+	},
+	
+	/**
+	 * * 删除报告记录
+	 * @param {*ReportId} params 
+	 * @param {*Id} params 
+	 * @returns 
+	 * */
+	reportHistoryDel: params => {
+		return http.post('/report_history/del',params)
+	},
+	/**
+	 * * 恢复报告记录
+	 * @param {*ReportId} params 
+	 * @param {*Id} params 
+	 * @returns
+	 * */
+	reportHistoryRevert: params => {
+		return http.post('/report_history/revert',params)
+	},
 }
 
 

+ 2 - 0
src/lang/modules/ReportManagement/ReportList.js

@@ -38,6 +38,7 @@ export const ReportListEn = {
   last_save_time: "Last save time",
   click_clear_btn: "Clear Content",
   click_refresh_btn: "Rfrsh",
+  version_record: "Version record",
   preview_btn: "Preview",
   save_draft_btn: "Draft",
   scheduled_publish_btn: "Schedule",
@@ -210,6 +211,7 @@ export const ReportListZh = {
   last_save_time: "最近保存时间",
   click_clear_btn: "一键清空内容",
   click_refresh_btn: "一键刷新",
+  version_record: "版本记录",
   preview_btn: "预览",
   save_draft_btn: "存草稿",
   scheduled_publish_btn: "定时发布",

+ 7 - 0
src/views/report_manage/reportV2/components/reportEditHeader.vue

@@ -12,6 +12,13 @@
               <img src="~@/assets/img/smartReport/back.png" alt="">
               <span>返回列表</span>
           </li>
+          <li 
+            class="action-item" 
+            @click="$emit('handleVersionRecord')"
+            >
+              <img src="~@/assets/img/smartReport/icon01.png" alt="">
+              <span>{{$t('ReportManage.ReportList.version_record')}}</span>
+          </li>
           <li v-if="!reportInfo.ReportChapterId" class="action-item" @click="$emit('openBaseInfo')">
               <img src="~@/assets/img/smartReport/icon01.png" alt="">
               <span>{{$t('ReportManage.ReportList.information_title')}}</span>

+ 200 - 0
src/views/report_manage/reportV2/normalReport/components/VersionRecord.vue

@@ -0,0 +1,200 @@
+<template>
+  <div class="statistic-analysis-wrap">
+      <div class="top-box">
+          <div class="right">
+            版本记录
+          </div>
+          <div class="left">
+              <div class="search-box">
+                  <el-switch
+                    v-model="OnlyMine"
+                    @change="handleChangeIsOnlyMine"
+                    active-text="仅显示我保存的版本">
+                  </el-switch>
+              </div>
+          </div>
+      </div>
+      <div class="main-box">
+          <div class="list-wrap" v-infinite-scroll="handleLoadMore" :infinite-scroll-immediate="true">
+              <div class="chart-item" v-for="item in list" :key="item.SandboxId">
+                  <div class="top">
+                    <div class="title">{{ item.Title }}</div>
+                    <div class="time">{{ item.CreateTime }}</div>
+                  </div>
+                  <div class="bottom">
+                    <div class="name">{{item.AdminName}}</div>
+                    <div class="operation">
+                      <span @click="preview(item.Id)">预览</span>
+                      <span @click="$emit('handleRestore', item.Id)">恢复</span>
+                      <span class="delete" @click="deleteVersionRecord(item.Id)">删除</span>
+                    </div>
+                  </div>
+              </div>
+              <tableNoData :text="$t('Table.prompt_slogan')" style="width: 100%;" size="mini" v-if="list.length===0&&finished"/>
+          </div>
+      </div>
+  </div>
+</template>
+
+<script>
+import { reportV2Interface } from '@/api/modules/reportV2';
+export default {
+  props:{
+    selectChapterId:{
+        type:Number,
+        default:0
+    }
+  },
+  data() {
+      return {
+          list:[],
+          page:1,
+          pageSize:10,
+          finished:false,
+          loading:false,
+          OnlyMine:false,      
+      }
+  },
+  created(){
+      this.getSandBoxList()
+  },
+  methods: {
+      /* 搜索版本记录分页 */
+      async getSandBoxList(word) {
+           this.$route.query.coopType
+          let params = {
+              CurrentIndex: this.page,
+              PageSize: this.pageSize,
+          };
+          if (this.$route.query.coopType == '1') {
+              params.ReportId = this.$route.query.id;
+          } else {
+              params.ReportChapterId = this.selectChapterId + '';
+          }
+          this.loading=true
+          let res = await reportV2Interface.reportHistoryList(params);
+          this.loading=false
+          if (res.Ret !== 200) return;
+          const arr = res.Data.List || [];
+          this.list =
+              this.page === 1
+              ? arr
+              : [...this.list, ...arr];
+          this.finished =  res.Data.Paging.IsEnd;
+      },
+      // 是否仅显示我保存的版本
+      handleChangeIsOnlyMine(val) {
+          this.page = 1;
+          this.list = [];
+          this.getSandBoxList();
+      },
+      handleLoadMore(){
+          if(this.finished||this.loading) return
+          this.page++
+          this.getSandBoxList()
+      },
+      // 预览
+      preview(id){
+        let { href } = this.$router.resolve({ 
+            path: '/reportdtlV2',
+            query:{
+                id,
+                isVersionRecord:'true'
+            }
+            
+        });
+        window.open(href, '_blank');
+      },
+      // 删除弹窗
+      deleteVersionRecord(Id){
+          this.$confirm('删除后不可恢复,是否确认删除该版本?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+              this.deleteItem(Id)
+          }).catch(() => {
+          });
+      },
+      deleteItem(Id) {
+          reportV2Interface.reportHistoryDel({
+              Id
+          }).then((res) => {
+              if(res.Ret !== 200) return
+              this.$message.success('删除成功!');
+              this.getSandBoxList();
+          });
+      },
+  },
+}
+</script>
+
+<style lang="scss" scoped>
+div{
+  box-sizing: border-box;
+}
+.statistic-analysis-wrap{
+  margin-top: 10px;
+  border: 1px solid var(--gary-gy-5-line, #C8CDD9);
+  background: #FFF;
+  .top-box{
+      padding: 20px 20px 0 20px;
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+  }
+  .main-box{
+      padding: 20px;
+      height: calc(100vh - 180px);
+      border-radius: 4px;
+      display: flex;
+      flex-direction: column;
+      .list-wrap{
+          flex: 1;
+          overflow-y: auto;
+          // display: flex;
+          // flex-wrap: wrap;
+          gap: 0 20px;
+
+      }
+  }
+}
+.chart-item {
+  width: 100%;
+  max-height: 100px;
+  margin: 10px 0;
+  padding: 20px;
+  border: 1px solid #eaeaea;
+  border-radius: 10px;
+  font-size: 16px;
+  text-align: center;
+  .top {
+    display: flex;
+    justify-content: space-between;
+    .title {
+      line-height: 20px;
+      font-size: 18px;
+      color: #333333;
+    }
+    .time {
+      line-height: 20px;
+      color: #666666;
+    }
+  }
+  .bottom {
+    margin-top: 10px;
+    display: flex;
+    justify-content: space-between;
+    .name {
+      color: #333333;
+    }
+    .operation {
+      cursor: pointer;
+      color: #0052D9;
+      .delete {
+        color: #D54941;
+      }
+    }
+  }
+}
+</style>

+ 7 - 2
src/views/report_manage/reportV2/normalReport/components/insertContent.vue

@@ -19,7 +19,8 @@
     <ETASandBox v-if="actTab==='etaSandBox'" @insertHtml="item=>{$emit('insertHtml',{item,type:'image'})}"/>
     <!-- 语义分析 -->
     <SemanticAnalysis v-if="actTab==='semanticAnalysis'" @insertHtml="item => {$emit('insertHtml',{item,type:'image'})}"/>
-
+    <!-- 版本记录 -->
+    <VersionRecord v-if="actTab==='versionRecord'" :selectChapterId="selectChapterId" @handleRestore="handleRestore"/>
   </div>
 </template>
 <script>
@@ -29,13 +30,14 @@ import StatisticAnalysis from './StatisticAnalysis.vue'
 import ETAPriceChart from './ETAPriceChart.vue'
 import ETASandBox from './ETASandBox.vue'
 import SemanticAnalysis from './SemanticAnalysis.vue'
+import VersionRecord from './VersionRecord.vue'
 export default {
   props: {
     actTab: {
       type: String
     }
   },
-  components: {ETAChart,ETASheet,StatisticAnalysis,ETAPriceChart,ETASandBox,SemanticAnalysis  },
+  components: {ETAChart,ETASheet,StatisticAnalysis,ETAPriceChart,ETASandBox,SemanticAnalysis,VersionRecord},
   data() {
     return {
     }
@@ -43,6 +45,9 @@ export default {
   methods: {
       handleImportMyChart(list){
           this.$emit('handleImportMyChart',list)
+      },
+      handleRestore(data){
+          this.$emit('handleRestore',data)
       }
   }
 }

+ 43 - 9
src/views/report_manage/reportV2/normalReport/editReport.vue

@@ -50,7 +50,8 @@
 						@openBaseInfo="showReportBaseInfo=true"
 						@handleRefreshAllChart="refreshReport"
 						@handlePreviewReport="reportInfo.ReportChapterId?handlePreviewChapter():handlePreviewReport()"
-						@handleSaveContent="reportInfo.ReportChapterId?handleAutoSaveChapter('save'):handleAutoSave('save')"
+						@handleVersionRecord="handleVersionRecord()"
+						@handleSaveContent="reportInfo.ReportChapterId?handleAutoSaveChapter('save'):handleAutoSave('save',true)"
 						@handlePublishOpt="(type) =>{reportInfo.ReportChapterId?handlePublishChapter():handlePublishReport(type)}"
 						@update="()=>{$refs.chapterContRef&&$refs.chapterContRef.getChapterList()}"
 					/>
@@ -78,6 +79,7 @@
 							@slide="activeTab=''"
 							@insertHtml="insertHtml"
 							@handleImportMyChart="handleImportMyChart"
+							@handleRestore="handleRestore"
 						/>
 						
 					</div>
@@ -192,7 +194,7 @@ export default {
 		if(this.reportCoopType===1) {	
 			this.getreportdetail();
 			this.timer = setInterval(() => {
-				this.handleAutoSave();
+				this.handleAutoSave('', false);
 			}, 6000);
 		}
 
@@ -234,13 +236,13 @@ export default {
 			$('.editor-wrapper')[0].scrollTop = 0;
 			if(this.editChapterId) {
 				this.timer = setInterval(() => {
-					this.handleAutoSaveChapter();
+					this.handleAutoSaveChapter('');
 				}, 6000);
 			}
 		},
 
 		/* 章节自动保存 存草稿*/
-		async handleAutoSaveChapter(type='auto') {
+		async handleAutoSaveChapter(type) {
 			
 			if(!this.reportInfo.ReportChapterId||!this.editChapterId) return
 
@@ -256,7 +258,8 @@ export default {
 				const res = await saveChapterReport({
 					ReportChapterId: this.reportInfo.ReportChapterId,
 					// Title: this.reportInfo.Title,
-					Content: $('.fr-element').html()
+					Content: $('.fr-element').html(),
+					IsManualSave: type === '' ? false : true    //是否手动保存
 				})
 				if(res.Ret !== 200) return
 				resolve(true)
@@ -365,7 +368,7 @@ export default {
 		},
 
 		// 每十秒自动保存 存草稿
-		handleAutoSave(type='auto') {
+		handleAutoSave(type='auto', IsManualSave) {
 
 			if(!this.autoSaveFlag) return
 			//如果富文本中有未上传完成的图片,去除这个dom
@@ -374,7 +377,8 @@ export default {
 				autosave({
 					ReportId: Number(this.$route.query.id),
 					Content: $('.fr-element').html(),
-					NoChange:this.ischange?0:1
+					NoChange:this.ischange?0:1,
+					IsManualSave
 				}).then((res) => {
 					if (res.Ret === 200) {
 						resolve(true)
@@ -389,7 +393,7 @@ export default {
 
 		/* 报告详情 */
 		async getreportdetail() {
-			
+
 			const res = await reportdetail({ ReportId: parseInt(this.report_id) })
 
 			if (res.Ret !== 200) return
@@ -409,7 +413,7 @@ export default {
 		/* 发布报告 */
 		async handlePublishReport(tp) {
 
-			const saveRes = await this.handleAutoSave('auto');
+			const saveRes = await this.handleAutoSave('auto', true);
 			if(!saveRes) return
 
 			if(tp==='dsfb'){
@@ -567,6 +571,36 @@ export default {
 				
 				this.$store.commit('SET_DYNAMIC_LINK',res.Data)
 		},
+		async handleVersionRecord() {
+			this.showRight=true 
+            this.activeTab = 'versionRecord';
+		},
+		/* 恢复版本 */
+		handleRestore(Id) {
+            this.$confirm('确认将报告恢复到该版本吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                this.reportHistoryRevert(Id)
+            }).catch(() => {
+            });
+        },
+        /* 恢复版本报告请求 */
+        async reportHistoryRevert(Id) {
+			const _this = this;
+            const res = await reportV2Interface.reportHistoryRevert({Id})
+			if(res.Ret !== 200) return
+			_this.$message.success('恢复成功!');
+			if (_this.$route.query.coopType === '1') {
+				_this.getReportDetail()
+				console.log(44555);
+			} else {
+				console.log(2222);
+				_this.getChapterDetail()
+			}
+        },
+
 	},
 };
 </script>

+ 24 - 11
src/views/report_manage/reportV2/normalReport/reportdtl.vue

@@ -35,7 +35,7 @@
 			<div v-html="configInfo.Disclaimer"></div>
 		</div>
 
-		<div v-if="linkUrl" style="width:100px;height30px;position:absolute;right:-100px;top:100px;cursor:pointer;">
+		<div v-if="linkUrl" style="width:100px;height:30px;position:absolute;right:-100px;top:100px;cursor:pointer;">
 			<div v-permission="$route.query.fromPage==='en'
                 ?permissionBtn.enReportManageBtn.enReport_reportView_copyWechat
                 :permissionBtn.reportManageBtn.reportManage_reportView_copyWechat"
@@ -58,6 +58,7 @@
 	import {etaBaseConfigInterence} from '@/api/modules/etaBaseConfigApi.js';
 	import * as reportEnInterface from '@/api/modules/reportEnApi';
 	import {strategyReportInterence} from '@/api/api.js'
+	import { reportV2Interface } from '@/api/modules/reportV2';
 	import vueQr from 'vue-qr'
 	export default {
 		computed: {
@@ -117,17 +118,19 @@
 				this.isshow=true;
 				return 
 			}
-
-			if(this.$route.query.id||this.reportId) {
-				this.getreportdetail();
-			}else {
-				let reportdtl=sessionStorage.getItem('reportdtl') || false;
-				this.reportInfo=JSON.parse(reportdtl);
-				console.info("reportInfo");
-				console.log(this.reportInfo);
-				this.isshow=true;
+			if(this.$route.query.isVersionRecord === 'true') {
+				this.getReportHistoryDetail()
+			} else {
+				if(this.$route.query.id||this.reportId) {
+					this.getreportdetail();
+				}else {
+					let reportdtl=sessionStorage.getItem('reportdtl') || false;
+					this.reportInfo=JSON.parse(reportdtl);
+					console.info("reportInfo");
+					console.log(this.reportInfo);
+					this.isshow=true;
+				}
 			}
-			
 			this.getConfigSet()
 		},
 		updated(){
@@ -166,6 +169,16 @@
 				this.reportInfo=res.Data;
 				this.isshow=true;
 			},
+
+			// 获取报告详情
+			async getReportHistoryDetail(){
+				const id=this.$route.query.id||this.reportId||0
+				if(!id) return
+				this.$emit("reportStartLoading")
+				const res = await reportV2Interface.reportHistoryDetail({Id:id})
+				this.reportInfo=res.Data;
+				this.isshow=true;
+			},
 			/* 复制链接 */
 			copyHandle() {
 				var clipboard = new this.Clipboard('.copy')

+ 200 - 0
src/views/report_manage/reportV2/smartReport/components/VersionRecord.vue

@@ -0,0 +1,200 @@
+<template>
+  <div class="statistic-analysis-wrap">
+      <div class="top-box">
+          <div class="right">
+            版本记录
+          </div>
+          <div class="left">
+              <div class="search-box">
+                  <el-switch
+                    v-model="OnlyMine"
+                    @change="handleChangeIsOnlyMine"
+                    active-text="仅显示我保存的版本">
+                  </el-switch>
+              </div>
+          </div>
+      </div>
+      <div class="main-box">
+          <div class="list-wrap" v-infinite-scroll="handleLoadMore" :infinite-scroll-immediate="true">
+              <div class="chart-item" v-for="item in list" :key="item.SandboxId">
+                  <div class="top">
+                    <div class="title">{{ item.Title }}</div>
+                    <div class="time">{{ item.CreateTime }}</div>
+                  </div>
+                  <div class="bottom">
+                    <div class="name">{{item.AdminName}}</div>
+                    <div class="operation">
+                      <span @click="preview(item.Id)">预览</span>
+                      <span @click="$emit('handleRestore', item.Id)">恢复</span>
+                      <span class="delete" @click="deleteVersionRecord(item.Id)">删除</span>
+                    </div>
+                  </div>
+              </div>
+              <tableNoData :text="$t('Table.prompt_slogan')" style="width: 100%;" size="mini" v-if="list.length===0&&finished"/>
+          </div>
+      </div>
+  </div>
+</template>
+
+<script>
+import { reportV2Interface } from '@/api/modules/reportV2';
+export default {
+  props:{
+    selectChapterId:{
+        type:Number,
+        default:0
+    }
+  },
+  data() {
+      return {
+          list:[],
+          page:1,
+          pageSize:10,
+          finished:false,
+          loading:false,
+          OnlyMine:false,      
+      }
+  },
+  created(){
+      this.getSandBoxList()
+  },
+  methods: {
+      /* 搜索版本记录分页 */
+      async getSandBoxList(word) {
+           this.$route.query.coopType
+          let params = {
+              CurrentIndex: this.page,
+              PageSize: this.pageSize,
+          };
+          if (this.$route.query.coopType == '1') {
+              params.ReportId = this.$route.query.id;
+          } else {
+              params.ReportChapterId = this.selectChapterId + '';
+          }
+          this.loading=true
+          let res = await reportV2Interface.reportHistoryList(params);
+          this.loading=false
+          if (res.Ret !== 200) return;
+          const arr = res.Data.List || [];
+          this.list =
+              this.page === 1
+              ? arr
+              : [...this.list, ...arr];
+          this.finished =  res.Data.Paging.IsEnd;
+      },
+      // 是否仅显示我保存的版本
+      handleChangeIsOnlyMine(val) {
+          this.page = 1;
+          this.list = [];
+          this.getSandBoxList();
+      },
+      handleLoadMore(){
+          if(this.finished||this.loading) return
+          this.page++
+          this.getSandBoxList()
+      },
+      // 预览
+      preview(id){
+        let { href } = this.$router.resolve({ 
+            path: '/smartReportDetail',
+            query:{
+                id,
+                type:'preview',
+                isVersionRecord:'true'
+            }
+        });
+        window.open(href, '_blank');
+      },
+      // 删除弹窗
+      deleteVersionRecord(Id){
+          this.$confirm('删除后不可恢复,是否确认删除该版本?', '提示', {
+            confirmButtonText: '确定',
+            cancelButtonText: '取消',
+            type: 'warning'
+          }).then(() => {
+              this.deleteItem(Id)
+          }).catch(() => {
+          });
+      },
+      deleteItem(Id) {
+          reportV2Interface.reportHistoryDel({
+              Id
+          }).then((res) => {
+              if(res.Ret !== 200) return
+              this.$message.success('删除成功!');
+              this.getSandBoxList();
+          });
+      },
+  },
+}
+</script>
+
+<style lang="scss" scoped>
+div{
+  box-sizing: border-box;
+}
+.statistic-analysis-wrap{
+  margin-top: 10px;
+  border: 1px solid var(--gary-gy-5-line, #C8CDD9);
+  background: #FFF;
+  .top-box{
+      padding: 20px 20px 0 20px;
+      display: flex;
+      justify-content: space-between;
+      align-items: center;
+  }
+  .main-box{
+      padding: 20px;
+      height: calc(100vh - 180px);
+      border-radius: 4px;
+      display: flex;
+      flex-direction: column;
+      .list-wrap{
+          flex: 1;
+          overflow-y: auto;
+          // display: flex;
+          // flex-wrap: wrap;
+          gap: 0 20px;
+
+      }
+  }
+}
+.chart-item {
+  width: 100%;
+  max-height: 100px;
+  margin: 10px 0;
+  padding: 20px;
+  border: 1px solid #eaeaea;
+  border-radius: 10px;
+  font-size: 16px;
+  text-align: center;
+  .top {
+    display: flex;
+    justify-content: space-between;
+    .title {
+      line-height: 20px;
+      font-size: 18px;
+      color: #333333;
+    }
+    .time {
+      line-height: 20px;
+      color: #666666;
+    }
+  }
+  .bottom {
+    margin-top: 10px;
+    display: flex;
+    justify-content: space-between;
+    .name {
+      color: #333333;
+    }
+    .operation {
+      cursor: pointer;
+      color: #0052D9;
+      .delete {
+        color: #D54941;
+      }
+    }
+  }
+}
+</style>

+ 51 - 12
src/views/report_manage/reportV2/smartReport/editReport.vue

@@ -29,7 +29,6 @@
                     <tableNoData :text="$t('Common.no_cont_msg')"/>
                 </div>
 			</template>
-
 			<!-- 章节报告预览 -->
 			<template v-else-if="reportCoopType===2&&selectChapterId&&!editChapterId">
 				<div style="max-height:100vh;overflow-y:auto;">
@@ -49,11 +48,12 @@
                     @openBaseInfo="showReportBaseInfo=true"
                     @handleRefreshAllChart="handleRefreshAllChart"
                     @handlePreviewReport="reportInfo.ReportChapterId?handlePreviewChapter():handlePreviewReport()"
-                    @handleSaveContent="reportInfo.ReportChapterId?handleAutoSaveChapter('save'):handleSaveContent({isAutoSave:false})"
+                    @handleSaveContent="reportInfo.ReportChapterId?handleAutoSaveChapter('save'):handleSaveContent({isAutoSave:false,IsManualSave:true})"
                     @handlePublishOpt="(type) =>{reportInfo.ReportChapterId?handlePublishChapter():handlePublishOpt(type)}"
                     @update="()=>{$refs.chapterContRef&&$refs.chapterContRef.getChapterList()}"
+                    @handleVersionRecord="handleVersionRecord()"
                 />
-                
+
                 <div class="main-wrap">
                     <div class="report-action-wrap">
                         <ul class="top-type-list">
@@ -186,8 +186,8 @@
                         <div class="close-icon" @click="handleCloseRight">
                             <img src="~@/assets/img/smartReport/icon14.png" alt="">
                         </div>
-                        <div style="overflow-x:auto;height:calc(100% + 12px);">
-                        <div style="min-width:800px;height: 100%;">
+                        <div :style="rightType !=='versionRecord' ? 'overflow-x:auto;height:calc(100% + 12px);' : 'overflow-x:auto;'">
+                        <div :style="rightType !=='versionRecord' ? 'min-width: 800px; height: 100%;' : 'height: 100%;'">
                         <TextEdit 
                             v-if="rightType==='text'"
                             :key="activeId"
@@ -215,6 +215,8 @@
                         <ETASandBox v-if="rightType==='etaSandBox'"/>
                         <!-- 语义分析 -->
                         <SemanticAnalysis v-if="rightType==='semanticAnalysis'"/>
+                        <!-- 版本记录 -->
+                        <VersionRecord v-if="rightType==='versionRecord'" :selectChapterId="selectChapterId" @handleRestore="handleRestore"/>
                         <!-- 版图资源库 -->
                         <ImgSource v-if="rightType==='imgSource'" @change="handleInsertImgSource" @close="handleCloseRight"/>
                         </div>
@@ -293,6 +295,7 @@ import reportBaseInfo from '../components/reportBaseInfoDia.vue'
 import StatisticAnalysis from './components/StatisticAnalysis.vue'
 import ETAPriceChart from './components/ETAPriceChart.vue'
 import ETASandBox from './components/ETASandBox.vue'
+import VersionRecord from './components/VersionRecord.vue'
 import SemanticAnalysis from './components/SemanticAnalysis.vue'
 import { getUrlParams } from '@/utils/common'
 import reportApproveConfig from "@/mixins/reportApproveConfig.js"
@@ -301,6 +304,7 @@ import editHeader from '../components/reportEditHeader.vue';
 import chapterWrapper from '../components/chapterEditWrapper.vue';
 import smartReportDetail from './reportDetail.vue'
 import { GetQueryString } from '@/utils/common'
+import { reportV2Interface } from '@/api/modules/reportV2';
 export default {
     mixins:[reportApproveConfig],
     name:"smartReportEditV2",
@@ -318,6 +322,7 @@ export default {
         StatisticAnalysis,
         ETAPriceChart,
         ETASandBox,
+        VersionRecord,
         SemanticAnalysis,
         ImgSource,
         editHeader,
@@ -422,6 +427,38 @@ export default {
 			this.getChapterDetail()
 		},
 
+        /* 版本记录 */
+        async handleVersionRecord() {
+            this.showRight=true 
+            this.rightType = 'versionRecord';
+		},
+
+        /* 恢复版本 */
+        handleRestore(Id) {
+            this.$confirm('确认将报告恢复到该版本吗?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+                type: 'warning'
+            }).then(() => {
+                this.reportHistoryRevert(Id)
+            }).catch(() => {
+            });
+        },
+        /* 恢复版本报告请求 */
+        async reportHistoryRevert(Id) {
+            reportV2Interface.reportHistoryRevert({
+                Id
+            }).then((res) => {
+                if(res.Ret !== 200) return
+                this.$message.success('恢复成功!');
+                if (this.$route.query.coopType === '1') {
+                    this.getReportDetail()
+                } else {
+                    this.getChapterDetail()
+                }
+            });
+        },
+
 		/* 获取章节报告详情 */
 		async getChapterDetail() {
             if(!this.selectChapterId) return
@@ -438,14 +475,13 @@ export default {
 			$('.edit-smart-report-page')[0].scrollTop = 0;
 			if(this.editChapterId) {
 				this.timer = setInterval(() => {
-					this.handleAutoSaveChapter();
+					this.handleAutoSaveChapter('');
 				}, 6000);
 			}
 		},
 
 		/* 章节自动保存 存草稿*/
-		async handleAutoSaveChapter(type='auto') {
-			
+		async handleAutoSaveChapter(type) {
 			if(!this.reportInfo.ReportChapterId||!this.editChapterId) return
             if(!document.getElementById('report-html-content')){
                 this.timer && clearInterval(this.timer);
@@ -458,6 +494,7 @@ export default {
                     ReportChapterId: this.reportInfo.ReportChapterId,
                     Content: htmlStr,
                     ContentStruct:this.formatContentListElData(),
+                    IsManualSave: type === '' ? false : true    //是否手动保存
                 })
                 if(res.Ret !== 200) return 
                 resolve(true)
@@ -673,7 +710,8 @@ export default {
                 path: '/smartReportDetail',
                 query:{
                     id:this.$route.query.id,
-                    type:'preview'
+                    type:'preview',
+                    isVersionRecord:'false'
                 }
             });
 			window.open(href, '_blank');
@@ -1125,7 +1163,7 @@ export default {
         },1000),
         
         // 自动/存草稿保存内容
-        handleSaveContent({isAutoSave}){
+        handleSaveContent({isAutoSave, IsManualSave}){
             const html=document.getElementById('report-html-content').outerHTML.replace(/contenteditable="true"/g,'contenteditable="false"');
             return new Promise((resolve,reject)=>{
                 const id=this.$route.query.id||0
@@ -1144,6 +1182,7 @@ export default {
                     Content:html,
                     ContentStruct:this.formatContentListElData(),
                     NoChange:this.contentChange?2:1,
+                    IsManualSave,
                     ...imgParams
                 }).then(res=>{
                     if(res.Ret===200){
@@ -1160,7 +1199,7 @@ export default {
         async handlePublishOpt(type){
             if(document.getElementById('report-html-content')) { 
                 // 存一次草稿
-                const saveRes=await this.handleSaveContent({isAutoSave:true})
+                const saveRes=await this.handleSaveContent({isAutoSave:true,IsManualSave:true})
                 if(!saveRes) return
             }
 
@@ -1382,7 +1421,7 @@ export default {
         window.addEventListener('message',this.setSheetIframeStyle)
         if(this.reportCoopType===1) {
             this.timer = setInterval(() => {
-                this.handleSaveContent({isAutoSave:true});
+                this.handleSaveContent({isAutoSave:true,IsManualSave:false});
             }, 6000);
         }
     },

+ 41 - 1
src/views/report_manage/reportV2/smartReport/reportDetail.vue

@@ -104,6 +104,7 @@
 <script>
 import {apiSmartReport}  from '@/api/modules/smartReport'
 import {etaBaseConfigInterence} from '@/api/modules/etaBaseConfigApi.js';
+import { reportV2Interface } from '@/api/modules/reportV2';
 import {
 	reportdetail,
 } from '@/api/modules/reportV2';
@@ -166,7 +167,11 @@ export default {
             this.content=this.reportInfo.Content
             return 
         }
-        this.getReportDetail()
+        if(this.$route.query.isVersionRecord === 'false') {
+            this.getReportDetail()
+        } else {
+            this.getReportHistoryDetail()
+        }
         this.getConfigSet()
     },
     methods: {
@@ -215,6 +220,41 @@ export default {
                 }
             })
         },
+        // 获取报告详情
+        async getReportHistoryDetail(){
+            const id=this.$route.query.id||this.reportId||0
+            if(!id) return
+            this.$emit("reportStartLoading")
+            await reportV2Interface.reportHistoryDetail({
+                Id:id
+            }).then(res=>{
+                this.$emit("reportEndLoading")
+                if(res.Ret===200){
+                    this.reportInfo=res.Data || {}
+                    this.headImgStyle=this.reportInfo.HeadStyle?JSON.parse(this.reportInfo.HeadStyle):[]
+                    this.headImgStyle.map(st =>{
+                        st.value=st.value || st.label
+                    })
+                    this.endImgStyle=this.reportInfo.EndStyle?JSON.parse(this.reportInfo.EndStyle):[]
+                    this.endImgStyle.map(st =>{
+                        st.value=st.value || st.label
+                    })
+                    this.layoutBaseInfo['研报标题']=this.reportInfo.Title
+                    this.layoutBaseInfo['研报作者']=this.reportInfo.Author
+                    this.layoutBaseInfo['创建时间']=[2,6].includes(this.reportInfo.State)?this.reportInfo.PublishTime:''
+                    if(['preview','previewChapter'].includes(this.$route.query.type)){
+                       this.content=sessionStorage.getItem('smartReportContent')||res.Data.Content;
+                       this.reportInfo.Abstract = this.$route.query.type==='preview'?this.reportInfo.Abstract : ''; 
+                       this.bgColor=this.$route.query.type==='preview'?(sessionStorage.getItem('smartReportContentBg')||res.Data.CanvasColor):''
+                    }else{
+                        this.content=res.Data.Content
+                        this.bgColor=res.Data.CanvasColor
+                    }
+                }else{
+                    this.$emit("reportError")
+                }
+            })
+        },
 
         /* 复制链接 */
 		copyHandle() {