@netang/quasar 0.2.11 → 0.2.13
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/components/data/index.vue +20 -20
- package/components/dialog/index.vue +2 -2
- package/components/dragger/index.vue +203 -203
- package/components/field-date/methods.js +100 -100
- package/components/field-text/index.vue +165 -165
- package/components/input-number/index.vue +21 -13
- package/components/list-menu/index.vue +149 -149
- package/components/list-menu-item/index.vue +79 -79
- package/components/price/index.vue +188 -188
- package/components/private/components/index.js +11 -11
- package/components/table-pagination/index.vue +192 -192
- package/components/thumbnail/index.vue +72 -72
- package/components/value-format/index.vue +274 -274
- package/configs/area3.js +1 -1
- package/docs/css/index.css +3 -3
- package/package.json +1 -1
- package/sass/line.scss +39 -39
- package/sass/quasar/btn.scss +46 -46
- package/sass/quasar/common.scss +3 -3
- package/sass/quasar/drawer.scss +6 -6
- package/sass/quasar/loading.scss +6 -6
- package/sass/quasar/toolbar.scss +22 -22
- package/store/index.js +29 -29
- package/utils/$auth.js +127 -127
- package/utils/$rule.js +13 -13
- package/utils/$ruleValid.js +10 -10
- package/utils/alert.js +12 -12
- package/utils/area.js +400 -400
- package/utils/arr.js +51 -51
- package/utils/bus.js +6 -6
- package/utils/confirm.js +11 -11
- package/utils/copy.js +30 -30
- package/utils/dictOptions.js +28 -28
- package/utils/loading.js +15 -15
- package/utils/notify.js +13 -13
- package/utils/price.js +18 -18
- package/utils/symbols.js +18 -18
- package/utils/toast.js +13 -13
- package/utils/useAuth.js +30 -30
- package/utils/useRouter.js +47 -47
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<slot :data="data" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script>
|
|
6
|
-
export default {
|
|
7
|
-
/**
|
|
8
|
-
* 标识
|
|
9
|
-
*/
|
|
10
|
-
name: 'NData',
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 传参
|
|
14
|
-
*/
|
|
15
|
-
props: {
|
|
16
|
-
// 数据
|
|
17
|
-
data: {},
|
|
18
|
-
},
|
|
19
|
-
}
|
|
20
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<slot :data="data" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
export default {
|
|
7
|
+
/**
|
|
8
|
+
* 标识
|
|
9
|
+
*/
|
|
10
|
+
name: 'NData',
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 传参
|
|
14
|
+
*/
|
|
15
|
+
props: {
|
|
16
|
+
// 数据
|
|
17
|
+
data: {},
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
@@ -300,7 +300,7 @@ export default {
|
|
|
300
300
|
/**
|
|
301
301
|
* 对话框确认
|
|
302
302
|
*/
|
|
303
|
-
async function onDialogConfirm() {
|
|
303
|
+
async function onDialogConfirm(...args) {
|
|
304
304
|
|
|
305
305
|
// 如果有确定按钮
|
|
306
306
|
if ($n_isFunction(props.onConfirm)) {
|
|
@@ -313,7 +313,7 @@ export default {
|
|
|
313
313
|
return
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
const res = await $n_runAsync(props.onConfirm)(await $n_runAsync(compSubmit)(), hide)
|
|
316
|
+
const res = await $n_runAsync(props.onConfirm)(await $n_runAsync(compSubmit)(...args), hide)
|
|
317
317
|
if (res === false) {
|
|
318
318
|
return
|
|
319
319
|
}
|
|
@@ -1,203 +1,203 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
class="n-dragger"
|
|
4
|
-
:class="{
|
|
5
|
-
dragging,
|
|
6
|
-
}"
|
|
7
|
-
>
|
|
8
|
-
<slot
|
|
9
|
-
:mousedown="mousedown"
|
|
10
|
-
:fromIndex="fromIndex"
|
|
11
|
-
:dragStart="dragStart"
|
|
12
|
-
:dragEnter="dragEnter"
|
|
13
|
-
:dragEnd="dragEnd"
|
|
14
|
-
/>
|
|
15
|
-
</div>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script>
|
|
19
|
-
import { ref, computed } from 'vue'
|
|
20
|
-
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
21
|
-
|
|
22
|
-
export default {
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 标识
|
|
26
|
-
*/
|
|
27
|
-
name: 'NDragger',
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* 声明属性
|
|
31
|
-
*/
|
|
32
|
-
props: {
|
|
33
|
-
// 值 v-model
|
|
34
|
-
modelValue: Array,
|
|
35
|
-
// 是否开启拖拽
|
|
36
|
-
drag: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: true,
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 声明事件
|
|
44
|
-
*/
|
|
45
|
-
emits: [
|
|
46
|
-
'update:modelValue',
|
|
47
|
-
],
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 组合式
|
|
51
|
-
*/
|
|
52
|
-
setup(props, { emit }) {
|
|
53
|
-
|
|
54
|
-
// ==========【数据】=============================================================================================
|
|
55
|
-
|
|
56
|
-
// 是否拖拽中
|
|
57
|
-
const dragging = ref(false)
|
|
58
|
-
|
|
59
|
-
// 原始位置 index
|
|
60
|
-
const fromIndex = ref(null)
|
|
61
|
-
|
|
62
|
-
// 目标位置 index
|
|
63
|
-
const toIndex = ref(null)
|
|
64
|
-
|
|
65
|
-
// ==========【计算属性】=========================================================================================
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 是否开启拖拽
|
|
69
|
-
*/
|
|
70
|
-
const isDrag = computed(function() {
|
|
71
|
-
return props.drag
|
|
72
|
-
&& $n_isValidArray(props.modelValue)
|
|
73
|
-
&& props.modelValue.length > 1
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
// ==========【方法】=============================================================================================
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 鼠标点击事件
|
|
80
|
-
*/
|
|
81
|
-
function mousedown() {
|
|
82
|
-
// 如果开启拖拽
|
|
83
|
-
if (isDrag.value) {
|
|
84
|
-
// 设置拖拽中
|
|
85
|
-
dragging.value = true
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* 拖拽开始
|
|
91
|
-
* dragstart: 开始拖元素触发
|
|
92
|
-
* dragenter: 当元素拖进可drop元素(绑定drop事件的元素)时触发
|
|
93
|
-
* dragover: 当元素拖动到drop元素上时触发
|
|
94
|
-
* drop: 当元素放下到drop元素触发
|
|
95
|
-
* dragleave : 当元素离开drop元素时触发
|
|
96
|
-
* drag: 每次元素被拖动时会触发
|
|
97
|
-
* dragend: 放开拖动元素时触发
|
|
98
|
-
*/
|
|
99
|
-
function dragStart(e, index) {
|
|
100
|
-
|
|
101
|
-
// 如果开启拖拽
|
|
102
|
-
if (isDrag.value) {
|
|
103
|
-
|
|
104
|
-
// 如果为火狐浏览器, 则必须要setData
|
|
105
|
-
// if ($n_ua.firefox) {
|
|
106
|
-
// e.dataTransfer.setData('info', e.target.id)
|
|
107
|
-
// }
|
|
108
|
-
|
|
109
|
-
// 设置拖拽中
|
|
110
|
-
dragging.value = true
|
|
111
|
-
|
|
112
|
-
// 设置原始位置 index
|
|
113
|
-
fromIndex.value = index
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* 拖拽中
|
|
119
|
-
*/
|
|
120
|
-
function dragEnter(e, index) {
|
|
121
|
-
|
|
122
|
-
// 如果开启拖拽
|
|
123
|
-
if (isDrag.value) {
|
|
124
|
-
|
|
125
|
-
// 设置目标位置 index
|
|
126
|
-
toIndex.value = index
|
|
127
|
-
|
|
128
|
-
// 如果拖拽中
|
|
129
|
-
if (dragging.value) {
|
|
130
|
-
|
|
131
|
-
// 为需要移动的元素设置 dragstart 事件
|
|
132
|
-
// e.dataTransfer.effectAllowed = 'move'
|
|
133
|
-
|
|
134
|
-
// 原始位置 index
|
|
135
|
-
const from = fromIndex.value
|
|
136
|
-
// 目标位置 index
|
|
137
|
-
const to = toIndex.value
|
|
138
|
-
|
|
139
|
-
// 如果原始位置 === 目标位置
|
|
140
|
-
if (from === to) {
|
|
141
|
-
// 则无任何操作
|
|
142
|
-
return
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const val = [...props.modelValue]
|
|
146
|
-
|
|
147
|
-
// 如果当前元素在拖动目标位置的下方, 先将当前元素从数组拿出, 数组长度-1, 我们直接给数组拖动目标位置的地方新增一个和当前元素值一样的元素,
|
|
148
|
-
// 我们再把数组之前的那个拖动的元素删除掉, 所以要len+1
|
|
149
|
-
if (from > to) {
|
|
150
|
-
val.splice(to, 0, val[from])
|
|
151
|
-
val.splice(from + 1, 1)
|
|
152
|
-
|
|
153
|
-
} else {
|
|
154
|
-
// 如果当前元素在拖动目标位置的上方, 先将当前元素从数组拿出, 数组长度-1, 我们直接给数组拖动目标位置+1的地方新增一个和当前元素值一样的元素,
|
|
155
|
-
// 这时, 数组len不变, 我们再把数组之前的那个拖动的元素删除掉, 下标还是from
|
|
156
|
-
val.splice(to + 1, 0, val[from])
|
|
157
|
-
val.splice(from, 1)
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
fromIndex.value = to
|
|
161
|
-
toIndex.value = from
|
|
162
|
-
|
|
163
|
-
// 更新值
|
|
164
|
-
emit('update:modelValue', val)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* 拖拽结束
|
|
171
|
-
*/
|
|
172
|
-
function dragEnd() {
|
|
173
|
-
|
|
174
|
-
// 如果开启拖拽
|
|
175
|
-
if (isDrag.value) {
|
|
176
|
-
fromIndex.value = null
|
|
177
|
-
toIndex.value = null
|
|
178
|
-
dragging.value = false
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// ==========【返回】=============================================================================================
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
// 是否拖拽中
|
|
186
|
-
dragging,
|
|
187
|
-
// 原始位置 index
|
|
188
|
-
fromIndex,
|
|
189
|
-
// 目标位置 index
|
|
190
|
-
toIndex,
|
|
191
|
-
|
|
192
|
-
// 鼠标点击事件
|
|
193
|
-
mousedown,
|
|
194
|
-
// 拖拽开始
|
|
195
|
-
dragStart,
|
|
196
|
-
// 拖拽中
|
|
197
|
-
dragEnter,
|
|
198
|
-
// 拖拽结束
|
|
199
|
-
dragEnd,
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
}
|
|
203
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="n-dragger"
|
|
4
|
+
:class="{
|
|
5
|
+
dragging,
|
|
6
|
+
}"
|
|
7
|
+
>
|
|
8
|
+
<slot
|
|
9
|
+
:mousedown="mousedown"
|
|
10
|
+
:fromIndex="fromIndex"
|
|
11
|
+
:dragStart="dragStart"
|
|
12
|
+
:dragEnter="dragEnter"
|
|
13
|
+
:dragEnd="dragEnd"
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { ref, computed } from 'vue'
|
|
20
|
+
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 标识
|
|
26
|
+
*/
|
|
27
|
+
name: 'NDragger',
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 声明属性
|
|
31
|
+
*/
|
|
32
|
+
props: {
|
|
33
|
+
// 值 v-model
|
|
34
|
+
modelValue: Array,
|
|
35
|
+
// 是否开启拖拽
|
|
36
|
+
drag: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
default: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* 声明事件
|
|
44
|
+
*/
|
|
45
|
+
emits: [
|
|
46
|
+
'update:modelValue',
|
|
47
|
+
],
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 组合式
|
|
51
|
+
*/
|
|
52
|
+
setup(props, { emit }) {
|
|
53
|
+
|
|
54
|
+
// ==========【数据】=============================================================================================
|
|
55
|
+
|
|
56
|
+
// 是否拖拽中
|
|
57
|
+
const dragging = ref(false)
|
|
58
|
+
|
|
59
|
+
// 原始位置 index
|
|
60
|
+
const fromIndex = ref(null)
|
|
61
|
+
|
|
62
|
+
// 目标位置 index
|
|
63
|
+
const toIndex = ref(null)
|
|
64
|
+
|
|
65
|
+
// ==========【计算属性】=========================================================================================
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 是否开启拖拽
|
|
69
|
+
*/
|
|
70
|
+
const isDrag = computed(function() {
|
|
71
|
+
return props.drag
|
|
72
|
+
&& $n_isValidArray(props.modelValue)
|
|
73
|
+
&& props.modelValue.length > 1
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
// ==========【方法】=============================================================================================
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 鼠标点击事件
|
|
80
|
+
*/
|
|
81
|
+
function mousedown() {
|
|
82
|
+
// 如果开启拖拽
|
|
83
|
+
if (isDrag.value) {
|
|
84
|
+
// 设置拖拽中
|
|
85
|
+
dragging.value = true
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 拖拽开始
|
|
91
|
+
* dragstart: 开始拖元素触发
|
|
92
|
+
* dragenter: 当元素拖进可drop元素(绑定drop事件的元素)时触发
|
|
93
|
+
* dragover: 当元素拖动到drop元素上时触发
|
|
94
|
+
* drop: 当元素放下到drop元素触发
|
|
95
|
+
* dragleave : 当元素离开drop元素时触发
|
|
96
|
+
* drag: 每次元素被拖动时会触发
|
|
97
|
+
* dragend: 放开拖动元素时触发
|
|
98
|
+
*/
|
|
99
|
+
function dragStart(e, index) {
|
|
100
|
+
|
|
101
|
+
// 如果开启拖拽
|
|
102
|
+
if (isDrag.value) {
|
|
103
|
+
|
|
104
|
+
// 如果为火狐浏览器, 则必须要setData
|
|
105
|
+
// if ($n_ua.firefox) {
|
|
106
|
+
// e.dataTransfer.setData('info', e.target.id)
|
|
107
|
+
// }
|
|
108
|
+
|
|
109
|
+
// 设置拖拽中
|
|
110
|
+
dragging.value = true
|
|
111
|
+
|
|
112
|
+
// 设置原始位置 index
|
|
113
|
+
fromIndex.value = index
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 拖拽中
|
|
119
|
+
*/
|
|
120
|
+
function dragEnter(e, index) {
|
|
121
|
+
|
|
122
|
+
// 如果开启拖拽
|
|
123
|
+
if (isDrag.value) {
|
|
124
|
+
|
|
125
|
+
// 设置目标位置 index
|
|
126
|
+
toIndex.value = index
|
|
127
|
+
|
|
128
|
+
// 如果拖拽中
|
|
129
|
+
if (dragging.value) {
|
|
130
|
+
|
|
131
|
+
// 为需要移动的元素设置 dragstart 事件
|
|
132
|
+
// e.dataTransfer.effectAllowed = 'move'
|
|
133
|
+
|
|
134
|
+
// 原始位置 index
|
|
135
|
+
const from = fromIndex.value
|
|
136
|
+
// 目标位置 index
|
|
137
|
+
const to = toIndex.value
|
|
138
|
+
|
|
139
|
+
// 如果原始位置 === 目标位置
|
|
140
|
+
if (from === to) {
|
|
141
|
+
// 则无任何操作
|
|
142
|
+
return
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const val = [...props.modelValue]
|
|
146
|
+
|
|
147
|
+
// 如果当前元素在拖动目标位置的下方, 先将当前元素从数组拿出, 数组长度-1, 我们直接给数组拖动目标位置的地方新增一个和当前元素值一样的元素,
|
|
148
|
+
// 我们再把数组之前的那个拖动的元素删除掉, 所以要len+1
|
|
149
|
+
if (from > to) {
|
|
150
|
+
val.splice(to, 0, val[from])
|
|
151
|
+
val.splice(from + 1, 1)
|
|
152
|
+
|
|
153
|
+
} else {
|
|
154
|
+
// 如果当前元素在拖动目标位置的上方, 先将当前元素从数组拿出, 数组长度-1, 我们直接给数组拖动目标位置+1的地方新增一个和当前元素值一样的元素,
|
|
155
|
+
// 这时, 数组len不变, 我们再把数组之前的那个拖动的元素删除掉, 下标还是from
|
|
156
|
+
val.splice(to + 1, 0, val[from])
|
|
157
|
+
val.splice(from, 1)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
fromIndex.value = to
|
|
161
|
+
toIndex.value = from
|
|
162
|
+
|
|
163
|
+
// 更新值
|
|
164
|
+
emit('update:modelValue', val)
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 拖拽结束
|
|
171
|
+
*/
|
|
172
|
+
function dragEnd() {
|
|
173
|
+
|
|
174
|
+
// 如果开启拖拽
|
|
175
|
+
if (isDrag.value) {
|
|
176
|
+
fromIndex.value = null
|
|
177
|
+
toIndex.value = null
|
|
178
|
+
dragging.value = false
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// ==========【返回】=============================================================================================
|
|
183
|
+
|
|
184
|
+
return {
|
|
185
|
+
// 是否拖拽中
|
|
186
|
+
dragging,
|
|
187
|
+
// 原始位置 index
|
|
188
|
+
fromIndex,
|
|
189
|
+
// 目标位置 index
|
|
190
|
+
toIndex,
|
|
191
|
+
|
|
192
|
+
// 鼠标点击事件
|
|
193
|
+
mousedown,
|
|
194
|
+
// 拖拽开始
|
|
195
|
+
dragStart,
|
|
196
|
+
// 拖拽中
|
|
197
|
+
dragEnter,
|
|
198
|
+
// 拖拽结束
|
|
199
|
+
dragEnd,
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
}
|
|
203
|
+
</script>
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
import { date } from 'quasar'
|
|
2
|
-
|
|
3
|
-
export const quickRange = ['最近7天', '最近30天', '本月', '上月', '最近2个月', '最近3个月', '最近6个月', '今年', '去年', '最近1年', '最近2年']
|
|
4
|
-
|
|
5
|
-
export function getQuickRange(index, showSecond) {
|
|
6
|
-
|
|
7
|
-
// 获取当前时间
|
|
8
|
-
const now = new Date()
|
|
9
|
-
|
|
10
|
-
const time = {
|
|
11
|
-
from: '00:00',
|
|
12
|
-
to: '23:59',
|
|
13
|
-
}
|
|
14
|
-
if (showSecond) {
|
|
15
|
-
time.from += ':00'
|
|
16
|
-
time.to += ':59'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// const quickRange = ['最近7天', '最近30天', '本周', '上周', '本月', '上月', '最近3个月', '最近6个月', '今年', '去年', '最近1年', '最近2年']
|
|
20
|
-
switch (index) {
|
|
21
|
-
|
|
22
|
-
// 最近7天
|
|
23
|
-
case 0:
|
|
24
|
-
// 最近30天
|
|
25
|
-
case 1:
|
|
26
|
-
return {
|
|
27
|
-
date: {
|
|
28
|
-
from: date.formatDate(date.subtractFromDate(now, { days: index === 0 ? 7 : 30 }), 'YYYY/MM/DD'),
|
|
29
|
-
to: date.formatDate(now, 'YYYY/MM/DD'),
|
|
30
|
-
},
|
|
31
|
-
time,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// 本月
|
|
35
|
-
case 2:
|
|
36
|
-
return {
|
|
37
|
-
date: {
|
|
38
|
-
from: date.formatDate(date.startOfDate(now, 'month'), 'YYYY/MM/DD'),
|
|
39
|
-
to: date.formatDate(date.endOfDate(now, 'month'), 'YYYY/MM/DD'),
|
|
40
|
-
},
|
|
41
|
-
time,
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 上月
|
|
45
|
-
case 3:
|
|
46
|
-
return {
|
|
47
|
-
date: {
|
|
48
|
-
from: date.formatDate(date.startOfDate(date.subtractFromDate(now, { month: 1 }), 'month'), 'YYYY/MM/DD'),
|
|
49
|
-
to: date.formatDate(date.endOfDate(date.subtractFromDate(now, { month: 1 }), 'month'), 'YYYY/MM/DD'),
|
|
50
|
-
},
|
|
51
|
-
time,
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// 最近2个月
|
|
55
|
-
case 4:
|
|
56
|
-
// 最近3个月
|
|
57
|
-
case 5:
|
|
58
|
-
// 最近6个月
|
|
59
|
-
case 6:
|
|
60
|
-
return {
|
|
61
|
-
date: {
|
|
62
|
-
from: date.formatDate(date.subtractFromDate(now, { months: index === 4 ? 2 : (index === 5 ? 3 : 6) }), 'YYYY/MM/DD'),
|
|
63
|
-
to: date.formatDate(now, 'YYYY/MM/DD'),
|
|
64
|
-
},
|
|
65
|
-
time,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// 今年
|
|
69
|
-
case 7:
|
|
70
|
-
return {
|
|
71
|
-
date: {
|
|
72
|
-
from: date.formatDate(date.startOfDate(now, 'year'), 'YYYY/MM/DD'),
|
|
73
|
-
to: date.formatDate(date.endOfDate(now, 'year'), 'YYYY/MM/DD'),
|
|
74
|
-
},
|
|
75
|
-
time,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// 去年
|
|
79
|
-
case 8:
|
|
80
|
-
return {
|
|
81
|
-
date: {
|
|
82
|
-
from: date.formatDate(date.startOfDate(date.subtractFromDate(now, { year: 1 }), 'year'), 'YYYY/MM/DD'),
|
|
83
|
-
to: date.formatDate(date.endOfDate(date.subtractFromDate(now, { year: 1 }), 'year'), 'YYYY/MM/DD'),
|
|
84
|
-
},
|
|
85
|
-
time,
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// 最近1年
|
|
89
|
-
case 9:
|
|
90
|
-
// 最近2年
|
|
91
|
-
case 10:
|
|
92
|
-
return {
|
|
93
|
-
date: {
|
|
94
|
-
from: date.formatDate(date.subtractFromDate(now, { year: index === 9 ? 1 : 2 }), 'YYYY/MM/DD'),
|
|
95
|
-
to: date.formatDate(now, 'YYYY/MM/DD'),
|
|
96
|
-
},
|
|
97
|
-
time,
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
1
|
+
import { date } from 'quasar'
|
|
2
|
+
|
|
3
|
+
export const quickRange = ['最近7天', '最近30天', '本月', '上月', '最近2个月', '最近3个月', '最近6个月', '今年', '去年', '最近1年', '最近2年']
|
|
4
|
+
|
|
5
|
+
export function getQuickRange(index, showSecond) {
|
|
6
|
+
|
|
7
|
+
// 获取当前时间
|
|
8
|
+
const now = new Date()
|
|
9
|
+
|
|
10
|
+
const time = {
|
|
11
|
+
from: '00:00',
|
|
12
|
+
to: '23:59',
|
|
13
|
+
}
|
|
14
|
+
if (showSecond) {
|
|
15
|
+
time.from += ':00'
|
|
16
|
+
time.to += ':59'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// const quickRange = ['最近7天', '最近30天', '本周', '上周', '本月', '上月', '最近3个月', '最近6个月', '今年', '去年', '最近1年', '最近2年']
|
|
20
|
+
switch (index) {
|
|
21
|
+
|
|
22
|
+
// 最近7天
|
|
23
|
+
case 0:
|
|
24
|
+
// 最近30天
|
|
25
|
+
case 1:
|
|
26
|
+
return {
|
|
27
|
+
date: {
|
|
28
|
+
from: date.formatDate(date.subtractFromDate(now, { days: index === 0 ? 7 : 30 }), 'YYYY/MM/DD'),
|
|
29
|
+
to: date.formatDate(now, 'YYYY/MM/DD'),
|
|
30
|
+
},
|
|
31
|
+
time,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 本月
|
|
35
|
+
case 2:
|
|
36
|
+
return {
|
|
37
|
+
date: {
|
|
38
|
+
from: date.formatDate(date.startOfDate(now, 'month'), 'YYYY/MM/DD'),
|
|
39
|
+
to: date.formatDate(date.endOfDate(now, 'month'), 'YYYY/MM/DD'),
|
|
40
|
+
},
|
|
41
|
+
time,
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// 上月
|
|
45
|
+
case 3:
|
|
46
|
+
return {
|
|
47
|
+
date: {
|
|
48
|
+
from: date.formatDate(date.startOfDate(date.subtractFromDate(now, { month: 1 }), 'month'), 'YYYY/MM/DD'),
|
|
49
|
+
to: date.formatDate(date.endOfDate(date.subtractFromDate(now, { month: 1 }), 'month'), 'YYYY/MM/DD'),
|
|
50
|
+
},
|
|
51
|
+
time,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 最近2个月
|
|
55
|
+
case 4:
|
|
56
|
+
// 最近3个月
|
|
57
|
+
case 5:
|
|
58
|
+
// 最近6个月
|
|
59
|
+
case 6:
|
|
60
|
+
return {
|
|
61
|
+
date: {
|
|
62
|
+
from: date.formatDate(date.subtractFromDate(now, { months: index === 4 ? 2 : (index === 5 ? 3 : 6) }), 'YYYY/MM/DD'),
|
|
63
|
+
to: date.formatDate(now, 'YYYY/MM/DD'),
|
|
64
|
+
},
|
|
65
|
+
time,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// 今年
|
|
69
|
+
case 7:
|
|
70
|
+
return {
|
|
71
|
+
date: {
|
|
72
|
+
from: date.formatDate(date.startOfDate(now, 'year'), 'YYYY/MM/DD'),
|
|
73
|
+
to: date.formatDate(date.endOfDate(now, 'year'), 'YYYY/MM/DD'),
|
|
74
|
+
},
|
|
75
|
+
time,
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 去年
|
|
79
|
+
case 8:
|
|
80
|
+
return {
|
|
81
|
+
date: {
|
|
82
|
+
from: date.formatDate(date.startOfDate(date.subtractFromDate(now, { year: 1 }), 'year'), 'YYYY/MM/DD'),
|
|
83
|
+
to: date.formatDate(date.endOfDate(date.subtractFromDate(now, { year: 1 }), 'year'), 'YYYY/MM/DD'),
|
|
84
|
+
},
|
|
85
|
+
time,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// 最近1年
|
|
89
|
+
case 9:
|
|
90
|
+
// 最近2年
|
|
91
|
+
case 10:
|
|
92
|
+
return {
|
|
93
|
+
date: {
|
|
94
|
+
from: date.formatDate(date.subtractFromDate(now, { year: index === 9 ? 1 : 2 }), 'YYYY/MM/DD'),
|
|
95
|
+
to: date.formatDate(now, 'YYYY/MM/DD'),
|
|
96
|
+
},
|
|
97
|
+
time,
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|