Skip to content

Commit 4adaaa0

Browse files
committed
Support batch deletion.
1 parent ce93b1c commit 4adaaa0

File tree

5 files changed

+26
-28
lines changed

5 files changed

+26
-28
lines changed

src/components/common/menu.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { provide, ref } from 'vue'
33
import { FN_CLOSE_CONTEXT_MENU } from '../../constant'
44
import { IwUtils } from '../../utils';
55
6-
const contextmenu = ref<HTMLElement | null>(null)
6+
const contextmenuRef = ref<HTMLElement | null>(null)
77
const isShow = ref<boolean>(false)
88
99
function showContextMenu(attachObj: HTMLElement | MouseEvent, offset: MenuOffsetKind = MenuOffsetKind.LEFT_BOTTOM, size: MenuSizeKind = MenuSizeKind.MEDIUM) {
@@ -72,7 +72,7 @@ function showContextMenu(attachObj: HTMLElement | MouseEvent, offset: MenuOffset
7272
break
7373
}
7474
}
75-
const contextMenuEle = contextmenu.value as HTMLElement
75+
const contextMenuEle = contextmenuRef.value as HTMLElement
7676
contextMenuEle.style.minHeight = minHeight + 'px'
7777
contextMenuEle.style.minWidth = minWidth + 'px'
7878
contextMenuEle.style.left = left + 'px'
@@ -128,8 +128,8 @@ export enum MenuSizeKind {
128128
</script>
129129

130130
<template>
131-
<div ref="contextmenu" class="iw-contextmenu flex flex-col items-start fixed z-[3000] shadow bg-base-100 p-1 rounded-md"
132-
v-show="isShow">
131+
<div ref="contextmenuRef"
132+
class="iw-contextmenu flex flex-col items-start fixed z-[3000] shadow bg-base-100 p-1 rounded-md" v-show="isShow">
133133
<slot></slot>
134134
</div>
135135
</template>

src/components/layout/list/CellFill.vue

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ const props = defineProps<{
1212
1313
let updateDataFun = inject(FN_UPDATE_DATA)
1414
15-
let startColumnName = ''
16-
let startRowIdx = 0
17-
let movedRowIdx = 0
18-
let startCellFixedX = 0
19-
let startCellEle: HTMLElement
20-
let isDragging = false
21-
2215
onMounted(() => {
16+
let startColumnName = ''
17+
let startRowIdx = 0
18+
let movedRowIdx = 0
19+
let startCellFixedX = 0
20+
let startCellEle: HTMLElement
21+
let isDragging = false
2322
const listEle = document.getElementsByClassName('iw-list')[0] as HTMLElement
2423
const selectDiv = document.createElement('div')
2524
selectDiv.classList.add('iw-list-fill--select')
@@ -45,7 +44,7 @@ onMounted(() => {
4544
selectDiv.style.display = 'none'
4645
4746
let records
48-
// TODO
47+
// TODO 判断dom idx @see row select
4948
const groupValue = 'Name1'
5049
if (!groupValue) {
5150
const data = props.data as TableDataResp

src/components/layout/list/RowDelete.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as iconSvg from '../../../assets/icon'
44
import { FN_CLOSE_CONTEXT_MENU, FN_DELETE_DATA } from '../../../constant'
55
66
const props = defineProps<{
7-
selectPks: string[] | number[] | undefined
7+
selectPks: string[] | number[]
88
}>()
99
1010
let closeContextMenuFun = inject(FN_CLOSE_CONTEXT_MENU)

src/components/skeleton.vue

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import MenuComp, { MenuOffsetKind } from './common/Menu.vue'
66
import { TableLayoutConf, TableStyleConf, initConf } from './conf'
77
import ResizeComp from './function/resize/Resize.vue'
88
import ThemeComp from './function/theme/Theme.vue'
9-
import * as List from './layout/list/conf'
109
import ListComp from './layout/list/List.vue'
10+
import * as List from './layout/list/conf'
1111
import { OperatorKind, SizeKind, TableProps } from './props'
1212
1313
const props = defineProps<TableProps>()
@@ -155,19 +155,10 @@ async function deleteData(deletedPks: any[], reFilter?: boolean, reSort?: boolea
155155
}
156156
if (Array.isArray(layout.data)) {
157157
layout.data.forEach((d) => {
158-
d.records.forEach((item, idx) => {
159-
if (deletedPks.includes(item[tableBasicConf.pkColumnName])) {
160-
d.records.splice(idx, 1)
161-
}
162-
})
158+
d.records = d.records.filter((item) => !deletedPks.includes(item[tableBasicConf.pkColumnName]))
163159
})
164160
} else if (layout.data && !Array.isArray(layout.data)) {
165-
layout.data.records.forEach((item, idx) => {
166-
if (deletedPks.includes(item[tableBasicConf.pkColumnName])) {
167-
// @ts-ignore
168-
layout.data.records.splice(idx, 1)
169-
}
170-
})
161+
layout.data.records = layout.data.records.filter((item) => !deletedPks.includes(item[tableBasicConf.pkColumnName]))
171162
} else {
172163
// Empty,unreachable
173164
}

src/utils/basic.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,19 @@ export const groupBy = <T>(array: T[], predicate: (value: T, index: number, arra
55
}, {} as { [key: string]: T[] })
66

77
export const hasParentWithClass = (element: HTMLElement | null, className: string): boolean => {
8+
return getParentWithClass(element, className) != null
9+
}
10+
11+
export const getParentWithClass = (element: HTMLElement | null, className: string): HTMLElement | null => {
812
while (element) {
913
if (element.classList && element.classList.contains(className)) {
10-
return true
14+
return element
1115
}
12-
element = element.parentElement;
16+
element = element.parentElement
1317
}
14-
return false
18+
return null
1519
}
20+
21+
export const getChildIndex = (parent: HTMLElement, child: HTMLElement): number => {
22+
return Array.prototype.indexOf.call(parent.children, child)
23+
}

0 commit comments

Comments
 (0)