這次新增一個部門管理功能到人員管理下
這邊做一些重點部分的講解
I am going to add a department management functionality
and just explain some key points.
source code 在此
1. 在 /module 下 增加 dbDepartment.js
subDep 欄位先留著,這次還沒要實做子部門的功能
Add dbDepartment.js under /module
I will keep implementation of subDep for next time.
2. 和之前一樣,部門也會需要 add/delete/modify 的功能
寫法和員工管理差不多,這邊不多做講解
要注意的地方是,部門的資料和員工的資料是有連動關係的
例如,當部門更改名稱,則也要把更改套用到該部門下的全體員工
Department management also needs add/delete/modify functionalities and the
implementation is similar to employee management.
Therefore, I won't talk about the implementation here.
One thing to notice is that the department's data are connected with employee's data.
For example, when you modified the name of department, the modification should
also be applied to all employees in that department.
3. 因為當資料有變動後,要把最新資料再傳回給 client 端
實做過程中發現,因為 mongoose 有 async 的特性
所以在 create、save、remove 的操作上,若是要確保動作完成後再傳回資料
可以使用 promise
The server need to send back the latest data whenever data are changed.
Because mongoose is async, I used promise to ensure that sever send back the
latest data.
ref: link1、link2
4. 在頁面設計上,使用了 angular-material 的 tab 來實做
詳細可看此處
I used the tab functionality of angular-material for the page design.
You can check the details here.
沒有留言:
張貼留言