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,91 +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>
|
|
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>
|
|
@@ -1,128 +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>
|
|
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>
|
|
@@ -1,94 +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>
|
|
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>
|