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,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form @submit.prevent="handleSubmit" class="form">
|
|
3
|
+
<div class="form-group">
|
|
4
|
+
<label for="dept-name">Department Name</label>
|
|
5
|
+
<input
|
|
6
|
+
id="dept-name"
|
|
7
|
+
v-model="deptForm.name"
|
|
8
|
+
type="text"
|
|
9
|
+
required
|
|
10
|
+
placeholder="e.g. Engineering"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="form-group">
|
|
14
|
+
<label for="dept-code">Department Code</label>
|
|
15
|
+
<input
|
|
16
|
+
id="dept-code"
|
|
17
|
+
v-model="deptForm.code"
|
|
18
|
+
type="text"
|
|
19
|
+
required
|
|
20
|
+
placeholder="e.g. ENG"
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
<button type="submit" class="btn btn-primary">Add Department</button>
|
|
24
|
+
</form>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script setup>
|
|
28
|
+
import { reactive } from 'vue'
|
|
29
|
+
|
|
30
|
+
const emit = defineEmits(['create-department'])
|
|
31
|
+
|
|
32
|
+
const deptForm = reactive({
|
|
33
|
+
name: '',
|
|
34
|
+
code: ''
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const handleSubmit = () => {
|
|
38
|
+
emit('create-department', {
|
|
39
|
+
name: deptForm.name,
|
|
40
|
+
code: deptForm.code
|
|
41
|
+
})
|
|
42
|
+
deptForm.name = ''
|
|
43
|
+
deptForm.code = ''
|
|
44
|
+
}
|
|
45
|
+
</script>
|
|
46
|
+
|
|
47
|
+
<style scoped>
|
|
48
|
+
.form {
|
|
49
|
+
display: flex;
|
|
50
|
+
flex-direction: column;
|
|
51
|
+
gap: 12px;
|
|
52
|
+
margin-bottom: 20px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.form-group {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column;
|
|
58
|
+
gap: 4px;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.form-group label {
|
|
62
|
+
font-size: 13px;
|
|
63
|
+
font-weight: 600;
|
|
64
|
+
color: #444444;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.form-group input {
|
|
68
|
+
padding: 8px 10px;
|
|
69
|
+
border: 1px solid #cccccc;
|
|
70
|
+
border-radius: 4px;
|
|
71
|
+
font-size: 14px;
|
|
72
|
+
background-color: #ffffff;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.form-group input:focus {
|
|
76
|
+
outline: none;
|
|
77
|
+
border-color: #0066cc;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.btn {
|
|
81
|
+
padding: 8px 14px;
|
|
82
|
+
border: none;
|
|
83
|
+
border-radius: 4px;
|
|
84
|
+
cursor: pointer;
|
|
85
|
+
font-size: 13px;
|
|
86
|
+
font-weight: 600;
|
|
87
|
+
transition: background-color 0.15s ease;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.btn-primary {
|
|
91
|
+
background-color: #0066cc;
|
|
92
|
+
color: #ffffff;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.btn-primary:hover {
|
|
96
|
+
background-color: #0052a3;
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table-wrapper">
|
|
3
|
+
<table>
|
|
4
|
+
<thead>
|
|
5
|
+
<tr>
|
|
6
|
+
<th>ID</th>
|
|
7
|
+
<th>Name</th>
|
|
8
|
+
<th>Code</th>
|
|
9
|
+
<th>Action</th>
|
|
10
|
+
</tr>
|
|
11
|
+
</thead>
|
|
12
|
+
<tbody>
|
|
13
|
+
<tr v-if="departments.length === 0">
|
|
14
|
+
<td colspan="4" class="empty">No departments found</td>
|
|
15
|
+
</tr>
|
|
16
|
+
<tr v-for="dept in departments" :key="dept.id">
|
|
17
|
+
<td>{{ dept.id }}</td>
|
|
18
|
+
<td>{{ dept.name }}</td>
|
|
19
|
+
<td><code>{{ dept.code }}</code></td>
|
|
20
|
+
<td>
|
|
21
|
+
<button @click="emit('delete-department', dept.id)" class="btn btn-danger">Delete</button>
|
|
22
|
+
</td>
|
|
23
|
+
</tr>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script setup>
|
|
30
|
+
defineProps(['departments'])
|
|
31
|
+
const emit = defineEmits(['delete-department'])
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<style scoped>
|
|
35
|
+
.table-wrapper {
|
|
36
|
+
overflow-x: auto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
table {
|
|
40
|
+
width: 100%;
|
|
41
|
+
border-collapse: collapse;
|
|
42
|
+
font-size: 13px;
|
|
43
|
+
margin-top: 8px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
th, td {
|
|
47
|
+
text-align: left;
|
|
48
|
+
padding: 8px 10px;
|
|
49
|
+
border-bottom: 1px solid #eeeeee;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
th {
|
|
53
|
+
background-color: #fafbfc;
|
|
54
|
+
color: #555555;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
code {
|
|
59
|
+
background: #f0f0f0;
|
|
60
|
+
padding: 2px 4px;
|
|
61
|
+
border-radius: 3px;
|
|
62
|
+
font-size: 12px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.empty {
|
|
66
|
+
text-align: center;
|
|
67
|
+
color: #888888;
|
|
68
|
+
padding: 16px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.btn {
|
|
72
|
+
padding: 8px 14px;
|
|
73
|
+
border: none;
|
|
74
|
+
border-radius: 4px;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
font-size: 13px;
|
|
77
|
+
font-weight: 600;
|
|
78
|
+
transition: background-color 0.15s ease;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.btn-danger {
|
|
82
|
+
background-color: #d9383a;
|
|
83
|
+
color: #ffffff;
|
|
84
|
+
padding: 4px 8px;
|
|
85
|
+
font-size: 12px;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.btn-danger:hover {
|
|
89
|
+
background-color: #b8282a;
|
|
90
|
+
}
|
|
91
|
+
</style>
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form @submit.prevent="handleSubmit" class="form">
|
|
3
|
+
<div class="form-group">
|
|
4
|
+
<label for="emp-name">Full Name</label>
|
|
5
|
+
<input
|
|
6
|
+
id="emp-name"
|
|
7
|
+
v-model="empForm.name"
|
|
8
|
+
type="text"
|
|
9
|
+
required
|
|
10
|
+
placeholder="e.g. Jane Doe"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="form-group">
|
|
14
|
+
<label for="emp-email">Email Address</label>
|
|
15
|
+
<input
|
|
16
|
+
id="emp-email"
|
|
17
|
+
v-model="empForm.email"
|
|
18
|
+
type="email"
|
|
19
|
+
required
|
|
20
|
+
placeholder="e.g. jane@example.com"
|
|
21
|
+
/>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="form-group">
|
|
24
|
+
<label for="emp-dept">Department</label>
|
|
25
|
+
<select id="emp-dept" v-model="empForm.departmentId" required>
|
|
26
|
+
<option value="" disabled>Select Department</option>
|
|
27
|
+
<option v-for="dept in departments" :key="dept.id" :value="dept.id">
|
|
28
|
+
{{ dept.name }} ({{ dept.code }})
|
|
29
|
+
</option>
|
|
30
|
+
</select>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="form-group">
|
|
33
|
+
<label for="emp-salary">Salary</label>
|
|
34
|
+
<input
|
|
35
|
+
id="emp-salary"
|
|
36
|
+
v-model.number="empForm.salary"
|
|
37
|
+
type="number"
|
|
38
|
+
min="0"
|
|
39
|
+
step="any"
|
|
40
|
+
required
|
|
41
|
+
placeholder="e.g. 75000"
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
<button type="submit" class="btn btn-primary">Add Employee</button>
|
|
45
|
+
</form>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script setup>
|
|
49
|
+
import { reactive } from 'vue'
|
|
50
|
+
|
|
51
|
+
defineProps(['departments'])
|
|
52
|
+
const emit = defineEmits(['create-employee'])
|
|
53
|
+
|
|
54
|
+
const empForm = reactive({
|
|
55
|
+
name: '',
|
|
56
|
+
email: '',
|
|
57
|
+
departmentId: '',
|
|
58
|
+
salary: ''
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const handleSubmit = () => {
|
|
62
|
+
emit('create-employee', {
|
|
63
|
+
name: empForm.name,
|
|
64
|
+
email: empForm.email,
|
|
65
|
+
departmentId: empForm.departmentId,
|
|
66
|
+
salary: Number(empForm.salary)
|
|
67
|
+
})
|
|
68
|
+
empForm.name = ''
|
|
69
|
+
empForm.email = ''
|
|
70
|
+
empForm.departmentId = ''
|
|
71
|
+
empForm.salary = ''
|
|
72
|
+
}
|
|
73
|
+
</script>
|
|
74
|
+
|
|
75
|
+
<style scoped>
|
|
76
|
+
.form {
|
|
77
|
+
display: flex;
|
|
78
|
+
flex-direction: column;
|
|
79
|
+
gap: 12px;
|
|
80
|
+
margin-bottom: 20px;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.form-group {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
gap: 4px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.form-group label {
|
|
90
|
+
font-size: 13px;
|
|
91
|
+
font-weight: 600;
|
|
92
|
+
color: #444444;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.form-group input,
|
|
96
|
+
.form-group select {
|
|
97
|
+
padding: 8px 10px;
|
|
98
|
+
border: 1px solid #cccccc;
|
|
99
|
+
border-radius: 4px;
|
|
100
|
+
font-size: 14px;
|
|
101
|
+
background-color: #ffffff;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.form-group input:focus,
|
|
105
|
+
.form-group select:focus {
|
|
106
|
+
outline: none;
|
|
107
|
+
border-color: #0066cc;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.btn {
|
|
111
|
+
padding: 8px 14px;
|
|
112
|
+
border: none;
|
|
113
|
+
border-radius: 4px;
|
|
114
|
+
cursor: pointer;
|
|
115
|
+
font-size: 13px;
|
|
116
|
+
font-weight: 600;
|
|
117
|
+
transition: background-color 0.15s ease;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.btn-primary {
|
|
121
|
+
background-color: #0066cc;
|
|
122
|
+
color: #ffffff;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.btn-primary:hover {
|
|
126
|
+
background-color: #0052a3;
|
|
127
|
+
}
|
|
128
|
+
</style>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table-wrapper">
|
|
3
|
+
<table>
|
|
4
|
+
<thead>
|
|
5
|
+
<tr>
|
|
6
|
+
<th>ID</th>
|
|
7
|
+
<th>Name</th>
|
|
8
|
+
<th>Email</th>
|
|
9
|
+
<th>Department</th>
|
|
10
|
+
<th>Salary</th>
|
|
11
|
+
<th>Action</th>
|
|
12
|
+
</tr>
|
|
13
|
+
</thead>
|
|
14
|
+
<tbody>
|
|
15
|
+
<tr v-if="employees.length === 0">
|
|
16
|
+
<td colspan="6" class="empty">No employees found</td>
|
|
17
|
+
</tr>
|
|
18
|
+
<tr v-for="emp in employees" :key="emp.id">
|
|
19
|
+
<td>{{ emp.id }}</td>
|
|
20
|
+
<td>{{ emp.name }}</td>
|
|
21
|
+
<td>{{ emp.email }}</td>
|
|
22
|
+
<td>{{ getDepartmentName(emp.departmentId) }}</td>
|
|
23
|
+
<td>${{ Number(emp.salary).toLocaleString() }}</td>
|
|
24
|
+
<td>
|
|
25
|
+
<button @click="emit('delete-employee', emp.id)" class="btn btn-danger">Delete</button>
|
|
26
|
+
</td>
|
|
27
|
+
</tr>
|
|
28
|
+
</tbody>
|
|
29
|
+
</table>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup>
|
|
34
|
+
const props = defineProps(['employees', 'departments'])
|
|
35
|
+
const emit = defineEmits(['delete-employee'])
|
|
36
|
+
|
|
37
|
+
const getDepartmentName = (deptId) => {
|
|
38
|
+
if (!props.departments) return `Dept #${deptId}`
|
|
39
|
+
const dept = props.departments.find((d) => String(d.id) === String(deptId))
|
|
40
|
+
return dept ? dept.name : `Dept #${deptId}`
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<style scoped>
|
|
45
|
+
.table-wrapper {
|
|
46
|
+
overflow-x: auto;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
table {
|
|
50
|
+
width: 100%;
|
|
51
|
+
border-collapse: collapse;
|
|
52
|
+
font-size: 13px;
|
|
53
|
+
margin-top: 8px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
th, td {
|
|
57
|
+
text-align: left;
|
|
58
|
+
padding: 8px 10px;
|
|
59
|
+
border-bottom: 1px solid #eeeeee;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
th {
|
|
63
|
+
background-color: #fafbfc;
|
|
64
|
+
color: #555555;
|
|
65
|
+
font-weight: 600;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.empty {
|
|
69
|
+
text-align: center;
|
|
70
|
+
color: #888888;
|
|
71
|
+
padding: 16px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.btn {
|
|
75
|
+
padding: 8px 14px;
|
|
76
|
+
border: none;
|
|
77
|
+
border-radius: 4px;
|
|
78
|
+
cursor: pointer;
|
|
79
|
+
font-size: 13px;
|
|
80
|
+
font-weight: 600;
|
|
81
|
+
transition: background-color 0.15s ease;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.btn-danger {
|
|
85
|
+
background-color: #d9383a;
|
|
86
|
+
color: #ffffff;
|
|
87
|
+
padding: 4px 8px;
|
|
88
|
+
font-size: 12px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.btn-danger:hover {
|
|
92
|
+
background-color: #b8282a;
|
|
93
|
+
}
|
|
94
|
+
</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</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",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"private": true,
|
|
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,90 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
</script>
|
|
3
|
+
|
|
4
|
+
<template>
|
|
5
|
+
<div class="app-layout">
|
|
6
|
+
<header class="app-header">
|
|
7
|
+
<div class="brand">
|
|
8
|
+
<h1>Company Portal</h1>
|
|
9
|
+
</div>
|
|
10
|
+
<nav class="nav-links">
|
|
11
|
+
<router-link to="/" class="nav-item">Dashboard</router-link>
|
|
12
|
+
<router-link to="/departments" class="nav-item">Departments</router-link>
|
|
13
|
+
<router-link to="/employees" class="nav-item">Employees</router-link>
|
|
14
|
+
<router-link to="/add-employee" class="nav-item">Add Employee</router-link>
|
|
15
|
+
</nav>
|
|
16
|
+
</header>
|
|
17
|
+
|
|
18
|
+
<main class="main-content">
|
|
19
|
+
<router-view />
|
|
20
|
+
</main>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
* {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
body {
|
|
30
|
+
margin: 0;
|
|
31
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
|
|
32
|
+
background-color: #f4f6f8;
|
|
33
|
+
color: #333333;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
36
|
+
|
|
37
|
+
<style scoped>
|
|
38
|
+
.app-layout {
|
|
39
|
+
min-height: 100vh;
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.app-header {
|
|
45
|
+
background-color: #2c3e50;
|
|
46
|
+
color: #ffffff;
|
|
47
|
+
padding: 0 24px;
|
|
48
|
+
display: flex;
|
|
49
|
+
justify-content: space-between;
|
|
50
|
+
align-items: center;
|
|
51
|
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.brand h1 {
|
|
55
|
+
font-size: 20px;
|
|
56
|
+
margin: 16px 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nav-links {
|
|
60
|
+
display: flex;
|
|
61
|
+
gap: 8px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.nav-item {
|
|
65
|
+
color: #ecf0f1;
|
|
66
|
+
text-decoration: none;
|
|
67
|
+
padding: 8px 14px;
|
|
68
|
+
border-radius: 4px;
|
|
69
|
+
font-size: 14px;
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
transition: background-color 0.2s;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.nav-item:hover {
|
|
75
|
+
background-color: #34495e;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.nav-item.router-link-exact-active {
|
|
79
|
+
background-color: #1abc9c;
|
|
80
|
+
color: #ffffff;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.main-content {
|
|
84
|
+
flex: 1;
|
|
85
|
+
max-width: 1000px;
|
|
86
|
+
width: 100%;
|
|
87
|
+
margin: 24px auto;
|
|
88
|
+
padding: 0 20px;
|
|
89
|
+
}
|
|
90
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
2
|
+
import HomeDashboardView from '../views/HomeDashboardView.vue'
|
|
3
|
+
import DepartmentView from '../views/DepartmentView.vue'
|
|
4
|
+
import EmployeeView from '../views/EmployeeView.vue'
|
|
5
|
+
import AddEmployeeView from '../views/AddEmployeeView.vue'
|
|
6
|
+
|
|
7
|
+
const routes = [
|
|
8
|
+
{ path: '/', name: 'Dashboard', component: HomeDashboardView },
|
|
9
|
+
{ path: '/departments', name: 'Departments', component: DepartmentView },
|
|
10
|
+
{ path: '/employees', name: 'Employees', component: EmployeeView },
|
|
11
|
+
{ path: '/add-employee', name: 'AddEmployee', component: AddEmployeeView }
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
const router = createRouter({
|
|
15
|
+
history: createWebHistory(),
|
|
16
|
+
routes
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
export default router
|