wad-lab 1.1.6 → 1.1.8
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/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/controller/CompanyController.java +88 -74
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/model/Employee.java +73 -73
- package/templates/fullstack-springboot-vue/backend/src/main/java/com/example/company/service/CompanyService.java +90 -60
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +429 -405
- package/templates/fullstack-springboot-vue/frontend/vue-axios-interceptor/src/App.vue +177 -159
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +441 -427
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/stores/companyStore.js +126 -96
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/App.vue +84 -69
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/App.vue +191 -167
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -98
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/DepartmentList.vue +92 -91
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -128
- package/templates/fullstack-springboot-vue/frontend/vue-axios-props-emits/src/components/EmployeeList.vue +95 -94
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +90 -90
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/AddEmployeeView.vue +247 -247
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +296 -273
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +219 -196
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/HomeDashboardView.vue +263 -263
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/App.vue +59 -59
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/components/DataCard.vue +72 -53
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/controller/CompanyController.java +88 -74
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/model/Employee.java +73 -73
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/service/CompanyService.java +90 -60
- package/templates/springboot-course-registration/src/main/java/com/example/coursereg/controller/CourseController.java +46 -42
- package/templates/springboot-course-registration/src/main/java/com/example/coursereg/service/CourseService.java +70 -60
- package/templates/springboot-hospital-api/src/main/java/com/example/hospital/controller/HospitalController.java +54 -50
- package/templates/springboot-hospital-api/src/main/java/com/example/hospital/service/HospitalService.java +65 -54
- package/templates/springboot-library-api/src/main/java/com/example/library/controller/LibraryController.java +57 -51
- package/templates/springboot-library-api/src/main/java/com/example/library/service/LibraryService.java +70 -60
- package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/controller/ItemController.java +45 -41
- package/templates/springboot-mockmvc/src/main/java/com/example/mockmvc/service/ItemService.java +48 -38
- package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-aggregation/src/main/java/com/example/aggregation/service/ItemService.java +48 -38
- package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-aggregation-mockmvc/src/main/java/com/example/aggmockmvc/service/ItemService.java +48 -38
- package/templates/springboot-mongo-crud/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/springboot-mongo-crud/src/main/java/com/example/crud/service/ItemService.java +48 -38
- package/templates/vue-axios/src/App.vue +264 -243
- package/templates/vue-axios/src/services/ItemService.js +27 -21
- package/templates/vue-axios-basic/src/App.vue +24 -0
- package/templates/vue-axios-interceptor/src/App.vue +177 -159
- package/templates/vue-axios-pinia/src/App.vue +14 -0
- package/templates/vue-axios-pinia/src/stores/companyStore.js +126 -96
- package/templates/vue-axios-pinia-props/src/App.vue +84 -69
- package/templates/vue-axios-pinia-props/src/components/DepartmentSection.vue +164 -152
- package/templates/vue-axios-pinia-props/src/components/EmployeeSection.vue +193 -181
- package/templates/vue-axios-pinia-props/src/stores/companyStore.js +126 -35
- package/templates/vue-axios-props-emits/src/App.vue +24 -0
- package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +2 -1
- package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +2 -1
- package/templates/vue-axios-router/src/views/DepartmentView.vue +23 -0
- package/templates/vue-axios-router/src/views/EmployeeView.vue +23 -0
- package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +250 -231
- package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +181 -159
- package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +315 -295
- package/templates/vue-axios-router-pinia/src/stores/companyStore.js +137 -70
- package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +229 -209
- package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +257 -237
- package/templates/vue-axios-router-pinia-props/src/components/EntityTable.vue +106 -92
- package/templates/vue-axios-router-pinia-props/src/stores/companyStore.js +139 -84
- package/templates/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +73 -64
- package/templates/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +76 -67
- package/templates/vue-axios-router-props/src/components/DataCard.vue +72 -53
- package/templates/vue-axios-router-props/src/views/DepartmentPage.vue +89 -77
- package/templates/vue-axios-router-props/src/views/EmployeePage.vue +128 -116
- package/templates/vue-fetch/src/App.vue +285 -259
- package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/vue-router-pinia-springboot/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
- package/templates/vue-router-pinia-springboot/frontend/src/services/ItemService.js +24 -21
- package/templates/vue-router-pinia-springboot/frontend/src/stores/itemStore.js +42 -37
- package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +76 -67
- package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/controller/ItemController.java +45 -41
- package/templates/vue-springboot-mongo-aggregation/backend/src/main/java/com/example/aggregation/service/ItemService.java +45 -35
- package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/controller/ItemController.java +45 -41
- package/templates/vue-springboot-mongo-crud/backend/src/main/java/com/example/crud/service/ItemService.java +45 -35
- package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +158 -149
- package/templates/vue-springboot-mongo-crud/frontend/src/services/ItemService.js +24 -21
|
@@ -1,405 +1,429 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="container">
|
|
3
|
-
<header class="header">
|
|
4
|
-
<h1>Company Directory</h1>
|
|
5
|
-
<p>Vue 3 + Axios Direct CRUD</p>
|
|
6
|
-
</header>
|
|
7
|
-
|
|
8
|
-
<div class="grid">
|
|
9
|
-
<section class="card">
|
|
10
|
-
<h2>Departments</h2>
|
|
11
|
-
|
|
12
|
-
<form @submit.prevent="createDepartment" class="form">
|
|
13
|
-
<div class="form-group">
|
|
14
|
-
<label for="dept-name">Department Name</label>
|
|
15
|
-
<input
|
|
16
|
-
id="dept-name"
|
|
17
|
-
v-model="deptForm.name"
|
|
18
|
-
type="text"
|
|
19
|
-
required
|
|
20
|
-
placeholder="e.g. Engineering"
|
|
21
|
-
/>
|
|
22
|
-
</div>
|
|
23
|
-
<div class="form-group">
|
|
24
|
-
<label for="dept-code">Department Code</label>
|
|
25
|
-
<input
|
|
26
|
-
id="dept-code"
|
|
27
|
-
v-model="deptForm.code"
|
|
28
|
-
type="text"
|
|
29
|
-
required
|
|
30
|
-
placeholder="e.g. ENG"
|
|
31
|
-
/>
|
|
32
|
-
</div>
|
|
33
|
-
<button type="submit" class="btn btn-primary">Add Department</button>
|
|
34
|
-
</form>
|
|
35
|
-
|
|
36
|
-
<div class="table-wrapper">
|
|
37
|
-
<table>
|
|
38
|
-
<thead>
|
|
39
|
-
<tr>
|
|
40
|
-
<th>ID</th>
|
|
41
|
-
<th>Name</th>
|
|
42
|
-
<th>Code</th>
|
|
43
|
-
<th>Action</th>
|
|
44
|
-
</tr>
|
|
45
|
-
</thead>
|
|
46
|
-
<tbody>
|
|
47
|
-
<tr v-if="departments.length === 0">
|
|
48
|
-
<td colspan="4" class="empty">No departments found</td>
|
|
49
|
-
</tr>
|
|
50
|
-
<tr v-for="dept in departments" :key="dept.id">
|
|
51
|
-
<td>{{ dept.id }}</td>
|
|
52
|
-
<td>{{ dept.name }}</td>
|
|
53
|
-
<td><code>{{ dept.code }}</code></td>
|
|
54
|
-
<td>
|
|
55
|
-
<button @click="
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
<option
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
<th>
|
|
117
|
-
<th>
|
|
118
|
-
<th>
|
|
119
|
-
<th>
|
|
120
|
-
<th>
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<td>{{ emp.
|
|
130
|
-
<td>{{ emp.
|
|
131
|
-
<td>{{
|
|
132
|
-
<td
|
|
133
|
-
<td>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
</
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
await
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
empForm.
|
|
217
|
-
empForm.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
.
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
font-size:
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
padding: 8px
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
font-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
.
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
.
|
|
360
|
-
|
|
361
|
-
color: #
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container">
|
|
3
|
+
<header class="header">
|
|
4
|
+
<h1>Company Directory</h1>
|
|
5
|
+
<p>Vue 3 + Axios Direct CRUD</p>
|
|
6
|
+
</header>
|
|
7
|
+
|
|
8
|
+
<div class="grid">
|
|
9
|
+
<section class="card">
|
|
10
|
+
<h2>Departments</h2>
|
|
11
|
+
|
|
12
|
+
<form @submit.prevent="createDepartment" class="form">
|
|
13
|
+
<div class="form-group">
|
|
14
|
+
<label for="dept-name">Department Name</label>
|
|
15
|
+
<input
|
|
16
|
+
id="dept-name"
|
|
17
|
+
v-model="deptForm.name"
|
|
18
|
+
type="text"
|
|
19
|
+
required
|
|
20
|
+
placeholder="e.g. Engineering"
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="form-group">
|
|
24
|
+
<label for="dept-code">Department Code</label>
|
|
25
|
+
<input
|
|
26
|
+
id="dept-code"
|
|
27
|
+
v-model="deptForm.code"
|
|
28
|
+
type="text"
|
|
29
|
+
required
|
|
30
|
+
placeholder="e.g. ENG"
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
<button type="submit" class="btn btn-primary">Add Department</button>
|
|
34
|
+
</form>
|
|
35
|
+
|
|
36
|
+
<div class="table-wrapper">
|
|
37
|
+
<table>
|
|
38
|
+
<thead>
|
|
39
|
+
<tr>
|
|
40
|
+
<th>ID</th>
|
|
41
|
+
<th>Name</th>
|
|
42
|
+
<th>Code</th>
|
|
43
|
+
<th>Action</th>
|
|
44
|
+
</tr>
|
|
45
|
+
</thead>
|
|
46
|
+
<tbody>
|
|
47
|
+
<tr v-if="departments.length === 0">
|
|
48
|
+
<td colspan="4" class="empty">No departments found</td>
|
|
49
|
+
</tr>
|
|
50
|
+
<tr v-for="dept in departments" :key="dept.id">
|
|
51
|
+
<td>{{ dept.id }}</td>
|
|
52
|
+
<td>{{ dept.name }}</td>
|
|
53
|
+
<td><code>{{ dept.code }}</code></td>
|
|
54
|
+
<td>
|
|
55
|
+
<button @click="patchDepartment(dept.id, dept.code)" class="btn">Patch</button>
|
|
56
|
+
<button @click="deleteDepartment(dept.id)" class="btn btn-danger">Delete</button>
|
|
57
|
+
</td>
|
|
58
|
+
</tr>
|
|
59
|
+
</tbody>
|
|
60
|
+
</table>
|
|
61
|
+
</div>
|
|
62
|
+
</section>
|
|
63
|
+
|
|
64
|
+
<section class="card">
|
|
65
|
+
<h2>Employees</h2>
|
|
66
|
+
|
|
67
|
+
<form @submit.prevent="createEmployee" class="form">
|
|
68
|
+
<div class="form-group">
|
|
69
|
+
<label for="emp-name">Full Name</label>
|
|
70
|
+
<input
|
|
71
|
+
id="emp-name"
|
|
72
|
+
v-model="empForm.name"
|
|
73
|
+
type="text"
|
|
74
|
+
required
|
|
75
|
+
placeholder="e.g. Jane Doe"
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
<div class="form-group">
|
|
79
|
+
<label for="emp-email">Email Address</label>
|
|
80
|
+
<input
|
|
81
|
+
id="emp-email"
|
|
82
|
+
v-model="empForm.email"
|
|
83
|
+
type="email"
|
|
84
|
+
required
|
|
85
|
+
placeholder="e.g. jane@example.com"
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
<div class="form-group">
|
|
89
|
+
<label for="emp-dept">Department</label>
|
|
90
|
+
<select id="emp-dept" v-model="empForm.departmentId" required>
|
|
91
|
+
<option value="" disabled>Select Department</option>
|
|
92
|
+
<option v-for="dept in departments" :key="dept.id" :value="dept.id">
|
|
93
|
+
{{ dept.name }} ({{ dept.code }})
|
|
94
|
+
</option>
|
|
95
|
+
</select>
|
|
96
|
+
</div>
|
|
97
|
+
<div class="form-group">
|
|
98
|
+
<label for="emp-salary">Salary</label>
|
|
99
|
+
<input
|
|
100
|
+
id="emp-salary"
|
|
101
|
+
v-model.number="empForm.salary"
|
|
102
|
+
type="number"
|
|
103
|
+
min="0"
|
|
104
|
+
step="any"
|
|
105
|
+
required
|
|
106
|
+
placeholder="e.g. 75000"
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
<button type="submit" class="btn btn-primary">Add Employee</button>
|
|
110
|
+
</form>
|
|
111
|
+
|
|
112
|
+
<div class="table-wrapper">
|
|
113
|
+
<table>
|
|
114
|
+
<thead>
|
|
115
|
+
<tr>
|
|
116
|
+
<th>ID</th>
|
|
117
|
+
<th>Name</th>
|
|
118
|
+
<th>Email</th>
|
|
119
|
+
<th>Department</th>
|
|
120
|
+
<th>Salary</th>
|
|
121
|
+
<th>Action</th>
|
|
122
|
+
</tr>
|
|
123
|
+
</thead>
|
|
124
|
+
<tbody>
|
|
125
|
+
<tr v-if="employees.length === 0">
|
|
126
|
+
<td colspan="6" class="empty">No employees found</td>
|
|
127
|
+
</tr>
|
|
128
|
+
<tr v-for="emp in employees" :key="emp.id">
|
|
129
|
+
<td>{{ emp.id }}</td>
|
|
130
|
+
<td>{{ emp.name }}</td>
|
|
131
|
+
<td>{{ emp.email }}</td>
|
|
132
|
+
<td>{{ getDepartmentName(emp.departmentId) }}</td>
|
|
133
|
+
<td>${{ Number(emp.salary).toLocaleString() }}</td>
|
|
134
|
+
<td>
|
|
135
|
+
<button @click="patchEmployeeSalary(emp.id, emp.salary)" class="btn">Patch</button>
|
|
136
|
+
<button @click="deleteEmployee(emp.id)" class="btn btn-danger">Delete</button>
|
|
137
|
+
</td>
|
|
138
|
+
</tr>
|
|
139
|
+
</tbody>
|
|
140
|
+
</table>
|
|
141
|
+
</div>
|
|
142
|
+
</section>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</template>
|
|
146
|
+
|
|
147
|
+
<script setup>
|
|
148
|
+
import { ref, reactive, onMounted } from 'vue'
|
|
149
|
+
import api from './services/api'
|
|
150
|
+
|
|
151
|
+
const departments = ref([])
|
|
152
|
+
const employees = ref([])
|
|
153
|
+
|
|
154
|
+
const deptForm = reactive({
|
|
155
|
+
name: '',
|
|
156
|
+
code: ''
|
|
157
|
+
})
|
|
158
|
+
|
|
159
|
+
const empForm = reactive({
|
|
160
|
+
name: '',
|
|
161
|
+
email: '',
|
|
162
|
+
departmentId: '',
|
|
163
|
+
salary: ''
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
const fetchDepartments = async () => {
|
|
167
|
+
try {
|
|
168
|
+
const response = await api.get('/departments')
|
|
169
|
+
departments.value = response.data
|
|
170
|
+
} catch (error) {
|
|
171
|
+
console.error(error)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const fetchEmployees = async () => {
|
|
176
|
+
try {
|
|
177
|
+
const response = await api.get('/employees')
|
|
178
|
+
employees.value = response.data
|
|
179
|
+
} catch (error) {
|
|
180
|
+
console.error(error)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const createDepartment = async () => {
|
|
185
|
+
try {
|
|
186
|
+
await api.post('/departments', {
|
|
187
|
+
name: deptForm.name,
|
|
188
|
+
code: deptForm.code
|
|
189
|
+
})
|
|
190
|
+
deptForm.name = ''
|
|
191
|
+
deptForm.code = ''
|
|
192
|
+
await fetchDepartments()
|
|
193
|
+
} catch (error) {
|
|
194
|
+
console.error(error)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const deleteDepartment = async (id) => {
|
|
199
|
+
try {
|
|
200
|
+
await api.delete(`/departments/${id}`)
|
|
201
|
+
await fetchDepartments()
|
|
202
|
+
await fetchEmployees()
|
|
203
|
+
} catch (error) {
|
|
204
|
+
console.error(error)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const createEmployee = async () => {
|
|
209
|
+
try {
|
|
210
|
+
await api.post('/employees', {
|
|
211
|
+
name: empForm.name,
|
|
212
|
+
email: empForm.email,
|
|
213
|
+
departmentId: Number(empForm.departmentId),
|
|
214
|
+
salary: Number(empForm.salary)
|
|
215
|
+
})
|
|
216
|
+
empForm.name = ''
|
|
217
|
+
empForm.email = ''
|
|
218
|
+
empForm.departmentId = ''
|
|
219
|
+
empForm.salary = ''
|
|
220
|
+
await fetchEmployees()
|
|
221
|
+
} catch (error) {
|
|
222
|
+
console.error(error)
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const deleteEmployee = async (id) => {
|
|
227
|
+
try {
|
|
228
|
+
await api.delete(`/employees/${id}`)
|
|
229
|
+
await fetchEmployees()
|
|
230
|
+
} catch (error) {
|
|
231
|
+
console.error(error)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const patchDepartment = async (id, currentCode) => {
|
|
236
|
+
const code = prompt('Enter new department code:', currentCode)
|
|
237
|
+
if (!code || code === currentCode) return
|
|
238
|
+
try {
|
|
239
|
+
await api.patch(`/departments/${id}`, { code })
|
|
240
|
+
await fetchDepartments()
|
|
241
|
+
} catch (error) {
|
|
242
|
+
console.error(error)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const patchEmployeeSalary = async (id, currentSalary) => {
|
|
247
|
+
const salary = prompt('Enter new salary:', currentSalary)
|
|
248
|
+
if (!salary || Number(salary) === Number(currentSalary)) return
|
|
249
|
+
try {
|
|
250
|
+
await api.patch(`/employees/${id}`, { salary: Number(salary) })
|
|
251
|
+
await fetchEmployees()
|
|
252
|
+
} catch (error) {
|
|
253
|
+
console.error(error)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
const getDepartmentName = (deptId) => {
|
|
258
|
+
const dept = departments.value.find((d) => d.id === deptId)
|
|
259
|
+
return dept ? dept.name : `Dept #${deptId}`
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
onMounted(() => {
|
|
263
|
+
fetchDepartments()
|
|
264
|
+
fetchEmployees()
|
|
265
|
+
})
|
|
266
|
+
</script>
|
|
267
|
+
|
|
268
|
+
<style>
|
|
269
|
+
* {
|
|
270
|
+
box-sizing: border-box;
|
|
271
|
+
margin: 0;
|
|
272
|
+
padding: 0;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
body {
|
|
276
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
277
|
+
background-color: #f4f5f7;
|
|
278
|
+
color: #333333;
|
|
279
|
+
line-height: 1.5;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
.container {
|
|
283
|
+
max-width: 1200px;
|
|
284
|
+
margin: 0 auto;
|
|
285
|
+
padding: 32px 16px;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.header {
|
|
289
|
+
margin-bottom: 24px;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.header h1 {
|
|
293
|
+
font-size: 28px;
|
|
294
|
+
color: #1a1a1a;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
.header p {
|
|
298
|
+
color: #666666;
|
|
299
|
+
font-size: 14px;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.grid {
|
|
303
|
+
display: grid;
|
|
304
|
+
grid-template-columns: 1fr;
|
|
305
|
+
gap: 24px;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
@media (min-width: 900px) {
|
|
309
|
+
.grid {
|
|
310
|
+
grid-template-columns: 1fr 1fr;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
.card {
|
|
315
|
+
background: #ffffff;
|
|
316
|
+
border: 1px solid #e1e4e8;
|
|
317
|
+
border-radius: 8px;
|
|
318
|
+
padding: 20px;
|
|
319
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.card h2 {
|
|
323
|
+
font-size: 20px;
|
|
324
|
+
margin-bottom: 16px;
|
|
325
|
+
color: #222222;
|
|
326
|
+
border-bottom: 1px solid #edf0f2;
|
|
327
|
+
padding-bottom: 8px;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.form {
|
|
331
|
+
display: flex;
|
|
332
|
+
flex-direction: column;
|
|
333
|
+
gap: 12px;
|
|
334
|
+
margin-bottom: 20px;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.form-group {
|
|
338
|
+
display: flex;
|
|
339
|
+
flex-direction: column;
|
|
340
|
+
gap: 4px;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.form-group label {
|
|
344
|
+
font-size: 13px;
|
|
345
|
+
font-weight: 600;
|
|
346
|
+
color: #444444;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.form-group input,
|
|
350
|
+
.form-group select {
|
|
351
|
+
padding: 8px 10px;
|
|
352
|
+
border: 1px solid #cccccc;
|
|
353
|
+
border-radius: 4px;
|
|
354
|
+
font-size: 14px;
|
|
355
|
+
background-color: #ffffff;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.form-group input:focus,
|
|
359
|
+
.form-group select:focus {
|
|
360
|
+
outline: none;
|
|
361
|
+
border-color: #0066cc;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.btn {
|
|
365
|
+
padding: 8px 14px;
|
|
366
|
+
border: none;
|
|
367
|
+
border-radius: 4px;
|
|
368
|
+
cursor: pointer;
|
|
369
|
+
font-size: 13px;
|
|
370
|
+
font-weight: 600;
|
|
371
|
+
transition: background-color 0.15s ease;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.btn-primary {
|
|
375
|
+
background-color: #0066cc;
|
|
376
|
+
color: #ffffff;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.btn-primary:hover {
|
|
380
|
+
background-color: #0052a3;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.btn-danger {
|
|
384
|
+
background-color: #d9383a;
|
|
385
|
+
color: #ffffff;
|
|
386
|
+
padding: 4px 8px;
|
|
387
|
+
font-size: 12px;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.btn-danger:hover {
|
|
391
|
+
background-color: #b8282a;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.table-wrapper {
|
|
395
|
+
overflow-x: auto;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
table {
|
|
399
|
+
width: 100%;
|
|
400
|
+
border-collapse: collapse;
|
|
401
|
+
font-size: 13px;
|
|
402
|
+
margin-top: 8px;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
th, td {
|
|
406
|
+
text-align: left;
|
|
407
|
+
padding: 8px 10px;
|
|
408
|
+
border-bottom: 1px solid #eeeeee;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
th {
|
|
412
|
+
background-color: #fafbfc;
|
|
413
|
+
color: #555555;
|
|
414
|
+
font-weight: 600;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
code {
|
|
418
|
+
background: #f0f0f0;
|
|
419
|
+
padding: 2px 4px;
|
|
420
|
+
border-radius: 3px;
|
|
421
|
+
font-size: 12px;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
.empty {
|
|
425
|
+
text-align: center;
|
|
426
|
+
color: #888888;
|
|
427
|
+
padding: 16px;
|
|
428
|
+
}
|
|
429
|
+
</style>
|