yh-mobile-components 1.0.8 → 1.1.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/README.md CHANGED
@@ -32,230 +32,4 @@ async function main() {
32
32
  main()
33
33
  ```
34
34
 
35
- ## 类型或枚举
36
-
37
- ###### 状态枚举 StatusType
38
-
39
- ```js
40
- export type StatusType = "primary" | "danger" | "success" | "warning" | "cyan" | "purple" | "yellow" | "pink";
41
- ```
42
-
43
- |属性|说明|
44
- |----|----|
45
- |primary|表示主要内容,文字显示为蓝色|
46
- |success|表示成功,文字显示为绿色|
47
- |danger|表示危险,文字显示为红色|
48
- |warning|表示警告,文字显示为橙色|
49
- |cyan|文字显示为青色|
50
- |purple|文字显示为紫色|
51
- |yellow|文字显示为黄色|
52
- |pink|文字显示为粉色|
53
-
54
- ###### 数据选项 VanOption
55
- 列表参数、下拉、单选、多选有用到
56
-
57
- ```js
58
- /** 下拉、单选、多选等组件的数据选项 */
59
- export interface vanOption {
60
- /** 选项的标签用来显示的 */
61
- text: string;
62
- /** 选项的值,用来赋值传递给后端的 */
63
- value: string | number;
64
- }
65
- ```
66
-
67
- ```js
68
- const optionData = reactive([{text:"一",value:1},{text:"二",value:2},{text:"三",value:3}])
69
- ```
70
-
71
- ## 组件说明
72
-
73
- ###### yhm-list
74
- 使用下面的模板创建一个列表
75
-
76
- ```html
77
- <template>
78
- <yhm-list v-bind="configObj"></yhm-list>
79
- </template>
80
-
81
- <script setup lang="ts">
82
- import { ref, reactive } from "vue";
83
- import { ListConfig, ListConfigObject, ParamConfig } from "yh-mobile-components/types";
84
-
85
- const listConfig = reactive<ListConfig<any>>({
86
- btns: [
87
- {
88
- type: "primary",
89
- text: "详情",
90
- callback(row) {
91
- console.log(row);
92
- },
93
- },
94
- ],
95
- items: [
96
- {
97
- span: 12,
98
- label: "标签名",
99
- value: "name",
100
- description: "标签描述",
101
- status(row) {
102
- return "primary";
103
- },
104
- },
105
- {
106
- span: 12,
107
- label: "偶数显示",
108
- value: "name",
109
- description: "标签描述",
110
- show(row) {
111
-
112
- return row.status === 0;
113
- },
114
- status(row) {
115
- return "primary";
116
- },
117
- },
118
- {
119
- span: 24,
120
- label: "标签名",
121
- value: "name",
122
- description: "标签描述",
123
- status(row) {
124
- return "primary";
125
- },
126
- },
127
- ],
128
- });
129
- const paramConfig = reactive<ParamConfig[]>([
130
- {
131
- value: "param1",
132
- optionData: [
133
- { text: "全部", value: "" },
134
- { text: "一", value: 1 },
135
- { text: "二", value: 2 },
136
- ],
137
- defaultValue: "",
138
- },
139
- {
140
- value: "param2",
141
- optionData: [
142
- { text: "全部", value: "" },
143
- { text: "一", value: 1 },
144
- { text: "二", value: 2 },
145
- ],
146
- defaultValue: "",
147
- },
148
- ]);
149
-
150
- const configObj = reactive<ListConfigObject<any>>({
151
- hasSearch: true,
152
- searchPlaceholder: "关键词搜索",
153
- paramConfig,
154
- listConfig,
155
- getData(pageIndex, pageSize, params, keyword) {
156
- return new Promise((resolve, reject) => {
157
- let arr: any = [];
158
- for (let i = 0; i < 20; i++) {
159
- arr.push({
160
- name: `name${i}`,
161
- status: i % 2,
162
- });
163
- }
164
- setTimeout(() => {
165
- resolve({ data: arr, total: 20 });
166
- }, 1000);
167
- });
168
- },
169
- });
170
- </script>
171
-
172
- <style lang="scss"></style>
173
-
174
- ```
175
-
176
- ###### yhm-form
177
- 使用下面的模板创建一个列表
178
-
179
- ```html
180
- <template>
181
- <yhm-form
182
- :options="options"
183
- :formData="formData"
184
- v-model:verification="verification">
185
- <van-button
186
- type="primary"
187
- :disabled="!verification"
188
- block
189
- @click="submit">
190
- 确认
191
- </van-button>
192
- </yhm-form>
193
- </template>
194
- <script setup lang="ts">
195
- import { ref, reactive } from "vue";
196
- import { ConfigFormItem } from "yh-mobile-components/types";
197
-
198
- const formData = reactive<any>({});
199
- const options = reactive<ConfigFormItem[]>([
200
- {
201
- label: "数字",
202
- type: "number",
203
- name: "1",
204
- defaultValue: "",
205
- config: {},
206
- itemChange(val, data) {
207
- console.log(val, data);
208
- },
209
- },
210
- ]);
211
- const verification = ref(false);
212
-
213
- function submit() {
214
- if (verification.value) {
215
- // 表单验证通过
216
- } else {
217
- // 表单验证没通过此时按钮也处于无法点击状态
218
- }
219
- }
220
- </script>
221
-
222
- ```
223
-
224
- ###### yhm-info
225
- 信息展示包裹组件,用来包裹 yhm-info-item。
226
-
227
- |属性|必选|类型|说明|
228
- |----|----|----|----|
229
- |hasTop|否|boolean|是否在组件上方增加一个间隔|
230
-
231
- ###### yhm-info-item
232
- 信息展示元素组件,必须嵌入 yhm-info-item 使用。
233
-
234
- |属性|必选|类型|说明|
235
- |----|----|----|----|
236
- |span|是|number| 1 - 24的数字|
237
- |label|否|string|标签名|
238
- |value|否|number|标签值|
239
- |description|否|number|标签描述|
240
- |regularValue|否|number| 是否让值显示黑色 |
241
- |status|否|StatusType| 是否让值显示黑色 |
242
-
243
- ```html
244
- <yhm-info has-top>
245
- <yhm-info>
246
- ```
247
-
248
- ###### yhm-datetime
249
- 日期时间选择组件
250
-
251
- ###### yhm-switch
252
- 开关组件
253
-
254
- ###### yhm-select
255
- 下拉选择
256
-
257
- ###### yhm-radio
258
- 单选
259
-
260
- ###### yhm-checkbox
261
- 多选
35
+ [最新文档地址](http://docs.js.sforcecon.com:5900/view/588)
@@ -1,5 +1,83 @@
1
1
  <template>
2
- <section></section>
2
+ <van-field
3
+ class="yhm-cascader-container"
4
+ v-bind="$attrs"
5
+ :error="error"
6
+ :error-message="errorMessage"
7
+ :disabled="disabled">
8
+ <template #input>
9
+ <div @click="showSignature">
10
+ <span :class="{ placeholder: !modelValue }">
11
+ {{ modelText || placeholder }}
12
+ </span>
13
+ </div>
14
+ </template>
15
+ </van-field>
16
+ <van-popup
17
+ class="yhm-cascader-container"
18
+ v-model:show="isShow"
19
+ position="bottom">
20
+ <van-cascader
21
+ :value-model="modelValue"
22
+ :title="placeholder"
23
+ :options="optionData"
24
+ @close="onCancel"
25
+ @finish="onFinish" />
26
+ </van-popup>
3
27
  </template>
4
- <script setup lang="ts"></script>
5
- <style lang="scss"></style>
28
+ <script setup lang="ts">
29
+ import { ref } from "vue";
30
+ import { vanOption } from "../types";
31
+ const props = withDefaults(
32
+ defineProps<{
33
+ placeholder?: string;
34
+ disabled?: boolean;
35
+ error?: boolean;
36
+ errorMessage?: string;
37
+ modelValue?: any;
38
+ optionData: vanOption[];
39
+ }>(),
40
+ {
41
+ disabled: false,
42
+ placeholder: "请选择",
43
+ }
44
+ );
45
+
46
+ const emits = defineEmits<{
47
+ (e: "update:modelValue", val: any);
48
+ (e: "change", val: any);
49
+ }>();
50
+
51
+ const isShow = ref(false);
52
+ const modelText = ref("");
53
+ function showSignature() {
54
+ if (!props.disabled) {
55
+ isShow.value = true;
56
+ }
57
+ }
58
+ function changeHandler(val) {
59
+ emits("update:modelValue", val);
60
+ emits("change", val);
61
+ }
62
+
63
+ function onFinish({ selectedOptions }) {
64
+ let value = selectedOptions.map((option) => option.value).join("/");
65
+ modelText.value = selectedOptions.map((option) => option.text).join("/");
66
+ changeHandler(value);
67
+ isShow.value = false;
68
+ }
69
+ function onCancel() {
70
+ changeHandler("");
71
+ isShow.value = false;
72
+ }
73
+ </script>
74
+ <style lang="scss">
75
+ .yhm-cascader-container {
76
+ .van-field__control {
77
+ justify-content: flex-end;
78
+ .placeholder {
79
+ color: var(--van-text-color-3);
80
+ }
81
+ }
82
+ }
83
+ </style>
@@ -186,21 +186,21 @@
186
186
  </template>
187
187
 
188
188
  <script setup lang="ts">
189
- import dayjs, { Dayjs } from "dayjs";
189
+ import dayjs from "dayjs";
190
190
  import { ref, computed, watch, onMounted } from "vue";
191
191
  import { cloneDeep } from "lodash-es";
192
192
 
193
193
  const props = withDefaults(
194
194
  defineProps<{
195
195
  type: "year" | "month" | "date" | "datetime" | "time";
196
- modelValue: Dayjs;
196
+ modelValue: dayjs.Dayjs;
197
197
  }>(),
198
198
  {}
199
199
  );
200
200
 
201
201
  const emits = defineEmits<{
202
- (e: "update:modelValue", date: Dayjs);
203
- (e: "change", date: Dayjs);
202
+ (e: "update:modelValue", date: dayjs.Dayjs);
203
+ (e: "change", date: dayjs.Dayjs);
204
204
  }>();
205
205
 
206
206
  const divType = ref("day");
@@ -243,7 +243,7 @@ const momentDay = computed(() => {
243
243
  const changeType = computed(() => {
244
244
  return divType.value === "day" ? "month" : "year";
245
245
  });
246
- const rows = computed<Dayjs[][]>(() => {
246
+ const rows = computed<dayjs.Dayjs[][]>(() => {
247
247
  if (divType.value === "day") {
248
248
  // 指定月份第一天
249
249
  let mMFD = viewDate.value.date(1);
@@ -256,13 +256,13 @@ const rows = computed<Dayjs[][]>(() => {
256
256
  } else {
257
257
  lastIndex = mMDays - (mMLW - 7);
258
258
  }
259
- let items: Dayjs[] = [];
259
+ let items: dayjs.Dayjs[] = [];
260
260
  for (let i = firstIndex; i < lastIndex; i++) {
261
261
  let day = mMFD.add(i, "day");
262
262
  items.push(day);
263
263
  }
264
264
  let powLen = Math.ceil(items.length / 7);
265
- let result: Dayjs[][] = [];
265
+ let result: dayjs.Dayjs[][] = [];
266
266
  for (let j = 0; j < powLen; j++) {
267
267
  result.push(items.splice(0, 7));
268
268
  }
@@ -271,23 +271,23 @@ const rows = computed<Dayjs[][]>(() => {
271
271
  let mMFD = viewDate.value.month();
272
272
  let firstIndex = 0 - mMFD;
273
273
  let lastIndex = -(mMFD - 12);
274
- let items: Dayjs[] = [];
274
+ let items: dayjs.Dayjs[] = [];
275
275
  for (let i = firstIndex; i < lastIndex; i++) {
276
276
  let month = viewDate.value.add(i, "month");
277
277
  items.push(month);
278
278
  }
279
- let result: Dayjs[][] = [];
279
+ let result: dayjs.Dayjs[][] = [];
280
280
  for (let j = 0; j < 4; j++) {
281
281
  result.push(items.splice(0, 3));
282
282
  }
283
283
  return result;
284
284
  } else {
285
- let items: Dayjs[] = [];
285
+ let items: dayjs.Dayjs[] = [];
286
286
  for (let i = -11; i < 13; i++) {
287
287
  let year = viewDate.value.add(i, "year");
288
288
  items.push(year);
289
289
  }
290
- let result: Dayjs[][] = [];
290
+ let result: dayjs.Dayjs[][] = [];
291
291
  for (let j = 0; j < 4; j++) {
292
292
  result.push(items.splice(0, 3));
293
293
  }
@@ -76,7 +76,6 @@ const props = withDefaults(
76
76
  error?: boolean;
77
77
  errorMessage?: string;
78
78
  modelValue?: any;
79
- scanCallback?: (val) => void;
80
79
  }>(),
81
80
  {}
82
81
  );
package/form/yhmRate.vue CHANGED
@@ -1,5 +1,61 @@
1
1
  <template>
2
- <section></section>
2
+ <van-field
3
+ class="yhm-rate-container"
4
+ v-bind="$attrs"
5
+ :error="error"
6
+ :error-message="errorMessage"
7
+ :disabled="disabled">
8
+ <template #input>
9
+ <van-rate
10
+ :disabled="disabled"
11
+ :model-value="modelValue"
12
+ @update:modelValue="changeHandler"
13
+ :count="count"
14
+ :size="size"
15
+ :gutter="gutter"
16
+ :color="color"
17
+ :allow-half="allowHalf"
18
+ :clearable="clearable"></van-rate>
19
+ </template>
20
+ </van-field>
3
21
  </template>
4
- <script setup lang="ts"></script>
5
- <style lang="scss"></style>
22
+ <script setup lang="ts">
23
+ const props = withDefaults(
24
+ defineProps<{
25
+ disabled?: boolean;
26
+ error?: boolean;
27
+ errorMessage?: string;
28
+ modelValue?: any;
29
+ count?: number;
30
+ size?: number;
31
+ gutter?: number;
32
+ color?: string;
33
+ allowHalf?: boolean;
34
+ clearable?: boolean;
35
+ }>(),
36
+ {
37
+ disabled: false,
38
+ step: 1,
39
+ min: 1,
40
+ barHeight: "2px",
41
+ buttonSize: "24px",
42
+ }
43
+ );
44
+
45
+ const emits = defineEmits<{
46
+ (e: "update:modelValue", val: any);
47
+ (e: "change", val: any);
48
+ }>();
49
+
50
+ function changeHandler(val) {
51
+ emits("update:modelValue", val);
52
+ emits("change", val);
53
+ }
54
+ </script>
55
+ <style lang="scss">
56
+ .yhm-rate-container {
57
+ .van-field__control {
58
+ justify-content: flex-end;
59
+ }
60
+ }
61
+ </style>
@@ -1,5 +1,84 @@
1
1
  <template>
2
- <section></section>
2
+ <van-field
3
+ class="yhm-signature-container"
4
+ v-bind="$attrs"
5
+ :error="error"
6
+ :error-message="errorMessage"
7
+ :disabled="disabled">
8
+ <template #input>
9
+ <span
10
+ @click="showSignature"
11
+ class="placeholder"
12
+ v-if="!modelValue">
13
+ 点击进行签名
14
+ </span>
15
+ <img
16
+ v-else
17
+ class="signature-image"
18
+ @click="showSignature"
19
+ :src="modelValue"
20
+ alt="签名" />
21
+ </template>
22
+ </van-field>
23
+ <van-popup
24
+ class="yhm-signature-container"
25
+ v-model:show="isShow"
26
+ position="bottom">
27
+ <van-signature
28
+ @submit="onSubmit"
29
+ @clear="onClear"></van-signature>
30
+ </van-popup>
3
31
  </template>
4
- <script setup lang="ts"></script>
5
- <style lang="scss"></style>
32
+ <script setup lang="ts">
33
+ import { ref } from "vue";
34
+ const props = withDefaults(
35
+ defineProps<{
36
+ disabled?: boolean;
37
+ error?: boolean;
38
+ errorMessage?: string;
39
+ modelValue?: any;
40
+ }>(),
41
+ {
42
+ disabled: false,
43
+ }
44
+ );
45
+
46
+ const emits = defineEmits<{
47
+ (e: "update:modelValue", val: any);
48
+ (e: "change", val: any);
49
+ }>();
50
+
51
+ const isShow = ref(false);
52
+ function showSignature() {
53
+ if (!props.disabled) {
54
+ isShow.value = true;
55
+ }
56
+ }
57
+ function changeHandler(val) {
58
+ emits("update:modelValue", val);
59
+ emits("change", val);
60
+ }
61
+
62
+ function onSubmit({ image }) {
63
+ changeHandler(image);
64
+ isShow.value = false;
65
+ }
66
+ function onClear() {
67
+ changeHandler("");
68
+ isShow.value = false;
69
+ }
70
+ </script>
71
+ <style lang="scss">
72
+ .yhm-signature-container {
73
+ .van-field__control {
74
+ justify-content: flex-end;
75
+ .placeholder {
76
+ color: var(--van-text-color-3);
77
+ }
78
+ .signature-image {
79
+ width: auto;
80
+ max-height: 60px;
81
+ }
82
+ }
83
+ }
84
+ </style>
@@ -1,5 +1,59 @@
1
1
  <template>
2
- <section></section>
2
+ <van-field
3
+ class="yhm-slider-container"
4
+ v-bind="$attrs"
5
+ :error="error"
6
+ :error-message="errorMessage"
7
+ :disabled="disabled">
8
+ <template #input>
9
+ <van-slider
10
+ :disabled="disabled"
11
+ :model-value="modelValue"
12
+ @update:modelValue="changeHandler"
13
+ :step="step"
14
+ :min="min"
15
+ :max="max"
16
+ :bar-height="barHeight"
17
+ :button-size="buttonSize"></van-slider>
18
+ </template>
19
+ </van-field>
3
20
  </template>
4
- <script setup lang="ts"></script>
5
- <style lang="scss"></style>
21
+ <script setup lang="ts">
22
+ const props = withDefaults(
23
+ defineProps<{
24
+ disabled?: boolean;
25
+ error?: boolean;
26
+ errorMessage?: string;
27
+ modelValue?: any;
28
+ step?: number;
29
+ min?: number;
30
+ max?: number;
31
+ barHeight?: string;
32
+ buttonSize?: string;
33
+ }>(),
34
+ {
35
+ disabled: false,
36
+ step: 1,
37
+ min: 1,
38
+ barHeight: "2px",
39
+ buttonSize: "24px",
40
+ }
41
+ );
42
+
43
+ const emits = defineEmits<{
44
+ (e: "update:modelValue", val: any);
45
+ (e: "change", val: any);
46
+ }>();
47
+
48
+ function changeHandler(val) {
49
+ emits("update:modelValue", val);
50
+ emits("change", val);
51
+ }
52
+ </script>
53
+ <style lang="scss">
54
+ .yhm-slider-container {
55
+ .van-field__control {
56
+ justify-content: flex-end;
57
+ }
58
+ }
59
+ </style>
@@ -1,5 +1,56 @@
1
1
  <template>
2
- <section></section>
2
+ <van-field
3
+ class="yhm-stepper-container"
4
+ v-bind="$attrs"
5
+ :error="error"
6
+ :error-message="errorMessage"
7
+ :disabled="disabled">
8
+ <template #input>
9
+ <van-stepper
10
+ :disabled="disabled"
11
+ :model-value="modelValue"
12
+ @update:modelValue="changeHandler"
13
+ :step="step"
14
+ :min="min"
15
+ :max="max"
16
+ :decimalLength="decimalLength"></van-stepper>
17
+ </template>
18
+ </van-field>
3
19
  </template>
4
- <script setup lang="ts"></script>
5
- <style lang="scss"></style>
20
+ <script setup lang="ts">
21
+ const props = withDefaults(
22
+ defineProps<{
23
+ disabled?: boolean;
24
+ error?: boolean;
25
+ errorMessage?: string;
26
+ modelValue?: any;
27
+ step?: number;
28
+ min?: number;
29
+ max?: number;
30
+ decimalLength?: number;
31
+ }>(),
32
+ {
33
+ disabled: false,
34
+ step: 1,
35
+ min: 1,
36
+ decimalLength: 0,
37
+ }
38
+ );
39
+
40
+ const emits = defineEmits<{
41
+ (e: "update:modelValue", val: any);
42
+ (e: "change", val: any);
43
+ }>();
44
+
45
+ function changeHandler(val) {
46
+ emits("update:modelValue", val);
47
+ emits("change", val);
48
+ }
49
+ </script>
50
+ <style lang="scss">
51
+ .yhm-stepper-container {
52
+ .van-field__control {
53
+ justify-content: flex-end;
54
+ }
55
+ }
56
+ </style>
package/info/yhmTable.vue CHANGED
@@ -43,9 +43,12 @@ const props = withDefaults(
43
43
  hasIndex?: boolean;
44
44
  columns: ColumnItem[];
45
45
  }>(),
46
+ // @ts-ignore
46
47
  {
48
+ // @ts-ignore
47
49
  data: [],
48
50
  hasIndex: false,
51
+ // @ts-ignore
49
52
  columns: [],
50
53
  }
51
54
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-mobile-components",
3
- "version": "1.0.8",
3
+ "version": "1.1.1",
4
4
  "description": "移动端组件封装及配置化需求",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/types.ts CHANGED
@@ -20,7 +20,7 @@ export interface ListBtn {
20
20
  /** 是否显示
21
21
  * @param row 当前行数据
22
22
  */
23
- show?: (row: T) => boolean;
23
+ show?: (row) => boolean;
24
24
  }
25
25
 
26
26
  /** 列表对象字段 */