yh-mobile-components 1.4.10 → 1.4.12
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 +18 -3
- 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
|
|
@@ -79,12 +80,14 @@
|
|
|
79
80
|
<script setup lang="ts">
|
|
80
81
|
import type { ListConfig, ParamConfig } from "../types";
|
|
81
82
|
import type { ListInstance } from "vant";
|
|
82
|
-
import { ref, reactive, computed, watch, onMounted, onActivated } from "vue";
|
|
83
|
+
import { ref, reactive, computed, watch, onMounted, onActivated, nextTick } from "vue";
|
|
83
84
|
|
|
84
85
|
const props = withDefaults(
|
|
85
86
|
defineProps<{
|
|
86
87
|
/** 是否有关键字筛选 */
|
|
87
88
|
hasSearch?: boolean;
|
|
89
|
+
/** 筛选搜索触发类型 默认 update当输入框内容发生变化时触发 search点击键盘上的搜索/回车按钮后触发 */
|
|
90
|
+
searchType?: "update";
|
|
88
91
|
/** 关键字筛选提示语 */
|
|
89
92
|
searchPlaceholder?: string;
|
|
90
93
|
paramType?: "dropdown" | "tabs";
|
|
@@ -115,6 +118,12 @@ const props = withDefaults(
|
|
|
115
118
|
|
|
116
119
|
const scrollContent = ref<ListInstance>();
|
|
117
120
|
const keyword = ref("");
|
|
121
|
+
function setKeyowrd(k) {
|
|
122
|
+
keyword.value = k;
|
|
123
|
+
nextTick(() => {
|
|
124
|
+
getList(true);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
118
127
|
const params = reactive({});
|
|
119
128
|
const list = ref<any[]>([]);
|
|
120
129
|
const listLoading = ref(false);
|
|
@@ -187,6 +196,12 @@ async function getList(isClear = false) {
|
|
|
187
196
|
}, 500);
|
|
188
197
|
}
|
|
189
198
|
|
|
199
|
+
function onSearch(type) {
|
|
200
|
+
if (props.searchType == type) {
|
|
201
|
+
getList(true);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
190
205
|
watch(
|
|
191
206
|
() => params,
|
|
192
207
|
() => {
|
|
@@ -236,7 +251,7 @@ onActivated(() => {});
|
|
|
236
251
|
|
|
237
252
|
defineExpose({
|
|
238
253
|
getList,
|
|
239
|
-
|
|
254
|
+
setKeyowrd,
|
|
240
255
|
});
|
|
241
256
|
</script>
|
|
242
257
|
<style lang="scss">
|
package/package.json
CHANGED
/package/{README.md → readme.md}
RENAMED
|
File without changes
|