yh-mobile-components 1.4.11 → 1.4.13
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/form/yhmMultipleSelect.vue +116 -0
- package/info/yhmList.vue +11 -1
- package/package.json +2 -2
- /package/{README.md → readme.md} +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<van-field
|
|
3
|
+
v-model="result"
|
|
4
|
+
is-link
|
|
5
|
+
readonly
|
|
6
|
+
name="picker"
|
|
7
|
+
:label="label"
|
|
8
|
+
:placeholder="placeholder"
|
|
9
|
+
@click="showPicker = true" />
|
|
10
|
+
<van-popup
|
|
11
|
+
v-model:show="showPicker"
|
|
12
|
+
:close-on-click-overlay="closeonclickoverlay"
|
|
13
|
+
:position="position">
|
|
14
|
+
<van-cell-group>
|
|
15
|
+
<van-cell>
|
|
16
|
+
<van-button
|
|
17
|
+
type="primary"
|
|
18
|
+
@click="cancelCheck"
|
|
19
|
+
style="width: 20%; float: left; border-radius: 10px">
|
|
20
|
+
取消
|
|
21
|
+
</van-button>
|
|
22
|
+
<van-button
|
|
23
|
+
type="primary"
|
|
24
|
+
@click="finishCheck"
|
|
25
|
+
style="width: 20%; float: right; border-radius: 10px">
|
|
26
|
+
确定
|
|
27
|
+
</van-button>
|
|
28
|
+
</van-cell>
|
|
29
|
+
<van-cell>
|
|
30
|
+
<van-checkbox
|
|
31
|
+
v-model="isCheckAll"
|
|
32
|
+
:indeterminate="isIndeterminate"
|
|
33
|
+
@change="checkAllChange">
|
|
34
|
+
全选
|
|
35
|
+
</van-checkbox>
|
|
36
|
+
</van-cell>
|
|
37
|
+
<van-checkbox-group
|
|
38
|
+
ref="checkboxGroup"
|
|
39
|
+
v-model="checkedResult"
|
|
40
|
+
@change="checkedResultChange"
|
|
41
|
+
direction="vertical">
|
|
42
|
+
<van-cell-group>
|
|
43
|
+
<van-cell v-for="item in columns">
|
|
44
|
+
<van-checkbox :name="item.value">
|
|
45
|
+
{{ item.text }}
|
|
46
|
+
</van-checkbox>
|
|
47
|
+
</van-cell>
|
|
48
|
+
</van-cell-group>
|
|
49
|
+
</van-checkbox-group>
|
|
50
|
+
</van-cell-group>
|
|
51
|
+
</van-popup>
|
|
52
|
+
</template>
|
|
53
|
+
<script lang="ts" setup>
|
|
54
|
+
import { ref } from "vue";
|
|
55
|
+
import type { CheckboxGroupInstance } from "vant";
|
|
56
|
+
|
|
57
|
+
// props: ["label", "placeholder", "position", "resullt", "columns"];
|
|
58
|
+
|
|
59
|
+
interface ListItem {
|
|
60
|
+
value: string | number;
|
|
61
|
+
text: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const props = withDefaults(
|
|
65
|
+
defineProps<{
|
|
66
|
+
label?: string;
|
|
67
|
+
placeholder?: string;
|
|
68
|
+
position?: string;
|
|
69
|
+
columns?: Array<ListItem>;
|
|
70
|
+
closeonclickoverlay?: boolean;
|
|
71
|
+
}>(),
|
|
72
|
+
{
|
|
73
|
+
label: "",
|
|
74
|
+
placeholder: "请选择",
|
|
75
|
+
position: "",
|
|
76
|
+
columns: () => [] as ListItem[],
|
|
77
|
+
closeonclickoverlay: false,
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const emits = defineEmits<{
|
|
82
|
+
(e: "update:modelValue", val: object);
|
|
83
|
+
}>();
|
|
84
|
+
|
|
85
|
+
const position = ref("bottom");
|
|
86
|
+
const result = ref("");
|
|
87
|
+
const showPicker = ref(false);
|
|
88
|
+
const checkedResult = ref([]);
|
|
89
|
+
const isCheckAll = ref(false);
|
|
90
|
+
const isIndeterminate = ref(false);
|
|
91
|
+
const checkboxGroup = ref<CheckboxGroupInstance>();
|
|
92
|
+
|
|
93
|
+
function checkAllChange(val: boolean) {
|
|
94
|
+
if (val) {
|
|
95
|
+
checkboxGroup.value?.toggleAll(true);
|
|
96
|
+
} else {
|
|
97
|
+
checkboxGroup.value?.toggleAll();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function checkedResultChange(value: string[]) {
|
|
102
|
+
const checkedCount = value.length;
|
|
103
|
+
isCheckAll.value = checkedCount == props.columns.length;
|
|
104
|
+
isIndeterminate.value = checkedCount > 0 && checkedCount < props.columns.length;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function cancelCheck() {
|
|
108
|
+
checkboxGroup.value?.toggleAll();
|
|
109
|
+
showPicker.value = false;
|
|
110
|
+
}
|
|
111
|
+
function finishCheck() {
|
|
112
|
+
emits("update:modelValue", checkedResult.value);
|
|
113
|
+
result.value = checkedResult.value.join("、");
|
|
114
|
+
showPicker.value = false;
|
|
115
|
+
}
|
|
116
|
+
</script>
|
package/info/yhmList.vue
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
v-if="hasSearch"
|
|
11
11
|
v-model="keyword"
|
|
12
12
|
:placeholder="searchPlaceholder"
|
|
13
|
-
@update:model-value="
|
|
13
|
+
@update:model-value="onSearch('update')"
|
|
14
|
+
@search="onSearch('search')"
|
|
14
15
|
:clearable="false"></van-search>
|
|
15
16
|
<van-dropdown-menu v-if="(dropdownParamsConfig && dropdownParamsConfig.length) || (customParamsConfig && customParamsConfig.length)">
|
|
16
17
|
<yhm-dropdown-item
|
|
@@ -85,6 +86,8 @@ const props = withDefaults(
|
|
|
85
86
|
defineProps<{
|
|
86
87
|
/** 是否有关键字筛选 */
|
|
87
88
|
hasSearch?: boolean;
|
|
89
|
+
/** 筛选搜索触发类型 默认 update当输入框内容发生变化时触发 search点击键盘上的搜索/回车按钮后触发 */
|
|
90
|
+
searchType?: string;
|
|
88
91
|
/** 关键字筛选提示语 */
|
|
89
92
|
searchPlaceholder?: string;
|
|
90
93
|
paramType?: "dropdown" | "tabs";
|
|
@@ -107,6 +110,7 @@ const props = withDefaults(
|
|
|
107
110
|
}>(),
|
|
108
111
|
{
|
|
109
112
|
hasSearch: false,
|
|
113
|
+
searchType: "update",
|
|
110
114
|
searchPlaceholder: "输入关键词搜索",
|
|
111
115
|
align: "right",
|
|
112
116
|
descAlign: "left",
|
|
@@ -193,6 +197,12 @@ async function getList(isClear = false) {
|
|
|
193
197
|
}, 500);
|
|
194
198
|
}
|
|
195
199
|
|
|
200
|
+
function onSearch(type) {
|
|
201
|
+
if (props.searchType == type) {
|
|
202
|
+
getList(true);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
196
206
|
watch(
|
|
197
207
|
() => params,
|
|
198
208
|
() => {
|
package/package.json
CHANGED
/package/{README.md → readme.md}
RENAMED
|
File without changes
|