aloha-vue 1.0.151 → 1.0.153
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
CHANGED
|
@@ -114,6 +114,12 @@ export default {
|
|
|
114
114
|
type: Boolean,
|
|
115
115
|
required: false,
|
|
116
116
|
},
|
|
117
|
+
maxCountMultiselect: {
|
|
118
|
+
type: Number,
|
|
119
|
+
required: false,
|
|
120
|
+
default: undefined,
|
|
121
|
+
validator: value => value > 0,
|
|
122
|
+
},
|
|
117
123
|
modelValue: {
|
|
118
124
|
type: [String, Number, Array],
|
|
119
125
|
required: false,
|
|
@@ -6,7 +6,9 @@ import {
|
|
|
6
6
|
import AKeysCode from "../../../const/AKeysCode";
|
|
7
7
|
import AKeyId from "../../const/AKeyId";
|
|
8
8
|
import {
|
|
9
|
-
cloneDeep,
|
|
9
|
+
cloneDeep,
|
|
10
|
+
get,
|
|
11
|
+
isUndefined,
|
|
10
12
|
} from "lodash-es";
|
|
11
13
|
|
|
12
14
|
export default function ASelectModelChangeAPI(props, {
|
|
@@ -17,15 +19,24 @@ export default function ASelectModelChangeAPI(props, {
|
|
|
17
19
|
dataKeyByKeyIdLocal = computed(() => ({})),
|
|
18
20
|
}) {
|
|
19
21
|
const isCloseByClick = toRef(props, "isCloseByClick");
|
|
22
|
+
const isDeselect = toRef(props, "isDeselect");
|
|
23
|
+
const maxCountMultiselect = toRef(props, "maxCountMultiselect");
|
|
24
|
+
const modelValue = toRef(props, "modelValue");
|
|
25
|
+
|
|
26
|
+
const isMaxSelected = computed(() => {
|
|
27
|
+
if (!isMultiselect.value || !maxCountMultiselect.value) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const MODEL_LENGTH = get(modelValue.value, "length");
|
|
31
|
+
return MODEL_LENGTH >= maxCountMultiselect.value;
|
|
32
|
+
});
|
|
33
|
+
|
|
20
34
|
const isCloseByClickLocal = computed(() => {
|
|
21
35
|
if (!isUndefined(isCloseByClick.value)) {
|
|
22
36
|
return isCloseByClick.value;
|
|
23
37
|
}
|
|
24
38
|
return !isMultiselect.value;
|
|
25
39
|
});
|
|
26
|
-
const isDeselect = toRef(props, "isDeselect");
|
|
27
|
-
|
|
28
|
-
const modelValue = toRef(props, "modelValue");
|
|
29
40
|
|
|
30
41
|
const onChangeModelValue = ({ currentValue, $event, isSelected }) => {
|
|
31
42
|
let modelValueLocal;
|
|
@@ -35,6 +46,9 @@ export default function ASelectModelChangeAPI(props, {
|
|
|
35
46
|
const INDEX = modelValueLocal.indexOf(currentValue);
|
|
36
47
|
modelValueLocal.splice(INDEX, 1);
|
|
37
48
|
} else {
|
|
49
|
+
if (isMaxSelected.value) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
38
52
|
modelValueLocal.push(currentValue);
|
|
39
53
|
}
|
|
40
54
|
} else {
|