-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(grid-select): [grid-select] add filter/config features and optim…
…ize demo/api docs (#2521) * docs(grid-select): optimize demo/api * docs(grid-select): add radio-config/select-config demo/api docs * feat(grid-select): add filter and optimize demo/api docs
- Loading branch information
Showing
10 changed files
with
505 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
examples/sites/demos/pc/app/grid-select/config-composition-api.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<template> | ||
<div> | ||
<p>场景1:单选</p> | ||
<br /> | ||
<tiny-grid-select | ||
v-model="valueSingle" | ||
value-field="id" | ||
text-field="city" | ||
:grid-op="gridOpSingle" | ||
:radio-config="radioConfig" | ||
></tiny-grid-select> | ||
<br /><br /> | ||
<p>场景2:多选</p> | ||
<br /> | ||
<tiny-grid-select | ||
v-model="valueMulti" | ||
multiple | ||
value-field="id" | ||
text-field="city" | ||
:grid-op="gridOpMulti" | ||
:select-config="selectConfig" | ||
></tiny-grid-select> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, reactive } from 'vue' | ||
import { TinyGridSelect } from '@opentiny/vue' | ||
const valueSingle = ref('') | ||
const valueMulti = ref([]) | ||
const gridOpSingle = reactive({ | ||
data: [ | ||
{ id: '001', area: '华南区', province: '广东省', city: '广州市' }, | ||
{ id: '002', area: '华南区', province: '广东省', city: '深圳市' }, | ||
{ id: '003', area: '华南区', province: '广东省', city: '珠海市' }, | ||
{ id: '004', area: '华南区', province: '广东省', city: '佛山市' }, | ||
{ id: '005', area: '华南区', province: '广东省', city: '中山市' } | ||
], | ||
columns: [ | ||
{ type: 'radio', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}) | ||
const gridOpMulti = reactive({ | ||
data: [ | ||
{ id: '001', area: '华南区', province: '广东省', city: '广州市' }, | ||
{ id: '002', area: '华南区', province: '广东省', city: '深圳市' }, | ||
{ id: '003', area: '华南区', province: '广东省', city: '珠海市' }, | ||
{ id: '004', area: '华南区', province: '广东省', city: '佛山市' }, | ||
{ id: '005', area: '华南区', province: '广东省', city: '中山市' } | ||
], | ||
columns: [ | ||
{ type: 'selection', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}) | ||
const radioConfig = ref({ | ||
trigger: 'row', | ||
checkMethod({ rowIndex }) { | ||
return rowIndex % 2 === 1 | ||
} | ||
}) | ||
const selectConfig = ref({ | ||
trigger: 'row', | ||
checkMethod({ rowIndex }) { | ||
return rowIndex % 2 === 0 | ||
} | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.tiny-grid-select { | ||
width: 280px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<template> | ||
<div> | ||
<p>场景1:单选</p> | ||
<br /> | ||
<tiny-grid-select | ||
v-model="valueSingle" | ||
value-field="id" | ||
text-field="city" | ||
:grid-op="gridOpSingle" | ||
:radio-config="radioConfig" | ||
></tiny-grid-select> | ||
<br /><br /> | ||
<p>场景2:多选</p> | ||
<br /> | ||
<tiny-grid-select | ||
v-model="valueMulti" | ||
multiple | ||
value-field="id" | ||
text-field="city" | ||
:grid-op="gridOpMulti" | ||
:select-config="selectConfig" | ||
></tiny-grid-select> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { TinyGridSelect } from '@opentiny/vue' | ||
export default { | ||
components: { | ||
TinyGridSelect | ||
}, | ||
data() { | ||
return { | ||
valueSingle: '', | ||
valueMulti: [], | ||
gridOpSingle: { | ||
data: [ | ||
{ id: '001', area: '华南区', province: '广东省', city: '广州市' }, | ||
{ id: '002', area: '华南区', province: '广东省', city: '深圳市' }, | ||
{ id: '003', area: '华南区', province: '广东省', city: '珠海市' }, | ||
{ id: '004', area: '华南区', province: '广东省', city: '佛山市' }, | ||
{ id: '005', area: '华南区', province: '广东省', city: '中山市' } | ||
], | ||
columns: [ | ||
{ type: 'radio', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}, | ||
gridOpMulti: { | ||
data: [ | ||
{ id: '001', area: '华南区', province: '广东省', city: '广州市' }, | ||
{ id: '002', area: '华南区', province: '广东省', city: '深圳市' }, | ||
{ id: '003', area: '华南区', province: '广东省', city: '珠海市' }, | ||
{ id: '004', area: '华南区', province: '广东省', city: '佛山市' }, | ||
{ id: '005', area: '华南区', province: '广东省', city: '中山市' } | ||
], | ||
columns: [ | ||
{ type: 'selection', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}, | ||
radioConfig: { | ||
trigger: 'row', | ||
checkMethod({ rowIndex }) { | ||
return rowIndex % 2 === 1 | ||
} | ||
}, | ||
selectConfig: { | ||
trigger: 'row', | ||
checkMethod({ rowIndex }) { | ||
return rowIndex % 2 === 0 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.tiny-grid-select { | ||
width: 280px; | ||
} | ||
</style> |
49 changes: 49 additions & 0 deletions
49
examples/sites/demos/pc/app/grid-select/filter-composition-api.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<template> | ||
<tiny-grid-select | ||
v-model="valueSingle" | ||
filterable | ||
:filter-method="filter" | ||
value-field="id" | ||
text-field="city" | ||
:grid-op="gridOpSingle" | ||
></tiny-grid-select> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, reactive } from 'vue' | ||
import { TinyGridSelect } from '@opentiny/vue' | ||
const valueSingle = ref('') | ||
const gridOpSingle = reactive({ | ||
data: [ | ||
{ id: '001', area: '华南区', province: '广东省', city: '广州市' }, | ||
{ id: '002', area: '华南区', province: '广东省', city: '深圳市' }, | ||
{ id: '003', area: '华南区', province: '广东省', city: '珠海市' }, | ||
{ id: '004', area: '华南区', province: '广东省', city: '佛山市' }, | ||
{ id: '005', area: '华南区', province: '广东省', city: '中山市' } | ||
], | ||
columns: [ | ||
{ type: 'radio', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}) | ||
const filter = (value) => { | ||
if (!value) { | ||
return gridOpSingle.data | ||
} | ||
return gridOpSingle.data.filter((item) => { | ||
return item.city.includes(value) | ||
}) | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.tiny-grid-select { | ||
width: 280px; | ||
} | ||
</style> |
Oops, something went wrong.