eoss-mobiles 0.4.0 → 0.4.2

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 (232) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/lib/button-group.js +2 -2
  3. package/lib/button.js +2 -2
  4. package/lib/calendar.js +2 -2
  5. package/lib/cell.js +2 -2
  6. package/lib/checkbox.js +2 -2
  7. package/lib/circle.js +2 -2
  8. package/lib/count-down.js +2 -2
  9. package/lib/empty.js +2 -2
  10. package/lib/eoss-mobile.common.js +542 -93
  11. package/lib/field.js +2 -2
  12. package/lib/flow-btn.js +2 -2
  13. package/lib/flow.js +8 -8
  14. package/lib/form.js +593 -144
  15. package/lib/grid-item.js +2 -2
  16. package/lib/grid.js +2 -2
  17. package/lib/index.js +1 -1
  18. package/lib/list.js +2 -2
  19. package/lib/loading.js +85 -85
  20. package/lib/nav-bar.js +2 -2
  21. package/lib/picker.js +12 -11
  22. package/lib/popover.js +2 -2
  23. package/lib/radio.js +8 -7
  24. package/lib/search.js +2 -2
  25. package/lib/selector.js +28 -28
  26. package/lib/switch.js +2 -2
  27. package/lib/tab.js +2 -2
  28. package/lib/table-column.js +3 -2
  29. package/lib/tabs.js +2 -2
  30. package/lib/tag.js +2 -2
  31. package/lib/theme-chalk/fonts/iconfont.scss +98 -98
  32. package/lib/theme-chalk/fonts/iconfont1.scss +90 -90
  33. package/lib/theme-chalk/form.css +1 -1
  34. package/lib/theme-chalk/index.css +1 -1
  35. package/lib/uploader.js +3 -2
  36. package/package.json +1 -1
  37. package/packages/action-sheet/index.js +5 -5
  38. package/packages/action-sheet/src/main.vue +32 -32
  39. package/packages/button/index.js +5 -5
  40. package/packages/button/src/main.vue +15 -15
  41. package/packages/button-group/index.js +5 -5
  42. package/packages/button-group/src/main.vue +80 -80
  43. package/packages/calendar/index.js +5 -5
  44. package/packages/calendar/src/main.vue +34 -34
  45. package/packages/cascader/index.js +5 -5
  46. package/packages/cascader/src/main.vue +39 -39
  47. package/packages/cell/index.js +5 -5
  48. package/packages/cell/src/main.vue +77 -77
  49. package/packages/checkbox/index.js +5 -5
  50. package/packages/checkbox/src/main.vue +232 -232
  51. package/packages/circle/index.js +5 -5
  52. package/packages/circle/src/main.vue +27 -27
  53. package/packages/count-down/index.js +5 -5
  54. package/packages/count-down/src/main.vue +27 -27
  55. package/packages/date/index.js +5 -5
  56. package/packages/date/src/date-time.vue +290 -290
  57. package/packages/date/src/main.vue +401 -401
  58. package/packages/empty/index.js +5 -5
  59. package/packages/empty/src/main.vue +16 -16
  60. package/packages/esign/index.js +5 -5
  61. package/packages/esign/src/main.vue +144 -144
  62. package/packages/field/index.js +5 -5
  63. package/packages/flow/index.js +5 -5
  64. package/packages/flow/src/components/Circulate.vue +595 -595
  65. package/packages/flow/src/components/Handle.vue +2404 -2404
  66. package/packages/flow/src/components/Message.vue +208 -208
  67. package/packages/flow/src/components/ProcessSettings.vue +342 -342
  68. package/packages/flow/src/components/TaskRead.vue +1 -1
  69. package/packages/flow/src/components/supervise.vue +139 -139
  70. package/packages/flow/src/flowMix.js +288 -288
  71. package/packages/flow/src/main.vue +116 -116
  72. package/packages/flow-btn/index.js +5 -5
  73. package/packages/flow-btn/src/main.vue +494 -494
  74. package/packages/flow-list/index.js +5 -5
  75. package/packages/flow-list/src/main.vue +248 -248
  76. package/packages/form/index.js +5 -5
  77. package/packages/form/src/CustomCard.vue +201 -0
  78. package/packages/form/src/main.vue +32 -19
  79. package/packages/grid/index.js +5 -5
  80. package/packages/grid/src/main.vue +486 -486
  81. package/packages/grid-item/index.js +5 -5
  82. package/packages/grid-item/src/main.vue +16 -16
  83. package/packages/image/index.js +5 -5
  84. package/packages/image/src/main.vue +12 -12
  85. package/packages/image-preview/index.js +5 -5
  86. package/packages/list/index.js +5 -5
  87. package/packages/list/src/main.vue +32 -32
  88. package/packages/loading/index.js +5 -5
  89. package/packages/loading/src/main.vue +19 -19
  90. package/packages/nav-bar/index.js +5 -5
  91. package/packages/nav-bar/src/main.vue +24 -24
  92. package/packages/notice-bar/index.js +5 -5
  93. package/packages/notice-bar/src/main.vue +15 -15
  94. package/packages/pagination/index.js +5 -5
  95. package/packages/pagination/src/main.vue +73 -73
  96. package/packages/picker/index.js +5 -5
  97. package/packages/picker/src/main.vue +604 -604
  98. package/packages/popover/index.js +5 -5
  99. package/packages/popover/src/main.vue +32 -32
  100. package/packages/popup/index.js +5 -5
  101. package/packages/popup/src/main.vue +27 -27
  102. package/packages/pull-refresh/index.js +5 -5
  103. package/packages/pull-refresh/src/main.vue +31 -31
  104. package/packages/radio/index.js +5 -5
  105. package/packages/radio/src/main.vue +179 -179
  106. package/packages/rate/index.js +5 -5
  107. package/packages/rate/src/main.vue +26 -26
  108. package/packages/retrial-auth/index.js +5 -5
  109. package/packages/retrial-auth/src/main.vue +257 -257
  110. package/packages/search/index.js +5 -5
  111. package/packages/search/src/main.vue +39 -39
  112. package/packages/selector/index.js +5 -5
  113. package/packages/selector/src/main.vue +186 -186
  114. package/packages/selector/src/selector-tree.vue +1117 -1117
  115. package/packages/selector/src/tree.vue +405 -405
  116. package/packages/skeleton/index.js +5 -5
  117. package/packages/skeleton/src/main.vue +17 -17
  118. package/packages/stepper/index.js +5 -5
  119. package/packages/stepper/src/main.vue +25 -25
  120. package/packages/swipe/index.js +5 -5
  121. package/packages/swipe/src/main.vue +42 -42
  122. package/packages/switch/index.js +5 -5
  123. package/packages/switch/src/main.vue +38 -38
  124. package/packages/tab/index.js +5 -5
  125. package/packages/tab/src/main.vue +16 -16
  126. package/packages/table/index.js +5 -5
  127. package/packages/table/src/main.vue +1006 -1006
  128. package/packages/table-column/index.js +5 -5
  129. package/packages/table-column/src/main.vue +931 -931
  130. package/packages/table-column/src/mixins/table.js +12 -12
  131. package/packages/tabs/index.js +5 -5
  132. package/packages/tabs/src/main.vue +34 -34
  133. package/packages/tag/index.js +5 -5
  134. package/packages/tag/src/main.vue +16 -16
  135. package/packages/theme-chalk/lib/action-sheet.css +0 -0
  136. package/packages/theme-chalk/lib/base.css +1 -0
  137. package/packages/theme-chalk/lib/button-group.css +1 -0
  138. package/packages/theme-chalk/lib/button.css +1 -0
  139. package/packages/theme-chalk/lib/calendar.css +1 -0
  140. package/packages/theme-chalk/lib/cascader.css +1 -0
  141. package/packages/theme-chalk/lib/cell.css +1 -0
  142. package/packages/theme-chalk/lib/checkbox.css +1 -0
  143. package/packages/theme-chalk/lib/circle.css +1 -0
  144. package/packages/theme-chalk/lib/count-down.css +0 -0
  145. package/packages/theme-chalk/lib/date.css +0 -0
  146. package/packages/theme-chalk/lib/empty.css +0 -0
  147. package/packages/theme-chalk/lib/esign.css +1 -0
  148. package/packages/theme-chalk/lib/field.css +1 -0
  149. package/packages/theme-chalk/lib/flow-btn.css +1 -0
  150. package/packages/theme-chalk/lib/flow-list-task-read.css +1 -0
  151. package/packages/theme-chalk/lib/flow-list.css +1 -0
  152. package/packages/theme-chalk/lib/flow.css +1 -0
  153. package/packages/theme-chalk/lib/fonts/iconfont.scss +98 -0
  154. package/packages/theme-chalk/lib/fonts/iconfont.ttf +0 -0
  155. package/packages/theme-chalk/lib/fonts/iconfont.woff +0 -0
  156. package/packages/theme-chalk/lib/fonts/iconfont1.scss +90 -0
  157. package/packages/theme-chalk/lib/form.css +1 -0
  158. package/packages/theme-chalk/lib/grid-item.css +1 -0
  159. package/packages/theme-chalk/lib/grid.css +1 -0
  160. package/packages/theme-chalk/lib/icon.css +1 -0
  161. package/packages/theme-chalk/lib/image-preview.css +0 -0
  162. package/packages/theme-chalk/lib/image.css +0 -0
  163. package/packages/theme-chalk/lib/index.css +1 -0
  164. package/packages/theme-chalk/lib/list.css +0 -0
  165. package/packages/theme-chalk/lib/loading.css +0 -0
  166. package/packages/theme-chalk/lib/nav-bar.css +0 -0
  167. package/packages/theme-chalk/lib/navbar.css +1 -0
  168. package/packages/theme-chalk/lib/notice-bar.css +0 -0
  169. package/packages/theme-chalk/lib/pagination.css +1 -0
  170. package/packages/theme-chalk/lib/picker.css +1 -0
  171. package/packages/theme-chalk/lib/popover.css +0 -0
  172. package/packages/theme-chalk/lib/popup.css +0 -0
  173. package/packages/theme-chalk/lib/pull-refresh.css +0 -0
  174. package/packages/theme-chalk/lib/radio.css +1 -0
  175. package/packages/theme-chalk/lib/rate.css +0 -0
  176. package/packages/theme-chalk/lib/retrial-auth.css +1 -0
  177. package/packages/theme-chalk/lib/search.css +0 -0
  178. package/packages/theme-chalk/lib/selector.css +1 -0
  179. package/packages/theme-chalk/lib/skeleton.css +0 -0
  180. package/packages/theme-chalk/lib/stepper.css +1 -0
  181. package/packages/theme-chalk/lib/swipe.css +0 -0
  182. package/packages/theme-chalk/lib/switch.css +1 -0
  183. package/packages/theme-chalk/lib/tab.css +0 -0
  184. package/packages/theme-chalk/lib/table-column.css +0 -0
  185. package/packages/theme-chalk/lib/table.css +1 -0
  186. package/packages/theme-chalk/lib/tabs.css +1 -0
  187. package/packages/theme-chalk/lib/tag.css +1 -0
  188. package/packages/theme-chalk/lib/theme.css +0 -0
  189. package/packages/theme-chalk/lib/tree.css +1 -0
  190. package/packages/theme-chalk/lib/uploader.css +0 -0
  191. package/packages/theme-chalk/src/base.scss +195 -195
  192. package/packages/theme-chalk/src/button-group.scss +25 -25
  193. package/packages/theme-chalk/src/button.scss +2 -2
  194. package/packages/theme-chalk/src/calendar.scss +11 -11
  195. package/packages/theme-chalk/src/cascader.scss +11 -11
  196. package/packages/theme-chalk/src/cell.scss +14 -14
  197. package/packages/theme-chalk/src/checkbox.scss +9 -9
  198. package/packages/theme-chalk/src/circle.scss +6 -6
  199. package/packages/theme-chalk/src/common/var.scss +1525 -1525
  200. package/packages/theme-chalk/src/esign.scss +51 -51
  201. package/packages/theme-chalk/src/field.scss +98 -98
  202. package/packages/theme-chalk/src/flow-btn.scss +99 -99
  203. package/packages/theme-chalk/src/flow-list.scss +122 -122
  204. package/packages/theme-chalk/src/fonts/iconfont.scss +98 -98
  205. package/packages/theme-chalk/src/fonts/iconfont1.scss +90 -90
  206. package/packages/theme-chalk/src/form.scss +107 -33
  207. package/packages/theme-chalk/src/grid-item.scss +16 -16
  208. package/packages/theme-chalk/src/grid.scss +46 -46
  209. package/packages/theme-chalk/src/icon.scss +1661 -1661
  210. package/packages/theme-chalk/src/mixins/color.scss +117 -117
  211. package/packages/theme-chalk/src/navbar.scss +5 -5
  212. package/packages/theme-chalk/src/pagination.scss +12 -12
  213. package/packages/theme-chalk/src/picker.scss +31 -31
  214. package/packages/theme-chalk/src/radio.scss +6 -6
  215. package/packages/theme-chalk/src/retrial-auth.scss +28 -28
  216. package/packages/theme-chalk/src/selector.scss +247 -247
  217. package/packages/theme-chalk/src/stepper.scss +9 -9
  218. package/packages/theme-chalk/src/switch.scss +5 -5
  219. package/packages/theme-chalk/src/table.scss +86 -86
  220. package/packages/theme-chalk/src/tabs.scss +31 -31
  221. package/packages/theme-chalk/src/tag.scss +12 -12
  222. package/packages/theme-chalk/src/theme.scss +1 -1
  223. package/packages/theme-chalk/src/tree.scss +127 -127
  224. package/packages/uploader/index.js +5 -5
  225. package/src/config/api.js +190 -190
  226. package/src/index.js +1 -1
  227. package/src/utils/axios.js +217 -217
  228. package/src/utils/date-util.js +312 -312
  229. package/src/utils/http.js +106 -106
  230. package/src/utils/rules.js +18 -18
  231. package/src/utils/store.js +21 -21
  232. package/packages/theme-chalk/gulpfile.js +0 -25
@@ -1,401 +1,401 @@
1
- <template>
2
- <div class="em-date">
3
- <em-input
4
- readonly
5
- clickable
6
- v-bind="$attrs"
7
- :label="label"
8
- :value="pickerValue || ''"
9
- :label-align="labelAlign"
10
- :input-align="inputAlign"
11
- :label-width="labelWidth"
12
- :center="center"
13
- :required="required"
14
- :hideLabel="hideLabel"
15
- :placeholder="
16
- (disabled || readonly) && placeholder == undefined ? '暂无数据' : placeholder != undefined ? placeholder : `请选择${label}`
17
- "
18
- @click="handlePicker"
19
- >
20
- <template slot="input">
21
- <span
22
- v-if="pickerValue"
23
- :style="`color:${disabled || readonly ? '#c8c9cc' : ''}`"
24
- >{{ pickerValue}} </span
25
- >
26
- <span style="color:#c8c9cc" v-else>{{
27
- (disabled || readonly) && placeholder == undefined ? '暂无数据' : placeholder != undefined ? placeholder : `请选择${label}`
28
- }}</span>
29
- </template>
30
- <template slot="right-icon" v-if="clearable">
31
- <span @click.stop="handleClear"
32
- ><van-icon name="clear" color="#C8C9CC"
33
- /></span>
34
- </template>
35
- </em-input>
36
- <van-popup
37
- v-model="showPicker"
38
- v-on="$listeners"
39
- round
40
- @close="onCancel"
41
- position="bottom"
42
- >
43
- <EmDateTime
44
- v-if="type == 'datetimeSecond'"
45
- :values="value"
46
- :joinStr="joinStr"
47
- :title="label"
48
- :min-date="$attrs['min-date']"
49
- :max-date="$attrs['max-date']"
50
- @confirm="onConfirm"
51
- @cancel="() => (showPicker = false)"
52
- />
53
- <EmDatePicker
54
- v-else
55
- show-toolbar
56
- :model="newValue"
57
- :loading="newLoading"
58
- :type="type"
59
- :timePeriod="timePeriod"
60
- :timePeriodValue="timePeriodValue"
61
- v-bind="$attrs"
62
- @cancel="onCancel"
63
- @confirm="onConfirm"
64
- @change="onChange"
65
- >
66
- <template v-for="(index, name) in $slots" :slot="name">
67
- <slot :name="name" />
68
- </template>
69
- </EmDatePicker>
70
- </van-popup>
71
- </div>
72
- </template>
73
-
74
- <script>
75
- import EmDateTime from './date-time.vue';
76
- import EmDatePicker from './date-picker.vue';
77
- export default {
78
- name: 'EmDate',
79
- components: { EmDateTime, EmDatePicker },
80
- inheritAttrs: false,
81
- data() {
82
- return {
83
- showPicker: false,
84
- newLoading: false,
85
- changeValue: true,
86
- firstShow: true,
87
- newValueKey: '',
88
- newValue: '',
89
- lastValue: '',
90
- dateValues: '',
91
- newColumns: [],
92
- newDefaultIndex: 0,
93
- isOnConfirm: false,
94
- count: 0,
95
- pickerValue: '',
96
- timeText: '',
97
- timePeriodText: ''
98
- };
99
- },
100
- props: {
101
- disabled: {
102
- type: Boolean,
103
- default: false
104
- },
105
- readonly: {
106
- type: Boolean,
107
- default: false
108
- },
109
- required: {
110
- type: Boolean,
111
- default: false
112
- },
113
- hideLabel: {
114
- type: Boolean,
115
- default: false
116
- },
117
- // 绑定值
118
- value: {
119
- type: [String, Array, Object, Date, Number, Boolean],
120
- default: ''
121
- },
122
- // 展示标题
123
- label: {
124
- type: String,
125
- default: '日期选择'
126
- },
127
- // 输入框占位提示文字
128
- placeholder: {
129
- type: String,
130
- default: ''
131
- },
132
- // 多级选择展示拼接字符
133
- joinStr: {
134
- type: String,
135
- default: undefined
136
- },
137
-
138
- loading: {
139
- type: Boolean,
140
- default: false
141
- },
142
- //左侧文本宽度
143
- labelWidth: {
144
- type: String
145
- },
146
- // 左侧文本对齐方式
147
- labelAlign: {
148
- type: String
149
- },
150
- // 右侧内容对齐方式
151
- inputAlign: {
152
- type: String
153
- },
154
- // 是否使内容垂直居中
155
- center: {
156
- type: Boolean
157
- },
158
- type: {
159
- type: String,
160
- default: 'datetime'
161
- },
162
- clearable: {
163
- type: Boolean,
164
- default: false
165
- },
166
- timePeriod: {
167
- type: Boolean,
168
- default: false
169
- },
170
- timePeriodValue: {
171
- type: [String, Number, Boolean],
172
- default: 'AM'
173
- }
174
- },
175
-
176
- watch: {
177
- loading: {
178
- handler(val) {
179
- this.newLoading = val;
180
- },
181
- deep: true,
182
- immediate: true
183
- },
184
- value: {
185
- handler() {
186
- this.changeValue && this.getValFun();
187
- },
188
- deep: true,
189
- immediate: true
190
- }
191
- },
192
-
193
- mounted() {
194
- this.$nextTick(() => {
195
- this.lastValue = this.value;
196
- });
197
- },
198
- methods: {
199
- handleClear() {
200
- this.pickerValue = '';
201
- this.timeText = '';
202
- this.lastValue = '';
203
- this.$emit(
204
- 'input',
205
- this.timePeriod && this.type === 'datehour'
206
- ? this.timeText
207
- : this.pickerValue
208
- );
209
- },
210
- onChange(picker) {
211
- this.$emit('change', picker);
212
- },
213
- getValFun(val) {
214
- const _that = this;
215
- if (_that.isOnConfirm) return;
216
- if (!val) {
217
- if (
218
- (_that.value != undefined && _that.value) ||
219
- (_that.value == undefined && _that.value)
220
- ) {
221
- _that.pickerValue = _that.getValue(_that.value);
222
- } else {
223
- _that.pickerValue = _that.value;
224
- }
225
- } else {
226
- _that.pickerValue = _that.getValue(_that.val);
227
- }
228
-
229
- const { type } = _that;
230
- if (type === 'time') {
231
- _that.newValue = _that.value != undefined ? _that.value : _that.value;
232
- return;
233
- }
234
- // if(_that.count == 0 || _that.value != undefined) {
235
- // _that.count++
236
- let date = _that.value;
237
- if (typeof date == 'string') {
238
- if (type != 'year') {
239
- date = date.replace('年', '/');
240
- } else {
241
- date = date.replace(this.joinStr || '年', '');
242
- }
243
- if (type == 'year-month') {
244
- date = date.replace('月', '');
245
- } else {
246
- date = date.replace('月', '/');
247
- }
248
- date = date.replace('日', ' ');
249
- date = date.replace('时', ':');
250
- date = date.replace('分', ':');
251
- date = date.replace('秒', '');
252
-
253
- // date = date.replace(/-/g, '/');
254
- date = date.trim();
255
- }
256
- _that.isOnConfirm = false;
257
- _that.newValue =
258
- date != undefined && date
259
- ? new Date(date || '')
260
- : date == undefined && _that.value
261
- ? new Date(_that.value || '')
262
- : new Date();
263
- // }
264
- },
265
- onCancel() {
266
- this.$emit('input', this.lastValue);
267
- this.getValFun(this.lastValue);
268
- this.showPicker = false;
269
- },
270
- onConfirm(value, timePeriod) {
271
-
272
- this.showPicker = false;
273
- this.timePeriodText = timePeriod;
274
- this.pickerValue = this.getValue(value);
275
- this.isOnConfirm = true;
276
- this.lastValue = value;
277
- this.changeValue = false;
278
- this.$emit(
279
- 'input',
280
- this.timePeriod && this.type === 'datehour'
281
- ? this.timeText
282
- : this.pickerValue
283
- );
284
- this.$emit('confirm', this.pickerValue.replace(/\s/g, ""), this.timePeriodText);
285
- },
286
- getValue(val) {
287
- const { type } = this;
288
- let timePeriodText = '';
289
- if (this.timePeriod && (this.timePeriodText || this.timePeriodValue)) {
290
- timePeriodText =
291
- (this.timePeriodText || this.timePeriodValue) == 'AM'
292
- ? '上午'
293
- : '下午';
294
- }
295
- let value = '';
296
- if (!this.value && !val && this.value == undefined) return;
297
- if (val && typeof val == 'string') {
298
- return val;
299
- } else if (
300
- this.value &&
301
- typeof this.value == 'string' &&
302
- val &&
303
- typeof val == 'string'
304
- ) {
305
- return this.value;
306
- }
307
- let newValue = new Date(val || this.value);
308
-
309
- if (typeof newValue == 'string') {
310
- newValue = newValue.replace('年', '/');
311
- newValue = newValue.replace('月', '/');
312
- newValue = newValue.replace('日', ' ');
313
- newValue = newValue.replace('时', ':');
314
- newValue = newValue.replace('分', ':');
315
- newValue = newValue.replace('秒', '');
316
- newValue = newValue.replace(/-/g, '/');
317
- newValue = newValue.trim();
318
- }
319
- let date = new Date(newValue);
320
- let y = date.getFullYear();
321
- let m =
322
- date.getMonth() + 1 < 10
323
- ? '0' + (date.getMonth() + 1)
324
- : date.getMonth() + 1;
325
- let d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
326
- let h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
327
- let minute =
328
- date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
329
- let s =
330
- date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
331
- if (type == 'date' && newValue != 'Invalid Date') {
332
- value =
333
- y +
334
- (this.joinStr || '年') +
335
- m +
336
- (this.joinStr || '月') +
337
- d +
338
- (this.joinStr ? ' ' : '日 ');
339
- } else if (type === 'year-month' && newValue != 'Invalid Date') {
340
- value = y + (this.joinStr || '年') + m + (this.joinStr ? ' ' : '月');
341
- } else if (type === 'month-day' && newValue != 'Invalid Date') {
342
- value = m + (this.joinStr || '月') + d + (this.joinStr ? ' ' : '日');
343
- } else if (type === 'time' && newValue.split(':').length >= 2) {
344
- let time = [newValue.split(':')[0], newValue.split(':')[1]];
345
- value = this.joinStr
346
- ? time.join(':')
347
- : time.join(':').replace(':', '时') + '分';
348
- } else if (
349
- (type === 'datetime' || type === 'datetimeSecond') &&
350
- newValue != 'Invalid Date'
351
- ) {
352
- value =
353
- y +
354
- (this.joinStr || '年') +
355
- m +
356
- (this.joinStr || '月') +
357
- d +
358
- (this.joinStr ? ' ' : '日 ') +
359
- h +
360
- (this.joinStr ? ':' : '时') +
361
- minute +
362
- (this.joinStr ? (type === 'datetimeSecond' ? ':' : '') : '分') +
363
- (type === 'datetimeSecond' ? s + (this.joinStr ? '' : '秒') : '');
364
- } else if (type === 'datehour' && newValue != 'Invalid Date') {
365
- value =
366
- y +
367
- (this.joinStr || '年') +
368
- m +
369
- (this.joinStr || '月') +
370
- d +
371
- (this.joinStr ? ' ' : '日 ') +
372
- (this.timePeriod ? timePeriodText : h + (this.joinStr ? ' ' : '时'));
373
- if (this.timePeriod && type === 'datehour') {
374
- this.timeText =
375
- y +
376
- (this.joinStr || '年') +
377
- m +
378
- (this.joinStr || '月') +
379
- d +
380
- (this.joinStr ? '' : '日 ');
381
- }
382
- } else if (type === 'year' && newValue != 'Invalid Date') {
383
- value = y + (this.joinStr ? '' : '年');
384
- }
385
- return value;
386
- },
387
-
388
- handlePicker() {
389
- if (this.disabled || this.readonly) return;
390
- if (this.firstShow) {
391
- this.lastValue = this.value;
392
- }
393
- this.firstShow = false;
394
- this.showPicker = true;
395
- this.$emit('showPicker');
396
- }
397
- }
398
- };
399
- </script>
400
-
401
- <style></style>
1
+ <template>
2
+ <div class="em-date">
3
+ <em-input
4
+ readonly
5
+ clickable
6
+ v-bind="$attrs"
7
+ :label="label"
8
+ :value="pickerValue || ''"
9
+ :label-align="labelAlign"
10
+ :input-align="inputAlign"
11
+ :label-width="labelWidth"
12
+ :center="center"
13
+ :required="required"
14
+ :hideLabel="hideLabel"
15
+ :placeholder="
16
+ (disabled || readonly) && placeholder == undefined ? '暂无数据' : placeholder != undefined ? placeholder : `请选择${label}`
17
+ "
18
+ @click="handlePicker"
19
+ >
20
+ <template slot="input">
21
+ <span
22
+ v-if="pickerValue"
23
+ :style="`color:${disabled || readonly ? '#c8c9cc' : ''}`"
24
+ >{{ pickerValue}} </span
25
+ >
26
+ <span style="color:#c8c9cc" v-else>{{
27
+ (disabled || readonly) && placeholder == undefined ? '暂无数据' : placeholder != undefined ? placeholder : `请选择${label}`
28
+ }}</span>
29
+ </template>
30
+ <template slot="right-icon" v-if="clearable">
31
+ <span @click.stop="handleClear"
32
+ ><van-icon name="clear" color="#C8C9CC"
33
+ /></span>
34
+ </template>
35
+ </em-input>
36
+ <van-popup
37
+ v-model="showPicker"
38
+ v-on="$listeners"
39
+ round
40
+ @close="onCancel"
41
+ position="bottom"
42
+ >
43
+ <EmDateTime
44
+ v-if="type == 'datetimeSecond'"
45
+ :values="value"
46
+ :joinStr="joinStr"
47
+ :title="label"
48
+ :min-date="$attrs['min-date']"
49
+ :max-date="$attrs['max-date']"
50
+ @confirm="onConfirm"
51
+ @cancel="() => (showPicker = false)"
52
+ />
53
+ <EmDatePicker
54
+ v-else
55
+ show-toolbar
56
+ :model="newValue"
57
+ :loading="newLoading"
58
+ :type="type"
59
+ :timePeriod="timePeriod"
60
+ :timePeriodValue="timePeriodValue"
61
+ v-bind="$attrs"
62
+ @cancel="onCancel"
63
+ @confirm="onConfirm"
64
+ @change="onChange"
65
+ >
66
+ <template v-for="(index, name) in $slots" :slot="name">
67
+ <slot :name="name" />
68
+ </template>
69
+ </EmDatePicker>
70
+ </van-popup>
71
+ </div>
72
+ </template>
73
+
74
+ <script>
75
+ import EmDateTime from './date-time.vue';
76
+ import EmDatePicker from './date-picker.vue';
77
+ export default {
78
+ name: 'EmDate',
79
+ components: { EmDateTime, EmDatePicker },
80
+ inheritAttrs: false,
81
+ data() {
82
+ return {
83
+ showPicker: false,
84
+ newLoading: false,
85
+ changeValue: true,
86
+ firstShow: true,
87
+ newValueKey: '',
88
+ newValue: '',
89
+ lastValue: '',
90
+ dateValues: '',
91
+ newColumns: [],
92
+ newDefaultIndex: 0,
93
+ isOnConfirm: false,
94
+ count: 0,
95
+ pickerValue: '',
96
+ timeText: '',
97
+ timePeriodText: ''
98
+ };
99
+ },
100
+ props: {
101
+ disabled: {
102
+ type: Boolean,
103
+ default: false
104
+ },
105
+ readonly: {
106
+ type: Boolean,
107
+ default: false
108
+ },
109
+ required: {
110
+ type: Boolean,
111
+ default: false
112
+ },
113
+ hideLabel: {
114
+ type: Boolean,
115
+ default: false
116
+ },
117
+ // 绑定值
118
+ value: {
119
+ type: [String, Array, Object, Date, Number, Boolean],
120
+ default: ''
121
+ },
122
+ // 展示标题
123
+ label: {
124
+ type: String,
125
+ default: '日期选择'
126
+ },
127
+ // 输入框占位提示文字
128
+ placeholder: {
129
+ type: String,
130
+ default: ''
131
+ },
132
+ // 多级选择展示拼接字符
133
+ joinStr: {
134
+ type: String,
135
+ default: undefined
136
+ },
137
+
138
+ loading: {
139
+ type: Boolean,
140
+ default: false
141
+ },
142
+ //左侧文本宽度
143
+ labelWidth: {
144
+ type: String
145
+ },
146
+ // 左侧文本对齐方式
147
+ labelAlign: {
148
+ type: String
149
+ },
150
+ // 右侧内容对齐方式
151
+ inputAlign: {
152
+ type: String
153
+ },
154
+ // 是否使内容垂直居中
155
+ center: {
156
+ type: Boolean
157
+ },
158
+ type: {
159
+ type: String,
160
+ default: 'datetime'
161
+ },
162
+ clearable: {
163
+ type: Boolean,
164
+ default: false
165
+ },
166
+ timePeriod: {
167
+ type: Boolean,
168
+ default: false
169
+ },
170
+ timePeriodValue: {
171
+ type: [String, Number, Boolean],
172
+ default: 'AM'
173
+ }
174
+ },
175
+
176
+ watch: {
177
+ loading: {
178
+ handler(val) {
179
+ this.newLoading = val;
180
+ },
181
+ deep: true,
182
+ immediate: true
183
+ },
184
+ value: {
185
+ handler() {
186
+ this.changeValue && this.getValFun();
187
+ },
188
+ deep: true,
189
+ immediate: true
190
+ }
191
+ },
192
+
193
+ mounted() {
194
+ this.$nextTick(() => {
195
+ this.lastValue = this.value;
196
+ });
197
+ },
198
+ methods: {
199
+ handleClear() {
200
+ this.pickerValue = '';
201
+ this.timeText = '';
202
+ this.lastValue = '';
203
+ this.$emit(
204
+ 'input',
205
+ this.timePeriod && this.type === 'datehour'
206
+ ? this.timeText
207
+ : this.pickerValue
208
+ );
209
+ },
210
+ onChange(picker) {
211
+ this.$emit('change', picker);
212
+ },
213
+ getValFun(val) {
214
+ const _that = this;
215
+ if (_that.isOnConfirm) return;
216
+ if (!val) {
217
+ if (
218
+ (_that.value != undefined && _that.value) ||
219
+ (_that.value == undefined && _that.value)
220
+ ) {
221
+ _that.pickerValue = _that.getValue(_that.value);
222
+ } else {
223
+ _that.pickerValue = _that.value;
224
+ }
225
+ } else {
226
+ _that.pickerValue = _that.getValue(_that.val);
227
+ }
228
+
229
+ const { type } = _that;
230
+ if (type === 'time') {
231
+ _that.newValue = _that.value != undefined ? _that.value : _that.value;
232
+ return;
233
+ }
234
+ // if(_that.count == 0 || _that.value != undefined) {
235
+ // _that.count++
236
+ let date = _that.value;
237
+ if (typeof date == 'string') {
238
+ if (type != 'year') {
239
+ date = date.replace('年', '/');
240
+ } else {
241
+ date = date.replace(this.joinStr || '年', '');
242
+ }
243
+ if (type == 'year-month') {
244
+ date = date.replace('月', '');
245
+ } else {
246
+ date = date.replace('月', '/');
247
+ }
248
+ date = date.replace('日', ' ');
249
+ date = date.replace('时', ':');
250
+ date = date.replace('分', ':');
251
+ date = date.replace('秒', '');
252
+
253
+ // date = date.replace(/-/g, '/');
254
+ date = date.trim();
255
+ }
256
+ _that.isOnConfirm = false;
257
+ _that.newValue =
258
+ date != undefined && date
259
+ ? new Date(date || '')
260
+ : date == undefined && _that.value
261
+ ? new Date(_that.value || '')
262
+ : new Date();
263
+ // }
264
+ },
265
+ onCancel() {
266
+ this.$emit('input', this.lastValue);
267
+ this.getValFun(this.lastValue);
268
+ this.showPicker = false;
269
+ },
270
+ onConfirm(value, timePeriod) {
271
+
272
+ this.showPicker = false;
273
+ this.timePeriodText = timePeriod;
274
+ this.pickerValue = this.getValue(value);
275
+ this.isOnConfirm = true;
276
+ this.lastValue = value;
277
+ this.changeValue = false;
278
+ this.$emit(
279
+ 'input',
280
+ this.timePeriod && this.type === 'datehour'
281
+ ? this.timeText
282
+ : this.pickerValue
283
+ );
284
+ this.$emit('confirm', this.pickerValue.replace(/\s/g, ""), this.timePeriodText);
285
+ },
286
+ getValue(val) {
287
+ const { type } = this;
288
+ let timePeriodText = '';
289
+ if (this.timePeriod && (this.timePeriodText || this.timePeriodValue)) {
290
+ timePeriodText =
291
+ (this.timePeriodText || this.timePeriodValue) == 'AM'
292
+ ? '上午'
293
+ : '下午';
294
+ }
295
+ let value = '';
296
+ if (!this.value && !val && this.value == undefined) return;
297
+ if (val && typeof val == 'string') {
298
+ return val;
299
+ } else if (
300
+ this.value &&
301
+ typeof this.value == 'string' &&
302
+ val &&
303
+ typeof val == 'string'
304
+ ) {
305
+ return this.value;
306
+ }
307
+ let newValue = new Date(val || this.value);
308
+
309
+ if (typeof newValue == 'string') {
310
+ newValue = newValue.replace('年', '/');
311
+ newValue = newValue.replace('月', '/');
312
+ newValue = newValue.replace('日', ' ');
313
+ newValue = newValue.replace('时', ':');
314
+ newValue = newValue.replace('分', ':');
315
+ newValue = newValue.replace('秒', '');
316
+ newValue = newValue.replace(/-/g, '/');
317
+ newValue = newValue.trim();
318
+ }
319
+ let date = new Date(newValue);
320
+ let y = date.getFullYear();
321
+ let m =
322
+ date.getMonth() + 1 < 10
323
+ ? '0' + (date.getMonth() + 1)
324
+ : date.getMonth() + 1;
325
+ let d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
326
+ let h = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
327
+ let minute =
328
+ date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
329
+ let s =
330
+ date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
331
+ if (type == 'date' && newValue != 'Invalid Date') {
332
+ value =
333
+ y +
334
+ (this.joinStr || '年') +
335
+ m +
336
+ (this.joinStr || '月') +
337
+ d +
338
+ (this.joinStr ? ' ' : '日 ');
339
+ } else if (type === 'year-month' && newValue != 'Invalid Date') {
340
+ value = y + (this.joinStr || '年') + m + (this.joinStr ? ' ' : '月');
341
+ } else if (type === 'month-day' && newValue != 'Invalid Date') {
342
+ value = m + (this.joinStr || '月') + d + (this.joinStr ? ' ' : '日');
343
+ } else if (type === 'time' && newValue.split(':').length >= 2) {
344
+ let time = [newValue.split(':')[0], newValue.split(':')[1]];
345
+ value = this.joinStr
346
+ ? time.join(':')
347
+ : time.join(':').replace(':', '时') + '分';
348
+ } else if (
349
+ (type === 'datetime' || type === 'datetimeSecond') &&
350
+ newValue != 'Invalid Date'
351
+ ) {
352
+ value =
353
+ y +
354
+ (this.joinStr || '年') +
355
+ m +
356
+ (this.joinStr || '月') +
357
+ d +
358
+ (this.joinStr ? ' ' : '日 ') +
359
+ h +
360
+ (this.joinStr ? ':' : '时') +
361
+ minute +
362
+ (this.joinStr ? (type === 'datetimeSecond' ? ':' : '') : '分') +
363
+ (type === 'datetimeSecond' ? s + (this.joinStr ? '' : '秒') : '');
364
+ } else if (type === 'datehour' && newValue != 'Invalid Date') {
365
+ value =
366
+ y +
367
+ (this.joinStr || '年') +
368
+ m +
369
+ (this.joinStr || '月') +
370
+ d +
371
+ (this.joinStr ? ' ' : '日 ') +
372
+ (this.timePeriod ? timePeriodText : h + (this.joinStr ? ' ' : '时'));
373
+ if (this.timePeriod && type === 'datehour') {
374
+ this.timeText =
375
+ y +
376
+ (this.joinStr || '年') +
377
+ m +
378
+ (this.joinStr || '月') +
379
+ d +
380
+ (this.joinStr ? '' : '日 ');
381
+ }
382
+ } else if (type === 'year' && newValue != 'Invalid Date') {
383
+ value = y + (this.joinStr ? '' : '年');
384
+ }
385
+ return value;
386
+ },
387
+
388
+ handlePicker() {
389
+ if (this.disabled || this.readonly) return;
390
+ if (this.firstShow) {
391
+ this.lastValue = this.value;
392
+ }
393
+ this.firstShow = false;
394
+ this.showPicker = true;
395
+ this.$emit('showPicker');
396
+ }
397
+ }
398
+ };
399
+ </script>
400
+
401
+ <style></style>