|
@@ -23,6 +23,7 @@ import {
|
|
|
setDeptArch,
|
|
|
setIndexTitle,
|
|
|
arrToObj,
|
|
|
+ objToArr,
|
|
|
setTableHeader
|
|
|
} from './utils'
|
|
|
import { message } from '@/utils/mesDebounce'
|
|
@@ -65,7 +66,13 @@ export default {
|
|
|
reportList: [], // 默认为用户
|
|
|
pageType: 'edit', // edit:(月报编辑和新建); readAll:(查看月报详情)
|
|
|
loading: false,
|
|
|
- clientTypeList: []
|
|
|
+ clientTypeList: [],
|
|
|
+ // 单业务线编辑时,数据迁移
|
|
|
+ saveAsTargetList: []
|
|
|
+ // saveAsData: {
|
|
|
+ // tableRow: '',
|
|
|
+ // targetSubReportId: ''
|
|
|
+ // }
|
|
|
},
|
|
|
mutations: {
|
|
|
// 页面基础数据赋值
|
|
@@ -518,27 +525,53 @@ export default {
|
|
|
state.clientTypeList = list
|
|
|
setDeptArch(state.clientTypeList)
|
|
|
},
|
|
|
- // 数据另存为
|
|
|
- SAVE_AS(state, { tableHeaders, tableRows, subReportName }) {
|
|
|
+ /**
|
|
|
+ * 数据另存为
|
|
|
+ *
|
|
|
+ */
|
|
|
+ SAVE_AS(state, { tableHeaders, tableRows, subReportid, key = 'only' }) {
|
|
|
// setTableHeader(data.tableHeaders)
|
|
|
- const rowData = arrToObj(
|
|
|
+ const rowData = objToArr(
|
|
|
[tableRows],
|
|
|
tableHeaders
|
|
|
)
|
|
|
const find = (arr) => {
|
|
|
arr.forEach(elm => {
|
|
|
if (elm.title === '线上问题') {
|
|
|
- elm.content[0].tableRows.push(rowData)
|
|
|
+ // console.log(532, elm, rowData)
|
|
|
+ // console.log(elm.content[0].tableRows, rowData)
|
|
|
+ elm.content[0].tableRows.push(rowData[0])
|
|
|
}
|
|
|
if (elm.children && elm.children.length) {
|
|
|
find(elm.children)
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- for (let i = state.reportData.length - 1; i >= 0; i--) {
|
|
|
- const elm = state.reportData[i]
|
|
|
- if (elm.reportName === subReportName) {
|
|
|
- find(elm.reportCatalog.children)
|
|
|
+ // 多业务线转移
|
|
|
+ if (state.pageType === 'editAll') {
|
|
|
+ for (let i = state.reportData.length - 1; i >= 0; i--) {
|
|
|
+ const elm = state.reportData[i]
|
|
|
+ if (elm.reportName === subReportid) {
|
|
|
+ find(elm.reportCatalog.children)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 单业务线转移
|
|
|
+ // 判断数据是否存在,不存在,就插入
|
|
|
+ if (state.saveAsTargetList.filter(elm => elm.targetSubReportId === subReportid).length) {
|
|
|
+ state.saveAsTargetList.forEach(elm => {
|
|
|
+ if (elm.targetSubReportId === subReportid) {
|
|
|
+ if (!elm.tableRow) {
|
|
|
+ elm.tableRow = []
|
|
|
+ }
|
|
|
+ elm.tableRow.push(rowData[0])
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ state.saveAsTargetList.push({
|
|
|
+ targetSubReportId: subReportid,
|
|
|
+ tableRow: [rowData[0]]
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -642,6 +675,10 @@ export default {
|
|
|
type: 'Tag'
|
|
|
}
|
|
|
params.reportCatalog = reportDataBack(params.reportCatalog)
|
|
|
+ if (state.saveAsTargetList.length) {
|
|
|
+ params.saveAsTargetList = _.cloneDeep(state.saveAsTargetList)
|
|
|
+ }
|
|
|
+ params.dependence = null
|
|
|
const res = await updateSubReport(params)
|
|
|
if (res.code === 200) {
|
|
|
callback()
|
|
@@ -657,6 +694,7 @@ export default {
|
|
|
if (`${elm.id}` === tabsActive) {
|
|
|
return {
|
|
|
...elm,
|
|
|
+ dependence: null,
|
|
|
reportCatalog: { ...reportDataBack({ ...tabPageData }) }
|
|
|
}
|
|
|
}
|
|
@@ -700,6 +738,7 @@ export default {
|
|
|
if (`${elm.id}` === tabsActive) {
|
|
|
return {
|
|
|
...elm,
|
|
|
+ dependence: null,
|
|
|
reportCatalog: { ...reportDataBack({ ...tabPageData }) }
|
|
|
}
|
|
|
}
|