@10yun/cv-mobile-ui 0.3.25 → 0.4.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 (190) hide show
  1. package/build/parse-pages.js +2 -2
  2. package/package.json +1 -1
  3. package/plugins/request.js +0 -1
  4. package/ui-cv/README.md +3 -0
  5. package/ui-cv/cv-badge/uni-badge.vue +249 -0
  6. package/ui-cv/cv-banner/cv-banner.vue +1 -1
  7. package/ui-cv/cv-banner-card/cv-banner-card.vue +1 -1
  8. package/ui-cv/cv-block/cv-block.vue +1 -1
  9. package/ui-cv/cv-box/cv-box.vue +1 -1
  10. package/{ui-uni/uni-calendar → ui-cv/cv-calendar}/calendar.js +0 -0
  11. package/{ui-uni/uni-calendar → ui-cv/cv-calendar}/uni-calendar-item.vue +0 -0
  12. package/{ui-uni/uni-calendar → ui-cv/cv-calendar}/uni-calendar.vue +0 -0
  13. package/{ui-uni/uni-calendar → ui-cv/cv-calendar}/util.js +0 -0
  14. package/{ui-uni/uni-card → ui-cv/cv-card}/uni-card.vue +0 -0
  15. package/ui-cv/cv-cell/cv-cell.vue +1 -1
  16. package/ui-cv/cv-checkbox-group/cv-checkbox-group.vue +227 -0
  17. package/ui-cv/cv-checkbox-opt-base/cv-checkbox-opt-base.vue +57 -0
  18. package/ui-cv/cv-checkbox-opt-tag/cv-checkbox-opt-tag.vue +107 -0
  19. package/ui-cv/cv-code-sms/cv-code-sms.vue +23 -42
  20. package/{ui-uni/uni-col → ui-cv/cv-col}/uni-col.vue +0 -0
  21. package/{ui-uni/uni-collapse → ui-cv/cv-collapse}/uni-collapse.vue +0 -0
  22. package/{ui-uni/uni-collapse-item → ui-cv/cv-collapse-item}/uni-collapse-item.vue +0 -0
  23. package/{ui-uni/uni-combox → ui-cv/cv-combox}/uni-combox.vue +0 -0
  24. package/{ui-uni/uni-countdown → ui-cv/cv-countdown}/uni-countdown.vue +0 -0
  25. package/{ui-uni/uni-data-checkbox → ui-cv/cv-data-checkbox}/uni-data-checkbox.vue +0 -0
  26. package/{ui-uni/uni-data-indexed-list → ui-cv/cv-data-indexed-list}/clientdb.js +0 -0
  27. package/{ui-uni/uni-data-indexed-list → ui-cv/cv-data-indexed-list}/uni-data-indexed-list-item.vue +0 -0
  28. package/{ui-uni/uni-data-indexed-list → ui-cv/cv-data-indexed-list}/uni-data-indexed-list.vue +0 -0
  29. package/{ui-uni/uni-data-picker → ui-cv/cv-data-picker}/keypress.js +0 -0
  30. package/{ui-uni/uni-data-picker → ui-cv/cv-data-picker}/uni-data-picker.vue +0 -0
  31. package/{ui-uni/uni-data-pickerview → ui-cv/cv-data-pickerview}/uni-data-picker.js +0 -0
  32. package/{ui-uni/uni-data-pickerview → ui-cv/cv-data-pickerview}/uni-data-pickerview.vue +0 -0
  33. package/{ui-uni/uni-dateformat → ui-cv/cv-dateformat}/date-format.js +0 -0
  34. package/{ui-uni/uni-dateformat → ui-cv/cv-dateformat}/uni-dateformat.vue +0 -0
  35. package/{ui-uni/uni-datetime-picker → ui-cv/cv-datetime-picker}/calendar-item.vue +0 -0
  36. package/{ui-uni/uni-datetime-picker → ui-cv/cv-datetime-picker}/calendar.js +0 -0
  37. package/{ui-uni/uni-datetime-picker → ui-cv/cv-datetime-picker}/calendar.vue +0 -0
  38. package/{ui-uni/uni-datetime-picker → ui-cv/cv-datetime-picker}/keypress.js +0 -0
  39. package/{ui-uni/uni-datetime-picker → ui-cv/cv-datetime-picker}/time-picker.vue +0 -0
  40. package/{ui-uni/uni-datetime-picker → ui-cv/cv-datetime-picker}/uni-datetime-picker.vue +0 -0
  41. package/{ui-uni/uni-datetime-picker → ui-cv/cv-datetime-picker}/util.js +0 -0
  42. package/ui-cv/cv-dialog-bottom/cv-dialog-bottom.vue +1 -1
  43. package/ui-cv/cv-dialog-full/cv-dialog-full.vue +1 -1
  44. package/ui-cv/cv-dialog-loading/cv-dialog-loading.vue +3 -3
  45. package/ui-cv/cv-drawer/cv-drawer.vue +185 -0
  46. package/{ui-uni/uni-drawer → ui-cv/cv-drawer}/keypress.js +14 -14
  47. package/{ui-uni/uni-easyinput → ui-cv/cv-easyinput}/common.js +0 -0
  48. package/{ui-uni/uni-easyinput → ui-cv/cv-easyinput}/uni-easyinput.vue +0 -0
  49. package/ui-cv/cv-editor-parse/readme.md +2 -3
  50. package/ui-cv/{cv-editor → cv-editor-quill}/compressImage.vue +0 -0
  51. package/ui-cv/{cv-editor/cv-editor.vue → cv-editor-quill/cv-editor-quill.vue} +3 -23
  52. package/ui-cv/{cv-editor → cv-editor-quill}/editor-icon.css +0 -0
  53. package/ui-cv/{cv-editor → cv-editor-quill}/editor-icon.ttf +0 -0
  54. package/ui-cv/{cv-editor → cv-editor-quill}/index.js +0 -0
  55. package/{ui-uni/uni-fab → ui-cv/cv-fab}/uni-fab.vue +0 -0
  56. package/{ui-uni/uni-fab → ui-cv/cv-fab}/uni-fab.vue.bak +0 -0
  57. package/{ui-uni/uni-fav → ui-cv/cv-fav}/uni-fav.vue +0 -0
  58. package/{ui-uni/uni-file-picker → ui-cv/cv-file-picker}/choose-and-upload-file.js +0 -0
  59. package/{ui-uni/uni-file-picker → ui-cv/cv-file-picker}/uni-file-picker.vue +0 -0
  60. package/{ui-uni/uni-file-picker → ui-cv/cv-file-picker}/upload-file.vue +0 -0
  61. package/{ui-uni/uni-file-picker → ui-cv/cv-file-picker}/upload-image.vue +0 -0
  62. package/{ui-uni/uni-file-picker → ui-cv/cv-file-picker}/utils.js +0 -0
  63. package/ui-cv/cv-form-base/cv-form-base.vue +470 -0
  64. package/ui-cv/cv-form-base/validate.js +477 -0
  65. package/ui-cv/cv-form-group/cv-form-group.vue +123 -80
  66. package/ui-cv/cv-form-group/cv-form-group2.vue +80 -0
  67. package/ui-cv/cv-form-item/cv-form-item.vue +482 -174
  68. package/ui-cv/cv-form-item/cv-form-item2.vue +215 -0
  69. package/ui-cv/cv-form-merge/cv-form-merge.vue +1 -1
  70. package/ui-cv/cv-geo-local/cv-geo-local.vue +14 -26
  71. package/{ui-uni/uni-goods-nav → ui-cv/cv-goods-nav}/uni-goods-nav.vue +0 -0
  72. package/ui-cv/cv-grid-group/cv-grid-group.vue +148 -0
  73. package/ui-cv/cv-grid-item/cv-grid-item.vue +132 -0
  74. package/ui-cv/cv-icons/cv-icons.vue +1 -1
  75. package/ui-cv/cv-icons2/cv-icons2.vue +78 -0
  76. package/ui-cv/cv-icons2/icons.js +132 -0
  77. package/{ui-uni/uni-icons → ui-cv/cv-icons2}/uni.ttf +0 -0
  78. package/{ui-uni/uni-indexed-list → ui-cv/cv-indexed-list}/uni-indexed-list-item.vue +0 -0
  79. package/{ui-uni/uni-indexed-list → ui-cv/cv-indexed-list}/uni-indexed-list.vue +0 -0
  80. package/ui-cv/cv-info/cv-info.vue +5 -20
  81. package/ui-cv/cv-input-btn/cv-input-btn.vue +25 -43
  82. package/ui-cv/cv-input-digit/cv-input-digit.vue +61 -28
  83. package/ui-cv/cv-input-idcard/cv-input-idcard.vue +47 -29
  84. package/ui-cv/cv-input-number/cv-input-number.vue +60 -28
  85. package/ui-cv/cv-input-password/cv-input-password.vue +80 -30
  86. package/ui-cv/cv-input-text/cv-input-text.vue +55 -37
  87. package/ui-cv/cv-link/uni-link.vue +130 -0
  88. package/{ui-uni/uni-list → ui-cv/cv-list}/uni-list.vue +0 -0
  89. package/{ui-uni/uni-list → ui-cv/cv-list}/uni-refresh.vue +0 -0
  90. package/{ui-uni/uni-list → ui-cv/cv-list}/uni-refresh.wxs +0 -0
  91. package/{ui-uni/uni-list-ad → ui-cv/cv-list-ad}/uni-list-ad.vue +0 -0
  92. package/{ui-uni/uni-list-chat → ui-cv/cv-list-chat}/uni-list-chat.scss +0 -0
  93. package/{ui-uni/uni-list-chat → ui-cv/cv-list-chat}/uni-list-chat.vue +0 -0
  94. package/{ui-uni/uni-list-item → ui-cv/cv-list-item}/uni-list-item.vue +0 -0
  95. package/ui-cv/cv-load-more/config.json +9 -9
  96. package/ui-cv/cv-load-more/cv-load-more.vue +34 -5
  97. package/ui-cv/cv-message/cv-message.vue +1 -1
  98. package/{ui-uni/uni-nav-bar → ui-cv/cv-nav-bar}/uni-nav-bar.vue +0 -0
  99. package/{ui-uni/uni-nav-bar → ui-cv/cv-nav-bar}/uni-status-bar.vue +0 -0
  100. package/ui-cv/cv-nav-col/cv-nav-col.vue +1 -1
  101. package/ui-cv/cv-nav-row/cv-nav-row.vue +1 -1
  102. package/{ui-uni/uni-notice-bar → ui-cv/cv-notice-bar}/uni-notice-bar.vue +0 -0
  103. package/{ui-uni/uni-number-box → ui-cv/cv-number-box}/uni-number-box.vue +0 -0
  104. package/{ui-uni/uni-pagination → ui-cv/cv-pagination}/uni-pagination.vue +0 -0
  105. package/ui-cv/cv-picker-date/cv-picker-date.vue +17 -27
  106. package/ui-cv/cv-picker-datetime/cv-picker-datetime.vue +31 -41
  107. package/ui-cv/cv-picker-datetime5/cv-picker-datetime5.vue +19 -29
  108. package/ui-cv/cv-picker-region/cv-picker-region.vue +23 -33
  109. package/ui-cv/cv-picker-time/cv-picker-time.vue +16 -26
  110. package/ui-cv/cv-picker1/cv-picker1.vue +16 -28
  111. package/ui-cv/cv-picker2/cv-picker2.vue +22 -32
  112. package/ui-cv/cv-picker3/cv-picker3.vue +34 -44
  113. package/{ui-uni/uni-popup → ui-cv/cv-popup}/keypress.js +0 -0
  114. package/{ui-uni/uni-popup → ui-cv/cv-popup}/popup.js +0 -0
  115. package/{ui-uni/uni-popup → ui-cv/cv-popup}/uni-popup.vue +0 -0
  116. package/{ui-uni/uni-popup-dialog → ui-cv/cv-popup-dialog}/keypress.js +0 -0
  117. package/{ui-uni/uni-popup-dialog → ui-cv/cv-popup-dialog}/uni-popup-dialog.vue +0 -0
  118. package/{ui-uni/uni-popup-message → ui-cv/cv-popup-message}/uni-popup-message.vue +0 -0
  119. package/{ui-uni/uni-popup-share → ui-cv/cv-popup-share}/uni-popup-share.vue +0 -0
  120. package/ui-cv/cv-radio-group/cv-radio-group.vue +185 -0
  121. package/ui-cv/cv-radio-opt-base/cv-radio-opt-base.vue +57 -0
  122. package/ui-cv/cv-radio-opt-tag/cv-radio-opt-tag.vue +107 -0
  123. package/ui-cv/cv-rate/cv-rate.vue +13 -17
  124. package/ui-cv/cv-rate/uni-rate.vue +358 -0
  125. package/ui-cv/cv-row/uni-row.vue +157 -0
  126. package/ui-cv/cv-search/cv-search.vue +4 -4
  127. package/{ui-uni/uni-search-bar → ui-cv/cv-search-bar}/uni-search-bar.vue +0 -0
  128. package/{ui-uni/uni-section → ui-cv/cv-section}/uni-section.vue +0 -0
  129. package/{ui-uni/uni-segmented-control → ui-cv/cv-segmented-control}/uni-segmented-control.vue +0 -0
  130. package/ui-cv/cv-skeleton/cv-skeleton2.vue +5 -5
  131. package/ui-cv/cv-specs/cv-specs.vue +1 -1
  132. package/{ui-uni/uni-status-bar → ui-cv/cv-status-bar}/uni-status-bar.vue +0 -0
  133. package/{ui-uni/uni-steps → ui-cv/cv-steps}/uni-steps.vue +0 -0
  134. package/{ui-uni/uni-swipe-action → ui-cv/cv-swipe-action}/uni-swipe-action.vue +0 -0
  135. package/{ui-uni/uni-swipe-action-item → ui-cv/cv-swipe-action-item}/bindingx.js +0 -0
  136. package/{ui-uni/uni-swipe-action-item → ui-cv/cv-swipe-action-item}/index.wxs +0 -0
  137. package/{ui-uni/uni-swipe-action-item → ui-cv/cv-swipe-action-item}/isPC.js +0 -0
  138. package/{ui-uni/uni-swipe-action-item → ui-cv/cv-swipe-action-item}/mpalipay.js +0 -0
  139. package/{ui-uni/uni-swipe-action-item → ui-cv/cv-swipe-action-item}/mpother.js +0 -0
  140. package/{ui-uni/uni-swipe-action-item → ui-cv/cv-swipe-action-item}/mpwxs.js +0 -0
  141. package/{ui-uni/uni-swipe-action-item → ui-cv/cv-swipe-action-item}/uni-swipe-action-item.vue +0 -0
  142. package/{ui-uni/uni-swiper-dot → ui-cv/cv-swiper-dot}/uni-swiper-dot.vue +0 -0
  143. package/ui-cv/cv-switch/cv-switch.vue +5 -9
  144. package/{ui-uni/uni-table → ui-cv/cv-table}/uni-table.vue +0 -0
  145. package/{ui-uni/uni-tag → ui-cv/cv-tag}/uni-tag.vue +0 -0
  146. package/{ui-uni/uni-tbody → ui-cv/cv-tbody}/uni-tbody.vue +0 -0
  147. package/{ui-uni/uni-td → ui-cv/cv-td}/uni-td.vue +0 -0
  148. package/{ui-uni/uni-test → ui-cv/cv-test}/uni-test.vue +0 -0
  149. package/ui-cv/cv-textarea/cv-textarea.vue +56 -41
  150. package/{ui-uni/uni-th → ui-cv/cv-th}/filter-dropdown.vue +0 -0
  151. package/{ui-uni/uni-th → ui-cv/cv-th}/uni-th.vue +0 -0
  152. package/{ui-uni/uni-thead → ui-cv/cv-thead}/uni-thead.vue +0 -0
  153. package/{ui-uni/uni-title → ui-cv/cv-title}/uni-title.vue +0 -0
  154. package/{ui-uni/uni-tr → ui-cv/cv-tr}/table-checkbox.vue +0 -0
  155. package/{ui-uni/uni-tr → ui-cv/cv-tr}/uni-tr.vue +0 -0
  156. package/{ui-uni/uni-transition → ui-cv/cv-transition}/createAnimation.js +0 -0
  157. package/{ui-uni/uni-transition → ui-cv/cv-transition}/uni-transition.vue +0 -0
  158. package/ui-cv/cv-upload-avatar/cv-upload-avatar.vue +24 -22
  159. package/ui-cv/cv-upload-img/cv-upload-img.vue +1 -1
  160. package/ui-cv/mixins/mixins-input.js +20 -29
  161. package/ui-cv/mixins/mixins-picker.js +1 -13
  162. package/ui-uni/amap-wx/js/util.js +158 -166
  163. package/ui-uni/product.vue +52 -52
  164. package/ui-uni/u-charts/u-charts.js +1092 -743
  165. package/ui-cv/cv-checkbox/cv-checkbox.vue +0 -140
  166. package/ui-cv/cv-checkbox-tag/cv-checkbox-tag.vue +0 -164
  167. package/ui-cv/cv-nav-group/cv-nav-group.vue +0 -33
  168. package/ui-cv/cv-radio/cv-radio.vue +0 -111
  169. package/ui-cv/cv-radio-sex/cv-radio-sex.vue +0 -80
  170. package/ui-cv/cv-radio-tag/cv-radio-tag.vue +0 -133
  171. package/ui-cv/mixins/mixins-checkbox.js +0 -71
  172. package/ui-cv/mixins/mixins-common.js +0 -53
  173. package/ui-cv/mixins/mixins-radio.js +0 -84
  174. package/ui-uni/page-foot/page-foot.vue +0 -38
  175. package/ui-uni/page-head/page-head.vue +0 -16
  176. package/ui-uni/u-link/u-link.vue +0 -59
  177. package/ui-uni/uni-badge/uni-badge.vue +0 -250
  178. package/ui-uni/uni-drawer/uni-drawer.vue +0 -178
  179. package/ui-uni/uni-forms/uni-forms.vue +0 -467
  180. package/ui-uni/uni-forms/validate.js +0 -486
  181. package/ui-uni/uni-forms-item/uni-forms-item.vue +0 -500
  182. package/ui-uni/uni-grid/uni-grid.vue +0 -141
  183. package/ui-uni/uni-grid-item/uni-grid-item.vue +0 -123
  184. package/ui-uni/uni-group/uni-group.vue +0 -123
  185. package/ui-uni/uni-icons/icons.js +0 -132
  186. package/ui-uni/uni-icons/uni-icons.vue +0 -72
  187. package/ui-uni/uni-link/uni-link.vue +0 -117
  188. package/ui-uni/uni-load-more/uni-load-more.vue +0 -366
  189. package/ui-uni/uni-rate/uni-rate.vue +0 -357
  190. package/ui-uni/uni-row/uni-row.vue +0 -155
@@ -1,238 +1,546 @@
1
1
  <template>
2
- <view class="cv-form-item" :class="localLayout == 'col' ? 'cv-form-item-col' : 'cv-form-item-row'">
3
- <text class="cv-form-item-lebel-title-must" v-if="must == true">*</text>
4
- <view class="cv-form-item-area">
5
- <view :class="localLayout == 'col' ? 'cv-form-item-area-col' : 'cv-form-item-area-row'">
6
- <view
7
- class="cv-form-item-label"
8
- :class="localLayout == 'col' ? 'cv-form-item-right-col' : 'cv-form-item-right-row'"
9
- v-bind:style="labelStyle"
10
- >
11
- <view class="cv-form-item-lebel-title">
12
- <text>{{ label }}</text>
13
- <text class="cv-form-item-lebel-tip" v-if="localLayout == 'col' && tip != ''">({{ tip }})</text>
14
- </view>
2
+ <view
3
+ class="cv-form-item"
4
+ :class="{ 'cv-form-item--border': border, 'is-first-border': border && isFirstBorder, 'cv-form-item-error': msg }"
5
+ >
6
+ <view class="cv-form-item__box">
7
+ <view class="cv-form-item__inner" :class="['is-direction-' + labelPos]">
8
+ <view class="cv-form-item__label" :style="{ width: labelWid, justifyContent: justifyContent }">
9
+ <slot name="left">
10
+ <uni-icons v-if="leftIcon" class="label-icon" size="16" :type="leftIcon" :color="iconColor" />
11
+ <text v-if="required" class="is-required">*</text>
12
+ <text class="label-text">{{ label }}</text>
13
+ <view v-if="label" class="label-seat"></view>
14
+ </slot>
15
15
  </view>
16
- <view
17
- class="cv-form-item-right"
18
- :class="localLayout == 'col' ? 'cv-form-item-right-col' : 'cv-form-item-right-row'"
19
- v-bind:style="labelRightStyle"
20
- >
21
- <view class="cv-form-item-right-item">
22
- <!-- 插槽 -->
23
- <slot />
24
- <!-- 三角形图标 -->
25
- <view class="cv-form-item-right-item-icon" v-if="isIcon">
26
- <view class="cv-form-item-right-item-icon-box" :class="iconTop ? 'cv-form-item-right-item-icon-box-top' : ''">
27
- <view class="cv-form-item-right-item-icon-item"></view>
28
- </view>
29
- </view>
30
- <!-- 输入框右侧信息 -->
31
- <view class="cv-form-item-right-item-right">
32
- <!-- 一键清空 -->
33
- <view class="cv-form-item-right-item-right-rtip" v-if="rtip != ''">
34
- {{ rtip }}
35
- </view>
36
- <view class="cv-form-item-right-item-empty-icon" @click="onEmpty" v-if="onQClear == true && inputValue != ''">
37
- X
38
- </view>
39
- </view>
40
- </view>
41
- <view class="cv-form-item-right-message" v-if="messageDisplay == true">
42
- <text>{{ message }}</text>
43
- </view>
16
+ <view class="cv-form-item__content" :class="{ 'is-input-error-border': msg }">
17
+ <slot></slot>
44
18
  </view>
45
19
  </view>
46
- <view class="cv-form-item-right-tip" v-if="localLayout == 'row' && tip != ''">
47
- <text>{{ tip }}</text>
20
+ <view
21
+ v-if="msg"
22
+ class="uni-error-message"
23
+ :class="{ 'uni-error-msg--boeder': border }"
24
+ :style="{
25
+ paddingLeft: labelLeft
26
+ }"
27
+ >
28
+ <text class="uni-error-message-text">{{ showMsg === 'undertext' ? msg : '' }}</text>
48
29
  </view>
30
+ <view class="cv-form-item__tip"><slot name="tip"></slot></view>
49
31
  </view>
32
+ <view class="cv-form-item__line" v-if="localLine"></view>
50
33
  </view>
51
34
  </template>
35
+
52
36
  <script>
53
- import MixinsCommon from '../mixins/mixins-common.js';
37
+ /**
38
+ * Field 输入框
39
+ * @description 此组件可以实现表单的输入与校验,包括 "text" 和 "textarea" 类型。
40
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=21001
41
+ * @property {Boolean} required 是否必填,左边显示红色"*"号(默认false)
42
+ * @property {String} validateTrigger = [bind|submit] 校验触发器方式 默认 submit 可选
43
+ * @value bind 发生变化时触发
44
+ * @value submit 提交时触发
45
+ * @property {String } leftIcon label左边的图标,限 uni-ui 的图标名称
46
+ * @property {String } iconColor 左边通过icon配置的图标的颜色(默认#606266)
47
+ * @property {String } label 输入框左边的文字提示
48
+ * @property {Number } labelWidth label的宽度,单位px(默认65)
49
+ * @property {String } labelAlign = [left|center|right] label的文字对齐方式(默认left)
50
+ * @value left label 左侧显示
51
+ * @value center label 居中
52
+ * @value right label 右侧对齐
53
+ * @property {String } labelPosition = [top|left] label的文字的位置(默认left)
54
+ * @value top 顶部显示 label
55
+ * @value left 左侧显示 label
56
+ * @property {String } errorMessage 显示的错误提示内容,如果为空字符串或者false,则不显示错误信息
57
+ * @property {String } name 表单域的属性名,在使用校验规则时必填
58
+ */
59
+
54
60
  export default {
55
- mixins: [MixinsCommon],
56
61
  name: 'cvFormItem',
57
62
  props: {
58
- isIcon: {
63
+ // 自定义内容
64
+ custom: {
59
65
  type: Boolean,
60
66
  default: false
61
67
  },
62
- iconTop: {
68
+ // 是否显示报错信息
69
+ showMessage: {
63
70
  type: Boolean,
64
- default: false
71
+ default: true
65
72
  },
66
- //右侧提示(一般用作单位)
67
- rtip: {
73
+ name: String,
74
+ required: Boolean,
75
+ validateTrigger: {
68
76
  type: String,
69
77
  default: ''
70
78
  },
71
- //一键清除按钮
72
- onQClear: {
73
- type: Boolean,
74
- default: false
79
+ leftIcon: String,
80
+ iconColor: {
81
+ type: String,
82
+ default: '#606266'
75
83
  },
76
- //父级输入框内容
77
- inputValue: {
78
- type: [String, Number],
84
+ label: String,
85
+ // 左边标题的宽度单位px
86
+ labelWidth: {
87
+ type: [Number, String],
79
88
  default: ''
80
89
  },
81
- message: {
90
+ // 对齐方式,left|center|right
91
+ labelAlign: {
82
92
  type: String,
83
93
  default: ''
84
94
  },
85
- messageDisplay: {
95
+ // lable的位置,可选为 left-左边,top-上边
96
+ labelPosition: {
97
+ type: String,
98
+ default: ''
99
+ },
100
+ errorMessage: {
101
+ type: [String, Boolean],
102
+ default: ''
103
+ },
104
+ // 表单校验规则
105
+ rules: {
106
+ type: Array,
107
+ default() {
108
+ return [];
109
+ }
110
+ },
111
+ /**
112
+ * 自定义
113
+ */
114
+ line: {
86
115
  type: Boolean,
87
- default: false
116
+ default: true
88
117
  }
89
118
  },
90
119
  data() {
91
120
  return {
92
- labelStyle: ''
121
+ errorTop: false,
122
+ errorBottom: false,
123
+ labelMarginBottom: '',
124
+ errorWidth: '',
125
+ errMsg: '',
126
+ val: '',
127
+ labelPos: '',
128
+ labelWid: '',
129
+ labelAli: '',
130
+ showMsg: 'undertext',
131
+ border: false,
132
+ isFirstBorder: false,
133
+ isArray: false,
134
+ arrayField: '',
135
+ /**
136
+ * 自定义
137
+ */
138
+ localLine: true
93
139
  };
94
140
  },
95
- created: function () {
96
- this.localLayout = this.layout == 'col' ? 'col' : 'row';
97
- this.labelStyle =
98
- this.localLayout == 'row' ? (this.labelWidth > 0 ? 'width:' + this.labelWidth + 'px;' : 'display:none;') : '';
99
- this.labelRightStyle =
100
- this.localLayout == 'row' && this.labelWidth > 0
101
- ? 'width:' + 'calc(100% - 8px - 20px - ' + this.labelWidth + 'px);'
102
- : 'padding-left:0;';
103
- this.$forceUpdate();
141
+ computed: {
142
+ msg() {
143
+ return this.errorMessage || this.errMsg;
144
+ },
145
+ fieldStyle() {
146
+ let style = {};
147
+ if (this.labelPos == 'top') {
148
+ style.padding = '0 0';
149
+ this.labelMarginBottom = '6px';
150
+ }
151
+ if (this.labelPos == 'left' && this.msg !== false && this.msg != '') {
152
+ style.paddingBottom = '0px';
153
+ this.errorBottom = true;
154
+ this.errorTop = false;
155
+ } else if (this.labelPos == 'top' && this.msg !== false && this.msg != '') {
156
+ this.errorBottom = false;
157
+ this.errorTop = true;
158
+ } else {
159
+ // style.paddingBottom = ''
160
+ this.errorTop = false;
161
+ this.errorBottom = false;
162
+ }
163
+ return style;
164
+ },
165
+
166
+ // uni不支持在computed中写style.justifyContent = 'center'的形式,故用此方法
167
+ justifyContent() {
168
+ if (this.labelAli === 'left') return 'flex-start';
169
+ if (this.labelAli === 'center') return 'center';
170
+ if (this.labelAli === 'right') return 'flex-end';
171
+ },
172
+ labelLeft() {
173
+ return (this.labelPos === 'left' ? parseInt(this.labelWid) : 0) + 'px';
174
+ }
175
+ },
176
+ watch: {
177
+ validateTrigger(trigger) {
178
+ this.formTrigger = trigger;
179
+ }
180
+ },
181
+ created() {
182
+ this.form = this.getForm();
183
+ this.group = this.getForm('cvFormGroup');
184
+ this.formRules = [];
185
+ this.formTrigger = this.validateTrigger;
186
+ // 处理 name,是否数组
187
+ if (this.name && this.name.indexOf('[') !== -1 && this.name.indexOf(']') !== -1) {
188
+ this.isArray = true;
189
+ this.arrayField = this.name;
190
+ // fix by mehaotian 修改不修改的情况,动态值不检验的问题
191
+ this.form.formData[this.name] = this.form._getValue(this.name, '');
192
+ }
193
+ },
194
+ mounted() {
195
+ if (this.form) {
196
+ this.form.childrens.push(this);
197
+ }
198
+ this.init();
104
199
  },
200
+ // #ifndef VUE3
201
+ destroyed() {
202
+ if (this.__isUnmounted) return;
203
+ this.unInit();
204
+ },
205
+ // #endif
206
+ // #ifdef VUE3
207
+ unmounted() {
208
+ this.__isUnmounted = true;
209
+ this.unInit();
210
+ },
211
+ // #endif
105
212
  methods: {
106
- onEmpty(e) {
107
- this.$parent.onEmpty();
213
+ init() {
214
+ if (this.form) {
215
+ // return false;
216
+ let { formRules, validator, formData, value, labelPosition, labelWidth, labelAlign, errShowType, line } = this.form;
217
+
218
+ /**
219
+ * 自定义 start
220
+ */
221
+ this.localLine = this.line ? this.line : line;
222
+ /**
223
+ * 自定义 end
224
+ */
225
+
226
+ this.labelPos = this.labelPosition ? this.labelPosition : labelPosition;
227
+
228
+ // if(){}
229
+
230
+ if (this.label) {
231
+ this.labelWid = this.labelWidth ? this.labelWidth : labelWidth || 70;
232
+ } else {
233
+ this.labelWid = this.labelWidth ? this.labelWidth : labelWidth || 'auto';
234
+ }
235
+ if (this.labelWid && this.labelWid !== 'auto') {
236
+ this.labelWid = parseInt(this.labelWid);
237
+ this.labelWid += 'px';
238
+ }
239
+
240
+ this.labelAli = this.labelAlign ? this.labelAlign : labelAlign;
241
+
242
+ // 判断第一个 item
243
+ if (!this.form.isFirstBorder) {
244
+ this.form.isFirstBorder = true;
245
+ this.isFirstBorder = true;
246
+ }
247
+
248
+ // 判断 group 里的第一个 item
249
+ if (this.group) {
250
+ if (!this.group.isFirstBorder) {
251
+ this.group.isFirstBorder = true;
252
+ this.isFirstBorder = true;
253
+ }
254
+ }
255
+
256
+ this.border = this.form.border;
257
+ this.showMsg = errShowType;
258
+ let name = this.isArray ? this.arrayField : this.name;
259
+ if (formRules) {
260
+ if (!formRules[name]) {
261
+ formRules[name] = {
262
+ rules: this.rules
263
+ };
264
+ }
265
+ this.formRules = formRules[name];
266
+ }
267
+ if (this.rules.length > 0) {
268
+ validator.updateSchema(formRules);
269
+ }
270
+ this.validator = validator;
271
+ } else {
272
+ this.labelPos = this.labelPosition || 'left';
273
+ this.labelWid = this.labelWidth || 65;
274
+ this.labelWid = parseInt(this.labelWid);
275
+
276
+ this.labelAli = this.labelAlign || 'left';
277
+ this.localLine = this.line || true;
278
+ }
279
+ },
280
+ unInit() {
281
+ if (this.form) {
282
+ this.form.childrens.forEach((item, index) => {
283
+ if (item === this) {
284
+ this.form.childrens.splice(index, 1);
285
+ delete this.form.formData[item.name];
286
+ }
287
+ });
288
+ }
289
+ },
290
+ /**
291
+ * 获取父元素实例
292
+ */
293
+ getForm(name = 'cvFormBase') {
294
+ let parent = this.$parent;
295
+ let parentName = parent.$options.name;
296
+ while (parentName !== name) {
297
+ parent = parent.$parent;
298
+ if (!parent) return false;
299
+ parentName = parent.$options.name;
300
+ }
301
+ return parent;
302
+ },
303
+
304
+ /**
305
+ * 移除该表单项的校验结果
306
+ */
307
+ clearValidate() {
308
+ this.errMsg = '';
309
+ },
310
+ /**
311
+ * 子组件调用,如 easyinput
312
+ * @param {Object} value
313
+ */
314
+ setValue(value) {
315
+ let name = this.isArray ? this.arrayField : this.name;
316
+ if (name) {
317
+ if (this.errMsg) this.errMsg = '';
318
+ // 给组件赋值
319
+ this.form.formData[name] = this.form._getValue(name, value);
320
+ if (!this.formRules || (typeof this.formRules && JSON.stringify(this.formRules) === '{}')) return;
321
+ this.triggerCheck(this.form._getValue(this.name, value));
322
+ }
323
+ },
324
+
325
+ /**
326
+ * 校验规则
327
+ * @param {Object} value
328
+ */
329
+ async triggerCheck(value, formTrigger) {
330
+ let promise = null;
331
+ this.errMsg = '';
332
+ if (!this.validator) return;
333
+ const isNoField = this.isRequired(this.formRules.rules || []);
334
+ let isTrigger = this.isTrigger(this.formRules.validateTrigger, this.validateTrigger, this.form.validateTrigger);
335
+ let result = null;
336
+ if (!!isTrigger || formTrigger) {
337
+ let name = this.isArray ? this.arrayField : this.name;
338
+ result = await this.validator.validateUpdate(
339
+ {
340
+ [name]: value
341
+ },
342
+ this.form.formData
343
+ );
344
+ }
345
+ // 判断是否必填,非必填,不填不校验,填写才校验
346
+ if (!isNoField && (value === undefined || value === '')) {
347
+ result = null;
348
+ }
349
+ const inputComp = this.form.inputChildrens.find((child) => child.rename === this.name);
350
+ if ((isTrigger || formTrigger) && result && result.errorMessage) {
351
+ if (inputComp) {
352
+ inputComp.errMsg = result.errorMessage;
353
+ }
354
+ if (this.form.errShowType === 'toast') {
355
+ uni.showToast({
356
+ title: result.errorMessage || '校验错误',
357
+ icon: 'none'
358
+ });
359
+ }
360
+ if (this.form.errShowType === 'modal') {
361
+ uni.showModal({
362
+ title: '提示',
363
+ content: result.errorMessage || '校验错误'
364
+ });
365
+ }
366
+ } else {
367
+ if (inputComp) {
368
+ inputComp.errMsg = '';
369
+ }
370
+ }
371
+
372
+ this.errMsg = !result ? '' : result.errorMessage;
373
+ // 触发validate事件
374
+ this.form.validateCheck(result ? result : null);
375
+ // typeof callback === 'function' && callback(result ? result : null);
376
+ // if (promise) return promise
377
+ return result ? result : null;
378
+ },
379
+ /**
380
+ * 触发时机
381
+ * @param {Object} event
382
+ */
383
+ isTrigger(rule, itemRlue, parentRule) {
384
+ let rl = true;
385
+ // bind submit
386
+ if (rule === 'submit' || !rule) {
387
+ if (rule === undefined) {
388
+ if (itemRlue !== 'bind') {
389
+ if (!itemRlue) {
390
+ return parentRule === 'bind' ? true : false;
391
+ }
392
+ return false;
393
+ }
394
+ return true;
395
+ }
396
+ return false;
397
+ }
398
+ return true;
399
+ },
400
+ // 是否有必填字段
401
+ isRequired(rules) {
402
+ let isNoField = false;
403
+ for (let i = 0; i < rules.length; i++) {
404
+ const ruleData = rules[i];
405
+ if (ruleData.required) {
406
+ isNoField = true;
407
+ break;
408
+ }
409
+ }
410
+ return isNoField;
108
411
  }
109
412
  }
110
413
  };
111
414
  </script>
112
415
 
113
- <style>
416
+ <style scoped>
114
417
  .cv-form-item {
418
+ position: relative;
419
+ padding: 0px;
420
+ text-align: left;
421
+ color: #333;
115
422
  font-size: 14px;
116
- padding-left: 15px;
117
- background-color: #ffffff;
423
+ }
424
+
425
+ .cv-form-item__box {
118
426
  position: relative;
119
427
  }
120
- .cv-form-item-area {
121
- padding: 5px 0px;
122
- border-bottom: solid 1px #eee;
428
+
429
+ .cv-form-item__inner {
430
+ /* #ifndef APP-NVUE */
431
+ display: flex;
432
+ /* #endif */
433
+ /* padding-bottom: 22px; */
123
434
  }
124
- /* #ifndef MP-WEIXIN */
125
- .cv-form-item:last-child .cv-form-item-area {
126
- border: none;
435
+
436
+ .is-direction-left {
437
+ flex-direction: row;
127
438
  }
128
- /* #endif */
129
- /* #ifdef MP-WEIXIN */
130
439
 
131
- /* #endif */
132
- .cv-form-item-area-row {
440
+ .is-direction-top {
441
+ flex-direction: column;
442
+ }
443
+
444
+ .cv-form-item__label {
445
+ /* #ifndef APP-NVUE */
133
446
  display: flex;
447
+ flex-shrink: 0;
448
+ box-sizing: border-box;
449
+ /* #endif */
450
+ flex-direction: row;
451
+ align-items: center;
452
+ width: 65px;
453
+ padding: 5px 0;
454
+ height: 36px;
134
455
  }
135
- .cv-input-text-item-placeholder {
456
+
457
+ .cv-form-item__label .label-text {
136
458
  font-size: 14px;
459
+ color: #333;
137
460
  }
138
- .cv-form-item-label {
139
- height: 35px;
140
- line-height: 35px;
141
- width: 60px;
142
- padding-right: 4px;
143
- overflow: hidden;
144
- color: #303133;
145
- padding-left: 4px;
146
- box-sizing: unset;
147
- }
148
- .cv-form-item-right {
149
- /* width: calc(100% - 60px - 4px - 4px - 20px); */
461
+
462
+ .cv-form-item__label .label-seat {
463
+ margin-right: 5px;
464
+ }
465
+
466
+ .cv-form-item__content {
467
+ /* #ifndef APP-NVUE */
150
468
  width: 100%;
151
- padding-left: 5px;
152
- padding-right: 15px;
153
- box-sizing: unset;
469
+ box-sizing: border-box;
470
+ min-height: 36px;
471
+ /* #endif */
472
+ flex: 1;
154
473
  }
155
- .cv-form-item-right-item {
156
- min-height: 35px;
157
- line-height: 35px;
158
- position: relative;
159
- overflow: auto;
474
+
475
+ .label-icon {
476
+ margin-right: 5px;
477
+ margin-top: -1px;
160
478
  }
161
- .cv-form-item-right-item-icon {
479
+
480
+ .is-required {
481
+ color: #dd524d;
482
+ padding-right: 5px;
483
+ }
484
+
485
+ .uni-error-message {
162
486
  position: absolute;
163
- width: 15px;
164
- height: 15px;
165
- top: 10px;
166
- right: 10px;
167
- }
168
- .cv-form-item-right-item-icon-box {
169
- padding-top: 1px;
170
- transform: rotate(0deg);
171
- transition: transform 0.4s;
172
- }
173
- .cv-form-item-right-item-icon-box-top {
174
- transform: rotate(-180deg);
175
- }
176
- .cv-form-item-right-item-icon-item {
177
- width: 0;
178
- height: 0;
179
- border-left: 7.5px solid transparent;
180
- border-right: 7.5px solid transparent;
181
- border-top: 11px solid #c0c4cc;
182
- }
183
- .cv-form-item-right-message {
487
+ bottom: 0px;
488
+ left: 0;
489
+ text-align: left;
490
+ }
491
+
492
+ .uni-error-message-text {
493
+ line-height: 22px;
494
+ color: #dd524d;
184
495
  font-size: 12px;
185
- color: #fa3534;
186
- margin-top: 6px;
187
- line-height: 12px;
188
496
  }
189
- .cv-form-item-right-col {
190
- /* padding-left: 0; */
191
- width: auto;
497
+
498
+ .uni-error-msg--boeder {
499
+ position: relative;
500
+ bottom: 0;
501
+ line-height: 22px;
192
502
  }
193
- .cv-form-item-right-tip {
194
- font-size: 12px;
195
- color: rgba(0, 0, 0, 0.4);
196
- /* margin-top: 5px; */
197
- line-height: 1.5em;
198
- padding-right: 15px;
503
+
504
+ .is-input-error-border {
505
+ border-color: #dd524d;
199
506
  }
200
- .cv-form-item-lebel-title-must {
201
- color: #fa3534;
202
- /* margin-right: 5px; */
203
- position: absolute;
204
- top: 15px;
205
- left: 8px;
507
+
508
+ .cv-form-item--border {
509
+ margin-bottom: 0;
510
+ padding: 10px 0;
511
+ border-top: 1px #eee solid;
206
512
  }
207
- .cv-form-item-lebel-tip {
208
- color: rgba(0, 0, 0, 0.4);
513
+
514
+ .cv-form-item--border .cv-form-item__inner {
515
+ padding: 0;
209
516
  }
210
- .cv-form-item-right-item-right {
211
- height: 16px;
212
- position: absolute;
213
- top: 10px;
214
- right: 0px;
215
- overflow: auto;
216
- z-index: 2;
217
- }
218
- .cv-form-item-right-item-empty-icon {
219
- width: 16px;
220
- height: 16px;
221
- border-radius: 50%;
222
- background-color: rgba(0, 0, 0, 0.4);
223
- font-size: 8px;
224
- line-height: 16px;
225
- text-align: center;
226
- color: #fff;
227
- float: left;
228
- margin-left: 10px;
229
- }
230
- .cv-form-item-right-item-right-rtip {
231
- width: auto;
232
- height: 16px;
517
+
518
+ .is-first-border {
519
+ /* #ifndef APP-NVUE */
520
+ border: none;
521
+ /* #endif */
522
+ /* #ifdef APP-NVUE */
523
+ border-width: 0;
524
+ /* #endif */
525
+ }
526
+
527
+ .uni-forms--no-padding {
528
+ padding: 0;
529
+ }
530
+ .cv-form-item__tip {
531
+ color: rgba(0, 0, 0, 0.4);
233
532
  font-size: 12px;
234
- line-height: 16px;
235
- float: left;
236
- color: rgba(0, 0, 0, 0.6);
533
+ padding-bottom: 5px;
534
+ }
535
+
536
+ .cv-form-item__line {
537
+ vertical-align: middle;
538
+ margin: 0px;
539
+ border-bottom: 1px solid rgb(214, 215, 217);
540
+ width: 100%;
541
+ transform: scaleY(0.5);
542
+ border-top-color: rgb(214, 215, 217);
543
+ border-right-color: rgb(214, 215, 217);
544
+ border-left-color: rgb(214, 215, 217);
237
545
  }
238
546
  </style>