This commit is contained in:
pipipi-pikachu 2021-01-23 01:10:00 +08:00
parent 8ba7a9d91c
commit 53050b5681
3 changed files with 34 additions and 10 deletions

View File

@ -51,6 +51,5 @@ export default defineComponent({
right: 0; right: 0;
background-color: #fff; background-color: #fff;
padding: 10px; padding: 10px;
z-index: -1;
} }
</style> </style>

View File

@ -53,7 +53,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { computed, defineComponent, nextTick, onMounted, onUnmounted, ref } from 'vue' import { computed, defineComponent, nextTick, onMounted, onUnmounted, PropType, ref } from 'vue'
import { ContextmenuItem } from './Contextmenu/types' import { ContextmenuItem } from './Contextmenu/types'
import { KEYS } from '@/configs/hotkey' import { KEYS } from '@/configs/hotkey'
import { createRandomCode } from '@/utils/common' import { createRandomCode } from '@/utils/common'
@ -81,6 +81,11 @@ export default defineComponent({
components: { components: {
EditableDiv, EditableDiv,
}, },
props: {
tableCells: {
type: Array as PropType<TableCells[][]>,
},
},
setup() { setup() {
const tableCells = ref<TableCells[][]>([ const tableCells = ref<TableCells[][]>([
[ [
@ -195,11 +200,11 @@ export default defineComponent({
const handleMouseup = () => isStartSelect.value = false const handleMouseup = () => isStartSelect.value = false
const handleCellMousedown = (e: MouseEvent, rowIndex: number, colIndex: number) => { const handleCellMousedown = (e: MouseEvent, rowIndex: number, colIndex: number) => {
if(e.which !== 1) return if(e.button === 0) {
endCell.value = []
endCell.value = [] isStartSelect.value = true
isStartSelect.value = true startCell.value = [rowIndex, colIndex]
startCell.value = [rowIndex, colIndex] }
} }
const handleCellMouseenter = (rowIndex: number, colIndex: number) => { const handleCellMouseenter = (rowIndex: number, colIndex: number) => {
@ -486,14 +491,23 @@ export default defineComponent({
{ divider: true }, { divider: true },
{ {
text: '合并单元格', text: '合并单元格',
hide: !isMultiSelected, disable: !isMultiSelected,
handler: mergeCells, handler: mergeCells,
}, },
{ {
text: '取消合并单元格', text: '取消合并单元格',
hide: isMultiSelected || !canSplit, disable: isMultiSelected || !canSplit,
handler: () => splitCells(rowIndex, colIndex), handler: () => splitCells(rowIndex, colIndex),
}, },
{ divider: true },
{
text: '选中当前列',
handler: () => selectCol(colIndex),
},
{
text: '选中当前行',
handler: () => selectRow(rowIndex),
},
{ {
text: '选中全部单元格', text: '选中全部单元格',
handler: selectAll, handler: selectAll,
@ -545,6 +559,17 @@ table {
border: 1px solid #d9d9d9; border: 1px solid #d9d9d9;
cursor: default; cursor: default;
&.active::after {
content: '';
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
border: 1px solid rgba($color: $themeColor, $alpha: .5);
pointer-events: none;
}
&.selected::after { &.selected::after {
content: ''; content: '';
width: 100%; width: 100%;

View File

@ -253,7 +253,7 @@ export default defineComponent({
} }
.viewport-wrapper { .viewport-wrapper {
position: absolute; position: absolute;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, .1); box-shadow: 0 0 15px 0 rgba(0, 0, 0, 0.1);
} }
.viewport { .viewport {
position: absolute; position: absolute;