@fecp/mobile 1.0.24 → 1.0.25
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/es/packages/mobile/src/components/form/fieldDatePicker/FieldDatePicker.vue.mjs +49 -17
- package/es/packages/mobile/src/components/form/fieldRadio/FieldRadio.vue.mjs +0 -1
- package/es/packages/mobile/src/components/form/fieldTimePicker/FieldTimePicker.vue.mjs +48 -15
- package/es/packages/mobile/src/utils/dateUtil.mjs +54 -0
- package/lib/packages/mobile/src/components/form/fieldDatePicker/FieldDatePicker.vue.js +49 -17
- package/lib/packages/mobile/src/components/form/fieldRadio/FieldRadio.vue.js +0 -1
- package/lib/packages/mobile/src/components/form/fieldTimePicker/FieldTimePicker.vue.js +48 -15
- package/lib/packages/mobile/src/utils/dateUtil.js +54 -0
- package/package.json +1 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { ref, computed, watch, createBlock, openBlock, unref, mergeProps, isRef, withCtx, createVNode } from "vue";
|
|
15
15
|
import { MobileField } from "../field/index.mjs";
|
|
16
16
|
import hooks from "../../../../../../node_modules/.pnpm/moment@2.30.1/node_modules/moment/dist/moment.mjs";
|
|
17
|
+
import { parseDateFormatter } from "../../../utils/dateUtil.mjs";
|
|
17
18
|
import { DatePicker } from "../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/date-picker/index.mjs";
|
|
18
19
|
import { Popup } from "../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/popup/index.mjs";
|
|
19
20
|
const _sfc_main = {
|
|
@@ -23,18 +24,23 @@ const _sfc_main = {
|
|
|
23
24
|
type: String,
|
|
24
25
|
default: ""
|
|
25
26
|
},
|
|
26
|
-
textFormat: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
valueFormat: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
27
|
+
// textFormat: {
|
|
28
|
+
// type: String,
|
|
29
|
+
// default: "YYYY-MM-DD",
|
|
30
|
+
// },
|
|
31
|
+
// valueFormat: {
|
|
32
|
+
// type: String,
|
|
33
|
+
// default: "YYYYMMDD",
|
|
34
|
+
// },
|
|
34
35
|
dateColumnsType: {
|
|
35
36
|
type: String,
|
|
36
37
|
default: "year,month,day"
|
|
37
38
|
},
|
|
39
|
+
dateTextFormat: {
|
|
40
|
+
//0:YYYYMMDD;1: YYYY-MM-DD;2:YYYY/MM/DD;3:YYYY年MM月DD日
|
|
41
|
+
type: String,
|
|
42
|
+
default: "1"
|
|
43
|
+
},
|
|
38
44
|
readonly: false,
|
|
39
45
|
"is-link": false
|
|
40
46
|
},
|
|
@@ -44,27 +50,52 @@ const _sfc_main = {
|
|
|
44
50
|
const fieldTextValue = ref("");
|
|
45
51
|
const showPicker = ref(false);
|
|
46
52
|
const emit = __emit;
|
|
53
|
+
let textFormat = parseDateFormatter(
|
|
54
|
+
props.dateTextFormat,
|
|
55
|
+
props.dateColumnsType
|
|
56
|
+
);
|
|
57
|
+
let valueFormat = parseDateFormatter("0", props.dateColumnsType);
|
|
47
58
|
const pickerValue = computed(() => {
|
|
59
|
+
let date;
|
|
48
60
|
if (!props.modelValue) {
|
|
49
|
-
|
|
50
|
-
|
|
61
|
+
date = hooks();
|
|
62
|
+
} else {
|
|
63
|
+
date = hooks(props.modelValue, valueFormat);
|
|
64
|
+
}
|
|
65
|
+
const year = date.year();
|
|
66
|
+
const month = date.month() + 1;
|
|
67
|
+
const day = date.date();
|
|
68
|
+
let value = [];
|
|
69
|
+
const columnsTypeArr = props.dateColumnsType.split(",");
|
|
70
|
+
if (columnsTypeArr.length == 1) {
|
|
71
|
+
value = [year];
|
|
72
|
+
} else if (columnsTypeArr.length == 2) {
|
|
73
|
+
value = [year, month];
|
|
74
|
+
} else if (columnsTypeArr.length == 3) {
|
|
75
|
+
value = [year, month, day];
|
|
51
76
|
}
|
|
52
|
-
const date = hooks(props.modelValue, props.valueFormat);
|
|
53
|
-
const value = [date.year(), date.month() + 1, date.date()];
|
|
54
77
|
return value;
|
|
55
78
|
});
|
|
56
79
|
const columnsType = computed(() => {
|
|
57
|
-
return props.dateColumnsType.
|
|
80
|
+
return props.dateColumnsType.split(",");
|
|
58
81
|
});
|
|
82
|
+
const formatter = (type, option) => {
|
|
83
|
+
if (type === "year") {
|
|
84
|
+
option.text += "年";
|
|
85
|
+
} else if (type === "month") {
|
|
86
|
+
option.text += "月";
|
|
87
|
+
} else if (type === "day") {
|
|
88
|
+
option.text += "日";
|
|
89
|
+
}
|
|
90
|
+
return option;
|
|
91
|
+
};
|
|
59
92
|
watch(
|
|
60
93
|
() => props.modelValue,
|
|
61
94
|
(value) => {
|
|
62
95
|
if (!value) {
|
|
63
96
|
return;
|
|
64
97
|
}
|
|
65
|
-
fieldTextValue.value = hooks(value,
|
|
66
|
-
props.textFormat
|
|
67
|
-
);
|
|
98
|
+
fieldTextValue.value = hooks(value, valueFormat).format(textFormat);
|
|
68
99
|
},
|
|
69
100
|
{ immediate: true }
|
|
70
101
|
);
|
|
@@ -72,7 +103,7 @@ const _sfc_main = {
|
|
|
72
103
|
const val = hooks(
|
|
73
104
|
`${selectedValues[0]}${selectedValues[1]}${selectedValues[2]}`,
|
|
74
105
|
"YYYYMMDD"
|
|
75
|
-
).format(
|
|
106
|
+
).format(valueFormat);
|
|
76
107
|
emit("update:modelValue", val);
|
|
77
108
|
showPicker.value = false;
|
|
78
109
|
};
|
|
@@ -100,6 +131,7 @@ const _sfc_main = {
|
|
|
100
131
|
readonly: false,
|
|
101
132
|
onConfirm,
|
|
102
133
|
columnsType: unref(columnsType),
|
|
134
|
+
formatter,
|
|
103
135
|
onCancel: _cache[1] || (_cache[1] = ($event) => showPicker.value = false)
|
|
104
136
|
}), null, 16, ["modelValue", "columnsType"])
|
|
105
137
|
]),
|
|
@@ -4,7 +4,6 @@ import { MobileRadioGroup } from "../radioGroup/index.mjs";
|
|
|
4
4
|
const _sfc_main = {
|
|
5
5
|
__name: "FieldRadio",
|
|
6
6
|
setup(__props) {
|
|
7
|
-
debugger;
|
|
8
7
|
return (_ctx, _cache) => {
|
|
9
8
|
return openBlock(), createBlock(unref(MobileField), normalizeProps(guardReactiveProps(_ctx.$attrs)), {
|
|
10
9
|
input: withCtx(() => [
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
import { ref, computed, watch, createBlock, openBlock, unref, mergeProps, isRef, withCtx, createVNode } from "vue";
|
|
15
15
|
import { MobileField } from "../field/index.mjs";
|
|
16
16
|
import hooks from "../../../../../../node_modules/.pnpm/moment@2.30.1/node_modules/moment/dist/moment.mjs";
|
|
17
|
+
import { parseTimeFormatter } from "../../../utils/dateUtil.mjs";
|
|
17
18
|
import { TimePicker } from "../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/time-picker/index.mjs";
|
|
18
19
|
import { Popup } from "../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/popup/index.mjs";
|
|
19
20
|
const _sfc_main = {
|
|
@@ -23,13 +24,18 @@ const _sfc_main = {
|
|
|
23
24
|
type: String,
|
|
24
25
|
default: ""
|
|
25
26
|
},
|
|
26
|
-
textFormat: {
|
|
27
|
+
// textFormat: {
|
|
28
|
+
// type: String,
|
|
29
|
+
// default: "HH:mm:ss",
|
|
30
|
+
// },
|
|
31
|
+
// valueFormat: {
|
|
32
|
+
// type: String,
|
|
33
|
+
// default: "HH:mm:ss",
|
|
34
|
+
// },
|
|
35
|
+
timeTextFormat: {
|
|
36
|
+
//0:HH:mm:ss;1: HH时mm分ss秒
|
|
27
37
|
type: String,
|
|
28
|
-
default: "
|
|
29
|
-
},
|
|
30
|
-
valueFormat: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: "HH:mm:ss"
|
|
38
|
+
default: "0"
|
|
33
39
|
},
|
|
34
40
|
timeColumnsType: {
|
|
35
41
|
type: String,
|
|
@@ -45,27 +51,53 @@ const _sfc_main = {
|
|
|
45
51
|
const fieldTextValue = ref("");
|
|
46
52
|
const showPicker = ref(false);
|
|
47
53
|
const emit = __emit;
|
|
54
|
+
let textFormat = parseTimeFormatter(
|
|
55
|
+
props.timeTextFormat,
|
|
56
|
+
props.timeColumnsType
|
|
57
|
+
);
|
|
58
|
+
let valueFormat = parseTimeFormatter("0", props.timeColumnsType);
|
|
48
59
|
const pickerValue = computed(() => {
|
|
60
|
+
let date;
|
|
49
61
|
if (!props.modelValue) {
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
date = hooks();
|
|
63
|
+
} else {
|
|
64
|
+
date = hooks(props.modelValue, props.valueFormat);
|
|
65
|
+
}
|
|
66
|
+
const hours = date.hours();
|
|
67
|
+
const minutes = date.minutes();
|
|
68
|
+
const seconds = date.seconds();
|
|
69
|
+
let value = [];
|
|
70
|
+
const columnsTypeArr = props.timeColumnsType.split(",");
|
|
71
|
+
if (columnsTypeArr.length == 1) {
|
|
72
|
+
value = [hours];
|
|
73
|
+
} else if (columnsTypeArr.length == 2) {
|
|
74
|
+
value = [hours, minutes];
|
|
75
|
+
} else if (columnsTypeArr.length == 3) {
|
|
76
|
+
value = [hours, minutes, seconds];
|
|
52
77
|
}
|
|
53
|
-
const date = hooks(props.modelValue, props.valueFormat);
|
|
54
|
-
const value = [date.hours(), date.minutes(), date.seconds()];
|
|
55
78
|
return value;
|
|
56
79
|
});
|
|
57
80
|
const columnsType = computed(() => {
|
|
58
|
-
return props.timeColumnsType.
|
|
81
|
+
return props.timeColumnsType.split(",");
|
|
59
82
|
});
|
|
83
|
+
const formatter = (type, option) => {
|
|
84
|
+
console.log(type);
|
|
85
|
+
if (type === "hour") {
|
|
86
|
+
option.text += "时";
|
|
87
|
+
} else if (type === "minute") {
|
|
88
|
+
option.text += "分";
|
|
89
|
+
} else if (type === "second") {
|
|
90
|
+
option.text += "秒";
|
|
91
|
+
}
|
|
92
|
+
return option;
|
|
93
|
+
};
|
|
60
94
|
watch(
|
|
61
95
|
() => props.modelValue,
|
|
62
96
|
(value) => {
|
|
63
97
|
if (!value) {
|
|
64
98
|
return;
|
|
65
99
|
}
|
|
66
|
-
fieldTextValue.value = hooks(value,
|
|
67
|
-
props.textFormat
|
|
68
|
-
);
|
|
100
|
+
fieldTextValue.value = hooks(value, valueFormat).format(textFormat);
|
|
69
101
|
},
|
|
70
102
|
{ immediate: true }
|
|
71
103
|
);
|
|
@@ -73,7 +105,7 @@ const _sfc_main = {
|
|
|
73
105
|
const val = hooks(
|
|
74
106
|
`${selectedValues[0]}${selectedValues[1]}${selectedValues[2]}`,
|
|
75
107
|
"HH:mm:ss"
|
|
76
|
-
).format(
|
|
108
|
+
).format(valueFormat);
|
|
77
109
|
emit("update:modelValue", val);
|
|
78
110
|
showPicker.value = false;
|
|
79
111
|
};
|
|
@@ -100,6 +132,7 @@ const _sfc_main = {
|
|
|
100
132
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(pickerValue) ? pickerValue.value = $event : null),
|
|
101
133
|
readonly: false,
|
|
102
134
|
columnsType: unref(columnsType),
|
|
135
|
+
formatter,
|
|
103
136
|
onConfirm,
|
|
104
137
|
onCancel: _cache[1] || (_cache[1] = ($event) => showPicker.value = false)
|
|
105
138
|
}), null, 16, ["modelValue", "columnsType"])
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const parseDateFormatter = (textFormatType, columnsType) => {
|
|
2
|
+
const columnsTypeArr = columnsType.split(",");
|
|
3
|
+
if (columnsTypeArr.length == 1) {
|
|
4
|
+
if (textFormatType == "3") {
|
|
5
|
+
return "YYYY年";
|
|
6
|
+
}
|
|
7
|
+
return "YYYY";
|
|
8
|
+
} else if (columnsTypeArr.length == 2) {
|
|
9
|
+
if (textFormatType == "0") {
|
|
10
|
+
return "YYYYMM";
|
|
11
|
+
} else if (textFormatType == "1") {
|
|
12
|
+
return "YYYY-MM";
|
|
13
|
+
} else if (textFormatType == "2") {
|
|
14
|
+
return "YYYY/MM";
|
|
15
|
+
} else if (textFormatType == "3") {
|
|
16
|
+
return "YYYY年MM月";
|
|
17
|
+
}
|
|
18
|
+
} else if (columnsTypeArr.length == 3) {
|
|
19
|
+
if (textFormatType == "0") {
|
|
20
|
+
return "YYYYMMDD";
|
|
21
|
+
} else if (textFormatType == "1") {
|
|
22
|
+
return "YYYY-MM-DD";
|
|
23
|
+
} else if (textFormatType == "2") {
|
|
24
|
+
return "YYYY/MM/DD";
|
|
25
|
+
} else if (textFormatType == "3") {
|
|
26
|
+
return "YYYY年MM月DD日";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const parseTimeFormatter = (textFormatType, columnsType) => {
|
|
31
|
+
const columnsTypeArr = columnsType.split(",");
|
|
32
|
+
if (columnsTypeArr.length == 1) {
|
|
33
|
+
if (textFormatType == "1") {
|
|
34
|
+
return "HH时";
|
|
35
|
+
}
|
|
36
|
+
return "HH";
|
|
37
|
+
} else if (columnsTypeArr.length == 2) {
|
|
38
|
+
if (textFormatType == "0") {
|
|
39
|
+
return "HH:mm";
|
|
40
|
+
} else if (textFormatType == "1") {
|
|
41
|
+
return "HH时mm分";
|
|
42
|
+
}
|
|
43
|
+
} else if (columnsTypeArr.length == 3) {
|
|
44
|
+
if (textFormatType == "0") {
|
|
45
|
+
return "HH:mm:ss";
|
|
46
|
+
} else if (textFormatType == "1") {
|
|
47
|
+
return "HH时mm分ss秒";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
parseDateFormatter,
|
|
53
|
+
parseTimeFormatter
|
|
54
|
+
};
|
|
@@ -16,6 +16,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
16
16
|
const vue = require("vue");
|
|
17
17
|
const index = require("../field/index.js");
|
|
18
18
|
const moment = require("../../../../../../node_modules/.pnpm/moment@2.30.1/node_modules/moment/dist/moment.js");
|
|
19
|
+
const dateUtil = require("../../../utils/dateUtil.js");
|
|
19
20
|
const index$2 = require("../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/date-picker/index.js");
|
|
20
21
|
const index$1 = require("../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/popup/index.js");
|
|
21
22
|
const _sfc_main = {
|
|
@@ -25,18 +26,23 @@ const _sfc_main = {
|
|
|
25
26
|
type: String,
|
|
26
27
|
default: ""
|
|
27
28
|
},
|
|
28
|
-
textFormat: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
valueFormat: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
29
|
+
// textFormat: {
|
|
30
|
+
// type: String,
|
|
31
|
+
// default: "YYYY-MM-DD",
|
|
32
|
+
// },
|
|
33
|
+
// valueFormat: {
|
|
34
|
+
// type: String,
|
|
35
|
+
// default: "YYYYMMDD",
|
|
36
|
+
// },
|
|
36
37
|
dateColumnsType: {
|
|
37
38
|
type: String,
|
|
38
39
|
default: "year,month,day"
|
|
39
40
|
},
|
|
41
|
+
dateTextFormat: {
|
|
42
|
+
//0:YYYYMMDD;1: YYYY-MM-DD;2:YYYY/MM/DD;3:YYYY年MM月DD日
|
|
43
|
+
type: String,
|
|
44
|
+
default: "1"
|
|
45
|
+
},
|
|
40
46
|
readonly: false,
|
|
41
47
|
"is-link": false
|
|
42
48
|
},
|
|
@@ -46,27 +52,52 @@ const _sfc_main = {
|
|
|
46
52
|
const fieldTextValue = vue.ref("");
|
|
47
53
|
const showPicker = vue.ref(false);
|
|
48
54
|
const emit = __emit;
|
|
55
|
+
let textFormat = dateUtil.parseDateFormatter(
|
|
56
|
+
props.dateTextFormat,
|
|
57
|
+
props.dateColumnsType
|
|
58
|
+
);
|
|
59
|
+
let valueFormat = dateUtil.parseDateFormatter("0", props.dateColumnsType);
|
|
49
60
|
const pickerValue = vue.computed(() => {
|
|
61
|
+
let date;
|
|
50
62
|
if (!props.modelValue) {
|
|
51
|
-
|
|
52
|
-
|
|
63
|
+
date = moment.default();
|
|
64
|
+
} else {
|
|
65
|
+
date = moment.default(props.modelValue, valueFormat);
|
|
66
|
+
}
|
|
67
|
+
const year = date.year();
|
|
68
|
+
const month = date.month() + 1;
|
|
69
|
+
const day = date.date();
|
|
70
|
+
let value = [];
|
|
71
|
+
const columnsTypeArr = props.dateColumnsType.split(",");
|
|
72
|
+
if (columnsTypeArr.length == 1) {
|
|
73
|
+
value = [year];
|
|
74
|
+
} else if (columnsTypeArr.length == 2) {
|
|
75
|
+
value = [year, month];
|
|
76
|
+
} else if (columnsTypeArr.length == 3) {
|
|
77
|
+
value = [year, month, day];
|
|
53
78
|
}
|
|
54
|
-
const date = moment.default(props.modelValue, props.valueFormat);
|
|
55
|
-
const value = [date.year(), date.month() + 1, date.date()];
|
|
56
79
|
return value;
|
|
57
80
|
});
|
|
58
81
|
const columnsType = vue.computed(() => {
|
|
59
|
-
return props.dateColumnsType.
|
|
82
|
+
return props.dateColumnsType.split(",");
|
|
60
83
|
});
|
|
84
|
+
const formatter = (type, option) => {
|
|
85
|
+
if (type === "year") {
|
|
86
|
+
option.text += "年";
|
|
87
|
+
} else if (type === "month") {
|
|
88
|
+
option.text += "月";
|
|
89
|
+
} else if (type === "day") {
|
|
90
|
+
option.text += "日";
|
|
91
|
+
}
|
|
92
|
+
return option;
|
|
93
|
+
};
|
|
61
94
|
vue.watch(
|
|
62
95
|
() => props.modelValue,
|
|
63
96
|
(value) => {
|
|
64
97
|
if (!value) {
|
|
65
98
|
return;
|
|
66
99
|
}
|
|
67
|
-
fieldTextValue.value = moment.default(value,
|
|
68
|
-
props.textFormat
|
|
69
|
-
);
|
|
100
|
+
fieldTextValue.value = moment.default(value, valueFormat).format(textFormat);
|
|
70
101
|
},
|
|
71
102
|
{ immediate: true }
|
|
72
103
|
);
|
|
@@ -74,7 +105,7 @@ const _sfc_main = {
|
|
|
74
105
|
const val = moment.default(
|
|
75
106
|
`${selectedValues[0]}${selectedValues[1]}${selectedValues[2]}`,
|
|
76
107
|
"YYYYMMDD"
|
|
77
|
-
).format(
|
|
108
|
+
).format(valueFormat);
|
|
78
109
|
emit("update:modelValue", val);
|
|
79
110
|
showPicker.value = false;
|
|
80
111
|
};
|
|
@@ -102,6 +133,7 @@ const _sfc_main = {
|
|
|
102
133
|
readonly: false,
|
|
103
134
|
onConfirm,
|
|
104
135
|
columnsType: vue.unref(columnsType),
|
|
136
|
+
formatter,
|
|
105
137
|
onCancel: _cache[1] || (_cache[1] = ($event) => showPicker.value = false)
|
|
106
138
|
}), null, 16, ["modelValue", "columnsType"])
|
|
107
139
|
]),
|
|
@@ -6,7 +6,6 @@ const index$1 = require("../radioGroup/index.js");
|
|
|
6
6
|
const _sfc_main = {
|
|
7
7
|
__name: "FieldRadio",
|
|
8
8
|
setup(__props) {
|
|
9
|
-
debugger;
|
|
10
9
|
return (_ctx, _cache) => {
|
|
11
10
|
return vue.openBlock(), vue.createBlock(vue.unref(index.MobileField), vue.normalizeProps(vue.guardReactiveProps(_ctx.$attrs)), {
|
|
12
11
|
input: vue.withCtx(() => [
|
|
@@ -16,6 +16,7 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
16
16
|
const vue = require("vue");
|
|
17
17
|
const index = require("../field/index.js");
|
|
18
18
|
const moment = require("../../../../../../node_modules/.pnpm/moment@2.30.1/node_modules/moment/dist/moment.js");
|
|
19
|
+
const dateUtil = require("../../../utils/dateUtil.js");
|
|
19
20
|
const index$2 = require("../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/time-picker/index.js");
|
|
20
21
|
const index$1 = require("../../../../../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/popup/index.js");
|
|
21
22
|
const _sfc_main = {
|
|
@@ -25,13 +26,18 @@ const _sfc_main = {
|
|
|
25
26
|
type: String,
|
|
26
27
|
default: ""
|
|
27
28
|
},
|
|
28
|
-
textFormat: {
|
|
29
|
+
// textFormat: {
|
|
30
|
+
// type: String,
|
|
31
|
+
// default: "HH:mm:ss",
|
|
32
|
+
// },
|
|
33
|
+
// valueFormat: {
|
|
34
|
+
// type: String,
|
|
35
|
+
// default: "HH:mm:ss",
|
|
36
|
+
// },
|
|
37
|
+
timeTextFormat: {
|
|
38
|
+
//0:HH:mm:ss;1: HH时mm分ss秒
|
|
29
39
|
type: String,
|
|
30
|
-
default: "
|
|
31
|
-
},
|
|
32
|
-
valueFormat: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: "HH:mm:ss"
|
|
40
|
+
default: "0"
|
|
35
41
|
},
|
|
36
42
|
timeColumnsType: {
|
|
37
43
|
type: String,
|
|
@@ -47,27 +53,53 @@ const _sfc_main = {
|
|
|
47
53
|
const fieldTextValue = vue.ref("");
|
|
48
54
|
const showPicker = vue.ref(false);
|
|
49
55
|
const emit = __emit;
|
|
56
|
+
let textFormat = dateUtil.parseTimeFormatter(
|
|
57
|
+
props.timeTextFormat,
|
|
58
|
+
props.timeColumnsType
|
|
59
|
+
);
|
|
60
|
+
let valueFormat = dateUtil.parseTimeFormatter("0", props.timeColumnsType);
|
|
50
61
|
const pickerValue = vue.computed(() => {
|
|
62
|
+
let date;
|
|
51
63
|
if (!props.modelValue) {
|
|
52
|
-
|
|
53
|
-
|
|
64
|
+
date = moment.default();
|
|
65
|
+
} else {
|
|
66
|
+
date = moment.default(props.modelValue, props.valueFormat);
|
|
67
|
+
}
|
|
68
|
+
const hours = date.hours();
|
|
69
|
+
const minutes = date.minutes();
|
|
70
|
+
const seconds = date.seconds();
|
|
71
|
+
let value = [];
|
|
72
|
+
const columnsTypeArr = props.timeColumnsType.split(",");
|
|
73
|
+
if (columnsTypeArr.length == 1) {
|
|
74
|
+
value = [hours];
|
|
75
|
+
} else if (columnsTypeArr.length == 2) {
|
|
76
|
+
value = [hours, minutes];
|
|
77
|
+
} else if (columnsTypeArr.length == 3) {
|
|
78
|
+
value = [hours, minutes, seconds];
|
|
54
79
|
}
|
|
55
|
-
const date = moment.default(props.modelValue, props.valueFormat);
|
|
56
|
-
const value = [date.hours(), date.minutes(), date.seconds()];
|
|
57
80
|
return value;
|
|
58
81
|
});
|
|
59
82
|
const columnsType = vue.computed(() => {
|
|
60
|
-
return props.timeColumnsType.
|
|
83
|
+
return props.timeColumnsType.split(",");
|
|
61
84
|
});
|
|
85
|
+
const formatter = (type, option) => {
|
|
86
|
+
console.log(type);
|
|
87
|
+
if (type === "hour") {
|
|
88
|
+
option.text += "时";
|
|
89
|
+
} else if (type === "minute") {
|
|
90
|
+
option.text += "分";
|
|
91
|
+
} else if (type === "second") {
|
|
92
|
+
option.text += "秒";
|
|
93
|
+
}
|
|
94
|
+
return option;
|
|
95
|
+
};
|
|
62
96
|
vue.watch(
|
|
63
97
|
() => props.modelValue,
|
|
64
98
|
(value) => {
|
|
65
99
|
if (!value) {
|
|
66
100
|
return;
|
|
67
101
|
}
|
|
68
|
-
fieldTextValue.value = moment.default(value,
|
|
69
|
-
props.textFormat
|
|
70
|
-
);
|
|
102
|
+
fieldTextValue.value = moment.default(value, valueFormat).format(textFormat);
|
|
71
103
|
},
|
|
72
104
|
{ immediate: true }
|
|
73
105
|
);
|
|
@@ -75,7 +107,7 @@ const _sfc_main = {
|
|
|
75
107
|
const val = moment.default(
|
|
76
108
|
`${selectedValues[0]}${selectedValues[1]}${selectedValues[2]}`,
|
|
77
109
|
"HH:mm:ss"
|
|
78
|
-
).format(
|
|
110
|
+
).format(valueFormat);
|
|
79
111
|
emit("update:modelValue", val);
|
|
80
112
|
showPicker.value = false;
|
|
81
113
|
};
|
|
@@ -102,6 +134,7 @@ const _sfc_main = {
|
|
|
102
134
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(pickerValue) ? pickerValue.value = $event : null),
|
|
103
135
|
readonly: false,
|
|
104
136
|
columnsType: vue.unref(columnsType),
|
|
137
|
+
formatter,
|
|
105
138
|
onConfirm,
|
|
106
139
|
onCancel: _cache[1] || (_cache[1] = ($event) => showPicker.value = false)
|
|
107
140
|
}), null, 16, ["modelValue", "columnsType"])
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const parseDateFormatter = (textFormatType, columnsType) => {
|
|
4
|
+
const columnsTypeArr = columnsType.split(",");
|
|
5
|
+
if (columnsTypeArr.length == 1) {
|
|
6
|
+
if (textFormatType == "3") {
|
|
7
|
+
return "YYYY年";
|
|
8
|
+
}
|
|
9
|
+
return "YYYY";
|
|
10
|
+
} else if (columnsTypeArr.length == 2) {
|
|
11
|
+
if (textFormatType == "0") {
|
|
12
|
+
return "YYYYMM";
|
|
13
|
+
} else if (textFormatType == "1") {
|
|
14
|
+
return "YYYY-MM";
|
|
15
|
+
} else if (textFormatType == "2") {
|
|
16
|
+
return "YYYY/MM";
|
|
17
|
+
} else if (textFormatType == "3") {
|
|
18
|
+
return "YYYY年MM月";
|
|
19
|
+
}
|
|
20
|
+
} else if (columnsTypeArr.length == 3) {
|
|
21
|
+
if (textFormatType == "0") {
|
|
22
|
+
return "YYYYMMDD";
|
|
23
|
+
} else if (textFormatType == "1") {
|
|
24
|
+
return "YYYY-MM-DD";
|
|
25
|
+
} else if (textFormatType == "2") {
|
|
26
|
+
return "YYYY/MM/DD";
|
|
27
|
+
} else if (textFormatType == "3") {
|
|
28
|
+
return "YYYY年MM月DD日";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const parseTimeFormatter = (textFormatType, columnsType) => {
|
|
33
|
+
const columnsTypeArr = columnsType.split(",");
|
|
34
|
+
if (columnsTypeArr.length == 1) {
|
|
35
|
+
if (textFormatType == "1") {
|
|
36
|
+
return "HH时";
|
|
37
|
+
}
|
|
38
|
+
return "HH";
|
|
39
|
+
} else if (columnsTypeArr.length == 2) {
|
|
40
|
+
if (textFormatType == "0") {
|
|
41
|
+
return "HH:mm";
|
|
42
|
+
} else if (textFormatType == "1") {
|
|
43
|
+
return "HH时mm分";
|
|
44
|
+
}
|
|
45
|
+
} else if (columnsTypeArr.length == 3) {
|
|
46
|
+
if (textFormatType == "0") {
|
|
47
|
+
return "HH:mm:ss";
|
|
48
|
+
} else if (textFormatType == "1") {
|
|
49
|
+
return "HH时mm分ss秒";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.parseDateFormatter = parseDateFormatter;
|
|
54
|
+
exports.parseTimeFormatter = parseTimeFormatter;
|