|
@@ -9,10 +9,11 @@ import moment from 'moment'
|
|
|
import { showToast,showDialog } from 'vant'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import {useCachedViewsStore} from '@/store/modules/cachedViews'
|
|
|
+import {usePublicSettingStore} from '@/store/modules/publicSetting'
|
|
|
import {reportManageBtn,useAuthBtn} from '@/hooks/useAuthBtn'
|
|
|
import {useReportApprove} from '@/hooks/useReportApprove'
|
|
|
import AddReportBaseInfoV2 from '../components/AddReportBaseInfoV2.vue'
|
|
|
-import { useReportHandles } from '../hooks/useReport'
|
|
|
+import { useReportHandles,useChapterRepoprtHandles } from '../hooks/useReport'
|
|
|
import draggable from 'vuedraggable'
|
|
|
import TextEditor from './components/TextEditor.vue'
|
|
|
import ImgEditor from './components/ImgEditor.vue'
|
|
@@ -24,28 +25,36 @@ import ReportLayoutImg from './components/ReportLayoutImg.vue'
|
|
|
|
|
|
|
|
|
const cachedViewsStore=useCachedViewsStore()
|
|
|
+const publicSettingStore = usePublicSettingStore()
|
|
|
const {isApprove,hasApproveFlow,getEtaConfig,checkClassifyNameArr} = useReportApprove()
|
|
|
const router=useRouter()
|
|
|
const route=useRoute()
|
|
|
const {checkAuthBtn} = useAuthBtn()
|
|
|
|
|
|
|
|
|
+const reportCoopType = ref(Number(route.query.coopType))
|
|
|
let autoSaveTimer=null
|
|
|
onMounted(() => {
|
|
|
+ if(reportCoopType.value===1) {
|
|
|
getEtaConfig()
|
|
|
getReportDetail()
|
|
|
- // autoSaveTimer=setInterval(() => {
|
|
|
- // autoSaveReportContent()
|
|
|
- // }, 6000);
|
|
|
+ autoSaveTimer=setInterval(() => {
|
|
|
+ autoSaveReportContent()
|
|
|
+ }, 6000);
|
|
|
+ }else if(reportCoopType.value===2) { //章节报告
|
|
|
+ getChapterDetail()
|
|
|
+ autoSaveTimer=setInterval(() => {
|
|
|
+ autoSaveReportChapter()
|
|
|
+ }, 6000);
|
|
|
+ }
|
|
|
})
|
|
|
onUnmounted(()=>{
|
|
|
- // clearInterval(autoSaveTimer)
|
|
|
+ clearInterval(autoSaveTimer)
|
|
|
})
|
|
|
|
|
|
|
|
|
// 获取报告详情
|
|
|
const reportInfo=ref(null)
|
|
|
-const reportCoopType = ref(Number(route.query.coopType))
|
|
|
const contentChange = ref(false)//内容是否发生变化
|
|
|
const smartState = reactive({
|
|
|
conList: [],//内容列表
|
|
@@ -128,6 +137,16 @@ async function getReportDetail(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+//获取章节详情
|
|
|
+async function getChapterDetail() {
|
|
|
+ const res=await apiReport.getChapterDetail({
|
|
|
+ ReportChapterId:Number(route.query.chapterId)
|
|
|
+ })
|
|
|
+ reportInfo.value=res.Data;
|
|
|
+
|
|
|
+ smartState.conList=res.Data.ContentStruct?JSON.parse(res.Data.ContentStruct):[]
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
watch(
|
|
|
() => smartState.conList,
|
|
@@ -397,6 +416,7 @@ const currentState = reactive({
|
|
|
})
|
|
|
// 当前再编辑哪个
|
|
|
function handleChoose(item,index,cindex){
|
|
|
+ // console.log(item,index,cindex)
|
|
|
//{item:数据,index:父序号,cindex:子序号}
|
|
|
if(!item.id||isDragResize.value||!['text','img'].includes(item.compType)) return
|
|
|
currentState.activeId=item.id
|
|
@@ -440,6 +460,11 @@ const compType = [
|
|
|
function handleOpenComPop(e) {
|
|
|
showPopover.value = false
|
|
|
console.log(e)
|
|
|
+
|
|
|
+ currentState.activeId=0
|
|
|
+ currentState.activeContent=''
|
|
|
+ currentState.activePindex=''
|
|
|
+ currentState.activeCindex=''
|
|
|
|
|
|
showInsertCompType.value = e.compId;
|
|
|
temTextVal.value = ''
|
|
@@ -497,12 +522,15 @@ function handleChartInsert({list,type,chartType}){
|
|
|
//插入文本
|
|
|
const temTextVal = ref('')
|
|
|
function handleInsertText(content) {
|
|
|
- if(temTextVal.value) { //编辑
|
|
|
+ console.log(content)
|
|
|
+ console.log(currentState)
|
|
|
+ if(currentState.activeId) { //编辑
|
|
|
currentState.activeContent=content
|
|
|
if(currentState.activeCindex>=0&¤tState.activeCindex!==''){
|
|
|
smartState.conList[currentState.activePindex].child[currentState.activeCindex].content=content
|
|
|
}else{
|
|
|
smartState.conList[currentState.activePindex].content = content
|
|
|
+ console.log(smartState.conList[currentState.activePindex])
|
|
|
}
|
|
|
}else { //新增
|
|
|
|
|
@@ -630,7 +658,7 @@ async function handleReportBaseInfoChange(e){
|
|
|
|
|
|
// 刷新所有图表
|
|
|
async function handleRefreshAllChart(){
|
|
|
- handleRefresh({ id: reportInfo.value.Id,chapterId:reportInfo.value.ChapterId })
|
|
|
+ handleRefresh({ id: Number(route.query.id),chapterId:Number(route.query.chapterId) })
|
|
|
}
|
|
|
|
|
|
//预览
|
|
@@ -658,11 +686,11 @@ function autoSaveReportContent(type="auto") {
|
|
|
return new Promise(async (resolve,reject)=>{
|
|
|
|
|
|
let imgParams = {
|
|
|
- HeadImg: reportCoopType.value===1?smartState.headImg:'',
|
|
|
- EndImg:reportCoopType.value===1?smartState.endImg:'',
|
|
|
- HeadResourceId:reportCoopType.value===1?smartState.headImgId:'',
|
|
|
- EndResourceId:reportCoopType.value===1?smartState.endImgId:'',
|
|
|
- CanvasColor:reportCoopType.value===1?smartState.bgColor:''
|
|
|
+ HeadImg:smartState.headImg,
|
|
|
+ EndImg:smartState.endImg,
|
|
|
+ HeadResourceId:smartState.headImgId,
|
|
|
+ EndResourceId:smartState.endImgId,
|
|
|
+ CanvasColor:smartState.bgColor
|
|
|
}
|
|
|
|
|
|
const res=await apiReport.reportContentSave({
|
|
@@ -695,9 +723,52 @@ async function handlePublishReport(tp) {
|
|
|
// 定时发布报告选择时间
|
|
|
function onConfirmDSFBTime(time){
|
|
|
// console.log(time);
|
|
|
- handleDSPublish(time,reportData.value)
|
|
|
+ handleDSPublish(time,reportInfo.value)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+const { handlePublishChapterApi } = useChapterRepoprtHandles()
|
|
|
+//预览章节
|
|
|
+async function handlePreviewChapter() {
|
|
|
+ const saveRes = await autoSaveReportChapter('auto');
|
|
|
+ if(!saveRes) return
|
|
|
+
|
|
|
+ const routerEl=router.resolve({
|
|
|
+ path:'/report/chapter/preview',
|
|
|
+ query:{
|
|
|
+ id:reportInfo.value.ReportChapterId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ window.open(routerEl.href,'_blank')
|
|
|
+}
|
|
|
+
|
|
|
+// 自动保存章节报告
|
|
|
+async function autoSaveReportChapter(type="auto"){
|
|
|
+ if(!route.query.chapterId) return
|
|
|
+ const html=document.getElementById('report-html-content').outerHTML.replace(/contenteditable="true"/g,'contenteditable="false"');
|
|
|
+
|
|
|
+ return new Promise(async (resolve,reject)=>{
|
|
|
+ const res=await apiReport.chapterDetailSave({
|
|
|
+ ReportChapterId:Number(route.query.chapterId),
|
|
|
+ Content: html,
|
|
|
+ ContentStruct:JSON.stringify(smartState.conList)
|
|
|
+ })
|
|
|
+ if(res.Ret === 200) {
|
|
|
+ resolve(true)
|
|
|
+ type==='save' && showToast("保存成功");
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+/* 提交章节 */
|
|
|
+async function handlePublishChapter() {
|
|
|
+ const saveRes = await autoSaveReportChapter('auto');
|
|
|
+ if(!saveRes) return
|
|
|
+
|
|
|
+ handlePublishChapterApi(reportInfo.value.ReportChapterId)
|
|
|
+}
|
|
|
|
|
|
const {
|
|
|
conList,
|
|
@@ -718,7 +789,7 @@ const {
|
|
|
<div class="report-content-box" id="report-content-box" >
|
|
|
|
|
|
<div class="add-comp-wrapper">
|
|
|
- <van-popover v-model:show="showPopover" @select="handleOpenComPop">
|
|
|
+ <van-popover v-model:show="showPopover">
|
|
|
<van-grid
|
|
|
square
|
|
|
clickable
|
|
@@ -840,8 +911,8 @@ const {
|
|
|
|
|
|
<!-- 底部操作 -->
|
|
|
<div class="bot-action-box">
|
|
|
- <div class="left-box">
|
|
|
- <div class="item" @click="showReportBaseInfo=true">
|
|
|
+ <div class="left-box" v-if="reportInfo">
|
|
|
+ <div class="item" @click="showReportBaseInfo=true" v-if="!reportInfo.ReportChapterId">
|
|
|
<img src="@/assets/imgs/report/icon_info.png" alt="">
|
|
|
<span>基础信息</span>
|
|
|
</div>
|
|
@@ -849,31 +920,46 @@ const {
|
|
|
<img src="@/assets/imgs/report/icon_refresh.png" alt="">
|
|
|
<span>刷新</span>
|
|
|
</div>
|
|
|
- <div class="item" @click="handlePreviewReport" v-permission="reportManageBtn.reportManage_reportView">
|
|
|
+ <div class="item" @click="reportInfo.ReportChapterId?handlePreviewChapter():handlePreviewReport()" v-permission="reportManageBtn.reportManage_reportView">
|
|
|
<img src="@/assets/imgs/report/icon_preview.png" alt="">
|
|
|
<span>预览</span>
|
|
|
</div>
|
|
|
- <div class="item" @click="autoSaveReportContent('save')" v-permission="reportManageBtn.reportManage_publish">
|
|
|
+ <div class="item" @click="reportInfo.ReportChapterId?autoSaveReportChapter('save'):autoSaveReportContent('save')" v-permission="reportManageBtn.reportManage_publish">
|
|
|
<img src="@/assets/imgs/report/icon_save2.png" alt="">
|
|
|
<span>保存</span>
|
|
|
</div>
|
|
|
- <template v-if="!isApprove||!hasApproveFlow">
|
|
|
- <div class="item" @click="handlePublishReport('dsfb')" v-permission="reportManageBtn.reportManage_publish">
|
|
|
- <img src="@/assets/imgs/report/icon_time.png" alt="">
|
|
|
- <span>定时发布</span>
|
|
|
- </div>
|
|
|
- <div class="item" @click="handlePublishReport('fb')" v-permission="reportManageBtn.reportManage_publish">
|
|
|
- <img src="@/assets/imgs/report/icon_publish3.png" alt="">
|
|
|
- <span>发布</span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template v-if="isApprove&&hasApproveFlow">
|
|
|
- <div class="item" @click="handlePublishReport('submit')" >
|
|
|
- <img src="@/assets/imgs/report/icon_publish3.png" alt="">
|
|
|
- <span>提交</span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <div class="item" @click="showMoreHandlePop=true" v-if="reportInfo&&!reportInfo.ReportChapterId">
|
|
|
+
|
|
|
+ <!-- 章节报告提交章节 -->
|
|
|
+ <div
|
|
|
+ class="item"
|
|
|
+ @click="handlePublishChapter"
|
|
|
+ v-permission="reportManageBtn.reportManage_publish"
|
|
|
+ v-if="reportInfo.ReportChapterId"
|
|
|
+ >
|
|
|
+ <img src="@/assets/imgs/report/icon_publish3.png" alt="">
|
|
|
+ <span>提交</span>
|
|
|
+ </div>
|
|
|
+ <!-- 单人报告提交发布 -->
|
|
|
+ <template v-else>
|
|
|
+ <template v-if="!isApprove||!hasApproveFlow">
|
|
|
+ <div class="item" @click="handlePublishReport('dsfb')" v-permission="reportManageBtn.reportManage_publish">
|
|
|
+ <img src="@/assets/imgs/report/icon_time.png" alt="">
|
|
|
+ <span>定时发布</span>
|
|
|
+ </div>
|
|
|
+ <div class="item" @click="handlePublishReport('fb')" v-permission="reportManageBtn.reportManage_publish">
|
|
|
+ <img src="@/assets/imgs/report/icon_publish3.png" alt="">
|
|
|
+ <span>发布</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-if="isApprove&&hasApproveFlow">
|
|
|
+ <div class="item" @click="handlePublishReport('submit')" >
|
|
|
+ <img src="@/assets/imgs/report/icon_publish3.png" alt="">
|
|
|
+ <span>提交</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <div class="item" @click="showMoreHandlePop=true" v-if="!reportInfo.ReportChapterId">
|
|
|
<van-icon name="ellipsis" size="24"/>
|
|
|
<div>更多设置</div>
|
|
|
</div>
|