Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
data-table
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
hookehuyr
2023-02-08 15:03:32 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
045ae4c6bfb80d3acecf2e99d031740203b19944
045ae4c6
1 parent
cd24e429
✨ feat(时间相关控件): 设置默认值后显示优化问题
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
18 deletions
src/components/DatePickerField/index.vue
src/components/DateTimePickerField/index.vue
src/components/TimePickerField/index.vue
src/components/DatePickerField/index.vue
View file @
045ae4c
<!--
* @Date: 2022-08-31 11:45:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-02-0
7 16:42:28
* @LastEditTime: 2023-02-0
8 15:01:56
* @FilePath: /data-table/src/components/DatePickerField/index.vue
* @Description: 日期选择组件
-->
...
...
@@ -75,10 +75,20 @@ const minDate = ref()
const maxDate = ref()
onMounted(() => {
currentDate.value = props.item.value.split("-");
const Year = String(dayjs().year());
const Month = formatZero(dayjs().month(), 2);
const Day = formatZero(dayjs().date(), 2);
// 根据默认值时间调整显示
currentDate.value = props.item.component_props.default ? props.item.component_props.default.split("-") : props.item.value.split("-");
let Year = '';
let Month = '';
let Day = '';
if (!props.item.component_props.default) {
Year = String(dayjs().year());
Month = formatZero(dayjs().month(), 2);
Day = formatZero(dayjs().date(), 2);
} else {
Year = currentDate.value[0];
Month = formatZero(currentDate.value[1], 2);
Day = formatZero(currentDate.value[2], 2);
}
switch (date_format) {
case "YYYY-MM":
columns_type.value = ['year', 'month']
...
...
src/components/DateTimePickerField/index.vue
View file @
045ae4c
...
...
@@ -81,17 +81,35 @@ const minDate = ref()
const maxDate = ref()
onMounted(() => {
//
获取值定位
显示
const datetime = props.item.value.split(" ");
//
根据默认值时间调整
显示
const datetime = props.item.
component_props.default ? props.item.component_props.default.split(" ") : props.item.
value.split(" ");
currentDate.value = datetime[0]?.split("-");
currentTime.value = datetime[1]?.split(":");
// YYYY=年,YYYY-MM=年月,YYYY-MM-DD=年月日,YYYY-MM-DD HH=年月日时,YYYY-MM-DD HH:mm=年月日时分,YYYY-MM-DD HH:mm:ss=年月日时分秒
const Hour = String(dayjs().hour());
const Minute = String(dayjs().minute());
const Second = String(dayjs().second());
const Year = String(dayjs().year());
const Month = formatZero(dayjs().month(), 2);
const Day = formatZero(dayjs().date(), 2);
let Year = '';
let Month = '';
let Day = '';
if (!props.item.component_props.default) {
Year = String(dayjs().year());
Month = formatZero(dayjs().month(), 2);
Day = formatZero(dayjs().date(), 2);
} else {
Year = currentDate.value[0];
Month = formatZero(currentDate.value[1], 2);
Day = formatZero(currentDate.value[2], 2);
}
let Hour = ''
let Minute = ''
let Second = ''
if (!props.item.component_props.default) {
Hour = String(dayjs().hour());
Minute = String(dayjs().minute());
Second = String(dayjs().second());
} else {
Hour = currentTime.value[0];
Minute = currentTime.value[1];
Second = currentTime.value[2];
}
switch (date_format) {
case "YYYY":
columns_date_type.value = ['year']
...
...
src/components/TimePickerField/index.vue
View file @
045ae4c
<!--
* @Date: 2022-08-31 11:45:30
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-02-0
7 15:14:4
8
* @LastEditTime: 2023-02-0
8 14:59:2
8
* @FilePath: /data-table/src/components/TimePickerField/index.vue
* @Description: 时间选择组件
-->
...
...
@@ -62,10 +62,20 @@ const onConfirm = ({ selectedValues, selectedOptions }) => {
const columns_type = ref([]);
const date_format = props.item.component_props.data_dateformat; // HH:mm=时分,HH:mm:ss=时分秒
onMounted(() => {
currentTime.value = props.item.value.split(":");
const Hour = String(dayjs().hour());
const Minute = String(dayjs().minute());
const Second = String(dayjs().second());
// 根据默认值时间调整显示
currentTime.value = props.item.component_props.default ? props.item.component_props.default.split(":") : props.item.value.split(":");
let Hour = ''
let Minute = ''
let Second = ''
if (!props.item.component_props.default) {
Hour = String(dayjs().hour());
Minute = String(dayjs().minute());
Second = String(dayjs().second());
} else {
Hour = currentTime.value[0];
Minute = currentTime.value[1];
Second = currentTime.value[2];
}
switch (date_format) {
case "HH:mm":
columns_type.value = ['hour', 'minute'];
...
...
Please
register
or
login
to post a comment