Merge pull request #9128 from dataease/pr@dev-v2@feat_group-click

feat(数据大屏): 批量修改组件大小支持键盘加鼠标点选
This commit is contained in:
王嘉豪 2024-04-16 14:46:56 +08:00 committed by GitHub
commit c4604a558e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,7 +48,7 @@ const composeStore = composeStoreWithOut()
const contextmenuStore = contextmenuStoreWithOut() const contextmenuStore = contextmenuStoreWithOut()
const { curComponent, dvInfo, editMode, tabMoveOutComponentId } = storeToRefs(dvMainStore) const { curComponent, dvInfo, editMode, tabMoveOutComponentId } = storeToRefs(dvMainStore)
const { editorMap } = storeToRefs(composeStore) const { editorMap, areaData } = storeToRefs(composeStore)
const emits = defineEmits(['scrollCanvasToTop']) const emits = defineEmits(['scrollCanvasToTop'])
const props = defineProps({ const props = defineProps({
isEdit: { isEdit: {
@ -215,6 +215,14 @@ watch(
{ deep: true } { deep: true }
) )
watch(
() => areaData.value.components,
() => {
groupAreaClickChange()
},
{ deep: true }
)
const initWatermark = (waterDomId = 'editor-canvas-main') => { const initWatermark = (waterDomId = 'editor-canvas-main') => {
try { try {
if ( if (
@ -397,13 +405,12 @@ const hideArea = () => {
}, },
components: [] components: []
}) })
groupAreaChange(false)
} }
const createGroup = () => { const createGroup = () => {
// //
const areaData = getSelectArea() const areaDataLocal = getSelectArea()
if (areaData.length <= 1) { if (areaDataLocal.length <= 1) {
hideArea() hideArea()
return return
} }
@ -414,7 +421,7 @@ const createGroup = () => {
left = Infinity left = Infinity
let right = -Infinity, let right = -Infinity,
bottom = -Infinity bottom = -Infinity
areaData.forEach(component => { areaDataLocal.forEach(component => {
let style = { left: 0, top: 0, right: 0, bottom: 0 } let style = { left: 0, top: 0, right: 0, bottom: 0 }
if (component.component == 'Group') { if (component.component == 'Group') {
component.propValue.forEach(item => { component.propValue.forEach(item => {
@ -454,13 +461,12 @@ const createGroup = () => {
// //
composeStore.setAreaData({ composeStore.setAreaData({
style: areaDataStyle, style: areaDataStyle,
components: areaData components: areaDataLocal
}) })
// group // group
if (areaData.length > 0) { if (areaDataLocal.length > 0) {
dvMainStore.setCurComponent({ component: null, index: null }) dvMainStore.setCurComponent({ component: null, index: null })
isShowArea.value = false isShowArea.value = false
groupAreaChange(true, areaDataStyle)
} }
} }
@ -1352,22 +1358,29 @@ const contextMenuShow = computed(() => {
const markLineShow = computed(() => isMainCanvas(canvasId.value)) const markLineShow = computed(() => isMainCanvas(canvasId.value))
const groupAreaChange = (showArea, style?) => { //
nextTick(() => { const groupAreaClickChange = () => {
if (showArea) { let groupAreaCom
const groupArea = findNewComponent('GroupArea', 'GroupArea') const groupAreaHis = componentData.value.filter(ele => ele.id === 100000001)
groupArea.style.left = style.left if (groupAreaHis && groupAreaHis.length > 0) {
groupArea.style.top = style.top groupAreaCom = groupAreaHis[0]
groupArea.style.width = style.width }
groupArea.style.height = style.height // Group
dvMainStore.addComponent({ component: groupArea, index: undefined }) if (areaData.value.components.length > 1) {
} else { //
const groupAreaHis = componentData.value.filter(ele => ele.id === 100000001) composeStore.calcComposeArea()
if (groupAreaHis && groupAreaHis.length > 0) { if (!groupAreaCom) {
dvMainStore.deleteComponentById(100000001) //
} groupAreaCom = findNewComponent('GroupArea', 'GroupArea')
dvMainStore.addComponent({ component: groupAreaCom, index: undefined })
} }
}) groupAreaCom.style.left = areaData.value.style.left
groupAreaCom.style.top = areaData.value.style.top
groupAreaCom.style.width = areaData.value.style.width
groupAreaCom.style.height = areaData.value.style.height
} else if (groupAreaCom) {
dvMainStore.deleteComponentById(100000001)
}
} }
onMounted(() => { onMounted(() => {