v-uni-app-ui 1.0.0 → 1.0.2
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/config.js +123 -0
- package/components/layout/v-card/v-card.vue +108 -0
- package/components/layout/v-grid/v-grid.vue +162 -0
- package/components/layout/v-icon-grid/v-icon-grid.vue +195 -0
- package/components/layout/v-infinite-scroll/v-infinite-scroll.vue +172 -0
- package/components/layout/v-list/v-list.vue +43 -0
- package/components/layout/v-row/v-row.vue +142 -0
- package/components/layout/v-waterfall/v-waterfall.vue +79 -0
- package/components/model/compound/v-checkbox-group/v-checkbox-group.vue +96 -0
- package/components/model/compound/v-console/v-console.js +20 -0
- package/components/model/compound/v-console/v-console.vue +299 -0
- package/components/model/compound/v-date-time/v-date-time.vue +261 -0
- package/components/model/compound/v-dialog/v-dialog.vue +178 -0
- package/components/model/compound/v-drum-select-picker/v-drum-select-picker.vue +83 -0
- package/components/model/compound/v-form/v-form.vue +226 -0
- package/components/model/compound/v-form-item/v-form-item.vue +255 -0
- package/components/model/compound/v-image/v-image.vue +357 -0
- package/components/model/compound/v-input-desensitize/v-input-desensitize.vue +101 -0
- package/components/model/compound/v-page/v-page.vue +11 -0
- package/components/model/compound/v-pages/v-pages.vue +141 -0
- package/components/model/compound/v-picker-list/v-picker-list.vue +109 -0
- package/components/model/compound/v-popup/v-popup.vue +151 -0
- package/components/model/compound/v-radio-group/v-radio-group.vue +86 -0
- package/components/model/compound/v-select-picker/v-select-picker.vue +202 -0
- package/components/model/compound/v-series-picker-list/v-series-picker-list.vue +221 -0
- package/components/model/compound/v-series-select-picker/v-series-select-picker.vue +203 -0
- package/components/model/compound/v-switch/v-switch.vue +136 -0
- package/components/model/compound/v-tabs-page/v-tabs-page.vue +138 -0
- package/components/model/native/v-badge/v-badge.vue +143 -0
- package/components/model/native/v-button/v-button.vue +273 -0
- package/components/model/native/v-carousel/v-carousel.vue +138 -0
- package/components/model/native/v-checkbox/v-checkbox.vue +215 -0
- package/components/model/native/v-collapse/v-collapse.vue +190 -0
- package/components/model/native/v-header-navigation-bar/v-header-navigation-bar.vue +92 -0
- package/components/model/native/v-input/v-input.vue +352 -0
- package/components/model/native/v-input-code/v-input-code.vue +146 -0
- package/components/model/native/v-loading/v-loading.vue +206 -0
- package/components/model/native/v-menu/v-menu.vue +222 -0
- package/components/model/native/v-menu-slide/v-menu-slide.vue +364 -0
- package/components/model/native/v-min-loading/v-min-loading.vue +80 -0
- package/components/model/native/v-null/v-null.vue +97 -0
- package/components/model/native/v-overlay/v-overlay.vue +96 -0
- package/components/model/native/v-pull-up-refresh/v-pull-up-refresh.vue +157 -0
- package/components/model/native/v-radio/v-radio.vue +138 -0
- package/components/model/native/v-scroll-list/v-scroll-list.vue +169 -0
- package/components/model/native/v-steps/v-steps.vue +253 -0
- package/components/model/native/v-table/v-table.vue +203 -0
- package/components/model/native/v-tabs/v-tabs.vue +235 -0
- package/components/model/native/v-tag/v-tag.vue +206 -0
- package/components/model/native/v-text/v-text.vue +187 -0
- package/components/model/native/v-text-button/v-text-button.vue +139 -0
- package/components/model/native/v-textarea/v-textarea.vue +178 -0
- package/components/model/native/v-title/v-title.vue +91 -0
- package/components/model/native/v-toast/info.png +0 -0
- package/components/model/native/v-toast/success.png +0 -0
- package/components/model/native/v-toast/v-toast.vue +198 -0
- package/components/model/native/v-toast/warn.png +0 -0
- package/components/model/native/v-upload-file-button/v-upload-file-button.vue +296 -0
- package/components/model/native/v-video/v-video.vue +175 -0
- package/components/model/native/v-window/v-window.vue +158 -0
- package/package.json +18 -94
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
v-if="!visible"
|
|
4
|
+
class="console-toggle"
|
|
5
|
+
:style="{ left: btnPos.x + 'rpx', top: btnPos.y + 'rpx' }"
|
|
6
|
+
@touchstart="onTouchStart"
|
|
7
|
+
@touchmove="onTouchMove"
|
|
8
|
+
@touchend="onTouchEnd"
|
|
9
|
+
@mousedown="onTouchStart"
|
|
10
|
+
@mousemove="onTouchMove"
|
|
11
|
+
@mouseup="onTouchEnd"
|
|
12
|
+
@click="toggle"
|
|
13
|
+
>
|
|
14
|
+
<v-button>控制台</v-button>
|
|
15
|
+
</view>
|
|
16
|
+
<view v-if="visible" class="v-console" :class="{ expanded: expanded }">
|
|
17
|
+
<view class="toolbar">
|
|
18
|
+
<view class="buttons">
|
|
19
|
+
<v-text-button size="medium" @click="toggle">关闭</v-text-button>
|
|
20
|
+
<v-text-button size="medium" @click="toggleExpand">
|
|
21
|
+
{{ expanded ? '收起' : '展开' }}
|
|
22
|
+
</v-text-button>
|
|
23
|
+
<v-text-button size="medium" @click="clear">清空</v-text-button>
|
|
24
|
+
</view>
|
|
25
|
+
<view class="filter">
|
|
26
|
+
<v-input v-model="keyword" placeholder="关键字筛选" class="keyword" @confirm="onKeywordConfirm" />
|
|
27
|
+
<v-select-picker :options="levels" :value="levelIndex" @confirm="onLevelConfirm" class="level" />
|
|
28
|
+
</view>
|
|
29
|
+
</view>
|
|
30
|
+
<scroll-view scroll-y class="list">
|
|
31
|
+
<view v-for="(log, i) in showList" :key="i" :class="'log ' + log.type">
|
|
32
|
+
<text v-if="log.time" class="time">{{ log.time }} {{ log.type }}</text>
|
|
33
|
+
<!-- <v-text :class="['msg', log.type]" :lines="log.blockLines" @longpress="copyLog(log.msg)">{{ log.msg }}</v-text> -->
|
|
34
|
+
<view class="msg" :class="log.type" @longpress="copyLog(log.msg)">
|
|
35
|
+
<v-text :lines="log.blockLines">{{ log.msg }}</v-text>
|
|
36
|
+
</view>
|
|
37
|
+
<v-text-button class="detail-info" @click="log.blockLines == 2 ? (log.blockLines = 999) : (log.blockLines = 2)">
|
|
38
|
+
{{ log.blockLines == 2 ? '详细' : '简略' }}
|
|
39
|
+
</v-text-button>
|
|
40
|
+
</view>
|
|
41
|
+
</scroll-view>
|
|
42
|
+
</view>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script setup>
|
|
46
|
+
import { ref, computed, onMounted } from 'vue';
|
|
47
|
+
|
|
48
|
+
const STORAGE_KEY = 'v-console-logs';
|
|
49
|
+
const visible = ref(false);
|
|
50
|
+
const toggle = () => (visible.value = !visible.value);
|
|
51
|
+
|
|
52
|
+
const expanded = ref(false);
|
|
53
|
+
const toggleExpand = () => (expanded.value = !expanded.value);
|
|
54
|
+
|
|
55
|
+
const logs = ref([]);
|
|
56
|
+
const keyword = ref('');
|
|
57
|
+
const levelIndex = ref(0);
|
|
58
|
+
const levels = [
|
|
59
|
+
{ label: '全部', value: 0 },
|
|
60
|
+
{ label: 'log', value: 1 },
|
|
61
|
+
{ label: 'info', value: 2 },
|
|
62
|
+
{ label: 'warn', value: 3 },
|
|
63
|
+
{ label: 'error', value: 4 },
|
|
64
|
+
{ label: 'debug', value: 5 }
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const btnPos = ref({ x: 30, y: 100 });
|
|
68
|
+
const dragging = ref(false);
|
|
69
|
+
const startPos = ref({ x: 0, y: 0 });
|
|
70
|
+
|
|
71
|
+
const rpx2px = (rpx) => (rpx * uni.getSystemInfoSync().windowWidth) / 750;
|
|
72
|
+
|
|
73
|
+
onMounted(() => {
|
|
74
|
+
loadLogs();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const getPos = (e) => {
|
|
78
|
+
// #ifdef H5
|
|
79
|
+
return { x: e.clientX, y: e.clientY };
|
|
80
|
+
// #endif
|
|
81
|
+
// #ifndef H5
|
|
82
|
+
const touch = e.touches[0] || e.changedTouches[0];
|
|
83
|
+
return { x: touch.clientX, y: touch.clientY };
|
|
84
|
+
// #endif
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/* 按下 */
|
|
88
|
+
const onTouchStart = (e) => {
|
|
89
|
+
dragging.value = true;
|
|
90
|
+
startPos.value = getPos(e);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
/* 移动 */
|
|
94
|
+
const onTouchMove = (e) => {
|
|
95
|
+
if (!dragging.value) return;
|
|
96
|
+
const { windowWidth, windowHeight } = uni.getSystemInfoSync();
|
|
97
|
+
const cur = getPos(e);
|
|
98
|
+
const dx = cur.x - startPos.value.x;
|
|
99
|
+
const dy = cur.y - startPos.value.y;
|
|
100
|
+
|
|
101
|
+
/* 转成 rpx */
|
|
102
|
+
const newX = btnPos.value.x + (dx * 750) / windowWidth;
|
|
103
|
+
const newY = btnPos.value.y + (dy * 750) / windowHeight;
|
|
104
|
+
|
|
105
|
+
/* 边界限制:0~屏幕宽/高 - 按钮宽/高(≈120rpx) */
|
|
106
|
+
btnPos.value.x = Math.max(0, Math.min(newX, (windowWidth * 750) / windowWidth - 120));
|
|
107
|
+
btnPos.value.y = Math.max(0, Math.min(newY, (windowHeight * 750) / windowWidth - 120));
|
|
108
|
+
|
|
109
|
+
startPos.value = cur;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const onTouchEnd = () => (dragging.value = false);
|
|
113
|
+
|
|
114
|
+
if (typeof window !== 'undefined') {
|
|
115
|
+
window.onerror = (msg, url, line, col, error) => {
|
|
116
|
+
console.error('[Global Error]', msg, `${url}:${line}:${col}`, error?.stack);
|
|
117
|
+
};
|
|
118
|
+
window.onunhandledrejection = (e) => {
|
|
119
|
+
console.error('[Unhandled Promise]', e.reason);
|
|
120
|
+
};
|
|
121
|
+
} else {
|
|
122
|
+
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-QQ
|
|
123
|
+
wx.onError?.((res) => console.error('[wx Error]', res));
|
|
124
|
+
wx.onUnhandledRejection?.((res) => console.error('[wx Promise]', res.reason));
|
|
125
|
+
// #endif
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
['log', 'info', 'warn', 'error', 'debug'].forEach((type) => {
|
|
130
|
+
const origin = console[type];
|
|
131
|
+
console[type] = (...args) => {
|
|
132
|
+
origin.apply(console, args);
|
|
133
|
+
const time = new Date().toLocaleTimeString();
|
|
134
|
+
const msg = args.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v))).join(' ');
|
|
135
|
+
const newLog = { type, msg, time, blockLines: 2 };
|
|
136
|
+
logs.value.unshift(newLog);
|
|
137
|
+
saveLogs();
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const showList = computed(() => {
|
|
142
|
+
let list = logs.value;
|
|
143
|
+
if (levelIndex.value) {
|
|
144
|
+
list = list.filter((l) => l.type === levels[levelIndex.value].label.toLowerCase());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (keyword.value.trim()) {
|
|
148
|
+
const k = keyword.value.trim().toLowerCase();
|
|
149
|
+
list = list.filter((l) => l.msg.toLowerCase().includes(k));
|
|
150
|
+
}
|
|
151
|
+
list.blockLines = 2;
|
|
152
|
+
return list;
|
|
153
|
+
});
|
|
154
|
+
const saveLogs = () => {
|
|
155
|
+
try {
|
|
156
|
+
// #ifdef H5
|
|
157
|
+
sessionStorage.setItem(STORAGE_KEY, JSON.stringify(logs.value));
|
|
158
|
+
// #endif
|
|
159
|
+
// #ifndef H5
|
|
160
|
+
uni.setStorageSync(STORAGE_KEY, logs.value);
|
|
161
|
+
// #endif
|
|
162
|
+
} catch (_) {}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const loadLogs = () => {
|
|
166
|
+
try {
|
|
167
|
+
let data = null;
|
|
168
|
+
// #ifdef H5
|
|
169
|
+
data = JSON.parse(sessionStorage.getItem(STORAGE_KEY) || '[]');
|
|
170
|
+
// #endif
|
|
171
|
+
// #ifndef H5
|
|
172
|
+
data = uni.getStorageSync(STORAGE_KEY) || [];
|
|
173
|
+
// #endif
|
|
174
|
+
logs.value = data;
|
|
175
|
+
} catch (_) {}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
const clear = () => {
|
|
179
|
+
logs.value = [];
|
|
180
|
+
try {
|
|
181
|
+
// #ifdef H5
|
|
182
|
+
sessionStorage.removeItem(STORAGE_KEY);
|
|
183
|
+
// #endif
|
|
184
|
+
// #ifndef H5
|
|
185
|
+
uni.removeStorageSync(STORAGE_KEY);
|
|
186
|
+
// #endif
|
|
187
|
+
} catch (_) {}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const copyLog = (msg) => {
|
|
191
|
+
// #ifdef H5
|
|
192
|
+
const input = document.createElement('textarea');
|
|
193
|
+
input.value = msg;
|
|
194
|
+
document.body.appendChild(input);
|
|
195
|
+
input.select();
|
|
196
|
+
document.execCommand('copy');
|
|
197
|
+
document.body.removeChild(input);
|
|
198
|
+
uni.showToast({ title: '已复制', icon: 'none' });
|
|
199
|
+
// #endif
|
|
200
|
+
// #ifndef H5
|
|
201
|
+
uni.setClipboardData({ data: msg, showToast: false });
|
|
202
|
+
uni.showToast({ title: '已复制', icon: 'none' });
|
|
203
|
+
// #endif
|
|
204
|
+
};
|
|
205
|
+
const onKeywordConfirm = (e) => {
|
|
206
|
+
console.log(e);
|
|
207
|
+
keyword.value = e;
|
|
208
|
+
};
|
|
209
|
+
const onLevelConfirm = (e) => {
|
|
210
|
+
levelIndex.value = e;
|
|
211
|
+
};
|
|
212
|
+
</script>
|
|
213
|
+
|
|
214
|
+
<style lang="scss" scoped>
|
|
215
|
+
/* 悬浮开关按钮(黑底白字) */
|
|
216
|
+
.console-toggle {
|
|
217
|
+
position: fixed;
|
|
218
|
+
right: 30rpx;
|
|
219
|
+
bottom: 100rpx;
|
|
220
|
+
z-index: 10000;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/* 控制台主体:白底黑字 */
|
|
224
|
+
.v-console {
|
|
225
|
+
position: fixed;
|
|
226
|
+
left: 0;
|
|
227
|
+
right: 0;
|
|
228
|
+
bottom: 0;
|
|
229
|
+
z-index: 9999;
|
|
230
|
+
background: #fff;
|
|
231
|
+
color: #000;
|
|
232
|
+
font-family: monospace;
|
|
233
|
+
font-size: 0.75rem;
|
|
234
|
+
height: 120rpx; /* 默认收缩高度 */
|
|
235
|
+
transition: height 0.25s ease;
|
|
236
|
+
border-top: 1rpx solid #e5e5e5;
|
|
237
|
+
|
|
238
|
+
&.expanded {
|
|
239
|
+
height: 50%; /* 展开后高度 */
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.toolbar {
|
|
243
|
+
display: flex;
|
|
244
|
+
padding: 12rpx 24rpx;
|
|
245
|
+
background: #f7f7f7;
|
|
246
|
+
border-bottom: 1rpx solid #e5e5e5;
|
|
247
|
+
flex-direction: column;
|
|
248
|
+
.buttons {
|
|
249
|
+
display: flex;
|
|
250
|
+
}
|
|
251
|
+
.filter {
|
|
252
|
+
display: flex;
|
|
253
|
+
.keyword {
|
|
254
|
+
flex: 1;
|
|
255
|
+
margin-right: 20rpx;
|
|
256
|
+
}
|
|
257
|
+
.level {
|
|
258
|
+
width: 200rpx;
|
|
259
|
+
:deep(.select-input) {
|
|
260
|
+
height: 60rpx;
|
|
261
|
+
line-height: 60rpx;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.list {
|
|
268
|
+
height: calc(100% - 100rpx);
|
|
269
|
+
padding: 16rpx;
|
|
270
|
+
.log {
|
|
271
|
+
display: flex;
|
|
272
|
+
line-height: 1.4;
|
|
273
|
+
margin-bottom: 8rpx;
|
|
274
|
+
.time {
|
|
275
|
+
margin-right: 12rpx;
|
|
276
|
+
color: #666;
|
|
277
|
+
}
|
|
278
|
+
.msg {
|
|
279
|
+
width: 50%;
|
|
280
|
+
&.log {
|
|
281
|
+
color: #008000;
|
|
282
|
+
}
|
|
283
|
+
&.info {
|
|
284
|
+
color: #0066cc;
|
|
285
|
+
}
|
|
286
|
+
&.warn {
|
|
287
|
+
color: #ff6600;
|
|
288
|
+
}
|
|
289
|
+
&.error {
|
|
290
|
+
color: #cc0000;
|
|
291
|
+
}
|
|
292
|
+
&.debug {
|
|
293
|
+
color: #666;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
</style>
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-popup v-model:value="isPopupVisible" :title="title" :scrollHeight="scrollHeight" model="semicircle" @close="handleClose" @confirm="handleConfirm">
|
|
3
|
+
<view class="drum-select-container">
|
|
4
|
+
<view class="drum-select-content">
|
|
5
|
+
<v-scroll-list
|
|
6
|
+
:value="value.getFullYear()"
|
|
7
|
+
:options="generateYearRange(props.maxDateTime.getFullYear(), props.minDateTime.getFullYear())"
|
|
8
|
+
:scrollHeight="scrollHeight"
|
|
9
|
+
@update:value="handleValueChangeYear($event)"
|
|
10
|
+
/>
|
|
11
|
+
<v-text class="separate-symbol">:</v-text>
|
|
12
|
+
<v-scroll-list
|
|
13
|
+
:value="value.getMonth() + 1"
|
|
14
|
+
:options="generateMonthRange(props.maxDateTime.getMonth(), props.minDateTime.getMonth())"
|
|
15
|
+
:scrollHeight="scrollHeight"
|
|
16
|
+
@update:value="handleValueChangeMonth($event)"
|
|
17
|
+
/>
|
|
18
|
+
<v-text class="separate-symbol">:</v-text>
|
|
19
|
+
<v-scroll-list
|
|
20
|
+
:value="value.getDate()"
|
|
21
|
+
:options="generateDateRange(props.maxDateTime.getDate(), props.minDateTime.getDate())"
|
|
22
|
+
:scrollHeight="scrollHeight"
|
|
23
|
+
@update:value="handleValueChangeDate($event)"
|
|
24
|
+
/>
|
|
25
|
+
<v-text class="separate-symbol">:</v-text>
|
|
26
|
+
<v-scroll-list
|
|
27
|
+
:value="hoursSystem ? value.getHours() || 24 : value.getHours() % 12 || 12"
|
|
28
|
+
:options="generateHoursRange(props.maxDateTime.getHours(), props.minDateTime.getHours())"
|
|
29
|
+
:scrollHeight="scrollHeight"
|
|
30
|
+
@update:value="handleValueChangeHours($event)"
|
|
31
|
+
/>
|
|
32
|
+
<v-text class="separate-symbol">:</v-text>
|
|
33
|
+
<v-scroll-list
|
|
34
|
+
:value="value.getMinutes()"
|
|
35
|
+
:options="generateMinutesRange(props.maxDateTime.getMinutes(), props.minDateTime.getMinutes())"
|
|
36
|
+
:scrollHeight="scrollHeight"
|
|
37
|
+
@update:value="handleValueChangeMinutes($event)"
|
|
38
|
+
/>
|
|
39
|
+
<v-text class="separate-symbol">:</v-text>
|
|
40
|
+
<v-scroll-list
|
|
41
|
+
:value="value.getSeconds()"
|
|
42
|
+
:options="generateSecondsRange(props.maxDateTime.getSeconds(), props.minDateTime.getSeconds())"
|
|
43
|
+
:scrollHeight="scrollHeight"
|
|
44
|
+
@update:value="handleValueChangeSeconds($event)"
|
|
45
|
+
/>
|
|
46
|
+
</view>
|
|
47
|
+
</view>
|
|
48
|
+
</v-popup>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script lang="ts" setup>
|
|
52
|
+
import { ref, computed, watch, inject } from 'vue';
|
|
53
|
+
|
|
54
|
+
interface DrumSelectPicker {
|
|
55
|
+
value: any;
|
|
56
|
+
label: string;
|
|
57
|
+
children?: DrumSelectPicker[];
|
|
58
|
+
}
|
|
59
|
+
const props = defineProps({
|
|
60
|
+
title: {
|
|
61
|
+
type: String,
|
|
62
|
+
default: '',
|
|
63
|
+
required: true
|
|
64
|
+
},
|
|
65
|
+
scrollHeight: {
|
|
66
|
+
type: Number,
|
|
67
|
+
default: 400
|
|
68
|
+
},
|
|
69
|
+
value: {
|
|
70
|
+
type: Date,
|
|
71
|
+
default: new Date(),
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
show: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: true
|
|
77
|
+
},
|
|
78
|
+
minDateTime: {
|
|
79
|
+
type: Date,
|
|
80
|
+
default: new Date('1000-1-1'),
|
|
81
|
+
required: true
|
|
82
|
+
},
|
|
83
|
+
maxDateTime: {
|
|
84
|
+
type: Date,
|
|
85
|
+
default: new Date('9999-12-31'),
|
|
86
|
+
required: true
|
|
87
|
+
},
|
|
88
|
+
hoursSystem: {
|
|
89
|
+
type: Boolean,
|
|
90
|
+
default: false
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const emit = defineEmits([
|
|
95
|
+
'update:value',
|
|
96
|
+
'handleValueChangeYear',
|
|
97
|
+
'handleValueChangeMonth',
|
|
98
|
+
'handleValueChangeDate',
|
|
99
|
+
'handleValueChangeHours',
|
|
100
|
+
'handleValueChangeMinutes',
|
|
101
|
+
'handleValueChangeSeconds',
|
|
102
|
+
'close',
|
|
103
|
+
'confirm',
|
|
104
|
+
'update:show'
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
const isPopupVisible = ref(props.show);
|
|
108
|
+
const config = inject<any>('config');
|
|
109
|
+
function generateYearRange(maxYear: any, minYear: any) {
|
|
110
|
+
const yearRange = [];
|
|
111
|
+
for (let year = maxYear; year >= minYear; year--) {
|
|
112
|
+
yearRange.push({
|
|
113
|
+
value: year,
|
|
114
|
+
label: `${year}`
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return yearRange;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function generateMonthRange(maxMonth: any, minMonth: any) {
|
|
121
|
+
const monthRange = [];
|
|
122
|
+
for (let month = maxMonth + 1; month > minMonth; month--) {
|
|
123
|
+
monthRange.push({
|
|
124
|
+
value: month,
|
|
125
|
+
label: `${month}`
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return monthRange;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function generateDateRange(maxDate: any, minDate: any) {
|
|
132
|
+
const dayRange = [];
|
|
133
|
+
const daysInMonth = new Date(props.value.getFullYear(), props.value.getMonth() + 1, 0).getDate();
|
|
134
|
+
const actualMaxDate = Math.min(maxDate, daysInMonth);
|
|
135
|
+
for (let day = actualMaxDate; day >= minDate; day--) {
|
|
136
|
+
dayRange.push({
|
|
137
|
+
value: day,
|
|
138
|
+
label: `${day}`
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return dayRange;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function generateHoursRange() {
|
|
145
|
+
const hoursRange = [];
|
|
146
|
+
if (props.hoursSystem) {
|
|
147
|
+
// 24小时制
|
|
148
|
+
for (let hour = 24; hour > 0; hour--) {
|
|
149
|
+
hoursRange.push({
|
|
150
|
+
value: hour,
|
|
151
|
+
label: `${hour}`
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
// 12小时制
|
|
156
|
+
for (let hour = 12; hour >= 1; hour--) {
|
|
157
|
+
hoursRange.push({
|
|
158
|
+
value: hour,
|
|
159
|
+
label: `${hour}`
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return hoursRange;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function generateMinutesRange() {
|
|
167
|
+
const minutesRange = [];
|
|
168
|
+
for (let minute = 60; minute > 0; minute--) {
|
|
169
|
+
minutesRange.push({
|
|
170
|
+
value: minute,
|
|
171
|
+
label: `${minute < 10 ? '0' + minute : minute}`
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
return minutesRange;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function generateSecondsRange() {
|
|
178
|
+
const secondsRange = [];
|
|
179
|
+
for (let second = 60; second > 0; second--) {
|
|
180
|
+
secondsRange.push({
|
|
181
|
+
value: second,
|
|
182
|
+
label: `${second < 10 ? '0' + second : second}`
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return secondsRange;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const handleValueChangeYear = (year: number) => {
|
|
189
|
+
props.value.setFullYear(year);
|
|
190
|
+
emit('handleValueChangeYear', year);
|
|
191
|
+
};
|
|
192
|
+
const handleValueChangeMonth = (month: number) => {
|
|
193
|
+
props.value.setMonth(month);
|
|
194
|
+
emit('handleValueChangeMonth', month);
|
|
195
|
+
};
|
|
196
|
+
const handleValueChangeDate = (date: number) => {
|
|
197
|
+
props.value.setDate(date);
|
|
198
|
+
emit('handleValueChangeDate', date);
|
|
199
|
+
};
|
|
200
|
+
const handleValueChangeHours = (hours: number) => {
|
|
201
|
+
props.value.setHours(hours);
|
|
202
|
+
emit('handleValueChangeHours', hours);
|
|
203
|
+
};
|
|
204
|
+
const handleValueChangeMinutes = (minutes: number) => {
|
|
205
|
+
props.value.setMinutes(minutes);
|
|
206
|
+
emit('handleValueChangeMinutes', minutes);
|
|
207
|
+
};
|
|
208
|
+
const handleValueChangeSeconds = (seconds: number) => {
|
|
209
|
+
props.value.setSeconds(seconds);
|
|
210
|
+
emit('handleValueChangeSeconds', seconds);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
watch(
|
|
214
|
+
() => props.show,
|
|
215
|
+
(val) => {
|
|
216
|
+
isPopupVisible.value = val;
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const handleClose = () => {
|
|
221
|
+
isPopupVisible.value = false;
|
|
222
|
+
emit('update:show', false);
|
|
223
|
+
emit('close', false);
|
|
224
|
+
};
|
|
225
|
+
const handleConfirm = () => {
|
|
226
|
+
isPopupVisible.value = false;
|
|
227
|
+
emit('update:show', false);
|
|
228
|
+
emit('confirm', props.value);
|
|
229
|
+
};
|
|
230
|
+
</script>
|
|
231
|
+
|
|
232
|
+
<style lang="scss" scoped>
|
|
233
|
+
.drum-select-container {
|
|
234
|
+
position: relative;
|
|
235
|
+
width: 100%;
|
|
236
|
+
height: 100%;
|
|
237
|
+
display: flex;
|
|
238
|
+
align-items: center;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.drum-select-content {
|
|
242
|
+
position: relative;
|
|
243
|
+
width: 100%;
|
|
244
|
+
height: 60%;
|
|
245
|
+
overflow: hidden;
|
|
246
|
+
display: flex;
|
|
247
|
+
view {
|
|
248
|
+
flex: 1;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.separate-symbol {
|
|
253
|
+
font-size: v-bind("config.fontSize.mediumText");
|
|
254
|
+
height: 85rpx;
|
|
255
|
+
line-height: 85rpx !important;
|
|
256
|
+
display: block !important;
|
|
257
|
+
background-color: v-bind('config.VDateTime.backgroundColor');
|
|
258
|
+
border-top: 1rpx solid v-bind('config.border.color');
|
|
259
|
+
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
260
|
+
}
|
|
261
|
+
</style>
|