@yuuuu_ovo/ci-web-plugins-commom 1.1.3

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.

Potentially problematic release.


This version of @yuuuu_ovo/ci-web-plugins-commom might be problematic. Click here for more details.

Files changed (116) hide show
  1. package/README.md +171 -0
  2. package/dist/CI.Web.Plugins.Commom.css +3 -0
  3. package/dist/DhtmlxGanttPro/README.md +360 -0
  4. package/dist/DhtmlxGanttPro/index.js +1 -0
  5. package/dist/HeaderDropdown/README.md +302 -0
  6. package/dist/HeaderDropdown/index.js +1 -0
  7. package/dist/HelloPlugin/index.js +1 -0
  8. package/dist/HelloWorld/index.js +1 -0
  9. package/dist/SearchPro/README.md +203 -0
  10. package/dist/SearchPro/SearchPro.bundle.js +3 -0
  11. package/dist/SearchPro/index.js +1 -0
  12. package/dist/VxeGridPro/README.md +91 -0
  13. package/dist/VxeGridPro/index.js +1 -0
  14. package/dist/VxeModalPro/README.md +122 -0
  15. package/dist/VxeModalPro/index.js +1 -0
  16. package/dist/VxeTablePro/README.md +86 -0
  17. package/dist/VxeTablePro/index.js +1 -0
  18. package/dist/_virtual/_commonjsHelpers/index.js +1 -0
  19. package/dist/_virtual/array-set/index.js +1 -0
  20. package/dist/_virtual/base64/index.js +1 -0
  21. package/dist/_virtual/base64-vlq/index.js +1 -0
  22. package/dist/_virtual/binary-search/index.js +1 -0
  23. package/dist/_virtual/mapping-list/index.js +1 -0
  24. package/dist/_virtual/picocolors/index.js +1 -0
  25. package/dist/_virtual/postcss/index.js +1 -0
  26. package/dist/_virtual/quick-sort/index.js +1 -0
  27. package/dist/_virtual/source-map/index.js +1 -0
  28. package/dist/_virtual/source-map-consumer/index.js +1 -0
  29. package/dist/_virtual/source-map-generator/index.js +1 -0
  30. package/dist/_virtual/source-node/index.js +1 -0
  31. package/dist/_virtual/symbols/index.js +1 -0
  32. package/dist/_virtual/util/index.js +1 -0
  33. package/dist/components/DhtmlxGanttPro/index.vue/index.js +1 -0
  34. package/dist/components/DhtmlxGanttPro/index.vue/index2.js +1 -0
  35. package/dist/components/DhtmlxGanttPro/index.vue/index3.js +1 -0
  36. package/dist/components/HeaderDropdown/index.vue/index.js +1 -0
  37. package/dist/components/HeaderDropdown/index.vue/index2.js +1 -0
  38. package/dist/components/HeaderDropdown.vue/index.js +1 -0
  39. package/dist/components/HeaderDropdown.vue/index2.js +1 -0
  40. package/dist/components/HelloPlugin.vue/index.js +1 -0
  41. package/dist/components/HelloPlugin.vue/index2.js +1 -0
  42. package/dist/components/HelloWorld.vue/index.js +1 -0
  43. package/dist/components/HelloWorld.vue/index2.js +1 -0
  44. package/dist/components/SearchPro/index.vue/index.js +1 -0
  45. package/dist/components/SearchPro/index.vue/index2.js +1 -0
  46. package/dist/components/SearchPro/innerComponents/minxin/index.js +1 -0
  47. package/dist/components/SearchPro/innerComponents/reportCustomMulSelect.vue/index.js +1 -0
  48. package/dist/components/SearchPro/innerComponents/reportCustomMulSelect.vue/index2.js +1 -0
  49. package/dist/components/SearchPro/innerComponents/reportCustomSelect.vue/index.js +1 -0
  50. package/dist/components/SearchPro/innerComponents/reportCustomSelect.vue/index2.js +1 -0
  51. package/dist/components/SearchPro/innerComponents/reportMulSelect.vue/index.js +1 -0
  52. package/dist/components/SearchPro/innerComponents/reportMulSelect.vue/index2.js +1 -0
  53. package/dist/components/SearchPro/innerComponents/reportSelect.vue/index.js +1 -0
  54. package/dist/components/SearchPro/innerComponents/reportSelect.vue/index2.js +1 -0
  55. package/dist/components/SearchPro/innerComponents/reportSelectTable.vue/index.js +1 -0
  56. package/dist/components/SearchPro/innerComponents/reportSelectTable.vue/index2.js +1 -0
  57. package/dist/components/SearchPro/tableTemplate/index.vue/index.js +1 -0
  58. package/dist/components/SearchPro/tableTemplate/index.vue/index2.js +1 -0
  59. package/dist/components/SearchPro/tableTemplate/second.vue/index.js +1 -0
  60. package/dist/components/SearchPro/tableTemplate/second.vue/index2.js +1 -0
  61. package/dist/components/VxeGridPro/index.vue/index.js +1 -0
  62. package/dist/components/VxeGridPro/index.vue/index2.js +1 -0
  63. package/dist/components/VxeModalPro/index.vue/index.js +1 -0
  64. package/dist/components/VxeModalPro/index.vue/index2.js +1 -0
  65. package/dist/components/VxeTablePro/index.vue/index.js +1 -0
  66. package/dist/components/VxeTablePro/index.vue/index2.js +1 -0
  67. package/dist/config/index/index.js +1 -0
  68. package/dist/index/index.js +1 -0
  69. package/dist/libs/api.request/index.js +1 -0
  70. package/dist/libs/axios/index.js +1 -0
  71. package/dist/libs/request/index.js +1 -0
  72. package/dist/libs/setStore/index.js +1 -0
  73. package/dist/node_modules/@element-plus/icons-vue/dist/index/index.js +2 -0
  74. package/dist/node_modules/nanoid/non-secure/index/index.js +1 -0
  75. package/dist/node_modules/picocolors/picocolors/index.js +1 -0
  76. package/dist/node_modules/postcss/lib/at-rule/index.js +1 -0
  77. package/dist/node_modules/postcss/lib/comment/index.js +1 -0
  78. package/dist/node_modules/postcss/lib/container/index.js +1 -0
  79. package/dist/node_modules/postcss/lib/css-syntax-error/index.js +1 -0
  80. package/dist/node_modules/postcss/lib/declaration/index.js +1 -0
  81. package/dist/node_modules/postcss/lib/document/index.js +1 -0
  82. package/dist/node_modules/postcss/lib/fromJSON/index.js +1 -0
  83. package/dist/node_modules/postcss/lib/input/index.js +1 -0
  84. package/dist/node_modules/postcss/lib/lazy-result/index.js +1 -0
  85. package/dist/node_modules/postcss/lib/list/index.js +1 -0
  86. package/dist/node_modules/postcss/lib/map-generator/index.js +1 -0
  87. package/dist/node_modules/postcss/lib/no-work-result/index.js +1 -0
  88. package/dist/node_modules/postcss/lib/node/index.js +1 -0
  89. package/dist/node_modules/postcss/lib/parse/index.js +1 -0
  90. package/dist/node_modules/postcss/lib/parser/index.js +1 -0
  91. package/dist/node_modules/postcss/lib/postcss/index.js +1 -0
  92. package/dist/node_modules/postcss/lib/postcss/index2.js +1 -0
  93. package/dist/node_modules/postcss/lib/previous-map/index.js +1 -0
  94. package/dist/node_modules/postcss/lib/processor/index.js +1 -0
  95. package/dist/node_modules/postcss/lib/result/index.js +1 -0
  96. package/dist/node_modules/postcss/lib/root/index.js +1 -0
  97. package/dist/node_modules/postcss/lib/rule/index.js +1 -0
  98. package/dist/node_modules/postcss/lib/stringifier/index.js +1 -0
  99. package/dist/node_modules/postcss/lib/stringify/index.js +1 -0
  100. package/dist/node_modules/postcss/lib/symbols/index.js +1 -0
  101. package/dist/node_modules/postcss/lib/terminal-highlight/index.js +1 -0
  102. package/dist/node_modules/postcss/lib/tokenize/index.js +1 -0
  103. package/dist/node_modules/postcss/lib/warn-once/index.js +1 -0
  104. package/dist/node_modules/postcss/lib/warning/index.js +1 -0
  105. package/dist/node_modules/source-map-js/lib/array-set/index.js +1 -0
  106. package/dist/node_modules/source-map-js/lib/base64/index.js +1 -0
  107. package/dist/node_modules/source-map-js/lib/base64-vlq/index.js +1 -0
  108. package/dist/node_modules/source-map-js/lib/binary-search/index.js +1 -0
  109. package/dist/node_modules/source-map-js/lib/mapping-list/index.js +1 -0
  110. package/dist/node_modules/source-map-js/lib/quick-sort/index.js +1 -0
  111. package/dist/node_modules/source-map-js/lib/source-map-consumer/index.js +1 -0
  112. package/dist/node_modules/source-map-js/lib/source-map-generator/index.js +1 -0
  113. package/dist/node_modules/source-map-js/lib/source-node/index.js +1 -0
  114. package/dist/node_modules/source-map-js/lib/util/index.js +1 -0
  115. package/dist/node_modules/source-map-js/source-map/index.js +1 -0
  116. package/package.json +124 -0
@@ -0,0 +1,360 @@
1
+ # DhtmlxGanttPro 插件
2
+ 官网文档:https://docs.dhtmlx.com/
3
+ 基于 DHTMLX-Gantt 的 Vue3 封装组件,提供开箱即用的甘特图功能。
4
+
5
+ ## 功能特性
6
+
7
+ - ✅ **Vue3 Composition API** - 使用最新的 Vue3 语法
8
+ - ✅ **TypeScript 支持** - 完整的类型定义
9
+ - ✅ **响应式数据** - 支持数据动态更新
10
+ - ✅ **事件系统** - 完整的事件回调机制
11
+ - ✅ **配置灵活** - 支持自定义配置和主题
12
+ - ✅ **中文本地化** - 内置中文界面支持
13
+ - ✅ **只读模式** - 支持只读和编辑模式切换
14
+ - ✅ **生命周期管理** - 自动处理组件初始化和销毁
15
+ - ✅ **错误处理** - 完善的错误处理和恢复机制
16
+
17
+ ## 安装
18
+
19
+ ```bash
20
+ npm install @cimom/ci-web-plugins-commom dhtmlx-gantt
21
+ ```
22
+
23
+ ## 基础用法
24
+
25
+ ```vue
26
+ <template>
27
+ <div>
28
+ <DhtmlxGanttPro
29
+ :data="ganttData"
30
+ :links="ganttLinks"
31
+ :height="'500px'"
32
+ @task-click="onTaskClick"
33
+ @task-change="onTaskChange"
34
+ />
35
+ </div>
36
+ </template>
37
+
38
+ <script>
39
+ import { ref } from 'vue'
40
+ import { DhtmlxGanttPro } from '@cimom/ci-web-plugins-commom'
41
+
42
+ export default {
43
+ components: {
44
+ DhtmlxGanttPro
45
+ },
46
+ setup() {
47
+ const ganttData = ref([
48
+ { id: 1, text: '任务1', start_date: '2024-01-01', duration: 5, progress: 0.6 },
49
+ { id: 2, text: '任务2', start_date: '2024-01-08', duration: 3, progress: 0.3 }
50
+ ])
51
+
52
+ const ganttLinks = ref([
53
+ { id: 1, source: 1, target: 2, type: '0' }
54
+ ])
55
+
56
+ const onTaskClick = ({ task }) => {
57
+ console.log('点击任务:', task)
58
+ }
59
+
60
+ const onTaskChange = ({ id, task }) => {
61
+ console.log('任务变更:', id, task)
62
+ }
63
+
64
+ return {
65
+ ganttData,
66
+ ganttLinks,
67
+ onTaskClick,
68
+ onTaskChange
69
+ }
70
+ }
71
+ }
72
+ </script>
73
+ ```
74
+
75
+ ## 按需引入
76
+
77
+ ```javascript
78
+ import { DhtmlxGanttPro } from '@cimom/ci-web-plugins-commom/DhtmlxGanttPro'
79
+ ```
80
+
81
+ ## 全局注册
82
+
83
+ ```javascript
84
+ import { createApp } from 'vue'
85
+ import CIWebPlugins from '@cimom/ci-web-plugins-commom'
86
+ import 'dhtmlx-gantt/codebase/dhtmlxgantt.css'
87
+
88
+ const app = createApp(App)
89
+ app.use(CIWebPlugins)
90
+ ```
91
+
92
+ ## Props
93
+
94
+ | 参数 | 类型 | 默认值 | 说明 |
95
+ |------|------|--------|------|
96
+ | width | String/Number | '100%' | 甘特图宽度 |
97
+ | height | String/Number | '500px' | 甘特图高度 |
98
+ | data | Array | [] | 任务数据 |
99
+ | links | Array | [] | 任务依赖关系数据 |
100
+ | config | Object | {} | 甘特图配置 |
101
+ | readonly | Boolean | false | 是否只读模式 |
102
+ | locale | String | 'cn' | 本地化语言 |
103
+ | theme | String | 'default' | 主题样式 |
104
+
105
+ ## 数据格式
106
+
107
+ ### 任务数据 (data)
108
+
109
+ ```javascript
110
+ [
111
+ {
112
+ id: 1, // 任务ID (必需)
113
+ text: '任务名称', // 任务名称 (必需)
114
+ start_date: '2024-01-01', // 开始日期 (必需)
115
+ duration: 5, // 工期 (必需)
116
+ progress: 0.6, // 进度 0-1
117
+ parent: 0, // 父任务ID
118
+ type: 'task', // 任务类型
119
+ color: '#3498db', // 颜色
120
+ priority: 1, // 优先级
121
+ // ... 其他自定义字段
122
+ }
123
+ ]
124
+ ```
125
+
126
+ ### 依赖关系数据 (links)
127
+
128
+ ```javascript
129
+ [
130
+ {
131
+ id: 1, // 链接ID (必需)
132
+ source: 1, // 源任务ID (必需)
133
+ target: 2, // 目标任务ID (必需)
134
+ type: '0' // 链接类型: '0'-'结束到开始', '1'-'开始到开始', '2'-'结束到结束', '3'-'开始到结束'
135
+ }
136
+ ]
137
+ ```
138
+
139
+ ## 事件
140
+
141
+ | 事件名 | 参数 | 说明 |
142
+ |--------|------|------|
143
+ | task-click | { task, event } | 任务点击 |
144
+ | task-dblclick | { task, event } | 任务双击 |
145
+ | task-change | { id, task } | 任务变更 |
146
+ | task-add | { id, task } | 任务添加 |
147
+ | task-delete | { id } | 任务删除 |
148
+ | data-loaded | { data, links } | 数据加载完成 |
149
+ | data-error | error | 数据加载错误 |
150
+ | view-change | { mode } | 视图变更 |
151
+ | scale-change | - | 时间尺度变更 |
152
+
153
+ ## 配置选项
154
+
155
+ ```javascript
156
+ const config = {
157
+ // 日期格式
158
+ date_format: '%Y-%m-%d',
159
+
160
+ // 时间尺度
161
+ scale_unit: 'day', // 'minute', 'hour', 'day', 'week', 'month', 'year'
162
+ date_scale: '%m/%d',
163
+ step: 1,
164
+
165
+ // 子尺度
166
+ subscales: [
167
+ { unit: 'month', step: 1, date: '%Y年%m月' }
168
+ ],
169
+
170
+ // 列配置
171
+ columns: [
172
+ { name: 'text', label: '任务名称', width: 150, tree: true },
173
+ { name: 'start_date', label: '开始时间', width: 80 },
174
+ { name: 'duration', label: '工期', width: 60 },
175
+ { name: 'progress', label: '进度', width: 60 }
176
+ ],
177
+
178
+ // 其他配置...
179
+ }
180
+ ```
181
+
182
+ ## 方法
183
+
184
+ 通过 ref 可以调用以下方法:
185
+
186
+ ```javascript
187
+ const ganttRef = ref(null)
188
+
189
+ // 获取甘特图实例
190
+ const ganttInstance = ganttRef.value.getGanttInstance()
191
+
192
+ // 刷新甘特图 - 重新应用配置
193
+ ganttRef.value.refresh()
194
+
195
+ // 获取选中的任务
196
+ const selectedTask = ganttRef.value.getSelectedTask()
197
+
198
+ // 添加任务
199
+ ganttRef.value.addTask({
200
+ text: '新任务',
201
+ start_date: '2024-01-01',
202
+ duration: 3
203
+ })
204
+
205
+ // 更新任务
206
+ ganttRef.value.updateTask(1, {
207
+ text: '更新的任务',
208
+ progress: 0.8
209
+ })
210
+
211
+ // 删除任务
212
+ ganttRef.value.deleteTask(1)
213
+
214
+ // 缩放到适应所有任务
215
+ ganttRef.value.fitToTask()
216
+ ```
217
+
218
+ ### 配置更新
219
+
220
+ 为了避免递归更新问题,配置变更不会自动应用到甘特图。如需更新配置,请调用 `refresh()` 方法:
221
+
222
+ ```javascript
223
+ const ganttRef = ref(null)
224
+ const ganttConfig = ref({
225
+ scale_unit: 'day',
226
+ date_scale: '%m/%d'
227
+ })
228
+
229
+ // 更新配置后刷新
230
+ const updateConfig = () => {
231
+ ganttConfig.value.scale_unit = 'week'
232
+ ganttConfig.value.date_scale = '%W周'
233
+
234
+ // 手动刷新以应用新配置
235
+ nextTick(() => {
236
+ ganttRef.value?.refresh()
237
+ })
238
+ }
239
+ ```
240
+
241
+ ## 高级用法
242
+
243
+ ### 自定义主题
244
+
245
+ ```vue
246
+ <template>
247
+ <DhtmlxGanttPro
248
+ :data="ganttData"
249
+ :theme="'dark'"
250
+ :config="customConfig"
251
+ />
252
+ </template>
253
+
254
+ <script>
255
+ const customConfig = {
256
+ // 自定义样式配置
257
+ grid_width: 350,
258
+ add_column: false,
259
+ autosize: 'y',
260
+ details_on_create: true,
261
+ // 更多配置...
262
+ }
263
+ </script>
264
+ ```
265
+
266
+ ### 动态数据加载
267
+
268
+ ```javascript
269
+ const loadProjectData = async (projectId) => {
270
+ try {
271
+ const response = await fetch(`/api/projects/${projectId}`)
272
+ const { data, links } = await response.json()
273
+
274
+ ganttData.value = data
275
+ ganttLinks.value = links
276
+ } catch (error) {
277
+ console.error('数据加载失败:', error)
278
+ }
279
+ }
280
+ ```
281
+
282
+ ### 只读模式
283
+
284
+ ```vue
285
+ <template>
286
+ <div>
287
+ <button @click="toggleReadonly">
288
+ {{ readonly ? '编辑模式' : '只读模式' }}
289
+ </button>
290
+
291
+ <DhtmlxGanttPro
292
+ :data="ganttData"
293
+ :readonly="readonly"
294
+ />
295
+ </div>
296
+ </template>
297
+ ```
298
+
299
+ ## 样式定制
300
+
301
+ ```css
302
+ /* 容器样式 */
303
+ .dhtmlx-gantt-pro {
304
+ border-radius: 8px;
305
+ overflow: hidden;
306
+ }
307
+
308
+ /* 任务条样式 */
309
+ :deep(.gantt_task_line) {
310
+ border-radius: 4px;
311
+ }
312
+
313
+ /* 进度条样式 */
314
+ :deep(.gantt_task_progress) {
315
+ border-radius: 4px;
316
+ background: linear-gradient(90deg, #4CAF50, #45a049);
317
+ }
318
+
319
+ /* 网格头部样式 */
320
+ :deep(.gantt_grid_scale) {
321
+ background: #f8f9fa;
322
+ border-bottom: 2px solid #e9ecef;
323
+ }
324
+ ```
325
+
326
+ ## 注意事项
327
+
328
+ 1. **依赖版本**: 确保安装了正确版本的 `dhtmlx-gantt`
329
+ 2. **CSS 样式**: 需要导入 `dhtmlx-gantt/codebase/dhtmlxgantt.css`
330
+ 3. **数据格式**: 严格按照文档格式提供数据
331
+ 4. **性能优化**: 大量数据时建议使用分页或虚拟滚动
332
+ 5. **浏览器兼容**: 支持现代浏览器,IE 需要额外 polyfill
333
+
334
+ ## 常见问题
335
+
336
+ ### Q: 甘特图不显示?
337
+ A: 检查是否正确导入了 CSS 文件,确保容器有正确的宽高。
338
+
339
+ ### Q: 数据更新后视图不刷新?
340
+ A: 确保使用响应式数据,或者调用 `refresh()` 方法。
341
+
342
+ ### Q: 如何自定义列?
343
+ A: 在 `config.columns` 中配置列定义。
344
+
345
+ ### Q: 如何处理大量数据?
346
+ A: 建议使用分页加载,或者启用虚拟滚动。
347
+
348
+ ## 更新日志
349
+
350
+ ### v1.0.0
351
+ - 🎉 初始版本发布
352
+ - ✨ 支持 Vue3 Composition API
353
+ - ✨ 完整的事件系统
354
+ - ✨ 中文本地化支持
355
+ - ✨ 只读模式
356
+ - ✨ TypeScript 类型定义
357
+
358
+ ## 许可证
359
+
360
+ MIT License
@@ -0,0 +1 @@
1
+ import"../components/DhtmlxGanttPro/index.vue/index.js";export{default}from"../components/DhtmlxGanttPro/index.vue/index2.js";
@@ -0,0 +1,302 @@
1
+ # HeaderDropdown 组件使用说明
2
+
3
+ ## 简介
4
+
5
+ `HeaderDropdown` 是一个用于表格列头的下拉菜单组件,提供了丰富的表格操作功能,包括导入导出、排序、列设置、样式调整等。该组件与 `VxeTablePro` 配合使用,通过传入 `tableRef` 来操作底层表格实例。
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ npm install @cimom/ci-web-plugins-commom
11
+ ```
12
+
13
+ ## 使用方法
14
+
15
+ ### 基础用法
16
+
17
+ ```vue
18
+ <script setup>
19
+ import { ref } from 'vue'
20
+ import HeaderDropdown from '@cimom/ci-web-plugins-commom/HeaderDropdown'
21
+ import VxeTablePro from '@cimom/ci-web-plugins-commom/VxeTablePro'
22
+
23
+ const tableRef = ref(null)
24
+
25
+ // 自定义导出
26
+ function handleExport() {
27
+ console.log('自定义导出逻辑')
28
+ }
29
+
30
+ // 自定义导入
31
+ function handleImport() {
32
+ console.log('自定义导入逻辑')
33
+ }
34
+ </script>
35
+
36
+ <template>
37
+ <VxeTablePro ref="tableRef" :data="tableData">
38
+ <vxe-column field="name" title="姓名">
39
+ <template #header>
40
+ <HeaderDropdown
41
+ :table-ref="tableRef"
42
+ title="姓名"
43
+ :column="{ field: 'name' }"
44
+ :header-config="{
45
+ import: true,
46
+ export: true,
47
+ custom: true,
48
+ lineHeight: true,
49
+ fullscreen: true
50
+ }"
51
+ :on-export="handleExport"
52
+ :on-import="handleImport"
53
+ />
54
+ </template>
55
+ </vxe-column>
56
+ </VxeTablePro>
57
+ </template>
58
+ ```
59
+
60
+ ## Props 参数说明
61
+
62
+ ### 必需参数
63
+
64
+ | 参数名 | 类型 | 说明 |
65
+ |--------|------|------|
66
+ | `tableRef` | Object | VxeTablePro 组件的 ref 实例,用于操作表格 |
67
+
68
+ ### 可选参数
69
+
70
+ | 参数名 | 类型 | 默认值 | 说明 |
71
+ |--------|------|--------|------|
72
+ | `title` | String | `null` | 列头标题文本 |
73
+ | `column` | Object | `null` | 列配置对象,包含 `field` 等属性,用于锁定/解锁列功能 |
74
+
75
+ ### headerConfig 配置项
76
+
77
+ 通过 `headerConfig` 对象控制菜单项的显示,所有配置项均为 `Boolean` 类型:
78
+
79
+ | 配置项 | 类型 | 默认值 | 说明 |
80
+ |--------|------|--------|------|
81
+ | `import` | Boolean | `false` | 显示"导入"菜单项 |
82
+ | `export` | Boolean | `false` | 显示"导出"菜单项 |
83
+ | `lineHeight` | Boolean | `false` | 显示"行高"设置菜单项 |
84
+ | `custom` | Boolean | `false` | 显示"列设置"菜单项 |
85
+ | `resetCustom` | Boolean | `false` | 显示"重置列"菜单项 |
86
+ | `save` | Boolean | `false` | 显示"保存布局"菜单项 |
87
+ | `feedback` | Boolean | `false` | 显示"样式"菜单项(斑马纹、边框) |
88
+ | `chart` | Boolean | `false` | 显示"排版"菜单项(表格尺寸) |
89
+ | `fullscreen` | Boolean | `false` | 显示"全屏"菜单项 |
90
+ | `print` | Boolean | `false` | 显示"打印"菜单项 |
91
+ | `lock` | Boolean | `false` | 显示"锁定"菜单项(固定列到左侧) |
92
+ | `unlock` | Boolean | `false` | 显示"解锁"菜单项(取消固定列) |
93
+
94
+ ### 回调函数
95
+
96
+ 所有回调函数均为可选,如果提供了函数则显示对应菜单项并执行自定义逻辑,否则使用默认行为:
97
+
98
+ | 函数名 | 参数 | 说明 |
99
+ |--------|------|------|
100
+ | `onImport` | `()` | 自定义导入逻辑 |
101
+ | `onExport` | `()` | 自定义导出逻辑 |
102
+ | `onAsc` | `()` | 正序排序回调 |
103
+ | `onDesc` | `()` | 倒序排序回调 |
104
+ | `onFullscreen` | `()` | 全屏回调 |
105
+ | `onPrint` | `()` | 打印回调 |
106
+ | `onCustom` | `()` | 列设置回调 |
107
+ | `onIndividual` | `(tableId, storeData)` | 保存个人布局回调,参数:表格ID、存储数据 |
108
+ | `onAll` | `(tableId, storeData)` | 保存所有布局回调,参数:表格ID、存储数据 |
109
+ | `refreshCustom` | `(tableId)` | 刷新布局回调,参数:表格ID |
110
+ | `searchCustom` | `()` | 刷新回调 |
111
+
112
+ ## 功能说明
113
+
114
+ ### 1. 导入/导出
115
+
116
+ - **导入**:点击后触发 `onImport` 回调,如果未提供则调用 `tableRef.openImport()`
117
+ - **导出**:点击后触发 `onExport` 回调,如果未提供则调用 `tableRef.exportData()` 进行默认导出
118
+
119
+ ### 2. 排序
120
+
121
+ - **正序(接口)**:触发 `onAsc` 回调,用于服务端排序
122
+ - **倒序(接口)**:触发 `onDesc` 回调,用于服务端排序
123
+
124
+ ### 3. 行高设置
125
+
126
+ 当 `headerConfig.lineHeight` 为 `true` 时显示,支持通过数字输入框调整表格行高(范围:1-200)。
127
+
128
+ ### 4. 列设置
129
+
130
+ - **列设置**:打开列自定义配置弹窗(需要 VxeTablePro 支持)
131
+ - **重置列**:重置列配置为默认状态,并保存到 localStorage
132
+
133
+ ### 5. 保存布局
134
+
135
+ 当 `headerConfig.save` 为 `true` 时显示,包含子菜单:
136
+ - **保存个人**:调用 `onIndividual(tableId, storeData)` 保存个人配置
137
+ - **保存所有**:调用 `onAll(tableId, storeData)` 保存全局配置
138
+
139
+ 存储数据结构:
140
+ ```javascript
141
+ {
142
+ resizableData: {}, // 列宽配置
143
+ sortData: {}, // 列排序顺序
144
+ visibleData: {}, // 列显示/隐藏
145
+ fixedData: {}, // 固定列配置
146
+ basicConfig: { // 基础配置(边框、行高、斑马纹、尺寸)
147
+ border: true,
148
+ lineHeight: 36,
149
+ stripe: false,
150
+ cellStyle: 'mini'
151
+ }
152
+ }
153
+ ```
154
+
155
+ ### 6. 样式设置
156
+
157
+ 当 `headerConfig.feedback` 为 `true` 时显示,包含:
158
+ - **启用斑马纹**:切换表格斑马纹样式
159
+ - **启用边框**:切换表格边框显示
160
+
161
+ ### 7. 排版设置
162
+
163
+ 当 `headerConfig.chart` 为 `true` 时显示,支持切换表格尺寸:
164
+ - **默认**:`default`
165
+ - **中**:`medium`
166
+ - **小**:`small`
167
+ - **迷你**:`mini`
168
+
169
+ ### 8. 其他功能
170
+
171
+ - **更新布局**:刷新表格布局配置
172
+ - **刷新**:触发 `searchCustom` 回调
173
+ - **全屏**:切换表格全屏显示
174
+ - **打印**:触发 `onPrint` 回调
175
+ - **锁定/解锁**:固定/取消固定当前列到左侧
176
+
177
+ ## 完整示例
178
+
179
+ ```vue
180
+ <script setup>
181
+ import { ref, reactive } from 'vue'
182
+ import HeaderDropdown from '@cimom/ci-web-plugins-commom/HeaderDropdown'
183
+ import VxeTablePro from '@cimom/ci-web-plugins-commom/VxeTablePro'
184
+
185
+ const tableRef = ref(null)
186
+ const tableData = reactive([
187
+ { id: '10001', name: '张三', sex: '男', age: 28 },
188
+ { id: '10002', name: '李四', sex: '女', age: 22 }
189
+ ])
190
+
191
+ // 自定义导出
192
+ function handleExport() {
193
+ tableRef.value?.exportData({
194
+ filename: '用户数据',
195
+ type: 'xlsx'
196
+ })
197
+ }
198
+
199
+ // 保存个人布局
200
+ function handleSaveIndividual(tableId, storeData) {
201
+ console.log('保存个人布局:', tableId, storeData)
202
+ // 发送到服务器保存
203
+ // api.saveUserLayout(tableId, storeData)
204
+ }
205
+
206
+ // 保存所有布局
207
+ function handleSaveAll(tableId, storeData) {
208
+ console.log('保存所有布局:', tableId, storeData)
209
+ // 发送到服务器保存
210
+ // api.saveGlobalLayout(tableId, storeData)
211
+ }
212
+ </script>
213
+
214
+ <template>
215
+ <VxeTablePro
216
+ ref="tableRef"
217
+ :data="tableData"
218
+ id="my-table"
219
+ >
220
+ <vxe-column field="name" title="姓名" width="120">
221
+ <template #header>
222
+ <HeaderDropdown
223
+ :table-ref="tableRef"
224
+ title="姓名"
225
+ :column="{ field: 'name' }"
226
+ :header-config="{
227
+ import: true,
228
+ export: true,
229
+ custom: true,
230
+ resetCustom: true,
231
+ save: true,
232
+ lineHeight: true,
233
+ feedback: true,
234
+ chart: true,
235
+ fullscreen: true,
236
+ print: true,
237
+ lock: true,
238
+ unlock: true
239
+ }"
240
+ :on-export="handleExport"
241
+ :on-individual="handleSaveIndividual"
242
+ :on-all="handleSaveAll"
243
+ />
244
+ </template>
245
+ </vxe-column>
246
+ <vxe-column field="sex" title="性别" width="80" />
247
+ <vxe-column field="age" title="年龄" width="80" />
248
+ </VxeTablePro>
249
+ </template>
250
+ ```
251
+
252
+ ## 数据持久化
253
+
254
+ 组件会自动将以下配置保存到 `localStorage`:
255
+
256
+ - **基础配置**:存储在 `tableId` 键下,包含边框、行高、斑马纹、尺寸等
257
+ - **列配置**:存储在 `VXE_CUSTOM_STORE` 键下,包含列宽、排序、显示状态、固定列等
258
+
259
+ ### 读取配置
260
+
261
+ ```javascript
262
+ // 读取基础配置
263
+ const basicConfig = JSON.parse(localStorage.getItem(tableId))
264
+
265
+ // 读取列配置
266
+ const customStorageKey = 'VXE_CUSTOM_STORE'
267
+ const storage = JSON.parse(localStorage.getItem(customStorageKey))
268
+ const columnConfig = storage[tableId]
269
+ ```
270
+
271
+ ## 注意事项
272
+
273
+ 1. **tableRef 必需**:组件需要 `tableRef` 才能正常工作,确保传入正确的 VxeTablePro 实例
274
+ 2. **列配置对象**:使用锁定/解锁功能时,需要传入 `column` 对象,包含 `field` 属性
275
+ 3. **表格 ID**:确保 VxeTablePro 设置了 `id` 属性,用于数据持久化
276
+ 4. **回调函数**:所有回调函数都是可选的,未提供时会使用默认行为
277
+
278
+ ## 与 VxeTablePro 集成
279
+
280
+ HeaderDropdown 组件设计用于与 VxeTablePro 配合使用:
281
+
282
+ ```vue
283
+ <template>
284
+ <VxeTablePro ref="tableRef" id="my-table" :data="data">
285
+ <vxe-column field="name" title="姓名">
286
+ <template #header>
287
+ <HeaderDropdown :table-ref="tableRef" :header-config="{ export: true }" />
288
+ </template>
289
+ </vxe-column>
290
+ </VxeTablePro>
291
+ </template>
292
+ ```
293
+
294
+ 通过 `tableRef` 可以访问 VxeTablePro 的所有方法,包括:
295
+ - `exportData()` - 导出数据
296
+ - `openImport()` - 打开导入
297
+ - `toggleFullscreen()` - 切换全屏
298
+ - `vxeTableProRef` - 底层 vxe-table 实例
299
+
300
+ ---
301
+
302
+ > 组件打包采用 `rollup.config.js`,产物位于 `dist/HeaderDropdown` 目录,按需引入即可。
@@ -0,0 +1 @@
1
+ import"../components/HeaderDropdown/index.vue/index.js";export{default}from"../components/HeaderDropdown/index.vue/index2.js";
@@ -0,0 +1 @@
1
+ import"../components/HelloPlugin.vue/index.js";export{default}from"../components/HelloPlugin.vue/index2.js";
@@ -0,0 +1 @@
1
+ import"../components/HelloWorld.vue/index.js";export{default}from"../components/HelloWorld.vue/index2.js";