npmapps 1.0.6 → 1.0.7

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.
@@ -1,327 +0,0 @@
1
- <template>
2
- <el-calendar
3
- v-model="value"
4
- :class="[
5
- { 'hide-button-group': !showButtonGroup },
6
- { 'next-or-prev-click': !isNextOrPrevClick },
7
- ]"
8
- :first-day-of-week="7"
9
- >
10
- <template slot="dateCell" slot-scope="{ date, data }">
11
- <div
12
- :class="[
13
- 'calendar-cell',
14
- handleClass(date, data),
15
- { selected: isSelected(data.day) },
16
- ]"
17
- @click="handleDateClick(data)"
18
- >
19
- <div class="date">
20
- {{ parseInt(data.day.split("-")[2]) }}
21
- <span v-if="isToday(data.day)" class="today-mark">今</span>
22
- </div>
23
- <div class="holiday-info">{{ getHolidayInfo(data.day) }}</div>
24
- </div>
25
- </template>
26
- </el-calendar>
27
- </template>
28
-
29
- <script>
30
- /**
31
- * @description 自定义日历组件,基于Element UI的Calendar组件封装
32
- * 支持节假日显示、今日标记、日期选择等功能
33
- *
34
- * @example
35
- * <custom-calendar
36
- * :date="new Date()"
37
- * :holiday="holidayList"
38
- * @date-click="handleDateClick"
39
- * />
40
- */
41
- export default {
42
- data() {
43
- return {
44
- value: this.date,
45
- selectedDate: null,
46
- };
47
- },
48
- props: {
49
- /**
50
- * 日历当前显示的日期
51
- * @type {Date}
52
- * @default new Date()
53
- */
54
- date: {
55
- type: Date,
56
- default: () => new Date(),
57
- },
58
- /**
59
- * 是否显示日历顶部的按钮组(上个月、下个月等)
60
- * @type {Boolean}
61
- * @default true
62
- */
63
- showButtonGroup: {
64
- type: Boolean,
65
- default: true,
66
- },
67
- /**
68
- * 是否显示工作日标记
69
- * @type {Boolean}
70
- * @default true
71
- */
72
- showWorkday: {
73
- type: Boolean,
74
- default: true,
75
- },
76
- /**
77
- * 节假日数据数组
78
- * @type {Array<{date: string, type: string, name: string, lunarDate: string}>}
79
- * @default []
80
- */
81
- holiday: {
82
- type: Array,
83
- default: () => [],
84
- },
85
- /**
86
- * 是否允许点击日期
87
- * @type {Boolean}
88
- * @default true
89
- */
90
- clickable: {
91
- type: Boolean,
92
- default: true,
93
- },
94
- /**
95
- * 是否显示今日标记
96
- * @type {Boolean}
97
- * @default true
98
- */
99
- showToday: {
100
- type: Boolean,
101
- default: true,
102
- },
103
-
104
- isNextOrPrevClick: {
105
- type: Boolean,
106
- default: false,
107
- },
108
- },
109
- methods: {
110
- /**
111
- * 处理日期单元格的样式类
112
- * @param {Date} date - 日期对象
113
- * @param {Object} data - 日期数据对象
114
- * @returns {string} 样式类名
115
- */
116
- handleClass(date, data) {
117
- let classes = [];
118
- const d = this.holiday.find((item) => item.date === data.day);
119
- if (d) {
120
- classes.push(d.type);
121
- }
122
- if (this.showToday && this.isToday(data.day)) {
123
- classes.push("is-today");
124
- }
125
- return classes.join(" ");
126
- },
127
- /**
128
- * 获取农历日期
129
- * @param {string} day - 日期字符串 (YYYY-MM-DD)
130
- * @returns {string} 农历日期
131
- */
132
- getLunarDate(day) {
133
- const d = this.holiday.find((item) => item.date === day);
134
- return d ? d.lunarDate : "";
135
- },
136
- /**
137
- * 获取节假日信息
138
- * @param {string} day - 日期字符串 (YYYY-MM-DD)
139
- * @returns {string} 节假日名称或工作日标记
140
- */
141
- getHolidayInfo(day) {
142
- const d = this.holiday.find((item) => item.date === day);
143
- if (d) {
144
- return d.name;
145
- }
146
- return this.showWorkday ? "班" : "";
147
- },
148
- /**
149
- * 处理日期点击事件
150
- * @param {string} day - 日期字符串 (YYYY-MM-DD)
151
- * @fires date-click
152
- */
153
- handleDateClick(data) {
154
- if (!this.clickable) return;
155
- this.selectedDate = data.day;
156
- this.$emit("date-click", data);
157
- },
158
- /**
159
- * 判断日期是否被选中
160
- * @param {string} day - 日期字符串 (YYYY-MM-DD)
161
- * @returns {boolean} 是否选中
162
- */
163
- isSelected(day) {
164
- return this.selectedDate === day;
165
- },
166
- /**
167
- * 判断是否为今天
168
- * @param {string} day - 日期字符串 (YYYY-MM-DD)
169
- * @returns {boolean} 是否为今天
170
- */
171
- isToday(day) {
172
- const today = new Date();
173
- const year = today.getFullYear();
174
- const month = String(today.getMonth() + 1).padStart(2, "0");
175
- const date = String(today.getDate()).padStart(2, "0");
176
- const todayStr = `${year}-${month}-${date}`;
177
- return day === todayStr;
178
- },
179
- },
180
- computed: {},
181
- mounted() {},
182
- };
183
- </script>
184
-
185
- <style scoped>
186
- .next-or-prev-click :deep(.el-calendar-table__row td.prev) {
187
- pointer-events: none;
188
- }
189
- .next-or-prev-click :deep(.el-calendar-table__row td.next) {
190
- pointer-events: none;
191
- }
192
-
193
- /* 隐藏日历顶部按钮组 */
194
- .hide-button-group :deep(.el-calendar__button-group) {
195
- display: none;
196
- }
197
- /* 日历单元格基础样式 */
198
- :deep(.el-calendar-day) {
199
- height: 60px;
200
- padding: 2px;
201
- }
202
- :deep(.el-calendar-day) /* 日历单元格容器样式 */
203
- .calendar-cell {
204
- height: 100%;
205
- display: flex;
206
- flex-direction: column;
207
- align-items: center;
208
- justify-content: space-between;
209
- box-sizing: border-box;
210
- padding: 2px !important;
211
- }
212
- /* 日期数字样式 */
213
- .calendar-cell .date {
214
- font-size: 16px;
215
- font-weight: bold;
216
- transition: transform 0.3s ease;
217
- display: flex;
218
- align-items: center;
219
- justify-content: center;
220
- gap: 2px;
221
- }
222
-
223
- /* 今日标记样式 */
224
- .calendar-cell .today-mark {
225
- font-size: 12px;
226
- color: #409eff;
227
- font-weight: normal;
228
- }
229
- .calendar-cell:hover .date {
230
- transform: scale(1.3);
231
- }
232
- /* 农历日期样式 */
233
- .calendar-cell .lunar-date {
234
- font-size: 12px;
235
- color: #666;
236
- transition: transform 0.3s ease;
237
- }
238
- .calendar-cell:hover .lunar-date {
239
- transform: scale(0.8);
240
- }
241
- /* 节假日信息样式 */
242
- .calendar-cell .holiday-info {
243
- font-size: 12px;
244
- margin-top: 2px;
245
- transition: transform 0.3s ease;
246
- }
247
- .calendar-cell:hover .holiday-info {
248
- transform: scale(0.8);
249
- }
250
- /* 日历单元格容器样式 */
251
- .calendar-cell {
252
- transition: all 0.3s ease;
253
- cursor: pointer;
254
- position: relative;
255
- padding: 4px;
256
- }
257
-
258
- /* .calendar-cell:hover::after {
259
- content: attr(data-tooltip);
260
- position: absolute;
261
- bottom: 100%;
262
- left: 50%;
263
- transform: translateX(-50%);
264
- padding: 4px 8px;
265
- background-color: rgba(0, 0, 0, 0.8);
266
- color: white;
267
- border-radius: 4px;
268
- font-size: 12px;
269
- white-space: nowrap;
270
- z-index: 1000;
271
- } */
272
-
273
- /* 节假日背景样式 */
274
- .holiday {
275
- background-color: #e7f5ff;
276
- }
277
-
278
- .holiday:hover {
279
- background-color: #cce7ff;
280
- }
281
-
282
- /* 周末背景样式 */
283
- .weekend {
284
- background-color: #ebfbee;
285
- }
286
-
287
- .weekend:hover {
288
- background-color: #d7f5dc;
289
- }
290
-
291
- /* 选中日期样式 */
292
- .calendar-cell.selected {
293
- background-color: #e7f5ff !important;
294
- /* color: white !important; */
295
- }
296
- /* .calendar-cell.selected .holiday-info {
297
- transform: scale(0.8);
298
- }
299
-
300
- .calendar-cell.selected .date {
301
- transform: scale(1.3);
302
- }
303
-
304
- .calendar-cell.selected .lunar-date {
305
- transform: scale(0.8);
306
- } */
307
-
308
- .calendar-cell.selected .holiday-info {
309
- /* color: white; */
310
- }
311
-
312
- /* 今日单元格样式 */
313
- .calendar-cell.is-today {
314
- background-color: #f4fce3;
315
- /* border: 1px solid #ffa940; */
316
- }
317
-
318
- .calendar-cell.is-today:hover {
319
- background-color: #e9fac8;
320
- }
321
-
322
- /* 覆盖Element UI默认的选中样式 */
323
- :deep(.el-calendar-table td.is-selected) {
324
- background-color: transparent;
325
- color: inherit;
326
- }
327
- </style>
@@ -1,177 +0,0 @@
1
- export const holiday = [
2
- // 春节
3
- {
4
- type: 'holiday',
5
- name: '春节',
6
- date: '2024-02-10',
7
- lunarDate: '正月初一'
8
- },
9
- {
10
- type: 'holiday',
11
- name: '春节',
12
- date: '2024-02-11',
13
- lunarDate: '正月初二'
14
- },
15
- {
16
- type: 'holiday',
17
- name: '春节',
18
- date: '2024-02-12',
19
- lunarDate: '正月初三'
20
- },
21
- // 清明节
22
- {
23
- type: 'holiday',
24
- name: '清明节',
25
- date: '2024-04-04',
26
- lunarDate: '二月廿五'
27
- },
28
- {
29
- type: 'holiday',
30
- name: '清明节',
31
- date: '2024-04-05',
32
- lunarDate: '二月廿六'
33
- },
34
- {
35
- type: 'holiday',
36
- name: '清明节',
37
- date: '2024-04-06',
38
- lunarDate: '二月廿七'
39
- },
40
- // 劳动节
41
- {
42
- type: 'holiday',
43
- name: '劳动节',
44
- date: '2024-05-01',
45
- lunarDate: '三月廿三'
46
- },
47
- {
48
- type: 'holiday',
49
- name: '劳动节',
50
- date: '2024-05-02',
51
- lunarDate: '三月廿四'
52
- },
53
- {
54
- type: 'holiday',
55
- name: '劳动节',
56
- date: '2024-05-03',
57
- lunarDate: '三月廿五'
58
- },
59
- {
60
- type: 'holiday',
61
- name: '劳动节',
62
- date: '2024-05-04',
63
- lunarDate: '三月廿六'
64
- },
65
- {
66
- type: 'holiday',
67
- name: '劳动节',
68
- date: '2024-05-05',
69
- lunarDate: '三月廿七'
70
- },
71
- // 端午节
72
- {
73
- type: 'holiday',
74
- name: '端午节',
75
- date: '2024-06-10',
76
- lunarDate: '五月初三'
77
- },
78
- // 中秋节
79
- {
80
- type: 'holiday',
81
- name: '中秋节',
82
- date: '2024-09-15',
83
- lunarDate: '八月初二'
84
- },
85
- {
86
- type: 'holiday',
87
- name: '中秋节',
88
- date: '2024-09-16',
89
- lunarDate: '八月初三'
90
- },
91
- {
92
- type: 'holiday',
93
- name: '中秋节',
94
- date: '2024-09-17',
95
- lunarDate: '八月初四'
96
- },
97
- // 国庆节
98
- {
99
- type: 'holiday',
100
- name: '国庆节',
101
- date: '2024-10-01',
102
- lunarDate: '八月十八'
103
- },
104
- {
105
- type: 'holiday',
106
- name: '国庆节',
107
- date: '2024-10-02',
108
- lunarDate: '八月十九'
109
- },
110
- {
111
- type: 'holiday',
112
- name: '国庆节',
113
- date: '2024-10-03',
114
- lunarDate: '八月二十'
115
- },
116
- {
117
- type: 'holiday',
118
- name: '国庆节',
119
- date: '2024-10-04',
120
- lunarDate: '八月廿一'
121
- },
122
- {
123
- type: 'holiday',
124
- name: '国庆节',
125
- date: '2024-10-05',
126
- lunarDate: '八月廿二'
127
- },
128
- {
129
- type: 'holiday',
130
- name: '国庆节',
131
- date: '2024-10-06',
132
- lunarDate: '八月廿三'
133
- },
134
- {
135
- type: 'holiday',
136
- name: '国庆节',
137
- date: '2024-10-07',
138
- lunarDate: '八月廿四'
139
- },
140
- // 普通周末
141
- {
142
- type: 'weekend',
143
- name: '周末',
144
- date: '2024-01-06',
145
- lunarDate: '十一月廿五'
146
- },
147
- {
148
- type: 'weekend',
149
- name: '周末',
150
- date: '2024-01-07',
151
- lunarDate: '十一月廿六'
152
- },
153
- {
154
- type: 'weekend',
155
- name: '周末',
156
- date: '2024-01-13',
157
- lunarDate: '十二月初二'
158
- },
159
- {
160
- type: 'weekend',
161
- name: '周末',
162
- date: '2024-01-14',
163
- lunarDate: '十二月初三'
164
- },
165
- {
166
- type: 'weekend',
167
- name: '周末',
168
- date: '2024-01-20',
169
- lunarDate: '十二月初九'
170
- },
171
- {
172
- type: 'weekend',
173
- name: '周末',
174
- date: '2024-01-21',
175
- lunarDate: '十二月初十'
176
- }
177
- ]
@@ -1,116 +0,0 @@
1
- <template>
2
- <div class="calendar-container" style="margin-left: 120px;">
3
- <div class="control-panel">
4
-
5
- <el-date-picker v-model="year" type="year" placeholder="选择年" class="year-picker">
6
- </el-date-picker>
7
- <el-switch v-model="showButtonGroup" active-text="显示按钮组" inactive-text="隐藏按钮组" class="control-item"></el-switch>
8
- <el-switch v-model="showWorkday" active-text="显示工作日" inactive-text="隐藏工作日" class="control-item"></el-switch>
9
- <el-switch v-model="clickable" active-text="允许点击" inactive-text="禁止点击" class="control-item"></el-switch>
10
- <!-- <el-switch v-model="showToday" active-text="显示今日标记" inactive-text="隐藏今日标记" class="control-item"></el-switch> -->
11
- <el-switch v-model="isNextOrPrevClick" active-text="隔月点击时间" inactive-text="不可隔月点击时间" class="control-item"></el-switch>
12
- </div>
13
- <div :key="year+''" class="calendar-grid">
14
- <div v-for="(item, index) in calendarDate" :key="index" class="calendar-item">
15
- <customCalendar
16
- @date-click="dataClick"
17
- :holiday="holiday"
18
- :date="item.date"
19
- :showButtonGroup="showButtonGroup"
20
- :showWorkday="showWorkday"
21
- :clickable="clickable"
22
- :showToday="showToday"
23
- :isNextOrPrevClick="isNextOrPrevClick"
24
- />
25
- </div>
26
- </div>
27
- </div>
28
- </template>
29
-
30
- <style scoped>
31
- .calendar-container {
32
- padding: 20px;
33
- }
34
-
35
- .year-picker {
36
- margin-bottom: 20px;
37
- }
38
-
39
- .control-panel {
40
- display: flex;
41
- flex-wrap: wrap;
42
- gap: 20px;
43
- margin-bottom: 20px;
44
- }
45
-
46
- .control-item {
47
- flex: 1;
48
- min-width: 200px;
49
- }
50
-
51
- .calendar-grid {
52
- display: grid;
53
- grid-template-columns: repeat(auto-fill, minmax(300px, 440px));
54
- gap: 10px;
55
- justify-content: space-between;
56
- }
57
-
58
- .calendar-item {
59
- width: 100%;
60
- background-color: #fff;
61
- border-radius: 8px;
62
- box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
63
- transition: all 0.3s ease;
64
- padding: 15px;
65
- }
66
-
67
- .calendar-item:hover {
68
- transform: translateY(-5px);
69
- box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
70
- }
71
- </style>
72
- <script>
73
- import customCalendar from "./customCalendar.vue";
74
- import {holiday} from "./data";
75
- export default {
76
- components: {
77
- customCalendar,
78
- },
79
- data() {
80
- return {
81
- year: new Date('2024'),
82
- showButtonGroup: false,
83
- showWorkday: true,
84
- clickable: true,
85
- showToday: true,
86
- isNextOrPrevClick: false,
87
- holiday
88
- };
89
- },
90
- methods: {
91
- dataClick(data) {
92
- console.log(data, "data");
93
- this.$message.success("日期选择成功:" + data.day);
94
- }
95
- },
96
- computed: {
97
- calendarDate: function () {
98
- const selectedYear = this.year.getFullYear();
99
- const list = Array.from({ length: 12 }, (_, index) => {
100
- const month = String(index + 1).padStart(2, "0");
101
- return {
102
- month: month,
103
- date: new Date(`${selectedYear}-${month}-01`),
104
- };
105
- });
106
- console.log(list, "list");
107
-
108
- return list;
109
- },
110
- },
111
- mounted() {
112
-
113
- },
114
-
115
- };
116
- </script>
@@ -1,51 +0,0 @@
1
- <template>
2
- <el-form ref="form" :model="formData" label-width="80px">
3
- <el-form-item label="名称" prop="name">
4
- <el-input
5
- v-model="formData.name"
6
- placeholder="请输入名称"
7
- />
8
- </el-form-item>
9
- <el-form-item label="邮箱" prop="email">
10
- <el-input
11
- v-model="formData.email"
12
- placeholder="请输入邮箱"
13
- />
14
- </el-form-item>
15
- <el-form-item label="描述" prop="description">
16
- <el-input
17
- type="textarea"
18
- v-model="formData.description"
19
- placeholder="请输入描述"
20
- :rows="3"
21
- />
22
- </el-form-item>
23
- </el-form>
24
- </template>
25
-
26
- <script>
27
- export default {
28
- name: 'DialogForm',
29
- data() {
30
- return {
31
- formData: {
32
- name: '',
33
- email: '',
34
- description: ''
35
- }
36
- }
37
- },
38
- methods: {
39
- getFormData() {
40
- return this.formData
41
- },
42
- resetForm() {
43
- this.formData = {
44
- name: '',
45
- email: '',
46
- description: ''
47
- }
48
- }
49
- }
50
- }
51
- </script>