wad-lab 1.1.2 → 1.1.3
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 +12 -1
- package/package.json +1 -1
- package/templates/springboot-2model-1controller-api/pom.xml +42 -0
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/CompanyApplication.java +11 -0
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/controller/CompanyController.java +74 -0
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/model/Department.java +51 -0
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/model/Employee.java +73 -0
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/repository/DepartmentRepository.java +12 -0
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/repository/EmployeeRepository.java +12 -0
- package/templates/springboot-2model-1controller-api/src/main/java/com/example/company/service/CompanyService.java +60 -0
- package/templates/springboot-2model-1controller-api/src/main/resources/application.properties +4 -0
- package/templates/vue-axios-basic/index.html +12 -0
- package/templates/{frontend → vue-axios-basic}/package.json +6 -9
- package/templates/vue-axios-basic/src/App.vue +405 -0
- package/templates/{frontend → vue-axios-basic}/src/main.js +0 -2
- package/templates/vue-axios-basic/src/services/api.js +7 -0
- package/templates/vue-axios-basic/vite.config.js +9 -0
- package/templates/{frontend → vue-axios-interceptor}/index.html +2 -3
- package/templates/vue-axios-interceptor/package.json +20 -0
- package/templates/vue-axios-interceptor/src/App.vue +159 -0
- package/templates/vue-axios-interceptor/src/components/ToastNotification.vue +47 -0
- package/templates/vue-axios-interceptor/src/main.js +7 -0
- package/templates/vue-axios-interceptor/src/services/api.js +32 -0
- package/templates/vue-axios-interceptor/src/stores/toastStore.js +23 -0
- package/templates/vue-axios-interceptor/vite.config.js +6 -0
- package/templates/vue-axios-pinia/index.html +12 -0
- package/templates/vue-axios-pinia/package.json +20 -0
- package/templates/vue-axios-pinia/src/App.vue +427 -0
- package/templates/vue-axios-pinia/src/main.js +5 -0
- package/templates/vue-axios-pinia/src/services/api.js +7 -0
- package/templates/vue-axios-pinia/src/stores/companyStore.js +96 -0
- package/templates/vue-axios-pinia/vite.config.js +9 -0
- package/templates/vue-axios-pinia-props/index.html +12 -0
- package/templates/vue-axios-pinia-props/package.json +20 -0
- package/templates/vue-axios-pinia-props/src/App.vue +69 -0
- package/templates/vue-axios-pinia-props/src/components/DepartmentSection.vue +152 -0
- package/templates/vue-axios-pinia-props/src/components/EmployeeSection.vue +181 -0
- package/templates/vue-axios-pinia-props/src/main.js +5 -0
- package/templates/vue-axios-pinia-props/src/services/api.js +7 -0
- package/templates/vue-axios-pinia-props/src/stores/companyStore.js +35 -0
- package/templates/vue-axios-pinia-props/vite.config.js +6 -0
- package/templates/vue-axios-props-emits/index.html +12 -0
- package/templates/vue-axios-props-emits/package.json +19 -0
- package/templates/vue-axios-props-emits/src/App.vue +167 -0
- package/templates/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -0
- package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +91 -0
- package/templates/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -0
- package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +94 -0
- package/templates/vue-axios-props-emits/src/main.js +4 -0
- package/templates/vue-axios-props-emits/src/services/api.js +7 -0
- package/templates/vue-axios-props-emits/vite.config.js +9 -0
- package/templates/vue-axios-router/index.html +12 -0
- package/templates/vue-axios-router/package.json +20 -0
- package/templates/vue-axios-router/src/App.vue +90 -0
- package/templates/vue-axios-router/src/main.js +5 -0
- package/templates/vue-axios-router/src/router/index.js +19 -0
- package/templates/vue-axios-router/src/services/api.js +7 -0
- package/templates/vue-axios-router/src/views/AddEmployeeView.vue +247 -0
- package/templates/vue-axios-router/src/views/DepartmentView.vue +273 -0
- package/templates/vue-axios-router/src/views/EmployeeView.vue +196 -0
- package/templates/vue-axios-router/src/views/HomeDashboardView.vue +263 -0
- package/templates/vue-axios-router/vite.config.js +6 -0
- package/templates/vue-axios-router-children/index.html +12 -0
- package/templates/vue-axios-router-children/package.json +20 -0
- package/templates/vue-axios-router-children/src/App.vue +20 -0
- package/templates/vue-axios-router-children/src/main.js +5 -0
- package/templates/vue-axios-router-children/src/router/index.js +42 -0
- package/templates/vue-axios-router-children/src/services/api.js +7 -0
- package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +75 -0
- package/templates/vue-axios-router-children/src/views/CompanyOverview.vue +109 -0
- package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +231 -0
- package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +159 -0
- package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +295 -0
- package/templates/vue-axios-router-children/vite.config.js +6 -0
- package/templates/vue-axios-router-pinia/index.html +12 -0
- package/templates/vue-axios-router-pinia/package.json +21 -0
- package/templates/vue-axios-router-pinia/src/App.vue +92 -0
- package/templates/vue-axios-router-pinia/src/main.js +9 -0
- package/templates/vue-axios-router-pinia/src/router/index.js +17 -0
- package/templates/vue-axios-router-pinia/src/services/api.js +7 -0
- package/templates/vue-axios-router-pinia/src/stores/companyStore.js +70 -0
- package/templates/vue-axios-router-pinia/src/views/DashboardView.vue +77 -0
- package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +209 -0
- package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +237 -0
- package/templates/vue-axios-router-pinia/vite.config.js +6 -0
- package/templates/vue-axios-router-pinia-props/index.html +12 -0
- package/templates/vue-axios-router-pinia-props/package.json +21 -0
- package/templates/vue-axios-router-pinia-props/src/App.vue +67 -0
- package/templates/vue-axios-router-pinia-props/src/components/EntityForm.vue +101 -0
- package/templates/vue-axios-router-pinia-props/src/components/EntityTable.vue +92 -0
- package/templates/vue-axios-router-pinia-props/src/components/SummaryBadge.vue +43 -0
- package/templates/vue-axios-router-pinia-props/src/main.js +9 -0
- package/templates/vue-axios-router-pinia-props/src/router/index.js +29 -0
- package/templates/vue-axios-router-pinia-props/src/services/api.js +29 -0
- package/templates/vue-axios-router-pinia-props/src/stores/companyStore.js +84 -0
- package/templates/vue-axios-router-pinia-props/src/views/ManageDepartmentsView.vue +64 -0
- package/templates/vue-axios-router-pinia-props/src/views/ManageEmployeesView.vue +67 -0
- package/templates/vue-axios-router-pinia-props/src/views/OverviewView.vue +38 -0
- package/templates/vue-axios-router-pinia-props/vite.config.js +6 -0
- package/templates/vue-axios-router-props/index.html +12 -0
- package/templates/vue-axios-router-props/package.json +20 -0
- package/templates/vue-axios-router-props/src/App.vue +59 -0
- package/templates/vue-axios-router-props/src/components/DataCard.vue +53 -0
- package/templates/vue-axios-router-props/src/components/EntryForm.vue +117 -0
- package/templates/vue-axios-router-props/src/main.js +7 -0
- package/templates/vue-axios-router-props/src/router/index.js +23 -0
- package/templates/vue-axios-router-props/src/services/api.js +7 -0
- package/templates/vue-axios-router-props/src/views/DepartmentPage.vue +77 -0
- package/templates/vue-axios-router-props/src/views/EmployeePage.vue +116 -0
- package/templates/vue-axios-router-props/vite.config.js +6 -0
- package/templates/backend/.gitattributes +0 -2
- package/templates/backend/.idea/compiler.xml +0 -21
- package/templates/backend/.idea/encodings.xml +0 -6
- package/templates/backend/.idea/jarRepositories.xml +0 -20
- package/templates/backend/.idea/misc.xml +0 -12
- package/templates/backend/.idea/vcs.xml +0 -6
- package/templates/backend/pom.xml +0 -104
- package/templates/backend/src/main/java/com/example/crud/CrudApplication.java +0 -13
- package/templates/backend/src/main/java/com/example/crud/controller/ItemController.java +0 -42
- package/templates/backend/src/main/java/com/example/crud/model/Item.java +0 -20
- package/templates/backend/src/main/java/com/example/crud/repository/ItemRepository.java +0 -9
- package/templates/backend/src/main/java/com/example/crud/service/ItemService.java +0 -37
- package/templates/backend/src/main/resources/application.properties +0 -4
- package/templates/backend/src/test/java/com/example/crud/CrudApplicationTests.java +0 -13
- package/templates/frontend/.vscode/extensions.json +0 -3
- package/templates/frontend/README.md +0 -38
- package/templates/frontend/jsconfig.json +0 -8
- package/templates/frontend/public/favicon.ico +0 -0
- package/templates/frontend/src/App.vue +0 -50
- package/templates/frontend/src/assets/base.css +0 -86
- package/templates/frontend/src/assets/logo.svg +0 -1
- package/templates/frontend/src/assets/main.css +0 -35
- package/templates/frontend/src/components/HelloWorld.vue +0 -44
- package/templates/frontend/src/components/TheWelcome.vue +0 -95
- package/templates/frontend/src/components/WelcomeItem.vue +0 -87
- package/templates/frontend/src/components/icons/IconCommunity.vue +0 -7
- package/templates/frontend/src/components/icons/IconDocumentation.vue +0 -7
- package/templates/frontend/src/components/icons/IconEcosystem.vue +0 -7
- package/templates/frontend/src/components/icons/IconSupport.vue +0 -7
- package/templates/frontend/src/components/icons/IconTooling.vue +0 -19
- package/templates/frontend/src/services/ItemService.js +0 -21
- package/templates/frontend/vite.config.js +0 -18
- /package/templates/{backend → springboot-2model-1controller-api}/.mvn/wrapper/maven-wrapper.properties +0 -0
- /package/templates/{backend → springboot-2model-1controller-api}/mvnw +0 -0
- /package/templates/{backend → springboot-2model-1controller-api}/mvnw.cmd +0 -0
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, computed, onMounted } from 'vue'
|
|
3
|
+
import api from '../services/api'
|
|
4
|
+
|
|
5
|
+
const departments = ref([])
|
|
6
|
+
const employees = ref([])
|
|
7
|
+
const loading = ref(false)
|
|
8
|
+
const errorMessage = ref('')
|
|
9
|
+
|
|
10
|
+
const totalDepartments = computed(() => departments.value.length)
|
|
11
|
+
const totalEmployees = computed(() => employees.value.length)
|
|
12
|
+
|
|
13
|
+
const totalPayroll = computed(() => {
|
|
14
|
+
return employees.value.reduce((sum, emp) => sum + (Number(emp.salary) || 0), 0)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const averageSalary = computed(() => {
|
|
18
|
+
if (employees.value.length === 0) return 0
|
|
19
|
+
return Math.round(totalPayroll.value / employees.value.length)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
async function fetchDashboardData() {
|
|
23
|
+
loading.value = true
|
|
24
|
+
errorMessage.value = ''
|
|
25
|
+
try {
|
|
26
|
+
const [deptRes, empRes] = await Promise.all([
|
|
27
|
+
api.get('/departments'),
|
|
28
|
+
api.get('/employees')
|
|
29
|
+
])
|
|
30
|
+
departments.value = deptRes.data
|
|
31
|
+
employees.value = empRes.data
|
|
32
|
+
} catch (err) {
|
|
33
|
+
errorMessage.value = err.message || 'Failed to load dashboard data'
|
|
34
|
+
} finally {
|
|
35
|
+
loading.value = false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onMounted(() => {
|
|
40
|
+
fetchDashboardData()
|
|
41
|
+
})
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<template>
|
|
45
|
+
<div class="dashboard-view">
|
|
46
|
+
<h2>Dashboard Overview</h2>
|
|
47
|
+
|
|
48
|
+
<div v-if="loading" class="state-msg">Loading dashboard stats...</div>
|
|
49
|
+
<div v-if="errorMessage" class="state-msg error">{{ errorMessage }}</div>
|
|
50
|
+
|
|
51
|
+
<div class="stats-grid">
|
|
52
|
+
<div class="stat-card">
|
|
53
|
+
<h3>Departments</h3>
|
|
54
|
+
<p class="stat-value">{{ totalDepartments }}</p>
|
|
55
|
+
<router-link to="/departments" class="stat-link">View all departments →</router-link>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div class="stat-card">
|
|
59
|
+
<h3>Employees</h3>
|
|
60
|
+
<p class="stat-value">{{ totalEmployees }}</p>
|
|
61
|
+
<router-link to="/employees" class="stat-link">View all employees →</router-link>
|
|
62
|
+
</div>
|
|
63
|
+
|
|
64
|
+
<div class="stat-card">
|
|
65
|
+
<h3>Total Payroll</h3>
|
|
66
|
+
<p class="stat-value">${{ totalPayroll.toLocaleString() }}</p>
|
|
67
|
+
<span class="stat-sub">Monthly expenditure</span>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div class="stat-card">
|
|
71
|
+
<h3>Average Salary</h3>
|
|
72
|
+
<p class="stat-value">${{ averageSalary.toLocaleString() }}</p>
|
|
73
|
+
<span class="stat-sub">Per employee</span>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
|
|
77
|
+
<div class="dashboard-sections">
|
|
78
|
+
<div class="section-card">
|
|
79
|
+
<div class="section-header">
|
|
80
|
+
<h3>Departments Overview</h3>
|
|
81
|
+
<router-link to="/departments" class="action-btn">Manage</router-link>
|
|
82
|
+
</div>
|
|
83
|
+
<ul v-if="departments.length > 0" class="item-list">
|
|
84
|
+
<li v-for="dept in departments" :key="dept.id" class="list-row">
|
|
85
|
+
<strong>{{ dept.name }}</strong>
|
|
86
|
+
<span class="badge">{{ dept.code }}</span>
|
|
87
|
+
</li>
|
|
88
|
+
</ul>
|
|
89
|
+
<p v-else class="empty-text">No departments recorded.</p>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div class="section-card">
|
|
93
|
+
<div class="section-header">
|
|
94
|
+
<h3>Recent Employees</h3>
|
|
95
|
+
<router-link to="/add-employee" class="action-btn">+ Add New</router-link>
|
|
96
|
+
</div>
|
|
97
|
+
<ul v-if="employees.length > 0" class="item-list">
|
|
98
|
+
<li v-for="emp in employees.slice(-5)" :key="emp.id" class="list-row">
|
|
99
|
+
<div>
|
|
100
|
+
<strong>{{ emp.name }}</strong>
|
|
101
|
+
<small class="muted-text">({{ emp.email }})</small>
|
|
102
|
+
</div>
|
|
103
|
+
<span class="salary-text">${{ Number(emp.salary || 0).toLocaleString() }}</span>
|
|
104
|
+
</li>
|
|
105
|
+
</ul>
|
|
106
|
+
<p v-else class="empty-text">No employees recorded.</p>
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
</template>
|
|
111
|
+
|
|
112
|
+
<style scoped>
|
|
113
|
+
.dashboard-view {
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
gap: 20px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
h2 {
|
|
120
|
+
margin: 0;
|
|
121
|
+
color: #2c3e50;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.state-msg {
|
|
125
|
+
padding: 10px;
|
|
126
|
+
background-color: #f8f9fa;
|
|
127
|
+
border: 1px solid #ddd;
|
|
128
|
+
border-radius: 4px;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.state-msg.error {
|
|
132
|
+
background-color: #fde8e8;
|
|
133
|
+
color: #c0392b;
|
|
134
|
+
border-color: #f5c6cb;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.stats-grid {
|
|
138
|
+
display: grid;
|
|
139
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
140
|
+
gap: 16px;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.stat-card {
|
|
144
|
+
background: #ffffff;
|
|
145
|
+
border: 1px solid #ddd;
|
|
146
|
+
border-radius: 6px;
|
|
147
|
+
padding: 16px;
|
|
148
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.stat-card h3 {
|
|
152
|
+
margin: 0 0 8px 0;
|
|
153
|
+
font-size: 14px;
|
|
154
|
+
color: #666;
|
|
155
|
+
text-transform: uppercase;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.stat-value {
|
|
159
|
+
margin: 0 0 10px 0;
|
|
160
|
+
font-size: 28px;
|
|
161
|
+
font-weight: bold;
|
|
162
|
+
color: #2c3e50;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.stat-link {
|
|
166
|
+
font-size: 13px;
|
|
167
|
+
color: #3498db;
|
|
168
|
+
text-decoration: none;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.stat-link:hover {
|
|
172
|
+
text-decoration: underline;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.stat-sub {
|
|
176
|
+
font-size: 13px;
|
|
177
|
+
color: #888;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.dashboard-sections {
|
|
181
|
+
display: grid;
|
|
182
|
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
183
|
+
gap: 16px;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.section-card {
|
|
187
|
+
background: #ffffff;
|
|
188
|
+
border: 1px solid #ddd;
|
|
189
|
+
border-radius: 6px;
|
|
190
|
+
padding: 16px;
|
|
191
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.05);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.section-header {
|
|
195
|
+
display: flex;
|
|
196
|
+
justify-content: space-between;
|
|
197
|
+
align-items: center;
|
|
198
|
+
margin-bottom: 12px;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.section-header h3 {
|
|
202
|
+
margin: 0;
|
|
203
|
+
font-size: 16px;
|
|
204
|
+
color: #2c3e50;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.action-btn {
|
|
208
|
+
font-size: 12px;
|
|
209
|
+
padding: 4px 8px;
|
|
210
|
+
background: #2c3e50;
|
|
211
|
+
color: #ffffff;
|
|
212
|
+
text-decoration: none;
|
|
213
|
+
border-radius: 4px;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.action-btn:hover {
|
|
217
|
+
background: #34495e;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.item-list {
|
|
221
|
+
list-style: none;
|
|
222
|
+
padding: 0;
|
|
223
|
+
margin: 0;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.list-row {
|
|
227
|
+
display: flex;
|
|
228
|
+
justify-content: space-between;
|
|
229
|
+
align-items: center;
|
|
230
|
+
padding: 8px 0;
|
|
231
|
+
border-bottom: 1px solid #eee;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.list-row:last-child {
|
|
235
|
+
border-bottom: none;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.badge {
|
|
239
|
+
background: #ecf0f1;
|
|
240
|
+
color: #2c3e50;
|
|
241
|
+
padding: 2px 6px;
|
|
242
|
+
border-radius: 3px;
|
|
243
|
+
font-size: 12px;
|
|
244
|
+
font-family: monospace;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.muted-text {
|
|
248
|
+
margin-left: 6px;
|
|
249
|
+
color: #7f8c8d;
|
|
250
|
+
font-size: 12px;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.salary-text {
|
|
254
|
+
font-weight: bold;
|
|
255
|
+
color: #27ae60;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.empty-text {
|
|
259
|
+
color: #7f8c8d;
|
|
260
|
+
font-size: 14px;
|
|
261
|
+
margin: 8px 0;
|
|
262
|
+
}
|
|
263
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Vue Axios Router Children</title>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<div id="app"></div>
|
|
10
|
+
<script type="module" src="/src/main.js"></script>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-axios-router-children",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"preview": "vite preview"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"axios": "^1.7.7",
|
|
13
|
+
"vue": "^3.5.44",
|
|
14
|
+
"vue-router": "^5.4.0"
|
|
15
|
+
},
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@vitejs/plugin-vue": "^6.0.10",
|
|
18
|
+
"vite": "^8.3.4"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<router-view />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
* {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
body {
|
|
16
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
17
|
+
color: #333333;
|
|
18
|
+
background-color: #f1f5f9;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
2
|
+
import CompanyLayout from '../views/CompanyLayout.vue'
|
|
3
|
+
import CompanyOverview from '../views/CompanyOverview.vue'
|
|
4
|
+
import DepartmentListView from '../views/DepartmentListView.vue'
|
|
5
|
+
import EmployeeListView from '../views/EmployeeListView.vue'
|
|
6
|
+
import EmployeeDetailView from '../views/EmployeeDetailView.vue'
|
|
7
|
+
|
|
8
|
+
const routes = [
|
|
9
|
+
{
|
|
10
|
+
path: '/',
|
|
11
|
+
redirect: '/company'
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
path: '/company',
|
|
15
|
+
component: CompanyLayout,
|
|
16
|
+
children: [
|
|
17
|
+
{
|
|
18
|
+
path: '',
|
|
19
|
+
component: CompanyOverview
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
path: 'departments',
|
|
23
|
+
component: DepartmentListView
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
path: 'employees',
|
|
27
|
+
component: EmployeeListView
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
path: 'employees/:id',
|
|
31
|
+
component: EmployeeDetailView
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const router = createRouter({
|
|
38
|
+
history: createWebHistory(),
|
|
39
|
+
routes
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
export default router
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="layout-container">
|
|
3
|
+
<aside class="sidebar">
|
|
4
|
+
<div class="sidebar-header">
|
|
5
|
+
<h2>Company Portal</h2>
|
|
6
|
+
</div>
|
|
7
|
+
<nav class="nav-links">
|
|
8
|
+
<router-link to="/company" class="nav-item" exact-active-class="active">Overview</router-link>
|
|
9
|
+
<router-link to="/company/departments" class="nav-item" active-class="active">Departments</router-link>
|
|
10
|
+
<router-link to="/company/employees" class="nav-item" active-class="active">Employees</router-link>
|
|
11
|
+
</nav>
|
|
12
|
+
</aside>
|
|
13
|
+
<main class="main-content">
|
|
14
|
+
<router-view />
|
|
15
|
+
</main>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<style scoped>
|
|
23
|
+
.layout-container {
|
|
24
|
+
display: flex;
|
|
25
|
+
min-height: 100vh;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.sidebar {
|
|
29
|
+
width: 240px;
|
|
30
|
+
background-color: #2c3e50;
|
|
31
|
+
color: #fff;
|
|
32
|
+
padding: 24px 16px;
|
|
33
|
+
display: flex;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
gap: 24px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sidebar-header h2 {
|
|
39
|
+
font-size: 1.25rem;
|
|
40
|
+
font-weight: 600;
|
|
41
|
+
color: #ecf0f1;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.nav-links {
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: column;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.nav-item {
|
|
51
|
+
color: #bdc3c7;
|
|
52
|
+
text-decoration: none;
|
|
53
|
+
padding: 10px 14px;
|
|
54
|
+
border-radius: 6px;
|
|
55
|
+
transition: background-color 0.2s, color 0.2s;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.nav-item:hover {
|
|
59
|
+
background-color: #34495e;
|
|
60
|
+
color: #ffffff;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.nav-item.active {
|
|
64
|
+
background-color: #3498db;
|
|
65
|
+
color: #ffffff;
|
|
66
|
+
font-weight: 600;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.main-content {
|
|
70
|
+
flex: 1;
|
|
71
|
+
padding: 32px;
|
|
72
|
+
background-color: #f8fafc;
|
|
73
|
+
overflow-y: auto;
|
|
74
|
+
}
|
|
75
|
+
</style>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="overview">
|
|
3
|
+
<header class="page-header">
|
|
4
|
+
<h1>Company Overview</h1>
|
|
5
|
+
<p>Welcome to the central company dashboard.</p>
|
|
6
|
+
</header>
|
|
7
|
+
|
|
8
|
+
<div class="stats-grid">
|
|
9
|
+
<div class="stat-card">
|
|
10
|
+
<h3>Total Departments</h3>
|
|
11
|
+
<p class="stat-value">{{ departmentCount }}</p>
|
|
12
|
+
<router-link to="/company/departments" class="stat-link">View Departments →</router-link>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div class="stat-card">
|
|
16
|
+
<h3>Total Employees</h3>
|
|
17
|
+
<p class="stat-value">{{ employeeCount }}</p>
|
|
18
|
+
<router-link to="/company/employees" class="stat-link">View Employees →</router-link>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
25
|
+
import { ref, onMounted } from 'vue'
|
|
26
|
+
import api from '../services/api'
|
|
27
|
+
|
|
28
|
+
const departmentCount = ref(0)
|
|
29
|
+
const employeeCount = ref(0)
|
|
30
|
+
|
|
31
|
+
const fetchStats = async () => {
|
|
32
|
+
try {
|
|
33
|
+
const deptRes = await api.get('/departments')
|
|
34
|
+
departmentCount.value = Array.isArray(deptRes.data) ? deptRes.data.length : 0
|
|
35
|
+
} catch (err) {
|
|
36
|
+
departmentCount.value = 0
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const empRes = await api.get('/employees')
|
|
41
|
+
employeeCount.value = Array.isArray(empRes.data) ? empRes.data.length : 0
|
|
42
|
+
} catch (err) {
|
|
43
|
+
employeeCount.value = 0
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
onMounted(() => {
|
|
48
|
+
fetchStats()
|
|
49
|
+
})
|
|
50
|
+
</script>
|
|
51
|
+
|
|
52
|
+
<style scoped>
|
|
53
|
+
.overview {
|
|
54
|
+
max-width: 900px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.page-header {
|
|
58
|
+
margin-bottom: 24px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.page-header h1 {
|
|
62
|
+
font-size: 1.75rem;
|
|
63
|
+
margin-bottom: 6px;
|
|
64
|
+
color: #1e293b;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.page-header p {
|
|
68
|
+
color: #64748b;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.stats-grid {
|
|
72
|
+
display: grid;
|
|
73
|
+
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
|
|
74
|
+
gap: 20px;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.stat-card {
|
|
78
|
+
background-color: #ffffff;
|
|
79
|
+
padding: 24px;
|
|
80
|
+
border-radius: 8px;
|
|
81
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
82
|
+
display: flex;
|
|
83
|
+
flex-direction: column;
|
|
84
|
+
gap: 12px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.stat-card h3 {
|
|
88
|
+
font-size: 1rem;
|
|
89
|
+
color: #475569;
|
|
90
|
+
font-weight: 500;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.stat-value {
|
|
94
|
+
font-size: 2.25rem;
|
|
95
|
+
font-weight: 700;
|
|
96
|
+
color: #2563eb;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.stat-link {
|
|
100
|
+
color: #2563eb;
|
|
101
|
+
text-decoration: none;
|
|
102
|
+
font-size: 0.9rem;
|
|
103
|
+
font-weight: 500;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.stat-link:hover {
|
|
107
|
+
text-decoration: underline;
|
|
108
|
+
}
|
|
109
|
+
</style>
|