hy-app 0.2.11 → 0.2.13
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/component-helper.ts +177 -0
- package/components/hy-action-sheet/hy-action-sheet.vue +9 -3
- package/components/hy-action-sheet/props.ts +2 -2
- package/components/hy-action-sheet/typing.d.ts +49 -16
- package/components/hy-button/hy-button.vue +144 -13
- package/components/hy-button/props.ts +158 -32
- package/components/hy-button/typing.d.ts +71 -32
- package/components/index.ts +114 -122
- package/components.json +3287 -0
- package/dist/attributes.json +1 -0
- package/dist/docs/components/hy-action-sheet/hy-action-sheet.md +41 -0
- package/dist/docs/components/hy-address-picker/hy-address-picker.md +25 -0
- package/dist/docs/components/hy-avatar/hy-avatar.md +19 -0
- package/dist/docs/components/hy-back-top/hy-back-top.md +19 -0
- package/dist/docs/components/hy-badge/hy-badge.md +13 -0
- package/dist/docs/components/hy-button/hy-button.md +61 -0
- package/dist/docs/components/hy-calendar/header.md +17 -0
- package/dist/docs/components/hy-calendar/hy-calendar.md +27 -0
- package/dist/docs/components/hy-calendar/month.md +38 -0
- package/dist/docs/components/hy-card/hy-card.md +24 -0
- package/dist/docs/components/hy-cell/hy-cell.md +26 -0
- package/dist/docs/components/hy-check-button/hy-check-button.md +14 -0
- package/dist/docs/components/hy-checkbox/hy-checkbox.md +21 -0
- package/dist/docs/components/hy-code-input/hy-code-input.md +15 -0
- package/dist/docs/components/hy-config-provider/hy-config-provider.md +13 -0
- package/dist/docs/components/hy-count-down/hy-count-down.md +34 -0
- package/dist/docs/components/hy-count-to/hy-count-to.md +31 -0
- package/dist/docs/components/hy-datetime-picker/hy-datetime-picker.md +25 -0
- package/dist/docs/components/hy-divider/hy-divider.md +13 -0
- package/dist/docs/components/hy-dropdown/hy-dropdown.md +13 -0
- package/dist/docs/components/hy-dropdown-item/hy-dropdown-item.md +20 -0
- package/dist/docs/components/hy-empty/hy-empty.md +20 -0
- package/dist/docs/components/hy-float-button/hy-float-button.md +20 -0
- package/dist/docs/components/hy-folding-panel/hy-folding-panel.md +24 -0
- package/dist/docs/components/hy-form/hy-form.md +29 -0
- package/dist/docs/components/hy-grid/hy-grid.md +19 -0
- package/dist/docs/components/hy-icon/hy-icon.md +13 -0
- package/dist/docs/components/hy-image/hy-image.md +22 -0
- package/dist/docs/components/hy-input/hy-input.md +29 -0
- package/dist/docs/components/hy-line/hy-line.md +7 -0
- package/dist/docs/components/hy-line-progress/hy-line-progress.md +13 -0
- package/dist/docs/components/hy-list/hy-list.md +25 -0
- package/dist/docs/components/hy-loading/hy-loading.md +14 -0
- package/dist/docs/components/hy-login/ThePhoneLogin.md +20 -0
- package/dist/docs/components/hy-login/TheUserLogin.md +44 -0
- package/dist/docs/components/hy-login/hy-login.md +14 -0
- package/dist/docs/components/hy-menu/hy-menu.md +21 -0
- package/dist/docs/components/hy-modal/hy-modal.md +23 -0
- package/dist/docs/components/hy-navbar/hy-navbar.md +22 -0
- package/dist/docs/components/hy-notice-bar/hy-column-notice.md +20 -0
- package/dist/docs/components/hy-notice-bar/hy-notice-bar.md +14 -0
- package/dist/docs/components/hy-notice-bar/hy-row-notice.md +20 -0
- package/dist/docs/components/hy-notify/hy-notify.md +23 -0
- package/dist/docs/components/hy-number-step/hy-number-step.md +27 -0
- package/dist/docs/components/hy-overlay/hy-overlay.md +19 -0
- package/dist/docs/components/hy-pagination/hy-pagination.md +14 -0
- package/dist/docs/components/hy-parse/hy-parse.md +46 -0
- package/dist/docs/components/hy-parse/node/node.md +7 -0
- package/dist/docs/components/hy-picker/hy-picker.md +32 -0
- package/dist/docs/components/hy-popover/hy-popover.md +34 -0
- package/dist/docs/components/hy-popup/hy-popup.md +22 -0
- package/dist/docs/components/hy-price/hy-price.md +13 -0
- package/dist/docs/components/hy-qrcode/hy-qrcode.md +15 -0
- package/dist/docs/components/hy-radio/hy-radio.md +21 -0
- package/dist/docs/components/hy-rate/hy-rate.md +14 -0
- package/dist/docs/components/hy-read-more/hy-read-more.md +21 -0
- package/dist/docs/components/hy-scroll-list/hy-scroll-list.md +21 -0
- package/dist/docs/components/hy-search/hy-search.md +27 -0
- package/dist/docs/components/hy-signature/hy-signature.md +45 -0
- package/dist/docs/components/hy-slider/hy-slider.md +24 -0
- package/dist/docs/components/hy-status-bar/hy-status-bar.md +13 -0
- package/dist/docs/components/hy-steps/hy-steps.md +23 -0
- package/dist/docs/components/hy-submit-bar/hy-submit-bar.md +21 -0
- package/dist/docs/components/hy-subsection/hy-subsection.md +14 -0
- package/dist/docs/components/hy-swipe-action/hy-swipe-action.md +29 -0
- package/dist/docs/components/hy-swiper/hy-swiper-indicator.md +23 -0
- package/dist/docs/components/hy-swiper/hy-swiper.md +22 -0
- package/dist/docs/components/hy-switch/hy-switch.md +20 -0
- package/dist/docs/components/hy-tabBar/hy-tabBar.md +13 -0
- package/dist/docs/components/hy-tabs/hy-tabs.md +27 -0
- package/dist/docs/components/hy-tag/hy-tag.md +21 -0
- package/dist/docs/components/hy-text/hy-text.md +13 -0
- package/dist/docs/components/hy-textarea/hy-textarea.md +19 -0
- package/dist/docs/components/hy-toast/hy-toast.md +17 -0
- package/dist/docs/components/hy-tooltip/hy-tooltip.md +13 -0
- package/dist/docs/components/hy-transition/hy-transition.md +25 -0
- package/dist/docs/components/hy-upload/hy-upload.md +25 -0
- package/dist/docs/components/hy-warn/hy-warn.md +14 -0
- package/dist/docs/components/hy-waterfall/hy-waterfall.md +30 -0
- package/dist/docs/components/hy-watermark/hy-watermark.md +7 -0
- package/dist/docs/components/message/TheMessage.md +17 -0
- package/dist/docs/components/yk-dialog/yk-dialog.md +7 -0
- package/dist/tags.json +1 -0
- package/dist/web-types.json +1 -0
- package/docgen.config.js +14 -0
- package/global.d.ts +101 -0
- package/package.json +29 -33
- package/web-types.config.js +7 -0
- package/web-types.json +1 -0
- package/components/dialog/TheDialog.vue +0 -128
- package/components/dialog/index.ts +0 -38
- package/components/hy-safe-bottom/hy-safe-bottom.vue +0 -60
- package/components/hy-safe-bottom/index.scss +0 -5
- package/components/message/TheMessage.vue +0 -169
- package/components/message/index.ts +0 -54
- package/components/u-form/form.js +0 -22
- package/components/u-form/hy-form.vue +0 -324
- package/components/u-form/props.js +0 -49
- package/components/u-form/schema.js +0 -1451
- package/components/u-form/u-form.vue +0 -267
- package/components/u-form/utils.js +0 -65
- package/components/u-form-item/formItem.js +0 -24
- package/components/u-form-item/hy-form-item.vue +0 -360
- package/components/u-form-item/props.js +0 -57
- package/components/u-form-item/u-form-item.vue +0 -294
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author : LQ
|
|
3
|
-
* @Description :
|
|
4
|
-
* @version : 1.0
|
|
5
|
-
* @Date : 2021-08-20 16:44:21
|
|
6
|
-
* @LastAuthor : LQ
|
|
7
|
-
* @lastTime : 2021-08-20 17:03:49
|
|
8
|
-
* @FilePath : /u-view2.0/uview-ui/libs/config/props/form.js
|
|
9
|
-
*/
|
|
10
|
-
export default {
|
|
11
|
-
// form 组件
|
|
12
|
-
form: {
|
|
13
|
-
model: {},
|
|
14
|
-
rules: {},
|
|
15
|
-
errorType: 'message',
|
|
16
|
-
borderBottom: true,
|
|
17
|
-
labelPosition: 'left',
|
|
18
|
-
labelWidth: 45,
|
|
19
|
-
labelAlign: 'left',
|
|
20
|
-
labelStyle: {}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,324 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="u-form">
|
|
3
|
-
<slot />
|
|
4
|
-
</view>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup>
|
|
8
|
-
// import { props } from "./props.js";
|
|
9
|
-
import Schema from "./schema";
|
|
10
|
-
import { getProperty, setProperty } from "./utils";
|
|
11
|
-
import { deepClone, error } from "../../utils";
|
|
12
|
-
import {
|
|
13
|
-
ref,
|
|
14
|
-
defineProps,
|
|
15
|
-
computed,
|
|
16
|
-
onMounted,
|
|
17
|
-
watch,
|
|
18
|
-
nextTick,
|
|
19
|
-
inject
|
|
20
|
-
} from "vue";
|
|
21
|
-
|
|
22
|
-
// 去除警告信息
|
|
23
|
-
Schema.warning = function () {};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Form 表单
|
|
27
|
-
* @description 此组件一般用于表单场景,可以配置Input输入框,Select弹出框,进行表单验证等。
|
|
28
|
-
* @tutorial https://ijry.github.io/uview-plus/components/form.html
|
|
29
|
-
* @property {Object} model 当前form的需要验证字段的集合
|
|
30
|
-
* @property {Object | Function | Array} rules 验证规则
|
|
31
|
-
* @property {String} errorType 错误的提示方式,见上方说明 ( 默认 message )
|
|
32
|
-
* @property {Boolean} borderBottom 是否显示表单域的下划线边框 ( 默认 true )
|
|
33
|
-
* @property {String} labelPosition 表单域提示文字的位置,left-左侧,top-上方 ( 默认 'left' )
|
|
34
|
-
* @property {String | Number} labelWidth 提示文字的宽度,单位px ( 默认 45 )
|
|
35
|
-
* @property {String} labelAlign lable字体的对齐方式 ( 默认 ‘left' )
|
|
36
|
-
* @property {Object} labelStyle lable的样式,对象形式
|
|
37
|
-
* @example <up-formlabelPosition="left" :model="model1" :rules="rules" ref="form1"></up-form>
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
import defProps from "./form";
|
|
41
|
-
const props = defineProps({
|
|
42
|
-
// 当前form的需要验证字段的集合
|
|
43
|
-
model: {
|
|
44
|
-
type: Object,
|
|
45
|
-
default: () => defProps.form.model
|
|
46
|
-
},
|
|
47
|
-
// 验证规则
|
|
48
|
-
rules: {
|
|
49
|
-
type: [Object, Function, Array],
|
|
50
|
-
default: () => defProps.form.rules
|
|
51
|
-
},
|
|
52
|
-
// 有错误时的提示方式,message-提示信息,toast-进行toast提示
|
|
53
|
-
// border-bottom-下边框呈现红色,none-无提示
|
|
54
|
-
errorType: {
|
|
55
|
-
type: String,
|
|
56
|
-
default: () => defProps.form.errorType
|
|
57
|
-
},
|
|
58
|
-
// 是否显示表单域的下划线边框
|
|
59
|
-
borderBottom: {
|
|
60
|
-
type: Boolean,
|
|
61
|
-
default: () => defProps.form.borderBottom
|
|
62
|
-
},
|
|
63
|
-
// label的位置,left-左边,top-上边
|
|
64
|
-
labelPosition: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: () => defProps.form.labelPosition
|
|
67
|
-
},
|
|
68
|
-
// label的宽度,单位px
|
|
69
|
-
labelWidth: {
|
|
70
|
-
type: [String, Number],
|
|
71
|
-
default: () => defProps.form.labelWidth
|
|
72
|
-
},
|
|
73
|
-
// lable字体的对齐方式
|
|
74
|
-
labelAlign: {
|
|
75
|
-
type: String,
|
|
76
|
-
default: () => defProps.form.labelAlign
|
|
77
|
-
},
|
|
78
|
-
// lable的样式,对象形式
|
|
79
|
-
labelStyle: {
|
|
80
|
-
type: Object,
|
|
81
|
-
default: () => defProps.form.labelStyle
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// 响应式数据
|
|
86
|
-
const formRules = ref({});
|
|
87
|
-
const validator = ref(null);
|
|
88
|
-
const originalModel = ref(null);
|
|
89
|
-
const children = ref([]);
|
|
90
|
-
|
|
91
|
-
const formItemRef = inject("formItemRef");
|
|
92
|
-
|
|
93
|
-
// 手动设置校验的规则,如果规则中有函数的话,微信小程序中会过滤掉,所以只能手动调用设置规则
|
|
94
|
-
const setRules = (rules) => {
|
|
95
|
-
// 判断是否有规则
|
|
96
|
-
if (Object.keys(rules).length === 0) return;
|
|
97
|
-
if (
|
|
98
|
-
process.env.NODE_ENV === "development" &&
|
|
99
|
-
Object.keys(props.model).length === 0
|
|
100
|
-
) {
|
|
101
|
-
error("设置rules,model必须设置!如果已经设置,请刷新页面。");
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
formRules.value = rules;
|
|
105
|
-
// 重新将规则赋予Validator
|
|
106
|
-
validator.value = new Schema(rules);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// 监听规则的变化
|
|
110
|
-
watch(
|
|
111
|
-
() => props.rules,
|
|
112
|
-
(n) => {
|
|
113
|
-
setRules(n);
|
|
114
|
-
},
|
|
115
|
-
{ immediate: true }
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
// 监听属性的变化,通知子组件u-form-item重新获取信息
|
|
119
|
-
const propsChange = computed(() => {
|
|
120
|
-
return [
|
|
121
|
-
props.errorType,
|
|
122
|
-
props.borderBottom,
|
|
123
|
-
props.labelPosition,
|
|
124
|
-
props.labelWidth,
|
|
125
|
-
props.labelAlign,
|
|
126
|
-
props.labelStyle
|
|
127
|
-
];
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
watch(propsChange.value, (n) => {
|
|
131
|
-
if (children.value?.length) {
|
|
132
|
-
children.value.forEach((child) => {
|
|
133
|
-
// 判断子组件(u-form-item)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值)
|
|
134
|
-
typeof child.updateParentData === "function" && child.updateParentData();
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// 监听model的初始值作为重置表单的快照
|
|
140
|
-
watch(
|
|
141
|
-
() => props.model,
|
|
142
|
-
(n) => {
|
|
143
|
-
if (!originalModel.value) {
|
|
144
|
-
originalModel.value = deepClone(n);
|
|
145
|
-
}
|
|
146
|
-
},
|
|
147
|
-
{ immediate: true }
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
// 清空所有u-form-item组件的内容,本质上是调用了u-form-item组件中的resetField()方法
|
|
151
|
-
const resetFields = () => {
|
|
152
|
-
resetModel();
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
// 重置model为初始值的快照
|
|
156
|
-
const resetModel = (obj) => {
|
|
157
|
-
// 历遍所有u-form-item,根据其prop属性,还原model的原始快照
|
|
158
|
-
children.value.forEach((child) => {
|
|
159
|
-
const prop = child?.prop;
|
|
160
|
-
const value = getProperty(originalModel.value, prop);
|
|
161
|
-
setProperty(props.model, prop, value);
|
|
162
|
-
});
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
// 清空校验结果
|
|
166
|
-
const clearValidate = (props) => {
|
|
167
|
-
props = [].concat(props);
|
|
168
|
-
formItemRef.children.forEach((child) => {
|
|
169
|
-
// 如果u-form-item的prop在props数组中,则清除对应的校验结果信息
|
|
170
|
-
if (props[0] === undefined || props.includes(child.prop)) {
|
|
171
|
-
child.message = null;
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
// 对部分表单字段进行校验
|
|
177
|
-
const validateField = async (value, callback, event = null, options) => {
|
|
178
|
-
// $nextTick是必须的,否则model的变更,可能会延后于此方法的执行
|
|
179
|
-
await nextTick();
|
|
180
|
-
// 校验错误信息,返回给回调方法,用于存放所有form-item的错误信息
|
|
181
|
-
const errorsRes = [];
|
|
182
|
-
// 如果为字符串,转为数组
|
|
183
|
-
value = [].concat(value);
|
|
184
|
-
// 历遍children所有子form-item
|
|
185
|
-
const promises = formItemRef.children.map((child) => {
|
|
186
|
-
return new Promise((resolve, reject) => {
|
|
187
|
-
// 用于存放form-item的错误信息
|
|
188
|
-
const childErrors = [];
|
|
189
|
-
if (value.includes(child.prop)) {
|
|
190
|
-
// 获取对应的属性,通过类似'a.b.c'的形式
|
|
191
|
-
const propertyVal = getProperty(props.model, child.prop);
|
|
192
|
-
// 属性链数组
|
|
193
|
-
const propertyChain = child.prop.split(".");
|
|
194
|
-
const propertyName = propertyChain[propertyChain.length - 1];
|
|
195
|
-
|
|
196
|
-
let rule = [];
|
|
197
|
-
if (child.itemRules && child.itemRules.length > 0) {
|
|
198
|
-
rule = child.itemRules;
|
|
199
|
-
} else {
|
|
200
|
-
rule = formRules.value[child.prop];
|
|
201
|
-
}
|
|
202
|
-
// 如果不存在对应的规则,直接返回,否则校验器会报错
|
|
203
|
-
if (!rule) {
|
|
204
|
-
resolve();
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
// rule规则可为数组形式,也可为对象形式,此处拼接成为数组
|
|
208
|
-
const rules = [].concat(rule);
|
|
209
|
-
|
|
210
|
-
// 对rules数组进行校验
|
|
211
|
-
if (!rules.length) {
|
|
212
|
-
resolve();
|
|
213
|
-
}
|
|
214
|
-
for (let i = 0; i < rules.length; i++) {
|
|
215
|
-
const ruleItem = rules[i];
|
|
216
|
-
// 将u-form-item的触发器转为数组形式
|
|
217
|
-
const trigger = [].concat(ruleItem?.trigger);
|
|
218
|
-
// 如果是有传入触发事件,但是此form-item却没有配置此触发器的话,不执行校验操作
|
|
219
|
-
if (event && !trigger.includes(event)) {
|
|
220
|
-
resolve();
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
// 实例化校验对象,传入构造规则
|
|
224
|
-
const validator = new Schema({
|
|
225
|
-
[propertyName]: ruleItem
|
|
226
|
-
});
|
|
227
|
-
validator.validate(
|
|
228
|
-
{
|
|
229
|
-
[propertyName]: propertyVal
|
|
230
|
-
},
|
|
231
|
-
(errors, fields) => {
|
|
232
|
-
if (Array.isArray(errors)) {
|
|
233
|
-
errors.forEach((element) => {
|
|
234
|
-
element.prop = child.prop;
|
|
235
|
-
});
|
|
236
|
-
errorsRes.push(...errors);
|
|
237
|
-
childErrors.push(...errors);
|
|
238
|
-
}
|
|
239
|
-
//没有配置,或者配置了showErrorMsg为true时候,才修改子组件message,默认没有配置
|
|
240
|
-
if (!options || options?.showErrorMsg === true) {
|
|
241
|
-
child.message = childErrors[0]?.message
|
|
242
|
-
? childErrors[0].message
|
|
243
|
-
: null;
|
|
244
|
-
}
|
|
245
|
-
if (i === rules.length - 1) {
|
|
246
|
-
resolve(errorsRes);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
);
|
|
250
|
-
}
|
|
251
|
-
} else {
|
|
252
|
-
resolve({});
|
|
253
|
-
}
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
// 使用Promise.all来等待所有Promise完成
|
|
258
|
-
Promise.all(promises)
|
|
259
|
-
.then((results) => {
|
|
260
|
-
// 执行回调函数
|
|
261
|
-
typeof callback === "function" && callback(errorsRes);
|
|
262
|
-
})
|
|
263
|
-
.catch((error) => {
|
|
264
|
-
console.error("An error occurred:", error);
|
|
265
|
-
});
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// 校验全部数据
|
|
269
|
-
const validate = (options) => {
|
|
270
|
-
// 开发环境才提示,生产环境不会提示
|
|
271
|
-
if (
|
|
272
|
-
process.env.NODE_ENV === "development" &&
|
|
273
|
-
Object.keys(formRules.value).length === 0
|
|
274
|
-
) {
|
|
275
|
-
error("未设置rules,请看文档说明!如果已经设置,请刷新页面。");
|
|
276
|
-
return;
|
|
277
|
-
}
|
|
278
|
-
return new Promise((resolve, reject) => {
|
|
279
|
-
console.log(formItemRef);
|
|
280
|
-
// $nextTick是必须的,否则model的变更,可能会延后于validate方法
|
|
281
|
-
nextTick(() => {
|
|
282
|
-
// 获取所有form-item的prop,交给validateField方法进行校验
|
|
283
|
-
const formItemProps = formItemRef.children.map((item) => item.prop);
|
|
284
|
-
// console.log(formItemProps)
|
|
285
|
-
validateField(
|
|
286
|
-
formItemProps,
|
|
287
|
-
(errors) => {
|
|
288
|
-
if (errors.length) {
|
|
289
|
-
// 如果错误提示方式为toast,则进行提示
|
|
290
|
-
props.errorType === "toast" &&
|
|
291
|
-
uni.showToast({
|
|
292
|
-
title: String(errors[0].message),
|
|
293
|
-
icon: "none"
|
|
294
|
-
});
|
|
295
|
-
reject(errors);
|
|
296
|
-
} else {
|
|
297
|
-
resolve(true);
|
|
298
|
-
}
|
|
299
|
-
},
|
|
300
|
-
null,
|
|
301
|
-
options
|
|
302
|
-
);
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
};
|
|
306
|
-
|
|
307
|
-
// 存储当前form下的所有u-form-item的实例
|
|
308
|
-
// 不能定义在data中,否则微信小程序会造成循环引用而报错
|
|
309
|
-
onMounted(() => {
|
|
310
|
-
children.value = [];
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
// 提供给子组件使用
|
|
314
|
-
defineExpose({
|
|
315
|
-
setRules,
|
|
316
|
-
resetFields,
|
|
317
|
-
resetModel,
|
|
318
|
-
clearValidate,
|
|
319
|
-
validateField,
|
|
320
|
-
validate
|
|
321
|
-
});
|
|
322
|
-
</script>
|
|
323
|
-
|
|
324
|
-
<style lang="scss" scoped></style>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export const defineMixin = (options) => {
|
|
2
|
-
return options;
|
|
3
|
-
};
|
|
4
|
-
import defProps from "./form";
|
|
5
|
-
export const props = defineMixin({
|
|
6
|
-
props: {
|
|
7
|
-
// 当前form的需要验证字段的集合
|
|
8
|
-
model: {
|
|
9
|
-
type: Object,
|
|
10
|
-
default: () => defProps.form.model
|
|
11
|
-
},
|
|
12
|
-
// 验证规则
|
|
13
|
-
rules: {
|
|
14
|
-
type: [Object, Function, Array],
|
|
15
|
-
default: () => defProps.form.rules
|
|
16
|
-
},
|
|
17
|
-
// 有错误时的提示方式,message-提示信息,toast-进行toast提示
|
|
18
|
-
// border-bottom-下边框呈现红色,none-无提示
|
|
19
|
-
errorType: {
|
|
20
|
-
type: String,
|
|
21
|
-
default: () => defProps.form.errorType
|
|
22
|
-
},
|
|
23
|
-
// 是否显示表单域的下划线边框
|
|
24
|
-
borderBottom: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
default: () => defProps.form.borderBottom
|
|
27
|
-
},
|
|
28
|
-
// label的位置,left-左边,top-上边
|
|
29
|
-
labelPosition: {
|
|
30
|
-
type: String,
|
|
31
|
-
default: () => defProps.form.labelPosition
|
|
32
|
-
},
|
|
33
|
-
// label的宽度,单位px
|
|
34
|
-
labelWidth: {
|
|
35
|
-
type: [String, Number],
|
|
36
|
-
default: () => defProps.form.labelWidth
|
|
37
|
-
},
|
|
38
|
-
// lable字体的对齐方式
|
|
39
|
-
labelAlign: {
|
|
40
|
-
type: String,
|
|
41
|
-
default: () => defProps.form.labelAlign
|
|
42
|
-
},
|
|
43
|
-
// lable的样式,对象形式
|
|
44
|
-
labelStyle: {
|
|
45
|
-
type: Object,
|
|
46
|
-
default: () => defProps.form.labelStyle
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|