yh-mobile-components 1.2.2 → 1.3.1
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/info/yhmInfoItem.vue +17 -7
- package/info/yhmList.vue +36 -19
- package/package.json +1 -1
- package/types.ts +8 -1
package/info/yhmInfoItem.vue
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
</section>
|
|
17
17
|
</template>
|
|
18
18
|
<script setup lang="ts">
|
|
19
|
-
import { computed
|
|
19
|
+
import { computed } from "vue";
|
|
20
20
|
const props = withDefaults(
|
|
21
21
|
defineProps<{
|
|
22
22
|
span: number;
|
|
@@ -24,13 +24,23 @@ const props = withDefaults(
|
|
|
24
24
|
value?: string;
|
|
25
25
|
description?: string;
|
|
26
26
|
regularValue?: boolean;
|
|
27
|
+
fontSize?: number;
|
|
28
|
+
align?: "left" | "center" | "right";
|
|
29
|
+
descAlign?: "left" | "center" | "right";
|
|
27
30
|
status?: "primary" | "success" | "danger" | "warning" | "cyan" | "purple" | "yellow" | "pink";
|
|
28
31
|
}>(),
|
|
29
32
|
{
|
|
30
33
|
span: 24,
|
|
34
|
+
fontSize: 14,
|
|
35
|
+
align: "right",
|
|
36
|
+
descAlign: "left",
|
|
31
37
|
}
|
|
32
38
|
);
|
|
33
39
|
|
|
40
|
+
const fontSize = computed(() => {
|
|
41
|
+
return `${props.fontSize}px`;
|
|
42
|
+
});
|
|
43
|
+
|
|
34
44
|
const widthCount = computed(() => {
|
|
35
45
|
return 24 / props.span;
|
|
36
46
|
});
|
|
@@ -38,22 +48,21 @@ const widthCount = computed(() => {
|
|
|
38
48
|
<style lang="scss">
|
|
39
49
|
.yhm-info-item-container {
|
|
40
50
|
width: calc((100% - (8px * v-bind(widthCount))) / v-bind(widthCount));
|
|
41
|
-
font-size:
|
|
51
|
+
font-size: v-bind(fontSize);
|
|
42
52
|
padding: 4px 0;
|
|
43
53
|
margin-right: 8px;
|
|
44
54
|
.yhm-info-item {
|
|
45
55
|
display: flex;
|
|
46
56
|
padding: 4px 0;
|
|
47
|
-
line-height:
|
|
57
|
+
line-height: 1.3em;
|
|
48
58
|
.yhm-info-item-value {
|
|
49
59
|
flex: 1;
|
|
50
|
-
text-align: right;
|
|
51
60
|
color: var(--van-text-color-2);
|
|
61
|
+
text-align: v-bind("$props.align");
|
|
62
|
+
padding-left: 5px;
|
|
52
63
|
}
|
|
53
64
|
&.regular-value {
|
|
54
65
|
.yhm-info-item-value {
|
|
55
|
-
flex: 1;
|
|
56
|
-
text-align: right;
|
|
57
66
|
color: var(--van-text-color);
|
|
58
67
|
}
|
|
59
68
|
}
|
|
@@ -61,7 +70,8 @@ const widthCount = computed(() => {
|
|
|
61
70
|
.yhm-info-description {
|
|
62
71
|
color: var(--van-text-color-2);
|
|
63
72
|
padding: 2px 0;
|
|
64
|
-
line-height:
|
|
73
|
+
line-height: 1.3em;
|
|
74
|
+
text-align: v-bind("$props.descAlign");
|
|
65
75
|
}
|
|
66
76
|
&.primary {
|
|
67
77
|
.yhm-info-item {
|
package/info/yhmList.vue
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<section class="yhm-list-container">
|
|
3
3
|
<section class="list-condition-container">
|
|
4
|
+
<yhm-tabs
|
|
5
|
+
v-for="conf in tabsParamsConfig"
|
|
6
|
+
:valueObj="params"
|
|
7
|
+
:value="conf.value"
|
|
8
|
+
:optionData="conf.optionData"
|
|
9
|
+
@change="getList(true)"></yhm-tabs>
|
|
4
10
|
<van-search
|
|
5
11
|
v-if="hasSearch"
|
|
6
12
|
v-model="keyword"
|
|
7
13
|
:placeholder="searchPlaceholder"
|
|
8
14
|
@update:model-value="getList(true)"
|
|
9
15
|
:clearable="false"></van-search>
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
<yhm-dropdown-item
|
|
13
|
-
:valueObj="params"
|
|
14
|
-
:value="conf.value"
|
|
15
|
-
:optionData="conf.optionData"
|
|
16
|
-
v-for="conf in paramConfig"
|
|
17
|
-
@change="getList(true)"></yhm-dropdown-item>
|
|
18
|
-
</van-dropdown-menu>
|
|
19
|
-
<yhm-tabs
|
|
20
|
-
v-else
|
|
16
|
+
<van-dropdown-menu v-if="dropdownParamsConfig && dropdownParamsConfig.length">
|
|
17
|
+
<yhm-dropdown-item
|
|
21
18
|
:valueObj="params"
|
|
22
19
|
:value="conf.value"
|
|
23
20
|
:optionData="conf.optionData"
|
|
24
|
-
v-for="conf in
|
|
25
|
-
@change="getList(true)"></yhm-
|
|
26
|
-
</
|
|
21
|
+
v-for="conf in dropdownParamsConfig"
|
|
22
|
+
@change="getList(true)"></yhm-dropdown-item>
|
|
23
|
+
</van-dropdown-menu>
|
|
27
24
|
</section>
|
|
28
25
|
<van-pull-refresh
|
|
29
26
|
v-model="refreshing"
|
|
@@ -36,13 +33,17 @@
|
|
|
36
33
|
finished-text="没有更多了"
|
|
37
34
|
ref="scrollContent"
|
|
38
35
|
@load="getList">
|
|
39
|
-
<template v-for="
|
|
36
|
+
<template v-for="row in list">
|
|
40
37
|
<yhm-info has-top>
|
|
41
38
|
<template v-for="item in listConfig?.items">
|
|
42
39
|
<yhm-info-item
|
|
43
40
|
v-if="!item.show || (item.show && item.show(row))"
|
|
44
41
|
:label="item.label"
|
|
42
|
+
regular-value
|
|
45
43
|
:span="item.span"
|
|
44
|
+
:align="item.align || align"
|
|
45
|
+
:desc-align="item.descAlign || descAlign"
|
|
46
|
+
:font-size="item.fontSize || fontSize"
|
|
46
47
|
:status="item.status && item.status(row)"
|
|
47
48
|
:description="row[item.description] || item.description"
|
|
48
49
|
:value="row[item.value] || item.value">
|
|
@@ -53,7 +54,9 @@
|
|
|
53
54
|
</yhm-info-item>
|
|
54
55
|
</template>
|
|
55
56
|
</yhm-info>
|
|
56
|
-
<yhm-info
|
|
57
|
+
<yhm-info
|
|
58
|
+
class="yhm-list-item-actions"
|
|
59
|
+
v-if="listConfig.btns && listConfig.btns.length > 0">
|
|
57
60
|
<template v-for="btn in listConfig.btns">
|
|
58
61
|
<div
|
|
59
62
|
v-if="!btn.show || (btn.show && btn.show(row))"
|
|
@@ -72,9 +75,6 @@
|
|
|
72
75
|
import type { ListConfig, ParamConfig } from "../types";
|
|
73
76
|
import type { ListInstance } from "vant";
|
|
74
77
|
import { ref, reactive, computed, onMounted, onActivated } from "vue";
|
|
75
|
-
import { useRouter } from "vue-router";
|
|
76
|
-
|
|
77
|
-
const router = useRouter();
|
|
78
78
|
|
|
79
79
|
const props = withDefaults(
|
|
80
80
|
defineProps<{
|
|
@@ -83,6 +83,9 @@ const props = withDefaults(
|
|
|
83
83
|
/** 关键字筛选提示语 */
|
|
84
84
|
searchPlaceholder?: string;
|
|
85
85
|
paramType?: "dropdown" | "tabs";
|
|
86
|
+
align?: "left" | "center" | "right";
|
|
87
|
+
descAlign?: "left" | "center" | "right";
|
|
88
|
+
fontSize?: number;
|
|
86
89
|
/** 下拉筛选条件配置 */
|
|
87
90
|
paramConfig?: ParamConfig[];
|
|
88
91
|
/** 列表项目筛选 */
|
|
@@ -100,6 +103,8 @@ const props = withDefaults(
|
|
|
100
103
|
{
|
|
101
104
|
hasSearch: false,
|
|
102
105
|
searchPlaceholder: "输入关键词搜索",
|
|
106
|
+
align: "right",
|
|
107
|
+
descAlign: "left",
|
|
103
108
|
}
|
|
104
109
|
);
|
|
105
110
|
|
|
@@ -114,6 +119,18 @@ const pageSize = ref(15);
|
|
|
114
119
|
const refreshing = ref(false);
|
|
115
120
|
const finished = ref(false);
|
|
116
121
|
|
|
122
|
+
const tabsParamsConfig = computed(() => {
|
|
123
|
+
return props.paramConfig?.filter((config) => {
|
|
124
|
+
return config.type === "tabs";
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const dropdownParamsConfig = computed(() => {
|
|
129
|
+
return props.paramConfig?.filter((config) => {
|
|
130
|
+
return config.type === "dropdown";
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
117
134
|
let timer: number | null = null;
|
|
118
135
|
async function getList(isClear = false) {
|
|
119
136
|
if (timer) {
|
package/package.json
CHANGED
package/types.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type SizeType = "mini" | "medium" | "lager";
|
|
|
7
7
|
/** 下拉参数配置 */
|
|
8
8
|
export interface ParamConfig {
|
|
9
9
|
optionData?: vanOption[];
|
|
10
|
+
type?: "tabs" | "dropdown";
|
|
10
11
|
value: string;
|
|
11
12
|
defaultValue: any;
|
|
12
13
|
}
|
|
@@ -38,8 +39,11 @@ export interface ListItem<T> {
|
|
|
38
39
|
label: string;
|
|
39
40
|
/** 字段值或者键,显示在右上方 */
|
|
40
41
|
value: keyof T;
|
|
42
|
+
align?: "left" | "center" | "right";
|
|
41
43
|
/** 字段描述或者键,显示在下方 */
|
|
42
|
-
description
|
|
44
|
+
description?: keyof T;
|
|
45
|
+
descAlign?: "left" | "center" | "right";
|
|
46
|
+
fontSize?: number;
|
|
43
47
|
/** 自定义插槽,用来渲染自定义元素 */
|
|
44
48
|
slot?: string;
|
|
45
49
|
/** 值的样式,自定义不同的颜色
|
|
@@ -64,6 +68,9 @@ export interface ListConfigObject<T> {
|
|
|
64
68
|
hasSearch: boolean;
|
|
65
69
|
searchPlaceholder: string;
|
|
66
70
|
paramType?: "dropdown" | "tabs";
|
|
71
|
+
align?: "left" | "center" | "right";
|
|
72
|
+
descAlign?: "left" | "center" | "right";
|
|
73
|
+
fontSize: number;
|
|
67
74
|
paramConfig: ParamConfig[];
|
|
68
75
|
listConfig: ListConfig<T>;
|
|
69
76
|
getData: (pageIndex, pageSie, params, keyword) => Promise<{ data: any[]; total: number }>;
|