|
@@ -1,27 +1,27 @@
|
|
|
<template>
|
|
|
- <div class="roy-simple-table">
|
|
|
+ <div class="yvan-simple-table">
|
|
|
<Context ref="simple-table-contextmenu" :theme="contextTheme">
|
|
|
<ContextItem
|
|
|
- v-for="item in contextMenu"
|
|
|
- :key="item.code"
|
|
|
- :class="`yvan-context--${item.status}`"
|
|
|
- @click="item.event"
|
|
|
+ v-for="item in contextMenu"
|
|
|
+ :key="item.code"
|
|
|
+ :class="`yvan-context--${item.status}`"
|
|
|
+ @click="item.event"
|
|
|
>
|
|
|
<i :class="item.icon"></i>
|
|
|
<span>{{ item.label }}</span>
|
|
|
</ContextItem>
|
|
|
</Context>
|
|
|
<StyledSimpleTable v-bind="style">
|
|
|
- <table ref="royTable">
|
|
|
+ <table ref="yvanTable">
|
|
|
<tbody>
|
|
|
- <tr v-for="(row, index) in tableConfig.rows" :key="index">
|
|
|
- <td
|
|
|
+ <tr v-for="(row, index) in tableConfig.rows" :key="index">
|
|
|
+ <td
|
|
|
v-for="(col, index) in tableConfig.cols"
|
|
|
v-show="isNeedShow(row - 1, col - 1)"
|
|
|
:key="index"
|
|
|
v-contextmenu="'simple-table-contextmenu'"
|
|
|
:class="{
|
|
|
- 'roy-simple-table-cell--selected': getIsActiveCell(row, col)
|
|
|
+ 'yvan-simple-table-cell--selected': getIsActiveCell(row, col)
|
|
|
}"
|
|
|
:colspan="getItColSpan(row, col)"
|
|
|
:rowspan="getItRowSpan(row, col)"
|
|
@@ -35,11 +35,11 @@
|
|
|
@mouseup="handleMouseUp"
|
|
|
@mousedown.stop="(e) => handleCellMousedown(e, row, col)"
|
|
|
@mouseenter.stop.prevent="handleCellMouseenter(row, col)"
|
|
|
- >
|
|
|
- <component
|
|
|
+ >
|
|
|
+ <component
|
|
|
:is="tableData[`${row}-${col}`] && tableData[`${row}-${col}`].component"
|
|
|
v-if="tableData[`${row}-${col}`]"
|
|
|
- :id="`roy-component-${tableData[`${row}-${col}`].id}`"
|
|
|
+ :id="`yvan-component-${tableData[`${row}-${col}`].id}`"
|
|
|
:bind-value.sync="tableData[`${row}-${col}`].bindValue"
|
|
|
:cur-id="curClickedId"
|
|
|
:element="tableData[`${row}-${col}`]"
|
|
@@ -54,27 +54,29 @@
|
|
|
componentUpdated(row, col, value)
|
|
|
}
|
|
|
"
|
|
|
- />
|
|
|
- <div
|
|
|
+ />
|
|
|
+ <div
|
|
|
v-if="getIsActiveCell(row, col) && selectedCells.length === 1"
|
|
|
- class="roy-simple-table__cell__corner"
|
|
|
+ class="yvan-simple-table__cell__corner"
|
|
|
@mousedown="handleMouseDownOnResize(row, col, $event)"
|
|
|
- ></div>
|
|
|
- </td>
|
|
|
- </tr>
|
|
|
+ ></div>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
</tbody>
|
|
|
</table>
|
|
|
</StyledSimpleTable>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { mapState } from 'vuex'
|
|
|
-import { Context, ContextItem, directive } from '@/components/RoyContext'
|
|
|
-import RoySimpleTextIn from './RoySimpleTextInTable.vue'
|
|
|
-import RoyTextIn from '@/components/PageComponents/RoyTable/RoyTextInTable'
|
|
|
-import commonMixin from '@/mixin/commonMixin'
|
|
|
+import {mapState} from 'pinia'
|
|
|
+import {globalStore} from "@/store"
|
|
|
import toast from '@/utils/toast'
|
|
|
-import { StyledSimpleTable } from '@/components/PageComponents/style'
|
|
|
+import commonMixin from '@/mixin/commonMixin'
|
|
|
+import {StyledSimpleTable} from '@/components/PageComponents/style'
|
|
|
+import {Context, ContextItem, directive} from '@/components/yvan-context'
|
|
|
+import YvanTextIn from '@/components/PageComponents/yvan-table/YvanTextInTable.vue'
|
|
|
+import YvanSimpleTextIn from '@/components/PageComponents/yvan-table/YvanSimpleTextInTable.vue'
|
|
|
+import YvanSimpleTableProps from '@/components/PageComponents/yvan-table/YvanSimpleTableProps.vue'
|
|
|
|
|
|
const defaultTableCell = {
|
|
|
icon: 'ri-text',
|
|
@@ -120,7 +122,7 @@ const defaultTableCell = {
|
|
|
}
|
|
|
|
|
|
export default {
|
|
|
- name: 'RoySimpleTable',
|
|
|
+ name: 'YvanSimpleTable',
|
|
|
mixins: [commonMixin],
|
|
|
directives: {
|
|
|
contextmenu: directive
|
|
@@ -128,14 +130,15 @@ export default {
|
|
|
components: {
|
|
|
Context,
|
|
|
ContextItem,
|
|
|
- RoyTextIn,
|
|
|
- RoySimpleTextIn,
|
|
|
+ YvanTextIn,
|
|
|
+ YvanSimpleTextIn,
|
|
|
StyledSimpleTable
|
|
|
},
|
|
|
props: {
|
|
|
element: {
|
|
|
type: Object,
|
|
|
- default: () => {}
|
|
|
+ default: () => {
|
|
|
+ }
|
|
|
},
|
|
|
propValue: {
|
|
|
type: Object,
|
|
@@ -250,27 +253,23 @@ export default {
|
|
|
event: () => {
|
|
|
this.menyItemCmd('clearSelection')
|
|
|
}
|
|
|
- },
|
|
|
- {
|
|
|
- code: 'setting',
|
|
|
- icon: 'ri-list-settings-line',
|
|
|
- label: '属性',
|
|
|
- status: 'default',
|
|
|
- event: () => {
|
|
|
- this.$store.commit('printTemplateModule/setPaletteCount')
|
|
|
- }
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
},
|
|
|
- created() {},
|
|
|
+ install(Vue){
|
|
|
+ Vue.component(this.name, this)
|
|
|
+ Vue.component(YvanSimpleTableProps.name, YvanSimpleTableProps)
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.initMounted()
|
|
|
},
|
|
|
computed: {
|
|
|
- ...mapState({
|
|
|
- editor: (state) => state.printTemplateModule.editor,
|
|
|
- isNightMode: (state) => state.printTemplateModule.nightMode.isNightMode
|
|
|
+ ...mapState(globalStore, {
|
|
|
+ editor: (state) => state.editor,
|
|
|
+ isNightMode: (state) => false
|
|
|
}),
|
|
|
style() {
|
|
|
return this.element.style || {}
|
|
@@ -286,8 +285,8 @@ export default {
|
|
|
if (tableConfig.layoutDetail[i * tableConfig.cols + j]) {
|
|
|
let colInfo = tableConfig.layoutDetail[i * tableConfig.cols + j]
|
|
|
if (
|
|
|
- (colInfo.colSpan && colInfo.colSpan > 1) ||
|
|
|
- (colInfo.rowSpan && colInfo.rowSpan > 1)
|
|
|
+ (colInfo.colSpan && colInfo.colSpan > 1) ||
|
|
|
+ (colInfo.rowSpan && colInfo.rowSpan > 1)
|
|
|
) {
|
|
|
for (let row = i; row < i + (colInfo.rowSpan || 1); row++) {
|
|
|
// col = (row === i ? j + 1 : j) 是为了避开自己
|
|
@@ -328,21 +327,21 @@ export default {
|
|
|
},
|
|
|
getItColSpan(row, col) {
|
|
|
return (
|
|
|
- this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1] &&
|
|
|
- this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1]['colSpan']
|
|
|
+ this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1] &&
|
|
|
+ this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1]['colSpan']
|
|
|
)
|
|
|
},
|
|
|
getItRowSpan(row, col) {
|
|
|
return (
|
|
|
- this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1] &&
|
|
|
- this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1]['rowSpan']
|
|
|
+ this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1] &&
|
|
|
+ this.tableConfig.layoutDetail[(row - 1) * this.tableConfig.cols + col - 1]['rowSpan']
|
|
|
)
|
|
|
},
|
|
|
handleCellMousedown(e, x, y) {
|
|
|
this.$refs['simple-table-contextmenu'].hide()
|
|
|
- this.$store.commit('printTemplateModule/setInEditorStatus', true)
|
|
|
- this.$store.commit('printTemplateModule/setClickComponentStatus', true)
|
|
|
- this.$store.commit('printTemplateModule/setCurTableCell', {
|
|
|
+ globalStore().setInEditorStatus(true)
|
|
|
+ globalStore().setClickComponentStatus(true)
|
|
|
+ globalStore().setCurTableCell({
|
|
|
component: this.tableData[`${x}-${y}`]
|
|
|
})
|
|
|
// e.witch = 1 是鼠标左键
|
|
@@ -449,11 +448,11 @@ export default {
|
|
|
const startIndex = (startX - 1) * tableConfig.cols + startY - 1
|
|
|
const groupId = this.getUuid()
|
|
|
if (
|
|
|
- startX === -1 ||
|
|
|
- startY === -1 ||
|
|
|
- endX === -1 ||
|
|
|
- endY === -1 ||
|
|
|
- (startX === endX && startY === endY)
|
|
|
+ startX === -1 ||
|
|
|
+ startY === -1 ||
|
|
|
+ endX === -1 ||
|
|
|
+ endY === -1 ||
|
|
|
+ (startX === endX && startY === endY)
|
|
|
) {
|
|
|
toast('请选中要合并的单元格')
|
|
|
return
|
|
@@ -467,13 +466,13 @@ export default {
|
|
|
let startCellData = this.tableData[`${startX}-${startY}`]
|
|
|
let endCellData = this.tableData[`${endX}-${endY}`]
|
|
|
let startComponent = document
|
|
|
- .getElementById(`roy-component-${startCellData.id}`)
|
|
|
- .getBoundingClientRect()
|
|
|
+ .getElementById(`yvan-component-${startCellData.id}`)
|
|
|
+ .getBoundingClientRect()
|
|
|
let endComponent = document
|
|
|
- .getElementById(`roy-component-${endCellData.id}`)
|
|
|
- .getBoundingClientRect()
|
|
|
- const { x: startAriaX, y: startAriaY } = startComponent
|
|
|
- const { x: endAriaX, y: endAriaY, width: endWidth, height: endHeight } = endComponent
|
|
|
+ .getElementById(`yvan-component-${endCellData.id}`)
|
|
|
+ .getBoundingClientRect()
|
|
|
+ const {x: startAriaX, y: startAriaY} = startComponent
|
|
|
+ const {x: endAriaX, y: endAriaY, width: endWidth, height: endHeight} = endComponent
|
|
|
curTableData.width = Math.abs(endAriaX - startAriaX) + endWidth
|
|
|
curTableData.height = Math.abs(endAriaY - startAriaY) + endHeight
|
|
|
this.tableConfig.layoutDetail[curIndex].rowSpan = endX - startX + 1
|
|
@@ -494,7 +493,7 @@ export default {
|
|
|
return
|
|
|
}
|
|
|
let startIndex = (startX - 1) * tableConfig.cols + startY - 1
|
|
|
- const { groupId } = this.tableConfig.layoutDetail[startIndex]
|
|
|
+ const {groupId} = this.tableConfig.layoutDetail[startIndex]
|
|
|
if (!groupId) {
|
|
|
return
|
|
|
}
|
|
@@ -532,7 +531,7 @@ export default {
|
|
|
})
|
|
|
this.reRenderTableLayout()
|
|
|
},
|
|
|
- onCellActive({ id }) {
|
|
|
+ onCellActive({id}) {
|
|
|
this.curClickedId = id
|
|
|
},
|
|
|
handleMouseDownOnResize(row, col, e) {
|
|
@@ -544,12 +543,12 @@ export default {
|
|
|
if (!element) {
|
|
|
return
|
|
|
}
|
|
|
- const comEle = document.getElementById(`roy-component-${element.id}`)
|
|
|
+ const comEle = document.getElementById(`yvan-component-${element.id}`)
|
|
|
if (!comEle) {
|
|
|
return
|
|
|
}
|
|
|
const move = (moveEvent) => {
|
|
|
- const { width, height } = comEle.getBoundingClientRect()
|
|
|
+ const {width, height} = comEle.getBoundingClientRect()
|
|
|
const deltaX = moveEvent.movementX
|
|
|
const deltaY = moveEvent.movementY
|
|
|
|
|
@@ -580,12 +579,11 @@ export default {
|
|
|
tableData: this.deepCopy(this.tableData),
|
|
|
tableConfig: this.deepCopy(this.tableConfig)
|
|
|
}
|
|
|
- this.$store.commit('printTemplateModule/setPropValue', {
|
|
|
+ globalStore().setPropValue({
|
|
|
id: this.element.id,
|
|
|
propValue
|
|
|
})
|
|
|
- // this.$emit('update:propValue', propValue)
|
|
|
- this.$store.commit('printTemplateModule/updateDataValue', {
|
|
|
+ globalStore().updateDataValue({
|
|
|
data: this.element,
|
|
|
value: propValue,
|
|
|
key: 'propValue'
|
|
@@ -618,7 +616,7 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|
|
|
-.roy-simple-table {
|
|
|
+.yvan-simple-table {
|
|
|
user-select: none;
|
|
|
}
|
|
|
</style>
|