yh-mobile-components 1.4.6 → 1.4.8
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/yhmInput.vue +1 -1
- package/info/yhmList.vue +49 -21
- package/package.json +1 -1
- package/types.ts +2 -0
package/form/yhmInput.vue
CHANGED
|
@@ -62,7 +62,7 @@ function changeHandler(val) {
|
|
|
62
62
|
if (props.type === "number" && props.precision && !isNaN(props.precision)) {
|
|
63
63
|
let valArr = val.split(".");
|
|
64
64
|
if (valArr[1] && valArr[1].length && valArr[1].length > props.precision) {
|
|
65
|
-
val = `${valArr[0]}.${valArr[1].substring(0, props.precision
|
|
65
|
+
val = `${valArr[0]}.${valArr[1].substring(0, props.precision)}`;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
emits("update:modelValue", val);
|
package/info/yhmList.vue
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
v-for="conf in tabsParamsConfig"
|
|
6
6
|
:valueObj="params"
|
|
7
7
|
:value="conf.value"
|
|
8
|
-
:optionData="conf.optionData"
|
|
9
|
-
@change="getList(true)"></yhm-tabs>
|
|
8
|
+
:optionData="conf.optionData"></yhm-tabs>
|
|
10
9
|
<van-search
|
|
11
10
|
v-if="hasSearch"
|
|
12
11
|
v-model="keyword"
|
|
@@ -18,8 +17,7 @@
|
|
|
18
17
|
:valueObj="params"
|
|
19
18
|
:value="conf.value"
|
|
20
19
|
:optionData="conf.optionData"
|
|
21
|
-
v-for="conf in dropdownParamsConfig"
|
|
22
|
-
@change="getList(true)"></yhm-dropdown-item>
|
|
20
|
+
v-for="conf in dropdownParamsConfig"></yhm-dropdown-item>
|
|
23
21
|
<van-dropdown-item
|
|
24
22
|
title="筛选"
|
|
25
23
|
class="custom-param-container"
|
|
@@ -41,25 +39,24 @@
|
|
|
41
39
|
finished-text="没有更多了"
|
|
42
40
|
ref="scrollContent"
|
|
43
41
|
@load="getList">
|
|
44
|
-
<template v-for="row in
|
|
42
|
+
<template v-for="row in renderCustom">
|
|
45
43
|
<yhm-info has-top>
|
|
46
|
-
<template v-for="
|
|
44
|
+
<template v-for="col in row">
|
|
45
|
+
<slot
|
|
46
|
+
v-if="col.slot"
|
|
47
|
+
:name="col.slot"
|
|
48
|
+
:row="row"></slot>
|
|
47
49
|
<yhm-info-item
|
|
48
|
-
v-
|
|
49
|
-
:label="
|
|
50
|
+
v-else
|
|
51
|
+
:label="col.label"
|
|
50
52
|
regular-value
|
|
51
|
-
:span="
|
|
52
|
-
:align="
|
|
53
|
-
:desc-align="
|
|
54
|
-
:font-size="
|
|
55
|
-
:status="
|
|
56
|
-
:description="
|
|
57
|
-
:value="
|
|
58
|
-
<slot
|
|
59
|
-
v-if="item.slot"
|
|
60
|
-
name="slot"
|
|
61
|
-
:row="row"></slot>
|
|
62
|
-
</yhm-info-item>
|
|
53
|
+
:span="col.span"
|
|
54
|
+
:align="col.align || align"
|
|
55
|
+
:desc-align="col.descAlign || descAlign"
|
|
56
|
+
:font-size="col.fontSize || fontSize"
|
|
57
|
+
:status="col.status"
|
|
58
|
+
:description="col.description"
|
|
59
|
+
:value="col.value"></yhm-info-item>
|
|
63
60
|
</template>
|
|
64
61
|
</yhm-info>
|
|
65
62
|
<yhm-info
|
|
@@ -82,7 +79,7 @@
|
|
|
82
79
|
<script setup lang="ts">
|
|
83
80
|
import type { ListConfig, ParamConfig } from "../types";
|
|
84
81
|
import type { ListInstance } from "vant";
|
|
85
|
-
import { ref, reactive, computed, onMounted, onActivated } from "vue";
|
|
82
|
+
import { ref, reactive, computed, watch, onMounted, onActivated } from "vue";
|
|
86
83
|
|
|
87
84
|
const props = withDefaults(
|
|
88
85
|
defineProps<{
|
|
@@ -190,6 +187,37 @@ async function getList(isClear = false) {
|
|
|
190
187
|
}, 500);
|
|
191
188
|
}
|
|
192
189
|
|
|
190
|
+
watch(
|
|
191
|
+
() => params,
|
|
192
|
+
() => {
|
|
193
|
+
getList(true);
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
deep: true,
|
|
197
|
+
immediate: true,
|
|
198
|
+
}
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const renderCustom = computed(() => {
|
|
202
|
+
return list.value.map((row) => {
|
|
203
|
+
return props.listConfig.items
|
|
204
|
+
.filter((item) => !item.show || (item.show && item.show(row)))
|
|
205
|
+
.map(({ label, span, align, descAlign, fontSize, status, description, defaultDescription, slot, value, defaultValue }) => {
|
|
206
|
+
return {
|
|
207
|
+
label,
|
|
208
|
+
span,
|
|
209
|
+
align,
|
|
210
|
+
descAlign: descAlign || props.descAlign,
|
|
211
|
+
fontSize: fontSize || props.fontSize,
|
|
212
|
+
status: status ? status(row) : "",
|
|
213
|
+
description: description ? row[description] || defaultDescription : "",
|
|
214
|
+
value: value ? row[value] || defaultValue : "",
|
|
215
|
+
slot,
|
|
216
|
+
};
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
|
|
193
221
|
onMounted(() => {
|
|
194
222
|
if (props.paramConfig && props.paramConfig.length) {
|
|
195
223
|
for (let i = 0; i < props.paramConfig.length; i++) {
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -40,9 +40,11 @@ export interface ListItem<T> {
|
|
|
40
40
|
label: string;
|
|
41
41
|
/** 字段值或者键,显示在右上方 */
|
|
42
42
|
value: keyof T;
|
|
43
|
+
defaultValue?: string;
|
|
43
44
|
align?: "left" | "center" | "right";
|
|
44
45
|
/** 字段描述或者键,显示在下方 */
|
|
45
46
|
description?: keyof T;
|
|
47
|
+
defaultDescription?: string;
|
|
46
48
|
descAlign?: "left" | "center" | "right";
|
|
47
49
|
fontSize?: number;
|
|
48
50
|
/** 自定义插槽,用来渲染自定义元素 */
|