瀏覽代碼

月报2.0改造(5.1):月报线上问题,subtitle动态更新

洪海涛 4 年之前
父節點
當前提交
b344321b53

+ 10 - 0
src/api/qualityMonthlyReport/edit.js

@@ -216,3 +216,13 @@ export function downloadMonthlyReport(reportId) {
     method: 'get'
   })
 }
+
+// 拉取subtitle /monthlyReport/pullSubTitle
+export function pullSubTitle(data) {
+  return request({
+    url: projectManagementUrl + '/monthlyReport/pullSubTitle',
+    method: 'post',
+    timeout: '20000',
+    data
+  })
+}

+ 67 - 1
src/store/modules/monthlyReport/edit/index.js

@@ -13,7 +13,8 @@ import {
   publishReport,
   getSubReportInfo,
   updateSubReport,
-  pullDataAgain
+  pullDataAgain,
+  pullSubTitle
 } from '@/api/qualityMonthlyReport/edit'
 // import { memberQueryMemberInfoByIDAPorName } from '@/api/projectIndex'
 import { getAvaliableInfo, getMonthlyReportVersion } from '@/api/qualityMonthlyReport'
@@ -1003,6 +1004,71 @@ export default {
           state.userNames = userNames
         }
       }, 100)
+    },
+    // 重新拉取线上问题的 SubTitle,只在tableData数据变化时更新
+    async pullOnlineQuestion({ state }, { domKey, route }) {
+      // 获取数据
+      let baseData = {}
+      let { subReportId } = route.query
+      const [tabKey, subTabKey] = state.subTabsActive
+      if (!subReportId) {
+        subReportId = state.tabsActive.replace(/tab_/, '')
+      }
+      //
+      const tabDataObj = {
+        tabKey: '',
+        subTabKey: ''
+      }
+      const setValue = (item, key, value) => {
+        if (item.domKey === value) {
+          tabDataObj[key] = item
+        }
+      }
+      const find = (arr) => {
+        arr &&
+          arr.length &&
+          arr.forEach((elm) => {
+            setValue(elm, 'tabKey', tabKey)
+            setValue(elm, 'subTabKey', subTabKey)
+            if (elm.domKey === domKey) {
+              baseData = _.cloneDeep(elm)
+            }
+            if (elm.content && elm.content.length) {
+              find(elm.content)
+            }
+            if (elm.children && elm.children.length) {
+              find(elm.children)
+            }
+          })
+      }
+      find(state.tabPageData.children)
+      // 转换数据
+      const tableRows = objToArr(baseData.content[1].tableRows, baseData.content[1].tableHeaders)
+      const res = await pullSubTitle({
+        subReportId,
+        catalogTitle: '线上问题',
+        isServer: tabDataObj.tabKey.title ? tabDataObj.tabKey.title === '服务端' : false,
+        tableRows
+      })
+      // 覆盖数据
+      const setSubTitle = (arr) => {
+        arr &&
+          arr.length &&
+          arr.forEach((elm) => {
+            if (elm.domKey === domKey) {
+              elm.subTitles = res.data
+            }
+            if (elm.content && elm.content.length) {
+              setSubTitle(elm.content)
+            }
+            if (elm.children && elm.children.length) {
+              setSubTitle(elm.children)
+            }
+          })
+      }
+      const tabPageData = { ...state.tabPageData }
+      setSubTitle(tabPageData.children)
+      state.tabPageData = { ...tabPageData }
     }
   }
 }

+ 0 - 1
src/store/modules/monthlyReport/edit/utils.js

@@ -187,7 +187,6 @@ export function readOnlyTableObjToArr(obj, tableHeaders) {
     const elms = {}
     tableHeaders.forEach((item, index) => {
       let param = {}
-      console.log(192)
       param = elm[item.headerKey]
       if (!elms.tableItems) {
         elms.tableItems = []

+ 21 - 0
src/views/monthlyReport/childrenPage/editReport/components/MrTable/index.vue

@@ -343,10 +343,16 @@ export default {
       type: Array,
       required: false,
       default: () => []
+    },
+    baseDataDomKey: {
+      type: String,
+      required: false,
+      default: () => ''
     }
   },
   data() {
     this.setAnalyticFeedback = _.debounce(this.setAnalyticFeedback, 300)
+    this.pullOnlineQuestion = _.debounce(this.pullOnlineQuestion, 1000)
     return {
       analyticFeedback: '',
       expandRowKeys: [],
@@ -404,6 +410,15 @@ export default {
       return this.$store.state.monthlyReportEdit.isLoading
     }
   },
+  watch: {
+    tableData: {
+      handler: (val, oldVal) => {
+        this.pullOnlineQuestion()
+      },
+      deep: true,
+      immediate: true
+    }
+  },
   // watch: {
   //   tableData() {
   //     if (this.tableData.length) {
@@ -425,6 +440,12 @@ export default {
   methods: {
     isEdit() {
     },
+    pullOnlineQuestion() {
+      this.$store.dispatch('monthlyReportEdit/pullOnlineQuestion', {
+        domKey: this.baseDataDomKey,
+        route: this.$route
+      })
+    },
     init() {
       this.paging.curIndex = 1
       this.paging.pageSize = 10

+ 1 - 0
src/views/monthlyReport/childrenPage/editReport/components/content.vue

@@ -11,6 +11,7 @@
           :columns="item.tableHeaders"
           :table-data="item.tableRows"
           :dom-key="item.domKey"
+          :base-data-dom-key="baseDataDomKey"
           plus-table-data-bottom="0px"
         />
         <div v-else-if="title.search(/线上问题/) > -1" class="no-data">

+ 10 - 1
src/views/monthlyReport/childrenPage/editReport/index.vue

@@ -195,7 +195,7 @@
       width="70%"
       @succes="downloadReportPdf">
       <div class="report-delete" style="text-align: initial;min-height: 30vh;max-height: 70vh;overflow-y: scroll;">
-        <!--        月报数据已检查无误,确认发布?-->
+        <!-- 月报数据已检查无误,确认发布?-->
         <div v-if="monthlyReportPrePdfView" style="" v-html="monthlyReportPrePdfView" />
       </div>
     </normal-dialog>
@@ -301,6 +301,11 @@ export default {
     }
     // 数据埋点
     this.monthlyReportBuriedPoint()
+    // 防止页面后退
+    history.pushState(null, null, document.URL)
+    window.addEventListener('popstate', function() {
+      history.pushState(null, null, document.URL)
+    })
   },
   destroyed() {
     this.indexShow = false
@@ -309,6 +314,10 @@ export default {
     if (this.$route.query.type && this.$route.query.type === 'create') {
       this.deleteReport({ isMsg: false })
     }
+    // 销毁组件时,取消浏览器前进后端拦截事件
+    window.removeEventListener('popstate', function() {
+      history.pushState(null, null, document.URL)
+    })
   },
   methods: {
     ...mapMutations('monthlyReportEdit',