vue_zhongyou 1.0.11 → 1.0.12

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue_zhongyou",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "keywords": [],
@@ -283,6 +283,9 @@ const addressPopup = ref({
283
283
  columnsPlaceholder: null
284
284
  })
285
285
 
286
+ // 存储各个datetime字段的选择时间
287
+ const dateTimeValues = ref({})
288
+
286
289
  // 单个日期时间弹窗状态
287
290
  const dateTimePopup = ref({
288
291
  visible: false,
@@ -350,6 +353,11 @@ const handleSubmit = () => {
350
353
  }
351
354
 
352
355
  const handleReset = () => {
356
+ // 清除保存的datetime值
357
+ Object.keys(dateTimeValues.value).forEach(key => {
358
+ delete dateTimeValues.value[key]
359
+ })
360
+
353
361
  initializeFormData()
354
362
  emit('update:modelValue', snapshot())
355
363
  emit('reset', snapshot())
@@ -613,16 +621,24 @@ const openDateTime = (field) => {
613
621
  dateTimePopup.value.visible = true
614
622
  dateTimePopup.value.field = field
615
623
 
616
- // 设置默认时间为当天8:30
617
- const today = new Date()
618
- const defaultTime = new Date(today)
619
- defaultTime.setHours(8, 30, 0, 0)
624
+ // 检查是否已有该字段的保存值
625
+ const savedTime = dateTimeValues.value[field.field]
620
626
 
621
- // 将field的时间转换为日期时间格式
622
- dateTimePopup.value.selectedTime = typeof field.defaultValue === 'string' ? reverseFormatDateTime(field.defaultValue) : defaultTime
627
+ // 如果已经有保存的时间,则使用保存的时间,否则设置默认时间为当天8:30
628
+ if (savedTime) {
629
+ dateTimePopup.value.selectedTime = new Date(savedTime)
630
+ } else {
631
+ const today = new Date()
632
+ const defaultTime = new Date(today)
633
+ defaultTime.setHours(8, 30, 0, 0)
634
+
635
+ // 将field的时间转换为日期时间格式
636
+ dateTimePopup.value.selectedTime = typeof field.defaultValue === 'string' ? reverseFormatDateTime(field.defaultValue) : defaultTime
637
+ }
623
638
 
624
- // 初始化当前小时值
625
- dateTimePopup.value.currentHour = '8'
639
+ // 更新当前小时值
640
+ const hours = dateTimePopup.value.selectedTime.getHours()
641
+ dateTimePopup.value.currentHour = hours.toString().padStart(2, '0')
626
642
  }
627
643
 
628
644
  const closeDateTime = () => {
@@ -637,8 +653,11 @@ const confirmDateTime = () => {
637
653
  // 格式化日期时间
638
654
  const dateTimeStr = formatDateTime(dateTimePopup.value.selectedTime)
639
655
 
640
- // 更新表单数据
656
+ // 保存当前字段的时间值
641
657
  if (dateTimePopup.value.field) {
658
+ dateTimeValues.value[dateTimePopup.value.field.field] = new Date(dateTimePopup.value.selectedTime)
659
+
660
+ // 更新表单数据
642
661
  updateFieldValue(dateTimePopup.value.field.field, dateTimeStr)
643
662
  }
644
663