af-mobile-client-vue3 1.3.42 → 1.3.43
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 +1 -1
- package/src/api/user/index.ts +40 -40
- package/src/components/data/XForm/index.vue +22 -9
- package/src/router/routes.ts +1 -1
- package/src/services/api/Login.ts +6 -6
- package/src/stores/modules/user.ts +1 -1
- package/src/styles/login.less +109 -109
- package/src/utils/environment.ts +10 -10
- package/src/utils/platform-auth.ts +1 -1
- package/src/utils/queryFormDefaultRangePicker.ts +57 -57
- package/src/utils/wechat.ts +297 -297
- package/src/views/component/XCellListView/index.vue +27 -6
- package/src/views/component/XFormGroupView/index.vue +11 -7
- package/src/views/component/XFormView/index.vue +19 -4
- package/src/views/loading/AuthLoading.vue +1 -1
- package/src/views/user/register/index.vue +1 -1
- package/certs/127.0.0.1+2-key.pem +0 -28
- package/certs/127.0.0.1+2.pem +0 -27
package/package.json
CHANGED
package/src/api/user/index.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { loginApi } from '@af-mobile-client-vue3/services/api/Login'
|
|
2
|
-
|
|
3
|
-
import { get, post } from '@af-mobile-client-vue3/services/restTools'
|
|
4
|
-
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
5
|
-
|
|
6
|
-
export interface BasicResponseModel<T = any> {
|
|
7
|
-
code: number
|
|
8
|
-
msg: string
|
|
9
|
-
data: T
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function login(data: any) {
|
|
13
|
-
return post(
|
|
14
|
-
loginApi.Login,
|
|
15
|
-
data,
|
|
16
|
-
)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function OALogin(data: any) {
|
|
20
|
-
return get(`/af-system/user/${data.username}/${data.password}/智慧OA`)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @description: 获取用户信息
|
|
25
|
-
*/
|
|
26
|
-
export function getUserInfo() {
|
|
27
|
-
return get(
|
|
28
|
-
'/getUserInfo',
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* @description: 用户登出
|
|
34
|
-
*/
|
|
35
|
-
export function doLogout() {
|
|
36
|
-
return http.request({
|
|
37
|
-
url: loginApi.Logout,
|
|
38
|
-
method: 'DELETE',
|
|
39
|
-
})
|
|
40
|
-
}
|
|
1
|
+
import { loginApi } from '@af-mobile-client-vue3/services/api/Login'
|
|
2
|
+
|
|
3
|
+
import { get, post } from '@af-mobile-client-vue3/services/restTools'
|
|
4
|
+
import { http } from '@af-mobile-client-vue3/utils/http'
|
|
5
|
+
|
|
6
|
+
export interface BasicResponseModel<T = any> {
|
|
7
|
+
code: number
|
|
8
|
+
msg: string
|
|
9
|
+
data: T
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function login(data: any) {
|
|
13
|
+
return post(
|
|
14
|
+
loginApi.Login,
|
|
15
|
+
data,
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function OALogin(data: any) {
|
|
20
|
+
return get(`/af-system/user/${data.username}/${data.password}/智慧OA`)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @description: 获取用户信息
|
|
25
|
+
*/
|
|
26
|
+
export function getUserInfo() {
|
|
27
|
+
return get(
|
|
28
|
+
'/getUserInfo',
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @description: 用户登出
|
|
34
|
+
*/
|
|
35
|
+
export function doLogout() {
|
|
36
|
+
return http.request({
|
|
37
|
+
url: loginApi.Logout,
|
|
38
|
+
method: 'DELETE',
|
|
39
|
+
})
|
|
40
|
+
}
|
|
@@ -39,6 +39,7 @@ interface GroupFormItems {
|
|
|
39
39
|
tableName?: string
|
|
40
40
|
paramLogicName?: string
|
|
41
41
|
isGroupForm?: boolean
|
|
42
|
+
isKeyHandle?: boolean
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
interface InitParams {
|
|
@@ -85,6 +86,7 @@ const loaded = ref(false)
|
|
|
85
86
|
const form = ref({})
|
|
86
87
|
const rules = reactive({})
|
|
87
88
|
const myGetDataParams = ref({})
|
|
89
|
+
const isKeyHandle = ref(false)
|
|
88
90
|
|
|
89
91
|
// 配置相关状态
|
|
90
92
|
const formConfig = ref<GroupFormItems | null>(null)
|
|
@@ -92,7 +94,7 @@ const formGroupName = ref<string>('default')
|
|
|
92
94
|
const myServiceName = ref('')
|
|
93
95
|
const tableName = ref('')
|
|
94
96
|
|
|
95
|
-
//
|
|
97
|
+
// 计算属性(获取全部表单项信息)
|
|
96
98
|
const realJsonData = computed(() => {
|
|
97
99
|
const sourceFormItems = formConfig.value?.formJson
|
|
98
100
|
if (!sourceFormItems)
|
|
@@ -103,6 +105,13 @@ const realJsonData = computed(() => {
|
|
|
103
105
|
})
|
|
104
106
|
})
|
|
105
107
|
|
|
108
|
+
// 过滤出用于新增/修改/只读场景的表单项
|
|
109
|
+
const addOrEditJsonData = computed(() => {
|
|
110
|
+
return realJsonData.value.filter((item) => {
|
|
111
|
+
return item.addOrEdit === 'all' || item.addOrEdit === 'add' || item.addOrEdit === 'edit' || item.addOrEdit === 'readonly'
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
|
|
106
115
|
// 过滤出用于静默新增场景的表单项
|
|
107
116
|
const silenceAddJsonData = computed(() => {
|
|
108
117
|
return realJsonData.value.filter((item) => {
|
|
@@ -208,6 +217,7 @@ async function initWithGroupFormItems() {
|
|
|
208
217
|
function setupFormConfig(config: GroupFormItems) {
|
|
209
218
|
loadParamLogicNameData(config.paramLogicName)
|
|
210
219
|
formConfig.value = config
|
|
220
|
+
isKeyHandle.value = config.isKeyHandle
|
|
211
221
|
myServiceName.value = props.serviceName || undefined
|
|
212
222
|
formGroupName.value = config.groupName || 'default'
|
|
213
223
|
form.value = props.formData || {}
|
|
@@ -388,9 +398,10 @@ function getRealKey(key: string, mustHandleKey = false) {
|
|
|
388
398
|
async function asyncSubmit() {
|
|
389
399
|
return new Promise((resolve, reject) => {
|
|
390
400
|
validate().then(async () => {
|
|
391
|
-
|
|
392
|
-
await appendSilenceAddFields(
|
|
393
|
-
|
|
401
|
+
let realForm = prepareForm()
|
|
402
|
+
await appendSilenceAddFields(realForm)
|
|
403
|
+
if (isKeyHandle.value)
|
|
404
|
+
realForm = handleFormKeys(realForm)
|
|
394
405
|
resolve({
|
|
395
406
|
realForm,
|
|
396
407
|
mode: props.mode,
|
|
@@ -545,11 +556,11 @@ function getFormData() {
|
|
|
545
556
|
async function onSubmit() {
|
|
546
557
|
await validate()
|
|
547
558
|
// 清理表单数据
|
|
548
|
-
|
|
559
|
+
let realForm = prepareForm()
|
|
560
|
+
await appendSilenceAddFields(realForm)
|
|
549
561
|
if (!props.configName && props.groupFormItems) {
|
|
550
562
|
// 只有单表才可以成功,多表关联或者自定义sql不行
|
|
551
|
-
|
|
552
|
-
const realForm = handleFormKeys(cleanedForm)
|
|
563
|
+
realForm = handleFormKeys(realForm)
|
|
553
564
|
|
|
554
565
|
try {
|
|
555
566
|
addOrModifyEntity(realForm, tableName.value, props.serviceName || import.meta.env.VITE_APP_SYSTEM_NAME).then(() => {
|
|
@@ -566,8 +577,10 @@ async function onSubmit() {
|
|
|
566
577
|
}
|
|
567
578
|
}
|
|
568
579
|
else {
|
|
580
|
+
if (isKeyHandle.value)
|
|
581
|
+
realForm = handleFormKeys(realForm)
|
|
569
582
|
// 使用清理后的数据
|
|
570
|
-
emits('onSubmit',
|
|
583
|
+
emits('onSubmit', realForm)
|
|
571
584
|
}
|
|
572
585
|
}
|
|
573
586
|
async function validate() {
|
|
@@ -586,7 +599,7 @@ defineExpose({ init, form, formGroupName, validate, asyncSubmit, setForm, getFor
|
|
|
586
599
|
<div class="form-fields-scrollable">
|
|
587
600
|
<VanCellGroup :title="groupTitle">
|
|
588
601
|
<XFormItem
|
|
589
|
-
v-for="(item, index) in
|
|
602
|
+
v-for="(item, index) in addOrEditJsonData"
|
|
590
603
|
:key="index"
|
|
591
604
|
v-model="form[item.model]"
|
|
592
605
|
:mode="props.mode"
|
package/src/router/routes.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const loginApi = {
|
|
2
|
-
Login: '/af-auth/login',
|
|
3
|
-
Logout: '/af-auth/logout',
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export { loginApi }
|
|
1
|
+
const loginApi = {
|
|
2
|
+
Login: '/af-auth/login',
|
|
3
|
+
Logout: '/af-auth/logout',
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { loginApi }
|
package/src/styles/login.less
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
html:not(.dark) {
|
|
2
|
-
.form {
|
|
3
|
-
.form_field {
|
|
4
|
-
:deep(.van-field__label) {
|
|
5
|
-
color: rgb(88, 88, 88);
|
|
6
|
-
}
|
|
7
|
-
:deep(.van-field__body) {
|
|
8
|
-
background: rgb(251, 251, 251);
|
|
9
|
-
box-shadow: inset 0 0 1px 0 rgba(0, 0, 0, 0.1);
|
|
10
|
-
color: rgb(71, 71, 71);
|
|
11
|
-
}
|
|
12
|
-
:deep(.van-cell) {
|
|
13
|
-
background: #ffffff;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
.extra_setting {
|
|
17
|
-
.extra_setting_for_remember_password {
|
|
18
|
-
color: rgb(88, 88, 88);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
.form {
|
|
24
|
-
width: 100%;
|
|
25
|
-
padding: 0 40px;
|
|
26
|
-
.form_field {
|
|
27
|
-
padding-right: 0;
|
|
28
|
-
padding-left: 0;
|
|
29
|
-
:deep(.van-field__label) {
|
|
30
|
-
opacity: 0.7;
|
|
31
|
-
font-size: 16px;
|
|
32
|
-
font-weight: 400;
|
|
33
|
-
line-height: 23px;
|
|
34
|
-
text-transform: uppercase;
|
|
35
|
-
text-indent: 10px;
|
|
36
|
-
}
|
|
37
|
-
:deep(.van-field__body) {
|
|
38
|
-
height: 40px;
|
|
39
|
-
border-radius: 5px;
|
|
40
|
-
font-size: 16px;
|
|
41
|
-
font-weight: 400;
|
|
42
|
-
padding: 8px 10px;
|
|
43
|
-
opacity: 0.6;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
.extra_setting {
|
|
47
|
-
font-size: 12px;
|
|
48
|
-
font-weight: 400;
|
|
49
|
-
line-height: 12px;
|
|
50
|
-
.extra_setting_for_remember_password {
|
|
51
|
-
opacity: 0.7;
|
|
52
|
-
span {
|
|
53
|
-
position: relative;
|
|
54
|
-
bottom: 3px;
|
|
55
|
-
left: 5px;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
.extra_setting_for_reset_password {
|
|
59
|
-
position: relative;
|
|
60
|
-
top: 2px;
|
|
61
|
-
opacity: 0.7;
|
|
62
|
-
color: rgb(56, 149, 250);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
.btn {
|
|
66
|
-
height: 50px;
|
|
67
|
-
:deep(.van-button__text) {
|
|
68
|
-
color: rgb(255, 255, 255);
|
|
69
|
-
font-size: 16px;
|
|
70
|
-
font-weight: 700;
|
|
71
|
-
line-height: 23px;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
.login_btn {
|
|
75
|
-
background: rgb(56, 149, 250);
|
|
76
|
-
margin-top: 104px;
|
|
77
|
-
}
|
|
78
|
-
.reset_btn {
|
|
79
|
-
margin: 24px 0;
|
|
80
|
-
}
|
|
81
|
-
.back_btn {
|
|
82
|
-
:deep(.van-button__text) {
|
|
83
|
-
color: rgb(56, 149, 250);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
:deep(.van-cell:after) {
|
|
87
|
-
border-bottom: none;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
.login_form {
|
|
91
|
-
margin-top: 65px;
|
|
92
|
-
}
|
|
93
|
-
.forget_password_form {
|
|
94
|
-
margin-top: 15px;
|
|
95
|
-
}
|
|
96
|
-
/* 使图标垂直居中 */
|
|
97
|
-
.wechat-login-btn .van-icon {
|
|
98
|
-
vertical-align: middle;
|
|
99
|
-
}
|
|
100
|
-
/* 悬停效果 */
|
|
101
|
-
.wechat-login-btn:hover {
|
|
102
|
-
background-color: #06ad56 !important;
|
|
103
|
-
border-color: #06ad56 !important;
|
|
104
|
-
}
|
|
105
|
-
/* 点击效果 */
|
|
106
|
-
.wechat-login-btn:active {
|
|
107
|
-
background-color: #05994c !important;
|
|
108
|
-
border-color: #05994c !important;
|
|
109
|
-
}
|
|
1
|
+
html:not(.dark) {
|
|
2
|
+
.form {
|
|
3
|
+
.form_field {
|
|
4
|
+
:deep(.van-field__label) {
|
|
5
|
+
color: rgb(88, 88, 88);
|
|
6
|
+
}
|
|
7
|
+
:deep(.van-field__body) {
|
|
8
|
+
background: rgb(251, 251, 251);
|
|
9
|
+
box-shadow: inset 0 0 1px 0 rgba(0, 0, 0, 0.1);
|
|
10
|
+
color: rgb(71, 71, 71);
|
|
11
|
+
}
|
|
12
|
+
:deep(.van-cell) {
|
|
13
|
+
background: #ffffff;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
.extra_setting {
|
|
17
|
+
.extra_setting_for_remember_password {
|
|
18
|
+
color: rgb(88, 88, 88);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
.form {
|
|
24
|
+
width: 100%;
|
|
25
|
+
padding: 0 40px;
|
|
26
|
+
.form_field {
|
|
27
|
+
padding-right: 0;
|
|
28
|
+
padding-left: 0;
|
|
29
|
+
:deep(.van-field__label) {
|
|
30
|
+
opacity: 0.7;
|
|
31
|
+
font-size: 16px;
|
|
32
|
+
font-weight: 400;
|
|
33
|
+
line-height: 23px;
|
|
34
|
+
text-transform: uppercase;
|
|
35
|
+
text-indent: 10px;
|
|
36
|
+
}
|
|
37
|
+
:deep(.van-field__body) {
|
|
38
|
+
height: 40px;
|
|
39
|
+
border-radius: 5px;
|
|
40
|
+
font-size: 16px;
|
|
41
|
+
font-weight: 400;
|
|
42
|
+
padding: 8px 10px;
|
|
43
|
+
opacity: 0.6;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
.extra_setting {
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
font-weight: 400;
|
|
49
|
+
line-height: 12px;
|
|
50
|
+
.extra_setting_for_remember_password {
|
|
51
|
+
opacity: 0.7;
|
|
52
|
+
span {
|
|
53
|
+
position: relative;
|
|
54
|
+
bottom: 3px;
|
|
55
|
+
left: 5px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
.extra_setting_for_reset_password {
|
|
59
|
+
position: relative;
|
|
60
|
+
top: 2px;
|
|
61
|
+
opacity: 0.7;
|
|
62
|
+
color: rgb(56, 149, 250);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
.btn {
|
|
66
|
+
height: 50px;
|
|
67
|
+
:deep(.van-button__text) {
|
|
68
|
+
color: rgb(255, 255, 255);
|
|
69
|
+
font-size: 16px;
|
|
70
|
+
font-weight: 700;
|
|
71
|
+
line-height: 23px;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
.login_btn {
|
|
75
|
+
background: rgb(56, 149, 250);
|
|
76
|
+
margin-top: 104px;
|
|
77
|
+
}
|
|
78
|
+
.reset_btn {
|
|
79
|
+
margin: 24px 0;
|
|
80
|
+
}
|
|
81
|
+
.back_btn {
|
|
82
|
+
:deep(.van-button__text) {
|
|
83
|
+
color: rgb(56, 149, 250);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
:deep(.van-cell:after) {
|
|
87
|
+
border-bottom: none;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
.login_form {
|
|
91
|
+
margin-top: 65px;
|
|
92
|
+
}
|
|
93
|
+
.forget_password_form {
|
|
94
|
+
margin-top: 15px;
|
|
95
|
+
}
|
|
96
|
+
/* 使图标垂直居中 */
|
|
97
|
+
.wechat-login-btn .van-icon {
|
|
98
|
+
vertical-align: middle;
|
|
99
|
+
}
|
|
100
|
+
/* 悬停效果 */
|
|
101
|
+
.wechat-login-btn:hover {
|
|
102
|
+
background-color: #06ad56 !important;
|
|
103
|
+
border-color: #06ad56 !important;
|
|
104
|
+
}
|
|
105
|
+
/* 点击效果 */
|
|
106
|
+
.wechat-login-btn:active {
|
|
107
|
+
background-color: #05994c !important;
|
|
108
|
+
border-color: #05994c !important;
|
|
109
|
+
}
|
package/src/utils/environment.ts
CHANGED
|
@@ -29,17 +29,17 @@ function getPlatformFromClient(): string {
|
|
|
29
29
|
|
|
30
30
|
function inferPlatformFromUserAgent(userAgent: string): string {
|
|
31
31
|
const ua = (userAgent || '').toLowerCase()
|
|
32
|
-
if (ua.includes('windows'))
|
|
32
|
+
if (ua.includes('windows'))
|
|
33
33
|
return 'windows'
|
|
34
|
-
if (ua.includes('mac os x') || ua.includes('macintosh') || ua.includes('mac os'))
|
|
34
|
+
if (ua.includes('mac os x') || ua.includes('macintosh') || ua.includes('mac os'))
|
|
35
35
|
return 'macos'
|
|
36
|
-
if (ua.includes('android'))
|
|
36
|
+
if (ua.includes('android'))
|
|
37
37
|
return 'android'
|
|
38
|
-
if (ua.includes('iphone') || ua.includes('ipad') || ua.includes('ipod') || ua.includes('ios'))
|
|
38
|
+
if (ua.includes('iphone') || ua.includes('ipad') || ua.includes('ipod') || ua.includes('ios'))
|
|
39
39
|
return 'ios'
|
|
40
|
-
if (ua.includes('cros'))
|
|
40
|
+
if (ua.includes('cros'))
|
|
41
41
|
return 'chrome os'
|
|
42
|
-
if (ua.includes('linux'))
|
|
42
|
+
if (ua.includes('linux'))
|
|
43
43
|
return 'linux'
|
|
44
44
|
return 'unknown'
|
|
45
45
|
}
|
|
@@ -89,13 +89,13 @@ export function detectEnvironment(): EnvironmentInfo {
|
|
|
89
89
|
export function getCurrentScene(): 'wechat' | 'browser' | 'miniprogram' | 'app' | 'unknown' {
|
|
90
90
|
const env = detectEnvironment()
|
|
91
91
|
|
|
92
|
-
if (env.isMiniprogram)
|
|
92
|
+
if (env.isMiniprogram)
|
|
93
93
|
return 'miniprogram'
|
|
94
|
-
if (env.isWechat)
|
|
94
|
+
if (env.isWechat)
|
|
95
95
|
return 'wechat'
|
|
96
|
-
if (env.isApp)
|
|
96
|
+
if (env.isApp)
|
|
97
97
|
return 'app'
|
|
98
|
-
if (env.isBrowser)
|
|
98
|
+
if (env.isBrowser)
|
|
99
99
|
return 'browser'
|
|
100
100
|
|
|
101
101
|
return 'unknown'
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 根据类型获取日期区间字符串
|
|
3
|
-
* @param type '当年' | 'curMonth' | '当日'
|
|
4
|
-
* @param show 区分实际值还是显示值, true为实际值, false为显示值
|
|
5
|
-
* @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
|
|
6
|
-
*/
|
|
7
|
-
export function getRangeByType(type: string, show: boolean): [string, string] {
|
|
8
|
-
const now = new Date()
|
|
9
|
-
const year = now.getFullYear()
|
|
10
|
-
const month = (now.getMonth() + 1).toString().padStart(2, '0')
|
|
11
|
-
const day = now.getDate().toString().padStart(2, '0')
|
|
12
|
-
|
|
13
|
-
if (!show) {
|
|
14
|
-
if (type === 'curYear') {
|
|
15
|
-
return [
|
|
16
|
-
`${year}-01-01 00:00:00`,
|
|
17
|
-
`${year}-12-31 23:59:59`,
|
|
18
|
-
]
|
|
19
|
-
}
|
|
20
|
-
if (type === 'curMonth') {
|
|
21
|
-
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
22
|
-
return [
|
|
23
|
-
`${year}-${month}-01 00:00:00`,
|
|
24
|
-
`${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
|
|
25
|
-
]
|
|
26
|
-
}
|
|
27
|
-
if (type === 'curDay') {
|
|
28
|
-
return [
|
|
29
|
-
`${year}-${month}-${day} 00:00:00`,
|
|
30
|
-
`${year}-${month}-${day} 23:59:59`,
|
|
31
|
-
]
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (show) {
|
|
35
|
-
if (type === 'curYear') {
|
|
36
|
-
return [
|
|
37
|
-
`${year}-01-01`,
|
|
38
|
-
`${year}-12-31`,
|
|
39
|
-
]
|
|
40
|
-
}
|
|
41
|
-
if (type === 'curMonth') {
|
|
42
|
-
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
43
|
-
return [
|
|
44
|
-
`${year}-${month}-01`,
|
|
45
|
-
`${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
|
|
46
|
-
]
|
|
47
|
-
}
|
|
48
|
-
if (type === 'curDay') {
|
|
49
|
-
return [
|
|
50
|
-
`${year}-${month}-${day}`,
|
|
51
|
-
`${year}-${month}-${day}`,
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
// 兜底返回空字符串数组
|
|
56
|
-
return ['', '']
|
|
57
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 根据类型获取日期区间字符串
|
|
3
|
+
* @param type '当年' | 'curMonth' | '当日'
|
|
4
|
+
* @param show 区分实际值还是显示值, true为实际值, false为显示值
|
|
5
|
+
* @returns [start, end] 例:['2024-01-01 00:00:00', '2024-12-31 23:59:59']
|
|
6
|
+
*/
|
|
7
|
+
export function getRangeByType(type: string, show: boolean): [string, string] {
|
|
8
|
+
const now = new Date()
|
|
9
|
+
const year = now.getFullYear()
|
|
10
|
+
const month = (now.getMonth() + 1).toString().padStart(2, '0')
|
|
11
|
+
const day = now.getDate().toString().padStart(2, '0')
|
|
12
|
+
|
|
13
|
+
if (!show) {
|
|
14
|
+
if (type === 'curYear') {
|
|
15
|
+
return [
|
|
16
|
+
`${year}-01-01 00:00:00`,
|
|
17
|
+
`${year}-12-31 23:59:59`,
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
if (type === 'curMonth') {
|
|
21
|
+
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
22
|
+
return [
|
|
23
|
+
`${year}-${month}-01 00:00:00`,
|
|
24
|
+
`${year}-${month}-${lastDay.toString().padStart(2, '0')} 23:59:59`,
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
if (type === 'curDay') {
|
|
28
|
+
return [
|
|
29
|
+
`${year}-${month}-${day} 00:00:00`,
|
|
30
|
+
`${year}-${month}-${day} 23:59:59`,
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (show) {
|
|
35
|
+
if (type === 'curYear') {
|
|
36
|
+
return [
|
|
37
|
+
`${year}-01-01`,
|
|
38
|
+
`${year}-12-31`,
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
if (type === 'curMonth') {
|
|
42
|
+
const lastDay = new Date(year, now.getMonth() + 1, 0).getDate()
|
|
43
|
+
return [
|
|
44
|
+
`${year}-${month}-01`,
|
|
45
|
+
`${year}-${month}-${lastDay.toString().padStart(2, '0')}`,
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
if (type === 'curDay') {
|
|
49
|
+
return [
|
|
50
|
+
`${year}-${month}-${day}`,
|
|
51
|
+
`${year}-${month}-${day}`,
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// 兜底返回空字符串数组
|
|
56
|
+
return ['', '']
|
|
57
|
+
}
|