当前位置:网站首页>Department management of cloud e-office projects
Department management of cloud e-office projects
2022-07-27 05:42:00 【Real code slag】
List of articles
cloud E do — Department of management
One 、 Show all departments
1. Background interface and data format
Address of the interface :/employee/basic/department/
Request mode :GET
Request parameters : nothing
Return data format :
[
{
"id": 1,
"name": " Shareholders' meeting ",
"parentId": -1,
"depPath": ".1",
"enabled": true,
"isParent": true,
"children": [
···
],
"result": null
}
]
2. Use Element-ui Medium Tree Tree control
<el-input
placeholder=" Enter the Department name to search "
v-model="filterText">
</el-input>
<el-tree
:data="departments"
:props="defaultProps"
:filter-node-method="filterNode"
ref="tree">
</el-tree>
<script>
export default {
watch: {
filterText(val) {
this.$refs.tree.filter(val);
}
},
methods: {
filterNode(value, data) {
if (!value) return true;
return data.name.indexOf(value) !== -1;
}
},
data() {
return {
filterText: '',
departments:[],
defaultProps: {
children: 'children',
label: 'name'
}
};
}
};
</script>
3. Initialize department information
initDepartments(){
this.getRequest(' Address of the interface ').then(response=>{
if(response.code === 200){
this.departments = response.data;
}
})
}
Two 、 Add Department
1. Background interface and data format
Address of the interface :/employee/basic/department/
Request mode :POST
Request parameters :
{
"name": "",
"parentId": 0
}
Return the data :
{
"code": ,
"data": {},
"message": "",
"success": true
}
2. Use Dialog Dialog implementation
dialogVisible:true,// Whether the dialog box is displayed , The default is true
When you click Add , The dialog box binding shows the name of the superior department .
After adding a department , The tree control does not collapse , Manually load the added Department :
// Display the newly added Department on the tree control , There is no need to refresh the functions of the whole department
addDepToDeps(departments, department) {
for (let i = 0; i < departments.length; i++) {
let d = departments[i];
if (d.id === departments.parentId) {
if (d.children === null) d.children = [];
d.children = d.children.concat(department);
return;
} else {
// recursive
this.addDepToDeps(d.children, department);
}
}
}
3、 ... and 、 Delete Department
1. Background interface and data format
Address of the interface :/employee/basic/department/{id}
Request mode :DELETE
Request parameters :
id
Return the data :
{
"code": ,
"data": {},
"message": "",
"success": true
}
2. Delete manually
When deleting the current department, you need to first determine whether it is the parent department , If it is , Pop up and delete failed ; If not , Then send a request to delete .
Manually refresh the Department list :
// Manually refresh the entire Department list
removeDepartmentFromDepartments(p, deps, id) {
for (let i = 0; i < deps.length; i++) {
let d = deps[i];
if (d.id === id) {
// Delete the entire department object
deps.splice(i, 1);
// Judge whether it is the parent department , If not , Set up isParent by false
if (deps.length === 0) {
p.isParent = false;
}
return;
} else {
// recursive
this.removeDepartmentFromDepartments(d, d.children, id);
}
}
},
summary
- Use Element-ui Medium Tree Tree control and Dialog Dialog box
- When adding and deleting departments , Save its parent department id, Manual display department , Traverse the currently added or deleted departments .
- When adding or deleting manually , Although the background data is requested ,isParent The attribute value has changed , But no request was sent , I do not know! isParent by false, It needs to be judged manually , That is, when the current department has no sub departments , Set up isParent=fasle.
边栏推荐
- 自我理解思考
- Share a multiple-choice question about variables (including global variables, local variables, the scope of variables, and life cycle knowledge points)
- MOVE PROTOCOL推出测试版,更可“0撸”参与P2E
- JS中&&(与)和||(或)操作符的返回值
- Package JWT
- M-DAO 7大赋能方案,助力DAO生态走向模式与标准化
- How JS determines whether an object belongs to a class
- js中isNaN和Number.isNaN的区别
- 「PHP基础知识」PHP语句和语句块
- Introduction of C language base conversion and original complement inverse code point operation
猜你喜欢

Prototype and prototype chain in JS

JS中原型及原型链

「PHP基础知识」布尔型的使用

一文读懂Elephant Swap的LaaS方案的优势之处

DeFi 2.0的LaaS协议Elephant,或许是你熊市下为数不多的获利手段

Permission display - dynamic list on the left

C language string function: strlen, strcpy, strcat

「PHP基础知识」PHP中实现数学运算

First knowledge of C language - why does every C program have a main function

NFT新范式,OKALEIDO创新NFT聚合交易生态
随机推荐
「PHP基础知识」PHP语句和语句块
一本通1319——排队接水
XXE&XML 漏洞
[BJDCTF2020]EasySearch 1
弹性盒/伸缩盒(flex)的使用
自我理解思考
JS中是如何使用for..of来遍历对象
MOVE PROTOCOL推出测试版,更可“0撸”参与P2E
JS中&&(与)和||(或)操作符的返回值
维持登录,路由跳转
My first blog
Maintain login and route jump
JS中apply、call、bind的区别
「PHP基础知识」PHP中的标记
Ubuntu:安装PostgreSQL
User page management
Elment UI usage
sql_mode严格模式(ANSI/TRADITIONAL/STRICT_TRANS_TABLES)
dirsearch[目录扫描工具]
JS==操作符的强制类型转换规定