wad-lab 1.1.4 → 1.1.6
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/bin/index.js +30 -3
- package/package.json +1 -1
- package/templates/vue-axios-basic/src/App.vue +405 -405
- package/templates/vue-axios-pinia/src/App.vue +427 -427
- package/templates/vue-axios-props-emits/src/App.vue +167 -167
- package/templates/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -98
- package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +91 -91
- package/templates/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -128
- package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +94 -94
- package/templates/vue-axios-router/src/App.vue +90 -90
- package/templates/vue-axios-router/src/views/AddEmployeeView.vue +247 -247
- package/templates/vue-axios-router/src/views/DepartmentView.vue +273 -273
- package/templates/vue-axios-router/src/views/EmployeeView.vue +196 -196
- package/templates/vue-axios-router/src/views/HomeDashboardView.vue +263 -263
- package/templates/vue-axios-router-props/src/App.vue +59 -59
|
@@ -1,273 +1,273 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { ref, reactive, onMounted } from 'vue'
|
|
3
|
-
import api from '../services/api'
|
|
4
|
-
|
|
5
|
-
const departments = ref([])
|
|
6
|
-
const loading = ref(false)
|
|
7
|
-
const errorMessage = ref('')
|
|
8
|
-
|
|
9
|
-
const form = reactive({
|
|
10
|
-
name: '',
|
|
11
|
-
code: ''
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
async function fetchDepartments() {
|
|
15
|
-
loading.value = true
|
|
16
|
-
errorMessage.value = ''
|
|
17
|
-
try {
|
|
18
|
-
const res = await api.get('/departments')
|
|
19
|
-
departments.value = res.data
|
|
20
|
-
} catch (err) {
|
|
21
|
-
errorMessage.value = err.message || 'Failed to fetch departments'
|
|
22
|
-
} finally {
|
|
23
|
-
loading.value = false
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
async function handleAddDepartment() {
|
|
28
|
-
if (!form.name.trim() || !form.code.trim()) return
|
|
29
|
-
loading.value = true
|
|
30
|
-
errorMessage.value = ''
|
|
31
|
-
try {
|
|
32
|
-
await api.post('/departments', {
|
|
33
|
-
name: form.name.trim(),
|
|
34
|
-
code: form.code.trim()
|
|
35
|
-
})
|
|
36
|
-
form.name = ''
|
|
37
|
-
form.code = ''
|
|
38
|
-
await fetchDepartments()
|
|
39
|
-
} catch (err) {
|
|
40
|
-
errorMessage.value = err.message || 'Failed to add department'
|
|
41
|
-
} finally {
|
|
42
|
-
loading.value = false
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function handleDeleteDepartment(id) {
|
|
47
|
-
if (!confirm('Are you sure you want to delete this department?')) return
|
|
48
|
-
loading.value = true
|
|
49
|
-
errorMessage.value = ''
|
|
50
|
-
try {
|
|
51
|
-
await api.delete(`/departments/${id}`)
|
|
52
|
-
await fetchDepartments()
|
|
53
|
-
} catch (err) {
|
|
54
|
-
errorMessage.value = err.message || 'Failed to delete department'
|
|
55
|
-
} finally {
|
|
56
|
-
loading.value = false
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
onMounted(() => {
|
|
61
|
-
fetchDepartments()
|
|
62
|
-
})
|
|
63
|
-
</script>
|
|
64
|
-
|
|
65
|
-
<template>
|
|
66
|
-
<div class="department-view">
|
|
67
|
-
<h2>Departments</h2>
|
|
68
|
-
|
|
69
|
-
<div v-if="loading" class="state-msg">Loading...</div>
|
|
70
|
-
<div v-if="errorMessage" class="state-msg error">{{ errorMessage }}</div>
|
|
71
|
-
|
|
72
|
-
<div class="card">
|
|
73
|
-
<h3>Add New Department</h3>
|
|
74
|
-
<form @submit.prevent="handleAddDepartment" class="dept-form">
|
|
75
|
-
<div class="form-group">
|
|
76
|
-
<label for="dept-name">Department Name</label>
|
|
77
|
-
<input
|
|
78
|
-
id="dept-name"
|
|
79
|
-
v-model="form.name"
|
|
80
|
-
type="text"
|
|
81
|
-
placeholder="e.g. Engineering"
|
|
82
|
-
required
|
|
83
|
-
/>
|
|
84
|
-
</div>
|
|
85
|
-
|
|
86
|
-
<div class="form-group">
|
|
87
|
-
<label for="dept-code">Department Code</label>
|
|
88
|
-
<input
|
|
89
|
-
id="dept-code"
|
|
90
|
-
v-model="form.code"
|
|
91
|
-
type="text"
|
|
92
|
-
placeholder="e.g. ENG"
|
|
93
|
-
required
|
|
94
|
-
/>
|
|
95
|
-
</div>
|
|
96
|
-
|
|
97
|
-
<button type="submit" class="btn primary" :disabled="loading">Add Department</button>
|
|
98
|
-
</form>
|
|
99
|
-
</div>
|
|
100
|
-
|
|
101
|
-
<div class="card">
|
|
102
|
-
<h3>Department List</h3>
|
|
103
|
-
<table v-if="departments.length > 0" class="data-table">
|
|
104
|
-
<thead>
|
|
105
|
-
<tr>
|
|
106
|
-
<th>ID</th>
|
|
107
|
-
<th>Name</th>
|
|
108
|
-
<th>Code</th>
|
|
109
|
-
<th>Actions</th>
|
|
110
|
-
</tr>
|
|
111
|
-
</thead>
|
|
112
|
-
<tbody>
|
|
113
|
-
<tr v-for="dept in departments" :key="dept.id">
|
|
114
|
-
<td>{{ dept.id }}</td>
|
|
115
|
-
<td>{{ dept.name }}</td>
|
|
116
|
-
<td><span class="badge">{{ dept.code }}</span></td>
|
|
117
|
-
<td>
|
|
118
|
-
<button
|
|
119
|
-
@click="handleDeleteDepartment(dept.id)"
|
|
120
|
-
class="btn danger"
|
|
121
|
-
:disabled="loading"
|
|
122
|
-
>
|
|
123
|
-
Delete
|
|
124
|
-
</button>
|
|
125
|
-
</td>
|
|
126
|
-
</tr>
|
|
127
|
-
</tbody>
|
|
128
|
-
</table>
|
|
129
|
-
<p v-else class="empty-text">No departments found.</p>
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
</template>
|
|
133
|
-
|
|
134
|
-
<style scoped>
|
|
135
|
-
.department-view {
|
|
136
|
-
display: flex;
|
|
137
|
-
flex-direction: column;
|
|
138
|
-
gap: 20px;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
h2 {
|
|
142
|
-
margin: 0;
|
|
143
|
-
color: #2c3e50;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
.card {
|
|
147
|
-
background: #ffffff;
|
|
148
|
-
border: 1px solid #ddd;
|
|
149
|
-
border-radius: 6px;
|
|
150
|
-
padding: 18px;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.card h3 {
|
|
154
|
-
margin: 0 0 14px 0;
|
|
155
|
-
font-size: 16px;
|
|
156
|
-
color: #2c3e50;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.dept-form {
|
|
160
|
-
display: flex;
|
|
161
|
-
flex-wrap: wrap;
|
|
162
|
-
gap: 12px;
|
|
163
|
-
align-items: flex-end;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.form-group {
|
|
167
|
-
display: flex;
|
|
168
|
-
flex-direction: column;
|
|
169
|
-
gap: 4px;
|
|
170
|
-
flex: 1;
|
|
171
|
-
min-width: 180px;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
label {
|
|
175
|
-
font-size: 13px;
|
|
176
|
-
font-weight: bold;
|
|
177
|
-
color: #555;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
input {
|
|
181
|
-
padding: 8px 10px;
|
|
182
|
-
border: 1px solid #ccc;
|
|
183
|
-
border-radius: 4px;
|
|
184
|
-
font-size: 14px;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
input:focus {
|
|
188
|
-
outline: none;
|
|
189
|
-
border-color: #3498db;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.btn {
|
|
193
|
-
padding: 8px 16px;
|
|
194
|
-
border: none;
|
|
195
|
-
border-radius: 4px;
|
|
196
|
-
font-size: 14px;
|
|
197
|
-
cursor: pointer;
|
|
198
|
-
font-weight: bold;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
.btn:disabled {
|
|
202
|
-
opacity: 0.6;
|
|
203
|
-
cursor: not-allowed;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.btn.primary {
|
|
207
|
-
background: #27ae60;
|
|
208
|
-
color: #fff;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
.btn.primary:hover:not(:disabled) {
|
|
212
|
-
background: #219150;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.btn.danger {
|
|
216
|
-
background: #e74c3c;
|
|
217
|
-
color: #fff;
|
|
218
|
-
padding: 5px 10px;
|
|
219
|
-
font-size: 12px;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
.btn.danger:hover:not(:disabled) {
|
|
223
|
-
background: #c0392b;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.data-table {
|
|
227
|
-
width: 100%;
|
|
228
|
-
border-collapse: collapse;
|
|
229
|
-
margin-top: 10px;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
.data-table th,
|
|
233
|
-
.data-table td {
|
|
234
|
-
padding: 10px 12px;
|
|
235
|
-
text-align: left;
|
|
236
|
-
border-bottom: 1px solid #eee;
|
|
237
|
-
font-size: 14px;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
.data-table th {
|
|
241
|
-
background: #f8f9fa;
|
|
242
|
-
color: #555;
|
|
243
|
-
font-weight: 600;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
.badge {
|
|
247
|
-
background: #ecf0f1;
|
|
248
|
-
color: #2c3e50;
|
|
249
|
-
padding: 2px 6px;
|
|
250
|
-
border-radius: 3px;
|
|
251
|
-
font-size: 12px;
|
|
252
|
-
font-family: monospace;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.state-msg {
|
|
256
|
-
padding: 10px;
|
|
257
|
-
background-color: #f8f9fa;
|
|
258
|
-
border: 1px solid #ddd;
|
|
259
|
-
border-radius: 4px;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
.state-msg.error {
|
|
263
|
-
background-color: #fde8e8;
|
|
264
|
-
color: #c0392b;
|
|
265
|
-
border-color: #f5c6cb;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
.empty-text {
|
|
269
|
-
color: #7f8c8d;
|
|
270
|
-
font-size: 14px;
|
|
271
|
-
margin: 10px 0 0 0;
|
|
272
|
-
}
|
|
273
|
-
</style>
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, reactive, onMounted } from 'vue'
|
|
3
|
+
import api from '../services/api'
|
|
4
|
+
|
|
5
|
+
const departments = ref([])
|
|
6
|
+
const loading = ref(false)
|
|
7
|
+
const errorMessage = ref('')
|
|
8
|
+
|
|
9
|
+
const form = reactive({
|
|
10
|
+
name: '',
|
|
11
|
+
code: ''
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
async function fetchDepartments() {
|
|
15
|
+
loading.value = true
|
|
16
|
+
errorMessage.value = ''
|
|
17
|
+
try {
|
|
18
|
+
const res = await api.get('/departments')
|
|
19
|
+
departments.value = res.data
|
|
20
|
+
} catch (err) {
|
|
21
|
+
errorMessage.value = err.message || 'Failed to fetch departments'
|
|
22
|
+
} finally {
|
|
23
|
+
loading.value = false
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function handleAddDepartment() {
|
|
28
|
+
if (!form.name.trim() || !form.code.trim()) return
|
|
29
|
+
loading.value = true
|
|
30
|
+
errorMessage.value = ''
|
|
31
|
+
try {
|
|
32
|
+
await api.post('/departments', {
|
|
33
|
+
name: form.name.trim(),
|
|
34
|
+
code: form.code.trim()
|
|
35
|
+
})
|
|
36
|
+
form.name = ''
|
|
37
|
+
form.code = ''
|
|
38
|
+
await fetchDepartments()
|
|
39
|
+
} catch (err) {
|
|
40
|
+
errorMessage.value = err.message || 'Failed to add department'
|
|
41
|
+
} finally {
|
|
42
|
+
loading.value = false
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function handleDeleteDepartment(id) {
|
|
47
|
+
if (!confirm('Are you sure you want to delete this department?')) return
|
|
48
|
+
loading.value = true
|
|
49
|
+
errorMessage.value = ''
|
|
50
|
+
try {
|
|
51
|
+
await api.delete(`/departments/${id}`)
|
|
52
|
+
await fetchDepartments()
|
|
53
|
+
} catch (err) {
|
|
54
|
+
errorMessage.value = err.message || 'Failed to delete department'
|
|
55
|
+
} finally {
|
|
56
|
+
loading.value = false
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
onMounted(() => {
|
|
61
|
+
fetchDepartments()
|
|
62
|
+
})
|
|
63
|
+
</script>
|
|
64
|
+
|
|
65
|
+
<template>
|
|
66
|
+
<div class="department-view">
|
|
67
|
+
<h2>Departments</h2>
|
|
68
|
+
|
|
69
|
+
<div v-if="loading" class="state-msg">Loading...</div>
|
|
70
|
+
<div v-if="errorMessage" class="state-msg error">{{ errorMessage }}</div>
|
|
71
|
+
|
|
72
|
+
<div class="card">
|
|
73
|
+
<h3>Add New Department</h3>
|
|
74
|
+
<form @submit.prevent="handleAddDepartment" class="dept-form">
|
|
75
|
+
<div class="form-group">
|
|
76
|
+
<label for="dept-name">Department Name</label>
|
|
77
|
+
<input
|
|
78
|
+
id="dept-name"
|
|
79
|
+
v-model="form.name"
|
|
80
|
+
type="text"
|
|
81
|
+
placeholder="e.g. Engineering"
|
|
82
|
+
required
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<div class="form-group">
|
|
87
|
+
<label for="dept-code">Department Code</label>
|
|
88
|
+
<input
|
|
89
|
+
id="dept-code"
|
|
90
|
+
v-model="form.code"
|
|
91
|
+
type="text"
|
|
92
|
+
placeholder="e.g. ENG"
|
|
93
|
+
required
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
|
|
97
|
+
<button type="submit" class="btn primary" :disabled="loading">Add Department</button>
|
|
98
|
+
</form>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div class="card">
|
|
102
|
+
<h3>Department List</h3>
|
|
103
|
+
<table v-if="departments.length > 0" class="data-table">
|
|
104
|
+
<thead>
|
|
105
|
+
<tr>
|
|
106
|
+
<th>ID</th>
|
|
107
|
+
<th>Name</th>
|
|
108
|
+
<th>Code</th>
|
|
109
|
+
<th>Actions</th>
|
|
110
|
+
</tr>
|
|
111
|
+
</thead>
|
|
112
|
+
<tbody>
|
|
113
|
+
<tr v-for="dept in departments" :key="dept.id">
|
|
114
|
+
<td>{{ dept.id }}</td>
|
|
115
|
+
<td>{{ dept.name }}</td>
|
|
116
|
+
<td><span class="badge">{{ dept.code }}</span></td>
|
|
117
|
+
<td>
|
|
118
|
+
<button
|
|
119
|
+
@click="handleDeleteDepartment(dept.id)"
|
|
120
|
+
class="btn danger"
|
|
121
|
+
:disabled="loading"
|
|
122
|
+
>
|
|
123
|
+
Delete
|
|
124
|
+
</button>
|
|
125
|
+
</td>
|
|
126
|
+
</tr>
|
|
127
|
+
</tbody>
|
|
128
|
+
</table>
|
|
129
|
+
<p v-else class="empty-text">No departments found.</p>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<style scoped>
|
|
135
|
+
.department-view {
|
|
136
|
+
display: flex;
|
|
137
|
+
flex-direction: column;
|
|
138
|
+
gap: 20px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
h2 {
|
|
142
|
+
margin: 0;
|
|
143
|
+
color: #2c3e50;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.card {
|
|
147
|
+
background: #ffffff;
|
|
148
|
+
border: 1px solid #ddd;
|
|
149
|
+
border-radius: 6px;
|
|
150
|
+
padding: 18px;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.card h3 {
|
|
154
|
+
margin: 0 0 14px 0;
|
|
155
|
+
font-size: 16px;
|
|
156
|
+
color: #2c3e50;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.dept-form {
|
|
160
|
+
display: flex;
|
|
161
|
+
flex-wrap: wrap;
|
|
162
|
+
gap: 12px;
|
|
163
|
+
align-items: flex-end;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.form-group {
|
|
167
|
+
display: flex;
|
|
168
|
+
flex-direction: column;
|
|
169
|
+
gap: 4px;
|
|
170
|
+
flex: 1;
|
|
171
|
+
min-width: 180px;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
label {
|
|
175
|
+
font-size: 13px;
|
|
176
|
+
font-weight: bold;
|
|
177
|
+
color: #555;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
input {
|
|
181
|
+
padding: 8px 10px;
|
|
182
|
+
border: 1px solid #ccc;
|
|
183
|
+
border-radius: 4px;
|
|
184
|
+
font-size: 14px;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
input:focus {
|
|
188
|
+
outline: none;
|
|
189
|
+
border-color: #3498db;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.btn {
|
|
193
|
+
padding: 8px 16px;
|
|
194
|
+
border: none;
|
|
195
|
+
border-radius: 4px;
|
|
196
|
+
font-size: 14px;
|
|
197
|
+
cursor: pointer;
|
|
198
|
+
font-weight: bold;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.btn:disabled {
|
|
202
|
+
opacity: 0.6;
|
|
203
|
+
cursor: not-allowed;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.btn.primary {
|
|
207
|
+
background: #27ae60;
|
|
208
|
+
color: #fff;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.btn.primary:hover:not(:disabled) {
|
|
212
|
+
background: #219150;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
.btn.danger {
|
|
216
|
+
background: #e74c3c;
|
|
217
|
+
color: #fff;
|
|
218
|
+
padding: 5px 10px;
|
|
219
|
+
font-size: 12px;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.btn.danger:hover:not(:disabled) {
|
|
223
|
+
background: #c0392b;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.data-table {
|
|
227
|
+
width: 100%;
|
|
228
|
+
border-collapse: collapse;
|
|
229
|
+
margin-top: 10px;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.data-table th,
|
|
233
|
+
.data-table td {
|
|
234
|
+
padding: 10px 12px;
|
|
235
|
+
text-align: left;
|
|
236
|
+
border-bottom: 1px solid #eee;
|
|
237
|
+
font-size: 14px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.data-table th {
|
|
241
|
+
background: #f8f9fa;
|
|
242
|
+
color: #555;
|
|
243
|
+
font-weight: 600;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.badge {
|
|
247
|
+
background: #ecf0f1;
|
|
248
|
+
color: #2c3e50;
|
|
249
|
+
padding: 2px 6px;
|
|
250
|
+
border-radius: 3px;
|
|
251
|
+
font-size: 12px;
|
|
252
|
+
font-family: monospace;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.state-msg {
|
|
256
|
+
padding: 10px;
|
|
257
|
+
background-color: #f8f9fa;
|
|
258
|
+
border: 1px solid #ddd;
|
|
259
|
+
border-radius: 4px;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.state-msg.error {
|
|
263
|
+
background-color: #fde8e8;
|
|
264
|
+
color: #c0392b;
|
|
265
|
+
border-color: #f5c6cb;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.empty-text {
|
|
269
|
+
color: #7f8c8d;
|
|
270
|
+
font-size: 14px;
|
|
271
|
+
margin: 10px 0 0 0;
|
|
272
|
+
}
|
|
273
|
+
</style>
|