This commit is contained in:
梁灏 2017-10-20 16:53:59 +08:00
parent 485a9039d5
commit 45103ca480
2 changed files with 133 additions and 29 deletions

View file

@ -84,41 +84,140 @@
<!--}--> <!--}-->
<!--</script>--> <!--</script>-->
<!--<template>-->
<!--<div style="width: 400px;margin: 50px;">-->
<!--<div>data: {{ model13 }}</div>-->
<!--<Row>-->
<!--<Col span="12" style="padding-right:10px">-->
<!--<Select-->
<!--size="small"-->
<!--placeholder="提示提示"-->
<!--v-model="model13"-->
<!--filterable-->
<!--remote-->
<!--transfer-->
<!--:remote-method="remoteMethod1"-->
<!--:loading="loading1">-->
<!--<Option v-for="(option, index) in options1" :value="option.value" :key="index">{{option.label}}</Option>-->
<!--</Select>-->
<!--</Col>-->
<!--<Col span="12">-->
<!--<Select-->
<!--v-model="model14"-->
<!--multiple-->
<!--filterable-->
<!--remote-->
<!--:remote-method="remoteMethod2"-->
<!--:loading="loading2">-->
<!--<Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option>-->
<!--</Select>-->
<!--</Col>-->
<!--</Row>-->
<!--</div>-->
<!--</template>-->
<!--<script>-->
<!--export default {-->
<!--data () {-->
<!--return {-->
<!--model13: '',-->
<!--loading1: false,-->
<!--options1: [],-->
<!--model14: [],-->
<!--loading2: false,-->
<!--options2: [],-->
<!--list: ['Alabama', 'Alaska', 'Arizona', 'Arkansas', 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New hampshire', 'New jersey', 'New mexico', 'New york', 'North carolina', 'North dakota', 'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode island', 'South carolina', 'South dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington', 'West virginia', 'Wisconsin', 'Wyoming']-->
<!--}-->
<!--},-->
<!--methods: {-->
<!--remoteMethod1 (query) {-->
<!--if (query !== '') {-->
<!--this.loading1 = true;-->
<!--setTimeout(() => {-->
<!--this.loading1 = false;-->
<!--const list = this.list.map(item => {-->
<!--return {-->
<!--value: item,-->
<!--label: item-->
<!--};-->
<!--});-->
<!--this.options1 = list.filter(item => item.label.toLowerCase().indexOf(query.toLowerCase()) > -1);-->
<!--}, 200);-->
<!--} else {-->
<!--this.options1 = [];-->
<!--}-->
<!--},-->
<!--remoteMethod2 (query) {-->
<!--if (query !== '') {-->
<!--this.loading2 = true;-->
<!--setTimeout(() => {-->
<!--this.loading2 = false;-->
<!--const list = this.list.map(item => {-->
<!--return {-->
<!--value: item,-->
<!--label: item-->
<!--};-->
<!--});-->
<!--this.options2 = list.filter(item => item.label.toLowerCase().indexOf(query.toLowerCase()) > -1);-->
<!--}, 200);-->
<!--} else {-->
<!--this.options2 = [];-->
<!--}-->
<!--}-->
<!--}-->
<!--}-->
<!--</script>-->
<template> <template>
<div style="width: 400px;margin: 50px;"> <div>
<div>data: {{ model13 }}</div> {{ model10 }}
<Row> <Select v-model="model10" multiple style="width:260px">
<Col span="12" style="padding-right:10px"> <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
<Select </Select>
size="small" ----------
placeholder="提示提示" {{ model14 }}
v-model="model13" <Select
filterable v-model="model14"
remote multiple
transfer filterable
:remote-method="remoteMethod1" remote
:loading="loading1"> :remote-method="remoteMethod2"
<Option v-for="(option, index) in options1" :value="option.value" :key="index">{{option.label}}</Option> :loading="loading2">
</Select> <Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option>
</Col> </Select>
<Col span="12"> <Button @click="clear">clear</Button>
<Select
v-model="model14"
multiple
filterable
remote
:remote-method="remoteMethod2"
:loading="loading2">
<Option v-for="(option, index) in options2" :value="option.value" :key="index">{{option.label}}</Option>
</Select>
</Col>
</Row>
</div> </div>
</template> </template>
<script> <script>
export default { export default {
data () { data () {
return { return {
cityList: [
{
value: 'beijing',
label: '北京市'
},
{
value: 'shanghai',
label: '上海市'
},
{
value: 'shenzhen',
label: '深圳市'
},
{
value: 'hangzhou',
label: '杭州市'
},
{
value: 'nanjing',
label: '南京市'
},
{
value: 'chongqing',
label: '重庆市'
}
],
model10: [],
model13: '', model13: '',
loading1: false, loading1: false,
options1: [], options1: [],
@ -162,6 +261,9 @@
} else { } else {
this.options2 = []; this.options2 = [];
} }
},
clear () {
this.model14 = [];
} }
} }
} }

View file

@ -369,6 +369,7 @@
const selectedArray = []; const selectedArray = [];
const selectedObject = {}; const selectedObject = {};
selected.forEach(item => { selected.forEach(item => {
if (!selectedObject[item.value]) { if (!selectedObject[item.value]) {
selectedArray.push(item); selectedArray.push(item);
@ -376,7 +377,8 @@
} }
}); });
this.selectedMultiple = this.remote ? selectedArray : selected; // #2066
this.selectedMultiple = this.remote ? this.model.length ? selectedArray : [] : selected;
if (slot) { if (slot) {
let selectedModel = []; let selectedModel = [];