hy-app 0.4.3 → 0.4.5
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/components/hy-action-sheet/hy-action-sheet.vue +1 -1
- package/components/hy-address-picker/hy-address-picker.vue +1 -1
- package/components/hy-avatar/hy-avatar.vue +1 -1
- package/components/hy-back-top/hy-back-top.vue +1 -2
- package/components/hy-badge/hy-badge.vue +1 -1
- package/components/hy-button/hy-button.vue +1 -2
- package/components/hy-calendar/hy-calendar.vue +3 -11
- package/components/hy-calendar/month.vue +1 -1
- package/components/hy-card/hy-card.vue +1 -1
- package/components/hy-cell/hy-cell.vue +1 -2
- package/components/hy-cell/props.ts +1 -1
- package/components/hy-check-button/hy-check-button.vue +2 -2
- package/components/hy-checkbox/hy-checkbox.vue +2 -3
- package/components/hy-checkbox-group/hy-checkbox-group.vue +1 -1
- package/components/hy-checkbox-item/hy-checkbox-item.vue +1 -2
- package/components/hy-code-input/hy-code-input.vue +1 -1
- package/components/hy-config-provider/hy-config-provider.vue +2 -3
- package/components/hy-config-provider/props.ts +1 -1
- package/components/hy-count-down/index.ts +1 -1
- package/components/hy-count-to/hy-count-to.vue +1 -1
- package/components/hy-datetime-picker/hy-datetime-picker.vue +2 -3
- package/components/hy-datetime-picker/props.ts +1 -1
- package/components/hy-divider/hy-divider.vue +1 -2
- package/components/hy-divider/props.ts +1 -1
- package/components/hy-dropdown/hy-dropdown.vue +2 -3
- package/components/hy-dropdown/props.ts +1 -1
- package/components/hy-dropdown-item/hy-dropdown-item.vue +1 -2
- package/components/hy-empty/hy-empty.vue +1 -1
- package/components/hy-flex/hy-flex.vue +1 -1
- package/components/hy-float-button/hy-float-button.vue +1 -2
- package/components/hy-float-button/props.ts +14 -14
- package/components/hy-folding-panel/hy-folding-panel.vue +2 -3
- package/components/hy-folding-panel/props.ts +1 -1
- package/components/hy-form/hy-form.vue +1 -1
- package/components/hy-form-group/hy-form-group.vue +183 -111
- package/components/hy-form-group/typing.d.ts +1 -1
- package/components/hy-form-item/hy-form-item.vue +1 -1
- package/components/hy-grid/hy-grid.vue +1 -1
- package/components/hy-icon/hy-icon.vue +1 -1
- package/components/hy-icon/index.scss +1 -1
- package/components/hy-image/hy-image.vue +1 -2
- package/components/hy-image/props.ts +10 -10
- package/components/hy-input/hy-input.vue +1 -2
- package/components/hy-line/hy-line.vue +1 -1
- package/components/hy-line-progress/hy-line-progress.vue +1 -2
- package/components/hy-list/hy-list.vue +1 -1
- package/components/hy-loading/hy-loading.vue +1 -1
- package/components/hy-menu/hy-menu.vue +1 -1
- package/components/hy-modal/hy-modal.vue +2 -2
- package/components/hy-modal/props.ts +13 -13
- package/components/hy-navbar/hy-navbar.vue +1 -2
- package/components/hy-navbar/props.ts +1 -1
- package/components/hy-notice-bar/hy-column-notice.vue +1 -2
- package/components/hy-notice-bar/hy-notice-bar.vue +1 -1
- package/components/hy-notice-bar/hy-row-notice.vue +1 -2
- package/components/hy-notice-bar/props.ts +1 -1
- package/components/hy-notify/hy-notify.vue +1 -2
- package/components/hy-number-step/hy-number-step.vue +1 -2
- package/components/hy-overlay/hy-overlay.vue +1 -1
- package/components/hy-pagination/hy-pagination.vue +1 -1
- package/components/hy-picker/hy-picker.vue +1 -2
- package/components/hy-popover/hy-popover.vue +9 -3
- package/components/hy-popup/hy-popup.vue +2 -3
- package/components/hy-price/hy-price.vue +3 -2
- package/components/hy-qrcode/hy-qrcode.vue +1 -1
- package/components/hy-radio/hy-radio.vue +1 -2
- package/components/hy-rate/hy-rate.vue +6 -4
- package/components/hy-rate/props.ts +6 -6
- package/components/hy-read-more/hy-read-more.vue +1 -2
- package/components/hy-scroll-list/hy-scroll-list.vue +1 -1
- package/components/hy-scroll-list/props.ts +0 -1
- package/components/hy-search/hy-search.vue +3 -3
- package/components/hy-signature/hy-signature.vue +1 -1
- package/components/hy-slider/hy-slider.vue +3 -13
- package/components/hy-slider/props.ts +1 -1
- package/components/hy-status-bar/hy-status-bar.vue +1 -1
- package/components/hy-status-bar/props.ts +1 -1
- package/components/hy-steps/hy-steps.vue +1 -2
- package/components/hy-subsection/hy-subsection.vue +1 -1
- package/components/hy-subsection/props.ts +0 -1
- package/components/hy-subsection/typing.d.ts +0 -1
- package/components/hy-swipe-action/hy-swipe-action.vue +1 -2
- package/components/hy-swiper/hy-swiper-indicator.vue +1 -1
- package/components/hy-swiper/hy-swiper.vue +2 -3
- package/components/hy-swiper/typing.d.ts +35 -36
- package/components/hy-switch/hy-switch.vue +2 -2
- package/components/hy-switch/typing.d.ts +0 -1
- package/components/hy-tabs/hy-tabs.vue +2 -3
- package/components/hy-tag/hy-tag.vue +1 -2
- package/components/hy-text/hy-text.vue +2 -2
- package/components/hy-text/typing.d.ts +26 -26
- package/components/hy-textarea/hy-textarea.vue +2 -2
- package/components/hy-toast/hy-toast.vue +33 -19
- package/components/hy-toast/index.scss +3 -2
- package/components/hy-toast/typing.d.ts +1 -1
- package/components/hy-tooltip/hy-tooltip.vue +8 -2
- package/components/hy-transition/hy-transition.vue +1 -1
- package/components/hy-upload/hy-upload.vue +7 -2
- package/components/hy-upload/props.ts +1 -1
- package/components/hy-warn/hy-warn.vue +1 -2
- package/components/hy-warn/typing.d.ts +12 -13
- package/components/hy-waterfall/hy-waterfall.vue +1 -1
- package/components/hy-watermark/hy-watermark.vue +1 -1
- package/components/index.ts +117 -118
- package/index.ts +1 -7
- package/{api → libs/api}/http.ts +2 -2
- package/libs/common/index.ts +2 -0
- package/libs/common/queue.ts +28 -0
- package/{composables → libs/composables}/index.ts +1 -0
- package/{composables → libs/composables}/usePopover.ts +7 -2
- package/{common/shakeService.ts → libs/composables/useShakeService.ts} +4 -2
- package/{composables → libs/composables}/useShare.ts +3 -0
- package/libs/composables/useToast.ts +45 -0
- package/{composables → libs/composables}/useTouch.ts +3 -0
- package/{global → libs/global}/register-properties.ts +1 -1
- package/libs/index.ts +7 -0
- package/{typing → libs/typing}/index.ts +0 -1
- package/{typing → libs/typing}/modules/form.ts +7 -7
- package/{utils → libs/utils}/utils.ts +1 -0
- package/package.json +2 -2
- package/common/index.ts +0 -3
- package/common/queue.ts +0 -34
- package/components/hy-form/README.md +0 -301
- package/components/hy-text/index.ts +0 -0
- package/components/yk-dialog/yk-dialog.vue +0 -129
- package/composables/useToast.ts +0 -51
- package/typing/modules/dialog.ts +0 -17
- /package/{api → libs/api}/index.ts +0 -0
- /package/{common → libs/common}/versionControl.ts +0 -0
- /package/{composables → libs/composables}/useQueue.ts +0 -0
- /package/{config → libs/config}/color.ts +0 -0
- /package/{config → libs/config}/icon.ts +0 -0
- /package/{config → libs/config}/index.ts +0 -0
- /package/{static/font → libs/css}/iconfont.css +0 -0
- /package/{global → libs/global}/index.ts +0 -0
- /package/{typing → libs/typing}/modules/common.d.ts +0 -0
- /package/{typing → libs/typing}/modules/enum.ts +0 -0
- /package/{typing → libs/typing}/modules/http.ts +0 -0
- /package/{typing → libs/typing}/modules/icon.d.ts +0 -0
- /package/{typing → libs/typing}/modules/rect.ts +0 -0
- /package/{utils → libs/utils}/address.json +0 -0
- /package/{utils → libs/utils}/base64.ts +0 -0
- /package/{utils → libs/utils}/calendar.js +0 -0
- /package/{utils → libs/utils}/colorGradient.ts +0 -0
- /package/{utils → libs/utils}/index.ts +0 -0
- /package/{utils → libs/utils}/inside.ts +0 -0
- /package/{utils → libs/utils}/inspect.ts +0 -0
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
:key="item.field"
|
|
7
7
|
>
|
|
8
8
|
<view v-if="item.label" class="hy-form--item__label" :style="labelStyle">
|
|
9
|
-
<text
|
|
9
|
+
<text
|
|
10
|
+
v-if="isRequired(item.rules)"
|
|
11
|
+
style="color: red; font-size: 20px; line-height: 10px"
|
|
12
|
+
>
|
|
10
13
|
*
|
|
11
14
|
</text>
|
|
12
15
|
{{ item.label }}
|
|
@@ -20,23 +23,35 @@
|
|
|
20
23
|
v-model="formData[item.field]"
|
|
21
24
|
:type="item.type"
|
|
22
25
|
:disabled="item?.input?.disabled || input?.disabled"
|
|
23
|
-
:disabledColor="
|
|
26
|
+
:disabledColor="
|
|
27
|
+
item?.input?.disabledColor || input?.disabledColor
|
|
28
|
+
"
|
|
24
29
|
:maxlength="item?.input?.maxlength || input?.maxlength"
|
|
25
30
|
:password="item?.input?.password"
|
|
26
31
|
:clearable="item?.input?.clearable || input?.clearable"
|
|
27
32
|
:readonly="item?.input?.readonly || input?.readonly"
|
|
28
33
|
:placeholder="item?.input?.placeholder"
|
|
29
|
-
:placeholderClass="
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
:placeholderClass="
|
|
35
|
+
item?.input?.placeholderClass || input?.placeholderClass
|
|
36
|
+
"
|
|
37
|
+
:placeholderStyle="
|
|
38
|
+
item?.input?.placeholderStyle || input?.placeholderStyle
|
|
39
|
+
"
|
|
40
|
+
:showWordLimit="
|
|
41
|
+
item?.input?.showWordLimit || input?.showWordLimit
|
|
42
|
+
"
|
|
32
43
|
:confirmType="item?.input?.confirmType || input?.confirmType"
|
|
33
44
|
:confirmHold="item?.input?.confirmHold || input?.confirmHold"
|
|
34
45
|
:holdKeyboard="item?.input?.holdKeyboard || input?.holdKeyboard"
|
|
35
46
|
:focus="item?.input?.focus || input?.focus"
|
|
36
47
|
:autoBlur="item?.input?.autoBlur || input?.autoBlur"
|
|
37
|
-
:selectionStart="
|
|
48
|
+
:selectionStart="
|
|
49
|
+
item?.input?.selectionStart || input?.selectionStart
|
|
50
|
+
"
|
|
38
51
|
:selectionEnd="item?.input?.selectionEnd || input?.selectionEnd"
|
|
39
|
-
:adjustPosition="
|
|
52
|
+
:adjustPosition="
|
|
53
|
+
item?.input?.adjustPosition || input?.adjustPosition
|
|
54
|
+
"
|
|
40
55
|
:inputAlign="item?.input?.inputAlign || input?.inputAlign"
|
|
41
56
|
:fontSize="item?.input?.fontSize || input?.fontSize"
|
|
42
57
|
:color="item?.input?.color || input?.color"
|
|
@@ -79,13 +94,25 @@
|
|
|
79
94
|
:disabled="item?.textarea?.disabled || textarea?.disabled"
|
|
80
95
|
:maxlength="item?.textarea?.maxlength || textarea?.maxlength"
|
|
81
96
|
:placeholder="item?.textarea?.placeholder"
|
|
82
|
-
:placeholderClass="
|
|
83
|
-
|
|
84
|
-
|
|
97
|
+
:placeholderClass="
|
|
98
|
+
item?.textarea?.placeholderClass || textarea?.placeholderClass
|
|
99
|
+
"
|
|
100
|
+
:placeholderStyle="
|
|
101
|
+
item?.textarea?.placeholderStyle || textarea?.placeholderStyle
|
|
102
|
+
"
|
|
103
|
+
:holdKeyboard="
|
|
104
|
+
item?.textarea?.holdKeyboard || textarea?.holdKeyboard
|
|
105
|
+
"
|
|
85
106
|
:focus="item?.textarea?.focus || textarea?.focus"
|
|
86
|
-
:selectionStart="
|
|
87
|
-
|
|
88
|
-
|
|
107
|
+
:selectionStart="
|
|
108
|
+
item?.textarea?.selectionStart || textarea?.selectionStart
|
|
109
|
+
"
|
|
110
|
+
:selectionEnd="
|
|
111
|
+
item?.textarea?.selectionEnd || textarea?.selectionEnd
|
|
112
|
+
"
|
|
113
|
+
:adjustPosition="
|
|
114
|
+
item?.textarea?.adjustPosition || textarea?.adjustPosition
|
|
115
|
+
"
|
|
89
116
|
:formatter="item?.textarea?.formatter || textarea?.formatter"
|
|
90
117
|
:border="item?.textarea?.border || textarea?.border"
|
|
91
118
|
:customStyle="errorStyle(!!errors[item.field])"
|
|
@@ -106,9 +133,13 @@
|
|
|
106
133
|
:size="item?.checkButton?.size || checkButton?.size"
|
|
107
134
|
:col="item?.checkButton?.col || checkButton?.col"
|
|
108
135
|
:gap="item?.checkButton?.gap || checkButton?.gap"
|
|
109
|
-
:fieldNames="
|
|
136
|
+
:fieldNames="
|
|
137
|
+
item?.checkButton?.fieldNames || checkButton?.fieldNames
|
|
138
|
+
"
|
|
110
139
|
:disabled="item?.checkButton?.size || checkButton?.disabled"
|
|
111
|
-
:selectType="
|
|
140
|
+
:selectType="
|
|
141
|
+
item?.checkButton?.selectType || checkButton?.selectType
|
|
142
|
+
"
|
|
112
143
|
></hy-check-button>
|
|
113
144
|
</template>
|
|
114
145
|
<!-- 复选框/单选框 -->
|
|
@@ -123,7 +154,9 @@
|
|
|
123
154
|
:disabled="item?.radio?.disabled || radio?.disabled"
|
|
124
155
|
:size="item?.radio?.size || radio?.size"
|
|
125
156
|
:activeColor="item?.radio?.activeColor || radio?.activeColor"
|
|
126
|
-
:inactiveColor="
|
|
157
|
+
:inactiveColor="
|
|
158
|
+
item?.radio?.inactiveColor || radio?.inactiveColor
|
|
159
|
+
"
|
|
127
160
|
:iconSize="item?.radio?.iconSize || radio?.iconSize"
|
|
128
161
|
:iconColor="item?.radio?.iconColor || radio?.iconColor"
|
|
129
162
|
:labelDisabled="item?.radio?.disabled || radio?.labelDisabled"
|
|
@@ -139,12 +172,24 @@
|
|
|
139
172
|
:loading="item?.switchItem?.loading || switchItem?.loading"
|
|
140
173
|
:disabled="item?.switchItem?.disabled || switchItem?.disabled"
|
|
141
174
|
:size="item?.switchItem?.size || switchItem?.size"
|
|
142
|
-
:activeColor="
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
:
|
|
146
|
-
|
|
147
|
-
|
|
175
|
+
:activeColor="
|
|
176
|
+
item?.switchItem?.activeColor || switchItem?.activeColor
|
|
177
|
+
"
|
|
178
|
+
:inactiveColor="
|
|
179
|
+
item?.switchItem?.inactiveColor || switchItem?.inactiveColor
|
|
180
|
+
"
|
|
181
|
+
:activeValue="
|
|
182
|
+
item?.switchItem?.activeValue || switchItem?.activeValue
|
|
183
|
+
"
|
|
184
|
+
:inactiveValue="
|
|
185
|
+
item?.switchItem?.inactiveValue || switchItem?.inactiveValue
|
|
186
|
+
"
|
|
187
|
+
:activeIcon="
|
|
188
|
+
item?.switchItem?.activeIcon || switchItem?.activeIcon
|
|
189
|
+
"
|
|
190
|
+
:inactiveIcon="
|
|
191
|
+
item?.switchItem?.inactiveIcon || switchItem?.inactiveIcon
|
|
192
|
+
"
|
|
148
193
|
:space="item?.switchItem?.space || switchItem?.space"
|
|
149
194
|
></HySwitch>
|
|
150
195
|
</template>
|
|
@@ -162,7 +207,9 @@
|
|
|
162
207
|
:confirmText="item?.picker?.confirmText || picker?.confirmText"
|
|
163
208
|
:cancelColor="item?.picker?.cancelColor || picker?.cancelColor"
|
|
164
209
|
:confirmColor="item?.picker?.confirmColor || picker?.confirmColor"
|
|
165
|
-
:visibleItemCount="
|
|
210
|
+
:visibleItemCount="
|
|
211
|
+
item?.picker?.visibleItemCount || picker?.visibleItemCount
|
|
212
|
+
"
|
|
166
213
|
:closeOnClickOverlay="
|
|
167
214
|
item?.picker?.closeOnClickOverlay || picker?.closeOnClickOverlay
|
|
168
215
|
"
|
|
@@ -170,7 +217,8 @@
|
|
|
170
217
|
:showToolbar="item?.picker?.showToolbar || picker?.showToolbar"
|
|
171
218
|
:customStyle="errorStyle(!!errors[item.field])"
|
|
172
219
|
:input="{
|
|
173
|
-
disabled:
|
|
220
|
+
disabled:
|
|
221
|
+
item?.picker?.input?.disabled || picker?.input?.disabled,
|
|
174
222
|
placeholder: item.picker?.input?.placeholder,
|
|
175
223
|
shape: item?.picker?.input?.shape || picker?.input?.shape,
|
|
176
224
|
border: item?.picker?.input?.border || picker?.input?.border,
|
|
@@ -192,7 +240,9 @@
|
|
|
192
240
|
:confirmText="item?.picker?.confirmText || picker?.confirmText"
|
|
193
241
|
:cancelColor="item?.picker?.cancelColor || picker?.cancelColor"
|
|
194
242
|
:confirmColor="item?.picker?.confirmColor || picker?.confirmColor"
|
|
195
|
-
:visibleItemCount="
|
|
243
|
+
:visibleItemCount="
|
|
244
|
+
item?.picker?.visibleItemCount || picker?.visibleItemCount
|
|
245
|
+
"
|
|
196
246
|
:closeOnClickOverlay="
|
|
197
247
|
item?.picker?.closeOnClickOverlay || picker?.closeOnClickOverlay
|
|
198
248
|
"
|
|
@@ -200,7 +250,8 @@
|
|
|
200
250
|
:showToolbar="item?.picker?.showToolbar || picker?.showToolbar"
|
|
201
251
|
:customStyle="errorStyle(!!errors[item.field])"
|
|
202
252
|
:input="{
|
|
203
|
-
disabled:
|
|
253
|
+
disabled:
|
|
254
|
+
item?.picker?.input?.disabled || picker?.input?.disabled,
|
|
204
255
|
placeholder: item.picker?.input?.placeholder,
|
|
205
256
|
shape: item?.picker?.input?.shape || picker?.input?.shape,
|
|
206
257
|
border: item?.picker?.input?.border || picker?.input?.border,
|
|
@@ -221,7 +272,9 @@
|
|
|
221
272
|
:confirmText="item?.picker?.confirmText || picker?.confirmText"
|
|
222
273
|
:cancelColor="item?.picker?.cancelColor || picker?.cancelColor"
|
|
223
274
|
:confirmColor="item?.picker?.confirmColor || picker?.confirmColor"
|
|
224
|
-
:visibleItemCount="
|
|
275
|
+
:visibleItemCount="
|
|
276
|
+
item?.picker?.visibleItemCount || picker?.visibleItemCount
|
|
277
|
+
"
|
|
225
278
|
:closeOnClickOverlay="
|
|
226
279
|
item?.picker?.closeOnClickOverlay || picker?.closeOnClickOverlay
|
|
227
280
|
"
|
|
@@ -229,7 +282,8 @@
|
|
|
229
282
|
:showToolbar="item?.picker?.showToolbar || picker?.showToolbar"
|
|
230
283
|
:customStyle="errorStyle(!!errors[item.field])"
|
|
231
284
|
:input="{
|
|
232
|
-
disabled:
|
|
285
|
+
disabled:
|
|
286
|
+
item?.picker?.input?.disabled || picker?.input?.disabled,
|
|
233
287
|
placeholder: item.picker?.input?.placeholder,
|
|
234
288
|
shape: item?.picker?.input?.shape || picker?.input?.shape,
|
|
235
289
|
border: item?.picker?.input?.border || picker?.input?.border,
|
|
@@ -252,7 +306,9 @@
|
|
|
252
306
|
|
|
253
307
|
<!-- 提示信息 -->
|
|
254
308
|
<HyTransition :show="!!errors[item.field]" mode="slide-left">
|
|
255
|
-
<view class="hy-form--item__container-warning">{{
|
|
309
|
+
<view class="hy-form--item__container-warning">{{
|
|
310
|
+
errors[item.field]
|
|
311
|
+
}}</view>
|
|
256
312
|
</HyTransition>
|
|
257
313
|
<!-- 提示信息 -->
|
|
258
314
|
</view>
|
|
@@ -262,69 +318,77 @@
|
|
|
262
318
|
|
|
263
319
|
<script lang="ts">
|
|
264
320
|
export default {
|
|
265
|
-
name:
|
|
321
|
+
name: "hy-form",
|
|
266
322
|
options: {
|
|
267
323
|
addGlobalClass: true,
|
|
268
324
|
virtualHost: true,
|
|
269
|
-
styleIsolation:
|
|
325
|
+
styleIsolation: "shared",
|
|
270
326
|
},
|
|
271
|
-
}
|
|
327
|
+
};
|
|
272
328
|
</script>
|
|
273
329
|
|
|
274
330
|
<script setup lang="ts">
|
|
275
|
-
import { computed, reactive, toRefs } from
|
|
276
|
-
import type { CSSProperties } from
|
|
277
|
-
import type IProps from
|
|
278
|
-
import defaultProps from
|
|
279
|
-
import { addUnit, error } from
|
|
280
|
-
import type { FormColumnsType, RulesVo } from
|
|
281
|
-
import { FormTypeEnum } from '../../typing'
|
|
331
|
+
import { computed, reactive, toRefs } from "vue";
|
|
332
|
+
import type { CSSProperties } from "vue";
|
|
333
|
+
import type IProps from "./typing";
|
|
334
|
+
import defaultProps from "./props";
|
|
335
|
+
import { addUnit, error, FormTypeEnum } from "../../libs";
|
|
336
|
+
import type { FormColumnsType, RulesVo } from "../../libs/typing";
|
|
282
337
|
|
|
283
338
|
// 组件
|
|
284
|
-
import HyInput from
|
|
285
|
-
import HyPicker from
|
|
286
|
-
import HyUpload from
|
|
287
|
-
import HyTextarea from
|
|
288
|
-
import HySwitch from
|
|
289
|
-
import HyRadio from
|
|
290
|
-
import HyDatetimePicker from
|
|
291
|
-
import HyAddressPicker from
|
|
292
|
-
import HyTransition from
|
|
293
|
-
import HyCheckButton from
|
|
294
|
-
|
|
295
|
-
const props = withDefaults(defineProps<IProps>(), defaultProps)
|
|
296
|
-
const {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
339
|
+
import HyInput from "../hy-input/hy-input.vue";
|
|
340
|
+
import HyPicker from "../hy-picker/hy-picker.vue";
|
|
341
|
+
import HyUpload from "../hy-upload/hy-upload.vue";
|
|
342
|
+
import HyTextarea from "../hy-textarea/hy-textarea.vue";
|
|
343
|
+
import HySwitch from "../hy-switch/hy-switch.vue";
|
|
344
|
+
import HyRadio from "../hy-radio/hy-radio.vue";
|
|
345
|
+
import HyDatetimePicker from "../hy-datetime-picker/hy-datetime-picker.vue";
|
|
346
|
+
import HyAddressPicker from "../hy-address-picker/hy-address-picker.vue";
|
|
347
|
+
import HyTransition from "../hy-transition/hy-transition.vue";
|
|
348
|
+
import HyCheckButton from "../hy-check-button/hy-check-button.vue";
|
|
349
|
+
|
|
350
|
+
const props = withDefaults(defineProps<IProps>(), defaultProps);
|
|
351
|
+
const {
|
|
352
|
+
formData,
|
|
353
|
+
columns,
|
|
354
|
+
labelWidth,
|
|
355
|
+
labelAlign,
|
|
356
|
+
labelPosition,
|
|
357
|
+
borderBottom,
|
|
358
|
+
} = toRefs(props);
|
|
359
|
+
const emit = defineEmits(["click"]);
|
|
360
|
+
|
|
361
|
+
const labelPos = labelPosition.value === "top" ? "column" : "row";
|
|
300
362
|
const isInput = (type: FormTypeEnum) =>
|
|
301
|
-
type === FormTypeEnum.TEXT ||
|
|
363
|
+
type === FormTypeEnum.TEXT ||
|
|
364
|
+
type === FormTypeEnum.NUMBER ||
|
|
365
|
+
type === FormTypeEnum.PASSWORD;
|
|
302
366
|
|
|
303
367
|
/**
|
|
304
368
|
* @description 错误输入框样式
|
|
305
369
|
* */
|
|
306
370
|
const errorStyle = computed(() => {
|
|
307
371
|
return (err: boolean) => {
|
|
308
|
-
const style: CSSProperties = {}
|
|
372
|
+
const style: CSSProperties = {};
|
|
309
373
|
if (err) {
|
|
310
|
-
style.background =
|
|
374
|
+
style.background = "#dd6161";
|
|
311
375
|
}
|
|
312
376
|
|
|
313
|
-
return style
|
|
314
|
-
}
|
|
315
|
-
})
|
|
377
|
+
return style;
|
|
378
|
+
};
|
|
379
|
+
});
|
|
316
380
|
|
|
317
381
|
const isRequired = computed(() => {
|
|
318
382
|
return (temp: any) => {
|
|
319
383
|
if (Array.isArray(temp)) {
|
|
320
|
-
return temp.some((item) => item?.required)
|
|
384
|
+
return temp.some((item) => item?.required);
|
|
321
385
|
} else {
|
|
322
|
-
return temp?.required
|
|
386
|
+
return temp?.required;
|
|
323
387
|
}
|
|
324
|
-
}
|
|
325
|
-
})
|
|
388
|
+
};
|
|
389
|
+
});
|
|
326
390
|
|
|
327
|
-
const errors: AnyObject = reactive({})
|
|
391
|
+
const errors: AnyObject = reactive({});
|
|
328
392
|
|
|
329
393
|
/**
|
|
330
394
|
* @description 标题行内样式
|
|
@@ -333,36 +397,44 @@ const labelStyle = computed(() => {
|
|
|
333
397
|
return {
|
|
334
398
|
textAlign: labelAlign.value,
|
|
335
399
|
width: addUnit(labelWidth.value),
|
|
336
|
-
}
|
|
337
|
-
})
|
|
400
|
+
};
|
|
401
|
+
});
|
|
338
402
|
|
|
339
403
|
/**
|
|
340
404
|
* @description 错误信息校验
|
|
341
405
|
* */
|
|
342
406
|
const errorMsg = (rule: RulesVo, value: string): string => {
|
|
343
407
|
// 手机正则
|
|
344
|
-
const phoneExpression = /^1[3-9]\d{9}
|
|
408
|
+
const phoneExpression = /^1[3-9]\d{9}$/;
|
|
345
409
|
// 邮箱正则
|
|
346
|
-
const emitExpression = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}
|
|
410
|
+
const emitExpression = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
|
|
347
411
|
// 复杂密码正则
|
|
348
412
|
const passwordExpression =
|
|
349
|
-
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,}
|
|
413
|
+
/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,}$/;
|
|
350
414
|
if (rule.required && !value) {
|
|
351
|
-
return rule.message
|
|
352
|
-
} else if (
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
415
|
+
return rule.message!;
|
|
416
|
+
} else if (
|
|
417
|
+
(rule?.min || rule?.max) &&
|
|
418
|
+
(value.length < rule?.min! || value.length > rule?.max!)
|
|
419
|
+
) {
|
|
420
|
+
return rule.message!;
|
|
421
|
+
} else if (rule.type === "phone" && !phoneExpression.test(String(value))) {
|
|
422
|
+
return rule.message || "请输入正确的手机号";
|
|
423
|
+
} else if (rule.type === "email" && !emitExpression.test(String(value))) {
|
|
424
|
+
return rule.message || "请输入正确的邮箱格式";
|
|
425
|
+
} else if (
|
|
426
|
+
rule.type === "password" &&
|
|
427
|
+
!passwordExpression.test(String(value))
|
|
428
|
+
) {
|
|
429
|
+
return (
|
|
430
|
+
rule.message || "至少8个字符串,并且包含大、小写字母、数字和特殊符号"
|
|
431
|
+
);
|
|
360
432
|
} else if (rule?.validator && !rule.validator(rule, value)) {
|
|
361
|
-
return rule.message ||
|
|
433
|
+
return rule.message || "";
|
|
362
434
|
} else {
|
|
363
|
-
return
|
|
435
|
+
return "";
|
|
364
436
|
}
|
|
365
|
-
}
|
|
437
|
+
};
|
|
366
438
|
|
|
367
439
|
/**
|
|
368
440
|
* @description 校验字段
|
|
@@ -371,28 +443,28 @@ const validateField = (
|
|
|
371
443
|
rules: RulesVo | RulesVo[] | undefined,
|
|
372
444
|
value: string,
|
|
373
445
|
field: string,
|
|
374
|
-
event?:
|
|
446
|
+
event?: "blur" | "change",
|
|
375
447
|
) => {
|
|
376
|
-
if (!rules) return
|
|
448
|
+
if (!rules) return;
|
|
377
449
|
|
|
378
|
-
let errorMessage =
|
|
450
|
+
let errorMessage = "";
|
|
379
451
|
|
|
380
452
|
if (Array.isArray(rules)) {
|
|
381
453
|
// 遍历所有规则
|
|
382
454
|
for (const index in rules) {
|
|
383
455
|
// 判断是否有change事件或者blur事件
|
|
384
|
-
if (event && !rules[index]?.trigger?.includes(event)) continue
|
|
385
|
-
errorMessage = errorMsg(rules[index], value)
|
|
456
|
+
if (event && !rules[index]?.trigger?.includes(event)) continue;
|
|
457
|
+
errorMessage = errorMsg(rules[index], value);
|
|
386
458
|
if (errorMessage) {
|
|
387
|
-
errors[field] = errorMessage
|
|
388
|
-
return
|
|
459
|
+
errors[field] = errorMessage;
|
|
460
|
+
return;
|
|
389
461
|
}
|
|
390
462
|
// 可以继续添加更多规则
|
|
391
463
|
}
|
|
392
464
|
} else {
|
|
393
465
|
// 必填校验
|
|
394
|
-
if (event && !rules?.trigger?.includes(event)) return
|
|
395
|
-
errorMessage = errorMsg(rules, value)
|
|
466
|
+
if (event && !rules?.trigger?.includes(event)) return;
|
|
467
|
+
errorMessage = errorMsg(rules, value);
|
|
396
468
|
}
|
|
397
469
|
|
|
398
470
|
// 自定义校验规则
|
|
@@ -403,61 +475,61 @@ const validateField = (
|
|
|
403
475
|
// }
|
|
404
476
|
// }
|
|
405
477
|
|
|
406
|
-
errors[field] = errorMessage
|
|
407
|
-
}
|
|
478
|
+
errors[field] = errorMessage;
|
|
479
|
+
};
|
|
408
480
|
|
|
409
481
|
/**
|
|
410
482
|
* @description 提交表单
|
|
411
483
|
* */
|
|
412
484
|
const handleSubmit = () => {
|
|
413
485
|
return new Promise((resolve, reject) => {
|
|
414
|
-
let isValid = true
|
|
486
|
+
let isValid = true;
|
|
415
487
|
|
|
416
488
|
// 校验所有字段
|
|
417
489
|
props.columns.forEach((col) => {
|
|
418
|
-
validateField(col.rules, formData.value[col.field], col.field)
|
|
490
|
+
validateField(col.rules, formData.value[col.field], col.field);
|
|
419
491
|
if (errors[col.field]) {
|
|
420
|
-
isValid = false
|
|
492
|
+
isValid = false;
|
|
421
493
|
}
|
|
422
|
-
})
|
|
494
|
+
});
|
|
423
495
|
|
|
424
496
|
if (isValid) {
|
|
425
497
|
// alert("表单提交成功!");
|
|
426
|
-
resolve(formData.value)
|
|
498
|
+
resolve(formData.value);
|
|
427
499
|
} else {
|
|
428
|
-
reject()
|
|
429
|
-
error(
|
|
500
|
+
reject();
|
|
501
|
+
error("表单校验失败,请检查输入!");
|
|
430
502
|
}
|
|
431
|
-
})
|
|
432
|
-
}
|
|
503
|
+
});
|
|
504
|
+
};
|
|
433
505
|
|
|
434
506
|
/**
|
|
435
507
|
* @description 输入值触发
|
|
436
508
|
* */
|
|
437
509
|
const handleChange = (event: string, temp: FormColumnsType) => {
|
|
438
510
|
if (isInput(temp.type) && temp?.input?.onChange) {
|
|
439
|
-
temp.input.onChange(event, temp)
|
|
511
|
+
temp.input.onChange(event, temp);
|
|
440
512
|
}
|
|
441
|
-
validateField(temp.rules, event, temp.field,
|
|
442
|
-
}
|
|
513
|
+
validateField(temp.rules, event, temp.field, "change");
|
|
514
|
+
};
|
|
443
515
|
/**
|
|
444
516
|
* @description 输入值触发
|
|
445
517
|
* */
|
|
446
518
|
const handleBlur = (event: string, temp: FormColumnsType) => {
|
|
447
519
|
if (isInput(temp.type) && temp?.input?.onBlur) {
|
|
448
|
-
temp.input.onBlur(event, temp)
|
|
520
|
+
temp.input.onBlur(event, temp);
|
|
449
521
|
}
|
|
450
|
-
validateField(temp.rules, event, temp.field,
|
|
451
|
-
}
|
|
522
|
+
validateField(temp.rules, event, temp.field, "blur");
|
|
523
|
+
};
|
|
452
524
|
|
|
453
525
|
defineExpose({
|
|
454
526
|
validateField,
|
|
455
527
|
handleSubmit,
|
|
456
|
-
})
|
|
528
|
+
});
|
|
457
529
|
</script>
|
|
458
530
|
|
|
459
531
|
<style lang="scss" scoped>
|
|
460
|
-
@import
|
|
532
|
+
@import "./index.scss";
|
|
461
533
|
.hy-form--item {
|
|
462
534
|
flex-direction: v-bind(labelPos);
|
|
463
535
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FormColumnsType } from "../../
|
|
1
|
+
import type { FormColumnsType } from "../../libs";
|
|
2
2
|
import type HyInputProps from "../hy-input/typing";
|
|
3
3
|
import type HyTextareaProps from "../hy-textarea/typing";
|
|
4
4
|
import type HySwitchProps from "../hy-switch/typing";
|
|
@@ -33,7 +33,7 @@ export default {
|
|
|
33
33
|
import { computed, inject, onMounted, onUnmounted, provide, ref } from "vue";
|
|
34
34
|
import type { PropType } from "vue";
|
|
35
35
|
import type { IFormContext } from "./typing";
|
|
36
|
-
import { addUnit } from "../../
|
|
36
|
+
import { addUnit } from "../../libs";
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* 表单组件子组件,需要搭配hy-form
|
|
@@ -49,7 +49,7 @@ export default {
|
|
|
49
49
|
import { computed } from "vue";
|
|
50
50
|
import type { CSSProperties, PropType } from "vue";
|
|
51
51
|
import type { CustomKeysVo, GridItemVo, IGridEmits } from "./typing";
|
|
52
|
-
import { addUnit } from "../../
|
|
52
|
+
import { addUnit } from "../../libs";
|
|
53
53
|
import type HyIconProps from "../hy-icon/typing";
|
|
54
54
|
// 组件
|
|
55
55
|
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
@@ -46,7 +46,7 @@ export default {
|
|
|
46
46
|
<script setup lang="ts">
|
|
47
47
|
import { computed } from "vue";
|
|
48
48
|
import type { PropType, CSSProperties } from "vue";
|
|
49
|
-
import { addUnit } from "../../
|
|
49
|
+
import { addUnit } from "../../libs";
|
|
50
50
|
import type { IIconEmits } from "./typing";
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -69,8 +69,7 @@ export default {
|
|
|
69
69
|
import { computed, onMounted, ref, watch } from "vue";
|
|
70
70
|
import type { PropType, CSSProperties } from "vue";
|
|
71
71
|
import type { IImageEmits } from "./typing";
|
|
72
|
-
import { addUnit, getPx } from "../../
|
|
73
|
-
import { IconConfig } from "../../config";
|
|
72
|
+
import { IconConfig, addUnit, getPx } from "../../libs";
|
|
74
73
|
// 组件
|
|
75
74
|
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
76
75
|
import HyTransition from "../hy-transition/hy-transition.vue";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type IProps from
|
|
2
|
-
import { IconConfig } from
|
|
1
|
+
import type IProps from "./typing";
|
|
2
|
+
import { IconConfig } from "../../libs/config";
|
|
3
3
|
|
|
4
4
|
const defaultProps: IProps = {
|
|
5
|
-
src:
|
|
6
|
-
mode:
|
|
7
|
-
width:
|
|
8
|
-
height:
|
|
9
|
-
shape:
|
|
5
|
+
src: "",
|
|
6
|
+
mode: "aspectFill",
|
|
7
|
+
width: "",
|
|
8
|
+
height: "",
|
|
9
|
+
shape: "square",
|
|
10
10
|
radius: 0,
|
|
11
11
|
lazyLoad: true,
|
|
12
12
|
showMenuByLongPress: true,
|
|
@@ -17,9 +17,9 @@ const defaultProps: IProps = {
|
|
|
17
17
|
fade: true,
|
|
18
18
|
webp: false,
|
|
19
19
|
duration: 500,
|
|
20
|
-
bgColor:
|
|
20
|
+
bgColor: "",
|
|
21
21
|
indistinct: false,
|
|
22
22
|
previewImage: false,
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
|
|
25
|
-
export default defaultProps
|
|
25
|
+
export default defaultProps;
|
|
@@ -113,8 +113,7 @@ export default {
|
|
|
113
113
|
import { computed, nextTick, ref, watch, inject } from "vue";
|
|
114
114
|
import type { CSSProperties, PropType } from "vue";
|
|
115
115
|
import HyIcon from "../hy-icon/hy-icon.vue";
|
|
116
|
-
import { addUnit, formatObject, sleep } from "../../
|
|
117
|
-
import { IconConfig } from "../../config";
|
|
116
|
+
import { addUnit, formatObject, sleep, IconConfig } from "../../libs";
|
|
118
117
|
import type { IInputEmits } from "./typing";
|
|
119
118
|
import type HyIconProps from "../hy-icon/typing";
|
|
120
119
|
import type { FormItemContext } from "../hy-form-item/typing";
|
|
@@ -16,7 +16,7 @@ export default {
|
|
|
16
16
|
<script setup lang="ts">
|
|
17
17
|
import { computed } from "vue";
|
|
18
18
|
import type { CSSProperties, PropType } from "vue";
|
|
19
|
-
import { addUnit } from "../../
|
|
19
|
+
import { addUnit } from "../../libs";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* 一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单。
|
|
@@ -40,12 +40,11 @@ import { computed, getCurrentInstance, onMounted, ref, watch } from "vue";
|
|
|
40
40
|
import type { CSSProperties, PropType } from "vue";
|
|
41
41
|
import {
|
|
42
42
|
addUnit,
|
|
43
|
-
getPx,
|
|
44
43
|
getRect,
|
|
45
44
|
range,
|
|
46
45
|
type RectResultType,
|
|
47
46
|
sleep,
|
|
48
|
-
} from "../../
|
|
47
|
+
} from "../../libs";
|
|
49
48
|
|
|
50
49
|
/**
|
|
51
50
|
* 展示操作或任务的当前进度,比如上传文件,是一个线形的进度条。
|
|
@@ -59,7 +59,7 @@ export default {
|
|
|
59
59
|
<script setup lang="ts">
|
|
60
60
|
import { ref, computed } from "vue";
|
|
61
61
|
import type { CSSProperties, PropType } from "vue";
|
|
62
|
-
import { addUnit, colorGradient } from "../../
|
|
62
|
+
import { addUnit, colorGradient } from "../../libs";
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* 目前用在华玥的loadMore加载更多等组件的正在加载状态场景。
|