@dt-frames/ui 1.0.9 → 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.
Files changed (90) hide show
  1. package/es/components/curd/src/components/dialog.d.ts +8 -3
  2. package/es/components/forms/src/components/formIcon.d.ts +1 -1
  3. package/es/components/forms/src/components/formInputUseDialog.d.ts +903 -0
  4. package/es/components/forms/src/types/form.type.d.ts +6 -4
  5. package/es/components/index.d.ts +3 -2
  6. package/es/components/modal/src/types/modal.type.d.ts +5 -2
  7. package/es/components/source/src/hooks/useFetch.d.ts +2 -2
  8. package/es/components/source/src/hooks/useSource.d.ts +8 -8
  9. package/es/components/source/src/types/table.type.d.ts +1 -1
  10. package/es/components/table/src/components/TableActions.d.ts +2 -2
  11. package/es/components/table/src/components/TableHeader.d.ts +2 -2
  12. package/es/components/table/src/components/editable/CellComponent.d.ts +14 -0
  13. package/es/components/table/src/components/editable/EditTableCell.d.ts +88 -0
  14. package/es/components/table/src/components/editable/componentMap.d.ts +4 -0
  15. package/es/components/table/src/components/editable/index.d.ts +9 -0
  16. package/es/components/table/src/components/setting/Download.d.ts +2 -2
  17. package/es/components/table/src/components/setting/Size.d.ts +2 -2
  18. package/es/components/table/src/hooks/useCustomRow.d.ts +19 -0
  19. package/es/components/table/src/index.d.ts +29 -6
  20. package/es/components/table/src/props.d.ts +5 -1
  21. package/es/components/table/src/types/table.type.d.ts +16 -0
  22. package/es/components/tree/index.d.ts +2 -0
  23. package/es/components/tree/src/hooks/useTree.d.ts +14 -0
  24. package/es/components/tree/src/props.d.ts +101 -0
  25. package/es/components/tree/src/type/tree.d.ts +85 -0
  26. package/es/components/tree/src/utils/tree.d.ts +5 -0
  27. package/es/components/upload/index.d.ts +3 -0
  28. package/es/components/upload/src/helper.d.ts +4 -0
  29. package/es/components/upload/src/index.d.ts +2807 -0
  30. package/es/components/upload/src/props.d.ts +40 -0
  31. package/es/components/upload/src/upload.d.ts +1653 -0
  32. package/es/index.js +2113 -270
  33. package/es/style/components/forms/index.less +23 -0
  34. package/es/style/components/table/index.less +8 -2
  35. package/es/style/components/tree/index.less +41 -0
  36. package/es/style/components/upload/index.less +43 -0
  37. package/es/style/theme/header/index.less +1 -1
  38. package/es/theme/sider/components/basic-menu/basic-menu.d.ts +3 -3
  39. package/es/theme/tabs/components/TabContent.d.ts +2 -2
  40. package/package.json +2 -1
  41. package/src/components/curd/src/components/dialog.vue +7 -4
  42. package/src/components/curd/src/hooks/useCurd.tsx +1 -1
  43. package/src/components/forms/index.less +23 -0
  44. package/src/components/forms/src/componentMap.ts +2 -0
  45. package/src/components/forms/src/components/formInputUseDialog.vue +43 -0
  46. package/src/components/forms/src/components/formItem.vue +25 -12
  47. package/src/components/forms/src/hooks/useFormEvents.ts +4 -3
  48. package/src/components/forms/src/hooks/useFormValues.ts +1 -1
  49. package/src/components/forms/src/types/form.type.ts +9 -3
  50. package/src/components/index.ts +9 -3
  51. package/src/components/modal/src/hooks/useModal.ts +12 -4
  52. package/src/components/modal/src/index.vue +2 -2
  53. package/src/components/modal/src/types/modal.type.ts +5 -2
  54. package/src/components/source/src/hooks/useFetch.ts +10 -6
  55. package/src/components/source/src/hooks/useSource.ts +33 -12
  56. package/src/components/source/src/types/table.type.ts +1 -1
  57. package/src/components/table/index.less +8 -2
  58. package/src/components/table/src/components/TableHeader.vue +2 -2
  59. package/src/components/table/src/components/editable/CellComponent.ts +57 -0
  60. package/src/components/table/src/components/editable/EditTableCell.vue +181 -0
  61. package/src/components/table/src/components/editable/componentMap.ts +18 -0
  62. package/src/components/table/src/components/editable/index.ts +58 -0
  63. package/src/components/table/src/hooks/useColumns.ts +15 -8
  64. package/src/components/table/src/hooks/useCustomRow.ts +86 -0
  65. package/src/components/table/src/hooks/useDataSource.ts +0 -13
  66. package/src/components/table/src/hooks/useTableHeader.ts +2 -2
  67. package/src/components/table/src/index.vue +20 -3
  68. package/src/components/table/src/props.ts +4 -1
  69. package/src/components/table/src/types/table.type.ts +28 -1
  70. package/src/components/tree/index.less +41 -0
  71. package/src/components/tree/index.ts +5 -0
  72. package/src/components/tree/src/components/TreeHeader.vue +97 -0
  73. package/src/components/tree/src/hooks/useTree.ts +239 -0
  74. package/src/components/tree/src/index.vue +392 -0
  75. package/src/components/tree/src/props.ts +133 -0
  76. package/src/components/tree/src/type/tree.ts +105 -0
  77. package/src/components/tree/src/utils/tree.ts +73 -0
  78. package/src/components/upload/index.less +43 -0
  79. package/src/components/upload/index.ts +7 -0
  80. package/src/components/upload/src/helper.ts +32 -0
  81. package/src/components/upload/src/index.vue +38 -0
  82. package/src/components/upload/src/props.ts +48 -0
  83. package/src/components/upload/src/upload.vue +166 -0
  84. package/src/theme/header/helper/menu-tree.ts +2 -2
  85. package/src/theme/header/index.less +1 -1
  86. package/src/theme/sider/helper/split-menu.ts +2 -2
  87. package/es/components/dialog/index.d.ts +0 -2
  88. package/es/components/dialog/src/hooks/useDialog.d.ts +0 -3
  89. package/src/components/dialog/index.ts +0 -5
  90. package/src/components/dialog/src/hooks/useDialog.ts +0 -85
@@ -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({
@@ -49,7 +50,14 @@
49
50
  emits: [
50
51
  'register',
51
52
  'columns-change',
52
- 'selection-change'
53
+ 'selection-change',
54
+ 'row-click',
55
+ 'row-dbClick',
56
+ 'row-contextmenu',
57
+ 'row-mouseenter',
58
+ 'row-mouseleave',
59
+ 'expanded-rows-change',
60
+ 'edit-change'
53
61
  ],
54
62
  setup(props, { emit, attrs, slots }) {
55
63
  // table实例
@@ -91,7 +99,7 @@
91
99
  getRowSelection,
92
100
  getSelectRows,
93
101
  getSelectRowKeys,
94
-
102
+ setSelectedRowKeys
95
103
  } = useRowSelection(getProps, emit)
96
104
 
97
105
  // 关于滚动条的设置
@@ -116,6 +124,7 @@
116
124
  getCacheColumns,
117
125
  getSelectRows,
118
126
  getSelectRowKeys,
127
+ emit,
119
128
  getSize: () => {
120
129
  return unref(getBind).size as SizeType;
121
130
  }
@@ -140,6 +149,13 @@
140
149
  emit
141
150
  )
142
151
 
152
+ // 表格的单击 双击事件
153
+ const { customRow } = useCustomRow(getProps, {
154
+ setSelectedRowKeys,
155
+ getSelectRowKeys,
156
+ clearSelectedRowKeys,
157
+ emit
158
+ })
143
159
 
144
160
  const getBind = computed(() => {
145
161
  return {
@@ -153,7 +169,8 @@
153
169
  rowSelection: unref(getRowSelectionRef),
154
170
  rowKey: unref(getProps).rowKey,
155
171
  columns: unref(getViewColumns),
156
- tableLayout: 'fixed'
172
+ tableLayout: 'fixed',
173
+ customRow,
157
174
  }
158
175
  })
159
176
 
@@ -12,7 +12,10 @@ 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
+
17
+ // 点击行是否可以选中整行数据
18
+ clickToRowSelect: { type: Boolean, default: false },
16
19
 
17
20
  // 是否显示斑马条纹
18
21
  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
- // editable?: boolean
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,5 @@
1
+ import DtTree from './src/index.vue'
2
+
3
+ export {
4
+ DtTree
5
+ }
@@ -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>
@@ -0,0 +1,239 @@
1
+ import { TreeDataItem } from "ant-design-vue/lib/tree"
2
+ import { ComputedRef, Ref, unref } from "vue"
3
+ import { cloneDeep } from 'lodash-es'
4
+ import { FieldNames, InsertNodeParams, TreeItem, KeyType } from "../type/tree"
5
+ import { forEach } from "../utils/tree"
6
+
7
+ export function useTree(
8
+ treeDataRef: Ref<TreeDataItem[]>,
9
+ getFieldNames: ComputedRef<FieldNames>
10
+ ) {
11
+
12
+ function getAllKeys(list?: TreeDataItem[]) {
13
+ const keys: string[] = []
14
+ const treeData = list || unref(treeDataRef)
15
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
16
+
17
+ if (!childrenField || !keyField) return keys
18
+
19
+ for (let index = 0; index < treeData.length; index++) {
20
+ const node = treeData[index]
21
+ keys.push(node[keyField]!)
22
+
23
+ const children = node[childrenField]
24
+
25
+ if (children && children.length) {
26
+ keys.push(...(getAllKeys(children) as string[]))
27
+ }
28
+ }
29
+
30
+ return keys as KeyType[]
31
+ }
32
+
33
+ function getEnabledKeys(list?: TreeDataItem[]) {
34
+ const keys: string[] = []
35
+ const treeData = list || unref(treeDataRef)
36
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
37
+
38
+ if (!childrenField || !keyField) return keys
39
+
40
+ for (let index = 0; index < treeData.length; index++) {
41
+ const node = treeData[index]
42
+ node.disabled !== true && node.selectable !== false && keys.push(node[keyField]!)
43
+
44
+ const children = node[childrenField]
45
+ if (children && children.length) {
46
+ keys.push(...(getEnabledKeys(children) as string[]))
47
+ }
48
+ }
49
+
50
+ return keys as KeyType[]
51
+ }
52
+
53
+ // 获取节点的keys
54
+ function getChildrenKeys(nodeKey: string | number, list?: TreeDataItem[]) {
55
+ const keys: KeyType[] = []
56
+ const treeData = list || unref(treeDataRef)
57
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
58
+
59
+ if (!childrenField || !keyField) return keys
60
+
61
+ for (let index = 0; index < treeData.length; index++) {
62
+ const node = treeData[index]
63
+ const children = node[childrenField]
64
+
65
+ if (nodeKey === node[keyField]) {
66
+ keys.push(node[keyField]!)
67
+
68
+ if (children && children.length) {
69
+ keys.push(...(getAllKeys(children) as KeyType[]))
70
+ }
71
+ } else {
72
+ if (children && children.length) {
73
+ keys.push(...getChildrenKeys(nodeKey, children))
74
+ }
75
+ }
76
+ }
77
+
78
+ return keys as KeyType[]
79
+ }
80
+
81
+
82
+ function updateNodeByKey(key: string, node: TreeDataItem, list?: TreeDataItem[]) {
83
+ if (!key) return
84
+
85
+ const treeData = list || unref(treeDataRef)
86
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
87
+
88
+ if (!childrenField || !keyField) return
89
+
90
+ for (let index = 0; index < treeData.length; index++) {
91
+ const element: any = treeData[index]
92
+ const children = element[childrenField]
93
+
94
+ if (element[keyField] === key) {
95
+ treeData[index] = { ...treeData[index], ...node }
96
+ break
97
+ } else if (children && children.length) {
98
+ updateNodeByKey(key, node, element[childrenField])
99
+ }
100
+ }
101
+
102
+ }
103
+
104
+
105
+ function filterByLevel(level = 1, list?: TreeDataItem[], currentLevel = 1) {
106
+ if (!level) return []
107
+
108
+ const res: (string | number)[] = []
109
+ const data = list || unref(treeDataRef) || []
110
+
111
+ for (let index = 0; index < data.length; index++) {
112
+ const item = data[index]
113
+
114
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
115
+ const key = keyField ? item[keyField] : ''
116
+ const children = childrenField ? item[childrenField] : []
117
+ res.push(key)
118
+
119
+ if (children && children.length && currentLevel < level) {
120
+ currentLevel += 1;
121
+ res.push(...filterByLevel(level, children, currentLevel));
122
+ }
123
+ }
124
+
125
+ return res as string[] | number[]
126
+ }
127
+
128
+ // 添加节点
129
+ function insertNodeByKey({ parentKey = null, node, push = 'push' }: InsertNodeParams) {
130
+ const treeData: any = cloneDeep(unref(treeDataRef))
131
+
132
+ if (!parentKey) {
133
+ treeData[push](node)
134
+ treeDataRef.value = treeData
135
+ return
136
+ }
137
+
138
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
139
+ if (!childrenField || !keyField) return
140
+
141
+ forEach(treeData, (treeItem) => {
142
+ if (treeItem[keyField] === parentKey) {
143
+ treeItem[childrenField] = treeItem[childrenField] || []
144
+ treeItem[childrenField][push](node)
145
+ return true
146
+ }
147
+ })
148
+ treeDataRef.value = treeData
149
+ }
150
+
151
+ // 批量添加节点
152
+ function insertNodesByKey({ parentKey = null, list, push = 'push' }: InsertNodeParams) {
153
+ const treeData: any = cloneDeep(unref(treeDataRef))
154
+
155
+ if (!list || list.length < 1) return
156
+
157
+ if (!parentKey) {
158
+ for (let i = 0; i < list.length; i++) {
159
+ treeData[push](list[i]);
160
+ }
161
+ } else {
162
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
163
+ if (!childrenField || !keyField) return
164
+
165
+ forEach(treeData, (treeItem) => {
166
+ if (treeItem[keyField] === parentKey) {
167
+ treeItem[childrenField] = treeItem[childrenField] || []
168
+
169
+ for (let i = 0; i < list.length; i++) {
170
+ treeItem[childrenField][push](list[i])
171
+ }
172
+
173
+ treeDataRef.value = treeData
174
+
175
+ return true
176
+ }
177
+ })
178
+ }
179
+ }
180
+
181
+ // 通过key 删除节点
182
+ function deleteNodeByKey(key: string, list?: TreeDataItem[]) {
183
+ if (!key) return
184
+
185
+ const treeData = list || unref(treeDataRef)
186
+ const { key: keyField, children: childrenField } = unref(getFieldNames)
187
+
188
+ if (!childrenField || !keyField) return
189
+
190
+ for (let index = 0; index < treeData.length; index++) {
191
+ const element: any = treeData[index]
192
+ const children = element[childrenField]
193
+
194
+ if (element[keyField] === key) {
195
+
196
+ treeData.splice(index, 1)
197
+ break
198
+
199
+ } else if (children && children.length) {
200
+
201
+ deleteNodeByKey(key, element[childrenField])
202
+
203
+ }
204
+ }
205
+ }
206
+
207
+ function getSelectedNode(key: KeyType, list?: TreeItem[], selectedNode?: TreeItem | null) {
208
+ if (!key && key !== 0) return null
209
+
210
+ const treeData = list || unref(treeDataRef)
211
+
212
+ treeData.forEach(item => {
213
+ if (selectedNode?.key || selectedNode?.key === 0) return selectedNode
214
+
215
+ if (item.key === key) {
216
+ selectedNode = item
217
+ return
218
+ }
219
+
220
+ if (item.children && item.children.length) {
221
+ selectedNode = getSelectedNode(key, item.children, selectedNode)
222
+ }
223
+ })
224
+
225
+ return selectedNode || null
226
+ }
227
+
228
+ return {
229
+ getAllKeys,
230
+ getEnabledKeys,
231
+ getChildrenKeys,
232
+ updateNodeByKey,
233
+ filterByLevel,
234
+ insertNodeByKey,
235
+ insertNodesByKey,
236
+ deleteNodeByKey,
237
+ getSelectedNode
238
+ }
239
+ }