Skip to content

Commit f85dd71

Browse files
authored
feat(transfer): [transfer] adds the ability to customize the panel width for the transfer component (#3285)
* fix(transfer): add custom panel's size * fix(transfer): document on adding custom panel size functionality * fix(transfer): 添加组合式的示例 * fix(transfer): remove comment
1 parent 542acda commit f85dd71

File tree

10 files changed

+469
-24
lines changed

10 files changed

+469
-24
lines changed

examples/sites/demos/apis/transfer.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,51 @@ export default {
287287
},
288288
mode: ['pc'],
289289
pcDemo: 'basic-usage'
290+
},
291+
{
292+
name: 'panel-style',
293+
type: 'Object',
294+
defaultValue: '',
295+
desc: {
296+
'zh-CN': '指定左右面板容器的样式,当面板的宽度大于外部容器的50%宽度时,面板会自适应容器的宽度。',
297+
'en-US':
298+
"Specify the style of the left and right panel containers. When the width of the panel is greater than 50% of the external container's width, the panel will adapt to the width of the container"
299+
},
300+
mode: ['pc'],
301+
pcDemo: 'custom-size',
302+
meta: {
303+
stable: '3.23.0'
304+
}
305+
},
306+
{
307+
name: 'panel-body-style',
308+
type: 'Object',
309+
defaultValue: '',
310+
desc: {
311+
'zh-CN': '指定面板内容区域的样式',
312+
'en-US': 'Specify the style of the content area of the designated panel.'
313+
},
314+
mode: ['pc'],
315+
pcDemo: 'custom-size',
316+
meta: {
317+
stable: '3.23.0'
318+
}
319+
},
320+
{
321+
name: 'panel-table-height',
322+
type: 'String',
323+
defaultValue: '',
324+
desc: {
325+
'zh-CN':
326+
'嵌套表格时,设置表格的高度值。嵌套表格的默认高度为400px, 当自定义面板内容区域的高度之后,可能会与表格高度不匹配。 可以通过该属性设置一个匹配的表格高度。',
327+
'en-US':
328+
'When nesting tables, set the height value of the table. The default height of a nested table is 400px. After customizing the height of the panel content area, it may not match the height of the table. You can use this property to set a matching table height.'
329+
},
330+
mode: ['pc'],
331+
pcDemo: 'custom-size',
332+
meta: {
333+
stable: '3.23.0'
334+
}
290335
}
291336
],
292337
events: [
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
<template>
2+
<div>
3+
<tiny-transfer
4+
v-model="listValue"
5+
:data="listData"
6+
filterable
7+
:panelStyle="panelStyle"
8+
:panelBodyStyle="panelBodyStyle"
9+
></tiny-transfer>
10+
<br />
11+
<br />
12+
<tiny-transfer
13+
v-model="treeValue"
14+
:props="{ key: 'id', disabled: 'disabled' }"
15+
:tree-op="treeConfig"
16+
filterable
17+
:data="treeData"
18+
:render="renderTree"
19+
:panelStyle="panelStyle"
20+
:panelBodyStyle="panelBodyStyle"
21+
></tiny-transfer>
22+
<br />
23+
<br />
24+
<tiny-transfer
25+
v-model="gridValue"
26+
:render="renderGrid"
27+
:data="gridData"
28+
filter-placeholder="请输入城市拼音"
29+
filterable
30+
:props="{ key: 'id', disabled: 'disabled' }"
31+
:columns="columns"
32+
:pager-op="pagerOp"
33+
:show-pager="true"
34+
:filter-method="filterMethod"
35+
:panelStyle="panelStyle"
36+
:panelBodyStyle="panelBodyStyle"
37+
:panelTableHeight="panelTableHeight"
38+
></tiny-transfer>
39+
</div>
40+
</template>
41+
42+
<script setup lang="jsx">
43+
import { ref } from 'vue'
44+
import { TinyTransfer, TinyTable, TinyTree } from '@opentiny/vue'
45+
46+
const generateData = () => {
47+
const data = []
48+
49+
for (let i = 0; i <= 15; i++) {
50+
data.push({
51+
key: i,
52+
label: `备选项 ${i}`
53+
})
54+
}
55+
56+
return data
57+
}
58+
const getGridData = () => {
59+
const data = []
60+
61+
for (let i = 1; i <= 10; i++) {
62+
data.push({
63+
id: i.toString(),
64+
name: 'GFD 科技 YX 公司 ' + i,
65+
area: '华东区 ' + i,
66+
disabled: i % 4 === 0
67+
})
68+
}
69+
70+
return data
71+
}
72+
// 自定义面板样式
73+
const panelStyle = ref({ width: '650px' })
74+
const panelBodyStyle = ref({ height: '200px' })
75+
const panelTableHeight = ref('700px')
76+
77+
// 列表示例
78+
const listData = ref(generateData())
79+
const listValue = ref([1, 4])
80+
81+
// tree 示例
82+
const treeValue = ref([3, 4, 5])
83+
const renderTree = ref({
84+
plugin: TinyTree
85+
})
86+
const treeData = ref([
87+
{
88+
id: 1,
89+
label: '一级 1',
90+
children: [
91+
{
92+
id: 4,
93+
label: '二级 1-1',
94+
children: [
95+
{
96+
id: 9,
97+
label: '三级 1-1-1'
98+
},
99+
{
100+
id: 10,
101+
label: '三级 1-1-2'
102+
}
103+
]
104+
}
105+
]
106+
},
107+
{
108+
id: 2,
109+
label: '一级 2',
110+
children: [
111+
{
112+
id: 5,
113+
label: '二级 2-1'
114+
},
115+
{
116+
id: 6,
117+
label: '二级 2-2',
118+
disabled: true
119+
}
120+
]
121+
},
122+
{
123+
id: 3,
124+
label: '一级 3',
125+
children: [
126+
{
127+
id: 7,
128+
label: '二级 3-1',
129+
disabled: true
130+
},
131+
{
132+
id: 8,
133+
label: '二级 3-2'
134+
}
135+
]
136+
}
137+
])
138+
const treeConfig = ref({
139+
showLine: true,
140+
showCheckbox: true,
141+
nodeKey: 'id',
142+
checkStrictly: true,
143+
filterNodeMethod(query, data) {
144+
return data.label.includes(query)
145+
}
146+
})
147+
148+
// grid 示例
149+
const renderGrid = ref({
150+
plugin: TinyTable
151+
})
152+
const gridValue = ref(['5', '6', '10'])
153+
const gridData = ref(getGridData())
154+
const columns = ref([
155+
{
156+
type: 'index',
157+
width: '30px'
158+
},
159+
{
160+
type: 'selection',
161+
width: '30px'
162+
},
163+
{
164+
field: 'name',
165+
title: '名称'
166+
},
167+
{
168+
field: 'area',
169+
title: '所属区域'
170+
}
171+
])
172+
const pagerOp = ref({
173+
pageVO: {
174+
pageSizes: [10, 20, 30],
175+
pageSize: 10
176+
}
177+
})
178+
function filterMethod(query, item) {
179+
return item.name.includes(query)
180+
}
181+
</script>

0 commit comments

Comments
 (0)