Browse Source

tree嵌套

master
aBin 4 years ago
parent
commit
f7efeb5b24
  1. 70
      src/components/RightPage/RightPage.vue
  2. 16
      src/components/RightPage/TreeNode.vue
  3. 16
      src/components/RightPage/TreeNodeCopy.vue
  4. 12
      src/config/api.js

70
src/components/RightPage/RightPage.vue

@ -40,7 +40,13 @@
</a-form> </a-form>
{{ addId }} {{ addId }}
</a-modal> </a-modal>
<a-modal :visible="visible2" title="修改部门信息" @cancel="visible2 = false" @ok="handleOk"> </a-modal> <a-modal :visible="editDepartmentVisible" title="aaa" @cancel="editDepartmentVisible = false" @ok="editDepartment">
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-form-item label="部门名称">
<a-input v-model="departmentName" placeholder="部门名称" />
</a-form-item>
</a-form>
</a-modal>
<a-modal :visible="visible1" title="添加成员" @cancel="visible1 = false" @ok="handleOk"> <a-modal :visible="visible1" title="添加成员" @cancel="visible1 = false" @ok="handleOk">
添加成员 添加成员
{{ addId }} {{ addId }}
@ -76,14 +82,15 @@
关联角色信息 关联角色信息
{{ changeRoleId }} {{ changeRoleId }}
</a-modal> </a-modal>
<a-modal :visible="positionModal" title="修改职位信息" @cancel="positionModal = false" @ok="handleOk"> <a-modal :visible="positionModal" title="修改职位信息" @cancel="positionModal = false" @ok="editPosition">
修改职位信息 <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
<a-form-item label="职位名称">
<a-input v-model="positionName" placeholder="职位名称" />
</a-form-item>
</a-form>
<span v-if="positionInfo">{{ positionInfo.pname }}</span> <span v-if="positionInfo">{{ positionInfo.pname }}</span>
</a-modal> </a-modal>
<a-modal :visible="departmentModal" title="修改部门信息" @cancel="departmentModal = false" @ok="handleOk">
修改部门信息
<span v-if="departmentInfo">{{ departmentInfo.departmentName }}</span>
</a-modal>
<!-- 添加部门/职位 --> <!-- 添加部门/职位 -->
<a-modal :visible="visibleAddPosition" title="添加部门/职位" @cancel="visibleAddPosition = false" @ok="addPosition"> <a-modal :visible="visibleAddPosition" title="添加部门/职位" @cancel="visibleAddPosition = false" @ok="addPosition">
<a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }"> <a-form :form="form" :label-col="{ span: 5 }" :wrapper-col="{ span: 12 }">
@ -106,7 +113,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import { queryHospitalInfo, editHospitalInfo, queryHospitalById, addDepartment, addPosition } from 'config/api'; import { queryHospitalInfo, editHospitalInfo, queryHospitalById, addDepartment, addPosition, updateDepartment, updatePosition } from 'config/api';
import TreeNode from './TreeNode.vue'; import TreeNode from './TreeNode.vue';
export default { export default {
@ -126,6 +133,7 @@ export default {
positionModal: false, positionModal: false,
departmentModal: false, departmentModal: false,
visibleAddPosition: false, visibleAddPosition: false,
editDepartmentVisible: false,
addId: '', addId: '',
hospitalName: '', hospitalName: '',
areaId: [], areaId: [],
@ -158,13 +166,51 @@ export default {
// modal // modal
editDepartmentModal(item) { editDepartmentModal(item) {
this.departmentInfo = item; this.departmentInfo = item;
this.departmentModal = true; // this.departmentModal = true;
this.editDepartmentVisible = true;
this.departmentName = this.departmentInfo.departmentName;
}, },
//
async editDepartment() {
try {
const params = { param: {did: this.departmentInfo.did , departmentName: this.departmentName}};
const res = await updateDepartment(params);
const { code, msg, data} = res.data;
if (code === 200) {
this.editDepartmentVisible = false;
this.$message.success('修改成功');
this.getHospitalInfo();
}else {
this.$message.warning(msg);
}
}catch (e) {
this.$message.warning(e);
}
},
// modal // modal
editPositionModal(item) { editPositionModal(item) {
this.positionInfo = item; this.positionInfo = item;
this.positionName = this.positionInfo.pname;
this.positionModal = true; this.positionModal = true;
}, },
//
async editPosition() {
try {
const params = { param: {positionId: this.positionInfo.pid, positionName: this.positionName}};
const res = await updatePosition(params);
const {code, msg, data} = res.data;
if (code === 200) {
this.$message.success('修改成功');
this.positionModal = false;
this.getHospitalInfo();
}else {
this.$message.warning(msg)
}
}catch (e) {
this.$message.error(e);
}
},
// modal // modal
changeRole(id) { changeRole(id) {
this.changeRoleId = id; this.changeRoleId = id;
@ -185,7 +231,7 @@ export default {
this.$message.warning(msg); this.$message.warning(msg);
} }
} catch (e) { } catch (e) {
this.$message.warning(error); this.$message.warning(e);
} }
} else { } else {
try { try {
@ -200,7 +246,7 @@ export default {
this.$message.warning(msg); this.$message.warning(msg);
} }
} catch (e) { } catch (e) {
this.$message.warning(error); this.$message.warning(e);
} }
} }
}, },
@ -309,7 +355,7 @@ export default {
const res = await queryHospitalInfo(params); const res = await queryHospitalInfo(params);
const { code, msg, data } = res.data; const { code, msg, data } = res.data;
if (code === 200) { if (code === 200) {
console.log(data); // console.log(data);
this.treeData = data; this.treeData = data;
} else { } else {
console.error(msg); console.error(msg);

16
src/components/RightPage/TreeNode.vue

@ -38,7 +38,15 @@
<template slot="content"> <template slot="content">
<div class="d-flex align-center"> <div class="d-flex align-center">
<a-button type="primary" class="mr-2" @click="editPositionModal(itemA)"> 修改 </a-button> <a-button type="primary" class="mr-2" @click="editPositionModal(itemA)"> 修改 </a-button>
<a-button type="danger" @click="delPositionInfo(itemA)"> 删除 </a-button> <a-popconfirm
placement="left"
title="确定删除此数据吗?"
ok-text="删除"
cancel-text="取消"
@confirm="delPositionInfo(itemA)"
>
<a-button type="danger"> 删除 </a-button>
</a-popconfirm>
</div> </div>
</template> </template>
</a-popover> </a-popover>
@ -67,7 +75,9 @@
<template slot="content"> <template slot="content">
<div class="d-flex align-center"> <div class="d-flex align-center">
<a-button type="primary" class="mr-2" @click="editDepartmentModal(item)"> 修改 </a-button> <a-button type="primary" class="mr-2" @click="editDepartmentModal(item)"> 修改 </a-button>
<a-button type="danger" @click="delpartment(item)"> 删除 </a-button> <a-popconfirm placement="left" title="确定删除此数据吗?" ok-text="删除" cancel-text="取消" @confirm="delpartment(item)">
<a-button type="danger"> 删除 </a-button>
</a-popconfirm>
</div> </div>
</template> </template>
</a-popover> </a-popover>
@ -93,6 +103,8 @@
</template> </template>
<script> <script>
import TreeNodeCopy from './TreeNodeCopy.vue'; import TreeNodeCopy from './TreeNodeCopy.vue';
// import TreeNode from './TreeNode.vue';
import { delPosition, delDepartment } from 'config/api';
export default { export default {
name: 'TreeNode', name: 'TreeNode',

16
src/components/RightPage/TreeNodeCopy.vue

@ -38,7 +38,15 @@
<template slot="content"> <template slot="content">
<div class="d-flex align-center"> <div class="d-flex align-center">
<a-button type="primary" class="mr-2" @click="editPositionModal(itemA)"> 修改 </a-button> <a-button type="primary" class="mr-2" @click="editPositionModal(itemA)"> 修改 </a-button>
<a-button type="danger" @click="delPositionInfo(itemA)"> 删除 </a-button> <a-popconfirm
placement="left"
title="确定删除此数据吗?"
ok-text="删除"
cancel-text="取消"
@confirm="delPositionInfo(itemA)"
>
<a-button type="danger"> 删除 </a-button>
</a-popconfirm>
</div> </div>
</template> </template>
</a-popover> </a-popover>
@ -67,7 +75,9 @@
<template slot="content"> <template slot="content">
<div class="d-flex align-center"> <div class="d-flex align-center">
<a-button type="primary" class="mr-2" @click="editDepartmentModal(item)"> 修改 </a-button> <a-button type="primary" class="mr-2" @click="editDepartmentModal(item)"> 修改 </a-button>
<a-button type="danger" @click="delpartment(item)"> 删除 </a-button> <a-popconfirm placement="left" title="确定删除此数据吗?" ok-text="删除" cancel-text="取消" @confirm="delpartment(item)">
<a-button type="danger"> 删除 </a-button>
</a-popconfirm>
</div> </div>
</template> </template>
</a-popover> </a-popover>
@ -93,6 +103,8 @@
</template> </template>
<script> <script>
import TreeNode from './TreeNode.vue'; import TreeNode from './TreeNode.vue';
// import TreeNode from './TreeNode.vue';
import { delPosition, delDepartment } from 'config/api';
export default { export default {
name: 'TreeNode', name: 'TreeNode',

12
src/config/api.js

@ -33,3 +33,15 @@ export const addDepartment = params => axios.post(`${management}/addDepartment`,
//添加职位 //添加职位
export const addPosition = params => axios.post(`${management}/addPosition`, params); export const addPosition = params => axios.post(`${management}/addPosition`, params);
//修改部门
export const updateDepartment = params => axios.post(`${management}/updateDepartment`, params);
//修改职位
export const updatePosition = params => axios.post(`${management}/updatePosition`, params);
//删除部门
export const delDepartment = params => axios.post(`${management}/delDepartment`, params);
//删除职位
export const delPosition = params => axios.post(`${management}/delPosition`, params);

Loading…
Cancel
Save