wad-lab 1.2.2 → 1.2.4
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 +477 -627
- package/package.json +1 -1
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/App.vue +241 -429
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-basic/src/components/ItemTable.vue +177 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/App.vue +150 -441
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemStats.vue +64 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-pinia/src/components/ItemTable.vue +195 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/App.vue +41 -90
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemFormModal.vue +173 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/ItemTable.vue +102 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/components/NavBar.vue +57 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue +132 -296
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/EmployeeView.vue +126 -219
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/ItemTable.vue +104 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/components/SideBar.vue +59 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/App.vue +19 -70
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
- package/templates/fullstack-springboot-vue/frontend/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
- package/templates/game-bingo/script.js +1 -1
- package/templates/game-memory-cards/script.js +2 -2
- package/templates/game-rock-paper-scissors/index.html +3 -3
- package/templates/game-rock-paper-scissors/script.js +2 -2
- package/templates/game-tic-tac-toe/script.js +2 -2
- package/templates/game-whack-a-mole/index.html +9 -9
- package/templates/servlet-basic/WEB-INF/ItemServlet.java +13 -0
- package/templates/servlet-basic/WEB-INF/classes/ItemServlet.class +0 -0
- package/templates/servlet-flow/WEB-INF/HelloServlet.java +34 -25
- package/templates/servlet-flow/WEB-INF/classes/HelloServlet.class +0 -0
- package/templates/servlet-jdbc/WEB-INF/JdbcItemServlet.java +13 -0
- package/templates/servlet-jdbc/WEB-INF/classes/JdbcItemServlet.class +0 -0
- package/templates/snippets/mongo-queries-cheatsheet.txt +105 -0
- package/templates/springboot-2model-aggregation-join/.mvn/wrapper/maven-wrapper.properties +3 -0
- package/templates/springboot-2model-aggregation-join/mvnw +295 -0
- package/templates/springboot-2model-aggregation-join/mvnw.cmd +189 -0
- package/templates/springboot-2model-aggregation-join/pom.xml +54 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/AggregationApplication.java +11 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/DepartmentController.java +65 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/controller/EmployeeController.java +65 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/DepartmentStatsDTO.java +15 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/dto/EmployeeJoinDTO.java +19 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Department.java +20 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/model/Employee.java +21 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/DepartmentRepository.java +9 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/repository/EmployeeRepository.java +9 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/DepartmentService.java +81 -0
- package/templates/springboot-2model-aggregation-join/src/main/java/com/example/aggregation/service/EmployeeService.java +80 -0
- package/templates/springboot-2model-aggregation-join/src/main/resources/application.properties +2 -0
- package/templates/springboot-2model-aggregation-join/src/test/java/com/example/aggregation/AggregationApplicationTests.java +13 -0
- package/templates/vue-2model-crud-patch/README.md +64 -0
- package/templates/vue-2model-crud-patch/index.html +12 -0
- package/templates/vue-2model-crud-patch/package-lock.json +1785 -0
- package/templates/vue-2model-crud-patch/package.json +21 -0
- package/templates/vue-2model-crud-patch/src/App.vue +63 -0
- package/templates/vue-2model-crud-patch/src/components/AnalyticsBoard.vue +291 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentFormModal.vue +138 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentPatchModal.vue +210 -0
- package/templates/vue-2model-crud-patch/src/components/DepartmentTable.vue +133 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeeFormModal.vue +177 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeePatchModal.vue +221 -0
- package/templates/vue-2model-crud-patch/src/components/EmployeeTable.vue +171 -0
- package/templates/vue-2model-crud-patch/src/components/NavBar.vue +156 -0
- package/templates/vue-2model-crud-patch/src/main.js +12 -0
- package/templates/vue-2model-crud-patch/src/router/index.js +33 -0
- package/templates/vue-2model-crud-patch/src/services/api.js +64 -0
- package/templates/vue-2model-crud-patch/src/stores/departmentStore.js +149 -0
- package/templates/vue-2model-crud-patch/src/stores/employeeStore.js +143 -0
- package/templates/vue-2model-crud-patch/src/style.css +415 -0
- package/templates/vue-2model-crud-patch/src/views/AnalyticsView.vue +59 -0
- package/templates/vue-2model-crud-patch/src/views/DepartmentsView.vue +135 -0
- package/templates/vue-2model-crud-patch/src/views/EmployeesView.vue +143 -0
- package/templates/vue-2model-crud-patch/vite.config.js +9 -0
- package/templates/vue-axios/src/App.vue +255 -264
- package/templates/vue-axios/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-axios/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-axios/src/components/ItemTable.vue +177 -0
- package/templates/vue-axios-basic/src/App.vue +241 -429
- package/templates/vue-axios-basic/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-axios-basic/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-axios-basic/src/components/ItemTable.vue +177 -0
- package/templates/vue-axios-pinia/src/App.vue +150 -441
- package/templates/vue-axios-pinia/src/components/ItemFormModal.vue +207 -0
- package/templates/vue-axios-pinia/src/components/ItemStats.vue +64 -0
- package/templates/vue-axios-pinia/src/components/ItemTable.vue +195 -0
- package/templates/vue-axios-router/src/App.vue +41 -90
- package/templates/vue-axios-router/src/components/ItemFormModal.vue +173 -0
- package/templates/vue-axios-router/src/components/ItemTable.vue +102 -0
- package/templates/vue-axios-router/src/components/NavBar.vue +57 -0
- package/templates/vue-axios-router/src/views/DepartmentView.vue +132 -296
- package/templates/vue-axios-router/src/views/EmployeeView.vue +126 -219
- package/templates/vue-axios-router-children/src/components/ItemDetail.vue +115 -0
- package/templates/vue-axios-router-children/src/components/ItemTable.vue +104 -0
- package/templates/vue-axios-router-children/src/components/SideBar.vue +59 -0
- package/templates/vue-axios-router-children/src/views/CompanyLayout.vue +2 -51
- package/templates/vue-axios-router-children/src/views/DepartmentListView.vue +92 -250
- package/templates/vue-axios-router-children/src/views/EmployeeDetailView.vue +59 -181
- package/templates/vue-axios-router-children/src/views/EmployeeListView.vue +67 -315
- package/templates/vue-axios-router-pinia/src/App.vue +19 -70
- package/templates/vue-axios-router-pinia/src/components/ItemFormModal.vue +173 -0
- package/templates/vue-axios-router-pinia/src/components/ItemPatchModal.vue +144 -0
- package/templates/vue-axios-router-pinia/src/components/ItemTable.vue +102 -0
- package/templates/vue-axios-router-pinia/src/components/NavBar.vue +53 -0
- package/templates/vue-axios-router-pinia/src/views/DepartmentView.vue +107 -229
- package/templates/vue-axios-router-pinia/src/views/EmployeeView.vue +143 -257
- package/templates/vue-banking-app/src/components/AccountOverview.vue +75 -0
- package/templates/vue-banking-app/src/components/TransactionForm.vue +89 -0
- package/templates/vue-banking-app/src/components/TransactionTable.vue +113 -0
- package/templates/vue-banking-app/src/stores/bankStore.js +16 -3
- package/templates/vue-banking-app/src/views/DashboardView.vue +23 -71
- package/templates/vue-banking-app/src/views/StatementView.vue +11 -158
- package/templates/vue-banking-app/src/views/TransactionFormView.vue +23 -121
- package/templates/vue-basics/src/App.vue +105 -76
- package/templates/vue-basics/src/components/CounterCard.vue +107 -0
- package/templates/vue-basics/src/components/ItemList.vue +99 -0
- package/templates/vue-basics/src/components/UserForm.vue +138 -0
- package/templates/vue-cart-router-pinia/src/components/CartSummary.vue +139 -0
- package/templates/vue-cart-router-pinia/src/components/CheckoutModal.vue +149 -0
- package/templates/vue-cart-router-pinia/src/components/ProductCard.vue +63 -0
- package/templates/vue-cart-router-pinia/src/stores/cartStore.js +11 -0
- package/templates/vue-cart-router-pinia/src/views/CartView.vue +52 -118
- package/templates/vue-cart-router-pinia/src/views/CheckoutView.vue +2 -5
- package/templates/vue-cart-router-pinia/src/views/ProductCatalogView.vue +20 -56
- package/templates/vue-employee-system/src/App.vue +75 -344
- package/templates/vue-employee-system/src/components/DepartmentFilter.vue +108 -0
- package/templates/vue-employee-system/src/components/EmployeeModal.vue +183 -0
- package/templates/vue-employee-system/src/components/EmployeeTable.vue +91 -0
- package/templates/vue-employee-system/src/stores/employeeStore.js +12 -0
- package/templates/vue-fetch/src/App.vue +261 -285
- package/templates/vue-fetch/src/components/FetchFormModal.vue +183 -0
- package/templates/vue-fetch/src/components/FetchPatchModal.vue +193 -0
- package/templates/vue-fetch/src/components/FetchTable.vue +177 -0
- package/templates/vue-food-ordering/src/components/CartSummary.vue +134 -0
- package/templates/vue-food-ordering/src/components/FoodMenu.vue +126 -0
- package/templates/vue-food-ordering/src/components/OrderModal.vue +150 -0
- package/templates/vue-food-ordering/src/views/MenuView.vue +11 -132
- package/templates/vue-food-ordering/src/views/OrderCartView.vue +31 -164
- package/templates/vue-game-rps/src/App.vue +29 -88
- package/templates/vue-game-tictactoe/src/App.vue +23 -53
- package/templates/vue-game-whackamole/src/App.vue +44 -63
- package/templates/vue-hospital-portal/src/components/AppointmentForm.vue +144 -0
- package/templates/vue-hospital-portal/src/components/DoctorCard.vue +73 -0
- package/templates/vue-hospital-portal/src/components/PatientTable.vue +123 -0
- package/templates/vue-hospital-portal/src/stores/hospitalStore.js +10 -1
- package/templates/vue-hospital-portal/src/views/OPDRegistrationView.vue +40 -416
- package/templates/vue-hospital-portal/src/views/PatientListView.vue +11 -301
- package/templates/vue-library-system/src/components/BookForm.vue +125 -0
- package/templates/vue-library-system/src/components/BookTable.vue +112 -0
- package/templates/vue-library-system/src/components/BorrowModal.vue +131 -0
- package/templates/vue-library-system/src/stores/libraryStore.js +26 -1
- package/templates/vue-library-system/src/views/BookCatalogView.vue +34 -415
- package/templates/vue-memory-game/src/App.vue +36 -40
- package/templates/vue-memory-game/src/stores/memoryStore.js +32 -37
- package/templates/vue-router/src/App.vue +24 -14
- package/templates/vue-router/src/components/AboutCard.vue +38 -0
- package/templates/vue-router/src/components/HomeHero.vue +75 -0
- package/templates/vue-router/src/components/NavBar.vue +54 -0
- package/templates/vue-router/src/views/ItemsLayout.vue +17 -9
- package/templates/vue-router/src/views/ListView.vue +106 -18
- package/templates/vue-router-pinia/src/App.vue +24 -14
- package/templates/vue-router-pinia/src/components/ItemFormModal.vue +163 -0
- package/templates/vue-router-pinia/src/components/ItemTable.vue +90 -0
- package/templates/vue-router-pinia/src/components/NavBar.vue +54 -0
- package/templates/vue-router-pinia/src/stores/itemStore.js +8 -1
- package/templates/vue-router-pinia/src/views/ListView.vue +78 -14
- package/templates/vue-router-pinia-springboot/frontend/src/App.vue +25 -8
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/ItemTable.vue +177 -0
- package/templates/vue-router-pinia-springboot/frontend/src/components/NavBar.vue +54 -0
- package/templates/vue-router-pinia-springboot/frontend/src/views/ListView.vue +92 -76
- package/templates/vue-springboot-mongo-aggregation/frontend/src/App.vue +184 -193
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/AnalyticsCards.vue +56 -0
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/CategorySummaryTable.vue +71 -0
- package/templates/vue-springboot-mongo-aggregation/frontend/src/components/ItemTable.vue +114 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/App.vue +228 -158
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemFormModal.vue +183 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemPatchModal.vue +193 -0
- package/templates/vue-springboot-mongo-crud/frontend/src/components/ItemTable.vue +177 -0
- package/templates/vue-symposium-system/src/App.vue +41 -256
- package/templates/vue-symposium-system/src/components/AttendeeTable.vue +100 -0
- package/templates/vue-symposium-system/src/components/EventCard.vue +67 -0
- package/templates/vue-symposium-system/src/components/RegistrationForm.vue +118 -0
- package/templates/vue-symposium-system/src/stores/symposiumStore.js +10 -0
- package/templates/vue-todo-pinia/src/App.vue +40 -138
- package/templates/vue-todo-pinia/src/components/TodoFilter.vue +74 -0
- package/templates/vue-todo-pinia/src/components/TodoInput.vue +53 -0
- package/templates/vue-todo-pinia/src/components/TodoList.vue +101 -0
- package/templates/vue-todo-pinia/src/stores/todoStore.js +6 -0
- package/templates/vue-todo-router/src/App.vue +5 -36
- package/templates/vue-todo-router/src/components/TodoForm.vue +78 -0
- package/templates/vue-todo-router/src/components/TodoList.vue +84 -0
- package/templates/vue-todo-router/src/components/TodoNavBar.vue +47 -0
- package/templates/vue-todo-router/src/data/todoState.js +7 -0
- package/templates/vue-todo-router/src/views/AddTodoView.vue +7 -66
- package/templates/vue-todo-router/src/views/TodoDetailView.vue +15 -1
- package/templates/vue-todo-router/src/views/TodoListView.vue +22 -64
package/templates/fullstack-springboot-vue/frontend/vue-axios-router/src/views/DepartmentView.vue
CHANGED
|
@@ -1,296 +1,132 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import { ref,
|
|
3
|
-
import api from '../services/api'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
await
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function
|
|
47
|
-
const code = prompt('Enter new department code:',
|
|
48
|
-
if (!code || code ===
|
|
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
|
-
|
|
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
|
-
<button
|
|
134
|
-
@click="handlePatchDepartment(dept.id, dept.code)"
|
|
135
|
-
class="btn"
|
|
136
|
-
:disabled="loading"
|
|
137
|
-
>
|
|
138
|
-
Patch
|
|
139
|
-
</button>
|
|
140
|
-
|
|
141
|
-
<button
|
|
142
|
-
@click="handleDeleteDepartment(dept.id)"
|
|
143
|
-
class="btn danger"
|
|
144
|
-
:disabled="loading"
|
|
145
|
-
>
|
|
146
|
-
Delete
|
|
147
|
-
</button>
|
|
148
|
-
</td>
|
|
149
|
-
</tr>
|
|
150
|
-
</tbody>
|
|
151
|
-
</table>
|
|
152
|
-
<p v-else class="empty-text">No departments found.</p>
|
|
153
|
-
</div>
|
|
154
|
-
</div>
|
|
155
|
-
</template>
|
|
156
|
-
|
|
157
|
-
<style scoped>
|
|
158
|
-
.department-view {
|
|
159
|
-
display: flex;
|
|
160
|
-
flex-direction: column;
|
|
161
|
-
gap: 20px;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
h2 {
|
|
165
|
-
margin: 0;
|
|
166
|
-
color: #2c3e50;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
.card {
|
|
170
|
-
background: #ffffff;
|
|
171
|
-
border: 1px solid #ddd;
|
|
172
|
-
border-radius: 6px;
|
|
173
|
-
padding: 18px;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.card h3 {
|
|
177
|
-
margin: 0 0 14px 0;
|
|
178
|
-
font-size: 16px;
|
|
179
|
-
color: #2c3e50;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.dept-form {
|
|
183
|
-
display: flex;
|
|
184
|
-
flex-wrap: wrap;
|
|
185
|
-
gap: 12px;
|
|
186
|
-
align-items: flex-end;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.form-group {
|
|
190
|
-
display: flex;
|
|
191
|
-
flex-direction: column;
|
|
192
|
-
gap: 4px;
|
|
193
|
-
flex: 1;
|
|
194
|
-
min-width: 180px;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
label {
|
|
198
|
-
font-size: 13px;
|
|
199
|
-
font-weight: bold;
|
|
200
|
-
color: #555;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
input {
|
|
204
|
-
padding: 8px 10px;
|
|
205
|
-
border: 1px solid #ccc;
|
|
206
|
-
border-radius: 4px;
|
|
207
|
-
font-size: 14px;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
input:focus {
|
|
211
|
-
outline: none;
|
|
212
|
-
border-color: #3498db;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
.btn {
|
|
216
|
-
padding: 8px 16px;
|
|
217
|
-
border: none;
|
|
218
|
-
border-radius: 4px;
|
|
219
|
-
font-size: 14px;
|
|
220
|
-
cursor: pointer;
|
|
221
|
-
font-weight: bold;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
.btn:disabled {
|
|
225
|
-
opacity: 0.6;
|
|
226
|
-
cursor: not-allowed;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.btn.primary {
|
|
230
|
-
background: #27ae60;
|
|
231
|
-
color: #fff;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
.btn.primary:hover:not(:disabled) {
|
|
235
|
-
background: #219150;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.btn.danger {
|
|
239
|
-
background: #e74c3c;
|
|
240
|
-
color: #fff;
|
|
241
|
-
padding: 5px 10px;
|
|
242
|
-
font-size: 12px;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.btn.danger:hover:not(:disabled) {
|
|
246
|
-
background: #c0392b;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.data-table {
|
|
250
|
-
width: 100%;
|
|
251
|
-
border-collapse: collapse;
|
|
252
|
-
margin-top: 10px;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
.data-table th,
|
|
256
|
-
.data-table td {
|
|
257
|
-
padding: 10px 12px;
|
|
258
|
-
text-align: left;
|
|
259
|
-
border-bottom: 1px solid #eee;
|
|
260
|
-
font-size: 14px;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.data-table th {
|
|
264
|
-
background: #f8f9fa;
|
|
265
|
-
color: #555;
|
|
266
|
-
font-weight: 600;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
.badge {
|
|
270
|
-
background: #ecf0f1;
|
|
271
|
-
color: #2c3e50;
|
|
272
|
-
padding: 2px 6px;
|
|
273
|
-
border-radius: 3px;
|
|
274
|
-
font-size: 12px;
|
|
275
|
-
font-family: monospace;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
.state-msg {
|
|
279
|
-
padding: 10px;
|
|
280
|
-
background-color: #f8f9fa;
|
|
281
|
-
border: 1px solid #ddd;
|
|
282
|
-
border-radius: 4px;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.state-msg.error {
|
|
286
|
-
background-color: #fde8e8;
|
|
287
|
-
color: #c0392b;
|
|
288
|
-
border-color: #f5c6cb;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
.empty-text {
|
|
292
|
-
color: #7f8c8d;
|
|
293
|
-
font-size: 14px;
|
|
294
|
-
margin: 10px 0 0 0;
|
|
295
|
-
}
|
|
296
|
-
</style>
|
|
1
|
+
<script setup>
|
|
2
|
+
import { ref, onMounted } from 'vue'
|
|
3
|
+
import api from '../services/api'
|
|
4
|
+
import ItemTable from '../components/ItemTable.vue'
|
|
5
|
+
import ItemFormModal from '../components/ItemFormModal.vue'
|
|
6
|
+
|
|
7
|
+
const departments = ref([])
|
|
8
|
+
const loading = ref(false)
|
|
9
|
+
const errorMessage = ref('')
|
|
10
|
+
const isModalOpen = ref(false)
|
|
11
|
+
|
|
12
|
+
const columns = [
|
|
13
|
+
{ key: 'id', label: 'ID' },
|
|
14
|
+
{ key: 'name', label: 'Department Name' },
|
|
15
|
+
{ key: 'code', label: 'Code' }
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const formFields = [
|
|
19
|
+
{ key: 'name', label: 'Department Name', required: true, placeholder: 'e.g. Finance' },
|
|
20
|
+
{ key: 'code', label: 'Department Code', required: true, placeholder: 'e.g. FIN' }
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
async function fetchDepartments() {
|
|
24
|
+
loading.value = true
|
|
25
|
+
errorMessage.value = ''
|
|
26
|
+
try {
|
|
27
|
+
const res = await api.get('/departments')
|
|
28
|
+
departments.value = res.data || []
|
|
29
|
+
} catch (err) {
|
|
30
|
+
errorMessage.value = err.message || 'Failed to fetch departments'
|
|
31
|
+
} finally {
|
|
32
|
+
loading.value = false
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function handleCreate(data) {
|
|
37
|
+
try {
|
|
38
|
+
await api.post('/departments', data)
|
|
39
|
+
isModalOpen.value = false
|
|
40
|
+
await fetchDepartments()
|
|
41
|
+
} catch (err) {
|
|
42
|
+
alert(err.message || 'Failed to create department')
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function handlePatch(dept) {
|
|
47
|
+
const code = prompt('Enter new department code:', dept.code)
|
|
48
|
+
if (!code || code === dept.code) return
|
|
49
|
+
try {
|
|
50
|
+
await api.patch('/departments/' + dept.id, { code })
|
|
51
|
+
await fetchDepartments()
|
|
52
|
+
} catch (err) {
|
|
53
|
+
alert(err.message || 'Failed to patch department')
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function handleDelete(id) {
|
|
58
|
+
if (!confirm('Delete this department?')) return
|
|
59
|
+
try {
|
|
60
|
+
await api.delete('/departments/' + id)
|
|
61
|
+
await fetchDepartments()
|
|
62
|
+
} catch (err) {
|
|
63
|
+
alert(err.message || 'Failed to delete department')
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onMounted(() => {
|
|
68
|
+
fetchDepartments()
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<div class="view-container">
|
|
74
|
+
<div class="view-header">
|
|
75
|
+
<h2>Department Directory</h2>
|
|
76
|
+
<button type="button" class="btn btn-primary" @click="isModalOpen = true">Add Department</button>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div v-if="errorMessage" class="error-msg">{{ errorMessage }}</div>
|
|
80
|
+
|
|
81
|
+
<ItemTable
|
|
82
|
+
:columns="columns"
|
|
83
|
+
:items="departments"
|
|
84
|
+
:loading="loading"
|
|
85
|
+
@patch="handlePatch"
|
|
86
|
+
@delete="handleDelete"
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
<ItemFormModal
|
|
90
|
+
:show="isModalOpen"
|
|
91
|
+
title="Add New Department"
|
|
92
|
+
:fields="formFields"
|
|
93
|
+
@close="isModalOpen = false"
|
|
94
|
+
@submit="handleCreate"
|
|
95
|
+
/>
|
|
96
|
+
</div>
|
|
97
|
+
</template>
|
|
98
|
+
|
|
99
|
+
<style scoped>
|
|
100
|
+
.view-container {
|
|
101
|
+
display: flex;
|
|
102
|
+
flex-direction: column;
|
|
103
|
+
gap: 16px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.view-header {
|
|
107
|
+
display: flex;
|
|
108
|
+
justify-content: space-between;
|
|
109
|
+
align-items: center;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.view-header h2 {
|
|
113
|
+
font-size: 20px;
|
|
114
|
+
color: #1e293b;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.error-msg {
|
|
118
|
+
background: #fee2e2;
|
|
119
|
+
color: #991b1b;
|
|
120
|
+
padding: 10px 14px;
|
|
121
|
+
border-radius: 6px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.btn-primary {
|
|
125
|
+
background: #0969da;
|
|
126
|
+
color: #fff;
|
|
127
|
+
border: none;
|
|
128
|
+
padding: 8px 14px;
|
|
129
|
+
border-radius: 6px;
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
}
|
|
132
|
+
</style>
|