Merge pull request #7997 from dataease/pr@dev-v2@feat_component-radio

feat(数据大屏): 组件的宽高增加宽高比例锁定功能,可以等比放大缩小
This commit is contained in:
王嘉豪 2024-02-05 13:49:33 +08:00 committed by GitHub
commit 5dc2fd913d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 0 deletions

View File

@ -608,6 +608,7 @@ const handleMouseDownOnPoint = (point, e) => {
let isFirst = true
const needLockProportion = isNeedLockProportion()
const originRadio = curComponent.value.style.width / curComponent.value.style.height
const move = moveEvent => {
// move
// move
@ -628,6 +629,25 @@ const handleMouseDownOnPoint = (point, e) => {
})
//Temp dataV
offsetDataVAdaptor(style, point)
//
if (curComponent.value.maintainRadio) {
//
const heightOffset = style.height - defaultStyle.value.height
//
const widthOffset = style.width - defaultStyle.value.width
//
const adaptorWidthOffset = heightOffset * originRadio
//
const adaptorHeightOffset = widthOffset / originRadio
if (Math.abs(widthOffset) > Math.abs(adaptorWidthOffset)) {
//
style.height = defaultStyle.value.height + adaptorHeightOffset
} else {
//
style.width = defaultStyle.value.width + adaptorWidthOffset
}
}
dvMainStore.setShapeStyle(style)
//
dashboardActive.value && emit('onResizing', moveEvent)

View File

@ -17,6 +17,17 @@
</el-form-item>
</el-col>
</el-row>
<el-form-item class="form-item" :class="'form-item-' + themes">
<el-checkbox
v-if="curComponent"
size="small"
:effect="themes"
v-model="curComponent['maintainRadio']"
@change="maintainRadioChange"
>
保持宽高比
</el-checkbox>
</el-form-item>
</el-form>
</template>
@ -84,6 +95,10 @@ const onPositionChange = key => {
snapshotStore.recordSnapshotCache()
}
const maintainRadioChange = () => {
snapshotStore.recordSnapshotCache()
}
const positionInit = () => {
if (curComponent.value) {
Object.keys(positionMounted.value).forEach(key => {

View File

@ -58,6 +58,7 @@ export const commonAttr = {
events: {},
groupStyle: {}, // 当一个组件成为 Group 的子组件时使用
isLock: false, // 是否锁定组件
maintainRadio: false, // 布局时保持宽高比例
isShow: true, // 是否显示组件
collapseName: ['position', 'background', 'style', 'picture'], // 编辑组件时记录当前使用的是哪个折叠面板再次回来时恢复上次打开的折叠面板优化用户体验
linkage: {

View File

@ -115,6 +115,7 @@ export function initCanvasDataPrepare(dvId, busiFlag, callBack) {
if (componentItem.component === 'Group') {
componentItem.expand = componentItem.expand || false
}
componentItem['maintainRadio'] = componentItem['maintainRadio'] || false
})
const curPreviewGap =
dvInfo.type === 'dashboard' && canvasStyleResult['dashboard'].gap === 'yes'