widget.qw 1.0.81 → 1.0.83
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/.env.development +10 -10
- package/.env.production +8 -8
- package/README.md +75 -75
- package/build/style.css +471 -471
- package/build/widget.qw.es.js +64 -65
- package/build/widget.qw.umd.js +64 -65
- package/index.html +17 -17
- package/package.json +47 -47
- package/src/App.vue +26 -26
- package/src/api/index.js +165 -165
- package/src/components/AuditBar.vue +396 -396
- package/src/components/BillCard.vue +164 -164
- package/src/components/CascaderPicker.vue +132 -132
- package/src/components/CascaderPop.vue +371 -371
- package/src/components/CheckGroup.vue +113 -113
- package/src/components/DatetimePicker/DatetimePop.vue +342 -342
- package/src/components/DatetimePicker/index.vue +124 -124
- package/src/components/DayDropdown.vue +56 -56
- package/src/components/FilePicker.vue +169 -169
- package/src/components/Input.vue +80 -80
- package/src/components/MonthDropdown.vue +51 -51
- package/src/components/MultiPicker.vue +123 -123
- package/src/components/ObjsEditor.vue +334 -334
- package/src/components/SecretNotify.js +5 -5
- package/src/components/Sheet.vue +92 -92
- package/src/components/SingleApiPicker.vue +108 -108
- package/src/components/SinglePicker.vue +102 -102
- package/src/components/SingleUserSelector.vue +425 -425
- package/src/components/Switch.vue +64 -64
- package/src/components/TreePicker.vue +113 -113
- package/src/components/UserPicker.vue +106 -106
- package/src/components/UserProfile.vue +129 -129
- package/src/components/UsersPicker.vue +118 -118
- package/src/components/YearDropdown.vue +59 -59
- package/src/components/data_selector.vue +303 -303
- package/src/components/image_picker.vue +123 -123
- package/src/components/images_picker.vue +195 -195
- package/src/components/index.js +162 -162
- package/src/components/mult_list_selector.vue +155 -155
- package/src/components/subdepartment_selector.vue +481 -481
- package/src/components/user_selector.vue +639 -639
- package/src/components/widget/DataPop.vue +95 -95
- package/src/components/widget/TreePop.vue +88 -88
- package/src/components/widget/UserPop.vue +347 -347
- package/src/env.d.ts +8 -8
- package/src/main.js +117 -117
- package/src/router/index.ts +173 -173
- package/src/util/array_util.js +32 -32
- package/src/util/auth_util.js +72 -73
- package/src/util/bool_util.js +5 -5
- package/src/util/bus.js +1 -1
- package/src/util/cache_util.js +18 -18
- package/src/util/errer_code.js +6 -6
- package/src/util/eval_util.js +19 -19
- package/src/util/icon_util.js +36 -36
- package/src/util/image_util.js +27 -27
- package/src/util/index.js +57 -57
- package/src/util/num_util.js +70 -70
- package/src/util/obj_util.js +28 -28
- package/src/util/request.js +73 -73
- package/src/util/request_json.js +71 -71
- package/src/util/request_json_mute.js +65 -65
- package/src/util/request_upload.js +79 -79
- package/src/util/route_util.js +31 -31
- package/src/util/str_util.js +143 -143
- package/src/util/time_util.js +406 -406
- package/src/util/toast_util.js +24 -24
- package/src/util/tree_util.js +153 -153
- package/src/util/uuid_util.js +9 -9
- package/src/util/validate.js +182 -182
- package/src/util/vue_filter.js +223 -223
- package/src/views/auditbar/index.vue +78 -78
- package/src/views/billcard/index.vue +48 -48
- package/src/views/cascaderpop/index.vue +90 -90
- package/src/views/checkgroup/index.vue +35 -35
- package/src/views/dataSelector/index.vue +48 -48
- package/src/views/datetimepicker/index.vue +34 -34
- package/src/views/daydropdown/index.vue +31 -31
- package/src/views/filepicker/index.vue +32 -32
- package/src/views/imagepicker/index.vue +31 -31
- package/src/views/imagespicker/index.vue +37 -37
- package/src/views/input/index.vue +35 -35
- package/src/views/monthdropdown/index.vue +31 -31
- package/src/views/multListSelector/index.vue +61 -61
- package/src/views/multipicker/index.vue +36 -36
- package/src/views/objseditor/index.vue +277 -277
- package/src/views/productSelector/index.vue +35 -35
- package/src/views/projectpicker/index.vue +41 -41
- package/src/views/secretnotify/index.vue +27 -27
- package/src/views/sheet/index.vue +45 -45
- package/src/views/singlepicker/index.vue +35 -35
- package/src/views/subdepartmentSelector/index.vue +40 -40
- package/src/views/switch/index.vue +34 -34
- package/src/views/treepicker/index.vue +41 -41
- package/src/views/userSelector/index.vue +54 -54
- package/src/views/userSelectorNew/index.vue +45 -45
- package/src/views/userpicker/index.vue +43 -43
- package/src/views/userprofile/index.vue +30 -30
- package/src/views/userspicker/index.vue +43 -43
- package/src/views/yeardropdown/index.vue +32 -32
- package/src/vm/index.js +1 -1
- package/tsconfig.json +19 -19
- package/tsconfig.node.json +8 -8
- package/vite.config.ts +122 -122
|
@@ -1,343 +1,343 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- 弹出层 -->
|
|
3
|
-
<van-popup v-model:show="isShow" position="bottom" round @close="onClose">
|
|
4
|
-
<van-picker ref="picker" title="请选择时间" :columns="data.columns" @change="onChange" @cancel="onCancel"
|
|
5
|
-
@confirm="onConfirm" v-model="data.selectedValues" />
|
|
6
|
-
</van-popup>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<script setup>
|
|
11
|
-
import { reactive, watch, getCurrentInstance, computed } from "vue"
|
|
12
|
-
import util from '@/util'
|
|
13
|
-
import { useVModel } from "@vueuse/core"
|
|
14
|
-
import moment from'moment'
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const data = reactive({
|
|
18
|
-
columns: [], //所有时间列
|
|
19
|
-
selectedValues: [] //控件选择的时间值
|
|
20
|
-
})
|
|
21
|
-
const props = defineProps({
|
|
22
|
-
isShow: {
|
|
23
|
-
type: Boolean,
|
|
24
|
-
default: false
|
|
25
|
-
},
|
|
26
|
-
modelValue: {
|
|
27
|
-
type: String,
|
|
28
|
-
default: ''
|
|
29
|
-
|
|
30
|
-
}, //时间值
|
|
31
|
-
before: {
|
|
32
|
-
type: Boolean,
|
|
33
|
-
default: false
|
|
34
|
-
},
|
|
35
|
-
//最晚时间
|
|
36
|
-
latest_time: {
|
|
37
|
-
type: String,
|
|
38
|
-
default: ''
|
|
39
|
-
},
|
|
40
|
-
columnsType: {
|
|
41
|
-
type: Array,
|
|
42
|
-
default: ['year', 'month', 'day', 'hour', 'minute', 'second']
|
|
43
|
-
}
|
|
44
|
-
})
|
|
45
|
-
//定义要向父组件传递的事件
|
|
46
|
-
const emit = defineEmits(['update:modelValue', 'update:isShow'])
|
|
47
|
-
const isShow = useVModel(props, 'isShow', emit)
|
|
48
|
-
|
|
49
|
-
watch(
|
|
50
|
-
() => isShow,
|
|
51
|
-
(n, o) => {
|
|
52
|
-
if (!n)
|
|
53
|
-
return
|
|
54
|
-
getcolumns()
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
// 修改年月,更新选项
|
|
62
|
-
watch(
|
|
63
|
-
() => {
|
|
64
|
-
if(props.columnsType.includes('year'))
|
|
65
|
-
return data.selectedValues[0]
|
|
66
|
-
else
|
|
67
|
-
return 0
|
|
68
|
-
},
|
|
69
|
-
(n, o) => {
|
|
70
|
-
if (!n)
|
|
71
|
-
return
|
|
72
|
-
|
|
73
|
-
getcolumns()
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
watch(
|
|
81
|
-
() => {
|
|
82
|
-
if(props.columnsType.includes('month'))
|
|
83
|
-
return data.selectedValues[1]
|
|
84
|
-
else
|
|
85
|
-
return 0
|
|
86
|
-
},
|
|
87
|
-
(n, o) => {
|
|
88
|
-
if (!n)
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
getcolumns()
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
watch(
|
|
99
|
-
() => {
|
|
100
|
-
if(props.columnsType.includes('day'))
|
|
101
|
-
return data.selectedValues[2]
|
|
102
|
-
else
|
|
103
|
-
return 0
|
|
104
|
-
},
|
|
105
|
-
(n, o) => {
|
|
106
|
-
if (!n)
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
getcolumns()
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
watch(
|
|
117
|
-
() => {
|
|
118
|
-
if(props.columnsType.includes('hour'))
|
|
119
|
-
return data.selectedValues[3]
|
|
120
|
-
else
|
|
121
|
-
return 0
|
|
122
|
-
},
|
|
123
|
-
(n, o) => {
|
|
124
|
-
if (!n)
|
|
125
|
-
return
|
|
126
|
-
|
|
127
|
-
getcolumns()
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
watch(
|
|
135
|
-
() => {
|
|
136
|
-
if(props.columnsType.includes('minute'))
|
|
137
|
-
return data.selectedValues[4]
|
|
138
|
-
else
|
|
139
|
-
return 0
|
|
140
|
-
},
|
|
141
|
-
(n, o) => {
|
|
142
|
-
if (!n)
|
|
143
|
-
return
|
|
144
|
-
|
|
145
|
-
getcolumns()
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
149
|
-
}
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
watch(
|
|
153
|
-
() => props.latest_time,
|
|
154
|
-
(n, o) => {
|
|
155
|
-
if (!n)
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
getcolumns()
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
162
|
-
}
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
function onChange() {
|
|
167
|
-
// 无用的方法
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function formatSelectTime() {
|
|
171
|
-
let res = data.selectedValues[0] +
|
|
172
|
-
"-" +
|
|
173
|
-
util.pad0(data.selectedValues[1]) +
|
|
174
|
-
"-" +
|
|
175
|
-
util.pad0(data.selectedValues[2]) +
|
|
176
|
-
" "
|
|
177
|
-
|
|
178
|
-
if(props.columnsType.includes('hour'))
|
|
179
|
-
res += util.pad0(data.selectedValues[3])
|
|
180
|
-
else
|
|
181
|
-
res += '00'
|
|
182
|
-
|
|
183
|
-
if(props.columnsType.includes('minute'))
|
|
184
|
-
res +=':'+ util.pad0(data.selectedValues[4])
|
|
185
|
-
else
|
|
186
|
-
res += ':00'
|
|
187
|
-
|
|
188
|
-
if(props.columnsType.includes('second'))
|
|
189
|
-
res +=':'+ util.pad0(data.selectedValues[5])
|
|
190
|
-
else
|
|
191
|
-
res += ':00'
|
|
192
|
-
|
|
193
|
-
return res
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// 根据选取时间,计算时间元素的取值范围
|
|
197
|
-
function getcolumns() {
|
|
198
|
-
// 清除旧的取值范围
|
|
199
|
-
data.columns = []
|
|
200
|
-
let strtime = ''
|
|
201
|
-
// 根据当先选取的时间计算年月日时分秒取值范围
|
|
202
|
-
if (data.selectedValues.length > 0) {
|
|
203
|
-
strtime = formatSelectTime()
|
|
204
|
-
|
|
205
|
-
//无效日期时,将日改为1号
|
|
206
|
-
if (!util.isValidDatetime(strtime)) {
|
|
207
|
-
data.selectedValues[2] = 1
|
|
208
|
-
strtime = formatSelectTime()
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// 开始没有选取的时间时,取父组件传入的时间
|
|
213
|
-
if (!strtime && props.modelValue) {
|
|
214
|
-
strtime = props.modelValue
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// 传入时间为空时,取当前时间
|
|
218
|
-
if (!strtime) {
|
|
219
|
-
strtime = util.date2yyyyMMddhhmmss(new Date()) //传入的时间
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// 获取选取时间的 年 月 日 时 分 秒
|
|
223
|
-
let dateVaules = new Date(moment(strtime))
|
|
224
|
-
let Y = dateVaules.getFullYear()
|
|
225
|
-
let M = dateVaules.getMonth()+1
|
|
226
|
-
let D = dateVaules.getDate()
|
|
227
|
-
let h = dateVaules.getHours()
|
|
228
|
-
let m = dateVaules.getMinutes()
|
|
229
|
-
let s = dateVaules.getSeconds()
|
|
230
|
-
|
|
231
|
-
let currentYear = new Date().getFullYear()
|
|
232
|
-
let beginYear = currentYear - 3
|
|
233
|
-
let endYear = currentYear + 3
|
|
234
|
-
let earliest_time = new Date(moment(`${beginYear}-01-01 00:00:00`))
|
|
235
|
-
let latest_time = new Date(moment(`${endYear}-12-31 23:59:59`))
|
|
236
|
-
|
|
237
|
-
if(props.before)
|
|
238
|
-
latest_time = new Date()
|
|
239
|
-
|
|
240
|
-
if(props.latest_time && (new Date(moment(props.latest_time)).getTime() < latest_time.getTime())){
|
|
241
|
-
latest_time = new Date(moment(props.latest_time))
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
endYear = latest_time.getFullYear()
|
|
245
|
-
|
|
246
|
-
let years = []; //获取后十年数组
|
|
247
|
-
years = Array.apply(null, {length:endYear-beginYear+1}).map((item,idx)=>{
|
|
248
|
-
return {
|
|
249
|
-
text: beginYear+idx,
|
|
250
|
-
value: beginYear+idx
|
|
251
|
-
}
|
|
252
|
-
})
|
|
253
|
-
if (props.columnsType.includes('year'))
|
|
254
|
-
data.columns.push(years) //生成年列
|
|
255
|
-
|
|
256
|
-
let total_month = 12
|
|
257
|
-
if(Y == latest_time.getFullYear())
|
|
258
|
-
total_month = latest_time.getMonth()+1
|
|
259
|
-
let months = [] //获取12月数组
|
|
260
|
-
months = Array.apply(null, { length: total_month }).map(function (item,idx) {
|
|
261
|
-
return {
|
|
262
|
-
text: idx+1,
|
|
263
|
-
value: idx+1
|
|
264
|
-
}
|
|
265
|
-
})
|
|
266
|
-
if (props.columnsType.includes('month'))
|
|
267
|
-
data.columns.push(months) //生成月列
|
|
268
|
-
|
|
269
|
-
//获取当月的天数
|
|
270
|
-
let total_day = util.YYYYMM2max_day(Y, M)
|
|
271
|
-
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1))
|
|
272
|
-
total_day = latest_time.getDate()
|
|
273
|
-
let days = [] //创建当月天数数组
|
|
274
|
-
days = Array.apply(null, { length: total_day }).map((item,idx)=>{
|
|
275
|
-
return { text: idx + 1, value: idx + 1 }
|
|
276
|
-
})
|
|
277
|
-
if (props.columnsType.includes('day'))
|
|
278
|
-
data.columns.push(days) //生成日列
|
|
279
|
-
|
|
280
|
-
let total_hour = 24
|
|
281
|
-
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1) && D == latest_time.getDate())
|
|
282
|
-
total_hour = latest_time.getHours()
|
|
283
|
-
|
|
284
|
-
let hours = [] //创建小时数组
|
|
285
|
-
hours =Array.apply(null, { length: total_hour }).map((item,idx)=> {
|
|
286
|
-
return {
|
|
287
|
-
text: idx,
|
|
288
|
-
value: idx
|
|
289
|
-
}
|
|
290
|
-
})
|
|
291
|
-
if (props.columnsType.includes('hour'))
|
|
292
|
-
data.columns.push(hours) //生成小时列
|
|
293
|
-
|
|
294
|
-
let total_minute = 60
|
|
295
|
-
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1) && D == latest_time.getDate() && h == latest_time.getHours())
|
|
296
|
-
total_minute = latest_time.getMinutes()
|
|
297
|
-
let minutes = [] //创建分钟数组
|
|
298
|
-
minutes = Array.apply(null, { length: total_minute }).map((item,idx)=>{
|
|
299
|
-
return{
|
|
300
|
-
text: idx,
|
|
301
|
-
value: idx
|
|
302
|
-
}
|
|
303
|
-
})
|
|
304
|
-
if (props.columnsType.includes('minute'))
|
|
305
|
-
data.columns.push(minutes) //生成分钟列
|
|
306
|
-
|
|
307
|
-
let total_second = 60
|
|
308
|
-
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1) && D == latest_time.getDate() && h == latest_time.getHours() && m == latest_time.getMinutes())
|
|
309
|
-
total_second = latest_time.getSeconds()
|
|
310
|
-
let seconds = []; //创建秒数数组
|
|
311
|
-
seconds = Array.apply(null, { length: total_minute }).map((item,idx)=>{
|
|
312
|
-
return{
|
|
313
|
-
text: idx,
|
|
314
|
-
value: idx
|
|
315
|
-
}
|
|
316
|
-
})
|
|
317
|
-
if (props.columnsType.includes('second'))
|
|
318
|
-
data.columns.push(seconds) //生成秒钟列
|
|
319
|
-
|
|
320
|
-
// 设置选中的年月日时分秒
|
|
321
|
-
let selectedValues = [Y, M, D, h, m, s]
|
|
322
|
-
data.selectedValues = selectedValues.splice(0, props.columnsType.length)
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
//时间选择器关闭 值不改变并关闭弹框
|
|
326
|
-
function onClose() {
|
|
327
|
-
isShow.value = false
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
// 时间选择器确定 值改变
|
|
331
|
-
function onConfirm({ selectedValues }) {
|
|
332
|
-
let endval = formatSelectTime()
|
|
333
|
-
isShow.value = false
|
|
334
|
-
|
|
335
|
-
console.log(endval)
|
|
336
|
-
emit("update:modelValue", endval);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function onCancel(){
|
|
340
|
-
isShow.value = false
|
|
341
|
-
}
|
|
342
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 弹出层 -->
|
|
3
|
+
<van-popup v-model:show="isShow" position="bottom" round @close="onClose">
|
|
4
|
+
<van-picker ref="picker" title="请选择时间" :columns="data.columns" @change="onChange" @cancel="onCancel"
|
|
5
|
+
@confirm="onConfirm" v-model="data.selectedValues" />
|
|
6
|
+
</van-popup>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
<script setup>
|
|
11
|
+
import { reactive, watch, getCurrentInstance, computed } from "vue"
|
|
12
|
+
import util from '@/util'
|
|
13
|
+
import { useVModel } from "@vueuse/core"
|
|
14
|
+
import moment from'moment'
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const data = reactive({
|
|
18
|
+
columns: [], //所有时间列
|
|
19
|
+
selectedValues: [] //控件选择的时间值
|
|
20
|
+
})
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
isShow: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
modelValue: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ''
|
|
29
|
+
|
|
30
|
+
}, //时间值
|
|
31
|
+
before: {
|
|
32
|
+
type: Boolean,
|
|
33
|
+
default: false
|
|
34
|
+
},
|
|
35
|
+
//最晚时间
|
|
36
|
+
latest_time: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: ''
|
|
39
|
+
},
|
|
40
|
+
columnsType: {
|
|
41
|
+
type: Array,
|
|
42
|
+
default: ['year', 'month', 'day', 'hour', 'minute', 'second']
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
//定义要向父组件传递的事件
|
|
46
|
+
const emit = defineEmits(['update:modelValue', 'update:isShow'])
|
|
47
|
+
const isShow = useVModel(props, 'isShow', emit)
|
|
48
|
+
|
|
49
|
+
watch(
|
|
50
|
+
() => isShow,
|
|
51
|
+
(n, o) => {
|
|
52
|
+
if (!n)
|
|
53
|
+
return
|
|
54
|
+
getcolumns()
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
// 修改年月,更新选项
|
|
62
|
+
watch(
|
|
63
|
+
() => {
|
|
64
|
+
if(props.columnsType.includes('year'))
|
|
65
|
+
return data.selectedValues[0]
|
|
66
|
+
else
|
|
67
|
+
return 0
|
|
68
|
+
},
|
|
69
|
+
(n, o) => {
|
|
70
|
+
if (!n)
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
getcolumns()
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
watch(
|
|
81
|
+
() => {
|
|
82
|
+
if(props.columnsType.includes('month'))
|
|
83
|
+
return data.selectedValues[1]
|
|
84
|
+
else
|
|
85
|
+
return 0
|
|
86
|
+
},
|
|
87
|
+
(n, o) => {
|
|
88
|
+
if (!n)
|
|
89
|
+
return
|
|
90
|
+
|
|
91
|
+
getcolumns()
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
watch(
|
|
99
|
+
() => {
|
|
100
|
+
if(props.columnsType.includes('day'))
|
|
101
|
+
return data.selectedValues[2]
|
|
102
|
+
else
|
|
103
|
+
return 0
|
|
104
|
+
},
|
|
105
|
+
(n, o) => {
|
|
106
|
+
if (!n)
|
|
107
|
+
return
|
|
108
|
+
|
|
109
|
+
getcolumns()
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
watch(
|
|
117
|
+
() => {
|
|
118
|
+
if(props.columnsType.includes('hour'))
|
|
119
|
+
return data.selectedValues[3]
|
|
120
|
+
else
|
|
121
|
+
return 0
|
|
122
|
+
},
|
|
123
|
+
(n, o) => {
|
|
124
|
+
if (!n)
|
|
125
|
+
return
|
|
126
|
+
|
|
127
|
+
getcolumns()
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
watch(
|
|
135
|
+
() => {
|
|
136
|
+
if(props.columnsType.includes('minute'))
|
|
137
|
+
return data.selectedValues[4]
|
|
138
|
+
else
|
|
139
|
+
return 0
|
|
140
|
+
},
|
|
141
|
+
(n, o) => {
|
|
142
|
+
if (!n)
|
|
143
|
+
return
|
|
144
|
+
|
|
145
|
+
getcolumns()
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
watch(
|
|
153
|
+
() => props.latest_time,
|
|
154
|
+
(n, o) => {
|
|
155
|
+
if (!n)
|
|
156
|
+
return
|
|
157
|
+
|
|
158
|
+
getcolumns()
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
immediate: true//立即监听--进入就会执行一次 监听显影状态
|
|
162
|
+
}
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
function onChange() {
|
|
167
|
+
// 无用的方法
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function formatSelectTime() {
|
|
171
|
+
let res = data.selectedValues[0] +
|
|
172
|
+
"-" +
|
|
173
|
+
util.pad0(data.selectedValues[1]) +
|
|
174
|
+
"-" +
|
|
175
|
+
util.pad0(data.selectedValues[2]) +
|
|
176
|
+
" "
|
|
177
|
+
|
|
178
|
+
if(props.columnsType.includes('hour'))
|
|
179
|
+
res += util.pad0(data.selectedValues[3])
|
|
180
|
+
else
|
|
181
|
+
res += '00'
|
|
182
|
+
|
|
183
|
+
if(props.columnsType.includes('minute'))
|
|
184
|
+
res +=':'+ util.pad0(data.selectedValues[4])
|
|
185
|
+
else
|
|
186
|
+
res += ':00'
|
|
187
|
+
|
|
188
|
+
if(props.columnsType.includes('second'))
|
|
189
|
+
res +=':'+ util.pad0(data.selectedValues[5])
|
|
190
|
+
else
|
|
191
|
+
res += ':00'
|
|
192
|
+
|
|
193
|
+
return res
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 根据选取时间,计算时间元素的取值范围
|
|
197
|
+
function getcolumns() {
|
|
198
|
+
// 清除旧的取值范围
|
|
199
|
+
data.columns = []
|
|
200
|
+
let strtime = ''
|
|
201
|
+
// 根据当先选取的时间计算年月日时分秒取值范围
|
|
202
|
+
if (data.selectedValues.length > 0) {
|
|
203
|
+
strtime = formatSelectTime()
|
|
204
|
+
|
|
205
|
+
//无效日期时,将日改为1号
|
|
206
|
+
if (!util.isValidDatetime(strtime)) {
|
|
207
|
+
data.selectedValues[2] = 1
|
|
208
|
+
strtime = formatSelectTime()
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 开始没有选取的时间时,取父组件传入的时间
|
|
213
|
+
if (!strtime && props.modelValue) {
|
|
214
|
+
strtime = props.modelValue
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 传入时间为空时,取当前时间
|
|
218
|
+
if (!strtime) {
|
|
219
|
+
strtime = util.date2yyyyMMddhhmmss(new Date()) //传入的时间
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 获取选取时间的 年 月 日 时 分 秒
|
|
223
|
+
let dateVaules = new Date(moment(strtime))
|
|
224
|
+
let Y = dateVaules.getFullYear()
|
|
225
|
+
let M = dateVaules.getMonth()+1
|
|
226
|
+
let D = dateVaules.getDate()
|
|
227
|
+
let h = dateVaules.getHours()
|
|
228
|
+
let m = dateVaules.getMinutes()
|
|
229
|
+
let s = dateVaules.getSeconds()
|
|
230
|
+
|
|
231
|
+
let currentYear = new Date().getFullYear()
|
|
232
|
+
let beginYear = currentYear - 3
|
|
233
|
+
let endYear = currentYear + 3
|
|
234
|
+
let earliest_time = new Date(moment(`${beginYear}-01-01 00:00:00`))
|
|
235
|
+
let latest_time = new Date(moment(`${endYear}-12-31 23:59:59`))
|
|
236
|
+
|
|
237
|
+
if(props.before)
|
|
238
|
+
latest_time = new Date()
|
|
239
|
+
|
|
240
|
+
if(props.latest_time && (new Date(moment(props.latest_time)).getTime() < latest_time.getTime())){
|
|
241
|
+
latest_time = new Date(moment(props.latest_time))
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
endYear = latest_time.getFullYear()
|
|
245
|
+
|
|
246
|
+
let years = []; //获取后十年数组
|
|
247
|
+
years = Array.apply(null, {length:endYear-beginYear+1}).map((item,idx)=>{
|
|
248
|
+
return {
|
|
249
|
+
text: beginYear+idx,
|
|
250
|
+
value: beginYear+idx
|
|
251
|
+
}
|
|
252
|
+
})
|
|
253
|
+
if (props.columnsType.includes('year'))
|
|
254
|
+
data.columns.push(years) //生成年列
|
|
255
|
+
|
|
256
|
+
let total_month = 12
|
|
257
|
+
if(Y == latest_time.getFullYear())
|
|
258
|
+
total_month = latest_time.getMonth()+1
|
|
259
|
+
let months = [] //获取12月数组
|
|
260
|
+
months = Array.apply(null, { length: total_month }).map(function (item,idx) {
|
|
261
|
+
return {
|
|
262
|
+
text: idx+1,
|
|
263
|
+
value: idx+1
|
|
264
|
+
}
|
|
265
|
+
})
|
|
266
|
+
if (props.columnsType.includes('month'))
|
|
267
|
+
data.columns.push(months) //生成月列
|
|
268
|
+
|
|
269
|
+
//获取当月的天数
|
|
270
|
+
let total_day = util.YYYYMM2max_day(Y, M)
|
|
271
|
+
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1))
|
|
272
|
+
total_day = latest_time.getDate()
|
|
273
|
+
let days = [] //创建当月天数数组
|
|
274
|
+
days = Array.apply(null, { length: total_day }).map((item,idx)=>{
|
|
275
|
+
return { text: idx + 1, value: idx + 1 }
|
|
276
|
+
})
|
|
277
|
+
if (props.columnsType.includes('day'))
|
|
278
|
+
data.columns.push(days) //生成日列
|
|
279
|
+
|
|
280
|
+
let total_hour = 24
|
|
281
|
+
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1) && D == latest_time.getDate())
|
|
282
|
+
total_hour = latest_time.getHours()
|
|
283
|
+
|
|
284
|
+
let hours = [] //创建小时数组
|
|
285
|
+
hours =Array.apply(null, { length: total_hour }).map((item,idx)=> {
|
|
286
|
+
return {
|
|
287
|
+
text: idx,
|
|
288
|
+
value: idx
|
|
289
|
+
}
|
|
290
|
+
})
|
|
291
|
+
if (props.columnsType.includes('hour'))
|
|
292
|
+
data.columns.push(hours) //生成小时列
|
|
293
|
+
|
|
294
|
+
let total_minute = 60
|
|
295
|
+
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1) && D == latest_time.getDate() && h == latest_time.getHours())
|
|
296
|
+
total_minute = latest_time.getMinutes()
|
|
297
|
+
let minutes = [] //创建分钟数组
|
|
298
|
+
minutes = Array.apply(null, { length: total_minute }).map((item,idx)=>{
|
|
299
|
+
return{
|
|
300
|
+
text: idx,
|
|
301
|
+
value: idx
|
|
302
|
+
}
|
|
303
|
+
})
|
|
304
|
+
if (props.columnsType.includes('minute'))
|
|
305
|
+
data.columns.push(minutes) //生成分钟列
|
|
306
|
+
|
|
307
|
+
let total_second = 60
|
|
308
|
+
if(Y == latest_time.getFullYear() && M == (latest_time.getMonth()+1) && D == latest_time.getDate() && h == latest_time.getHours() && m == latest_time.getMinutes())
|
|
309
|
+
total_second = latest_time.getSeconds()
|
|
310
|
+
let seconds = []; //创建秒数数组
|
|
311
|
+
seconds = Array.apply(null, { length: total_minute }).map((item,idx)=>{
|
|
312
|
+
return{
|
|
313
|
+
text: idx,
|
|
314
|
+
value: idx
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
if (props.columnsType.includes('second'))
|
|
318
|
+
data.columns.push(seconds) //生成秒钟列
|
|
319
|
+
|
|
320
|
+
// 设置选中的年月日时分秒
|
|
321
|
+
let selectedValues = [Y, M, D, h, m, s]
|
|
322
|
+
data.selectedValues = selectedValues.splice(0, props.columnsType.length)
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
//时间选择器关闭 值不改变并关闭弹框
|
|
326
|
+
function onClose() {
|
|
327
|
+
isShow.value = false
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// 时间选择器确定 值改变
|
|
331
|
+
function onConfirm({ selectedValues }) {
|
|
332
|
+
let endval = formatSelectTime()
|
|
333
|
+
isShow.value = false
|
|
334
|
+
|
|
335
|
+
console.log(endval)
|
|
336
|
+
emit("update:modelValue", endval);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function onCancel(){
|
|
340
|
+
isShow.value = false
|
|
341
|
+
}
|
|
342
|
+
|
|
343
343
|
</script>
|