-
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): add remote feature (#2530)
- Loading branch information
Showing
10 changed files
with
250 additions
and
28 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
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
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
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/remote-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" | ||
:grid-op="gridOpSingle" | ||
filterable | ||
remote | ||
:remote-method="remoteMethod" | ||
></tiny-grid-select> | ||
<br /><br /> | ||
<p>场景2:多选</p> | ||
<br /> | ||
<tiny-grid-select | ||
v-model="valueMultiple" | ||
:grid-op="gridOpMultiple" | ||
multiple | ||
filterable | ||
remote | ||
:remote-method="remoteMethod" | ||
></tiny-grid-select> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, reactive } from 'vue' | ||
import { TinyGridSelect } from '@opentiny/vue' | ||
const valueSingle = ref('') | ||
const valueMultiple = ref([]) | ||
const gridOpSingle = reactive({ | ||
data: [], | ||
height: 300, | ||
columns: [ | ||
{ type: 'radio', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}) | ||
const gridOpMultiple = reactive({ | ||
data: [], | ||
height: 300, | ||
columns: [ | ||
{ type: 'selection', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}) | ||
const allData = Array.from({ length: 1000 }, (a, i) => { | ||
return { | ||
value: '00' + i, | ||
province: '省份' + i, | ||
city: '城市' + i, | ||
area: '区域' + i, | ||
label: `省${i}-市${i}` | ||
} | ||
}) | ||
const filter = (value) => { | ||
return allData.filter((item) => item.city.includes(value)) | ||
} | ||
const remoteMethod = (value) => { | ||
const filterData = filter(value) | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(filterData) | ||
}, 500) | ||
}) | ||
} | ||
</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,89 @@ | ||
<template> | ||
<div> | ||
<p>场景1:单选</p> | ||
<br /> | ||
<tiny-grid-select | ||
v-model="valueSingle" | ||
:grid-op="gridOpSingle" | ||
filterable | ||
remote | ||
:remote-method="remoteMethod" | ||
></tiny-grid-select> | ||
<br /><br /> | ||
<p>场景2:多选</p> | ||
<br /> | ||
<tiny-grid-select | ||
v-model="valueMultiple" | ||
:grid-op="gridOpMultiple" | ||
multiple | ||
filterable | ||
remote | ||
:remote-method="remoteMethod" | ||
></tiny-grid-select> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { TinyGridSelect } from '@opentiny/vue' | ||
export default { | ||
components: { | ||
TinyGridSelect | ||
}, | ||
data() { | ||
return { | ||
valueSingle: '', | ||
valueMultiple: [], | ||
gridOpSingle: { | ||
data: [], | ||
height: 300, | ||
columns: [ | ||
{ type: 'radio', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}, | ||
gridOpMultiple: { | ||
data: [], | ||
height: 300, | ||
columns: [ | ||
{ type: 'selection', title: '' }, | ||
{ field: 'area', title: '区域', width: 90 }, | ||
{ field: 'province', title: '省份', width: 60 }, | ||
{ field: 'city', title: '城市', width: 60 } | ||
] | ||
}, | ||
allData: Array.from({ length: 1000 }, (a, i) => { | ||
return { | ||
value: '00' + i, | ||
province: '省份' + i, | ||
city: '城市' + i, | ||
area: '区域' + i, | ||
label: `省${i}-市${i}` | ||
} | ||
}) | ||
} | ||
}, | ||
methods: { | ||
filter(value) { | ||
return this.allData.filter((item) => item.city.includes(value)) | ||
}, | ||
remoteMethod(value) { | ||
const filterData = this.filter(value) | ||
return new Promise((resolve) => { | ||
setTimeout(() => { | ||
resolve(filterData) | ||
}, 500) | ||
}) | ||
} | ||
} | ||
} | ||
</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
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
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
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