diff --git a/src/assets/js/computeddata.js b/src/assets/js/computeddata.js index b16bcbe..cb263ad 100644 --- a/src/assets/js/computeddata.js +++ b/src/assets/js/computeddata.js @@ -248,7 +248,7 @@ class computedFunc { // 重定向数组 let listArrs = JSON.parse(JSON.stringify(listArr)) let lineArrs = JSON.parse(JSON.stringify(lineArr)) - listArrs.push(0) // 必选第一项 + listArrs.unshift(0) // 必选第一项 if (this.restur.tableLine.length < listArrs.length) { listArrs = this.restur.tableLine.map((item, index) => { return index @@ -261,10 +261,12 @@ class computedFunc { } // 处理数据显示 this.selectData.tableLine = [] + console.log(this.restur.tableLine, 'this.restur.tableLine') + console.log(listArrs, lineArrs) listArrs.forEach((items, indexs) => { this.selectData.tableLine.push({ - labelId: this.restur.tableLine[indexs].labelId, - label: this.restur.tableLine[indexs].label + labelId: this.restur.tableLine[items].labelId, + label: this.restur.tableLine[items].label }) }) // this.selectData.tableLine = this.restur.tableLine @@ -1156,6 +1158,7 @@ class computedFunc { dataPieMapRow () { let termsLine = [] let cloneLine = JSON.parse(JSON.stringify(this.selectData.tableLine)) + console.log(cloneLine, 'cloneLine') cloneLine.forEach((item, index) => { if (index !== 0) { termsLine.push(item.label) @@ -1187,6 +1190,7 @@ class computedFunc { } } }) + console.log(this.chartsDatazzPie) return this.chartsDatazzPie } // 饼图数据 ============列转换 diff --git a/src/components/chartsCont/ChartsCont.vue b/src/components/chartsCont/ChartsCont.vue index 6ceea4b..d1fcbb7 100644 --- a/src/components/chartsCont/ChartsCont.vue +++ b/src/components/chartsCont/ChartsCont.vue @@ -7,13 +7,14 @@ @rowColInd="rowColInd" :echartsDatartsPie="echartsDatartsPie" > - + @@ -369,7 +370,9 @@ export default { // 高级查询数据 startsyui: false, // 初始化左侧状态 - leftState: false + leftState: false, + // 列宽数组 + lieWidthArr: [] } }, watch: { @@ -460,7 +463,6 @@ export default { deep: true }, downLaSelectArea (valStrinf) { - console.log(this.$store.state.AreaAllCountData, '555222000') console.log(valStrinf, '555222000选中') console.log(this.$store.state.AreaAllCountData, 'kkkkk数据') if (!this.$store.state.advancedSearchState) { @@ -473,9 +475,9 @@ export default { this.$store.state.areaIndexName = valStrinf this.selectState = 2 } - if (this.leftState) { - this.getDatas() - } + // if (this.leftState) { + this.getDatas() + // } } else { console.log(this.leftState, '走这里') if (this.$store.state.newSelectDaaState) { @@ -487,9 +489,9 @@ export default { this.$store.state.areaIndexName = valStrinf this.selectState = 2 } - if (this.leftState) { - this.advancedSearchDataShow() - } + // if (this.leftState) { + this.advancedSearchDataShow() + // } } }, // 监听行列图表转换 @@ -615,17 +617,45 @@ export default { } }, methods: { + /** + * @desc 计算列宽,返回每一列中内容最大的那个的内容长度 + * @return 返回一个含有每列最大的内容的长度的数组 + * + * */ + lieWidthComputed () { + // 总数据 + let AllCountData = (this.tableData.map((item, index) => { return Object.values(item) })) + AllCountData.unshift(this.tableLine.map((item, index) => { return item.label })) + // 将数据进行行列转换 + let zhuanChange = AllCountData[0].map((col, index) => { + return AllCountData.map((row, key) => { + return row[index].length + }) + }) + console.log(zhuanChange, 'AllCountData') + this.lieWidthArr = zhuanChange.map((item, index) => { + return item.reduce((total, currentValue) => { + return total > currentValue ? total : currentValue + }) + }) + console.log(this.lieWidthArr, 'this.lieWidthArr') + this.$nextTick(() => { + this.$refs.table.doLayout() + }) + }, /** * @desc 请求时间完成 后就执行 * * */ /* eslint-disable */ downLaSelects() { - console.log(this.$store.state.advancedSearchState, 'this.$store.state.advancedSearchState') - if (!this.$store.state.advancedSearchState) { - this.getDatas() - } else { - this.advancedSearchDataShow() + console.log(this.$store.state.advancedSearchState, 'this.$store.state.advancedSearchState0000000000000000000000') + if (this.leftState) { + if (!this.$store.state.advancedSearchState) { + this.getDatas() + } else { + this.advancedSearchDataShow() + } } }, // 获取所有当前分类下的所有的指标、地区、时间 @@ -668,6 +698,8 @@ export default { this.tableData = objDatasAfter.countData console.log(objDatasAfter, 'objDatasAfter') } + // 计算列宽的数组 + this.lieWidthComputed() }, // 地区数据转置 areaTrans() { @@ -681,6 +713,13 @@ export default { }) }) console.log(this.transBefore, 'transpositionData') + // let transpositionDatas = JSON.parse(JSON.stringify(this.$store.state.allNochangeInitData.transBeforeAreaData)) + // this.$store.state.allNochangeInitData.transBeforeAreaData = transpositionDatas[0].map(function (col, index) { + // return transpositionDatas.map((row, key) => { + // return row[index] + // }) + // }) + console.log(this.$store.state.allNochangeInitData.transBeforeAreaData, 'this.$store.state.allNochangeInitData.transBeforeAreaData') // 数据转置完成恢复 this.$store.state.transClickState = false } @@ -727,6 +766,8 @@ export default { console.log(comTransAreabeforeLabelArea, 'comTransAreabeforeLabelArea') this.objCompBefore = objCompAfter } + // 计算列宽的数组 + this.lieWidthComputed() }, // 渲染列表数据 showTable() { @@ -857,6 +898,8 @@ export default { } } this.chartsShow() + // 计算列宽的数组 + this.lieWidthComputed() }, // 图表渲染 chartsShow() { @@ -1161,6 +1204,8 @@ export default { // 行计算样式 computedLineSty() { return (ind) => { + // console.log(this.$store.state.allNochangeInitData, 'this.$store.state.allNochangeInitData') + // console.log(this.transBefore, 'this.transBefores19') let styStatic = false if (this.transState) { if (this.$route.query.type !== 'area') { @@ -1217,12 +1262,19 @@ export default { // 监听全局表数据的的变化从而改变渲染数据 transBefores() { return this.$store.state.allState + }, + // 计算列宽 + computedWidth() { + return (strings) => { + return this.lieWidthArr[strings] * 20 + } } }, created() { // 还原高级查询状态 // this.$store.state.advancedSearchState = false this.startsyui = this.advancedStates + this.leftState = false }, updated() { // 重新渲染表格 @@ -1235,6 +1287,7 @@ export default { // this.showTable() // 转置状态 this.transState = this.chartsStatusMegger.transState + this.leftState = false } } @@ -1279,10 +1332,22 @@ export default { .slotExplain:hover { cursor: pointer; } -/deep/ .el-table .cell { - display: flex; +/deep/ .cell { + display: flex !important; flex-direction: row; justify-content: flex-start; align-items: center; + flex-wrap: nowrap; +} +/deep/ .cell > span { + // white-space: nowrap; + flex-shrink: 0; +} +/deep/ .cell > span:hover { + cursor: pointer; +} +/deep/ .cell > img { + display: inline; + flex-shrink: 0; } diff --git a/src/components/chartsCut/ChartsCut.vue b/src/components/chartsCut/ChartsCut.vue index 7ebe000..2cac26f 100644 --- a/src/components/chartsCut/ChartsCut.vue +++ b/src/components/chartsCut/ChartsCut.vue @@ -353,7 +353,6 @@ export default { this.$emit('update:loading', false) } // 调用父组件的chuFachildChartCont方法渲染 - // this.$parent.chuFachildChartCont() } }).catch((fail) => { console.log(fail) @@ -652,12 +651,12 @@ export default { if (value[0] === '序列') { this.stateChangeSDF = !this.stateChangeSDF this.$store.state.newSelectDaaState = this.stateChangeSDF - this.showLabelArea() if (this.$store.state.SelecttDimension.row === 'sj' && this.$store.state.SelecttDimension.col === 'dq') { this.$store.state.SelecttDimension.col = 'zb' } else if (this.$store.state.SelecttDimension.row === 'sj' && this.$store.state.SelecttDimension.col === 'zb') { this.$store.state.SelecttDimension.col = 'dq' } + this.showLabelArea() } else { this.$emit('statertfResu', value[0]) } diff --git a/src/components/dimension/Dimension.vue b/src/components/dimension/Dimension.vue index 4af44d2..2b2db54 100644 --- a/src/components/dimension/Dimension.vue +++ b/src/components/dimension/Dimension.vue @@ -209,6 +209,15 @@ export default { this.$store.state.areaDimensionState = false } this.$store.state.allNochangeInitData = JSON.parse(JSON.stringify(this.$store.state.transBefore)) + let transpositionDatas = JSON.parse(JSON.stringify(this.$store.state.allNochangeInitData.transBeforeAreaData)) + if (this.$store.state.befaultAfter === 'zz') { + this.$store.state.allNochangeInitData.transBeforeAreaData = transpositionDatas[0].map(function (col, index) { + return transpositionDatas.map((row, key) => { + return row[index] + }) + }) + this.$store.state.befaultAfter = 'wdzh' + } }).catch((fail) => { console.log(fail, 2369) }) diff --git a/src/store.js b/src/store.js index 1584bf8..5c82ef3 100644 --- a/src/store.js +++ b/src/store.js @@ -109,7 +109,9 @@ export default new Vuex.Store({ // 转置被点击了 transClickState: false, // 初始化请求的所有数据(全局不变) - allNochangeInitData: null + allNochangeInitData: null, + // 转置状态和维度转换状态先后(默认先点击维度转换)wdzh zz + befaultAfter: 'no' }, mutations: {}, diff --git a/src/views/datasweb/Datasweb.vue b/src/views/datasweb/Datasweb.vue index 45eee09..d84c7f6 100644 --- a/src/views/datasweb/Datasweb.vue +++ b/src/views/datasweb/Datasweb.vue @@ -705,6 +705,7 @@ export default { clickCate (hierarchy, ind, textType) { switch (textType) { case '新增指标': + this.cutStatic(0) console.log(this.$store.state.transBefore, 'this.$store.state.transBefore') if (this.$store.state.transBefore) { this.$store.state.insertWindowState = true @@ -715,6 +716,7 @@ export default { } break case '筛选': + this.cutStatic(0) if (this.$store.state.transBefore) { this.$store.state.selcettWindowState = true } else { @@ -724,6 +726,7 @@ export default { } break case '恢复':// 恢复 + this.cutStatic(0) if (this.$store.state.transBefore) { this.$router.go(0) } else { @@ -733,6 +736,7 @@ export default { } break case '清除空行空列':// 清除空行空列 + this.cutStatic(0) // this.$router.go(0) // console.log(this.$store.state.transBefore, 'this.$store.state.transBefore') if (this.$store.state.transBefore) { @@ -837,6 +841,7 @@ export default { } break case '编辑': + this.cutStatic(0) if (this.$store.state.transBefore) { this.$store.state.editWindowState = true } else { @@ -846,11 +851,15 @@ export default { } break case '转置': + if (this.$store.state.befaultAfter !== 'wdzh') { + this.$store.state.befaultAfter = 'zz' + } + this.cutStatic(0) if (this.$store.state.transBefore) { // 当前数据是地区数据时点击转置需要将数据进行转置 if (this.$route.query.type === 'area') { - // let transpositionData = JSON.parse(JSON.stringify(this.$store.state.transBefore.transBeforeAreaData)) - // this.$store.state.transBefore.transBeforeAreaData = transpositionData[0].map(function (col, index) { + // let transpositionData = JSON.parse(JSON.stringify(this.$store.state.allNochangeInitData.transBeforeAreaData)) + // this.$store.state.allNochangeInitData.transBeforeAreaData = transpositionData[0].map(function (col, index) { // return transpositionData.map((row, key) => { // return row[index] // }) @@ -871,8 +880,10 @@ export default { confirmButtonText: '确定' }) } + // this.$refs.childChartCont.lieWidthComputed() break case '维度转换': + this.cutStatic(0) if (this.$store.state.transBefore) { if (this.$route.query.type === 'area') { this.$store.state.dimensionState = true @@ -886,6 +897,7 @@ export default { } break case '保存默认':// 将分类id 和 分类数据存入本地 + this.cutStatic(0) // 获取本地保存数据 if (this.$store.state.transBefore) { if (JSON.parse(sessionStorage.getItem('classFiyData'))) { @@ -918,6 +930,7 @@ export default { } break case '恢复默认':// 将分类id 和 分类数据从本地删除 + this.cutStatic(0) if (this.$store.state.transBefore) { if (JSON.parse(sessionStorage.getItem('classFiyData'))) { let arrtsBGY = JSON.parse(sessionStorage.getItem('classFiyData')) diff --git a/src/views/index/Index.vue b/src/views/index/Index.vue index abb3639..7cf8796 100644 --- a/src/views/index/Index.vue +++ b/src/views/index/Index.vue @@ -5,7 +5,7 @@
- +