wad-lab 1.1.5 → 1.1.7
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/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 +429 -405
- package/templates/vue-axios-interceptor/src/App.vue +177 -159
- package/templates/vue-axios-pinia/src/App.vue +441 -427
- 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 +191 -167
- package/templates/vue-axios-props-emits/src/components/DepartmentForm.vue +98 -98
- package/templates/vue-axios-props-emits/src/components/DepartmentList.vue +92 -91
- package/templates/vue-axios-props-emits/src/components/EmployeeForm.vue +128 -128
- package/templates/vue-axios-props-emits/src/components/EmployeeList.vue +95 -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 +296 -273
- package/templates/vue-axios-router/src/views/EmployeeView.vue +219 -196
- package/templates/vue-axios-router/src/views/HomeDashboardView.vue +263 -263
- 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/App.vue +59 -59
- 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,167 +1,191 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="container">
|
|
3
|
-
<header class="header">
|
|
4
|
-
<h1>Company Directory</h1>
|
|
5
|
-
<p>Vue 3 + Axios + Props & Emits</p>
|
|
6
|
-
</header>
|
|
7
|
-
|
|
8
|
-
<div class="grid">
|
|
9
|
-
<section class="card">
|
|
10
|
-
<h2>Departments</h2>
|
|
11
|
-
<DepartmentForm @create-department="createDepartment" />
|
|
12
|
-
<DepartmentList
|
|
13
|
-
:departments="departments"
|
|
14
|
-
@delete-department="deleteDepartment"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
</
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
await
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
font-size:
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container">
|
|
3
|
+
<header class="header">
|
|
4
|
+
<h1>Company Directory</h1>
|
|
5
|
+
<p>Vue 3 + Axios + Props & Emits</p>
|
|
6
|
+
</header>
|
|
7
|
+
|
|
8
|
+
<div class="grid">
|
|
9
|
+
<section class="card">
|
|
10
|
+
<h2>Departments</h2>
|
|
11
|
+
<DepartmentForm @create-department="createDepartment" />
|
|
12
|
+
<DepartmentList
|
|
13
|
+
:departments="departments"
|
|
14
|
+
@delete-department="deleteDepartment"
|
|
15
|
+
@patch-department="patchDepartment"
|
|
16
|
+
/>
|
|
17
|
+
</section>
|
|
18
|
+
|
|
19
|
+
<section class="card">
|
|
20
|
+
<h2>Employees</h2>
|
|
21
|
+
<EmployeeForm
|
|
22
|
+
:departments="departments"
|
|
23
|
+
@create-employee="createEmployee"
|
|
24
|
+
/>
|
|
25
|
+
<EmployeeList
|
|
26
|
+
:employees="employees"
|
|
27
|
+
:departments="departments"
|
|
28
|
+
@delete-employee="deleteEmployee"
|
|
29
|
+
@patch-employee="patchEmployee"
|
|
30
|
+
/>
|
|
31
|
+
</section>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup>
|
|
37
|
+
import { ref, onMounted } from 'vue'
|
|
38
|
+
import api from './services/api'
|
|
39
|
+
import DepartmentList from './components/DepartmentList.vue'
|
|
40
|
+
import DepartmentForm from './components/DepartmentForm.vue'
|
|
41
|
+
import EmployeeList from './components/EmployeeList.vue'
|
|
42
|
+
import EmployeeForm from './components/EmployeeForm.vue'
|
|
43
|
+
|
|
44
|
+
const departments = ref([])
|
|
45
|
+
const employees = ref([])
|
|
46
|
+
|
|
47
|
+
const fetchDepartments = async () => {
|
|
48
|
+
try {
|
|
49
|
+
const response = await api.get('/departments')
|
|
50
|
+
departments.value = response.data
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error(error)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const fetchEmployees = async () => {
|
|
57
|
+
try {
|
|
58
|
+
const response = await api.get('/employees')
|
|
59
|
+
employees.value = response.data
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error(error)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const createDepartment = async (departmentData) => {
|
|
66
|
+
try {
|
|
67
|
+
await api.post('/departments', departmentData)
|
|
68
|
+
await fetchDepartments()
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error(error)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const deleteDepartment = async (id) => {
|
|
75
|
+
try {
|
|
76
|
+
await api.delete(`/departments/${id}`)
|
|
77
|
+
await fetchDepartments()
|
|
78
|
+
await fetchEmployees()
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const createEmployee = async (employeeData) => {
|
|
85
|
+
try {
|
|
86
|
+
await api.post('/employees', employeeData)
|
|
87
|
+
await fetchEmployees()
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error(error)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const deleteEmployee = async (id) => {
|
|
94
|
+
try {
|
|
95
|
+
await api.delete(`/employees/${id}`)
|
|
96
|
+
await fetchEmployees()
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error(error)
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const patchDepartment = async (id, currentCode) => {
|
|
103
|
+
const code = prompt('Enter new department code:', currentCode)
|
|
104
|
+
if (!code || code === currentCode) return
|
|
105
|
+
try {
|
|
106
|
+
await api.patch(`/departments/${id}`, { code })
|
|
107
|
+
await fetchDepartments()
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error(error)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const patchEmployee = async (id, currentSalary) => {
|
|
114
|
+
const salary = prompt('Enter new salary:', currentSalary)
|
|
115
|
+
if (!salary || Number(salary) === Number(currentSalary)) return
|
|
116
|
+
try {
|
|
117
|
+
await api.patch(`/employees/${id}`, { salary: Number(salary) })
|
|
118
|
+
await fetchEmployees()
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(error)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
onMounted(() => {
|
|
125
|
+
fetchDepartments()
|
|
126
|
+
fetchEmployees()
|
|
127
|
+
})
|
|
128
|
+
</script>
|
|
129
|
+
|
|
130
|
+
<style>
|
|
131
|
+
* {
|
|
132
|
+
box-sizing: border-box;
|
|
133
|
+
margin: 0;
|
|
134
|
+
padding: 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
body {
|
|
138
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
139
|
+
background-color: #f4f5f7;
|
|
140
|
+
color: #333333;
|
|
141
|
+
line-height: 1.5;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.container {
|
|
145
|
+
max-width: 1200px;
|
|
146
|
+
margin: 0 auto;
|
|
147
|
+
padding: 32px 16px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.header {
|
|
151
|
+
margin-bottom: 24px;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.header h1 {
|
|
155
|
+
font-size: 28px;
|
|
156
|
+
color: #1a1a1a;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.header p {
|
|
160
|
+
color: #666666;
|
|
161
|
+
font-size: 14px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.grid {
|
|
165
|
+
display: grid;
|
|
166
|
+
grid-template-columns: 1fr;
|
|
167
|
+
gap: 24px;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@media (min-width: 900px) {
|
|
171
|
+
.grid {
|
|
172
|
+
grid-template-columns: 1fr 1fr;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.card {
|
|
177
|
+
background: #ffffff;
|
|
178
|
+
border: 1px solid #e1e4e8;
|
|
179
|
+
border-radius: 8px;
|
|
180
|
+
padding: 20px;
|
|
181
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.card h2 {
|
|
185
|
+
font-size: 20px;
|
|
186
|
+
margin-bottom: 16px;
|
|
187
|
+
color: #222222;
|
|
188
|
+
border-bottom: 1px solid #edf0f2;
|
|
189
|
+
padding-bottom: 8px;
|
|
190
|
+
}
|
|
191
|
+
</style>
|
|
@@ -1,98 +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>
|
|
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>
|