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 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 + 1)}`;
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 list">
42
+ <template v-for="row in renderCustom">
45
43
  <yhm-info has-top>
46
- <template v-for="item in listConfig?.items">
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-if="!item.show || (item.show && item.show(row))"
49
- :label="item.label"
50
+ v-else
51
+ :label="col.label"
50
52
  regular-value
51
- :span="item.span"
52
- :align="item.align || align"
53
- :desc-align="item.descAlign || descAlign"
54
- :font-size="item.fontSize || fontSize"
55
- :status="item.status && item.status(row)"
56
- :description="row[item.description] || item.description"
57
- :value="row[item.value] || item.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-mobile-components",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
4
4
  "description": "移动端组件封装及配置化需求",
5
5
  "main": "index.js",
6
6
  "scripts": {
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
  /** 自定义插槽,用来渲染自定义元素 */