@neatui/nuxt 0.1.0 → 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 (84) hide show
  1. package/BUILD.md +128 -0
  2. package/README.md +98 -1
  3. package/SSR_COMPATIBILITY.md +201 -0
  4. package/USAGE.md +260 -0
  5. package/nuxt.config.example.ts +37 -0
  6. package/package.json +29 -11
  7. package/src/components/basic/IDraggable.vue +87 -65
  8. package/src/components/basic/IFollowView.vue +32 -23
  9. package/src/components/basic/IRouterView.vue +38 -23
  10. package/src/components/basic/IScrollView.vue +11 -7
  11. package/src/components/basic/Icon.vue +17 -17
  12. package/src/components/basic/LayerView/Layer.vue +33 -106
  13. package/src/components/basic/follow.ts +133 -0
  14. package/src/components/display/Calendar.vue +14 -14
  15. package/src/components/display/CalendarReg.vue +14 -14
  16. package/src/components/display/Image.vue +8 -8
  17. package/src/components/display/PhotoEditor.vue +36 -36
  18. package/src/components/display/PhotoViewer.vue +8 -8
  19. package/src/components/display/Tree.vue +6 -6
  20. package/src/components/display/TreeView.vue +4 -4
  21. package/src/components/display/index.ts +2 -2
  22. package/src/components/form/Cascader.vue +19 -19
  23. package/src/components/form/Checkbox.vue +64 -0
  24. package/src/components/form/DatePicker.vue +6 -7
  25. package/src/components/form/DateRangePicker@v3.vue +4 -4
  26. package/src/components/form/DateRangeView@v3.vue +18 -19
  27. package/src/components/form/DateView.vue +14 -14
  28. package/src/components/form/DateView@v2.vue +14 -14
  29. package/src/components/form/DateView@v3.vue +331 -318
  30. package/src/components/form/ImgUpload.vue +7 -7
  31. package/src/components/form/Input@v3.vue +11 -11
  32. package/src/components/form/MoreSelect@v3.vue +87 -17
  33. package/src/components/form/MoreSelectList.vue +8 -8
  34. package/src/components/form/MoreSelectPanel@v3.vue +3 -3
  35. package/src/components/form/MoreSelectPicker.vue +7 -7
  36. package/src/components/form/MoreSelectTags.vue +8 -8
  37. package/src/components/form/PageMoreSelect.vue +14 -14
  38. package/src/components/form/PageSelect.vue +16 -16
  39. package/src/components/form/SearchMoreSelect.vue +12 -12
  40. package/src/components/form/SearchSelect@v3.vue +3 -3
  41. package/src/components/form/Select@v3.vue +229 -23
  42. package/src/components/form/SelectList.vue +8 -8
  43. package/src/components/form/SelectPicker.vue +6 -6
  44. package/src/components/form/SelectTags.vue +7 -7
  45. package/src/components/form/SelectTree/SelectTree@v1.vue +5 -5
  46. package/src/components/form/Switch.vue +38 -103
  47. package/src/components/form/TextArea.vue +18 -18
  48. package/src/components/form/Textarea@v2.vue +275 -0
  49. package/src/components/form/TimeView.vue +14 -14
  50. package/src/components/form/Upload.vue +806 -297
  51. package/src/components/form/date.ts +321 -0
  52. package/src/components/form/index.ts +7 -5
  53. package/src/components/form/number.ts +3 -0
  54. package/src/components/form/type.ts +224 -0
  55. package/src/components/icon/OrderIcon.vue +113 -0
  56. package/src/components/loader/FormLoader/FormLoader@v2.vue +193 -195
  57. package/src/components/loader/FormLoader/FormLoader@v3.vue.backup +372 -291
  58. package/src/components/loader/FormLoader/FormRender@v3.vue.backup +4 -0
  59. package/src/components/loader/FormLoader/NodeLoader.vue +85 -0
  60. package/src/components/loader/FormLoader@v1/FormLoader.vue +1 -1
  61. package/src/components/loader/FormLoader@v1/FormRender.vue +49 -24
  62. package/src/components/loader/LayerLoader/LayerLoader.vue +318 -0
  63. package/src/components/loader/LayerLoader/index.ts +2 -0
  64. package/src/components/loader/LayerLoader/style.scss +77 -0
  65. package/src/components/loader/LimitLoader/LimitLoader@v3.vue +39 -28
  66. package/src/components/loader/MoveLoader/MoveLoader.vue +628 -0
  67. package/src/components/loader/MoveLoader/index.ts +2 -0
  68. package/src/components/loader/MoveLoader/style.scss +77 -0
  69. package/src/components/loader/TableLoader/TableLoader.vue +227 -195
  70. package/src/components/loader/TableLoader/TableRender.vue +141 -0
  71. package/src/components/loader/TableLoader/index.ts +47 -0
  72. package/src/components/loader/index.ts +3 -2
  73. package/src/components/tools/Pagination@a.vue +17 -18
  74. package/src/components/tools/Pagination@b.vue +16 -16
  75. package/src/index.ts +2 -1
  76. package/src/module.ts +169 -0
  77. package/src/runtime/types.d.ts +36 -0
  78. package/src/store/{myui.ts → frame.ts} +4 -4
  79. package/src/utils/theme.ts +14 -0
  80. package/tsconfig.json +1 -1
  81. package/src/components/loader/FormLoader/index.ts +0 -2
  82. package/src/components/loader/LimitLoader/LimitLoader.vue.backup +0 -131
  83. package/src/components/loader/LimitLoader/LimitLoader@v2.vue.backup +0 -174
  84. package/src/components/loader/TableLoader/TableColView.vue +0 -115
@@ -1,271 +1,149 @@
1
1
  <template>
2
- <div ui-date="@a" class="fekit-date-view pr" :class="`${frame ? 'b-solid bk-line b-xs r-sm' : ''}`" ui-flex="col xy" style="width: 31em; height: 24.5em">
3
- <div class="flex-block" ui-flex="row xy">
4
- <div style="width: 20em; height: 100%">
5
- <div ui-date-head="" class="h-xs+ flex-fixed nx-sl mt-ss ny-ss b-solid bk-back -bb-xs" ui-flex="row xm">
6
- <div ui-flex="row lm" class="o-lm">
7
- <div ui-btn="@a s none :square" @click="prev('y')">
8
- <Icon name="double-arrow-left" />
9
- </div>
10
- <div ui-btn="@a s none :square" @click="prev('m')">
11
- <Icon name="arrow-left" />
12
- </div>
13
- </div>
14
- <div ui-flex="row cm" class="nx-ss-sub">
15
- <div ui-flex="row cm" class="nx-ss-sub">
16
- <p class="nx-ss-sub nowrap" ui-flex="row cm" ui-btns="@a none xs">
17
- <b @click="setPanelType('year')">{{ state.curr.y }}年</b>
18
- <b @click="setPanelType('month')">{{ state.curr.m }}月</b>
19
- </p>
20
- </div>
21
- </div>
22
- <div ui-flex="row rm" class="o-lm">
23
- <div ui-btn="@a s none :square" @click="next('m')">
24
- <Icon name="arrow-right" />
25
- </div>
26
- <div ui-btn="@a s none :square" @click="next('y')">
27
- <Icon name="double-arrow-right" />
28
- </div>
29
- </div>
30
- </div>
31
- <div ui-date-body="" class="flex-block pr">
32
- <div class="full nb-sm">
33
- <ul ui-flex="row am" class="fs-xs nx-sm nt-sm">
34
- <li class="flex-block ac"><span>日</span></li>
35
- <li class="flex-block ac"><span>一</span></li>
36
- <li class="flex-block ac"><span>二</span></li>
37
- <li class="flex-block ac"><span>三</span></li>
38
- <li class="flex-block ac"><span>四</span></li>
39
- <li class="flex-block ac"><span>五</span></li>
40
- <li class="flex-block ac"><span>六</span></li>
41
- </ul>
42
- <ul ui-date-days="" ui-flex="col xm" class="flex-wrap nx-sm">
43
- <li v-for="(week, idx) in state.curr.days" :key="idx" :ui-date-week="idx + 1" class="flex-block" ui-flex="row am" style="margin-bottom: -0.25em">
44
- <div v-for="(item, i) in week" :key="i" class="pr flex-block nb-sm" ui-flex="col xy">
45
- <div
46
- v-if="item.day"
47
- :ui-date-day="item.day"
48
- class="flex-block"
49
- :class="`${item.range ? 'bg-main-xs' : ''} ${item.sta ? 'r-lt-sl r-lb-sl' : ''} ${item.end ? 'r-rt-sl r-rb-sl' : ''}`"
50
- ui-flex="col cm"
51
- @click="change(item)"
52
- @mouseenter="setRangeValue(item)"
53
- >
54
- <div
55
- ui-flex="col cm"
56
- class="r-sm b-solid bk-none b-xs my-ss ux-scale"
57
- style="width: 1.8em; height: 1.8em"
58
- :class="`${item.isLastMonth || item.isNextMonth ? 'co-idle' : item.isHoliday ? 'co-risk' : ''} ${
59
- item.selected ? 'active bg-main-lm co-fore' : 'hover-bg-weak'
60
- }`"
61
- >
62
- <span>{{ item.day }}</span>
63
- </div>
64
- </div>
65
- <div class="pa full-x lh-xs ny-ss ob-no ol-no nowrap s-ml bold" style="transform-origin: 50% 100%" ui-flex="row ct" v-html="extras(item)"></div>
66
- </div>
67
- </li>
68
- </ul>
69
- </div>
2
+ <div ui-date="@a" class="fekit-date-view pr" :class="`${frame ? 'b-solid bk-line b-xs r-sm' : ''}`" ui-flex="col xy" style="width: 22em">
3
+ <div ui-date-head="" class="flex-fixed nx-ms mt-ss ny-sm b-solid bk-back" ui-flex="row xm">
4
+ <div ui-flex="row lm" class="o-lm">
5
+ <div ui-btn="@a s none :square" @click="prev()">
6
+ <Icon name="arrow-left" />
70
7
  </div>
71
8
  </div>
72
- <div style="width: 11em" class="flex-fixed b-solid bk-back bl-xs" ui-flex="col xy">
73
- <div ui-date-head="" class="h-xs+ flex-fixed nx-sl mt-ss ny-ss b-solid bk-back -bb-xs" ui-flex="row cm">
74
- <div ui-flex="row cm" class="nx-ss-sub">
75
- <div ui-flex="row cm" class="nx-ss-sub">
76
- <p class="nx-ss-sub nowrap" ui-flex="row cm" ui-btns="@a none xs">
77
- <b @click="setPanelType('year')">时间</b>
78
- </p>
79
- </div>
80
- </div>
9
+ <div ui-btns="@a none s" @click="setPanelType()">
10
+ <p v-if="state.type > 2" class="nowrap" ui-flex="row cm">
11
+ <b class="nx-ss">{{ panel.sta }}年</b>
12
+ <span class="nx-xs">-</span>
13
+ <b class="nx-ss">{{ panel.end }}年</b>
14
+ </p>
15
+ <p v-else-if="state.type === 1" class="nowrap" ui-flex="row cm">
16
+ <b class="nx-ss">{{ state.curr.y }}年</b>
17
+ </p>
18
+ <p v-else class="nowrap" ui-flex="row cm">
19
+ <b class="nx-xs">{{ state.curr.y }}年</b>
20
+ <b class="nx-xs">{{ state.curr.M }}月</b>
21
+ </p>
22
+ </div>
23
+ <div ui-flex="row rm" class="o-lm">
24
+ <div ui-btn="@a s none :square" @click="next()">
25
+ <Icon name="arrow-right" />
81
26
  </div>
82
- <div ui-date-body="" class="flex-block pr nl-ss n-ss-sub ac">
83
- <div class="full" ui-row="mob-8">
84
- <div class="full" ui-scroll=":y" style="padding-bottom: 15.2em">
85
- <ul ui-btns="@a none s :block">
86
- <li>00</li>
87
- <li>01</li>
88
- <li>02</li>
89
- <li>03</li>
90
- <li>04</li>
91
- <li>05</li>
92
- <li>06</li>
93
- <li>07</li>
94
- <li>08</li>
95
- <li>09</li>
96
- <li>10</li>
97
- <li>11</li>
98
- <li>12</li>
99
- <li>13</li>
100
- <li>14</li>
101
- <li>15</li>
102
- <li>16</li>
103
- <li>17</li>
104
- <li>18</li>
105
- <li>19</li>
106
- <li>20</li>
107
- <li>21</li>
108
- <li>22</li>
109
- <li>23</li>
110
- </ul>
111
- </div>
112
- <div class="full" ui-scroll=":y" style="padding-bottom: 15.2em">
113
- <ul ui-btns="@a none s :block">
114
- <li>00</li>
115
- <li>01</li>
116
- <li>02</li>
117
- <li>03</li>
118
- <li>04</li>
119
- <li>05</li>
120
- <li>06</li>
121
- <li>07</li>
122
- <li>08</li>
123
- <li>09</li>
124
-
125
- <li>10</li>
126
- <li>11</li>
127
- <li>12</li>
128
- <li>13</li>
129
- <li>14</li>
130
- <li>15</li>
131
- <li>16</li>
132
- <li>17</li>
133
- <li>18</li>
134
- <li>19</li>
135
-
136
- <li>20</li>
137
- <li>21</li>
138
- <li>22</li>
139
- <li>23</li>
140
- <li>24</li>
141
- <li>25</li>
142
- <li>26</li>
143
- <li>27</li>
144
- <li>28</li>
145
- <li>29</li>
146
-
147
- <li>30</li>
148
- <li>31</li>
149
- <li>32</li>
150
- <li>33</li>
151
- <li>34</li>
152
- <li>35</li>
153
- <li>36</li>
154
- <li>37</li>
155
- <li>38</li>
156
- <li>39</li>
157
-
158
- <li>40</li>
159
- <li>41</li>
160
- <li>42</li>
161
- <li>43</li>
162
- <li>44</li>
163
- <li>45</li>
164
- <li>46</li>
165
- <li>47</li>
166
- <li>48</li>
167
- <li>49</li>
168
-
169
- <li>50</li>
170
- <li>51</li>
171
- <li>52</li>
172
- <li>53</li>
173
- <li>54</li>
174
- <li>55</li>
175
- <li>56</li>
176
- <li>57</li>
177
- <li>58</li>
178
- <li>59</li>
179
- </ul>
180
- </div>
181
- <div class="full" ui-scroll=":y" style="padding-bottom: 15.2em">
182
- <ul ui-btns="@a none s :block">
183
- <li>00</li>
184
- <li>01</li>
185
- <li>02</li>
186
- <li>03</li>
187
- <li>04</li>
188
- <li>05</li>
189
- <li>06</li>
190
- <li>07</li>
191
- <li>08</li>
192
- <li>09</li>
193
-
194
- <li>10</li>
195
- <li>11</li>
196
- <li>12</li>
197
- <li>13</li>
198
- <li>14</li>
199
- <li>15</li>
200
- <li>16</li>
201
- <li>17</li>
202
- <li>18</li>
203
- <li>19</li>
204
-
205
- <li>20</li>
206
- <li>21</li>
207
- <li>22</li>
208
- <li>23</li>
209
- <li>24</li>
210
- <li>25</li>
211
- <li>26</li>
212
- <li>27</li>
213
- <li>28</li>
214
- <li>29</li>
215
-
216
- <li>30</li>
217
- <li>31</li>
218
- <li>32</li>
219
- <li>33</li>
220
- <li>34</li>
221
- <li>35</li>
222
- <li>36</li>
223
- <li>37</li>
224
- <li>38</li>
225
- <li>39</li>
226
-
227
- <li>40</li>
228
- <li>41</li>
229
- <li>42</li>
230
- <li>43</li>
231
- <li>44</li>
232
- <li>45</li>
233
- <li>46</li>
234
- <li>47</li>
235
- <li>48</li>
236
- <li>49</li>
237
-
238
- <li>50</li>
239
- <li>51</li>
240
- <li>52</li>
241
- <li>53</li>
242
- <li>54</li>
243
- <li>55</li>
244
- <li>56</li>
245
- <li>57</li>
246
- <li>58</li>
247
- <li>59</li>
248
- </ul>
27
+ </div>
28
+ </div>
29
+ <div ui-date-body="" class="flex-block pr">
30
+ <div v-if="state.type === 2" class="full n-ms">
31
+ <ul ui-row="mob-6" class="n-ms ny-sm-sub">
32
+ <li v-for="(year, idx) in panel.years" :key="idx" ui-flex="col cm" @click="setDateValue('y', year)">
33
+ <div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">{{ year }}</div>
34
+ </li>
35
+ </ul>
36
+ </div>
37
+ <div v-else-if="state.type === 1" class="full">
38
+ <ul ui-row="mob-4" class="n-ms ny-sm-sub">
39
+ <li ui-flex="col cm" @click="setDateValue('m', 1)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">1月</div></li>
40
+ <li ui-flex="col cm" @click="setDateValue('m', 2)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">2月</div></li>
41
+ <li ui-flex="col cm" @click="setDateValue('m', 3)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">3月</div></li>
42
+ <li ui-flex="col cm" @click="setDateValue('m', 4)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">4月</div></li>
43
+ <li ui-flex="col cm" @click="setDateValue('m', 5)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">5月</div></li>
44
+ <li ui-flex="col cm" @click="setDateValue('m', 6)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">6月</div></li>
45
+ <li ui-flex="col cm" @click="setDateValue('m', 7)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">7月</div></li>
46
+ <li ui-flex="col cm" @click="setDateValue('m', 8)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">8月</div></li>
47
+ <li ui-flex="col cm" @click="setDateValue('m', 9)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">9月</div></li>
48
+ <li ui-flex="col cm" @click="setDateValue('m', 10)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">10月</div></li>
49
+ <li ui-flex="col cm" @click="setDateValue('m', 11)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">11月</div></li>
50
+ <li ui-flex="col cm" @click="setDateValue('m', 12)"><div ui-flex="col cm" class="w-xs+ h-xs+ ac ux-none co-main:hover">12月</div></li>
51
+ </ul>
52
+ </div>
53
+ <div v-else class="full">
54
+ <ul ui-flex="row am" class="fs-xs nx-sm nt-sm">
55
+ <li class="flex-block ac"><span>日</span></li>
56
+ <li class="flex-block ac"><span>一</span></li>
57
+ <li class="flex-block ac"><span>二</span></li>
58
+ <li class="flex-block ac"><span>三</span></li>
59
+ <li class="flex-block ac"><span>四</span></li>
60
+ <li class="flex-block ac"><span>五</span></li>
61
+ <li class="flex-block ac"><span>六</span></li>
62
+ </ul>
63
+ <ul ui-date-days="" ui-flex="col xm" class="flex-wrap nx-sm">
64
+ <li v-for="(week, idx) in state.curr.days" :key="idx" :ui-date-week="idx + 1" class="flex-block" ui-flex="row am" style="margin-bottom: -0.25em">
65
+ <div v-for="(item, i) in week" :key="i" class="pr flex-block nb-sm" ui-flex="col xy">
66
+ <div
67
+ v-if="item.day"
68
+ :ui-date-day="item.day"
69
+ class="flex-block"
70
+ :class="`${item.range ? 'bg-main-o-xs' : ''} ${item.sta ? 'r-lt-sl r-lb-sl' : ''} ${item.end ? 'r-rt-sl r-rb-sl' : ''}`"
71
+ ui-flex="col cm"
72
+ @click="change(item)"
73
+ >
74
+ <div
75
+ ui-flex="col cm"
76
+ class="r-sm b-solid bk-none b-xs my-ss ux-scale co-main:hover"
77
+ style="width: 1.8em; height: 1.8em"
78
+ :class="`${item.isLastMonth || item.isNextMonth ? 'co-idle' : item.isHoliday ? 'co-risk' : ''} ${item.selected ? 'active bg-main-o-lm co-fore' : 'hover-bg-weak'}`"
79
+ >
80
+ <span>{{ item.day }}</span>
81
+ </div>
82
+ </div>
83
+ <div class="pa w-full lh-xs ny-ss ob-no ol-no nowrap s-ml bold" style="transform-origin: 50% 100%" ui-flex="row ct" v-html="extras(item)"></div>
249
84
  </div>
250
- </div>
251
- </div>
85
+ </li>
86
+ </ul>
87
+ </div>
88
+ </div>
89
+ <div v-if="!state.isNoTime && state.type === 0" class="ny-sm nx-ms">
90
+ <div class="full ac b-solid bk-back b-xs r-sm" ui-row="mob-8" style="width: 100%; height: 3em; padding: 0.5em">
91
+ <ul
92
+ :style="`${state.panel ? '' : 'pointer-events: none; opacity:.35'}`"
93
+ class="fekit-date-view-time-scroll"
94
+ ref="ths"
95
+ ui-scroll=":y xs"
96
+ ui-btns="@a none s :block"
97
+ data-type="h"
98
+ @scroll="timeScroll"
99
+ >
100
+ <li v-for="(item, idx) in hours" :key="idx">
101
+ {{ item }}
102
+ </li>
103
+ </ul>
104
+ <ul
105
+ :style="`${state.panel ? '' : 'pointer-events: none; opacity:.35'}`"
106
+ class="fekit-date-view-time-scroll"
107
+ ref="tms"
108
+ ui-scroll=":y xs"
109
+ ui-btns="@a none s :block"
110
+ data-type="m"
111
+ @scroll="timeScroll"
112
+ >
113
+ <li v-for="(item, idx) in seconds" :key="idx">
114
+ {{ item }}
115
+ </li>
116
+ </ul>
117
+ <ul
118
+ :style="`${state.panel ? '' : 'pointer-events: none; opacity:.35'}`"
119
+ class="fekit-date-view-time-scroll"
120
+ ref="tss"
121
+ ui-scroll=":y xs"
122
+ ui-btns="@a none s :block"
123
+ data-type="s"
124
+ @scroll="timeScroll"
125
+ >
126
+ <li v-for="(item, idx) in seconds" :key="idx">
127
+ {{ item }}
128
+ </li>
129
+ </ul>
252
130
  </div>
253
131
  </div>
254
- <div v-if="tools" ui-date-foot="" ui-flex="row xm" class="flex-fixed nx-sl ny-sl b-solid bk-line-mm bt-xs">
132
+ <div v-if="tools" ui-date-foot="" ui-flex="row xm" class="flex-fixed nx-sl ny-sl b-solid bk-line-o-mm bt-xs">
255
133
  <div ui-flex="row lm" class="nl-ss">
256
- <p v-if="state.panel" ui-flex="row lm">
257
- <span ui-btn="@a xs none" class="nx-ss" @click="setPanelType('date')">{{ state.panel }}</span>
258
- <span v-if="!state.isNoTime" ui-btn="@a xs none" class="nx-ss" @click="setPanelType('time')"> {{ state.time.h }}:{{ state.time.m }}:{{ state.time.s }} </span>
259
- </p>
134
+ <div v-if="state.panel" ui-flex="row lm">
135
+ <span :anim-editing="state.type === 'date'" class="nx-ss">{{ idate(state.panel).format('YYYY-MM-DD') }}</span>
136
+ <span v-if="!state.isNoTime" :anim-editing="state.type === 'time'" class="nx-ss">{{ idate(state.panel).format('HH:mm:ss') }}</span>
137
+ </div>
260
138
  <div v-else-if="state.shortcuts?.length" ui-flex="row lm">
261
139
  <div class="mr-sm-sub nx-sl-sub ny-ss-sub lh-ss nowrap fs-ss dib-sub" ui-scroll=":x y:hidden">
262
- <p v-for="(item, idx) in state.shortcuts" :key="idx" class="bg-main-xs co-main r-xl" ui-btn="@a xs none :round" @click="item?.func">{{ item?.text }}</p>
263
- <p class="bg-main-xs co-main r-xl" ui-btn="@a xs none :round"><Icon class="co-main" name="more" /></p>
140
+ <p v-for="(item, idx) in state.shortcuts" :key="idx" class="bg-main-o-ss co-main r-xl" ui-btn="@a xs none :round" @click="item?.func">{{ item?.text }}</p>
141
+ <p class="bg-main-o-ss co-main r-xl" ui-btn="@a xs none :round"><Icon class="co-main" name="more" /></p>
264
142
  </div>
265
143
  </div>
266
144
  <div>&nbsp;</div>
267
145
  </div>
268
- <div class="ml-sm-sub" ui-flex="row rm">
146
+ <div class="ml-ss-sub" ui-flex="row rm">
269
147
  <button v-if="state.panel" ui-btn="@a xs none" class="nx-ss co-risk" @click="remove">清除</button>
270
148
  <button v-if="state.panel && !state.isNoTime" ui-btn="@a xs none" class="nx-ss co-main" @click="update">确定</button>
271
149
  </div>
@@ -273,10 +151,14 @@
273
151
  </div>
274
152
  </template>
275
153
  <script setup lang="ts">
276
- import { computed, reactive, watch } from 'vue';
277
- import { idate, isDateString, isObject, isString } from '@fekit/utils';
154
+ import { computed, ref, reactive, watch, onMounted } from 'vue';
155
+ import { isDateString, isObject, isString } from '@fekit/utils';
156
+ // import { idate } from '@fekit/utils';
157
+ import { idate } from './date';
278
158
  import { Icon } from '../basic';
279
159
 
160
+ // const _level: any = { 0: ['d', 1], 1: ['m', 1], 2: ['y', 10], 3: ['y', 100] };
161
+
280
162
  // 创建日期
281
163
  const cDate = (date: any = null) => {
282
164
  return isDateString(date) ? new Date(date) : new Date();
@@ -288,20 +170,20 @@
288
170
  text: '昨天',
289
171
  func() {
290
172
  change({ date: idate(new Date().setDate(new Date().getDate() - 1)).format('YYYY-MM-DD') });
291
- }
173
+ },
292
174
  },
293
175
  today: {
294
176
  text: '今天',
295
177
  func() {
296
178
  change({ date: idate(new Date()).format('YYYY-MM-DD') });
297
- }
179
+ },
298
180
  },
299
181
  tomorrow: {
300
182
  text: '明天',
301
183
  func() {
302
184
  change({ date: idate(new Date().setDate(new Date().getDate() + 1)).format('YYYY-MM-DD') });
303
- }
304
- }
185
+ },
186
+ },
305
187
  };
306
188
 
307
189
  const emits: any = defineEmits(['update:modelValue', 'change', 'update']);
@@ -321,6 +203,7 @@
321
203
  shortcuts?: Array<'yesterday' | 'today' | 'tomorrow'>;
322
204
  extras?: (item: any) => string;
323
205
  time?: boolean | TimeProps;
206
+ lang?: string;
324
207
  }
325
208
  const props: any = withDefaults(defineProps<Props>(), {
326
209
  // 值
@@ -343,74 +226,196 @@
343
226
  format: 'YYYY-MM-DD',
344
227
  // 节假日
345
228
  holiday: () => ({}),
346
- time: false
229
+ time: false,
230
+ // 语言
231
+ lang: 'zh-CN',
232
+ });
233
+
234
+ // 小时
235
+ const hours = computed(() => {
236
+ const _hours: any = [];
237
+ for (let i = 0; i < 24; i++) {
238
+ _hours.push(i > 9 ? `${i}` : `0${i}`);
239
+ }
240
+ return _hours;
241
+ });
242
+ // 分秒
243
+ const seconds = computed(() => {
244
+ const _seconds: any = [];
245
+ for (let i = 0; i < 60; i++) {
246
+ _seconds.push(i > 9 ? `${i}` : `0${i}`);
247
+ }
248
+ return _seconds;
347
249
  });
348
250
 
349
251
  // 内部数据
350
252
  const state: any = reactive({
351
253
  // 面板显示时间
352
- panel: '',
254
+ panel: undefined,
255
+ // 面板年份选择
256
+ years: 0,
353
257
  // 当前时间计算
354
258
  curr: computed(() => {
259
+ // console.log(158, state.panel);
355
260
  const date = idate(state.panel);
356
261
  const days = date.calendar({ group: true, value: [state.panel] });
357
- const { y = 0, M: m = 0, d = 0 } = date.attr || {};
358
- return { days, y, m, d };
262
+ return { days, ...date.attr };
359
263
  }),
360
- type: 'date',
264
+ // 当前面板类型
265
+ type: 0,
361
266
  // 值
362
- value: '',
267
+ value: undefined,
363
268
  // 快捷选择
364
269
  shortcuts: computed(() => {
365
270
  return props.shortcuts.map((item: any) => {
366
271
  return isString(item) ? shortcutsList[item] : item;
367
272
  });
368
273
  }),
369
- // 时间
370
- time: {
371
- h: '00',
372
- m: '00',
373
- s: '00'
374
- },
274
+ // 不带时间(只要时或分的也考虑到)
375
275
  isNoTime: computed(() => {
376
276
  if (isObject(props.time)) {
377
277
  return !(props.time.h || props.time.m || props.time.s);
378
278
  } else {
379
- return props.time;
279
+ return !props.time;
380
280
  }
381
- })
281
+ }),
382
282
  });
383
283
 
284
+ // 面板
285
+ const panel: any = reactive({
286
+ years: computed(() => {
287
+ const startYear = Math.floor(state.curr.year / 10) * 10;
288
+ const list = [];
289
+ for (let i = 0; i < 10; i++) {
290
+ list.push(startYear + i);
291
+ }
292
+ return list;
293
+ }),
294
+ sta: computed(() => {
295
+ return panel.years[0];
296
+ }),
297
+ end: computed(() => {
298
+ return panel.years[9];
299
+ }),
300
+ });
301
+
302
+ // 设置日期
303
+ const setDateValue = (type: any, value: number = 0, add: number = 0) => {
304
+ state.panel = upload(type, value, add);
305
+ // 面板返回上一级
306
+ state.type -= 1;
307
+ };
308
+
309
+ // 时分秒
310
+ const ths: any = ref(null);
311
+ const tms: any = ref(null);
312
+ const tss: any = ref(null);
313
+ const setTimeValue = () => {
314
+ const { H = 0, m = 0, s = 0 }: any = state.curr || {};
315
+ if (state.panel) {
316
+ if (ths.value && ths.value.children[H]) {
317
+ ths.value.scrollTop = ths.value.children[H].offsetTop;
318
+ }
319
+ if (tms.value && tms.value.children[m]) {
320
+ tms.value.scrollTop = tms.value.children[m].offsetTop;
321
+ }
322
+ if (tss.value && tss.value.children[s]) {
323
+ tss.value.scrollTop = tss.value.children[s].offsetTop;
324
+ }
325
+ } else {
326
+ if (ths.value && ths.value.children[H]) {
327
+ ths.value.scrollTop = ths.value.children[0].offsetTop;
328
+ }
329
+ if (tms.value && tms.value.children[m]) {
330
+ tms.value.scrollTop = tms.value.children[0].offsetTop;
331
+ }
332
+ if (tss.value && tss.value.children[s]) {
333
+ tss.value.scrollTop = tss.value.children[0].offsetTop;
334
+ }
335
+ }
336
+ };
337
+
384
338
  watch(
385
339
  () => props.modelValue,
386
340
  (value: any) => {
387
341
  // 面板显示日期
388
- state.panel = value || '';
342
+ state.panel = value || undefined;
389
343
  // 值
390
- state.value = value || '';
391
- // 时间
344
+ state.value = value || undefined;
345
+ },
346
+ { deep: true, immediate: true },
347
+ );
348
+
349
+ onMounted(() => {
350
+ setTimeValue();
351
+ });
352
+ watch(
353
+ () => state.panel,
354
+ () => {
355
+ setTimeValue();
392
356
  },
393
- { deep: true, immediate: true }
394
357
  );
395
358
 
396
359
  // 更新时间
397
- const upload = (a: any = 'm', b: any = 1) => {
360
+ const upload = (type: string = 'm', value: number = 0, add: number = 1) => {
398
361
  const date = cDate(state.panel);
399
- if (a === 'm') {
400
- date.setMonth(date.getMonth() + b);
401
- } else {
402
- date.setFullYear(date.getFullYear() + b);
362
+
363
+ switch (type) {
364
+ case 'y':
365
+ if (value !== 0) {
366
+ date.setFullYear(value);
367
+ } else {
368
+ date.setFullYear(date.getFullYear() + add);
369
+ }
370
+ break;
371
+ case 'm':
372
+ if (value !== 0) {
373
+ date.setMonth(value - 1);
374
+ } else {
375
+ date.setMonth(date.getMonth() + add);
376
+ }
377
+ break;
378
+ case 'd':
379
+ if (value !== 0) {
380
+ date.setDate(value);
381
+ } else {
382
+ date.setDate(date.getDate() + add);
383
+ }
384
+ break;
385
+ case 'h':
386
+ if (value !== 0) {
387
+ date.setHours(value);
388
+ } else {
389
+ date.setHours(date.getHours() + add);
390
+ }
391
+ break;
392
+ case 'n':
393
+ if (value !== 0) {
394
+ date.setMinutes(value);
395
+ } else {
396
+ date.setMinutes(date.getMinutes() + add);
397
+ }
398
+ break;
399
+ case 's':
400
+ if (value !== 0) {
401
+ date.setSeconds(value);
402
+ } else {
403
+ date.setSeconds(date.getSeconds() + add);
404
+ }
405
+ break;
406
+ default:
407
+ break;
403
408
  }
404
409
  return idate(date).format(props.format);
405
410
  };
406
411
 
407
412
  // 日期前翻
408
- const prev = (type: any = 'm') => {
409
- state.panel = upload(type, -1);
413
+ const prev = () => {
414
+ state.panel = upload(state.type > 0 ? 'y' : 'm', 0, state.type === 2 ? -10 : -1);
410
415
  };
411
416
  // 日期后翻
412
- const next = (type: any = 'm') => {
413
- state.panel = upload(type, 1);
417
+ const next = () => {
418
+ state.panel = upload(state.type > 0 ? 'y' : 'm', 0, state.type === 2 ? 10 : 1);
414
419
  };
415
420
 
416
421
  // 向外通信
@@ -418,54 +423,62 @@
418
423
  state.panel = item ? idate(item.date).format(props.format) : item;
419
424
  emits('change', state.value);
420
425
  if (state.isNoTime) {
421
- console.log('这是没有时间的');
422
426
  update();
423
427
  }
424
428
  };
425
429
 
426
430
  // 清空日期
427
431
  const remove = () => {
428
- state.panel = '';
432
+ state.panel = undefined;
429
433
  update();
430
434
  };
431
435
 
432
436
  // 更新数据
433
437
  const update = () => {
434
- emits('update:modelValue', state.panel);
435
- emits('update', state.panel);
438
+ emits('update:modelValue', state.panel ? idate(state.panel).format(props.format) : undefined);
439
+ emits('update', state.panel ? idate(state.panel).format(props.format) : undefined);
436
440
  };
437
441
 
438
- // 设置范围
439
- const setRangeValue = (item: any) => {};
440
- // 设置面板类型
441
- const setPanelType = (type: any) => {
442
- state.type = type;
443
- };
444
- // 设置年份
445
- const setYear = (y: any) => {
446
- state.type = 'month';
442
+ // 面板类型
443
+ const setPanelType = () => {
444
+ if (state.type < 3) {
445
+ state.type += 1;
446
+ }
447
447
  };
448
- // 设置月份
449
- const setMonth = (m: any) => {
450
- state.type = 'date';
448
+
449
+ // 时间滚动
450
+ const _timer: any = ref(null);
451
+ const timeScroll = (ev: any) => {
452
+ const item: any = ev.target?.children[0];
453
+ const type: any = ev.target.getAttribute('data-type') || '';
454
+ if (state.panel && item) {
455
+ clearTimeout(_timer.value);
456
+ _timer.value = setTimeout(() => {
457
+ const h = item.offsetHeight;
458
+ const idx = Math.floor(ev.target.scrollTop / h);
459
+ const { YYYY = 0, MM = 0, DD = 0, HH = '', mm = '', ss = '' }: any = state.curr || {};
460
+ let _panel = `${YYYY}-${MM}-${DD}`;
461
+ if (type === 'h') {
462
+ _panel += ` ${idx}:${mm}:${ss}`;
463
+ }
464
+ if (type === 'm') {
465
+ _panel += ` ${HH}:${idx}:${ss}`;
466
+ }
467
+ if (type === 's') {
468
+ _panel += ` ${HH}:${mm}:${idx}`;
469
+ }
470
+ state.panel = idate(_panel).format('YYYY-MM-DD HH:mm:ss');
471
+ }, 100);
472
+ }
451
473
  };
452
474
  </script>
453
475
  <style lang="scss">
454
- @keyframes am-editing {
455
- 0%,
456
- 20% {
457
- opacity: 1;
458
- }
459
- 40%,
460
- 60% {
461
- opacity: 0;
476
+ .fekit-date-view-time-scroll {
477
+ position: relative;
478
+ height: 100%;
479
+ scroll-snap-type: y mandatory;
480
+ & > * {
481
+ scroll-snap-align: center;
462
482
  }
463
- 80%,
464
- 100% {
465
- opacity: 1;
466
- }
467
- }
468
- .am-editing {
469
- animation: am-editing 1s linear infinite;
470
483
  }
471
484
  </style>