实验台权限、员工班级修复

dev_2022-05-11
yujialong 3 years ago
parent dbd354fe31
commit fa02e97cf7
  1. 2
      src/components/org-tree/src/tree-node.vue
  2. 2
      src/pages/station/list/index.vue
  3. 78
      src/pages/system/list/staff.vue
  4. 206
      src/pages/system/list/staffSide.vue
  5. 266
      src/pages/system/list/stafftree.vue
  6. 29
      src/router/index.js

@ -35,7 +35,7 @@
>
</span>
<el-checkbox
v-if="showCheckbox && node.data.showCheckbox"
v-if="showCheckbox"
v-model="node.checked"
:indeterminate="node.indeterminate"
:disabled="!!node.disabled"

@ -3,7 +3,7 @@
<div class="wrap">
<div class="search">
<h6>创新实验智能教学</h6>
<div class="input">
<div class="input" v-if="auth('搜索')">
<img src="@/assets/img/search.png" alt="">
<input type="text" placeholder="请输入关键词" v-model="keyword">
</div>

@ -1,7 +1,7 @@
<template>
<div class="wrap">
<div class="side">
<TeacherSide ref="getSelectData" @fircheck="fircheck" @twocheck="twocheck" @getData="initData" @delDep="delDep"></TeacherSide>
<org ref="org" @getSingle="getSingle" @getCheck="getCheck"></org>
</div>
<div class="right">
@ -122,8 +122,7 @@
<script>
import Setting from "@/setting";
import util from "@/libs/util";
import TeacherSide from "./staffSide";
import org from "./staffSide"
export default {
data() {
var accountPass = (rule, value, callback) => {
@ -224,7 +223,7 @@ export default {
};
},
components: {
TeacherSide
org
},
watch: {
keyword: function(val) {
@ -235,66 +234,29 @@ export default {
}
},
mounted() {
this.getRoleData();
this.getData();
this.getRoleData()
this.getData()
},
methods: {
removeByValue(val) {
for (var i = 0; i < this.length; i++) {
if (JSON.stringify(this[i]).indexOf(JSON.stringify(val)) != -1) {
this.splice(i, 1);
break;
}
}
},
handleCheck(data) {
let oneDepartmentIds = [];
let twoDepartmentIds = [];
getSingle(data) {
this.staffArchitectureId = data.gradeId ? '' : data.staffArchitectureId
this.gradeId = data.gradeId || ''
this.initData()
},
getCheck(data) {
const marjorIds = []
const depIds = []
data.forEach(e => {
if (e.ischeck) {
oneDepartmentIds.push(e.staffArchitectureId);
} else {
this.removeByValue(oneDepartmentIds, e.staffArchitectureId);
}
e.children.forEach(r => {
if (r.ischeck) {
twoDepartmentIds.push(r.gradeId);
} else {
this.removeByValue(twoDepartmentIds, r.gradeId);
}
});
e.gradeId ? depIds.push(e.gradeId) : marjorIds.push(e.staffArchitectureId)
});
this.staffArchitectureId = oneDepartmentIds.toString();
this.gradeId = twoDepartmentIds.toString();
this.initData();
},
fircheck(val, val2) {
val.ischeck = !val.ischeck;
val.children.map(e => e.ischeck = val.ischeck);
this.handleCheck(val2);
},
twocheck(val, val2) {
val.ischeck = !val.ischeck;
val2.map(e => {
e.children.map(r => {
if (r.gradeId == val.gradeId) {
if (e.children.every(i => i.ischeck)) {
e.ischeck = true;
} else {
e.ischeck = false;
}
}
});
});
this.handleCheck(val2);
},
delDep(val, val2) {
this.handleCheck(val2);
this.staffArchitectureId = marjorIds.toString()
this.gradeId = depIds.toString()
this.initData()
},
initData() {
this.$refs.table.clearSelection();
this.page = 1;
this.getData();
this.$refs.table.clearSelection()
this.page = 1
this.getData()
},
getData() { //
let data = {

@ -1,52 +1,83 @@
<template>
<div>
<div>
<lctree :data="majorList"
@addMajor="addMajor" @editMajor="editMajor" @delMajor="delMajor"
@addDepartment="addDepartment" @editDepartment="editDepartment" @delDepartment="delDepartment"
@fircheckitem="fircheckitem" @twocheckitem="twocheckitem"
></lctree>
<div class="flex-between m-b-20">
<h6 class="p-title" style="margin-bottom: 0">员工组织架构</h6>
<el-button type="text" @click="addMajor">添加</el-button>
</div>
<org-tree
:data="orgList"
show-checkbox
default-expand-all
ref="orgTree"
node-key="id"
highlight-current
:expand-on-click-node="false"
@node-click="getSingle"
@check="getCheck"
:props="{children: 'children', label: 'label', isLeaf: 'leaf'}"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span style="display: inline-block; margin-right: 20px">{{ node.label }}</span>
<span>
<el-button
type="text"
icon="el-icon-edit-outline"
@click="() => handleEdit(node, data)">
</el-button>
<el-button
v-if="node.level === 1"
type="text"
icon="el-icon-circle-plus-outline"
@click="() => handleAdd(node, data)">
</el-button>
<el-button
type="text"
icon="el-icon-delete"
@click="() => handleDel(node, data)">
</el-button>
</span>
</span>
</org-tree>
</div>
<el-dialog :title="Form.staffArchitectureId ? '编辑专业' : '新增专业'" :visible.sync="isaddMajor" width="24%" center @close="closeAdd" :close-on-click-modal="false">
<el-dialog :title="Form.staffArchitectureId ? '编辑专业' : '新增专业'" :visible.sync="majorVisible" width="24%" center @close="closeAdd" :close-on-click-modal="false">
<el-form ref="Form" :model="Form" :rules="rules">
<el-form-item prop="staffArchitectureName">
<el-input placeholder="请输入专业名称" v-model="Form.staffArchitectureName"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="isaddMajor = false"> </el-button>
<el-button @click="majorVisible = false"> </el-button>
<el-button type="primary" @click="sure('Form')"> </el-button>
</span>
</el-dialog>
<el-dialog :title="Form.gradeId ? '编辑部门' : '新增部门'" :visible.sync="isAddDepartment" width="24%" center @close="closeAdd" :close-on-click-modal="false">
<el-dialog :title="Form.gradeId ? '编辑部门' : '新增部门'" :visible.sync="depVisible" width="24%" center @close="closeAdd" :close-on-click-modal="false">
<el-form ref="Form" :model="Form" :rules="rules">
<el-form-item prop="gradeName">
<el-input placeholder="请输入部门名称" v-model="Form.gradeName"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="isAddDepartment = false"> </el-button>
<el-button @click="depVisible = false"> </el-button>
<el-button type="primary" @click="sureDepartment('Form')"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import Setting from "@/setting";
import util from "@/libs/util";
import lctree from "./stafftree";
import OrgTree from "@/components/org-tree/src/tree";
export default {
props: ["Data"],
data() {
return {
majorList: [],
orgList: [],
firactive: 0,
twoactive: 0,
isaddMajor: false,
isAddDepartment: false,
majorVisible: false,
depVisible: false,
Form: {
staffArchitectureId: "", // ID
staffArchitectureName: "", // //
@ -66,56 +97,47 @@ export default {
};
},
components: {
lctree
OrgTree
},
mounted() {
this.getStaff();
this.getStaff()
},
methods: {
getStaff() {
this.$get(this.api.professionalList).then(res => {
if (res.data && res.data.length) {
res.data.map(e => {
(e.ifVisible = false), (e.ischeck = false), (e.label = e.staffArchitectureName), (e.value = e.staffArchitectureId);
(e.ifVisible = false), (e.ischeck = false), (e.label = e.staffArchitectureName), (e.id = e.staffArchitectureId);
let data = {
staffArchitectureId: e.staffArchitectureId
};
}
this.$get(this.api.staffGradeList, data).then(res => {
res.data.map(e => {
(e.ischeck = false), (e.label = e.gradeName), (e.value = e.gradeId);
});
e.children = res.data;
}).catch(res => {
});
(e.ischeck = false), (e.label = e.gradeName), (e.id = e.gradeId)
})
e.children = res.data
}).catch(res => {})
});
}
setTimeout(() => {
this.majorList = res.data;
}, 500);
}).catch(res => {
});
this.orgList = res.data;
}, 500)
}).catch(res => {})
},
//
fircheckitem(item) {
this.$emit("fircheck", item, this.majorList);
closeAdd() {
this.$refs.Form.resetFields()
},
//
twocheckitem(item) {
this.$emit("twocheck", item, this.majorList);
getSingle(data) {
this.$emit('getSingle', data)
},
closeAdd() {
this.$refs.Form.resetFields();
getCheck(data, checked) {
this.$emit('getCheck', checked.checkedNodes)
},
//
addMajor() {
this.Form.staffArchitectureId = "";
this.Form.staffArchitectureName = "";
this.isaddMajor = true;
},
editMajor(item) {
this.Form.staffArchitectureId = item.staffArchitectureId;
this.Form.staffArchitectureName = item.staffArchitectureName;
this.isaddMajor = true;
this.Form.staffArchitectureId = ''
this.Form.staffArchitectureName = ''
this.majorVisible = true
},
sure(Form) { // /
this.$refs[Form].validate((valid) => {
@ -128,8 +150,8 @@ export default {
if (this.Form.staffArchitectureId) {
this.$post(this.api.updateProfessional, data).then(res => {
util.successMsg("编辑成功");
this.isaddMajor = false;
this.majorList.map(e => {
this.majorVisible = false;
this.orgList.map(e => {
if (e.staffArchitectureId == this.Form.staffArchitectureId) {
e.staffArchitectureName = this.Form.staffArchitectureName;
e.label = this.Form.staffArchitectureName;
@ -141,7 +163,7 @@ export default {
} else {
this.$post(this.api.saveProfessional, data).then(res => {
util.successMsg("添加成功");
this.isaddMajor = false;
this.majorVisible = false;
let newData = {
staffArchitectureId: res.staffArchitectureId,
staffArchitectureName: this.Form.staffArchitectureName,
@ -151,7 +173,7 @@ export default {
ischeck: false,
children: []
};
this.majorList.push(newData);
this.orgList.push(newData);
}).catch(res => {
});
}
@ -160,21 +182,26 @@ export default {
}
});
},
//
addDepartment(item) {
this.Form.gradeId = "";
this.Form.gradeName = "";
this.isAddDepartment = true;
this.Form.staffArchitectureId = item.staffArchitectureId;
handleAdd(node, data) { //
this.Form.gradeId = ''
this.Form.gradeName = ''
this.depVisible = true
this.Form.staffArchitectureId = data.staffArchitectureId
},
editDepartment(item) {
this.Form.gradeId = item.gradeId;
this.Form.gradeName = item.gradeName;
this.isAddDepartment = true;
for (let j = 0; j < this.majorList.length; j++) {
for (let k = 0; k < this.majorList[j].children.length; k++) {
if (this.majorList[j].children[k].gradeName == item.gradeName) {
this.Form.staffArchitectureId = this.majorList[j].staffArchitectureId;
handleEdit(node, data) { //
if (node.level === 1) {
this.Form.staffArchitectureId = data.staffArchitectureId
this.Form.staffArchitectureName = data.staffArchitectureName
this.majorVisible = true
} else {
this.Form.gradeId = data.gradeId
this.Form.gradeName = data.gradeName
this.depVisible = true
}
for (let j = 0; j < this.orgList.length; j++) {
for (let k = 0; k < this.orgList[j].children.length; k++) {
if (this.orgList[j].children[k].gradeName == data.gradeName) {
this.Form.staffArchitectureId = this.orgList[j].staffArchitectureId;
}
}
}
@ -190,8 +217,8 @@ export default {
if (this.Form.gradeId) {
this.$post(this.api.updateGrade, data).then(res => {
util.successMsg("编辑成功");
this.isAddDepartment = false;
this.majorList.map(e => {
this.depVisible = false;
this.orgList.map(e => {
e.children.map(r => {
if (r.gradeId == this.Form.gradeId) {
r.gradeName = this.Form.gradeName;
@ -204,7 +231,7 @@ export default {
} else {
this.$post(this.api.saveGrade, data).then(res => {
util.successMsg("添加成功");
this.isAddDepartment = false;
this.depVisible = false;
let newData = {
gradeId: res.gradeId,
gradeName: this.Form.gradeName,
@ -213,7 +240,7 @@ export default {
ifVisible: false,
ischeck: false
};
this.majorList.map(e => {
this.orgList.map(e => {
if (e.staffArchitectureId == this.Form.staffArchitectureId) {
e.ifVisible = true;
e.children.push(newData);
@ -227,45 +254,31 @@ export default {
}
});
},
delMajor(item, index) {
handleDel(node, data) {
node.level === 1 ? this.delMajor(data) : this.delDepartment(data)
},
delMajor(item) {
this.$confirm("确定要删除该专业吗?该操作将会删除该组织下的用户账号。", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.deleteProfessional}?staffArchitectureId=${item.staffArchitectureId}`).then(res => {
util.successMsg("删除成功");
this.majorList.splice(index, 1);
this.$emit("getData");
// this.$get(`${this.api.dalStaffByProfessionalId}?staffArchitectureId=${item.staffArchitectureId}`).then(res => {
// }).catch(res => {
// });
}).catch(res => {});
}).catch(() => {});
util.successMsg("删除成功")
this.$emit("getData")
this.getStaff()
}).catch(res => {})
}).catch(() => {})
},
delDepartment(item, index) {
console.log(item);
delDepartment(item) {
this.$confirm("确定要删除该部门吗?该操作将会删除该组织下的用户账号。", "提示", {
type: "warning"
}).then(() => {
this.$post(`${this.api.deleteGrade}?gradeId=${item.gradeId}`).then(res => {
util.successMsg("删除成功");
this.majorList.map(e => {
e.children.map(r => {
if (r.gradeId == item.gradeId) {
e.children.splice(index, 1);
if (e.children.length == 0) {
e.ifVisible = false;
}
}
});
});
this.$emit("delDep", item, this.majorList);
this.$emit("getData");
// this.$get(`${this.api.dalStaffByStaffGradeId}?gradeId=${item.gradeId}`).then(res => {
// }).catch(res => {
// });
}).catch(res => {
});
}).catch(() => {});
util.successMsg("删除成功")
this.getStaff()
this.$emit("delDep", item, this.orgList)
this.$emit("getData")
}).catch(res => {})
}).catch(() => {})
}
}
};
@ -275,7 +288,6 @@ export default {
height: 800px;
padding: 40px 20px;
background-color: #fff;
box-shadow: -2px 0px 57px 0px rgba(192, 189, 216, 0.39);
}
.side_icon {

@ -1,266 +0,0 @@
<template>
<div class="side_view">
<p class="side_icon mab20">
<i v-if="auth('员工管理-新增专业')" class="icon-jiahao mar20" @click="addMajor"></i>
</p>
<div class="side_tree" v-for="(item,index) in data" :key="index">
<div class="item" @click.stop="open(item,1)">
<img
v-if="item.children&&item.children.length!=0"
:class="{ 'arrowTransform': !item.ifVisible, 'arrowTransformReturn': item.ifVisible}"
src="@/assets/img/icon-xiangyou.png"
alt
/>
<i v-else class="empty"></i>
<i :class="item.ischeck ? 'icon-yigouxuan' : 'icon-weigouxuan'" @click.stop="fircheckitem(item)"></i>
<span>{{ item.label }}</span>
<svg v-if="auth('员工管理-编辑专业')" t="1604370117041" class="icon edit ft" @click.stop="editMajor(item)" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9029" width="16" height="16">
<path
d="M511.979 30.125c-266.13 0-481.871 215.741-481.871 481.871s215.741 481.871 481.871 481.871S993.85 778.126 993.85 511.996 778.109 30.125 511.979 30.125zM459.644 693.015c-15.876 18.135-22.818 22.486-44.972 30.657-34.111 12.787-96.687 36.27-137.374 51.515-7.706 3.056-36.735 1.495-24.578-27.036 13.784-39.757 34.045-98.414 45.636-131.894 8.436-23.615 11.758-29.76 28.73-45.603l175.271-175.271 124.055 124.088C626.413 519.471 508.469 642.264 459.644 693.015zM653.084 492.867 528.996 368.779l26.605-26.605 124.088 124.121L653.084 492.867zM759.469 386.482l-53.176 53.209L582.205 315.569l53.209-53.176c19.596-19.596 51.316-19.596 70.912 0l53.209 53.176C779.065 335.166 779.065 366.919 759.469 386.482z"
p-id="9030" fill="#9076ff"></path>
</svg>
<i v-if="auth('员工管理-新增部门')" class="el-icon-circle-plus ft fz" @click.stop="addDepartment(item)"></i>
<i v-if="auth('员工管理-删除专业')" class="icon-delete ft" @click.stop="delMajor(item,index)"></i>
</div>
<div v-show="item.ifVisible" v-if="item.children&&item.children.length!=0">
<div v-for="(item1,index1) in item.children" :key="index1">
<div class="item2" @click.stop="open(item1,2)">
<i :class="item1.ischeck ? 'icon-yigouxuan' : 'icon-weigouxuan'" @click.stop="twocheckitem(item1)"></i>
<span>{{ item1.label }}</span>
<svg v-if="auth('员工管理-编辑部门')" t="1604370117041" class="icon edit ft" @click.stop="editDepartment(item1)" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9029" width="16" height="16">
<path
d="M511.979 30.125c-266.13 0-481.871 215.741-481.871 481.871s215.741 481.871 481.871 481.871S993.85 778.126 993.85 511.996 778.109 30.125 511.979 30.125zM459.644 693.015c-15.876 18.135-22.818 22.486-44.972 30.657-34.111 12.787-96.687 36.27-137.374 51.515-7.706 3.056-36.735 1.495-24.578-27.036 13.784-39.757 34.045-98.414 45.636-131.894 8.436-23.615 11.758-29.76 28.73-45.603l175.271-175.271 124.055 124.088C626.413 519.471 508.469 642.264 459.644 693.015zM653.084 492.867 528.996 368.779l26.605-26.605 124.088 124.121L653.084 492.867zM759.469 386.482l-53.176 53.209L582.205 315.569l53.209-53.176c19.596-19.596 51.316-19.596 70.912 0l53.209 53.176C779.065 335.166 779.065 366.919 759.469 386.482z"
p-id="9030" fill="#9076ff"></path>
</svg>
<i v-if="auth('员工管理-删除部门')" class="icon-delete ft" @click.stop="delDepartment(item1,index1)"></i>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
Array.prototype.removeByValue = function(val) {
for (var i = 0; i < this.length; i++) {
if (JSON.stringify(this[i]).indexOf(JSON.stringify(val)) != -1) {
this.splice(i, 1);
break;
}
}
};
export default {
data() {
return {
chooseList: []
};
},
watch: {
chooseList(n, o) {
this.$emit("chooseNode", n);
}
},
props: {
data: {
type: Array
}
},
methods: {
//
open(item, type) {
item.ifVisible = !item.ifVisible;
type == 1 ? this.$emit("fircheckitem", item) : this.$emit("twocheckitem", item);
},
//removeByvaluemain.js
choose(item) {
item.ifVisible = !item.ifVisible;
if (item.ifVisible) {
this.chooseList.push(item);
} else {
this.chooseList.removeByValue(item);
}
},
fircheckitem(item) {
this.$emit("fircheckitem", item);
},
twocheckitem(item) {
this.$emit("twocheckitem", item);
},
//
addMajor() {
this.$emit("addMajor");
},
editMajor(item) {
this.$emit("editMajor", item);
},
delMajor(item, index) {
this.$emit("delMajor", item, index);
},
//
addDepartment(item) {
this.$emit("addDepartment", item);
},
editDepartment(item) {
this.$emit("editDepartment", item);
},
delDepartment(item, index) {
this.$emit("delDepartment", item, index);
},
//
addClass(item) {
this.$emit("addClass", item);
},
//
isHasObj(arr, val) {
var flag = 0; //1 0
for (var i = 0; i < arr.length; i++) {
if (JSON.stringify(arr[i]).indexOf(JSON.stringify(val)) != -1) {
flag = 1;
}
}
if (flag == 1) {
return true;
} else {
return false;
}
}
}
};
</script>
<style lang="scss" scoped>
$insideColor: rgba(245, 242, 255, 0.8); //
$outColor: rgba(255, 255, 255, 0.8); //
//,item
@mixin public {
cursor: pointer;
font-size: 18px;
color: #333333;
display: flex;
align-items: center;
img {
height: 20px;
width: 20px;
margin-left: 10px;
}
}
.main {
width: 100%;
}
.item {
@include public;
width: 100%;
padding: 15px 0;
background: rgba(255, 255, 255, 1);
box-shadow: 1px 14px 29px 0px rgba(138, 97, 250, 0.19);
border-radius: 10px;
text-align: left;
margin-top: 20px;
}
.item:first {
margin-top: 0;
}
.item .empty {
width: 20px;
}
.edit {
width: 18px !important;
height: 18px !important;
margin-left: 10px;
}
.item2 {
@include public;
margin-top: 20px;
margin-left: 60px
}
.item2:hover {
color: #9278FF;
}
//ul,li
ul,
li {
padding: 0;
margin: 0;
list-style: none;
}
// 使
.arrowTransform {
transition: 0.4s;
transform-origin: center;
transform: rotateZ(0deg);
}
.arrowTransformReturn {
transition: 0.4s;
transform-origin: center;
transform: rotateZ(90deg);
}
//
.checkBox {
width: 14px;
height: 14px;
border-radius: 7px;
margin-left: 10px;
margin-right: 10px;
border: 2px solid rgba(146, 120, 255, 1);
}
//
.isActive {
background: url('../../../assets/img/icon-yigouxuan.png');
background-size: 14px 14px;
}
.side_view {
// height: 800px;
padding: 40px 20px;
background-color: #fff;
box-shadow: -2px 0px 57px 0px rgba(192, 189, 216, 0.39);
i {
color: #9278FF;
}
}
.side_icon {
text-align: right;
}
.side_icon i {
cursor: pointer;
font-size: 20px;
}
.side_tree {
width: 100%;
font-size: 14px;
color: #333;
i {
margin-left: 10px;
}
span {
margin-left: 5px;
font-size: 14px;
}
}
.fz {
font-size: 20px;
}
</style>

@ -56,31 +56,8 @@ function getPermission() {
// 取得路由的值,使用addRouter添加进路由里
// 该项目的路由实际上做了两层处理,一层指向了默认的路由,对应模块,用于基础布局的nav,下面一层才是实际上的路由跳转,
// 所以需要默认进行赋值,实际操作时根据path去禁用掉对应的nav即可。
const arr = ['achievement','assessment','course',"evaluation",'information','match','project','setting','student','system'];
let permissionRouters = [
{
path: "/station",
name: "station",
redirect: {
name: `stationlist`
},
component: BasicLayout,
children: [
{
name: `stationlist`,
path: `/station/list`,
component: () => import("@/pages/station/list"),
meta: { title: "实验台" }
},
{
name: `stationPreview`,
path: `/station/preview`,
component: () => import("@/pages/station/preview"),
meta: { title: "实验台" }
}
]
}
]; // 最后处理好的路由数组
const arr = ['station', 'achievement','assessment','course',"evaluation",'information','match','project','setting','student','system'];
let permissionRouters = []; // 最后处理好的路由数组
let data = res.permissionMenu[0].children;
if (data.length > 0) {
@ -257,7 +234,7 @@ function getPermission() {
router.app.$options.store.commit("routers", nav);
let redirect = [{
path: "/index",
redirect: permissionRouters[0].path
redirect: permissionRouters.find(e => e.name === 'station') ? '/station' : permissionRouters[0].path
}];
router.addRoutes(redirect);
router.addRoutes(permissionRouters);

Loading…
Cancel
Save