|
@@ -1,32 +1,41 @@
|
|
<template>
|
|
<template>
|
|
<div>
|
|
<div>
|
|
<label class="v-label theme--light" v-html="label"></label>
|
|
<label class="v-label theme--light" v-html="label"></label>
|
|
- <v-card v-if='internalSelectedItems.length > 0'>
|
|
|
|
|
|
+ <v-card v-if="internalSelectedItems.length > 0">
|
|
<v-list>
|
|
<v-list>
|
|
<vx-draggable
|
|
<vx-draggable
|
|
- v-model='internalSelectedItems'
|
|
|
|
- animation='300'
|
|
|
|
|
|
+ v-model="internalSelectedItems"
|
|
|
|
+ animation="300"
|
|
handle=".handle"
|
|
handle=".handle"
|
|
- @change="changeOrder">
|
|
|
|
- <div v-for='(item, index) in internalSelectedItems' :key='item.id'>
|
|
|
|
|
|
+ @change="changeOrder"
|
|
|
|
+ >
|
|
|
|
+ <div
|
|
|
|
+ v-for="(item, index) in internalSelectedItems"
|
|
|
|
+ :key="item.id"
|
|
|
|
+ >
|
|
<v-list-item>
|
|
<v-list-item>
|
|
<v-list-item-avatar tile>
|
|
<v-list-item-avatar tile>
|
|
<v-img :src="item[itemImage]"></v-img>
|
|
<v-img :src="item[itemImage]"></v-img>
|
|
</v-list-item-avatar>
|
|
</v-list-item-avatar>
|
|
<v-list-item-content>
|
|
<v-list-item-content>
|
|
- <v-list-item-title>{{ item[itemText] }}
|
|
|
|
|
|
+ <v-list-item-title
|
|
|
|
+ >{{ item[itemText] }}
|
|
</v-list-item-title>
|
|
</v-list-item-title>
|
|
</v-list-item-content>
|
|
</v-list-item-content>
|
|
<v-list-item-icon>
|
|
<v-list-item-icon>
|
|
- <v-btn :icon="true" @click="removeItem(item[itemValue])">
|
|
|
|
|
|
+ <v-btn
|
|
|
|
+ :icon="true"
|
|
|
|
+ @click="removeItem(item[itemValue])"
|
|
|
|
+ >
|
|
<v-icon>delete</v-icon>
|
|
<v-icon>delete</v-icon>
|
|
</v-btn>
|
|
</v-btn>
|
|
<v-icon class="handle">reorder</v-icon>
|
|
<v-icon class="handle">reorder</v-icon>
|
|
</v-list-item-icon>
|
|
</v-list-item-icon>
|
|
</v-list-item>
|
|
</v-list-item>
|
|
<v-divider
|
|
<v-divider
|
|
- v-if='index < internalSelectedItems.length - 1'
|
|
|
|
- :key='index'></v-divider>
|
|
|
|
|
|
+ v-if="index < internalSelectedItems.length - 1"
|
|
|
|
+ :key="index"
|
|
|
|
+ ></v-divider>
|
|
</div>
|
|
</div>
|
|
</vx-draggable>
|
|
</vx-draggable>
|
|
</v-list>
|
|
</v-list>
|
|
@@ -49,11 +58,12 @@
|
|
<template v-slot:item="data">
|
|
<template v-slot:item="data">
|
|
<template>
|
|
<template>
|
|
<v-list-item-avatar tile>
|
|
<v-list-item-avatar tile>
|
|
- <img :src="data.item[itemImage]">
|
|
|
|
|
|
+ <img :src="data.item[itemImage]" />
|
|
</v-list-item-avatar>
|
|
</v-list-item-avatar>
|
|
<v-list-item-content>
|
|
<v-list-item-content>
|
|
<v-list-item-title
|
|
<v-list-item-title
|
|
- v-html="data.item[itemText]"></v-list-item-title>
|
|
|
|
|
|
+ v-html="data.item[itemText]"
|
|
|
|
+ ></v-list-item-title>
|
|
</v-list-item-content>
|
|
</v-list-item-content>
|
|
</template>
|
|
</template>
|
|
</template>
|
|
</template>
|
|
@@ -63,7 +73,7 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
export default {
|
|
export default {
|
|
- name: 'vx-selectmany',
|
|
|
|
|
|
+ name: "vx-selectmany",
|
|
props: {
|
|
props: {
|
|
items: {
|
|
items: {
|
|
type: Array,
|
|
type: Array,
|
|
@@ -78,23 +88,23 @@ export default {
|
|
},
|
|
},
|
|
itemValue: {
|
|
itemValue: {
|
|
type: String,
|
|
type: String,
|
|
- default: 'id',
|
|
|
|
|
|
+ default: "id",
|
|
},
|
|
},
|
|
itemText: {
|
|
itemText: {
|
|
type: String,
|
|
type: String,
|
|
- default: 'text',
|
|
|
|
|
|
+ default: "text",
|
|
},
|
|
},
|
|
itemImage: {
|
|
itemImage: {
|
|
type: String,
|
|
type: String,
|
|
- default: 'image',
|
|
|
|
|
|
+ default: "image",
|
|
},
|
|
},
|
|
label: {
|
|
label: {
|
|
type: String,
|
|
type: String,
|
|
- default: '',
|
|
|
|
|
|
+ default: "",
|
|
},
|
|
},
|
|
addItemLabel: {
|
|
addItemLabel: {
|
|
type: String,
|
|
type: String,
|
|
- default: '',
|
|
|
|
|
|
+ default: "",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
@@ -102,7 +112,7 @@ export default {
|
|
internalSelectedItems: [],
|
|
internalSelectedItems: [],
|
|
internalItems: [],
|
|
internalItems: [],
|
|
autocompleteValue: [],
|
|
autocompleteValue: [],
|
|
- searchKeyword: '',
|
|
|
|
|
|
+ searchKeyword: "",
|
|
isLoading: false,
|
|
isLoading: false,
|
|
noFilter: false,
|
|
noFilter: false,
|
|
};
|
|
};
|
|
@@ -124,22 +134,30 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.isLoading = true;
|
|
this.isLoading = true;
|
|
- this.searchItemsFunc(val).then(r => {
|
|
|
|
- this.internalItems = r.data || [];
|
|
|
|
- }).finally(() => {
|
|
|
|
- this.isLoading = false;
|
|
|
|
- });
|
|
|
|
|
|
+ this.searchItemsFunc(val)
|
|
|
|
+ .then((r) => {
|
|
|
|
+ this.internalItems = r.data || [];
|
|
|
|
+ })
|
|
|
|
+ .finally(() => {
|
|
|
|
+ this.isLoading = false;
|
|
|
|
+ });
|
|
},
|
|
},
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
addItem(event) {
|
|
addItem(event) {
|
|
this.autocompleteValue = [];
|
|
this.autocompleteValue = [];
|
|
- if (this.internalSelectedItems.find(
|
|
|
|
- element => element[this.itemValue] == event)) {
|
|
|
|
|
|
+ if (
|
|
|
|
+ this.internalSelectedItems.find(
|
|
|
|
+ (element) => element[this.itemValue] == event
|
|
|
|
+ )
|
|
|
|
+ ) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.internalSelectedItems.push(
|
|
this.internalSelectedItems.push(
|
|
- this.internalItems.find(element => element[this.itemValue] == event));
|
|
|
|
|
|
+ this.internalItems.find(
|
|
|
|
+ (element) => element[this.itemValue] == event
|
|
|
|
+ )
|
|
|
|
+ );
|
|
this.setValue();
|
|
this.setValue();
|
|
},
|
|
},
|
|
changeOrder(event) {
|
|
changeOrder(event) {
|
|
@@ -147,7 +165,8 @@ export default {
|
|
},
|
|
},
|
|
removeItem(id) {
|
|
removeItem(id) {
|
|
this.internalSelectedItems = this.internalSelectedItems.filter(
|
|
this.internalSelectedItems = this.internalSelectedItems.filter(
|
|
- element => element[this.itemValue] != id);
|
|
|
|
|
|
+ (element) => element[this.itemValue] != id
|
|
|
|
+ );
|
|
this.setValue();
|
|
this.setValue();
|
|
},
|
|
},
|
|
search(val) {
|
|
search(val) {
|
|
@@ -157,12 +176,15 @@ export default {
|
|
this.searchKeyword = val;
|
|
this.searchKeyword = val;
|
|
},
|
|
},
|
|
focus() {
|
|
focus() {
|
|
- this.search('');
|
|
|
|
|
|
+ this.search("");
|
|
},
|
|
},
|
|
setValue() {
|
|
setValue() {
|
|
- this.$emit('input', this.internalSelectedItems.map((i) => {
|
|
|
|
- return i[this.itemValue];
|
|
|
|
- }));
|
|
|
|
|
|
+ this.$emit(
|
|
|
|
+ "input",
|
|
|
|
+ this.internalSelectedItems.map((i) => {
|
|
|
|
+ return i[this.itemValue];
|
|
|
|
+ })
|
|
|
|
+ );
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
};
|
|
@@ -174,3 +196,9 @@ export default {
|
|
cursor: move;
|
|
cursor: move;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|
|
|
|
+
|
|
|
|
+<style>
|
|
|
|
+.v-autocomplete-sorting .v-label--active {
|
|
|
|
+ transform: none;
|
|
|
|
+}
|
|
|
|
+</style>
|