@dt-frames/ui 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/components/curd/src/components/dialog.d.ts +7 -3
- package/es/components/forms/src/components/formInputUseDialog.d.ts +903 -0
- package/es/components/forms/src/types/form.type.d.ts +3 -1
- package/es/components/modal/src/types/modal.type.d.ts +4 -1
- package/es/components/table/src/hooks/useCustomRow.d.ts +19 -0
- package/es/components/table/src/index.d.ts +21 -2
- package/es/components/table/src/props.d.ts +4 -0
- package/es/components/upload/src/index.d.ts +21 -2
- package/es/components/upload/src/upload.d.ts +21 -2
- package/es/index.js +150 -34
- package/es/style/components/forms/index.less +23 -0
- package/package.json +1 -1
- package/src/components/curd/src/components/dialog.vue +3 -2
- package/src/components/forms/index.less +23 -0
- package/src/components/forms/src/componentMap.ts +2 -0
- package/src/components/forms/src/components/formInputUseDialog.vue +43 -0
- package/src/components/forms/src/components/formItem.vue +10 -10
- package/src/components/forms/src/types/form.type.ts +6 -0
- package/src/components/modal/src/hooks/useModal.ts +7 -1
- package/src/components/modal/src/types/modal.type.ts +4 -1
- package/src/components/source/src/hooks/useSource.ts +1 -1
- package/src/components/table/src/components/TableHeader.vue +1 -1
- package/src/components/table/src/hooks/useCustomRow.ts +86 -0
- package/src/components/table/src/index.vue +14 -2
- package/src/components/table/src/props.ts +3 -0
|
@@ -8,7 +8,10 @@ export type ModalMethods = {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export interface ReturnMethods extends ModalMethods{
|
|
11
|
-
openModal:
|
|
11
|
+
openModal: (data?: {
|
|
12
|
+
data?: Recordable,
|
|
13
|
+
afterClose?: ( data: Recordable ) => void
|
|
14
|
+
}, openOnSet?: boolean) => void
|
|
12
15
|
closeModal: () => void
|
|
13
16
|
getVisible?: ComputedRef<boolean>
|
|
14
17
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ref, reactive, toRaw, Ref } from 'vue'
|
|
2
|
-
import { isString, Recordable, useMessage } from "@dt-frames/core"
|
|
2
|
+
import { isFunction, isString, Recordable, useMessage } from "@dt-frames/core"
|
|
3
3
|
import { BaseDataType, SourceType } from "../types/source.type"
|
|
4
4
|
import { useFetch } from './useFetch'
|
|
5
5
|
import { TableParamsType } from '../types/table.type'
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { DtEvent, Recordable } from "@dt-frames/core"
|
|
2
|
+
import { ComputedRef, unref } from "vue"
|
|
3
|
+
import { BasicTableProps } from "../types/table.type"
|
|
4
|
+
|
|
5
|
+
interface Options {
|
|
6
|
+
setSelectedRowKeys: (keys: string[]) => void
|
|
7
|
+
getSelectRowKeys: () => string[]
|
|
8
|
+
clearSelectedRowKeys: () => void
|
|
9
|
+
emit: any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function useCustomRow(
|
|
13
|
+
propsRef: ComputedRef<BasicTableProps>,
|
|
14
|
+
{ setSelectedRowKeys, getSelectRowKeys, clearSelectedRowKeys, emit }: Options
|
|
15
|
+
) {
|
|
16
|
+
const customRow = (record: Recordable, index: number) => {
|
|
17
|
+
return {
|
|
18
|
+
onClick: (e) => {
|
|
19
|
+
e?.stopPropagation()
|
|
20
|
+
|
|
21
|
+
function handleClick() {
|
|
22
|
+
const { rowSelection, rowKey, clickToRowSelect } = unref(propsRef)
|
|
23
|
+
if (!rowSelection || !clickToRowSelect) return
|
|
24
|
+
|
|
25
|
+
const keys = getSelectRowKeys()
|
|
26
|
+
const key = record[rowKey]
|
|
27
|
+
if (!key) return
|
|
28
|
+
|
|
29
|
+
const isCheckbox = rowSelection.type === 'checkbox'
|
|
30
|
+
if (isCheckbox) {
|
|
31
|
+
const tr: HTMLElement = (e as MouseEvent)
|
|
32
|
+
.composedPath?.()
|
|
33
|
+
.find((dom: HTMLElement) => dom.tagName === 'TR') as HTMLElement;
|
|
34
|
+
if (!tr) return
|
|
35
|
+
|
|
36
|
+
const checkBox = tr.querySelector('input[type=checkbox]')
|
|
37
|
+
|
|
38
|
+
if (!checkBox || checkBox.hasAttribute('disabled')) return
|
|
39
|
+
|
|
40
|
+
if (!keys.includes(key)) {
|
|
41
|
+
setSelectedRowKeys([...keys, key])
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const keyIndex = keys.findIndex((item) => item === key)
|
|
46
|
+
keys.splice(keyIndex, 1)
|
|
47
|
+
setSelectedRowKeys(keys)
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const isRadio = rowSelection.type === 'radio'
|
|
52
|
+
|
|
53
|
+
if (isRadio) {
|
|
54
|
+
if (!keys.includes(key)) {
|
|
55
|
+
if (keys.length) {
|
|
56
|
+
clearSelectedRowKeys()
|
|
57
|
+
}
|
|
58
|
+
setSelectedRowKeys([key])
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
clearSelectedRowKeys()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
handleClick()
|
|
66
|
+
emit('row-click', record, index, e)
|
|
67
|
+
},
|
|
68
|
+
onDblclick: (event: Event) => {
|
|
69
|
+
emit('row-dbClick', record, index, event);
|
|
70
|
+
},
|
|
71
|
+
onContextmenu: (event: Event) => {
|
|
72
|
+
emit('row-contextmenu', record, index, event);
|
|
73
|
+
},
|
|
74
|
+
onMouseenter: (event: Event) => {
|
|
75
|
+
emit('row-mouseenter', record, index, event);
|
|
76
|
+
},
|
|
77
|
+
onMouseleave: (event: Event) => {
|
|
78
|
+
emit('row-mouseleave', record, index, event);
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
customRow,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
import { useColumns } from "./hooks/useColumns"
|
|
38
38
|
import { useTableHeader } from "./hooks/useTableHeader"
|
|
39
39
|
import { useTableScroll } from "./hooks/useTableScroll"
|
|
40
|
+
import { useCustomRow } from "./hooks/useCustomRow"
|
|
40
41
|
|
|
41
42
|
|
|
42
43
|
export default defineComponent({
|
|
@@ -52,6 +53,9 @@
|
|
|
52
53
|
'selection-change',
|
|
53
54
|
'row-click',
|
|
54
55
|
'row-dbClick',
|
|
56
|
+
'row-contextmenu',
|
|
57
|
+
'row-mouseenter',
|
|
58
|
+
'row-mouseleave',
|
|
55
59
|
'expanded-rows-change',
|
|
56
60
|
'edit-change'
|
|
57
61
|
],
|
|
@@ -95,7 +99,7 @@
|
|
|
95
99
|
getRowSelection,
|
|
96
100
|
getSelectRows,
|
|
97
101
|
getSelectRowKeys,
|
|
98
|
-
|
|
102
|
+
setSelectedRowKeys
|
|
99
103
|
} = useRowSelection(getProps, emit)
|
|
100
104
|
|
|
101
105
|
// 关于滚动条的设置
|
|
@@ -145,6 +149,13 @@
|
|
|
145
149
|
emit
|
|
146
150
|
)
|
|
147
151
|
|
|
152
|
+
// 表格的单击 双击事件
|
|
153
|
+
const { customRow } = useCustomRow(getProps, {
|
|
154
|
+
setSelectedRowKeys,
|
|
155
|
+
getSelectRowKeys,
|
|
156
|
+
clearSelectedRowKeys,
|
|
157
|
+
emit
|
|
158
|
+
})
|
|
148
159
|
|
|
149
160
|
const getBind = computed(() => {
|
|
150
161
|
return {
|
|
@@ -158,7 +169,8 @@
|
|
|
158
169
|
rowSelection: unref(getRowSelectionRef),
|
|
159
170
|
rowKey: unref(getProps).rowKey,
|
|
160
171
|
columns: unref(getViewColumns),
|
|
161
|
-
tableLayout: 'fixed'
|
|
172
|
+
tableLayout: 'fixed',
|
|
173
|
+
customRow,
|
|
162
174
|
}
|
|
163
175
|
})
|
|
164
176
|
|
|
@@ -14,6 +14,9 @@ export const TableProps = {
|
|
|
14
14
|
// 表格设置
|
|
15
15
|
tableSetting: {type: Object as PropType<TableSetting | boolean>, default: () => ({})},
|
|
16
16
|
|
|
17
|
+
// 点击行是否可以选中整行数据
|
|
18
|
+
clickToRowSelect: { type: Boolean, default: false },
|
|
19
|
+
|
|
17
20
|
// 是否显示斑马条纹
|
|
18
21
|
striped: { type: Boolean, default: true },
|
|
19
22
|
|