diff --git a/frontend/src/components/canvas/components/Editor/ContextMenu.vue b/frontend/src/components/canvas/components/Editor/ContextMenu.vue
index e22d9b8742..10ce586676 100644
--- a/frontend/src/components/canvas/components/Editor/ContextMenu.vue
+++ b/frontend/src/components/canvas/components/Editor/ContextMenu.vue
@@ -65,6 +65,7 @@ export default {
},
cut() {
+ this.deleteCurCondition()
this.$store.commit('cut')
},
@@ -78,10 +79,17 @@ export default {
},
deleteComponent() {
+ this.deleteCurCondition()
this.$store.commit('deleteComponent')
this.$store.commit('recordSnapshot')
},
+ deleteCurCondition() {
+ if (this.curComponent.type === 'custom') {
+ bus.$emit('delete-condition', { componentId: this.curComponent.id })
+ }
+ },
+
upComponent() {
this.$store.commit('upComponent')
this.$store.commit('recordSnapshot')
diff --git a/frontend/src/components/canvas/components/Editor/MarkLine.vue b/frontend/src/components/canvas/components/Editor/MarkLine.vue
index a07ccedc80..7ad032c413 100644
--- a/frontend/src/components/canvas/components/Editor/MarkLine.vue
+++ b/frontend/src/components/canvas/components/Editor/MarkLine.vue
@@ -61,7 +61,7 @@ export default {
this.hideLine()
components.forEach(component => {
- if (component == this.curComponent) return
+ if (component === this.curComponent) return
const componentStyle = getComponentRotatedStyle(component.style)
const { top, left, bottom, right } = componentStyle
const componentHalfwidth = componentStyle.width / 2
diff --git a/frontend/src/components/canvas/components/Editor/Preview.vue b/frontend/src/components/canvas/components/Editor/Preview.vue
index eca610433c..b086c8ef74 100644
--- a/frontend/src/components/canvas/components/Editor/Preview.vue
+++ b/frontend/src/components/canvas/components/Editor/Preview.vue
@@ -61,13 +61,11 @@ export default {
])
},
mounted() {
- debugger
const _this = this
const erd = elementResizeDetectorMaker()
// 监听div变动事件
erd.listenTo(document.getElementById('canvasInfo'), element => {
_this.$nextTick(() => {
- debugger
_this.restore()
})
})
diff --git a/frontend/src/components/canvas/components/Editor/PreviewEject.vue b/frontend/src/components/canvas/components/Editor/PreviewEject.vue
index 96b6db6fa7..59bb770dcd 100644
--- a/frontend/src/components/canvas/components/Editor/PreviewEject.vue
+++ b/frontend/src/components/canvas/components/Editor/PreviewEject.vue
@@ -71,7 +71,6 @@ export default {
})
})
window.onresize = () => {
- debugger
this.resize()
}
// this.resize()
@@ -88,7 +87,6 @@ export default {
this.handleScaleChange()
},
restore() {
- debugger
this.panelId = this.$route.path.split('/')[2]
// 加载视图数据
get('panel/group/findOne/' + this.panelId).then(response => {
diff --git a/frontend/src/components/canvas/components/Editor/PreviewFullScreen.vue b/frontend/src/components/canvas/components/Editor/PreviewFullScreen.vue
index d14a926e07..a3ba065164 100644
--- a/frontend/src/components/canvas/components/Editor/PreviewFullScreen.vue
+++ b/frontend/src/components/canvas/components/Editor/PreviewFullScreen.vue
@@ -19,7 +19,6 @@ export default {
methods: {
toDir() {
- debugger
this.$router.replace('/panel/index')
bus.$emit('PanelSwitchComponent', { name: 'PanelEdit' })
}
diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue
index 277591c938..3c6c103ced 100644
--- a/frontend/src/components/canvas/components/Editor/index.vue
+++ b/frontend/src/components/canvas/components/Editor/index.vue
@@ -25,14 +25,14 @@
:class="{ lock: item.isLock }"
>
-
import { mapState } from 'vuex'
import Shape from './Shape'
+// eslint-disable-next-line no-unused-vars
import { getStyle, getComponentRotatedStyle } from '@/components/canvas/utils/style'
import { $ } from '@/components/canvas/utils/utils'
import ContextMenu from './ContextMenu'
@@ -75,7 +76,8 @@ import Area from './Area'
import eventBus from '@/components/canvas/utils/eventBus'
import Grid from './Grid'
import { changeStyleWithScale } from '@/components/canvas/utils/translate'
-
+import { Condition } from '@/components/widget/bean/Condition'
+import bus from '@/utils/bus'
export default {
components: { Shape, ContextMenu, MarkLine, Area, Grid },
props: {
@@ -94,7 +96,8 @@ export default {
},
width: 0,
height: 0,
- isShowArea: false
+ isShowArea: false,
+ conditions: []
}
},
computed: {
@@ -116,6 +119,9 @@ export default {
eventBus.$on('hideArea', () => {
this.hideArea()
})
+ bus.$on('delete-condition', condition => {
+ this.deleteCondition(condition)
+ })
},
methods: {
changeStyleWithScale,
@@ -281,7 +287,8 @@ export default {
},
getComponentStyle(style) {
- return getStyle(style, ['top', 'left', 'width', 'height', 'rotate'])
+ // return getStyle(style, ['top', 'left', 'width', 'height', 'rotate'])
+ return style
},
handleInput(element, value) {
@@ -290,6 +297,7 @@ export default {
},
getTextareaHeight(element, text) {
+ // eslint-disable-next-line prefer-const
let { lineHeight, fontSize, height } = element.style
if (lineHeight === '') {
lineHeight = 1.5
@@ -301,6 +309,28 @@ export default {
filterValueChange(value) {
console.log('emit:' + value)
+ },
+
+ setConditionValue(obj) {
+ const { component, value, operator } = obj
+ const fieldId = component.options.attrs.fieldId
+ const condition = new Condition(component.id, fieldId, operator, value, null)
+ this.addCondition(condition)
+ },
+ addCondition(condition) {
+ this.conditions.push(condition)
+ this.executeSearch()
+ },
+ deleteCondition(condition) {
+ this.conditions = this.conditions.filter(item => {
+ const componentIdSuitable = !condition.componentId || (item.componentId === condition.componentId)
+ const fieldIdSuitable = !condition.fieldId || (item.fieldId === condition.fieldId)
+ return !(componentIdSuitable && fieldIdSuitable)
+ })
+ this.executeSearch()
+ },
+ executeSearch() {
+ console.log('当前查询条件是: ' + JSON.stringify(this.conditions))
}
}
}
diff --git a/frontend/src/components/canvas/store/compose.js b/frontend/src/components/canvas/store/compose.js
index 2166b54bdc..c130e800e9 100644
--- a/frontend/src/components/canvas/store/compose.js
+++ b/frontend/src/components/canvas/store/compose.js
@@ -6,95 +6,95 @@ import { $ } from '@/components/canvas/utils/utils'
import { commonStyle, commonAttr } from '@/components/canvas/custom-component/component-list'
export default {
- state: {
- areaData: { // 选中区域包含的组件以及区域位移信息
- style: {
- top: 0,
- left: 0,
- width: 0,
- height: 0,
- },
- components: [],
- },
- editor: null,
+ state: {
+ areaData: { // 选中区域包含的组件以及区域位移信息
+ style: {
+ top: 0,
+ left: 0,
+ width: 0,
+ height: 0
+ },
+ components: []
},
- mutations: {
- getEditor(state) {
- state.editor = $('#editor')
- },
-
- setAreaData(state, data) {
- state.areaData = data
- },
-
- compose({ componentData, areaData, editor }) {
- const components = []
- areaData.components.forEach(component => {
- if (component.component != 'Group') {
- components.push(component)
- } else {
- // 如果要组合的组件中,已经存在组合数据,则需要提前拆分
- const parentStyle = { ...component.style }
- const subComponents = component.propValue
- const editorRect = editor.getBoundingClientRect()
-
- store.commit('deleteComponent')
- subComponents.forEach(component => {
- decomposeComponent(component, editorRect, parentStyle)
- store.commit('addComponent', { component })
- })
-
- components.push(...component.propValue)
- store.commit('batchDeleteComponent', component.propValue)
- }
- })
-
- store.commit('addComponent', {
- component: {
- id: generateID(),
- component: 'Group',
- ...commonAttr,
- style: {
- ...commonStyle,
- ...areaData.style,
- },
- propValue: components,
- },
- })
-
- eventBus.$emit('hideArea')
-
- store.commit('batchDeleteComponent', areaData.components)
- store.commit('setCurComponent', {
- component: componentData[componentData.length - 1],
- index: componentData.length - 1,
- })
-
- areaData.components = []
- },
-
- // 将已经放到 Group 组件数据删除,也就是在 componentData 中删除,因为它们已经放到 Group 组件中了
- batchDeleteComponent({ componentData }, deleteData) {
- deleteData.forEach(component => {
- for (let i = 0, len = componentData.length; i < len; i++) {
- if (component.id == componentData[i].id) {
- componentData.splice(i, 1)
- break
- }
- }
- })
- },
-
- decompose({ curComponent, editor }) {
- const parentStyle = { ...curComponent.style }
- const components = curComponent.propValue
- const editorRect = editor.getBoundingClientRect()
-
- store.commit('deleteComponent')
- components.forEach(component => {
- decomposeComponent(component, editorRect, parentStyle)
- store.commit('addComponent', { component })
- })
- },
+ editor: null
+ },
+ mutations: {
+ getEditor(state) {
+ state.editor = $('#editor')
},
+
+ setAreaData(state, data) {
+ state.areaData = data
+ },
+
+ compose({ componentData, areaData, editor }) {
+ const components = []
+ areaData.components.forEach(component => {
+ if (component.component !== 'Group') {
+ components.push(component)
+ } else {
+ // 如果要组合的组件中,已经存在组合数据,则需要提前拆分
+ const parentStyle = { ...component.style }
+ const subComponents = component.propValue
+ const editorRect = editor.getBoundingClientRect()
+
+ store.commit('deleteComponent')
+ subComponents.forEach(component => {
+ decomposeComponent(component, editorRect, parentStyle)
+ store.commit('addComponent', { component })
+ })
+
+ components.push(...component.propValue)
+ store.commit('batchDeleteComponent', component.propValue)
+ }
+ })
+
+ store.commit('addComponent', {
+ component: {
+ id: generateID(),
+ component: 'Group',
+ ...commonAttr,
+ style: {
+ ...commonStyle,
+ ...areaData.style
+ },
+ propValue: components
+ }
+ })
+
+ eventBus.$emit('hideArea')
+
+ store.commit('batchDeleteComponent', areaData.components)
+ store.commit('setCurComponent', {
+ component: componentData[componentData.length - 1],
+ index: componentData.length - 1
+ })
+
+ areaData.components = []
+ },
+
+ // 将已经放到 Group 组件数据删除,也就是在 componentData 中删除,因为它们已经放到 Group 组件中了
+ batchDeleteComponent({ componentData }, deleteData) {
+ deleteData.forEach(component => {
+ for (let i = 0, len = componentData.length; i < len; i++) {
+ if (component.id == componentData[i].id) {
+ componentData.splice(i, 1)
+ break
+ }
+ }
+ })
+ },
+
+ decompose({ curComponent, editor }) {
+ const parentStyle = { ...curComponent.style }
+ const components = curComponent.propValue
+ const editorRect = editor.getBoundingClientRect()
+
+ store.commit('deleteComponent')
+ components.forEach(component => {
+ decomposeComponent(component, editorRect, parentStyle)
+ store.commit('addComponent', { component })
+ })
+ }
+ }
}
diff --git a/frontend/src/components/canvas/utils/style.js b/frontend/src/components/canvas/utils/style.js
index 3b1fd50f71..f426d07177 100644
--- a/frontend/src/components/canvas/utils/style.js
+++ b/frontend/src/components/canvas/utils/style.js
@@ -1,55 +1,55 @@
import { sin, cos } from '@/components/canvas/utils/translate'
export function getStyle(style, filter = []) {
- const needUnit = [
- 'fontSize',
- 'width',
- 'height',
- 'top',
- 'left',
- 'borderWidth',
- 'letterSpacing',
- 'borderRadius',
- ]
+ const needUnit = [
+ 'fontSize',
+ 'width',
+ 'height',
+ 'top',
+ 'left',
+ 'borderWidth',
+ 'letterSpacing',
+ 'borderRadius'
+ ]
- const result = {}
- Object.keys(style).forEach(key => {
- if (!filter.includes(key)) {
- if (key != 'rotate') {
- result[key] = style[key]
+ const result = {}
+ Object.keys(style).forEach(key => {
+ if (!filter.includes(key)) {
+ if (key !== 'rotate') {
+ result[key] = style[key]
- if (needUnit.includes(key)) {
- result[key] += 'px'
- }
- } else {
- result.transform = key + '(' + style[key] + 'deg)'
- }
+ if (needUnit.includes(key)) {
+ result[key] += 'px'
}
- })
+ } else {
+ result.transform = key + '(' + style[key] + 'deg)'
+ }
+ }
+ })
- return result
+ return result
}
// 获取一个组件旋转 rotate 后的样式
export function getComponentRotatedStyle(style) {
- style = { ...style }
- if (style.rotate != 0) {
- const newWidth = style.width * cos(style.rotate) + style.height * sin(style.rotate)
- const diffX = (style.width - newWidth) / 2 // 旋转后范围变小是正值,变大是负值
- style.left += diffX
- style.right = style.left + newWidth
+ style = { ...style }
+ if (style.rotate != 0) {
+ const newWidth = style.width * cos(style.rotate) + style.height * sin(style.rotate)
+ const diffX = (style.width - newWidth) / 2 // 旋转后范围变小是正值,变大是负值
+ style.left += diffX
+ style.right = style.left + newWidth
- const newHeight = style.height * cos(style.rotate) + style.width * sin(style.rotate)
- const diffY = (newHeight - style.height) / 2 // 始终是正
- style.top -= diffY
- style.bottom = style.top + newHeight
+ const newHeight = style.height * cos(style.rotate) + style.width * sin(style.rotate)
+ const diffY = (newHeight - style.height) / 2 // 始终是正
+ style.top -= diffY
+ style.bottom = style.top + newHeight
- style.width = newWidth
- style.height = newHeight
- } else {
- style.bottom = style.top + style.height
- style.right = style.left + style.width
- }
+ style.width = newWidth
+ style.height = newHeight
+ } else {
+ style.bottom = style.top + style.height
+ style.right = style.left + style.width
+ }
- return style
+ return style
}
diff --git a/frontend/src/components/widget/DeWidget/DeDrawingWidget.vue b/frontend/src/components/widget/DeWidget/DeDrawingWidget.vue
index 03bf5480d8..0cebb0cd2d 100644
--- a/frontend/src/components/widget/DeWidget/DeDrawingWidget.vue
+++ b/frontend/src/components/widget/DeWidget/DeDrawingWidget.vue
@@ -1,5 +1,6 @@