papayaui 0.3.7 → 0.3.8

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.
@@ -172,11 +172,19 @@ const emitRangeConfirm = (start?: Date, end?: Date) => {
172
172
 
173
173
  const openStart = () => {
174
174
  if (!canOpenPopup.value) return
175
+ // 没有已选值时,用 defaultStartDate 或当前时间作为选择器初始时间
176
+ if (!innerStart.value) {
177
+ innerStart.value = props.defaultStartDate || new Date()
178
+ }
175
179
  showStartPopup.value = true
176
180
  }
177
181
 
178
182
  const openEnd = () => {
179
183
  if (!canOpenPopup.value) return
184
+ // 没有已选值时,用 defaultEndDate 或当前时间作为选择器初始时间
185
+ if (!innerEnd.value) {
186
+ innerEnd.value = props.defaultEndDate || new Date()
187
+ }
180
188
  showEndPopup.value = true
181
189
  }
182
190
 
@@ -211,6 +219,8 @@ const onStartConfirm = (val: Date) => {
211
219
  }
212
220
 
213
221
  const onStartCancel = () => {
222
+ // 取消时恢复内部值,防止临时默认值影响下次打开
223
+ innerStart.value = props.start
214
224
  showStartPopup.value = false
215
225
  emit('cancel')
216
226
  }
@@ -235,6 +245,8 @@ const onEndChange = (val: Date) => {
235
245
  }
236
246
 
237
247
  const onEndCancel = () => {
248
+ // 取消时恢复内部值,防止临时默认值影响下次打开
249
+ innerEnd.value = props.end
238
250
  showEndPopup.value = false
239
251
  emit('cancel')
240
252
  }
@@ -15,6 +15,14 @@ export const dateRangePickerProps = {
15
15
  * 结束时间
16
16
  */
17
17
  end: Date,
18
+ /**
19
+ * 开始时间默认值,未设置 start 时打开选择器的初始时间
20
+ */
21
+ defaultStartDate: Date,
22
+ /**
23
+ * 结束时间默认值,未设置 end 时打开选择器的初始时间
24
+ */
25
+ defaultEndDate: Date,
18
26
  /**
19
27
  * 选项类型
20
28
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "papayaui",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "适用于uniapp的ui扩展库",
5
5
  "main": "index.ts",
6
6
  "module": "index.ts",