Showing
3 changed files
with
56 additions
and
18 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-31 11:45:30 | 2 | * @Date: 2022-08-31 11:45:30 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-02-07 16:42:28 | 4 | + * @LastEditTime: 2023-02-08 15:01:56 |
| 5 | * @FilePath: /data-table/src/components/DatePickerField/index.vue | 5 | * @FilePath: /data-table/src/components/DatePickerField/index.vue |
| 6 | * @Description: 日期选择组件 | 6 | * @Description: 日期选择组件 |
| 7 | --> | 7 | --> |
| ... | @@ -75,10 +75,20 @@ const minDate = ref() | ... | @@ -75,10 +75,20 @@ const minDate = ref() |
| 75 | const maxDate = ref() | 75 | const maxDate = ref() |
| 76 | 76 | ||
| 77 | onMounted(() => { | 77 | onMounted(() => { |
| 78 | - currentDate.value = props.item.value.split("-"); | 78 | + // 根据默认值时间调整显示 |
| 79 | - const Year = String(dayjs().year()); | 79 | + currentDate.value = props.item.component_props.default ? props.item.component_props.default.split("-") : props.item.value.split("-"); |
| 80 | - const Month = formatZero(dayjs().month(), 2); | 80 | + let Year = ''; |
| 81 | - const Day = formatZero(dayjs().date(), 2); | 81 | + let Month = ''; |
| 82 | + let Day = ''; | ||
| 83 | + if (!props.item.component_props.default) { | ||
| 84 | + Year = String(dayjs().year()); | ||
| 85 | + Month = formatZero(dayjs().month(), 2); | ||
| 86 | + Day = formatZero(dayjs().date(), 2); | ||
| 87 | + } else { | ||
| 88 | + Year = currentDate.value[0]; | ||
| 89 | + Month = formatZero(currentDate.value[1], 2); | ||
| 90 | + Day = formatZero(currentDate.value[2], 2); | ||
| 91 | + } | ||
| 82 | switch (date_format) { | 92 | switch (date_format) { |
| 83 | case "YYYY-MM": | 93 | case "YYYY-MM": |
| 84 | columns_type.value = ['year', 'month'] | 94 | columns_type.value = ['year', 'month'] | ... | ... |
| ... | @@ -81,17 +81,35 @@ const minDate = ref() | ... | @@ -81,17 +81,35 @@ const minDate = ref() |
| 81 | const maxDate = ref() | 81 | const maxDate = ref() |
| 82 | 82 | ||
| 83 | onMounted(() => { | 83 | onMounted(() => { |
| 84 | - // 获取值定位显示 | 84 | + // 根据默认值时间调整显示 |
| 85 | - const datetime = props.item.value.split(" "); | 85 | + const datetime = props.item.component_props.default ? props.item.component_props.default.split(" ") : props.item.value.split(" "); |
| 86 | currentDate.value = datetime[0]?.split("-"); | 86 | currentDate.value = datetime[0]?.split("-"); |
| 87 | currentTime.value = datetime[1]?.split(":"); | 87 | currentTime.value = datetime[1]?.split(":"); |
| 88 | // YYYY=年,YYYY-MM=年月,YYYY-MM-DD=年月日,YYYY-MM-DD HH=年月日时,YYYY-MM-DD HH:mm=年月日时分,YYYY-MM-DD HH:mm:ss=年月日时分秒 | 88 | // YYYY=年,YYYY-MM=年月,YYYY-MM-DD=年月日,YYYY-MM-DD HH=年月日时,YYYY-MM-DD HH:mm=年月日时分,YYYY-MM-DD HH:mm:ss=年月日时分秒 |
| 89 | - const Hour = String(dayjs().hour()); | 89 | + let Year = ''; |
| 90 | - const Minute = String(dayjs().minute()); | 90 | + let Month = ''; |
| 91 | - const Second = String(dayjs().second()); | 91 | + let Day = ''; |
| 92 | - const Year = String(dayjs().year()); | 92 | + if (!props.item.component_props.default) { |
| 93 | - const Month = formatZero(dayjs().month(), 2); | 93 | + Year = String(dayjs().year()); |
| 94 | - const Day = formatZero(dayjs().date(), 2); | 94 | + Month = formatZero(dayjs().month(), 2); |
| 95 | + Day = formatZero(dayjs().date(), 2); | ||
| 96 | + } else { | ||
| 97 | + Year = currentDate.value[0]; | ||
| 98 | + Month = formatZero(currentDate.value[1], 2); | ||
| 99 | + Day = formatZero(currentDate.value[2], 2); | ||
| 100 | + } | ||
| 101 | + let Hour = '' | ||
| 102 | + let Minute = '' | ||
| 103 | + let Second = '' | ||
| 104 | + if (!props.item.component_props.default) { | ||
| 105 | + Hour = String(dayjs().hour()); | ||
| 106 | + Minute = String(dayjs().minute()); | ||
| 107 | + Second = String(dayjs().second()); | ||
| 108 | + } else { | ||
| 109 | + Hour = currentTime.value[0]; | ||
| 110 | + Minute = currentTime.value[1]; | ||
| 111 | + Second = currentTime.value[2]; | ||
| 112 | + } | ||
| 95 | switch (date_format) { | 113 | switch (date_format) { |
| 96 | case "YYYY": | 114 | case "YYYY": |
| 97 | columns_date_type.value = ['year'] | 115 | columns_date_type.value = ['year'] | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-08-31 11:45:30 | 2 | * @Date: 2022-08-31 11:45:30 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-02-07 15:14:48 | 4 | + * @LastEditTime: 2023-02-08 14:59:28 |
| 5 | * @FilePath: /data-table/src/components/TimePickerField/index.vue | 5 | * @FilePath: /data-table/src/components/TimePickerField/index.vue |
| 6 | * @Description: 时间选择组件 | 6 | * @Description: 时间选择组件 |
| 7 | --> | 7 | --> |
| ... | @@ -62,10 +62,20 @@ const onConfirm = ({ selectedValues, selectedOptions }) => { | ... | @@ -62,10 +62,20 @@ const onConfirm = ({ selectedValues, selectedOptions }) => { |
| 62 | const columns_type = ref([]); | 62 | const columns_type = ref([]); |
| 63 | const date_format = props.item.component_props.data_dateformat; // HH:mm=时分,HH:mm:ss=时分秒 | 63 | const date_format = props.item.component_props.data_dateformat; // HH:mm=时分,HH:mm:ss=时分秒 |
| 64 | onMounted(() => { | 64 | onMounted(() => { |
| 65 | - currentTime.value = props.item.value.split(":"); | 65 | + // 根据默认值时间调整显示 |
| 66 | - const Hour = String(dayjs().hour()); | 66 | + currentTime.value = props.item.component_props.default ? props.item.component_props.default.split(":") : props.item.value.split(":"); |
| 67 | - const Minute = String(dayjs().minute()); | 67 | + let Hour = '' |
| 68 | - const Second = String(dayjs().second()); | 68 | + let Minute = '' |
| 69 | + let Second = '' | ||
| 70 | + if (!props.item.component_props.default) { | ||
| 71 | + Hour = String(dayjs().hour()); | ||
| 72 | + Minute = String(dayjs().minute()); | ||
| 73 | + Second = String(dayjs().second()); | ||
| 74 | + } else { | ||
| 75 | + Hour = currentTime.value[0]; | ||
| 76 | + Minute = currentTime.value[1]; | ||
| 77 | + Second = currentTime.value[2]; | ||
| 78 | + } | ||
| 69 | switch (date_format) { | 79 | switch (date_format) { |
| 70 | case "HH:mm": | 80 | case "HH:mm": |
| 71 | columns_type.value = ['hour', 'minute']; | 81 | columns_type.value = ['hour', 'minute']; | ... | ... |
-
Please register or login to post a comment