forked from github/dataease
refactor(图表): 明细表图片点击放大
This commit is contained in:
parent
911c006f69
commit
945d195835
@ -35,7 +35,8 @@ const state = reactive({
|
|||||||
drill: t('visualization.drill'),
|
drill: t('visualization.drill'),
|
||||||
linkage: t('visualization.linkage'),
|
linkage: t('visualization.linkage'),
|
||||||
linkageAndDrill: t('visualization.linkage_and_drill'),
|
linkageAndDrill: t('visualization.linkage_and_drill'),
|
||||||
jump: t('visualization.jump')
|
jump: t('visualization.jump'),
|
||||||
|
enlarge: t('visualization.enlarge')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -13,14 +13,19 @@ class ImageCell extends TableDataCell {
|
|||||||
const img = new Image()
|
const img = new Image()
|
||||||
const { x, y, width, height, fieldValue } = this.meta
|
const { x, y, width, height, fieldValue } = this.meta
|
||||||
img.src = fieldValue as string
|
img.src = fieldValue as string
|
||||||
|
img.setAttribute('crossOrigin', 'anonymous')
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
!this.cfg.children && (this.cfg.children = [])
|
!this.cfg.children && (this.cfg.children = [])
|
||||||
|
const { width: imgWidth, height: imgHeight } = img
|
||||||
|
const ratio = Math.max(imgWidth / width, imgHeight / height)
|
||||||
|
const imgShowWidth = imgWidth / ratio
|
||||||
|
const imgShowHeight = imgHeight / ratio
|
||||||
this.textShape = this.addShape('image', {
|
this.textShape = this.addShape('image', {
|
||||||
attrs: {
|
attrs: {
|
||||||
x,
|
x: x + (imgShowWidth < width ? (width - imgShowWidth) / 2 : 0),
|
||||||
y,
|
y: y + (imgShowHeight < height ? (height - imgShowHeight) / 2 : 0),
|
||||||
width,
|
width: imgShowWidth,
|
||||||
height,
|
height: imgShowHeight,
|
||||||
img
|
img
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -118,12 +123,21 @@ export class TableInfo extends S2ChartView<TableSheet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const customAttr = parseJson(chart.customAttr)
|
const customAttr = parseJson(chart.customAttr)
|
||||||
|
const style = this.configStyle(chart)
|
||||||
|
// 自适应列宽模式下,URL 字段的宽度固定为 120
|
||||||
|
if (customAttr.basicStyle.tableColumnMode === 'adapt') {
|
||||||
|
const urlFields = fields.filter(field => axisMap[field.dataeaseName]?.deType === 7)
|
||||||
|
style.colCfg.widthByFieldValue = urlFields?.reduce((p, n) => {
|
||||||
|
p[n.chartShowName ?? n.name] = 120
|
||||||
|
return p
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
// options
|
// options
|
||||||
const s2Options: S2Options = {
|
const s2Options: S2Options = {
|
||||||
width: containerDom.offsetWidth,
|
width: containerDom.offsetWidth,
|
||||||
height: containerDom.offsetHeight,
|
height: containerDom.offsetHeight,
|
||||||
showSeriesNumber: customAttr.tableHeader.showIndex,
|
showSeriesNumber: customAttr.tableHeader.showIndex,
|
||||||
style: this.configStyle(chart),
|
style,
|
||||||
conditions: this.configConditions(chart),
|
conditions: this.configConditions(chart),
|
||||||
tooltip: {
|
tooltip: {
|
||||||
getContainer: () => containerDom,
|
getContainer: () => containerDom,
|
||||||
|
@ -107,7 +107,9 @@ const state = reactive({
|
|||||||
totalItems: 0,
|
totalItems: 0,
|
||||||
showPage: false,
|
showPage: false,
|
||||||
pageStyle: 'simple',
|
pageStyle: 'simple',
|
||||||
currentPageSize: 0
|
currentPageSize: 0,
|
||||||
|
imgEnlarge: false,
|
||||||
|
imgSrc: ''
|
||||||
})
|
})
|
||||||
// 图表数据不用全响应式
|
// 图表数据不用全响应式
|
||||||
let chartData = shallowRef<Partial<Chart['data']>>({
|
let chartData = shallowRef<Partial<Chart['data']>>({
|
||||||
@ -408,6 +410,16 @@ const trackClick = trackAction => {
|
|||||||
if (mobileInPc.value && !inMobile.value) return
|
if (mobileInPc.value && !inMobile.value) return
|
||||||
emit('onJumpClick', jumpParam)
|
emit('onJumpClick', jumpParam)
|
||||||
break
|
break
|
||||||
|
case 'enlarge':
|
||||||
|
if (view.value.type === 'table-info') {
|
||||||
|
param.data.dimensionList?.forEach(d => {
|
||||||
|
if (d.id === state.curActionId) {
|
||||||
|
state.imgSrc = d.value
|
||||||
|
state.imgEnlarge = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -491,6 +503,14 @@ const trackMenuCalc = itemId => {
|
|||||||
) {
|
) {
|
||||||
trackMenuInfo = ['linkageAndDrill']
|
trackMenuInfo = ['linkageAndDrill']
|
||||||
}
|
}
|
||||||
|
// 明细表 URL 字段图片放大
|
||||||
|
if (view.value.type === 'table-info') {
|
||||||
|
view.value.xAxis?.forEach(axis => {
|
||||||
|
if (axis.id === itemId) {
|
||||||
|
trackMenuInfo.push('enlarge')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
return trackMenuInfo
|
return trackMenuInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,6 +671,11 @@ const tablePageClass = computed(() => {
|
|||||||
</el-row>
|
</el-row>
|
||||||
<chart-error v-if="isError" :err-msg="errMsg" />
|
<chart-error v-if="isError" :err-msg="errMsg" />
|
||||||
</div>
|
</div>
|
||||||
|
<el-dialog v-model="state.imgEnlarge" append-to-body>
|
||||||
|
<div class="enlarge-image">
|
||||||
|
<img :src="state.imgSrc" />
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
@ -697,3 +722,13 @@ const tablePageClass = computed(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<style lang="less">
|
||||||
|
.enlarge-image {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
flex-direction: row;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user