@dt-frames/ui 1.0.8 → 1.0.11
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 +1 -0
- package/es/components/forms/src/components/formIcon.d.ts +1 -1
- package/es/components/forms/src/types/form.type.d.ts +3 -3
- package/es/components/index.d.ts +3 -2
- package/es/components/modal/src/types/modal.type.d.ts +1 -1
- package/es/components/source/src/hooks/useFetch.d.ts +2 -2
- package/es/components/source/src/hooks/useSource.d.ts +8 -8
- package/es/components/source/src/types/table.type.d.ts +1 -1
- package/es/components/table/src/components/TableActions.d.ts +2 -2
- package/es/components/table/src/components/TableHeader.d.ts +2 -2
- package/es/components/table/src/components/editable/CellComponent.d.ts +14 -0
- package/es/components/table/src/components/editable/EditTableCell.d.ts +88 -0
- package/es/components/table/src/components/editable/componentMap.d.ts +4 -0
- package/es/components/table/src/components/editable/index.d.ts +9 -0
- package/es/components/table/src/components/setting/Download.d.ts +2 -2
- package/es/components/table/src/components/setting/Size.d.ts +2 -2
- package/es/components/table/src/index.d.ts +9 -5
- package/es/components/table/src/props.d.ts +1 -1
- package/es/components/table/src/types/table.type.d.ts +16 -0
- package/es/components/tree/index.d.ts +2 -0
- package/es/components/tree/src/hooks/useTree.d.ts +14 -0
- package/es/components/tree/src/props.d.ts +101 -0
- package/es/components/tree/src/type/tree.d.ts +85 -0
- package/es/components/tree/src/utils/tree.d.ts +5 -0
- package/es/components/upload/index.d.ts +3 -0
- package/es/components/upload/src/helper.d.ts +4 -0
- package/es/components/upload/src/index.d.ts +2788 -0
- package/es/components/upload/src/props.d.ts +40 -0
- package/es/components/upload/src/upload.d.ts +1634 -0
- package/es/index.js +2035 -308
- package/es/style/components/table/index.less +8 -2
- package/es/style/components/tree/index.less +41 -0
- package/es/style/components/upload/index.less +43 -0
- package/es/style/theme/header/index.less +1 -1
- package/es/theme/sider/components/basic-menu/basic-menu.d.ts +3 -3
- package/es/theme/tabs/components/TabContent.d.ts +2 -2
- package/package.json +2 -1
- package/src/components/curd/src/components/dialog.vue +4 -2
- package/src/components/curd/src/hooks/useCurd.tsx +1 -1
- package/src/components/forms/src/components/formItem.vue +15 -2
- package/src/components/forms/src/hooks/useFormEvents.ts +4 -3
- package/src/components/forms/src/hooks/useFormValues.ts +1 -1
- package/src/components/forms/src/types/form.type.ts +3 -3
- package/src/components/index.ts +9 -3
- package/src/components/modal/src/hooks/useModal.ts +5 -3
- package/src/components/modal/src/index.vue +2 -2
- package/src/components/modal/src/types/modal.type.ts +1 -1
- package/src/components/source/src/hooks/useFetch.ts +10 -6
- package/src/components/source/src/hooks/useSource.ts +32 -11
- package/src/components/source/src/types/table.type.ts +1 -1
- package/src/components/table/index.less +8 -2
- package/src/components/table/src/components/TableHeader.vue +2 -2
- package/src/components/table/src/components/TableRender.vue +1 -3
- package/src/components/table/src/components/editable/CellComponent.ts +57 -0
- package/src/components/table/src/components/editable/EditTableCell.vue +181 -0
- package/src/components/table/src/components/editable/componentMap.ts +18 -0
- package/src/components/table/src/components/editable/index.ts +58 -0
- package/src/components/table/src/hooks/useColumns.ts +15 -8
- package/src/components/table/src/hooks/useDataSource.ts +0 -13
- package/src/components/table/src/hooks/useTableHeader.ts +2 -2
- package/src/components/table/src/index.vue +6 -1
- package/src/components/table/src/props.ts +1 -1
- package/src/components/table/src/types/table.type.ts +28 -1
- package/src/components/tree/index.less +41 -0
- package/src/components/tree/index.ts +5 -0
- package/src/components/tree/src/components/TreeHeader.vue +97 -0
- package/src/components/tree/src/hooks/useTree.ts +239 -0
- package/src/components/tree/src/index.vue +392 -0
- package/src/components/tree/src/props.ts +133 -0
- package/src/components/tree/src/type/tree.ts +105 -0
- package/src/components/tree/src/utils/tree.ts +73 -0
- package/src/components/upload/index.less +43 -0
- package/src/components/upload/index.ts +7 -0
- package/src/components/upload/src/helper.ts +32 -0
- package/src/components/upload/src/index.vue +38 -0
- package/src/components/upload/src/props.ts +48 -0
- package/src/components/upload/src/upload.vue +166 -0
- package/src/theme/header/helper/menu-tree.ts +2 -2
- package/src/theme/header/index.less +1 -1
- package/src/theme/sider/helper/split-menu.ts +2 -2
- package/es/components/dialog/index.d.ts +0 -2
- package/es/components/dialog/src/hooks/useDialog.d.ts +0 -3
- package/src/components/dialog/index.ts +0 -5
- package/src/components/dialog/src/hooks/useDialog.ts +0 -85
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="editable-cell">
|
|
3
|
+
<CellComponent
|
|
4
|
+
ref="elRef"
|
|
5
|
+
v-bind="getComponentProps"
|
|
6
|
+
:component = "column?.editComponent"
|
|
7
|
+
:popoverVisible = "getRuleVisible"
|
|
8
|
+
:rule = "editRule"
|
|
9
|
+
:ruleMessage = "ruleMessage"
|
|
10
|
+
:class = "getWrapperClass"
|
|
11
|
+
:onChange = "handleChange"
|
|
12
|
+
:onOptionsChange = "handleOptionsChange"
|
|
13
|
+
>
|
|
14
|
+
</CellComponent>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script lang="tsx">
|
|
19
|
+
import { DtEvent, isBoolean, isNumber, isString, Recordable } from "@dt-frames/core"
|
|
20
|
+
import { isFunction } from "@vueuse/core"
|
|
21
|
+
import { omit } from 'lodash-es'
|
|
22
|
+
import { Spin } from "ant-design-vue"
|
|
23
|
+
import { defineComponent, PropType, ref, unref, computed, toRaw } from "vue"
|
|
24
|
+
import { BasicColumn, ComponentType, LableValOptions } from "../../types/table.type"
|
|
25
|
+
import { CellComponent, EditRecordRow } from "./CellComponent"
|
|
26
|
+
import { getTableInstance } from "../../hooks/useTableInstance"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export default defineComponent({
|
|
30
|
+
name: 'EditableCell',
|
|
31
|
+
components: {
|
|
32
|
+
Spin,
|
|
33
|
+
CellComponent
|
|
34
|
+
},
|
|
35
|
+
props: {
|
|
36
|
+
value: {
|
|
37
|
+
type: [String, Number, Boolean, Object] as PropType<string | number | boolean | Recordable>,
|
|
38
|
+
default: ''
|
|
39
|
+
},
|
|
40
|
+
record: {
|
|
41
|
+
type: Object as PropType<EditRecordRow>,
|
|
42
|
+
},
|
|
43
|
+
column: {
|
|
44
|
+
type: Object as PropType<BasicColumn>,
|
|
45
|
+
default: ():BasicColumn => ({}),
|
|
46
|
+
},
|
|
47
|
+
index: Number
|
|
48
|
+
},
|
|
49
|
+
setup(props) {
|
|
50
|
+
const table = getTableInstance()
|
|
51
|
+
const elRef = ref()
|
|
52
|
+
|
|
53
|
+
const { editRule, align = 'left' } = props.column
|
|
54
|
+
|
|
55
|
+
const ruleMessage = ref('')
|
|
56
|
+
const ruleVisible = ref(false)
|
|
57
|
+
|
|
58
|
+
const optionsRef = ref<LableValOptions>([])
|
|
59
|
+
const currentValueRef = ref<any>(props.value)
|
|
60
|
+
|
|
61
|
+
const getComponent = computed(() => props.column?.editComponent || 'Input')
|
|
62
|
+
|
|
63
|
+
// 提示信息是否可见
|
|
64
|
+
const getRuleVisible = computed(() => {
|
|
65
|
+
return unref( ruleMessage ) && unref( ruleVisible )
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const getWrapperClass = computed(() => {
|
|
69
|
+
return `edit-cell-align-${align}`
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
const getIsCheckComp = computed(() => {
|
|
73
|
+
const component = unref(getComponent);
|
|
74
|
+
return ['Checkbox', 'Switch'].includes(component);
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
const createPlaceholderMessage = ( component: ComponentType ) => {
|
|
78
|
+
if( component.includes('Input') ) {
|
|
79
|
+
return '请输入'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return '请选择'
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 设置表格属性
|
|
86
|
+
const getComponentProps = computed(() => {
|
|
87
|
+
const isCheckValue = unref(getIsCheckComp)
|
|
88
|
+
const valueField = isCheckValue ? 'checked' : 'value'
|
|
89
|
+
|
|
90
|
+
const val = unref(currentValueRef)
|
|
91
|
+
const value = isCheckValue ? (isNumber(val) && isBoolean(val) ? val : !!val) : val
|
|
92
|
+
|
|
93
|
+
let compProps = props.column?.editComponentProps ?? {}
|
|
94
|
+
|
|
95
|
+
const { record, column, index } = props
|
|
96
|
+
if (isFunction(compProps)) {
|
|
97
|
+
compProps = compProps({ text: val, record, column, index }) ?? {}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return {
|
|
101
|
+
size: 'small',
|
|
102
|
+
getPopupContainer: () => document.body,
|
|
103
|
+
placeholder: createPlaceholderMessage(unref(getComponent)),
|
|
104
|
+
...omit(compProps, 'onChange'),
|
|
105
|
+
[valueField]: value
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
async function handleChange( e: any ) {
|
|
111
|
+
const component = unref(getComponent)
|
|
112
|
+
|
|
113
|
+
if( !e ) {
|
|
114
|
+
currentValueRef.value = e
|
|
115
|
+
} else if (component === 'Checkbox') {
|
|
116
|
+
currentValueRef.value = (e as DtEvent).target.checked
|
|
117
|
+
} else if (component === 'Switch') {
|
|
118
|
+
currentValueRef.value = e
|
|
119
|
+
} else if (e?.target && Reflect.has(e.target, 'value')) {
|
|
120
|
+
currentValueRef.value = (e as DtEvent).target.value
|
|
121
|
+
} else if (isString(e) || isBoolean(e) || isNumber(e)) {
|
|
122
|
+
currentValueRef.value = e
|
|
123
|
+
}
|
|
124
|
+
const onChange = unref(getComponentProps)?.onChange
|
|
125
|
+
if (onChange && isFunction(onChange)) onChange(...arguments)
|
|
126
|
+
|
|
127
|
+
table.emit?.('edit-change', {
|
|
128
|
+
column: props.column,
|
|
129
|
+
value: unref(currentValueRef),
|
|
130
|
+
record: toRaw(props.record),
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
handleSubmitRule()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
async function handleSubmitRule() {
|
|
138
|
+
const { column, record } = props
|
|
139
|
+
const { editRule } = column
|
|
140
|
+
const currentValue = unref(currentValueRef)
|
|
141
|
+
|
|
142
|
+
if ( editRule ) {
|
|
143
|
+
if( isBoolean(editRule) && !currentValue && !isNumber(currentValue) ) {
|
|
144
|
+
ruleVisible.value = true
|
|
145
|
+
const component = unref(getComponent)
|
|
146
|
+
ruleMessage.value = createPlaceholderMessage(component)
|
|
147
|
+
return false
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if( isFunction(editRule) ) {
|
|
151
|
+
const res = await editRule(currentValue, record as Recordable)
|
|
152
|
+
|
|
153
|
+
if (!!res) {
|
|
154
|
+
ruleMessage.value = res;
|
|
155
|
+
ruleVisible.value = true;
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
ruleMessage.value = ''
|
|
162
|
+
return true
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function handleOptionsChange(options: LableValOptions) {
|
|
166
|
+
optionsRef.value = options
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return {
|
|
170
|
+
props,
|
|
171
|
+
getComponentProps,
|
|
172
|
+
getRuleVisible,
|
|
173
|
+
editRule,
|
|
174
|
+
ruleMessage,
|
|
175
|
+
getWrapperClass,
|
|
176
|
+
handleChange,
|
|
177
|
+
handleOptionsChange
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
})
|
|
181
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Input, Select, Checkbox, DatePicker, InputNumber, Switch, TimePicker, TreeSelect } from 'ant-design-vue'
|
|
2
|
+
import { Component } from 'vue'
|
|
3
|
+
import { ComponentType } from '../../types/table.type'
|
|
4
|
+
|
|
5
|
+
const componentMap = new Map<ComponentType, Component>()
|
|
6
|
+
|
|
7
|
+
componentMap.set('Input', Input)
|
|
8
|
+
componentMap.set('InputNumber', InputNumber)
|
|
9
|
+
componentMap.set('Select', Select)
|
|
10
|
+
componentMap.set('TreeSelect', TreeSelect)
|
|
11
|
+
componentMap.set('Switch', Switch)
|
|
12
|
+
componentMap.set('Checkbox', Checkbox)
|
|
13
|
+
componentMap.set('DatePicker', DatePicker)
|
|
14
|
+
componentMap.set('TimePicker', TimePicker)
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
componentMap
|
|
18
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isArray } from '@dt-frames/core'
|
|
2
|
+
import { h } from 'vue'
|
|
3
|
+
import { BasicColumn } from "../../types/table.type"
|
|
4
|
+
import EditableCell from './EditTableCell.vue'
|
|
5
|
+
|
|
6
|
+
function renderEditCell(column: BasicColumn) {
|
|
7
|
+
return ({text: value, record, index}) => {
|
|
8
|
+
// 触发校验
|
|
9
|
+
record.onValid = async () => {
|
|
10
|
+
if ( isArray( record?.validCbs ) ) {
|
|
11
|
+
const validFns = (record?.validCbs || []).map((fn) => fn())
|
|
12
|
+
const res = await Promise.all( validFns )
|
|
13
|
+
return res.every((item) => !!item)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return false
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 触发修改
|
|
20
|
+
record.onEdit = async (edit: boolean, submit = false) => {
|
|
21
|
+
if (!submit) {
|
|
22
|
+
record.editable = edit;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 提交
|
|
26
|
+
if (!edit && submit) {
|
|
27
|
+
if ( !(await record.onValid()) ) return false
|
|
28
|
+
|
|
29
|
+
const res = await record.onSubmitEdit?.()
|
|
30
|
+
|
|
31
|
+
if (res) {
|
|
32
|
+
record.editable = false
|
|
33
|
+
return true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return false
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 取消
|
|
40
|
+
if (!edit && !submit) {
|
|
41
|
+
record.onCancelEdit?.()
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return true
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return h(EditableCell, {
|
|
48
|
+
value,
|
|
49
|
+
record,
|
|
50
|
+
column,
|
|
51
|
+
index,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
renderEditCell
|
|
58
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { PaginationProps } from 'ant-design-vue/lib/pagination'
|
|
2
|
-
import { computed, ComputedRef, Ref, ref, unref, toRaw, watch, h } from "vue"
|
|
3
|
-
import { cloneDeep, isEqual } from 'lodash-es'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { computed, ComputedRef, Ref, ref, unref, toRaw, watch, h } from "vue"
|
|
3
|
+
import { cloneDeep, isEqual, omit } from 'lodash-es'
|
|
4
|
+
import { renderEditCell } from '../components/editable'
|
|
5
|
+
import { BasicColumn, BasicTableProps } from "../types/table.type"
|
|
6
|
+
import { SetColumnsParams } from '../types/tableHeader.type'
|
|
7
|
+
import { isArray, isBoolean, isFunction, isObject, isString, Recordable, useAppStore, getDictValueByCode } from '@dt-frames/core'
|
|
7
8
|
import TableAction from '../components/TableActions.vue'
|
|
8
9
|
|
|
9
10
|
// 索引列及操作列标识
|
|
@@ -157,12 +158,11 @@ function handleActionColumn(propsRef: ComputedRef<BasicTableProps>, columns: Bas
|
|
|
157
158
|
customRender: ({ record, index}) => {
|
|
158
159
|
return h(
|
|
159
160
|
TableAction as any,
|
|
160
|
-
{
|
|
161
|
+
omit({
|
|
161
162
|
...columnObj,
|
|
162
163
|
record,
|
|
163
|
-
align: null,
|
|
164
164
|
index
|
|
165
|
-
}
|
|
165
|
+
}, 'align')
|
|
166
166
|
)
|
|
167
167
|
}
|
|
168
168
|
})
|
|
@@ -211,6 +211,13 @@ export function useColumns(
|
|
|
211
211
|
|
|
212
212
|
return columns
|
|
213
213
|
.filter( column => isIfShow(column) )
|
|
214
|
+
.map(column => {
|
|
215
|
+
if( column.edit ) {
|
|
216
|
+
column.customRender = renderEditCell(column)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return column
|
|
220
|
+
})
|
|
214
221
|
|
|
215
222
|
})
|
|
216
223
|
|
|
@@ -24,19 +24,6 @@ export function useDataSource(
|
|
|
24
24
|
// 拷贝一份表格数据 然后再做数据处理
|
|
25
25
|
const dataSourceRef = ref<Recordable[]>([])
|
|
26
26
|
|
|
27
|
-
// const { defSort, onTableChange } = unref( propsRef )
|
|
28
|
-
// const { appConf } = useAppStore()
|
|
29
|
-
|
|
30
|
-
// onTableChange({
|
|
31
|
-
// pagination: {
|
|
32
|
-
// current: 1,
|
|
33
|
-
// pageSize: appConf.ui.table.defaultPageSize
|
|
34
|
-
// },
|
|
35
|
-
// sort:defSort,
|
|
36
|
-
// filter: null,
|
|
37
|
-
// showBtnLoading: false
|
|
38
|
-
// }, false)
|
|
39
|
-
|
|
40
27
|
watch(
|
|
41
28
|
() => unref(propsRef).dataSource,
|
|
42
29
|
(dataSource) => {
|
|
@@ -9,10 +9,10 @@ export function useTableHeader(
|
|
|
9
9
|
handlers: { onColumnsChange: (data: ColumnChangeParam[]) => void }
|
|
10
10
|
) {
|
|
11
11
|
const getHeaderProps = computed((): Recordable => {
|
|
12
|
-
const { tableSetting, toolbar } = unref(propsRef)
|
|
12
|
+
const { tableSetting, toolbar = [] } = unref(propsRef)
|
|
13
13
|
|
|
14
14
|
const { getSlot } = useSlots()
|
|
15
|
-
const hideTitle = !slots.toolbar && !slots.headerTop && !tableSetting
|
|
15
|
+
const hideTitle = !toolbar.length && !slots.toolbar && !slots.headerTop && !tableSetting
|
|
16
16
|
|
|
17
17
|
return {
|
|
18
18
|
title: hideTitle
|
|
@@ -49,7 +49,11 @@
|
|
|
49
49
|
emits: [
|
|
50
50
|
'register',
|
|
51
51
|
'columns-change',
|
|
52
|
-
'selection-change'
|
|
52
|
+
'selection-change',
|
|
53
|
+
'row-click',
|
|
54
|
+
'row-dbClick',
|
|
55
|
+
'expanded-rows-change',
|
|
56
|
+
'edit-change'
|
|
53
57
|
],
|
|
54
58
|
setup(props, { emit, attrs, slots }) {
|
|
55
59
|
// table实例
|
|
@@ -116,6 +120,7 @@
|
|
|
116
120
|
getCacheColumns,
|
|
117
121
|
getSelectRows,
|
|
118
122
|
getSelectRowKeys,
|
|
123
|
+
emit,
|
|
119
124
|
getSize: () => {
|
|
120
125
|
return unref(getBind).size as SizeType;
|
|
121
126
|
}
|
|
@@ -12,7 +12,7 @@ export const TableProps = {
|
|
|
12
12
|
clickRowSelect: { type: Boolean, default: false },
|
|
13
13
|
|
|
14
14
|
// 表格设置
|
|
15
|
-
tableSetting: {type: Object as PropType<TableSetting>, default: () => ({})},
|
|
15
|
+
tableSetting: {type: Object as PropType<TableSetting | boolean>, default: () => ({})},
|
|
16
16
|
|
|
17
17
|
// 是否显示斑马条纹
|
|
18
18
|
striped: { type: Boolean, default: true },
|
|
@@ -88,6 +88,22 @@ export type ActionType = {
|
|
|
88
88
|
btns?: BtnsType[]
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
export type ComponentType =
|
|
92
|
+
| 'Input'
|
|
93
|
+
| 'InputNumber'
|
|
94
|
+
| 'Select'
|
|
95
|
+
| 'TreeSelect'
|
|
96
|
+
| 'Checkbox'
|
|
97
|
+
| 'Switch'
|
|
98
|
+
| 'DatePicker'
|
|
99
|
+
| 'TimePicker'
|
|
100
|
+
|
|
101
|
+
export type LableValOptions = {
|
|
102
|
+
label: string;
|
|
103
|
+
value: any;
|
|
104
|
+
[key: string]: string | number | boolean
|
|
105
|
+
}[]
|
|
106
|
+
|
|
91
107
|
|
|
92
108
|
export interface BasicColumn extends ColumnProps {
|
|
93
109
|
// 子元素
|
|
@@ -107,7 +123,17 @@ export interface BasicColumn extends ColumnProps {
|
|
|
107
123
|
|
|
108
124
|
edit?: boolean
|
|
109
125
|
editRow?: boolean
|
|
110
|
-
|
|
126
|
+
editable?: boolean
|
|
127
|
+
editComponent?: ComponentType
|
|
128
|
+
editComponentProps?:
|
|
129
|
+
| ((opt: {
|
|
130
|
+
text: string | number | boolean | Recordable;
|
|
131
|
+
record: Recordable;
|
|
132
|
+
column: BasicColumn;
|
|
133
|
+
index: number;
|
|
134
|
+
}) => Recordable)
|
|
135
|
+
| Recordable
|
|
136
|
+
editRule?: boolean | ((text: string, record: Recordable) => Promise<string>)
|
|
111
137
|
|
|
112
138
|
// 是否显示序号列
|
|
113
139
|
showIndexColumn?: boolean
|
|
@@ -130,4 +156,5 @@ export type TableActionType = {
|
|
|
130
156
|
setCacheColumnsByField?: (dataIndex: string | undefined, value: BasicColumn) => void
|
|
131
157
|
getSelectRows: ( ) => void
|
|
132
158
|
getSelectRowKeys: ( ) => void
|
|
159
|
+
emit?: any
|
|
133
160
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.dt-tree{
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
height: 100%;
|
|
5
|
+
|
|
6
|
+
.dt-tree-header{
|
|
7
|
+
.headerTitle{
|
|
8
|
+
text-align: center;
|
|
9
|
+
line-height: 32px;
|
|
10
|
+
font-weight: bolder;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.dt-tree-search{
|
|
14
|
+
display: flex;
|
|
15
|
+
padding: 0 0 10px 10px;
|
|
16
|
+
border-bottom: 1px solid #e7e7e7;
|
|
17
|
+
&>i{
|
|
18
|
+
width: 24px;
|
|
19
|
+
display: block;
|
|
20
|
+
text-align: center;
|
|
21
|
+
cursor: pointer;
|
|
22
|
+
}
|
|
23
|
+
.dt-tree-search-input{
|
|
24
|
+
flex: 1;
|
|
25
|
+
input{
|
|
26
|
+
font-size: 12px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.ant-spin-nested-loading{
|
|
33
|
+
flex: 1;
|
|
34
|
+
overflow-y: auto;
|
|
35
|
+
padding: 10px 0;
|
|
36
|
+
|
|
37
|
+
.tree-title{
|
|
38
|
+
font-size: 12px;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="dt-tree-header">
|
|
3
|
+
<slot name="headerTitle" v-if="slots.headerTitle"></slot>
|
|
4
|
+
|
|
5
|
+
<h4 v-if="!slots.headerTitle && title" class="headerTitle">{{ title }}</h4>
|
|
6
|
+
|
|
7
|
+
<div v-if="search || toolbar" class="dt-tree-search">
|
|
8
|
+
<div class="dt-tree-search-input" v-if="search">
|
|
9
|
+
<InputSearch size="small" allowClear v-model:value="searchValue" placeholder="搜索"/>
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
<Dropdown @click.prevent v-if="toolbar">
|
|
13
|
+
<i class="i ic:baseline-more-vert"></i>
|
|
14
|
+
<template #overlay>
|
|
15
|
+
<Menu @click="handleMenuClick">
|
|
16
|
+
<template v-for="item in toolbarList" :key="item.value">
|
|
17
|
+
<MenuItem v-bind="{ key: item.value }">
|
|
18
|
+
{{ item.label }}
|
|
19
|
+
</MenuItem>
|
|
20
|
+
<MenuDivider v-if="item.divider" />
|
|
21
|
+
</template>
|
|
22
|
+
</Menu>
|
|
23
|
+
</template>
|
|
24
|
+
</Dropdown>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<script lang="ts" setup>
|
|
31
|
+
import { useSlots, ref, watch, computed } from 'vue'
|
|
32
|
+
import { InputSearch, Dropdown, Menu, MenuItem, MenuDivider } from 'ant-design-vue'
|
|
33
|
+
import { useDebounceFn } from '@vueuse/core'
|
|
34
|
+
import { searchProps } from '../props'
|
|
35
|
+
import { ToolbarEnum } from '../type/tree'
|
|
36
|
+
|
|
37
|
+
const slots = useSlots()
|
|
38
|
+
const emits = defineEmits([
|
|
39
|
+
'search',
|
|
40
|
+
'strictly-change',
|
|
41
|
+
'strictly-change'
|
|
42
|
+
])
|
|
43
|
+
const props = defineProps( searchProps )
|
|
44
|
+
|
|
45
|
+
const searchValue = ref('')
|
|
46
|
+
|
|
47
|
+
function emitChange(value?: string){
|
|
48
|
+
emits('search', value)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function handleMenuClick(e) {
|
|
52
|
+
const { key } = e;
|
|
53
|
+
switch (key) {
|
|
54
|
+
case ToolbarEnum.SELECT_ALL: props.checkAll?.(true); break
|
|
55
|
+
case ToolbarEnum.UN_SELECT_ALL: props.checkAll?.(false); break
|
|
56
|
+
case ToolbarEnum.EXPAND_ALL: props.expandAll?.(true); break
|
|
57
|
+
case ToolbarEnum.UN_EXPAND_ALL: props.expandAll?.(false); break
|
|
58
|
+
case ToolbarEnum.CHECK_STRICTLY: emits('strictly-change', false); break
|
|
59
|
+
case ToolbarEnum.CHECK_UN_STRICTLY: emits('strictly-change', true); break
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const toolbarList = computed(() => {
|
|
64
|
+
const { checkable } = props
|
|
65
|
+
|
|
66
|
+
const defaultToolbarList = [
|
|
67
|
+
{ label: '展开全部', value: ToolbarEnum.EXPAND_ALL },
|
|
68
|
+
{
|
|
69
|
+
label: '折叠全部',
|
|
70
|
+
value: ToolbarEnum.UN_EXPAND_ALL,
|
|
71
|
+
divider: checkable,
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
return checkable
|
|
76
|
+
? [
|
|
77
|
+
{ label: '选择全部', value: ToolbarEnum.SELECT_ALL },
|
|
78
|
+
{
|
|
79
|
+
label: '取消选择',
|
|
80
|
+
value: ToolbarEnum.UN_SELECT_ALL,
|
|
81
|
+
divider: checkable,
|
|
82
|
+
},
|
|
83
|
+
...defaultToolbarList,
|
|
84
|
+
{ label: '层级关联', value: ToolbarEnum.CHECK_STRICTLY },
|
|
85
|
+
{ label: '层级独立', value: ToolbarEnum.CHECK_UN_STRICTLY },
|
|
86
|
+
]
|
|
87
|
+
: defaultToolbarList;
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const debounceEmitChange = useDebounceFn(emitChange, 200)
|
|
91
|
+
watch(
|
|
92
|
+
() => searchValue.value,
|
|
93
|
+
(v) => {
|
|
94
|
+
debounceEmitChange(v);
|
|
95
|
+
},
|
|
96
|
+
)
|
|
97
|
+
</script>
|