提交 4c9dbcca 编写于 作者: lzlhxj's avatar lzlhxj

统一代码注释

上级 835b2d2f
<template>
<div class="design-tree-container">
<context-menu-container>
<el-input size="small" placeholder="搜索..." v-model="filerText" @input="filterChange">
<el-input
size="small"
placeholder="搜索..."
v-model="filerText"
@input="filterChange"
>
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
<el-tree
......@@ -17,10 +22,18 @@
:props="this.defaultProps"
@node-click="handleNodeClick"
>
<span class="custom-tree-node" slot-scope="{node, data}">
<i v-if="node.isLeaf" class="fa fa-building-o" style="margin-right: 2px;"></i>
<i v-if="!node.isLeaf" class="fa fa-building" style="margin-right: 2px;"></i>
<span>{{node.label}}</span>
<span class="custom-tree-node" slot-scope="{ node, data }">
<i
v-if="node.isLeaf"
class="fa fa-building-o"
style="margin-right: 2px"
></i>
<i
v-if="!node.isLeaf"
class="fa fa-building"
style="margin-right: 2px"
></i>
<span>{{ node.label }}</span>
</span>
</el-tree>
</context-menu-container>
......@@ -28,48 +41,80 @@
</template>
<script lang='tsx'>
import {Component, Vue} from 'vue-property-decorator';
import { Component, Vue } from "vue-property-decorator";
@Component({
components: {}
})
export default class DeptTree extends Vue {
@Component({
components: {},
})
export default class DeptTree extends Vue {
/**
* 过滤文本
*
* @type {string}
* @memberof DeptTree
*/
public filerText: string = "";
// 过滤文本
public filerText: any = '';
/**
* 过滤节点
*
* @param {string} value 过滤文本
* @param {*} data 树数据
* @memberof DeptTree
*/
public filterNode(value:any,data:any){
public filterNode(value: string, data: any) {
if (!value) return true;
return data.label.indexOf(value) !==-1;
return data.label.indexOf(value) !== -1;
}
/**
* 树搜索触发
* 树搜索触发
*
* @memberof DeptTree
*/
public filterChange(){
const DeptTree:any = this.$refs.DeptTree;
public filterChange() {
const DeptTree: any = this.$refs.DeptTree;
DeptTree.filter(this.filerText);
}
/*树数据*/
public TreeData: any = [];
/**
* 树数据
*
* @type {Array<*>}
* @memberof DeptTree
*/
public TreeData: Array<any> = [];
/*树显示说明:子树为节点对象的children,节点标签为节点对象的label*/
/**
* 树显示说明:子树为节点对象的children,节点标签为节点对象的label
*
* @type {*}
* @memberof DeptTree
*/
public defaultProps: any = {
children: 'children',
label: 'label'
}
children: "children",
label: "label",
};
/*默认展开节点*/
public defaultExpandedKeys: any = [];
/**
* 默认展开节点
* @type {Array<*>}
* @memberof DeptTree
*/
public defaultExpandedKeys: Array<any> = [];
/*当前登录人信息*/
/**
* 当前登录人信息
*
* @type {*}
* @memberof DeptTree
*/
public curUserContext: any = {};
/**
* vue 创建
*
* @memberof DeptTree
*/
public created() {
var _this: any = this;
......@@ -81,6 +126,8 @@
/**
* vue 挂载
*
* @memberof DeptTree
*/
public mounted() {
this.initTree();
......@@ -88,54 +135,63 @@
/**
* 初始化树
*
* @memberof DeptTree
*/
private initTree() {
const _this = this;
// 获取当前登录人的身份
const userStr = localStorage.getItem('user');
const userStr = localStorage.getItem("user");
let user: any = {};
if (userStr) {
user = JSON.parse(userStr);
}
// 获取当前登录人所处组织的部门及下级组织的部门
let url = '';
let url: string = "";
// 判断是否超级用户
if (user.superuser==1) {
if (user.superuser == 1) {
// 获取所有组织的部门及下级组织的部门
url = 'sysorganizations/alls/suborg/sysdepartments/picker';
}else {
url = "sysorganizations/alls/suborg/sysdepartments/picker";
} else {
// 获取当前登录人所在组织的部门及下级组织的部门
if (_this.curUserContext && _this.curUserContext.srforgid) {
url = 'sysorganizations/' + _this.curUserContext.srforgid + '/suborg/sysdepartments/picker';
}else {
this.$Notice.error({title: '错误', desc: '当前登录人组织为空'});
url =
"sysorganizations/" +
_this.curUserContext.srforgid +
"/suborg/sysdepartments/picker";
} else {
this.$Notice.error({ title: "错误", desc: "当前登录人组织为空" });
}
}
this.$http.get(url).then((response: any) => {
this.$http
.get(url)
.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({title: '错误', desc: response.message});
this.$Notice.error({ title: "错误", desc: response.message });
return;
} else {
// 给树赋值,数据结构在后台已经按照eltree格式化
_this.TreeData = response.data;
if (response.data && response.data.length > 0) {
// 设置默认选中第一个节点,即高亮显示
this.$nextTick(function(){
let deptTree:any = this.$refs.DeptTree;
this.$nextTick(function () {
let deptTree: any = this.$refs.DeptTree;
deptTree.setCurrentKey(response.data[0].id);
})
});
// 默认加载第一个节点的右侧视图,调用选中数据变更事件
_this.selectionChange(response.data[0]);
}
}
}).catch((e:any) => {
})
.catch((e: any) => {
console.log(e);
});
}
/**
* 处理点击节点
*
* @memberof DeptTree
*/
protected handleNodeClick() {
// 获取当前树
......@@ -143,7 +199,7 @@
// 获取点击状态的节点
let node = DeptTree.getCurrentNode();
// console.log("选中的node:" + JSON.stringify(node));
// if (node.isLeaf && node.isLeaf == true)
// 选中数据变更事件
this.selectionChange(node);
}
......@@ -151,20 +207,21 @@
/**
* 选中数据变更事件
*
* @public
* @param {*} node 节点对应node对象
* @memberof OrgTree
* @param {*} 节点对应node对象
* @memberof DeptTree
*/
public selectionChange(node: any) {
// 获取右侧视图渲染数据需要的参数
let temp = JSON.parse(JSON.stringify(node));
let srfappctx: any = {};
if (node.disabled == true) {// 单位
if (node.disabled == true) {
// 单位
temp.id = "Dept;" + node.id;
temp.srfparentdename = "SysOrganization";
temp.sysorganization = node.id;
srfappctx.sysorganization = temp.sysorganization;
}else {// 部门
} else {
// 部门
temp.id = "Dept;" + node.id;
temp.srfparentdename = "SysDepartment";
temp.sysdepartment = node.id;
......@@ -178,11 +235,10 @@
temp.srfappctx = srfappctx;
// 抛出参数
let selectiondata: any = [temp];
this.$emit('selectionchange', selectiondata);
}
this.$emit("selectionchange", selectiondata);
}
}
</script>
<style lang='less'>
@import './dept-tree-treeview.less';
@import "./dept-tree-treeview.less";
</style>
\ No newline at end of file
<template>
<div class="design-tree-container">
<context-menu-container>
<el-input size="small" placeholder="搜索..." v-model="filerText" @input="filterChange">
<el-input
size="small"
placeholder="搜索..."
v-model="filerText"
@input="filterChange"
>
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
<el-tree
......@@ -17,10 +22,18 @@
:props="this.defaultProps"
@node-click="handleNodeClick"
>
<span class="custom-tree-node" slot-scope="{node, data}">
<i v-if="node.isLeaf" class="fa fa-building-o" style="margin-right: 2px;"></i>
<i v-if="!node.isLeaf" class="fa fa-building" style="margin-right: 2px;"></i>
<span>{{node.label}}</span>
<span class="custom-tree-node" slot-scope="{ node, data }">
<i
v-if="node.isLeaf"
class="fa fa-building-o"
style="margin-right: 2px"
></i>
<i
v-if="!node.isLeaf"
class="fa fa-building"
style="margin-right: 2px"
></i>
<span>{{ node.label }}</span>
</span>
</el-tree>
</context-menu-container>
......@@ -28,48 +41,81 @@
</template>
<script lang='tsx'>
import {Component, Vue} from 'vue-property-decorator';
import { Component, Vue } from "vue-property-decorator";
@Component({
components: {}
})
export default class OrgTree extends Vue {
@Component({
components: {},
})
export default class OrgTree extends Vue {
/**
* 过滤文本
*
* @type {string}
* @memberof OrgTree
*/
public filerText: string = "";
// 过滤文本
public filerText: any = '';
/**
* 过滤节点
*
* @param {string} value 过滤文本
* @param {*} data 树数据
* @memberof OrgTree
*/
public filterNode(value:any,data:any){
public filterNode(value: string, data: any) {
if (!value) return true;
return data.label.indexOf(value) !==-1;
return data.label.indexOf(value) !== -1;
}
/**
* 树搜索触发
* 树搜索触发
*
* @memberof OrgTree
*/
public filterChange(){
const OrgTree:any = this.$refs.OrgTree;
public filterChange() {
const OrgTree: any = this.$refs.OrgTree;
OrgTree.filter(this.filerText);
}
/*树数据*/
public TreeData: any = [];
/**
* 树数据
*
* @type {Array<*>}
* @memberof OrgTree
*/
public TreeData: Array<any> = [];
/*树显示说明:子树为节点对象的children,节点标签为节点对象的label*/
/**
* 树显示说明:子树为节点对象的children,节点标签为节点对象的label
*
* @type {*}
* @memberof OrgTree
*/
public defaultProps: any = {
children: 'children',
label: 'label'
}
children: "children",
label: "label",
};
/*默认展开节点*/
public defaultExpandedKeys: any = [];
/**
* 默认展开节点
*
* @type {Array<*>}
* @memberof OrgTree
*/
public defaultExpandedKeys: Array<any> = [];
/*当前登录人信息*/
/**
* 当前登录人信息
*
* @type {*}
* @memberof OrgTree
*/
public curUserContext: any = {};
/**
* vue 创建
*
* @memberof OrgTree
*/
public created() {
var _this: any = this;
......@@ -81,6 +127,8 @@
/**
* vue 挂载
*
* @memberof OrgTree
*/
public mounted() {
this.initTree();
......@@ -88,53 +136,62 @@
/**
* 初始化树
*
* @memberof OrgTree
*/
private initTree() {
const _this = this;
// 获取当前登录人的身份
const userStr = localStorage.getItem('user');
const userStr = localStorage.getItem("user");
let user: any = {};
if (userStr) {
user = JSON.parse(userStr);
}
// 获取当前登录人所处组织及其下级组织
let url = '';
if (user.superuser==1) {
let url: string = "";
if (user.superuser == 1) {
// 获取所有组织
url = 'sysorganizations/alls/suborg/picker';
}else {
url = "sysorganizations/alls/suborg/picker";
} else {
if (_this.curUserContext && _this.curUserContext.srforgid) {
url = 'sysorganizations/' + _this.curUserContext.srforgid + '/suborg/picker';
url =
"sysorganizations/" +
_this.curUserContext.srforgid +
"/suborg/picker";
} else {
this.$Notice.error({title: '错误', desc: '当前登录人组织为空'});
this.$Notice.error({ title: "错误", desc: "当前登录人组织为空" });
}
}
this.$http.get(url).then((response: any) => {
this.$http
.get(url)
.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({title: '错误', desc: response.message});
this.$Notice.error({ title: "错误", desc: response.message });
return;
} else {
// 给树赋值,数据结构在后台已经按照eltree格式化
_this.TreeData = response.data;
if (response.data && response.data.length > 0) {
// 设置默认选中第一个节点,即高亮显示
this.$nextTick(function(){
let orgTree:any = this.$refs.OrgTree;
this.$nextTick(function () {
let orgTree: any = this.$refs.OrgTree;
orgTree.setCurrentKey(response.data[0].id);
})
});
// 默认加载第一个节点的右侧视图,调用选中数据变更事件
_this.selectionChange(response.data[0]);
}
}
}).catch((e:any) => {
})
.catch((e: any) => {
console.log(e);
});
}
/**
* 处理点击节点
*
* @memberof OrgTree
*/
protected handleNodeClick() {
// 获取当前树
......@@ -142,7 +199,7 @@
// 获取点击状态的节点
let node = OrgTree.getCurrentNode();
// console.log("选中的node:" + JSON.stringify(node));
// if (node.isLeaf && node.isLeaf == true)
// 选中数据变更事件
this.selectionChange(node);
}
......@@ -150,7 +207,6 @@
/**
* 选中数据变更事件
*
* @public
* @param {*} node 节点对应node对象
* @memberof OrgTree
*/
......@@ -169,13 +225,12 @@
temp.srfappctx = srfappctx;
// 抛出参数
let selectiondata: any = [temp];
this.$emit('selectionchange', selectiondata);
}
this.$emit("selectionchange", selectiondata);
}
}
</script>
<style lang='less'>
@import './org-tree-treeview.less';
@import "./org-tree-treeview.less";
</style>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册