@kengic/uni 0.5.1 → 0.5.2-beta.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.
Files changed (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,398 +1,386 @@
1
1
  <template>
2
- <view class="uni-forms">
3
- <form>
4
- <slot></slot>
5
- </form>
6
- </view>
2
+ <view class="uni-forms">
3
+ <form>
4
+ <slot></slot>
5
+ </form>
6
+ </view>
7
7
  </template>
8
8
 
9
9
  <script>
10
- import Validator from './validate.js';
11
- import { defineComponent } from 'vue';
12
- import {
13
- deepCopy,
14
- getValue,
15
- isRequiredField,
16
- setDataValue,
17
- getDataValue,
18
- realName,
19
- isRealName,
20
- rawData,
21
- isEqual
22
- } from './utils.js'
10
+ import Validator from './validate.js';
11
+ // #ifndef VUE3
12
+ // 后续会慢慢废弃这个方法
13
+ import Vue, { defineComponent } from 'vue';
14
+ import { deepCopy, getDataValue, getValue, isEqual, isRealName, isRequiredField, rawData, realName, setDataValue } from './utils.js';
23
15
 
24
- // #ifndef VUE3
25
- // 后续会慢慢废弃这个方法
26
- import Vue from 'vue';
27
- Vue.prototype.binddata = function(name, value, formName) {
28
- if (formName) {
29
- this.$refs[formName].setValue(name, value);
30
- } else {
31
- let formVm;
32
- for (let i in this.$refs) {
33
- const vm = this.$refs[i];
34
- if (vm && vm.$options && vm.$options.name === 'uniForms') {
35
- formVm = vm;
36
- break;
37
- }
38
- }
39
- if (!formVm) return console.error('当前 uni-froms 组件缺少 ref 属性');
40
- formVm.setValue(name, value);
41
- }
42
- };
43
- // #endif
44
- /**
45
- * Forms 表单
46
- * @description 由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据
47
- * @tutorial https://ext.dcloud.net.cn/plugin?id=2773
48
- * @property {Object} rules 表单校验规则
49
- * @property {String} validateTrigger = [bind|submit|blur] 校验触发器方式 默认 submit
50
- * @value bind 发生变化时触发
51
- * @value submit 提交时触发
52
- * @value blur 失去焦点时触发
53
- * @property {String} labelPosition = [top|left] label 位置 默认 left
54
- * @value top 顶部显示 label
55
- * @value left 左侧显示 label
56
- * @property {String} labelWidth label 宽度,默认 65px
57
- * @property {String} labelAlign = [left|center|right] label 居中方式 默认 left
58
- * @value left label 左侧显示
59
- * @value center label 居中
60
- * @value right label 右侧对齐
61
- * @property {String} errShowType = [undertext|toast|modal] 校验错误信息提示方式
62
- * @value undertext 错误信息在底部显示
63
- * @value toast 错误信息toast显示
64
- * @value modal 错误信息modal显示
65
- * @event {Function} submit 提交时触发
66
- * @event {Function} validate 校验结果发生变化触发
67
- */
68
- export default defineComponent({
69
- name: 'UniForms',
70
- emits: ['validate', 'submit'],
71
- options: {
72
- virtualHost: true
73
- },
74
- props: {
75
- // 即将弃用
76
- value: {
77
- type: Object,
78
- default () {
79
- return null;
80
- }
81
- },
82
- // vue3 替换 value 属性
83
- modelValue: {
84
- type: Object,
85
- default () {
86
- return null;
87
- }
88
- },
89
- // 1.4.0 开始将不支持 v-model ,且废弃 value 和 modelValue
90
- model: {
91
- type: Object,
92
- default () {
93
- return null;
94
- }
95
- },
96
- // 表单校验规则
97
- rules: {
98
- type: Object,
99
- default () {
100
- return {};
101
- }
102
- },
103
- //校验错误信息提示方式 默认 undertext 取值 [undertext|toast|modal]
104
- errShowType: {
105
- type: String,
106
- default: 'undertext'
107
- },
108
- // 校验触发器方式 默认 bind 取值 [bind|submit]
109
- validateTrigger: {
110
- type: String,
111
- default: 'submit'
112
- },
113
- // label 位置,默认 left 取值 top/left
114
- labelPosition: {
115
- type: String,
116
- default: 'left'
117
- },
118
- // label 宽度
119
- labelWidth: {
120
- type: [String, Number],
121
- default: ''
122
- },
123
- // label 居中方式,默认 left 取值 left/center/right
124
- labelAlign: {
125
- type: String,
126
- default: 'left'
127
- },
128
- border: {
129
- type: Boolean,
130
- default: false
131
- }
132
- },
133
- provide() {
134
- return {
135
- uniForm: this
136
- }
137
- },
138
- data() {
139
- return {
140
- // 表单本地值的记录,不应该与传如的值进行关联
141
- formData: {},
142
- formRules: {}
143
- };
144
- },
145
- computed: {
146
- // 计算数据源变化的
147
- localData() {
148
- const localVal = this.model || this.modelValue || this.value
149
- if (localVal) {
150
- return deepCopy(localVal)
151
- }
152
- return {}
153
- }
154
- },
155
- watch: {
156
- // 监听数据变化 ,暂时不使用,需要单独赋值
157
- // localData: {},
158
- // 监听规则变化
159
- rules: {
160
- handler: function(val, oldVal) {
161
- this.setRules(val)
162
- },
163
- deep: true,
164
- immediate: true
165
- }
166
- },
167
- created() {
168
- // #ifdef VUE3
169
- let getbinddata = getApp().$vm.$.appContext.config.globalProperties.binddata
170
- if (!getbinddata) {
171
- getApp().$vm.$.appContext.config.globalProperties.binddata = function(name, value, formName) {
172
- if (formName) {
173
- this.$refs[formName].setValue(name, value);
174
- } else {
175
- let formVm;
176
- for (let i in this.$refs) {
177
- const vm = this.$refs[i];
178
- if (vm && vm.$options && vm.$options.name === 'uniForms') {
179
- formVm = vm;
180
- break;
181
- }
182
- }
183
- if (!formVm) return console.error('当前 uni-froms 组件缺少 ref 属性');
184
- formVm.setValue(name, value);
185
- }
186
- }
187
- }
188
- // #endif
16
+ Vue.prototype.binddata = function (name, value, formName) {
17
+ if (formName) {
18
+ this.$refs[formName].setValue(name, value);
19
+ } else {
20
+ let formVm;
21
+ for (let i in this.$refs) {
22
+ const vm = this.$refs[i];
23
+ if (vm && vm.$options && vm.$options.name === 'uniForms') {
24
+ formVm = vm;
25
+ break;
26
+ }
27
+ }
28
+ if (!formVm) return console.error('当前 uni-froms 组件缺少 ref 属性');
29
+ formVm.setValue(name, value);
30
+ }
31
+ };
32
+ // #endif
33
+ /**
34
+ * Forms 表单
35
+ * @description 由输入框、选择器、单选框、多选框等控件组成,用以收集、校验、提交数据
36
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=2773
37
+ * @property {Object} rules 表单校验规则
38
+ * @property {String} validateTrigger = [bind|submit|blur] 校验触发器方式 默认 submit
39
+ * @value bind 发生变化时触发
40
+ * @value submit 提交时触发
41
+ * @value blur 失去焦点时触发
42
+ * @property {String} labelPosition = [top|left] label 位置 默认 left
43
+ * @value top 顶部显示 label
44
+ * @value left 左侧显示 label
45
+ * @property {String} labelWidth label 宽度,默认 65px
46
+ * @property {String} labelAlign = [left|center|right] label 居中方式 默认 left
47
+ * @value left label 左侧显示
48
+ * @value center label 居中
49
+ * @value right label 右侧对齐
50
+ * @property {String} errShowType = [undertext|toast|modal] 校验错误信息提示方式
51
+ * @value undertext 错误信息在底部显示
52
+ * @value toast 错误信息toast显示
53
+ * @value modal 错误信息modal显示
54
+ * @event {Function} submit 提交时触发
55
+ * @event {Function} validate 校验结果发生变化触发
56
+ */
57
+ export default defineComponent({
58
+ name: 'UniForms',
59
+ emits: ['validate', 'submit'],
60
+ options: {
61
+ virtualHost: true,
62
+ },
63
+ props: {
64
+ // 即将弃用
65
+ value: {
66
+ type: Object,
67
+ default() {
68
+ return null;
69
+ },
70
+ },
71
+ // vue3 替换 value 属性
72
+ modelValue: {
73
+ type: Object,
74
+ default() {
75
+ return null;
76
+ },
77
+ },
78
+ // 1.4.0 开始将不支持 v-model ,且废弃 value 和 modelValue
79
+ model: {
80
+ type: Object,
81
+ default() {
82
+ return null;
83
+ },
84
+ },
85
+ // 表单校验规则
86
+ rules: {
87
+ type: Object,
88
+ default() {
89
+ return {};
90
+ },
91
+ },
92
+ //校验错误信息提示方式 默认 undertext 取值 [undertext|toast|modal]
93
+ errShowType: {
94
+ type: String,
95
+ default: 'undertext',
96
+ },
97
+ // 校验触发器方式 默认 bind 取值 [bind|submit]
98
+ validateTrigger: {
99
+ type: String,
100
+ default: 'submit',
101
+ },
102
+ // label 位置,默认 left 取值 top/left
103
+ labelPosition: {
104
+ type: String,
105
+ default: 'left',
106
+ },
107
+ // label 宽度
108
+ labelWidth: {
109
+ type: [String, Number],
110
+ default: '',
111
+ },
112
+ // label 居中方式,默认 left 取值 left/center/right
113
+ labelAlign: {
114
+ type: String,
115
+ default: 'left',
116
+ },
117
+ border: {
118
+ type: Boolean,
119
+ default: false,
120
+ },
121
+ },
122
+ provide() {
123
+ return {
124
+ uniForm: this,
125
+ };
126
+ },
127
+ data() {
128
+ return {
129
+ // 表单本地值的记录,不应该与传如的值进行关联
130
+ formData: {},
131
+ formRules: {},
132
+ };
133
+ },
134
+ computed: {
135
+ // 计算数据源变化的
136
+ localData() {
137
+ const localVal = this.model || this.modelValue || this.value;
138
+ if (localVal) {
139
+ return deepCopy(localVal);
140
+ }
141
+ return {};
142
+ },
143
+ },
144
+ watch: {
145
+ // 监听数据变化 ,暂时不使用,需要单独赋值
146
+ // localData: {},
147
+ // 监听规则变化
148
+ rules: {
149
+ handler: function (val, oldVal) {
150
+ this.setRules(val);
151
+ },
152
+ deep: true,
153
+ immediate: true,
154
+ },
155
+ },
156
+ created() {
157
+ // #ifdef VUE3
158
+ let getbinddata = getApp().$vm.$.appContext.config.globalProperties.binddata;
159
+ if (!getbinddata) {
160
+ getApp().$vm.$.appContext.config.globalProperties.binddata = function (name, value, formName) {
161
+ if (formName) {
162
+ this.$refs[formName].setValue(name, value);
163
+ } else {
164
+ let formVm;
165
+ for (let i in this.$refs) {
166
+ const vm = this.$refs[i];
167
+ if (vm && vm.$options && vm.$options.name === 'uniForms') {
168
+ formVm = vm;
169
+ break;
170
+ }
171
+ }
172
+ if (!formVm) return console.error('当前 uni-froms 组件缺少 ref 属性');
173
+ formVm.setValue(name, value);
174
+ }
175
+ };
176
+ }
177
+ // #endif
189
178
 
190
- // 子组件实例数组
191
- this.childrens = []
192
- // TODO 兼容旧版 uni-data-picker ,新版本中无效,只是避免报错
193
- this.inputChildrens = []
194
- this.setRules(this.rules)
195
- },
196
- methods: {
197
- /**
198
- * 外部调用方法
199
- * 设置规则 ,主要用于小程序自定义检验规则
200
- * @param {Array} rules 规则源数据
201
- */
202
- setRules(rules) {
203
- // TODO 有可能子组件合并规则的时机比这个要早,所以需要合并对象 ,而不是直接赋值,可能会被覆盖
204
- this.formRules = Object.assign({}, this.formRules, rules)
205
- // 初始化校验函数
206
- this.validator = new Validator(rules);
207
- },
179
+ // 子组件实例数组
180
+ this.childrens = [];
181
+ // TODO 兼容旧版 uni-data-picker ,新版本中无效,只是避免报错
182
+ this.inputChildrens = [];
183
+ this.setRules(this.rules);
184
+ },
185
+ methods: {
186
+ /**
187
+ * 外部调用方法
188
+ * 设置规则 ,主要用于小程序自定义检验规则
189
+ * @param {Array} rules 规则源数据
190
+ */
191
+ setRules(rules) {
192
+ // TODO 有可能子组件合并规则的时机比这个要早,所以需要合并对象 ,而不是直接赋值,可能会被覆盖
193
+ this.formRules = Object.assign({}, this.formRules, rules);
194
+ // 初始化校验函数
195
+ this.validator = new Validator(rules);
196
+ },
208
197
 
209
- /**
210
- * 外部调用方法
211
- * 设置数据,用于设置表单数据,公开给用户使用 , 不支持在动态表单中使用
212
- * @param {Object} key
213
- * @param {Object} value
214
- */
215
- setValue(key, value) {
216
- let example = this.childrens.find(child => child.name === key);
217
- if (!example) return null;
218
- this.formData[key] = getValue(key, value, (this.formRules[key] && this.formRules[key].rules) || [])
219
- return example.onFieldChange(this.formData[key]);
220
- },
198
+ /**
199
+ * 外部调用方法
200
+ * 设置数据,用于设置表单数据,公开给用户使用 , 不支持在动态表单中使用
201
+ * @param {Object} key
202
+ * @param {Object} value
203
+ */
204
+ setValue(key, value) {
205
+ let example = this.childrens.find((child) => child.name === key);
206
+ if (!example) return null;
207
+ this.formData[key] = getValue(key, value, (this.formRules[key] && this.formRules[key].rules) || []);
208
+ return example.onFieldChange(this.formData[key]);
209
+ },
221
210
 
222
- /**
223
- * 外部调用方法
224
- * 手动提交校验表单
225
- * 对整个表单进行校验的方法,参数为一个回调函数。
226
- * @param {Array} keepitem 保留不参与校验的字段
227
- * @param {type} callback 方法回调
228
- */
229
- validate(keepitem, callback) {
230
- return this.checkAll(this.formData, keepitem, callback);
231
- },
211
+ /**
212
+ * 外部调用方法
213
+ * 手动提交校验表单
214
+ * 对整个表单进行校验的方法,参数为一个回调函数。
215
+ * @param {Array} keepitem 保留不参与校验的字段
216
+ * @param {type} callback 方法回调
217
+ */
218
+ validate(keepitem, callback) {
219
+ return this.checkAll(this.formData, keepitem, callback);
220
+ },
232
221
 
233
- /**
234
- * 外部调用方法
235
- * 部分表单校验
236
- * @param {Array|String} props 需要校验的字段
237
- * @param {Function} 回调函数
238
- */
239
- validateField(props = [], callback) {
240
- props = [].concat(props);
241
- let invalidFields = {};
242
- this.childrens.forEach(item => {
243
- const name = realName(item.name)
244
- if (props.indexOf(name) !== -1) {
245
- invalidFields = Object.assign({}, invalidFields, {
246
- [name]: this.formData[name]
247
- });
248
- }
249
- });
250
- return this.checkAll(invalidFields, [], callback);
251
- },
222
+ /**
223
+ * 外部调用方法
224
+ * 部分表单校验
225
+ * @param {Array|String} props 需要校验的字段
226
+ * @param {Function} 回调函数
227
+ */
228
+ validateField(props = [], callback) {
229
+ props = [].concat(props);
230
+ let invalidFields = {};
231
+ this.childrens.forEach((item) => {
232
+ const name = realName(item.name);
233
+ if (props.indexOf(name) !== -1) {
234
+ invalidFields = Object.assign({}, invalidFields, {
235
+ [name]: this.formData[name],
236
+ });
237
+ }
238
+ });
239
+ return this.checkAll(invalidFields, [], callback);
240
+ },
252
241
 
253
- /**
254
- * 外部调用方法
255
- * 移除表单项的校验结果。传入待移除的表单项的 prop 属性或者 prop 组成的数组,如不传则移除整个表单的校验结果
256
- * @param {Array|String} props 需要移除校验的字段 ,不填为所有
257
- */
258
- clearValidate(props = []) {
259
- props = [].concat(props);
260
- this.childrens.forEach(item => {
261
- if (props.length === 0) {
262
- item.errMsg = '';
263
- } else {
264
- const name = realName(item.name)
265
- if (props.indexOf(name) !== -1) {
266
- item.errMsg = '';
267
- }
268
- }
269
- });
270
- },
242
+ /**
243
+ * 外部调用方法
244
+ * 移除表单项的校验结果。传入待移除的表单项的 prop 属性或者 prop 组成的数组,如不传则移除整个表单的校验结果
245
+ * @param {Array|String} props 需要移除校验的字段 ,不填为所有
246
+ */
247
+ clearValidate(props = []) {
248
+ props = [].concat(props);
249
+ this.childrens.forEach((item) => {
250
+ if (props.length === 0) {
251
+ item.errMsg = '';
252
+ } else {
253
+ const name = realName(item.name);
254
+ if (props.indexOf(name) !== -1) {
255
+ item.errMsg = '';
256
+ }
257
+ }
258
+ });
259
+ },
271
260
 
272
- /**
273
- * 外部调用方法 ,即将废弃
274
- * 手动提交校验表单
275
- * 对整个表单进行校验的方法,参数为一个回调函数。
276
- * @param {Array} keepitem 保留不参与校验的字段
277
- * @param {type} callback 方法回调
278
- */
279
- submit(keepitem, callback, type) {
280
- for (let i in this.dataValue) {
281
- const itemData = this.childrens.find(v => v.name === i);
282
- if (itemData) {
283
- if (this.formData[i] === undefined) {
284
- this.formData[i] = this._getValue(i, this.dataValue[i]);
285
- }
286
- }
287
- }
261
+ /**
262
+ * 外部调用方法 ,即将废弃
263
+ * 手动提交校验表单
264
+ * 对整个表单进行校验的方法,参数为一个回调函数。
265
+ * @param {Array} keepitem 保留不参与校验的字段
266
+ * @param {type} callback 方法回调
267
+ */
268
+ submit(keepitem, callback, type) {
269
+ for (let i in this.dataValue) {
270
+ const itemData = this.childrens.find((v) => v.name === i);
271
+ if (itemData) {
272
+ if (this.formData[i] === undefined) {
273
+ this.formData[i] = this._getValue(i, this.dataValue[i]);
274
+ }
275
+ }
276
+ }
288
277
 
289
- if (!type) {
290
- console.warn('submit 方法即将废弃,请使用validate方法代替!');
291
- }
278
+ if (!type) {
279
+ console.warn('submit 方法即将废弃,请使用validate方法代替!');
280
+ }
292
281
 
293
- return this.checkAll(this.formData, keepitem, callback, 'submit');
294
- },
282
+ return this.checkAll(this.formData, keepitem, callback, 'submit');
283
+ },
295
284
 
296
- // 校验所有
297
- async checkAll(invalidFields, keepitem, callback, type) {
298
- // 不存在校验规则 ,则停止校验流程
299
- if (!this.validator) return
300
- let childrens = []
301
- // 处理参与校验的item实例
302
- for (let i in invalidFields) {
303
- const item = this.childrens.find(v => realName(v.name) === i)
304
- if (item) {
305
- childrens.push(item)
306
- }
307
- }
285
+ // 校验所有
286
+ async checkAll(invalidFields, keepitem, callback, type) {
287
+ // 不存在校验规则 ,则停止校验流程
288
+ if (!this.validator) return;
289
+ let childrens = [];
290
+ // 处理参与校验的item实例
291
+ for (let i in invalidFields) {
292
+ const item = this.childrens.find((v) => realName(v.name) === i);
293
+ if (item) {
294
+ childrens.push(item);
295
+ }
296
+ }
308
297
 
309
- // 如果validate第一个参数是funciont ,那就走回调
310
- if (!callback && typeof keepitem === 'function') {
311
- callback = keepitem;
312
- }
298
+ // 如果validate第一个参数是funciont ,那就走回调
299
+ if (!callback && typeof keepitem === 'function') {
300
+ callback = keepitem;
301
+ }
313
302
 
314
- let promise;
315
- // 如果不存在回调,那么使用 Promise 方式返回
316
- if (!callback && typeof callback !== 'function' && Promise) {
317
- promise = new Promise((resolve, reject) => {
318
- callback = function(valid, invalidFields) {
319
- !valid ? resolve(invalidFields) : reject(valid);
320
- };
321
- });
322
- }
303
+ let promise;
304
+ // 如果不存在回调,那么使用 Promise 方式返回
305
+ if (!callback && typeof callback !== 'function' && Promise) {
306
+ promise = new Promise((resolve, reject) => {
307
+ callback = function (valid, invalidFields) {
308
+ !valid ? resolve(invalidFields) : reject(valid);
309
+ };
310
+ });
311
+ }
323
312
 
324
- let results = [];
325
- // 避免引用错乱 ,建议拷贝对象处理
326
- let tempFormData = JSON.parse(JSON.stringify(invalidFields))
327
- // 所有子组件参与校验,使用 for 可以使用 awiat
328
- for (let i in childrens) {
329
- const child = childrens[i]
330
- let name = realName(child.name);
331
- const result = await child.onFieldChange(tempFormData[name]);
332
- if (result) {
333
- results.push(result);
334
- // toast ,modal 只需要执行第一次就可以
335
- if (this.errShowType === 'toast' || this.errShowType === 'modal') break;
336
- }
337
- }
313
+ let results = [];
314
+ // 避免引用错乱 ,建议拷贝对象处理
315
+ let tempFormData = JSON.parse(JSON.stringify(invalidFields));
316
+ // 所有子组件参与校验,使用 for 可以使用 awiat
317
+ for (let i in childrens) {
318
+ const child = childrens[i];
319
+ let name = realName(child.name);
320
+ const result = await child.onFieldChange(tempFormData[name]);
321
+ if (result) {
322
+ results.push(result);
323
+ // toast ,modal 只需要执行第一次就可以
324
+ if (this.errShowType === 'toast' || this.errShowType === 'modal') break;
325
+ }
326
+ }
338
327
 
328
+ if (Array.isArray(results)) {
329
+ if (results.length === 0) results = null;
330
+ }
331
+ if (Array.isArray(keepitem)) {
332
+ keepitem.forEach((v) => {
333
+ let vName = realName(v);
334
+ let value = getDataValue(v, this.localData);
335
+ if (value !== undefined) {
336
+ tempFormData[vName] = value;
337
+ }
338
+ });
339
+ }
339
340
 
340
- if (Array.isArray(results)) {
341
- if (results.length === 0) results = null;
342
- }
343
- if (Array.isArray(keepitem)) {
344
- keepitem.forEach(v => {
345
- let vName = realName(v);
346
- let value = getDataValue(v, this.localData)
347
- if (value !== undefined) {
348
- tempFormData[vName] = value
349
- }
350
- });
351
- }
341
+ // TODO submit 即将废弃
342
+ if (type === 'submit') {
343
+ this.$emit('submit', {
344
+ detail: {
345
+ value: tempFormData,
346
+ errors: results,
347
+ },
348
+ });
349
+ } else {
350
+ this.$emit('validate', results);
351
+ }
352
352
 
353
- // TODO submit 即将废弃
354
- if (type === 'submit') {
355
- this.$emit('submit', {
356
- detail: {
357
- value: tempFormData,
358
- errors: results
359
- }
360
- });
361
- } else {
362
- this.$emit('validate', results);
363
- }
353
+ // const resetFormData = rawData(tempFormData, this.localData, this.name)
354
+ let resetFormData = {};
355
+ resetFormData = rawData(tempFormData, this.name);
356
+ callback && typeof callback === 'function' && callback(results, resetFormData);
364
357
 
365
- // const resetFormData = rawData(tempFormData, this.localData, this.name)
366
- let resetFormData = {}
367
- resetFormData = rawData(tempFormData, this.name)
368
- callback && typeof callback === 'function' && callback(results, resetFormData);
358
+ if (promise && callback) {
359
+ return promise;
360
+ } else {
361
+ return null;
362
+ }
363
+ },
369
364
 
370
- if (promise && callback) {
371
- return promise;
372
- } else {
373
- return null;
374
- }
375
-
376
- },
377
-
378
- /**
379
- * 返回validate事件
380
- * @param {Object} result
381
- */
382
- validateCheck(result) {
383
- this.$emit('validate', result);
384
- },
385
- _getValue: getValue,
386
- _isRequiredField: isRequiredField,
387
- _setDataValue: setDataValue,
388
- _getDataValue: getDataValue,
389
- _realName: realName,
390
- _isRealName: isRealName,
391
- _isEqual: isEqual
392
- }
393
- });
365
+ /**
366
+ * 返回validate事件
367
+ * @param {Object} result
368
+ */
369
+ validateCheck(result) {
370
+ this.$emit('validate', result);
371
+ },
372
+ _getValue: getValue,
373
+ _isRequiredField: isRequiredField,
374
+ _setDataValue: setDataValue,
375
+ _getDataValue: getDataValue,
376
+ _realName: realName,
377
+ _isRealName: isRealName,
378
+ _isEqual: isEqual,
379
+ },
380
+ });
394
381
  </script>
395
382
 
396
383
  <style lang="scss">
397
- .uni-forms {}
384
+ .uni-forms {
385
+ }
398
386
  </style>