@a2simcode/ui 0.0.264 → 0.0.265
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/dist/components/table/index.d.ts +30 -0
- package/dist/components/table/src/interface.d.ts +42 -0
- package/dist/components/table/src/table.vue.d.ts +25 -1
- package/dist/simcode-ui.es.js +2123 -2110
- package/dist/simcode-ui.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/dist/ui.css +1 -1
- package/docs/components/meta/table.ts +6 -0
- package/docs/components/table.md +30 -0
- package/docs/examples/table/custom-merge-cell.vue +206 -0
- package/docs/examples/table/merge-cell.vue +78 -0
- package/docs/examples/table/row-fixed.vue +7 -1
- package/package.json +4 -4
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-radio-group v-model="mode" style="margin-bottom: 12px">
|
|
4
|
+
<el-radio-button value="array">数组模式</el-radio-button>
|
|
5
|
+
<el-radio-button value="function">回调函数模式</el-radio-button>
|
|
6
|
+
</el-radio-group>
|
|
7
|
+
|
|
8
|
+
<div style="position: relative; width: 100%; height: 500px">
|
|
9
|
+
<j-table
|
|
10
|
+
:columns="columns"
|
|
11
|
+
:records="records"
|
|
12
|
+
:custom-merge-cell="customMergeCell"
|
|
13
|
+
:is-show-number="false"
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { ref, computed } from 'vue'
|
|
21
|
+
|
|
22
|
+
const mode = ref<'array' | 'function'>('array')
|
|
23
|
+
|
|
24
|
+
const columns = ref([
|
|
25
|
+
{ id: 'xiangmu', config: { label: '项目', width: 120, align: 'center' } },
|
|
26
|
+
{ id: 'mokuai', config: { label: '模块', width: 120, align: 'center' } },
|
|
27
|
+
{ id: 'fuzeren', config: { label: '负责人', width: 'auto', align: 'center' } },
|
|
28
|
+
{ id: 'jindu', config: { label: '进度', width: 100, align: 'center' } },
|
|
29
|
+
{ id: 'zhuangtai', config: { label: '状态', width: 100, align: 'center' } },
|
|
30
|
+
{ id: 'beizhu', config: { label: '备注', width: 'auto', align: 'left' } },
|
|
31
|
+
])
|
|
32
|
+
|
|
33
|
+
const records = ref([
|
|
34
|
+
{
|
|
35
|
+
xiangmu: '项目A',
|
|
36
|
+
mokuai: '前端',
|
|
37
|
+
fuzeren: '张三',
|
|
38
|
+
jindu: '80%',
|
|
39
|
+
zhuangtai: '进行中',
|
|
40
|
+
beizhu: '按计划推进',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
xiangmu: '项目A',
|
|
44
|
+
mokuai: '后端',
|
|
45
|
+
fuzeren: '李四',
|
|
46
|
+
jindu: '60%',
|
|
47
|
+
zhuangtai: '进行中',
|
|
48
|
+
beizhu: '接口开发中',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
xiangmu: '项目A',
|
|
52
|
+
mokuai: '测试',
|
|
53
|
+
fuzeren: '王五',
|
|
54
|
+
jindu: '0%',
|
|
55
|
+
zhuangtai: '未开始',
|
|
56
|
+
beizhu: '等待开发完成',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
xiangmu: '项目A',
|
|
60
|
+
mokuai: '设计',
|
|
61
|
+
fuzeren: '赵六',
|
|
62
|
+
jindu: '100%',
|
|
63
|
+
zhuangtai: '已完成',
|
|
64
|
+
beizhu: '',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
xiangmu: '项目B',
|
|
68
|
+
mokuai: '前端',
|
|
69
|
+
fuzeren: '钱七',
|
|
70
|
+
jindu: '40%',
|
|
71
|
+
zhuangtai: '进行中',
|
|
72
|
+
beizhu: '需求变更',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
xiangmu: '项目B',
|
|
76
|
+
mokuai: '后端',
|
|
77
|
+
fuzeren: '孙八',
|
|
78
|
+
jindu: '90%',
|
|
79
|
+
zhuangtai: '进行中',
|
|
80
|
+
beizhu: '即将收尾',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
xiangmu: '项目B',
|
|
84
|
+
mokuai: '测试',
|
|
85
|
+
fuzeren: '周九',
|
|
86
|
+
jindu: '20%',
|
|
87
|
+
zhuangtai: '进行中',
|
|
88
|
+
beizhu: '部分测试中',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
xiangmu: '项目B',
|
|
92
|
+
mokuai: '运维',
|
|
93
|
+
fuzeren: '吴十',
|
|
94
|
+
jindu: '0%',
|
|
95
|
+
zhuangtai: '未开始',
|
|
96
|
+
beizhu: '',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
xiangmu: '项目C',
|
|
100
|
+
mokuai: '前端',
|
|
101
|
+
fuzeren: '郑十一',
|
|
102
|
+
jindu: '100%',
|
|
103
|
+
zhuangtai: '已完成',
|
|
104
|
+
beizhu: '',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
xiangmu: '项目C',
|
|
108
|
+
mokuai: '后端',
|
|
109
|
+
fuzeren: '王十二',
|
|
110
|
+
jindu: '100%',
|
|
111
|
+
zhuangtai: '已完成',
|
|
112
|
+
beizhu: '',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
xiangmu: '项目C',
|
|
116
|
+
mokuai: '测试',
|
|
117
|
+
fuzeren: '李十三',
|
|
118
|
+
jindu: '50%',
|
|
119
|
+
zhuangtai: '进行中',
|
|
120
|
+
beizhu: '回归测试中',
|
|
121
|
+
},
|
|
122
|
+
])
|
|
123
|
+
|
|
124
|
+
// 数组模式:静态定义合并规则(row 从 1 开始,0 是表头)
|
|
125
|
+
const arrayRules = [
|
|
126
|
+
// 合并行:项目A 的"项目"列纵向合并 4 行
|
|
127
|
+
{
|
|
128
|
+
text: '项目A 汇总\n前端+后端+测试+设计',
|
|
129
|
+
range: { start: { col: 0, row: 1 }, end: { col: 0, row: 4 } },
|
|
130
|
+
style: { bgColor: '#e8f5e9', color: '#2e7d32' },
|
|
131
|
+
},
|
|
132
|
+
// 合并行:项目B 的"项目"列纵向合并 4 行
|
|
133
|
+
{
|
|
134
|
+
text: '项目B 汇总',
|
|
135
|
+
range: { start: { col: 0, row: 5 }, end: { col: 0, row: 8 } },
|
|
136
|
+
style: { bgColor: '#e3f2fd', color: '#1565c0' },
|
|
137
|
+
},
|
|
138
|
+
// 合并行:项目C 的"项目"列纵向合并 3 行
|
|
139
|
+
{
|
|
140
|
+
text: '项目C 汇总',
|
|
141
|
+
range: { start: { col: 0, row: 9 }, end: { col: 0, row: 11 } },
|
|
142
|
+
style: { bgColor: '#fff3e0', color: '#e65100' },
|
|
143
|
+
},
|
|
144
|
+
// 合并列+行:项目B 的进度/状态/备注 3 列 × 4 行合并为一个大单元格
|
|
145
|
+
{
|
|
146
|
+
text: '项目B 整体评估\n进度偏慢,需重点关注测试模块',
|
|
147
|
+
range: { start: { col: 3, row: 5 }, end: { col: 5, row: 8 } },
|
|
148
|
+
style: { bgColor: '#fce4ec', color: '#c62828' },
|
|
149
|
+
},
|
|
150
|
+
// 合并列+行:项目C 的进度/状态/备注 3 列 × 3 行合并为一个大单元格
|
|
151
|
+
{
|
|
152
|
+
text: '项目C 即将收尾\n前端后端已完成,测试进行中',
|
|
153
|
+
range: { start: { col: 3, row: 9 }, end: { col: 5, row: 11 } },
|
|
154
|
+
style: { bgColor: '#f3e5f5', color: '#6a1b9a' },
|
|
155
|
+
},
|
|
156
|
+
]
|
|
157
|
+
|
|
158
|
+
// 回调函数模式:根据 col/row 动态返回合并规则
|
|
159
|
+
const funcMerge = (col: number, row: number) => {
|
|
160
|
+
// 合并"项目"列(col=0),row 从 1 开始(0 是表头)
|
|
161
|
+
if (col === 0) {
|
|
162
|
+
if (row >= 1 && row <= 4) {
|
|
163
|
+
return {
|
|
164
|
+
text: '项目A 汇总\n前端+后端+测试+设计',
|
|
165
|
+
range: { start: { col: 0, row: 1 }, end: { col: 0, row: 4 } },
|
|
166
|
+
style: { bgColor: '#e8f5e9', color: '#2e7d32' },
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (row >= 5 && row <= 8) {
|
|
170
|
+
return {
|
|
171
|
+
text: '项目B 汇总',
|
|
172
|
+
range: { start: { col: 0, row: 5 }, end: { col: 0, row: 8 } },
|
|
173
|
+
style: { bgColor: '#e3f2fd', color: '#1565c0' },
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (row >= 9 && row <= 11) {
|
|
177
|
+
return {
|
|
178
|
+
text: '项目C 汇总',
|
|
179
|
+
range: { start: { col: 0, row: 9 }, end: { col: 0, row: 11 } },
|
|
180
|
+
style: { bgColor: '#fff3e0', color: '#e65100' },
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
// 合并列+行:项目B 的进度/状态/备注 3 列 × 4 行
|
|
185
|
+
if (col >= 3 && col <= 5 && row >= 5 && row <= 8) {
|
|
186
|
+
return {
|
|
187
|
+
text: '项目B 整体评估\n进度偏慢,需重点关注测试模块',
|
|
188
|
+
range: { start: { col: 3, row: 5 }, end: { col: 5, row: 8 } },
|
|
189
|
+
style: { bgColor: '#fce4ec', color: '#c62828' },
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// 合并列+行:项目C 的进度/状态/备注 3 列 × 3 行
|
|
193
|
+
if (col >= 3 && col <= 5 && row >= 9 && row <= 11) {
|
|
194
|
+
return {
|
|
195
|
+
text: '项目C 即将收尾\n前端后端已完成,测试进行中',
|
|
196
|
+
range: { start: { col: 3, row: 9 }, end: { col: 5, row: 11 } },
|
|
197
|
+
style: { bgColor: '#f3e5f5', color: '#6a1b9a' },
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return undefined
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const customMergeCell = computed(() => {
|
|
204
|
+
return mode.value === 'array' ? arrayRules : funcMerge
|
|
205
|
+
})
|
|
206
|
+
</script>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div style="position: relative; width: 100%; height: 500px">
|
|
3
|
+
<j-table :columns="columns" :records="records" />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { ref } from 'vue'
|
|
9
|
+
|
|
10
|
+
const columns = ref([
|
|
11
|
+
{
|
|
12
|
+
id: 'bumen',
|
|
13
|
+
config: {
|
|
14
|
+
label: '部门',
|
|
15
|
+
width: 120,
|
|
16
|
+
align: 'center',
|
|
17
|
+
// 自动合并相邻相同值的单元格
|
|
18
|
+
mergeCell: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
id: 'zu',
|
|
23
|
+
config: {
|
|
24
|
+
label: '组',
|
|
25
|
+
width: 120,
|
|
26
|
+
align: 'center',
|
|
27
|
+
// 自定义合并:同部门且同组时才合并
|
|
28
|
+
mergeCell: (v1: unknown, v2: unknown, info: any) => {
|
|
29
|
+
const table = info.table
|
|
30
|
+
const r1 = info.source.row
|
|
31
|
+
const r2 = info.target.row
|
|
32
|
+
const bumenCol = table.getBodyColumnDefine('bumen')
|
|
33
|
+
const val1 = table.getCellValue(bumenCol?.col ?? 0, r1)
|
|
34
|
+
const val2 = table.getCellValue(bumenCol?.col ?? 0, r2)
|
|
35
|
+
return val1 === val2 && v1 === v2
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'xingming',
|
|
41
|
+
config: {
|
|
42
|
+
label: '姓名',
|
|
43
|
+
width: 'auto',
|
|
44
|
+
align: 'left',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'zhiwei',
|
|
49
|
+
config: {
|
|
50
|
+
label: '职位',
|
|
51
|
+
width: 'auto',
|
|
52
|
+
align: 'left',
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 'gongling',
|
|
57
|
+
config: {
|
|
58
|
+
label: '工龄(年)',
|
|
59
|
+
width: 100,
|
|
60
|
+
align: 'center',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
])
|
|
64
|
+
|
|
65
|
+
const records = ref([
|
|
66
|
+
{ bumen: '技术部', zu: '前端组', xingming: '张三', zhiwei: '高级工程师', gongling: 5 },
|
|
67
|
+
{ bumen: '技术部', zu: '前端组', xingming: '李四', zhiwei: '工程师', gongling: 3 },
|
|
68
|
+
{ bumen: '技术部', zu: '前端组', xingming: '王五', zhiwei: '初级工程师', gongling: 1 },
|
|
69
|
+
{ bumen: '技术部', zu: '后端组', xingming: '赵六', zhiwei: '高级工程师', gongling: 6 },
|
|
70
|
+
{ bumen: '技术部', zu: '后端组', xingming: '钱七', zhiwei: '工程师', gongling: 4 },
|
|
71
|
+
{ bumen: '产品部', zu: '产品设计', xingming: '孙八', zhiwei: '产品经理', gongling: 4 },
|
|
72
|
+
{ bumen: '产品部', zu: '产品设计', xingming: '周九', zhiwei: '产品助理', gongling: 2 },
|
|
73
|
+
{ bumen: '产品部', zu: '用户研究', xingming: '吴十', zhiwei: '用研专家', gongling: 5 },
|
|
74
|
+
{ bumen: '市场部', zu: '品牌组', xingming: '郑十一', zhiwei: '品牌经理', gongling: 7 },
|
|
75
|
+
{ bumen: '市场部', zu: '品牌组', xingming: '王十二', zhiwei: '品牌专员', gongling: 2 },
|
|
76
|
+
{ bumen: '市场部', zu: '渠道组', xingming: '李十三', zhiwei: '渠道经理', gongling: 5 },
|
|
77
|
+
])
|
|
78
|
+
</script>
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div style="height: 360px">
|
|
3
|
-
<j-table
|
|
3
|
+
<j-table
|
|
4
|
+
v-model="records"
|
|
5
|
+
is-row-fixed
|
|
6
|
+
:row-num="5"
|
|
7
|
+
:columns="columns"
|
|
8
|
+
:edit-config="{ isAddBtn: true, isRemoveBtn: true }"
|
|
9
|
+
/>
|
|
4
10
|
</div>
|
|
5
11
|
</template>
|
|
6
12
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a2simcode/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.265",
|
|
4
4
|
"description": "A Vue 3 UI Component Library",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/simcode-ui.umd.js",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"@codemirror/state": "6.6.0",
|
|
69
69
|
"@codemirror/view": "6.40.0",
|
|
70
70
|
"@iconify/vue": "5.0.0",
|
|
71
|
-
"@visactor/vtable": "1.26.
|
|
72
|
-
"@visactor/vtable-editors": "1.26.
|
|
73
|
-
"@visactor/vtable-plugins": "1.26.
|
|
71
|
+
"@visactor/vtable": "1.26.5",
|
|
72
|
+
"@visactor/vtable-editors": "1.26.5",
|
|
73
|
+
"@visactor/vtable-plugins": "1.26.5",
|
|
74
74
|
"@vueuse/core": "14.2.1",
|
|
75
75
|
"async-validator": "4.2.5",
|
|
76
76
|
"codemirror": "6.0.2",
|