bri-components 1.0.0

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 (215) hide show
  1. package/README.md +30 -0
  2. package/lib/.DS_Store +0 -0
  3. package/lib/0.bri-components.min.js +2 -0
  4. package/lib/0.bri-components.min.js.map +1 -0
  5. package/lib/1.bri-components.min.js +2 -0
  6. package/lib/1.bri-components.min.js.map +1 -0
  7. package/lib/2.bri-components.min.js +2 -0
  8. package/lib/2.bri-components.min.js.map +1 -0
  9. package/lib/3.bri-components.min.js +2 -0
  10. package/lib/3.bri-components.min.js.gz +0 -0
  11. package/lib/3.bri-components.min.js.map +1 -0
  12. package/lib/4.bri-components.min.js +2 -0
  13. package/lib/4.bri-components.min.js.gz +0 -0
  14. package/lib/4.bri-components.min.js.map +1 -0
  15. package/lib/5.bri-components.min.js +2 -0
  16. package/lib/5.bri-components.min.js.map +1 -0
  17. package/lib/6.bri-components.min.js +2 -0
  18. package/lib/6.bri-components.min.js.map +1 -0
  19. package/lib/bri-components.min.js +21 -0
  20. package/lib/bri-components.min.js.gz +0 -0
  21. package/lib/bri-components.min.js.map +1 -0
  22. package/lib/styles/bri-components.css +1 -0
  23. package/lib/styles/bundle.css +14 -0
  24. package/lib/styles/font/fontello.eot +0 -0
  25. package/lib/styles/font/fontello.svg +32 -0
  26. package/lib/styles/font/fontello.ttf +0 -0
  27. package/lib/styles/font/fontello.woff +0 -0
  28. package/lib/styles/font/fontello.woff2 +0 -0
  29. package/package.json +121 -0
  30. package/src/.DS_Store +0 -0
  31. package/src/components/controls/base/DshBack.vue +36 -0
  32. package/src/components/controls/base/DshCascader.vue +366 -0
  33. package/src/components/controls/base/DshCascaderMultiple.vue +158 -0
  34. package/src/components/controls/base/DshCheckbox.vue +199 -0
  35. package/src/components/controls/base/DshCoordinates.vue +497 -0
  36. package/src/components/controls/base/DshDate.vue +148 -0
  37. package/src/components/controls/base/DshDaterange.vue +335 -0
  38. package/src/components/controls/base/DshDivider.vue +59 -0
  39. package/src/components/controls/base/DshEditor.vue +166 -0
  40. package/src/components/controls/base/DshInput.vue +139 -0
  41. package/src/components/controls/base/DshLabels.vue +302 -0
  42. package/src/components/controls/base/DshNumber/BriInputNumber/BriInputNumber.vue +425 -0
  43. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/emitter.js +34 -0
  44. package/src/components/controls/base/DshNumber/BriInputNumber/mixins/form.js +14 -0
  45. package/src/components/controls/base/DshNumber/BriInputNumber/utils/assist.js +322 -0
  46. package/src/components/controls/base/DshNumber/DshNumber.vue +148 -0
  47. package/src/components/controls/base/DshNumberange.vue +137 -0
  48. package/src/components/controls/base/DshPackage.vue +72 -0
  49. package/src/components/controls/base/DshSelect.vue +231 -0
  50. package/src/components/controls/base/DshSwitch.vue +112 -0
  51. package/src/components/controls/base/DshUndeveloped.vue +39 -0
  52. package/src/components/controls/base/YSerialNumber.vue +37 -0
  53. package/src/components/controls/base/ZUpload/YUploadImage.vue +228 -0
  54. package/src/components/controls/base/ZUpload/index.vue +356 -0
  55. package/src/components/controls/base/ZUpload/upload-list.vue +277 -0
  56. package/src/components/controls/base/ZUpload/upload-listItem.vue +0 -0
  57. package/src/components/controls/base/ZUpload/uploadMixin.js +397 -0
  58. package/src/components/controls/base/selectMixin.js +110 -0
  59. package/src/components/controls/base/textMultiple/DshTextMultiple.vue +94 -0
  60. package/src/components/controls/base/textMultiple/MultipleInput.vue +106 -0
  61. package/src/components/controls/controlMap.js +94 -0
  62. package/src/components/controls/controlMixin.js +84 -0
  63. package/src/components/form/DshAdvSearchForm.vue +341 -0
  64. package/src/components/form/DshDefaultSearch.vue +203 -0
  65. package/src/components/form/DshForm.vue +364 -0
  66. package/src/components/form/searchMixin.js +205 -0
  67. package/src/components/list/DshBox/DshBox.vue +168 -0
  68. package/src/components/list/DshBox/DshCard.vue +219 -0
  69. package/src/components/list/DshBox/DshCrossTable.vue +624 -0
  70. package/src/components/list/DshBox/DshList.vue +442 -0
  71. package/src/components/list/DshBox/DshPanel.vue +407 -0
  72. package/src/components/list/DshBox/DshSingleData.vue +82 -0
  73. package/src/components/list/DshBox/DshTable.vue +273 -0
  74. package/src/components/list/DshCascaderTable.vue +817 -0
  75. package/src/components/list/DshFlatTable.vue +622 -0
  76. package/src/components/list/ZTree.vue +527 -0
  77. package/src/components/list/easyTable/index.js +23 -0
  78. package/src/components/list/easyTable/src/directives/clickoutside.js +32 -0
  79. package/src/components/list/easyTable/src/mixins/layerAdjustment.js +62 -0
  80. package/src/components/list/easyTable/src/settings/settings.js +11 -0
  81. package/src/components/list/easyTable/src/utils/deepClone.js +256 -0
  82. package/src/components/list/easyTable/src/utils/dom.js +41 -0
  83. package/src/components/list/easyTable/src/utils/utils.js +190 -0
  84. package/src/components/list/easyTable/v-checkbox/index.js +7 -0
  85. package/src/components/list/easyTable/v-checkbox/src/checkbox.vue +127 -0
  86. package/src/components/list/easyTable/v-checkbox-group/index.js +7 -0
  87. package/src/components/list/easyTable/v-checkbox-group/src/checkbox-group.vue +68 -0
  88. package/src/components/list/easyTable/v-dropdown/index.js +7 -0
  89. package/src/components/list/easyTable/v-dropdown/src/dropdown.vue +337 -0
  90. package/src/components/list/easyTable/v-table/index.js +7 -0
  91. package/src/components/list/easyTable/v-table/src/body-cell-merge-mixin.js +141 -0
  92. package/src/components/list/easyTable/v-table/src/cell-edit-mixin.js +102 -0
  93. package/src/components/list/easyTable/v-table/src/checkbox-selection-mixin.js +189 -0
  94. package/src/components/list/easyTable/v-table/src/classes-mixin.js +56 -0
  95. package/src/components/list/easyTable/v-table/src/drag-width-mixin.js +202 -0
  96. package/src/components/list/easyTable/v-table/src/export-csv.js +74 -0
  97. package/src/components/list/easyTable/v-table/src/frozen-columns-mixin.js +134 -0
  98. package/src/components/list/easyTable/v-table/src/loading.vue +49 -0
  99. package/src/components/list/easyTable/v-table/src/scroll-bar-control-mixin.js +21 -0
  100. package/src/components/list/easyTable/v-table/src/scroll-control-mixin.js +92 -0
  101. package/src/components/list/easyTable/v-table/src/sort-control-mixin.js +108 -0
  102. package/src/components/list/easyTable/v-table/src/table-empty-mixin.js +73 -0
  103. package/src/components/list/easyTable/v-table/src/table-empty.vue +66 -0
  104. package/src/components/list/easyTable/v-table/src/table-filters-mixin.js +126 -0
  105. package/src/components/list/easyTable/v-table/src/table-footer-mixin.js +122 -0
  106. package/src/components/list/easyTable/v-table/src/table-resize-mixin.js +279 -0
  107. package/src/components/list/easyTable/v-table/src/table-row-mouse-events-mixin.js +123 -0
  108. package/src/components/list/easyTable/v-table/src/table.vue +1565 -0
  109. package/src/components/list/easyTable/v-table/src/title-cell-merge-mixin.js +115 -0
  110. package/src/components/list/evTable/EvTable.vue +323 -0
  111. package/src/components/list/evTable/EvTableMixin.js +26 -0
  112. package/src/components/other/DshAvatar.vue +149 -0
  113. package/src/components/other/DshBtnModal.vue +64 -0
  114. package/src/components/other/DshColorPanel.vue +128 -0
  115. package/src/components/other/DshEditPanel.vue +130 -0
  116. package/src/components/other/InfoCascader.vue +258 -0
  117. package/src/components/other/YNoPermission.vue +45 -0
  118. package/src/components/other/ZCode.vue +125 -0
  119. package/src/components/other/ZCollapseTree.vue +84 -0
  120. package/src/components/other/ZGantt.vue +669 -0
  121. package/src/components/other/ZIframe.vue +105 -0
  122. package/src/components/other/ZLoading.vue +59 -0
  123. package/src/components/other/menu/DshMenu.vue +133 -0
  124. package/src/components/other/menu/DshMenuNav.vue +104 -0
  125. package/src/components/pages/Error/Error403.vue +34 -0
  126. package/src/components/pages/Error/Error404.vue +34 -0
  127. package/src/components/pages/Error/Error500.vue +34 -0
  128. package/src/components/pages/Error/error.less +163 -0
  129. package/src/components/pages/Error/errorBack.vue +38 -0
  130. package/src/components/small/Ctooltip.vue +90 -0
  131. package/src/components/small/DshButtons.vue +195 -0
  132. package/src/components/small/DshControlDefine.vue +110 -0
  133. package/src/components/small/DshCrumbs.vue +61 -0
  134. package/src/components/small/DshCrumbsItem.vue +107 -0
  135. package/src/components/small/DshDropdown.vue +159 -0
  136. package/src/components/small/DshFileShow.vue +212 -0
  137. package/src/components/small/DshIcons.vue +63 -0
  138. package/src/components/small/DshModal.vue +255 -0
  139. package/src/components/small/DshPage.vue +98 -0
  140. package/src/components/small/DshSteps.vue +68 -0
  141. package/src/components/small/DshTabs.vue +227 -0
  142. package/src/components/small/DshTags.vue +58 -0
  143. package/src/components/small/DshTdRender.js +21 -0
  144. package/src/components/small/DshTitle.vue +36 -0
  145. package/src/components/small/render.js +20 -0
  146. package/src/components/unit/DshFormItem.vue +157 -0
  147. package/src/components/unit/DshUnit.vue +72 -0
  148. package/src/components/unit/unitMixin.js +43 -0
  149. package/src/datas/.DS_Store +0 -0
  150. package/src/datas/common/region.json +1 -0
  151. package/src/datas/common/resourceData.json +20 -0
  152. package/src/datas/index.js +11 -0
  153. package/src/index.js +243 -0
  154. package/src/styles/animate.less +16 -0
  155. package/src/styles/bundle.css +14 -0
  156. package/src/styles/common/box.less +157 -0
  157. package/src/styles/common/common.less +31 -0
  158. package/src/styles/common/flex.less +282 -0
  159. package/src/styles/common/index.less +4 -0
  160. package/src/styles/common/text.less +43 -0
  161. package/src/styles/components/controls/DshCascader.less +75 -0
  162. package/src/styles/components/controls/DshCheckbox.less +156 -0
  163. package/src/styles/components/controls/DshCoordinates.less +72 -0
  164. package/src/styles/components/controls/DshDaterange.less +49 -0
  165. package/src/styles/components/controls/DshDivider.less +115 -0
  166. package/src/styles/components/controls/DshEditor.less +52 -0
  167. package/src/styles/components/controls/DshInput.less +40 -0
  168. package/src/styles/components/controls/DshLabels.less +187 -0
  169. package/src/styles/components/controls/DshNumberange.less +24 -0
  170. package/src/styles/components/controls/DshPackage.less +25 -0
  171. package/src/styles/components/controls/DshSelect.less +172 -0
  172. package/src/styles/components/controls/MultipleInput.less +55 -0
  173. package/src/styles/components/controls/ZUpload.less +446 -0
  174. package/src/styles/components/form/DshAdvSearchForm.less +159 -0
  175. package/src/styles/components/form/DshDefaultSearch.less +71 -0
  176. package/src/styles/components/index.less +49 -0
  177. package/src/styles/components/list/DshCascaderTable.less +113 -0
  178. package/src/styles/components/list/DshCrossTable.less +175 -0
  179. package/src/styles/components/list/DshFlatTable.less +98 -0
  180. package/src/styles/components/list/DshSingleData.less +30 -0
  181. package/src/styles/components/list/evTable.less +79 -0
  182. package/src/styles/components/list/evtable/animation.less +141 -0
  183. package/src/styles/components/list/evtable/font/fontello.eot +0 -0
  184. package/src/styles/components/list/evtable/font/fontello.svg +32 -0
  185. package/src/styles/components/list/evtable/font/fontello.ttf +0 -0
  186. package/src/styles/components/list/evtable/font/fontello.woff +0 -0
  187. package/src/styles/components/list/evtable/font/fontello.woff2 +0 -0
  188. package/src/styles/components/list/evtable/fontello.less +68 -0
  189. package/src/styles/components/list/evtable/index.less +5 -0
  190. package/src/styles/components/list/evtable/v-checkbox.less +167 -0
  191. package/src/styles/components/list/evtable/v-dropdown.less +235 -0
  192. package/src/styles/components/list/evtable/v-table.less +334 -0
  193. package/src/styles/components/list/ivu_reset.less +49 -0
  194. package/src/styles/components/other/DshEditPanel.less +70 -0
  195. package/src/styles/components/other/DshMenu.less +37 -0
  196. package/src/styles/components/other/DshMenuNav.less +82 -0
  197. package/src/styles/components/other/InfoCascader.less +55 -0
  198. package/src/styles/components/other/ZCode.less +1 -0
  199. package/src/styles/components/other/ZCollapseTree.less +62 -0
  200. package/src/styles/components/other/ZGantt.less +278 -0
  201. package/src/styles/components/other/ZLoading.less +36 -0
  202. package/src/styles/components/small/Ctooltip.less +5 -0
  203. package/src/styles/components/small/DshButtons.less +40 -0
  204. package/src/styles/components/small/DshControlDefine.less +64 -0
  205. package/src/styles/components/small/DshDropdown.less +61 -0
  206. package/src/styles/components/small/DshPage.less +94 -0
  207. package/src/styles/components/small/DshSteps.less +58 -0
  208. package/src/styles/components/small/DshTabs.less +82 -0
  209. package/src/styles/components/small/DshTitle.less +18 -0
  210. package/src/styles/components/unit/DshFormItem.less +124 -0
  211. package/src/styles/define.less +374 -0
  212. package/src/styles/index.less +10 -0
  213. package/src/styles/reset.less +83 -0
  214. package/src/styles/variables.less +98 -0
  215. package/src/styles/view_reset.less +446 -0
@@ -0,0 +1,425 @@
1
+ <template>
2
+ <div :class="wrapClasses">
3
+ <!-- <div :class="suffixClasses">
4
+ <slot name="suffix"></slot>
5
+ </div> -->
6
+ <div
7
+ v-if="numberAdjust"
8
+ :class="handlerClasses"
9
+ :style="handlerStyle"
10
+ >
11
+ <a
12
+ @click="up"
13
+ :class="upClasses"
14
+ >
15
+ <span
16
+ :class="innerUpClasses"
17
+ @click="preventDefault"
18
+ ></span>
19
+ </a>
20
+ <a
21
+ @click="down"
22
+ :class="downClasses"
23
+ >
24
+ <span
25
+ :class="innerDownClasses"
26
+ @click="preventDefault"
27
+ ></span>
28
+ </a>
29
+ </div>
30
+ <div
31
+ :class="inputWrapClasses"
32
+ style="display:flex"
33
+ >
34
+ <input
35
+ :id="elementId"
36
+ :class="inputClasses"
37
+ :disabled="itemDisabled"
38
+ autocomplete="off"
39
+ spellcheck="false"
40
+ :autofocus="autofocus"
41
+ @focus="focus"
42
+ @blur="blur"
43
+ @keydown.stop="keyDown"
44
+ @input="change"
45
+ @mouseup="preventDefault"
46
+ @change="change"
47
+ :readonly="readonly || !editable"
48
+ :name="name"
49
+ :value="formatterValue"
50
+ :placeholder="placeholder"
51
+ :style="{textAlign:itemDisabled ? 'right':'left'}"
52
+ >
53
+ <slot name="suffix"></slot>
54
+ </div>
55
+ </div>
56
+ </template>
57
+ <script>
58
+ import { findComponentUpward } from "./utils/assist";
59
+ import Emitter from "./mixins/emitter";
60
+ import mixinsForm from "./mixins/form";
61
+
62
+ const prefixCls = "ivu-input-number";
63
+ const iconPrefixCls = "ivu-icon";
64
+
65
+ function addNum (num1, num2) {
66
+ let sq1, sq2, m;
67
+ try {
68
+ sq1 = num1.toString().split(".")[1].length;
69
+ }
70
+ catch (e) {
71
+ sq1 = 0;
72
+ }
73
+ try {
74
+ sq2 = num2.toString().split(".")[1].length;
75
+ }
76
+ catch (e) {
77
+ sq2 = 0;
78
+ }
79
+ // if (sq1 === 0 || sq2 === 0) {
80
+ // return num1 + num2;
81
+ // } else {
82
+ // m = Math.pow(10, Math.max(sq1, sq2));
83
+ // return (num1 * m + num2 * m) / m;
84
+ // }
85
+ m = Math.pow(10, Math.max(sq1, sq2));
86
+ return (Math.round(num1 * m) + Math.round(num2 * m)) / m;
87
+ }
88
+
89
+ /* function _debounce (fn, delayTime) {
90
+ let delay = delayTime || 1000;
91
+ let timer;
92
+ return function () {
93
+ let that = this;
94
+ let args = arguments;
95
+ if (timer) {
96
+ clearTimeout(timer);
97
+ }
98
+ timer = setTimeout(() => {
99
+ timer = null;
100
+ fn.apply(that, args);
101
+ }, delay);
102
+ };
103
+ } */
104
+
105
+ export default {
106
+ name: "BriInputNumber",
107
+ mixins: [ Emitter, mixinsForm ],
108
+ props: {
109
+ max: {
110
+ type: Number,
111
+ default: Infinity
112
+ },
113
+ min: {
114
+ type: Number,
115
+ default: -Infinity
116
+ },
117
+ step: {
118
+ type: Number,
119
+ default: 1
120
+ },
121
+ activeChange: {
122
+ type: Boolean,
123
+ default: true
124
+ },
125
+ value: {
126
+ type: [Number, String],
127
+ default: null
128
+ },
129
+ size: {
130
+ default () {
131
+ return !this.$IVIEW || this.$IVIEW.size === "" ? "default" : this.$IVIEW.size;
132
+ },
133
+ validator (value) {
134
+ return ["small", "large", "default"].includes(value);
135
+ }
136
+ },
137
+ disabled: {
138
+ type: Boolean,
139
+ default: false
140
+ },
141
+ autofocus: {
142
+ type: Boolean,
143
+ default: false
144
+ },
145
+ readonly: {
146
+ type: Boolean,
147
+ default: false
148
+ },
149
+ editable: {
150
+ type: Boolean,
151
+ default: true
152
+ },
153
+ name: {
154
+ type: String
155
+ },
156
+ precision: {
157
+ type: Number
158
+ },
159
+ elementId: {
160
+ type: String
161
+ },
162
+ formatter: {
163
+ type: Function
164
+ },
165
+ parser: {
166
+ type: Function
167
+ },
168
+ placeholder: {
169
+ type: String,
170
+ default: ""
171
+ },
172
+ handlerStyle: {
173
+ type: Object,
174
+ default () {
175
+ return {};
176
+ }
177
+ },
178
+ numberAdjust: {
179
+ type: Boolean,
180
+ default: true
181
+ },
182
+ isPositive: {
183
+ type: Boolean,
184
+ default: false
185
+ }
186
+ },
187
+ data () {
188
+ return {
189
+ focused: false,
190
+ upDisabled: false,
191
+ downDisabled: false,
192
+ currentValue: this.value,
193
+ transferValue: null
194
+ };
195
+ },
196
+ computed: {
197
+ wrapClasses () {
198
+ return [
199
+ `${prefixCls}`,
200
+ {
201
+ [`${prefixCls}-${this.size}`]: !!this.size,
202
+ [`${prefixCls}-disabled`]: this.itemDisabled,
203
+ [`${prefixCls}-focused`]: this.focused
204
+ }
205
+ ];
206
+ },
207
+ suffixClasses () {
208
+ return `${prefixCls}-suffix-wrap`;
209
+ },
210
+ handlerClasses () {
211
+ return `${prefixCls}-handler-wrap`;
212
+ },
213
+ upClasses () {
214
+ return [
215
+ `${prefixCls}-handler`,
216
+ `${prefixCls}-handler-up`,
217
+ {
218
+ [`${prefixCls}-handler-up-disabled`]: this.upDisabled
219
+ }
220
+ ];
221
+ },
222
+ innerUpClasses () {
223
+ return `${prefixCls}-handler-up-inner ${iconPrefixCls} ${iconPrefixCls}-ios-arrow-up`;
224
+ },
225
+ downClasses () {
226
+ return [
227
+ `${prefixCls}-handler`,
228
+ `${prefixCls}-handler-down`,
229
+ {
230
+ [`${prefixCls}-handler-down-disabled`]: this.downDisabled
231
+ }
232
+ ];
233
+ },
234
+ innerDownClasses () {
235
+ return `${prefixCls}-handler-down-inner ${iconPrefixCls} ${iconPrefixCls}-ios-arrow-down`;
236
+ },
237
+ inputWrapClasses () {
238
+ return `${prefixCls}-input-wrap`;
239
+ },
240
+ inputClasses () {
241
+ return `${prefixCls}-input`;
242
+ },
243
+ precisionValue () {
244
+ // can not display 1.0
245
+ if (!this.currentValue) return this.currentValue;
246
+ return this.precision ? this.currentValue.toFixed(this.precision) : this.currentValue;
247
+ },
248
+ formatterValue () {
249
+ if (this.formatter && this.precisionValue !== null) {
250
+ let formatterStr = this.formatter(this.precisionValue);
251
+ if (this.isPositive) {
252
+ return formatterStr.replace("整", "正");
253
+ } else {
254
+ return formatterStr;
255
+ }
256
+ } else {
257
+ return this.precisionValue;
258
+ }
259
+ }
260
+ },
261
+ methods: {
262
+ preventDefault (e) {
263
+ e.preventDefault();
264
+ },
265
+ up (e) {
266
+ const targetVal = Number(e.target.value);
267
+ if (this.upDisabled && isNaN(targetVal)) {
268
+ return false;
269
+ }
270
+ this.changeStep("up", e);
271
+ },
272
+ down (e) {
273
+ const targetVal = Number(e.target.value);
274
+ if (this.downDisabled && isNaN(targetVal)) {
275
+ return false;
276
+ }
277
+ this.changeStep("down", e);
278
+ },
279
+ changeStep (type, e) {
280
+ if (this.itemDisabled || this.readonly) {
281
+ return false;
282
+ }
283
+
284
+ const targetVal = Number(e.target.value);
285
+ let val = Number(this.currentValue);
286
+ const step = Number(this.step);
287
+ if (isNaN(val)) {
288
+ return false;
289
+ }
290
+
291
+ // input a number, and key up or down
292
+ if (!isNaN(targetVal)) {
293
+ if (type === "up") {
294
+ if (addNum(targetVal, step) <= this.max) {
295
+ val = targetVal;
296
+ } else {
297
+ return false;
298
+ }
299
+ } else if (type === "down") {
300
+ if (addNum(targetVal, -step) >= this.min) {
301
+ val = targetVal;
302
+ } else {
303
+ return false;
304
+ }
305
+ }
306
+ }
307
+
308
+ if (type === "up") {
309
+ val = addNum(val, step);
310
+ } else if (type === "down") {
311
+ val = addNum(val, -step);
312
+ }
313
+ this.setValue(val, "step");
314
+ },
315
+ setValue (val, setType) {
316
+ // 如果 step 是小数,且没有设置 precision,是有问题的
317
+ if (val && !isNaN(this.precision)) val = Number(Number(val).toFixed(this.precision));
318
+
319
+ const {min, max} = this;
320
+ if (val !== null) {
321
+ if (val > max) {
322
+ val = max;
323
+ } else if (val < min) {
324
+ val = min;
325
+ }
326
+ }
327
+
328
+ this.$nextTick(() => {
329
+ this.transferValue = val;
330
+ if (setType && setType === "step") {
331
+ this.$emit("input", val);
332
+ this.$emit("on-change", val);
333
+ this.dispatch("FormItem", "on-form-change", val);
334
+ }
335
+ });
336
+ },
337
+ focus (event) {
338
+ this.focused = true;
339
+ this.$emit("on-focus", event);
340
+ },
341
+ blur () {
342
+ if (this.transferValue !== this.currentValue) {
343
+ this.currentValue = this.transferValue;
344
+ this.$emit("input", this.transferValue);
345
+ this.$emit("on-change", this.transferValue);
346
+ this.dispatch("FormItem", "on-form-change", this.transferValue);
347
+ this.focused = false;
348
+ this.$emit("on-blur");
349
+ if (!findComponentUpward(this, ["DatePicker", "TimePicker", "Cascader", "Search"])) {
350
+ this.dispatch("FormItem", "on-form-blur", this.transferValue);
351
+ }
352
+ }
353
+ },
354
+ keyDown (e) {
355
+ if (e.keyCode === 38) {
356
+ e.preventDefault();
357
+ this.up(e);
358
+ } else if (e.keyCode === 40) {
359
+ e.preventDefault();
360
+ this.down(e);
361
+ }
362
+ },
363
+ change (event) {
364
+ if (event.type == "change" && this.activeChange) return;
365
+
366
+ if (event.type == "input" && !this.activeChange) return;
367
+ let val = event.target.value.trim();
368
+ if (this.parser) {
369
+ val = this.parser(val);
370
+ }
371
+
372
+ const isEmptyString = val.length === 0;
373
+ if (isEmptyString) {
374
+ this.setValue(null);
375
+ return;
376
+ }
377
+ if (event.type == "input" && val.match(/^-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
378
+
379
+ // eslint认为\为无用的转义符(-不需要转义)
380
+ // if (event.type == "input" && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
381
+ val = Number(val);
382
+
383
+ if (!isNaN(val)) {
384
+ // this.currentValue = val;
385
+ this.setValue(val);
386
+ } else {
387
+ event.target.value = this.currentValue;
388
+ }
389
+ },
390
+ changeVal (val) {
391
+ val = Number(val);
392
+ if (!isNaN(val)) {
393
+ const step = this.step;
394
+
395
+ this.upDisabled = val + step > this.max;
396
+ this.downDisabled = val - step < this.min;
397
+ } else {
398
+ this.upDisabled = true;
399
+ this.downDisabled = true;
400
+ }
401
+ }
402
+ },
403
+ mounted () {
404
+ this.transferValue = this.value;
405
+ this.changeVal(this.currentValue);
406
+ },
407
+ watch: {
408
+ value (val) {
409
+ if (val) {
410
+ this.transferValue = this.value;
411
+ }
412
+ this.currentValue = val;
413
+ },
414
+ currentValue (val) {
415
+ this.changeVal(val);
416
+ },
417
+ min () {
418
+ this.changeVal(this.currentValue);
419
+ },
420
+ max () {
421
+ this.changeVal(this.currentValue);
422
+ }
423
+ }
424
+ };
425
+ </script>
@@ -0,0 +1,34 @@
1
+ function broadcast (componentName, eventName, params) {
2
+ this.$children.forEach(child => {
3
+ const name = child.$options.name;
4
+
5
+ if (name === componentName) {
6
+ child.$emit.apply(child, [eventName].concat(params));
7
+ } else {
8
+ // todo 如果 params 是空数组,接收到的会是 undefined
9
+ broadcast.apply(child, [componentName, eventName].concat([params]));
10
+ }
11
+ });
12
+ }
13
+ export default {
14
+ methods: {
15
+ dispatch (componentName, eventName, params) {
16
+ let parent = this.$parent || this.$root;
17
+ let name = parent.$options.name;
18
+
19
+ while (parent && (!name || name !== componentName)) {
20
+ parent = parent.$parent;
21
+
22
+ if (parent) {
23
+ name = parent.$options.name;
24
+ }
25
+ }
26
+ if (parent) {
27
+ parent.$emit.apply(parent, [eventName].concat(params));
28
+ }
29
+ },
30
+ broadcast (componentName, eventName, params) {
31
+ broadcast.call(this, componentName, eventName, params);
32
+ }
33
+ }
34
+ };
@@ -0,0 +1,14 @@
1
+ export default {
2
+ inject: {
3
+ FormInstance: {
4
+ default: ""
5
+ }
6
+ },
7
+ computed: {
8
+ itemDisabled () {
9
+ let state = this.disabled;
10
+ if (!state && this.FormInstance) state = this.FormInstance.disabled;
11
+ return state;
12
+ }
13
+ }
14
+ };