@xilonglab/vue-main 1.6.9 → 1.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/form/XlTags.vue +11 -22
package/package.json
CHANGED
package/packages/form/XlTags.vue
CHANGED
|
@@ -8,8 +8,8 @@ const emits = defineEmits(['change', 'update:modelValue'])
|
|
|
8
8
|
|
|
9
9
|
const props = defineProps({
|
|
10
10
|
modelValue: {
|
|
11
|
-
type:
|
|
12
|
-
default:
|
|
11
|
+
type: Array,
|
|
12
|
+
default: () => []
|
|
13
13
|
},
|
|
14
14
|
editable: {
|
|
15
15
|
type: Boolean,
|
|
@@ -25,20 +25,10 @@ const props = defineProps({
|
|
|
25
25
|
}
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return props.modelValue.split(',');
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return []
|
|
36
|
-
},
|
|
37
|
-
set(data) {
|
|
38
|
-
emits('change', data.join(','))
|
|
39
|
-
emits('update:modelValue', data.join(','))
|
|
40
|
-
},
|
|
41
|
-
});
|
|
28
|
+
function updateValue(data) {
|
|
29
|
+
emits('change', data)
|
|
30
|
+
emits('update:modelValue', data)
|
|
31
|
+
}
|
|
42
32
|
|
|
43
33
|
const valueMap = computed(() => {
|
|
44
34
|
let tmp = {};
|
|
@@ -52,16 +42,15 @@ const newTag = ref('')
|
|
|
52
42
|
|
|
53
43
|
const handlers = {
|
|
54
44
|
add() {
|
|
55
|
-
const temp =
|
|
45
|
+
const temp = Array.isArray(props.modelValue) ? props.modelValue.slice() : []
|
|
56
46
|
temp.push(newTag.value);
|
|
57
|
-
|
|
47
|
+
updateValue(temp)
|
|
58
48
|
newTag.value = ''
|
|
59
49
|
},
|
|
60
50
|
remove(index) {
|
|
61
|
-
|
|
62
|
-
const temp = tags.value.slice()
|
|
51
|
+
const temp = Array.isArray(props.modelValue) ? props.modelValue.slice() : []
|
|
63
52
|
temp.splice(index, 1);
|
|
64
|
-
|
|
53
|
+
updateValue(temp)
|
|
65
54
|
}
|
|
66
55
|
}
|
|
67
56
|
</script>
|
|
@@ -69,7 +58,7 @@ const handlers = {
|
|
|
69
58
|
|
|
70
59
|
<template>
|
|
71
60
|
<div class="xl-tags">
|
|
72
|
-
<el-tag v-for="(tag, index) in
|
|
61
|
+
<el-tag v-for="(tag, index) in modelValue" :key="tag" :closable="editable" @close="handlers.remove(index)">
|
|
73
62
|
{{ type == 'select' ? valueMap[tag] : tag }}
|
|
74
63
|
</el-tag>
|
|
75
64
|
<xl-input v-if="editable && type == 'input'" class="new-tag" v-model="newTag" />
|