@dt-frames/ui 1.0.2 → 1.0.5

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 (233) hide show
  1. package/README.md +1 -15
  2. package/es/assets/imgs/header/avatar.png +0 -0
  3. package/es/assets/style/reset.less +0 -3
  4. package/es/components/curd/src/components/dialog.d.ts +21 -58
  5. package/es/components/curd/src/types/curd.type.d.ts +2 -1
  6. package/es/components/dialog/index.d.ts +2 -0
  7. package/es/components/dialog/src/hooks/useDialog.d.ts +3 -0
  8. package/es/components/forms/index.d.ts +2 -2
  9. package/es/components/forms/src/components/formIcon.d.ts +4 -47
  10. package/es/components/forms/src/index.d.ts +2 -6
  11. package/es/components/iframe/index.d.ts +2 -2
  12. package/es/components/index.d.ts +3 -2
  13. package/es/components/modal/src/components/close-icon.d.ts +0 -43
  14. package/es/components/modal/src/index.d.ts +0 -43
  15. package/es/components/source/src/types/table.type.d.ts +1 -1
  16. package/es/components/table/index.d.ts +1 -1
  17. package/es/components/table/src/components/setting/Column.d.ts +6 -5
  18. package/es/components/table/src/hooks/useColumns.d.ts +1 -1
  19. package/es/components/table/src/hooks/useDataSource.d.ts +1 -3
  20. package/es/components/table/src/hooks/useHeaderCode.d.ts +2 -0
  21. package/es/components/table/src/hooks/useRowSelection.d.ts +2 -3
  22. package/es/components/table/src/index.d.ts +15 -3
  23. package/es/components/table/src/props.d.ts +7 -1
  24. package/es/index.js +284 -271
  25. package/es/style/assets/style/reset.less +0 -3
  26. package/es/style/components/forms/{src/index.less → index.less} +2 -0
  27. package/es/style/components/icons/index.less +1 -0
  28. package/es/style/components/iframe/index.less +3 -0
  29. package/es/style/components/modal/{src/index.less → index.less} +0 -0
  30. package/es/style/components/table/{src/index.less → index.less} +12 -1
  31. package/es/style/theme/header/index.less +8 -4
  32. package/es/style/theme/sider/index.less +25 -25
  33. package/es/style/theme/theme.less +2 -1
  34. package/es/theme/header/components/logo.d.ts +43 -0
  35. package/es/theme/header/components/notify.d.ts +0 -1
  36. package/package.json +50 -40
  37. package/src/assets/data/icons/actions.ts +427 -0
  38. package/src/assets/data/icons/code.ts +10 -0
  39. package/src/assets/data/icons/commuticate.ts +190 -0
  40. package/src/assets/data/icons/currency.ts +46 -0
  41. package/src/assets/data/icons/devices.ts +128 -0
  42. package/src/assets/data/icons/edit.ts +165 -0
  43. package/src/assets/data/icons/file.ts +104 -0
  44. package/src/assets/data/icons/math.ts +53 -0
  45. package/src/assets/data/icons/message.ts +75 -0
  46. package/src/assets/data/icons/navigate.ts +181 -0
  47. package/src/assets/data/icons/other.ts +333 -0
  48. package/src/assets/data/icons.ts +58 -0
  49. package/src/assets/imgs/header/avatar.png +0 -0
  50. package/src/assets/imgs/logo/logo.png +0 -0
  51. package/src/assets/locales/en_US.json +3 -0
  52. package/src/assets/locales/zh_CN.json +3 -0
  53. package/src/assets/style/index.less +10 -0
  54. package/src/assets/style/reset.less +17 -0
  55. package/src/components/container/index.less +85 -0
  56. package/src/components/container/index.ts +8 -0
  57. package/src/components/container/src/bar.ts +107 -0
  58. package/src/components/container/src/lazy-container.vue +9 -0
  59. package/src/components/container/src/scroll-bar.vue +117 -0
  60. package/src/components/container/src/scroll-container.vue +61 -0
  61. package/src/components/curd/index.ts +5 -0
  62. package/src/components/curd/src/components/dialog.vue +71 -0
  63. package/src/components/curd/src/components/props.ts +32 -0
  64. package/src/components/curd/src/hooks/useCurd.tsx +87 -0
  65. package/src/components/curd/src/types/curd.type.ts +31 -0
  66. package/src/components/dialog/index.ts +5 -0
  67. package/src/components/dialog/src/hooks/useDialog.ts +85 -0
  68. package/src/components/excel/index.ts +6 -0
  69. package/src/components/excel/src/export2Excel.ts +44 -0
  70. package/src/components/forms/index.less +84 -0
  71. package/src/components/forms/index.ts +11 -0
  72. package/src/components/forms/src/componentMap.ts +44 -0
  73. package/src/components/forms/src/components/formButton.vue +150 -0
  74. package/src/components/forms/src/components/formIcon.vue +50 -0
  75. package/src/components/forms/src/components/formItem.vue +407 -0
  76. package/src/components/forms/src/components/radioButton.vue +58 -0
  77. package/src/components/forms/src/const/form.const.ts +7 -0
  78. package/src/components/forms/src/hooks/helper.ts +70 -0
  79. package/src/components/forms/src/hooks/useForm.ts +130 -0
  80. package/src/components/forms/src/hooks/useFormActions.ts +63 -0
  81. package/src/components/forms/src/hooks/useFormEvents.ts +247 -0
  82. package/src/components/forms/src/hooks/useFormValue.ts +49 -0
  83. package/src/components/forms/src/hooks/useFormValues.ts +131 -0
  84. package/src/components/forms/src/hooks/useLabelWidth.ts +57 -0
  85. package/src/components/forms/src/index.vue +306 -0
  86. package/src/components/forms/src/prop.ts +80 -0
  87. package/src/components/forms/src/types/form.type.ts +269 -0
  88. package/{es/style/components/icons/src → src/components/icons}/index.less +1 -0
  89. package/src/components/icons/index.ts +7 -0
  90. package/src/components/icons/src/pick-icon.vue +117 -0
  91. package/src/components/icons/src/svg-icon.vue +117 -0
  92. package/src/components/iframe/index.less +3 -0
  93. package/src/components/iframe/index.ts +5 -0
  94. package/src/components/iframe/src/index.less +3 -0
  95. package/src/components/iframe/src/index.vue +38 -0
  96. package/src/components/index.ts +48 -0
  97. package/src/components/modal/index.less +60 -0
  98. package/src/components/modal/index.ts +8 -0
  99. package/src/components/modal/src/components/close-icon.vue +47 -0
  100. package/src/components/modal/src/components/modal-wrap.vue +118 -0
  101. package/src/components/modal/src/components/modal.tsx +30 -0
  102. package/src/components/modal/src/components/modalFooter.vue +38 -0
  103. package/src/components/modal/src/hooks/useDrag.ts +107 -0
  104. package/src/components/modal/src/hooks/useFullScreen.ts +27 -0
  105. package/src/components/modal/src/hooks/useModal.ts +176 -0
  106. package/src/components/modal/src/index.vue +173 -0
  107. package/src/components/modal/src/props.ts +43 -0
  108. package/src/components/modal/src/types/modal.type.ts +27 -0
  109. package/src/components/router/base-router.vue +11 -0
  110. package/src/components/router/index.ts +3 -0
  111. package/src/components/source/index.ts +1 -0
  112. package/src/components/source/src/hooks/useFetch.ts +69 -0
  113. package/src/components/source/src/hooks/usePage.ts +3 -0
  114. package/src/components/source/src/hooks/useSource.ts +179 -0
  115. package/src/components/source/src/index.ts +5 -0
  116. package/src/components/source/src/types/source.type.ts +68 -0
  117. package/src/components/source/src/types/table.type.ts +8 -0
  118. package/src/components/table/index.less +173 -0
  119. package/src/components/table/index.ts +7 -0
  120. package/src/components/table/src/components/TableActions.vue +108 -0
  121. package/src/components/table/src/components/TableHeader.vue +77 -0
  122. package/src/components/table/src/components/TableRender.vue +76 -0
  123. package/src/components/table/src/components/setting/Column.vue +354 -0
  124. package/src/components/table/src/components/setting/Download.vue +55 -0
  125. package/src/components/table/src/components/setting/Fullscreen.vue +43 -0
  126. package/src/components/table/src/components/setting/Size.vue +42 -0
  127. package/src/components/table/src/components/setting/index.vue +64 -0
  128. package/src/components/table/src/const.ts +13 -0
  129. package/src/components/table/src/hooks/useColumns.ts +319 -0
  130. package/{es/assets/app-antd-dark-theme-style.e3b0c442.css → src/components/table/src/hooks/useCustomRow.ts} +0 -0
  131. package/src/components/table/src/hooks/useDataSource.ts +99 -0
  132. package/src/components/table/src/hooks/useHeaderCode.ts +82 -0
  133. package/src/components/table/src/hooks/useLoading.ts +29 -0
  134. package/src/components/table/src/hooks/usePagination.ts +76 -0
  135. package/src/components/table/src/hooks/useRowSelection.ts +145 -0
  136. package/src/components/table/src/hooks/useRows.ts +30 -0
  137. package/src/components/table/src/hooks/useTable.ts +89 -0
  138. package/src/components/table/src/hooks/useTableHeader.ts +48 -0
  139. package/src/components/table/src/hooks/useTableInstance.ts +29 -0
  140. package/src/components/table/src/hooks/useTableScroll.ts +229 -0
  141. package/src/components/table/src/index.vue +197 -0
  142. package/src/components/table/src/props.ts +157 -0
  143. package/src/components/table/src/types/table.type.ts +133 -0
  144. package/src/components/table/src/types/tableHeader.type.ts +27 -0
  145. package/{es/assets/app-theme-style.e3b0c442.css → src/components/type.ts} +0 -0
  146. package/src/directives/icon.ts +36 -0
  147. package/src/directives/index.ts +26 -0
  148. package/src/directives/permission.ts +20 -0
  149. package/src/global.d.ts +8 -0
  150. package/src/index.ts +4 -0
  151. package/src/theme/content/index.vue +37 -0
  152. package/src/theme/feature/back-top.vue +11 -0
  153. package/src/theme/feature/index.vue +7 -0
  154. package/src/theme/footer/index.less +16 -0
  155. package/src/theme/footer/index.vue +24 -0
  156. package/src/theme/header/components/bread-crumb.vue +26 -0
  157. package/src/theme/header/components/fullscreen.vue +12 -0
  158. package/src/theme/header/components/handler.ts +81 -0
  159. package/src/theme/header/components/index.ts +21 -0
  160. package/src/theme/header/components/lang-picker.vue +36 -0
  161. package/src/theme/header/components/logo.vue +35 -0
  162. package/src/theme/header/components/menu-search.vue +62 -0
  163. package/src/theme/header/components/notify.vue +22 -0
  164. package/src/theme/header/components/setting-theme.vue +123 -0
  165. package/src/theme/header/components/theme-drawer/enum.ts +12 -0
  166. package/src/theme/header/components/theme-drawer/feature.vue +75 -0
  167. package/src/theme/header/components/theme-drawer/index.ts +7 -0
  168. package/src/theme/header/components/theme-drawer/menu-type.vue +40 -0
  169. package/src/theme/header/components/theme-drawer/select-item.vue +46 -0
  170. package/src/theme/header/components/theme-drawer/switch-item.vue +39 -0
  171. package/src/theme/header/components/theme-drawer/theme-color.vue +26 -0
  172. package/src/theme/header/components/trigger.vue +14 -0
  173. package/src/theme/header/components/user-info.vue +60 -0
  174. package/src/theme/header/const/index.ts +40 -0
  175. package/src/theme/header/helper/menu-tree.ts +64 -0
  176. package/src/theme/header/index.less +442 -0
  177. package/{es/theme/theme.d.ts → src/theme/header/index.ts} +0 -0
  178. package/src/theme/header/index.vue +96 -0
  179. package/src/theme/header/multiple-header.vue +67 -0
  180. package/src/theme/header/set-theme.less +68 -0
  181. package/src/theme/index.ts +3 -0
  182. package/src/theme/sider/components/basic-menu/basic-menu-item.vue +14 -0
  183. package/src/theme/sider/components/basic-menu/basic-menu.vue +122 -0
  184. package/src/theme/sider/components/basic-menu/basic-sub-menu-item.vue +46 -0
  185. package/src/theme/sider/components/basic-menu/menu-item-content.vue +13 -0
  186. package/src/theme/sider/components/drag-bar.vue +26 -0
  187. package/src/theme/sider/components/layout-menu.vue +132 -0
  188. package/src/theme/sider/components/props.ts +97 -0
  189. package/src/theme/sider/components/sider-trigger.vue +24 -0
  190. package/src/theme/sider/helper/sider.ts +52 -0
  191. package/src/theme/sider/helper/split-menu.ts +146 -0
  192. package/src/theme/sider/hooks/useDragLine.ts +86 -0
  193. package/src/theme/sider/hooks/useOpenKeys.ts +57 -0
  194. package/src/theme/sider/index.less +203 -0
  195. package/src/theme/sider/index.vue +88 -0
  196. package/src/theme/tabs/components/TabContent.vue +36 -0
  197. package/src/theme/tabs/components/TabRedo.vue +18 -0
  198. package/src/theme/tabs/hooks/useMultifyTabs.ts +96 -0
  199. package/src/theme/tabs/hooks/useTabDropdown.ts +89 -0
  200. package/src/theme/tabs/index.less +165 -0
  201. package/src/theme/tabs/index.vue +98 -0
  202. package/src/theme/tabs/types/tabs.type.ts +8 -0
  203. package/src/theme/theme.less +67 -0
  204. package/src/theme/theme.vue +90 -0
  205. package/src/theme/transition.less +99 -0
  206. package/es/assets/data/icon.d.ts +0 -4
  207. package/es/assets/data/icon.ts +0 -69
  208. package/es/assets/data/icon11.ts +0 -69
  209. package/es/assets/style/var.less +0 -42
  210. package/es/components/icons/pick-icon.d.ts +0 -529
  211. package/es/components/icons/svg-icon.d.ts +0 -44
  212. package/es/components/table/src/hooks/useFormat.d.ts +0 -2
  213. package/es/components/table/src/hooks/useVirtualScroll.d.ts +0 -5
  214. package/es/components/table/src/utils/format.d.ts +0 -1
  215. package/es/index.css +0 -1
  216. package/es/style/assets/style/var.less +0 -42
  217. package/es/theme/content/index.d.ts +0 -29
  218. package/es/theme/header/components/menu-search.d.ts +0 -528
  219. package/es/theme/header/components/setting-theme.d.ts +0 -2550
  220. package/es/theme/header/components/user-info.d.ts +0 -452
  221. package/es/theme/header/index.d.ts +0 -4369
  222. package/es/theme/header/multiple-header.d.ts +0 -2001
  223. package/es/theme/styles/hooks/changeTheme.d.ts +0 -1
  224. package/es/theme/styles/hooks/generate.d.ts +0 -13
  225. package/es/theme/styles/index.d.ts +0 -2
  226. package/es/theme/tabs/components/TabRedo.d.ts +0 -49
  227. package/es/theme/tabs/index.d.ts +0 -1399
  228. package/es/theme/theme/initTheme.d.ts +0 -3
  229. package/es/theme/theme/util.d.ts +0 -5
  230. package/es/themes/generate.ts +0 -74
  231. package/es/themes/index.ts +0 -10
  232. package/es/themes/modifyVars.ts +0 -33
  233. package/es/themes/themePlugiin.ts +0 -74
@@ -0,0 +1,179 @@
1
+ import { computed, ref, reactive, toRaw, Ref } from 'vue'
2
+ import { http, isArray, isFunction, isObject, isString, JsonResult, Recordable } from "@dt-frames/core"
3
+ import { BaseDataType, SourceType } from "../types/source.type"
4
+ import { useFetch } from './useFetch'
5
+ import { TableParamsType } from '../types/table.type'
6
+ import { DownloadType } from '../../../table/src/types/tableHeader.type'
7
+ import { handleDownloadPage } from '../../../excel/index'
8
+ import { useAppStore } from '@dt-frames/core'
9
+
10
+ export function useSource(opt: SourceType) {
11
+ const loading: {
12
+ [key: string]: Ref<boolean>
13
+ } = {
14
+ onSearch: ref(false),
15
+ onReset: ref(false)
16
+ }
17
+ const { baseUrl = '', api = {}, exportName = '' } = opt
18
+ const { add, deletes, update, queryById, queryPage } = api
19
+
20
+ // 定义加载状态
21
+ for( let it in api ) {
22
+ loading['on' + it.slice(0,1).toUpperCase() + it.slice(1).toLowerCase()] = ref(false)
23
+ }
24
+
25
+ // 定义分页数据
26
+ const { appConf } = useAppStore()
27
+ const pagination = ref({
28
+ current: appConf?.ui?.table?.defaultPageNo || 1,
29
+ pageSize: appConf?.ui?.table?.defaultPageSize || 10,
30
+ total: 0
31
+ })
32
+
33
+ const dataSource = ref([])
34
+ const baseData = reactive<BaseDataType>({
35
+ entityDTO: {},
36
+ pageDTO: {
37
+ pageNo: 0,
38
+ pageSize: 10
39
+ },
40
+ orderDTOs: {}
41
+ })
42
+
43
+
44
+ /**
45
+ * 分页查询
46
+ */
47
+ function onSearch(model: Recordable) {
48
+ baseData.entityDTO = { ...model }
49
+ baseData.pageDTO.pageNo = 0
50
+ loading.onSearch.value = true
51
+
52
+ search()
53
+ }
54
+
55
+ // 重置
56
+ function onReset(model: Recordable) {
57
+ baseData.entityDTO = { ...model }
58
+ baseData.pageDTO.pageNo = 0
59
+ loading.onReset.value = true
60
+
61
+ search()
62
+ }
63
+
64
+
65
+ /**
66
+ * table 表单发生改变时, 进行分页查询
67
+ * 如果为首次 则为数据初始化 不需要查询
68
+ */
69
+ function onTableChange( params: TableParamsType, needSearch: boolean = true ) {
70
+ const { pagination, showBtnLoading, sort = [], filter } = params
71
+
72
+ baseData.pageDTO = {
73
+ pageNo: pagination.current - 1,
74
+ pageSize: pagination.pageSize
75
+ }
76
+
77
+ // baseData.orderDTOs = sort.length ?? null
78
+ baseData.orderDTOs = []
79
+
80
+ if( needSearch ) search()
81
+ }
82
+
83
+
84
+ // 查询
85
+ function search() {
86
+ const { fetch } = useFetch(queryPage, baseUrl)
87
+ loading.onQuerypage.value = true
88
+
89
+ fetch(
90
+ toRaw(baseData)
91
+ ).then( (rsp: any) => {
92
+ const { records, pageDTO } = rsp
93
+
94
+ dataSource.value.splice(0, dataSource.value.length, ...records)
95
+
96
+ pagination.value = {
97
+ current: (pageDTO?.pageNo??0) + 1,
98
+ pageSize: (pageDTO?.pageSize??10),
99
+ total: pageDTO?.totalCount??0
100
+ }
101
+ } )
102
+ .finally(() => {
103
+ loading.onSearch.value = false
104
+ loading.onQuerypage.value = false
105
+ loading.onReset.value = false
106
+ })
107
+ }
108
+
109
+
110
+ // 新增
111
+ function onAdd(model: Recordable) {
112
+ const { fetch } = useFetch(add, baseUrl)
113
+
114
+ fetch(model).then( (rsp: any) => {
115
+ search()
116
+ } )
117
+ }
118
+
119
+
120
+ // 根据id查询
121
+ async function onQueryById(id: string) {
122
+ const { fetch } = useFetch(queryById, baseUrl)
123
+ return await fetch( { id } )
124
+ }
125
+
126
+
127
+ // 修改
128
+ function onUpdate(model: Recordable) {
129
+ const { fetch } = useFetch(update, baseUrl)
130
+ fetch(model).then( (rsp: any) => {
131
+ search()
132
+ } )
133
+ }
134
+
135
+
136
+ // 删除
137
+ function onDeletes(ids: any) {
138
+ const { fetch } = useFetch(deletes, baseUrl)
139
+
140
+ fetch(ids).then( (rsp: any) => {
141
+ search()
142
+ } )
143
+ }
144
+
145
+
146
+ // 导出
147
+ function onDownload( excelData: DownloadType ) {
148
+ handleDownloadPage(excelData, exportName)
149
+ }
150
+
151
+ const form = {
152
+ onSearch,
153
+ onReset,
154
+ loading
155
+ }
156
+
157
+ const table = {
158
+ dataSource,
159
+ pagination,
160
+ onTableChange,
161
+ onDownload,
162
+ loading: loading.onQuerypage
163
+ }
164
+
165
+ const curd = {
166
+ onAdd,
167
+ onQueryById,
168
+ onUpdate,
169
+ onDeletes
170
+ }
171
+
172
+ return {
173
+ api,
174
+ form,
175
+ table,
176
+ curd,
177
+ onSearch
178
+ }
179
+ }
@@ -0,0 +1,5 @@
1
+ import { useSource } from './hooks/useSource'
2
+
3
+ export {
4
+ useSource
5
+ }
@@ -0,0 +1,68 @@
1
+ import { Recordable } from "@dt-frames/core"
2
+
3
+ export type ApiType = {
4
+ // api接口
5
+ api: string
6
+
7
+ // 请求类型
8
+ type?: 'get' | 'post' | 'put' | 'delete',
9
+
10
+ // 请求头信息
11
+ header?: any
12
+
13
+ // 默认的基础数据
14
+ model?: Recordable
15
+
16
+ // 请求之前
17
+ beforeFetch?: ( params: Recordable ) => boolean
18
+
19
+ // 请求之后
20
+ afterFetch?: <T = any>( data: any) => T
21
+ }
22
+
23
+
24
+ export type ApiObjType = {
25
+ // 新增
26
+ add?: string | ApiType
27
+
28
+ // 修改
29
+ update?: string | ApiType
30
+
31
+ // 保存
32
+ save?: string | ApiType
33
+
34
+ // 删除
35
+ deletes?: string | ApiType
36
+
37
+ // 查找
38
+ queryById?: string | ApiType
39
+
40
+ // 分页查询
41
+ queryPage?: string | ApiType
42
+
43
+ // 其它接口
44
+ [key: string]: string | ApiType
45
+ }
46
+
47
+
48
+ export type SourceType = {
49
+ // 基础路径
50
+ baseUrl?: string
51
+
52
+ // 文件导出名称
53
+ exportName?: string
54
+
55
+ // api接口
56
+ api: ApiObjType
57
+ }
58
+
59
+ export type BaseDataType = {
60
+ entityDTO?: any
61
+
62
+ pageDTO?: {
63
+ pageNo: Number
64
+ pageSize: Number
65
+ } | null
66
+
67
+ orderDTOs: any
68
+ }
@@ -0,0 +1,8 @@
1
+ import { Recordable } from "@dt-frames/core";
2
+
3
+ export type TableParamsType = {
4
+ pagination: any,
5
+ showBtnLoading: boolean,
6
+ sort: Recordable[],
7
+ filter: any
8
+ }
@@ -0,0 +1,173 @@
1
+ .table-striped td {
2
+ background-color: #fafafa;
3
+ }
4
+
5
+ .dt-table-header{
6
+ .dt-table-header-actions{
7
+ display: flex;
8
+ flex-direction: row;
9
+ justify-content: space-between;
10
+ }
11
+
12
+ .dt-table-header-actions__right{
13
+ display: flex;
14
+ .dt-icon{
15
+ margin: 0 5px;
16
+ cursor: pointer;
17
+ }
18
+ }
19
+ }
20
+
21
+ .column-setting{
22
+ &__check-item{
23
+ display: flex;
24
+ align-items: center;
25
+ min-width: 100%;
26
+ padding: 4px 16px 8px 0;
27
+ }
28
+ &__popover-title {
29
+ display: flex;
30
+ }
31
+ }
32
+
33
+ .column-setting__cloumn-list {
34
+ .ant-popover-inner-content{
35
+ padding: 12px 0 0 0;
36
+ }
37
+ .ant-checkbox-group {
38
+ width: 100%;
39
+ min-width: 260px;
40
+ }
41
+
42
+ .drag-icon{
43
+ margin: 0 5px;
44
+ cursor: move;
45
+ }
46
+
47
+ .ant-checkbox-wrapper{
48
+ flex: 1;
49
+ }
50
+
51
+ .dt-icon{
52
+ cursor: pointer;
53
+ display: flex;
54
+ }
55
+
56
+ .disabled{
57
+ .dt-icon{
58
+ cursor: not-allowed;
59
+ opacity: 0.5;
60
+ }
61
+ }
62
+
63
+ .active{
64
+ .dt-icon{
65
+ color: @primary-color !important;
66
+ }
67
+ }
68
+
69
+ .ant-popover-inner-content {
70
+ max-height: 400px;
71
+ overflow-y: auto;
72
+ }
73
+ }
74
+
75
+ .dt-table-action-btn{
76
+ width: 24px;
77
+ display: inline-block;
78
+ vertical-align: middle;
79
+ cursor: pointer;
80
+ svg{
81
+ display: flex;
82
+ }
83
+ }
84
+
85
+ .dt-table-action-dropdown{
86
+ vertical-align: middle;
87
+ cursor: pointer;
88
+ }
89
+
90
+ .ant-table-fixed-left table, .ant-table-fixed-right table{
91
+ width: min-content;
92
+ }
93
+
94
+ .ant-table-cell {
95
+ height: 44px !important;
96
+ line-height: 24px !important;
97
+ font-size: 14px !important;
98
+ padding: 4px 8px !important;
99
+ }
100
+
101
+ .ant-table-small{
102
+ .ant-table-cell {
103
+ height: 32px !important;
104
+ line-height: 16px !important;
105
+ font-size: 12px !important;
106
+ padding: 2px 8px !important;
107
+ }
108
+ }
109
+
110
+ .ant-table-middle{
111
+ .ant-table-cell {
112
+ height: 38px !important;
113
+ line-height: 20px !important;
114
+ font-size: 13px !important;
115
+ padding: 4px 8px !important;
116
+ }
117
+ }
118
+
119
+ .dt-action-select{
120
+ .ant-dropdown-menu-title-content{
121
+ display: flex;
122
+ align-items: center;
123
+ font-size: 13px;
124
+ svg{
125
+ display: block;
126
+ }
127
+
128
+ .dt-icon{
129
+ padding-right: 8px;
130
+ }
131
+ }
132
+ }
133
+
134
+
135
+ .dt-table{
136
+ .ant-table-pagination{
137
+ margin: 0 !important;
138
+ padding: 10px 0;
139
+ border: 1px solid #f0f0f0;
140
+ }
141
+
142
+ .ant-table-title{
143
+ padding: 8px 0 !important;
144
+ border: none !important;
145
+ }
146
+
147
+ .ant-table-resize-handle{
148
+ right: -7px;
149
+ .ant-table-resize-handle-line{
150
+ width: 2px;
151
+ }
152
+ }
153
+
154
+ .ant-table-body {
155
+ position: relative;
156
+ table{
157
+ position: absolute;
158
+ top: 0;
159
+ left: 0;
160
+ }
161
+ }
162
+
163
+ .form-btns{
164
+ button:first-of-type {
165
+ margin-left: 0;
166
+ }
167
+ }
168
+
169
+ .ant-table-thead > tr > th{
170
+ font-weight: bolder;
171
+ color: #333;
172
+ }
173
+ }
@@ -0,0 +1,7 @@
1
+ import { useTable } from './src/hooks/useTable';
2
+ import DtTable from "./src/index.vue"
3
+
4
+ export {
5
+ DtTable,
6
+ useTable,
7
+ }
@@ -0,0 +1,108 @@
1
+ <template>
2
+ <template v-if="props.expand">
3
+ <span v-for="item in props.btns" class="dt-table-action-btn">
4
+ <Tooltip placement="bottom" v-if="item.ifShow">
5
+ <template #title>{{ item.title }}</template>
6
+ <span v-icon="item.icon" :color="item.color" @click="handleAction(item)"></span>
7
+ </Tooltip>
8
+ </span>
9
+ </template>
10
+
11
+ <template v-else>
12
+ <Dropdown
13
+ :getPopupContainer="getPopupContainer"
14
+ :trigger="['click']"
15
+ >
16
+ <DtIcon :icon-class="'ic:baseline-settings'" class-name="dt-table-action-dropdown"></DtIcon>
17
+
18
+ <template #overlay>
19
+ <Menu class="dt-action-select">
20
+ <template v-for="item in props.btns">
21
+ <MenuItem
22
+ v-if="item.ifShow"
23
+ @click="handleAction(item)"
24
+ >
25
+ <DtIcon :icon-class="item.icon" :color="item.color" :size="16"></DtIcon>
26
+ <span>{{ item.title }}</span>
27
+ </MenuItem>
28
+ </template>
29
+
30
+ </Menu>
31
+ </template>
32
+
33
+ </Dropdown>
34
+
35
+ </template>
36
+
37
+ </template>
38
+
39
+ <script lang="ts" setup>
40
+ import { PropType, watch, useAttrs } from 'vue';
41
+ import { Tooltip, Dropdown, Menu, MenuItem } from 'ant-design-vue'
42
+ import { BtnsType } from '../types/table.type';
43
+ import { DtIcon } from '../../../icons/index'
44
+ import { isBoolean, isFunction, getPopupContainer as getParentContainer } from '@dt-frames/core';
45
+
46
+ const props = defineProps({
47
+ fixed: {
48
+ type: String as PropType<boolean | 'left' | 'right' | undefined>,
49
+ default: 'right'
50
+ },
51
+ title: {
52
+ type: String
53
+ },
54
+ expand: {
55
+ type: Boolean,
56
+ default: false
57
+ },
58
+ width: {
59
+ type: String,
60
+ default: '70px'
61
+ },
62
+ btns: {
63
+ type: Array as PropType<BtnsType[]>,
64
+ default: []
65
+ },
66
+ flag: {
67
+ type: String as PropType<'ACTION'>
68
+ },
69
+ record: {
70
+ default: { }
71
+ },
72
+ index: {
73
+ type: Number
74
+ }
75
+ })
76
+
77
+ watch(
78
+ () => props.btns,
79
+ (btns) => {
80
+ btns.map( it => {
81
+ it.ifShow = isBoolean( it.ifShow )
82
+ ? it.ifShow
83
+ : isFunction( it.ifShow )
84
+ ? it.ifShow( props.record )
85
+ : true
86
+ } )
87
+ },{
88
+ immediate: true
89
+ }
90
+ )
91
+
92
+ function handleAction(it: BtnsType) {
93
+ if( isFunction( it.action ) ) {
94
+ it.action({
95
+ row: props.record,
96
+ index: props.index
97
+ })
98
+ }
99
+ }
100
+
101
+ const attrs = useAttrs()
102
+ function getPopupContainer() {
103
+ return isFunction(attrs.getPopupContainer)
104
+ ? attrs.getPopupContainer()
105
+ : getParentContainer();
106
+ }
107
+
108
+ </script>
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <div class="dt-table-header">
3
+ <div class="dt-table-header-actions">
4
+ <div class="dt-table-header-actions__left">
5
+ <FormButtons
6
+ v-bind="getActionsProps"
7
+ @handle-method="handleMethod"
8
+ ></FormButtons>
9
+ <slot name="toolbar"></slot>
10
+ </div>
11
+
12
+ <div class="dt-table-header-actions__right">
13
+ <TableSettinCom
14
+ @columns-change="handleColumnChange"
15
+ ></TableSettinCom>
16
+ </div>
17
+ </div>
18
+
19
+ <div v-if="$slots.headerTop" style="margin: 5px">
20
+ <slot name="headerTop"></slot>
21
+ </div>
22
+ </div>
23
+ </template>
24
+
25
+ <script lang="ts">
26
+ import { defineComponent, PropType } from "vue"
27
+ import { Button } from 'ant-design-vue'
28
+ import type { BtnsType, ColumnChangeParam, TableSetting } from "../types/table.type"
29
+ import TableSettinCom from './setting/index.vue'
30
+ import { DtIcon } from '../../../icons/index'
31
+ import { FormButtons } from "../../../forms"
32
+ import { isFunction } from "@dt-frames/core"
33
+
34
+ export default defineComponent({
35
+ name: 'table-header',
36
+ components: {
37
+ TableSettinCom,
38
+ Button,
39
+ DtIcon,
40
+ FormButtons
41
+ },
42
+ props: {
43
+ tableTools: {
44
+ type: Object as PropType<TableSetting>
45
+ },
46
+ toolbar: {
47
+ type: Array as PropType<BtnsType[]>,
48
+ default: []
49
+ }
50
+ },
51
+ emits: ['columns-change'],
52
+ setup(props, { emit }) {
53
+ function handleColumnChange(data: ColumnChangeParam[]) {
54
+ emit('columns-change', data);
55
+ }
56
+
57
+ function handleMethod( e ) {
58
+ if( isFunction(e.onClick) ) {
59
+ e.onClick()
60
+ }
61
+ }
62
+
63
+ const getActionsProps = {
64
+ mode: null,
65
+ showAdvancedButton: false,
66
+ show: true,
67
+ buttonList: props.toolbar
68
+ } as any
69
+
70
+ return {
71
+ getActionsProps,
72
+ handleColumnChange,
73
+ handleMethod
74
+ }
75
+ }
76
+ })
77
+ </script>
@@ -0,0 +1,76 @@
1
+ <script lang="tsx">
2
+ import { getDictValueByCode, isFunction, isObject, Recordable, formatNumber, isVnode } from '@dt-frames/core'
3
+ import dayjs from 'dayjs'
4
+ import { defineComponent, PropType, unref, ref, h, toRaw, render as render1, resolveComponent, resolveDynamicComponent, createVNode } from 'vue'
5
+ import { BasicColumn } from '../types/table.type'
6
+
7
+ export default defineComponent({
8
+ name: 'TableFormat',
9
+ props: {
10
+ column: {
11
+ type: Object as PropType<BasicColumn>
12
+ },
13
+ record: {
14
+ type: Object as PropType<Recordable>
15
+ },
16
+ index: {
17
+ type: Number
18
+ }
19
+ },
20
+ setup(props: {
21
+ column: BasicColumn,
22
+ record: Recordable,
23
+ index: number
24
+ }) {
25
+ let renderText = ref()
26
+
27
+ function renderCell() {
28
+ const { column, record, index } = props
29
+ const { render, dataIndex } = column
30
+ const text = record[dataIndex.toString()]
31
+
32
+ if( isFunction(render) ) {
33
+ renderText.value = render(text, record, index)
34
+ }
35
+
36
+ if( isObject(render) ) {
37
+ const { dict, date, number, percent } = render as Recordable
38
+
39
+ if( dict ) {
40
+ renderText = getDictValueByCode(text, dict)
41
+ }
42
+
43
+ if( date ) {
44
+ renderText.value = dayjs(text).format(date || 'YYYY-MM-DD')
45
+ }
46
+
47
+ if( number ) {
48
+ renderText.value = formatNumber(text, number)
49
+ }
50
+
51
+ if( percent ) {
52
+ renderText.value = formatNumber((text || 0) * 100, percent) + '%'
53
+ }
54
+
55
+ if( isVnode(render) ) {
56
+ renderText.value = render
57
+ }
58
+
59
+ if( render['setup'] ) {
60
+ renderText.value = createVNode(render as any, { text })
61
+ }
62
+
63
+
64
+ } else {
65
+ console.log(text)
66
+ renderText.value = text
67
+ }
68
+ }
69
+
70
+ renderCell()
71
+
72
+ return () => <span>{unref(renderText)}</span>
73
+ }
74
+ })
75
+
76
+ </script>