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

统一代码注释

上级 835b2d2f
......@@ -6,28 +6,69 @@
trigger="click"
width="400"
@show="initTabCnt"
@hide="initTabCnt">
@hide="initTabCnt"
>
<el-tabs :value="default_tab_pane" :stretch="true">
<!-- 待办 -->
<el-tab-pane :label="myTasks.length==0?myTasksLabel:(myTasksLabel+'('+myTasks.length+')')" name="first" style="height: 300px; overflow: auto" :draggable="false">
<template v-for="(myTask,index) in myTasks">
<el-tab-pane
:label="
myTasks.length == 0
? myTasksLabel
: myTasksLabel + '(' + myTasks.length + ')'
"
name="first"
style="height: 300px; overflow: auto"
:draggable="false"
>
<template v-for="(myTask, index) in myTasks">
<template v-if="index < taskShowCnt">
<el-row class="Row" :key="index" :draggable="false">
<el-col :span="3" class="column1" :draggable="false">
<el-avatar icon="el-icon-s-check" size="small" :draggable="false" style="color: white;background-color: #409eff;"></el-avatar>
<el-avatar
icon="el-icon-s-check"
size="small"
:draggable="false"
style="color: white; background-color: #409eff"
></el-avatar>
</el-col>
<el-col :span="21" class="column2" :draggable="false">
<el-row :draggable="false">
<el-col :span="16" :draggable="false" style="width: 65%;">
<div class="process-definition-name" :draggable="false"><strong>{{myTask.processDefinitionName}}</strong></div>
<div class="description" :draggable="false">{{myTask.description}}</div>
<div class="createtime" :draggable="false">{{ formatDate(myTask.createTime, 'MM-DD hh:mm') }}</div>
<el-col :span="16" :draggable="false" style="width: 65%">
<div class="process-definition-name" :draggable="false">
<strong>{{ myTask.processDefinitionName }}</strong>
</div>
<div class="description" :draggable="false">
{{ myTask.description }}
</div>
<div class="createtime" :draggable="false">
{{ formatDate(myTask.createTime, "MM-DD hh:mm") }}
</div>
</el-col>
<el-col :span="5" :draggable="false" style='display: flex; align-items: center'>
<el-tag :type="myTask.name.indexOf('驳回')!=-1?'danger':(myTask.name.indexOf('成功')!=-1?'success':(myTask.name.indexOf('取消')!=-1?'info':'-'))"
size="small" @click="handleTag(myTask)"
style="cursor: pointer;overflow: hidden;text-overflow: ellipsis;" :draggable="false">
{{myTask.name}}
<el-col
:span="5"
:draggable="false"
style="display: flex; align-items: center"
>
<el-tag
:type="
myTask.name.indexOf('驳回') != -1
? 'danger'
: myTask.name.indexOf('成功') != -1
? 'success'
: myTask.name.indexOf('取消') != -1
? 'info'
: '-'
"
size="small"
@click="handleTag(myTask)"
style="
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
"
:draggable="false"
>
{{ myTask.name }}
</el-tag>
</el-col>
</el-row>
......@@ -36,32 +77,76 @@
</template>
</template>
<template>
<div class='show-more' @click="showMore('taskShowCnt')">
<label v-if="taskShowCnt < myTasks.length ">{{ this.$t('components.appMessagePopover.loadMore') }}</label>
<label v-else>{{ this.$t('components.appMessagePopover.noMore') }}</label>
<div class="show-more" @click="showMore('taskShowCnt')">
<label v-if="taskShowCnt < myTasks.length">{{
this.$t("components.appMessagePopover.loadMore")
}}</label>
<label v-else>{{
this.$t("components.appMessagePopover.noMore")
}}</label>
</div>
</template>
</el-tab-pane>
<!-- 消息 -->
<el-tab-pane :label="myMsgs.length==0?myMsgsLabel:(myMsgsLabel+'('+myMsgs.length+')')" name="second" :style="{height: '300px',overflow: 'auto'}" :draggable="false">
<template v-for="(myMsg,index) in myMsgs">
<el-tab-pane
:label="
myMsgs.length == 0
? myMsgsLabel
: myMsgsLabel + '(' + myMsgs.length + ')'
"
name="second"
:style="{ height: '300px', overflow: 'auto' }"
:draggable="false"
>
<template v-for="(myMsg, index) in myMsgs">
<template v-if="index < msgShowCnt">
<el-row class="Row" :key="index" :draggable="false">
<el-col :span="3" class="column1" :draggable="false">
<el-avatar icon="el-icon-chat-dot-square" size="small" :draggable="false" style="color: white;background-color: orange;"></el-avatar>
<el-avatar
icon="el-icon-chat-dot-square"
size="small"
:draggable="false"
style="color: white; background-color: orange"
></el-avatar>
</el-col>
<el-col :span="21" class="column2" :draggable="false">
<el-row :draggable="false">
<el-col :span="16" :draggable="false" style="width: 65%;">
<div class="process-definition-name" :draggable="false"><strong>{{myMsg.processDefinitionName}}</strong></div>
<div class="description" :draggable="false">{{myMsg.description}}</div>
<div class="createtime" :draggable="false">{{ formatDate(myMsg.createTime, 'MM-DD hh:mm') }}</div>
<el-col :span="16" :draggable="false" style="width: 65%">
<div class="process-definition-name" :draggable="false">
<strong>{{ myMsg.processDefinitionName }}</strong>
</div>
<div class="description" :draggable="false">
{{ myMsg.description }}
</div>
<div class="createtime" :draggable="false">
{{ formatDate(myMsg.createTime, "MM-DD hh:mm") }}
</div>
</el-col>
<el-col :span="5" :draggable="false" style='display: flex; align-items: center'>
<el-tag :type="myMsg.name.indexOf('驳回')!=-1?'danger':(myMsg.name.indexOf('成功')!=-1?'success':(myMsg.name.indexOf('取消')!=-1?'info':'-'))"
size="small" @click="handleTag(myMsg)"
style="cursor: pointer;overflow: hidden;text-overflow: ellipsis;" :draggable="false">
{{myMsg.name}}
<el-col
:span="5"
:draggable="false"
style="display: flex; align-items: center"
>
<el-tag
:type="
myMsg.name.indexOf('驳回') != -1
? 'danger'
: myMsg.name.indexOf('成功') != -1
? 'success'
: myMsg.name.indexOf('取消') != -1
? 'info'
: '-'
"
size="small"
@click="handleTag(myMsg)"
style="
cursor: pointer;
overflow: hidden;
text-overflow: ellipsis;
"
:draggable="false"
>
{{ myMsg.name }}
</el-tag>
</el-col>
</el-row>
......@@ -70,62 +155,115 @@
</template>
</template>
<template>
<div class='show-more' @click="showMore('msgShowCnt')">
<label v-if="msgShowCnt < myTasks.length ">{{ this.$t('components.appMessagePopover.loadMore') }}</label>
<label v-else>{{ this.$t('components.appMessagePopover.noMore') }}</label>
<div class="show-more" @click="showMore('msgShowCnt')">
<label v-if="msgShowCnt < myTasks.length">{{
this.$t("components.appMessagePopover.loadMore")
}}</label>
<label v-else>{{
this.$t("components.appMessagePopover.noMore")
}}</label>
</div>
</template>
</el-tab-pane>
</el-tabs>
<i id="bellBtn" size="20" slot="reference" class='el-icon-bell'></i>
<i id="bellBtn" size="20" slot="reference" class="el-icon-bell"></i>
</el-popover>
</el-badge>
<!-- 消息弹出框绘制结束 -->
</template>
<script lang="ts">
import {Vue, Component, Prop, Model, Emit} from "vue-property-decorator";
import {Subject} from "rxjs";
import {Environment} from '@/environments/environment';
import moment from 'moment';
@Component({})
export default class AppMessagePopover extends Vue {
// 是否显示小圆点
public showIsDot: any = false;
// 默认显示的tab页
public default_tab_pane: any = "first";
// 待办列表
public myTasks: any = [];
// 待办面板标签
public myTasksLabel: any = "待办";
// 待办面板显示条数
public taskShowCnt:number = 0;
// 消息列表
public myMsgs: any = [];
// 消息面板标签
public myMsgsLabel: any = "消息";
// 信息面板显示条数
public msgShowCnt:number = 0;
import { Vue, Component, Prop, Model, Emit } from "vue-property-decorator";
import { Subject } from "rxjs";
import { Environment } from "@/environments/environment";
import moment from "moment";
@Component({})
export default class AppMessagePopover extends Vue {
/**
* 是否显示小圆点
*
* @type {boolean}
* @memberof AppMessagePopover
*/
public showIsDot: boolean = false;
/**
* 默认显示的tab页
*
* @type {string}
* @memberof AppMessagePopover
*/
public default_tab_pane: string = "first";
/**
* 待办列表
*
* @type {Array<*>}
* @memberof AppMessagePopover
*/
public myTasks: Array<any> = [];
/**
* 待办面板标签
*
* @type {string}
* @memberof AppMessagePopover
*/
public myTasksLabel: string = "待办";
/**
* 待办面板显示条数
*
* @type {number}
* @memberof AppMessagePopover
*/
public taskShowCnt: number = 0;
/**
* 消息列表
* @type {Array<*>}
* @memberof AppMessagePopover
*/
public myMsgs: Array<any> = [];
/**
* 消息面板标签
*
* @type {string}
* @memberof AppMessagePopover
*/
public myMsgsLabel: string = "消息";
/**
* 信息面板显示条数
*
* @type {number}
* @memberof AppMessagePopover
*/
public msgShowCnt: number = 0;
/**
* vue创建
*
* @memberof AppMessagePopover
*/
created(): void {}
/**
* vue挂载
*
* @memberof AppMessagePopover
*/
mounted(): void {
// 首次获取待办列表
this.getMyTasks();
// 定时器:每隔1分钟重新获取待办列表
const timer = setInterval(()=>{
const timer = setInterval(() => {
this.getMyTasks();
},60000);
}, 60000);
// 监听定时器,在vue销毁前清除定时器
this.$once('hook:beforeDestroy',()=>{
this.$once("hook:beforeDestroy", () => {
// 清除定时器
clearInterval(timer);
});
......@@ -133,10 +271,14 @@
/**
* 获取待办列表
*
* @memberof AppMessagePopover
*/
public getMyTasks() {
let url: any = '/wfcore/mytasks';
this.$http.get(url).then((response: any) => {
let url: any = "/wfcore/mytasks";
this.$http
.get(url)
.then((response: any) => {
if (response && response.status == 200) {
const data: any = response.data;
if (data && data.length > 0) {
......@@ -148,15 +290,18 @@
// 获取消息列表
this.getMyMsgs();
}
}).catch((error: any) => {
console.warn("加载数据错误");
})
.catch((error: any) => {
console.warn("加载数据错误");
});
}
/**
* 获取消息列表
*
* @memberof AppMessagePopover
*/
public getMyMsgs(){
public getMyMsgs() {
// TODO:接口获取消息列表,这里用的待办数据
this.myMsgs = this.myTasks;
if (this.myMsgs.length > 0 && this.myTasks.length == 0) {
......@@ -167,18 +312,24 @@
/**
* 点击标签事件
*
* @memberof AppMessagePopover
*/
public handleTag(data: any) {
if (!data) return this.$message.error("未获取到标签内容");
// 拼接要打开的窗口地址
const baseUrl:any = Environment.BaseUrl;
const openUrl:any = baseUrl + `/wfcore/mytasks/${data.processDefinitionKey}/web/${data.processInstanceBusinessKey}/usertasks/${data.taskDefinitionKey}`;
const baseUrl: any = Environment.BaseUrl;
const openUrl: any =
baseUrl +
`/wfcore/mytasks/${data.processDefinitionKey}/web/${data.processInstanceBusinessKey}/usertasks/${data.taskDefinitionKey}`;
// 打开新窗口
window.open(openUrl,'_blank');
window.open(openUrl, "_blank");
}
/**
* 销毁之前
* vue销毁之前
*
* @memberof AppMessagePopover
*/
beforeDestroy(): void {
// 清空数据
......@@ -189,9 +340,11 @@
/**
* 时间格式转换
*
* @memberof AppMessagePopover
*/
public formatDate(date: string, format: string) {
if(date && format) {
if (date && format) {
return moment(date).format(format);
}
return date;
......@@ -199,27 +352,34 @@
/**
* 加载更多
*
* @memberof AppMessagePopover
*/
public showMore(cnt: string) {
if(Object.is('taskShowCnt', cnt)) {
this.taskShowCnt + 10 < this.myTasks.length ? this.taskShowCnt += 10 : this.taskShowCnt += this.myTasks.length-this.taskShowCnt;
if (Object.is("taskShowCnt", cnt)) {
this.taskShowCnt + 10 < this.myTasks.length
? (this.taskShowCnt += 10)
: (this.taskShowCnt += this.myTasks.length - this.taskShowCnt);
}
if(Object.is('msgShowCnt', cnt)) {
this.msgShowCnt + 10 < this.myMsgs.length ? this.msgShowCnt += 10 : this.msgShowCnt += this.myMsgs.length-this.msgShowCnt;
if (Object.is("msgShowCnt", cnt)) {
this.msgShowCnt + 10 < this.myMsgs.length
? (this.msgShowCnt += 10)
: (this.msgShowCnt += this.myMsgs.length - this.msgShowCnt);
}
}
/**
* 弹出框 显示/隐藏 时显示条数初始化
*
* @memberof AppMessagePopover
*/
public initTabCnt() {
this.taskShowCnt = this.myTasks.length >= 10 ? 10 : this.myTasks.length;
this.msgShowCnt = this.myMsgs.length >= 10 ? 10 : this.myMsgs.length;
}
}
}
</script>
<style lang='less'>
@import "app-message-popover.less";
@import "app-message-popover.less";
</style>
\ No newline at end of file
<template>
<div class="view-container dempickupview sys-permissionmpickup-view view-permissionmp-center">
<card class='view-card view-no-caption view-no-toolbar' :dis-hover="true" :padding="0" :bordered="false">
<div
class="view-container dempickupview sys-permissionmpickup-view view-permissionmp-center"
>
<card
class="view-card view-no-caption view-no-toolbar"
:dis-hover="true"
:padding="0"
:bordered="false"
>
<div class="content-container pickup-view">
<div class="translate-contant">
<!--应用菜单-->
<div class="center" :style="{width : '33%',border:'1px solid #dcdee2', margin: '0 16px 0 0'}">
<context-menu-container class='design-tree-container'>
<div
class="center"
:style="{
width: '33%',
border: '1px solid #dcdee2',
margin: '0 16px 0 0',
}"
>
<context-menu-container class="design-tree-container">
<div>
<div style="margin: 20px 20px 0 20px;">
<el-input size="small" placeholder="搜索应用菜单..." v-model="CDtreefilterText" @input="filterChangeCDtree">
<div style="margin: 20px 20px 0 20px">
<el-input
size="small"
placeholder="搜索应用菜单..."
v-model="CDtreefilterText"
@input="filterChangeCDtree"
>
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
</div>
......@@ -32,11 +51,23 @@
</context-menu-container>
</div>
<!--数据能力-->
<div class="center" :style="{width : '33%',border:'1px solid #dcdee2', margin: '0 16px 0 0' }">
<context-menu-container class='design-tree-container'>
<div
class="center"
:style="{
width: '33%',
border: '1px solid #dcdee2',
margin: '0 16px 0 0',
}"
>
<context-menu-container class="design-tree-container">
<div>
<div style="margin: 20px 20px 0 20px;">
<el-input size="small" placeholder="搜索数据能力..." v-model="QXtreefilterText" @input="filterChangeQXtree">
<div style="margin: 20px 20px 0 20px">
<el-input
size="small"
placeholder="搜索数据能力..."
v-model="QXtreefilterText"
@input="filterChangeQXtree"
>
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
</div>
......@@ -60,11 +91,19 @@
</context-menu-container>
</div>
<!--自定义资源-->
<div class="center" :style="{width : '33%',border:'1px solid #dcdee2' }">
<context-menu-container class='design-tree-container'>
<div
class="center"
:style="{ width: '33%', border: '1px solid #dcdee2' }"
>
<context-menu-container class="design-tree-container">
<div>
<div style="margin: 20px 20px 0 20px;">
<el-input size="small" placeholder="搜索自定义资源..." v-model="ZYtreefilterText" @input="filterChangeZYtree">
<div style="margin: 20px 20px 0 20px">
<el-input
size="small"
placeholder="搜索自定义资源..."
v-model="ZYtreefilterText"
@input="filterChangeZYtree"
>
<i slot="prefix" class="el-input__icon el-icon-search"></i>
</el-input>
</div>
......@@ -88,112 +127,202 @@
</context-menu-container>
</div>
</div>
</div>
</card>
</div>
</template>
<script lang='tsx'>
import {Component, Prop, Vue} from 'vue-property-decorator';
import view_pickupviewpanel
from '@widgets/sys-permission/mpickup-viewpickupviewpanel-pickupviewpanel/mpickup-viewpickupviewpanel-pickupviewpanel.vue';
import ContextMenuContainer from "@components/context-menu-container/context-menu-container.vue";
import {Subject} from "rxjs";
import { Component, Prop, Vue } from "vue-property-decorator";
import view_pickupviewpanel from "@widgets/sys-permission/mpickup-viewpickupviewpanel-pickupviewpanel/mpickup-viewpickupviewpanel-pickupviewpanel.vue";
import ContextMenuContainer from "@components/context-menu-container/context-menu-container.vue";
import { Subject } from "rxjs";
@Component({
@Component({
components: {
ContextMenuContainer,
view_pickupviewpanel,
},
beforeRouteEnter: (to: any, from: any, next: any) => {
next((vm: any) => {
vm.$store.commit('addCurPageViewtag', {fullPath: to.fullPath, viewtag: vm.viewtag});
vm.$store.commit("addCurPageViewtag", {
fullPath: to.fullPath,
viewtag: vm.viewtag,
});
});
},
})
export default class SYS_ROLE_PERMISSIONCustomView extends Vue {
})
export default class SYS_ROLE_PERMISSIONCustomView extends Vue {
/**
* 应用菜单树搜索文本
*
* @type {string}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public CDtreefilterText: string = "";
/**
* 数据能力树搜索文本
*
* @type {string}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public QXtreefilterText: string = "";
// 应用菜单树搜索文本
public CDtreefilterText:any = '';
// 数据能力树搜索文本
public QXtreefilterText:any = '';
// 自定义资源树搜索文本
public ZYtreefilterText:any = '';
/**
* 自定义资源树搜索文本
*
* @type {string}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public ZYtreefilterText: string = "";
/**
* 过滤节点
*
* @param {value={string}}
* @param {data={*}}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public fiterNode(value:any,data:any){
public fiterNode(value: string, data: any) {
if (!value) return true;
return data.label.indexOf(value) !==-1;
return data.label.indexOf(value) !== -1;
}
/**
* 应用菜单树搜索触发
* 应用菜单树搜索触发
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public filterChangeCDtree(){
const CDtree:any = this.$refs.CDtree;
public filterChangeCDtree() {
const CDtree: any = this.$refs.CDtree;
CDtree.filter(this.CDtreefilterText);
}
/**
* 数据能力树搜索触发
* 数据能力树搜索触发
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public filterChangeQXtree(){
const QXtree:any = this.$refs.QXtree;
public filterChangeQXtree() {
const QXtree: any = this.$refs.QXtree;
QXtree.filter(this.QXtreefilterText);
}
/**
* 自定义资源树搜索触发
* 自定义资源树搜素触发
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public filterChangeZYtree(){
const ZYtree:any = this.$refs.ZYtree;
public filterChangeZYtree() {
const ZYtree: any = this.$refs.ZYtree;
ZYtree.filter(this.ZYtreefilterText);
}
/**
* 应用菜单数据
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected CDdata: Array<any> = [];
/*应用菜单数据*/
protected CDdata: any = [];
/*数据能力数据*/
protected QXdata: any = [];
/*自定义资源数据*/
protected ZYdata: any = [];
/*默认选中节点*/
protected defaultCheckedNodes: any = [];
/*应用菜单数据默认展开节点*/
protected CDdataexpandedKeys: any = [];
/*数据能力数据默认展开节点*/
protected QXdataexpandedKeys: any = [];
/*自定义资源数据默认展开节点*/
protected ZYdataexpandedKeys: any = [];
/**
* 数据能力数据
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected QXdata: Array<any> = [];
/**
* 自定义资源数据
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected ZYdata: Array<any> = [];
/**
* 默认选中节点
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected defaultCheckedNodes: Array<any> = [];
/**
* 应用菜单数据默认展开节点
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected CDdataexpandedKeys: Array<any> = [];
/**
* 数据能力数据默认展开节点
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected QXdataexpandedKeys: Array<any> = [];
/**
* 自定义资源数据默认展开节点
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected ZYdataexpandedKeys: Array<any> = [];
/**
* 树显示说明:子树为节点对象的children,节点标签为节点对象的label
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected defaultProps: any = {
children: 'children',
label: 'label'
}
children: "children",
label: "label",
};
/**
* 选中数据
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected selectData: any = {};
/**
* 初始选中的数据
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected ininselectData: any = {};
/**
* 视图选中数据
*
* @type {Array<*>}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public viewSelections: any[] = [];
/**
* 父数据
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected parentData: any = {};
/**
* 父数据主键
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected srfparentkey: any;
......@@ -201,23 +330,23 @@
* 视图标识
*
* @type {string}
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public viewtag: string = 'e791be173ed0f4bbe9cce942b6edde63';
public viewtag: string = "e791be173ed0f4bbe9cce942b6edde63";
/**
* 是否嵌入关系界面
*
* @type {boolean}
* @memberof SYS_USER_ROLEGridViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
@Prop({default:false}) public isformDruipart?: boolean;
@Prop({ default: false }) public isformDruipart?: boolean;
/**
* 界面关系通讯对象
*
* @type {Subject<ViewState>}
* @memberof SYS_USER_ROLEGridViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
@Prop() public formDruipart?: Subject<ViewState>;
......@@ -225,23 +354,23 @@
* 应用上下文
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public context:any = {};
public context: any = {};
/**
* 视图参数
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public viewparams:any = {};
public viewparams: any = {};
/**
* 传入视图上下文
*
* @type {string}
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
@Prop() public viewdata!: string;
......@@ -249,7 +378,7 @@
* 视图默认使用
*
* @type {boolean}
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
@Prop({ default: true }) public viewDefaultUsage!: boolean;
......@@ -257,39 +386,47 @@
* 自定义视图导航上下文集合
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public customViewNavContexts:any ={};
public customViewNavContexts: any = {};
/**
* 自定义视图导航参数集合
*
* @type {*}
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public customViewParams:any ={};
public customViewParams: any = {};
/**
* 解析视图参数
*
* @public
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public parseViewParam(): void {
for(let key in this.context){
for (let key in this.context) {
delete this.context[key];
}
if (!this.viewDefaultUsage && this.viewdata && !Object.is(this.viewdata, '')) {
if (
!this.viewDefaultUsage &&
this.viewdata &&
!Object.is(this.viewdata, "")
) {
Object.assign(this.context, JSON.parse(this.viewdata));
if(this.context && this.context.srfparentdename){
Object.assign(this.viewparams,{srfparentdename:this.context.srfparentdename});
if (this.context && this.context.srfparentdename) {
Object.assign(this.viewparams, {
srfparentdename: this.context.srfparentdename,
});
}
if(this.context && this.context.srfparentkey){
Object.assign(this.viewparams,{srfparentkey:this.context.srfparentkey});
if (this.context && this.context.srfparentkey) {
Object.assign(this.viewparams, {
srfparentkey: this.context.srfparentkey,
});
}
this.handleCustomViewData();
return;
}
const path = (this.$route.matched[this.$route.matched.length - 1]).path;
const path = this.$route.matched[this.$route.matched.length - 1].path;
const keys: Array<any> = [];
const curReg = this.$pathToRegExp.pathToRegexp(path, keys);
const matchArray = curReg.exec(this.$route.path);
......@@ -297,88 +434,99 @@
keys.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item.name, {
enumerable: true,
value: matchArray[index + 1]
value: matchArray[index + 1],
});
});
this.$viewTool.formatRouteParams(tempValue,this.$route,this.context,this.viewparams);
if(this.$store.getters.getAppData() && this.$store.getters.getAppData().context){
Object.assign(this.context,this.$store.getters.getAppData().context);
this.$viewTool.formatRouteParams(
tempValue,
this.$route,
this.context,
this.viewparams
);
if (
this.$store.getters.getAppData() &&
this.$store.getters.getAppData().context
) {
Object.assign(this.context, this.$store.getters.getAppData().context);
}
//初始化视图唯一标识
Object.assign(this.context,{srfsessionid:this.$util.createUUID()});
Object.assign(this.context, { srfsessionid: this.$util.createUUID() });
this.handleCustomViewData();
}
/**
* 处理自定义视图数据
*
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public handleCustomViewData(){
if(Object.keys(this.customViewNavContexts).length > 0){
Object.keys(this.customViewNavContexts).forEach((item:any) =>{
let tempContext:any = {};
let curNavContext:any = this.customViewNavContexts[item];
this.handleCustomDataLogic(curNavContext,tempContext,item);
Object.assign(this.context,tempContext);
})
public handleCustomViewData() {
if (Object.keys(this.customViewNavContexts).length > 0) {
Object.keys(this.customViewNavContexts).forEach((item: any) => {
let tempContext: any = {};
let curNavContext: any = this.customViewNavContexts[item];
this.handleCustomDataLogic(curNavContext, tempContext, item);
Object.assign(this.context, tempContext);
});
}
if(Object.keys(this.customViewParams).length > 0){
Object.keys(this.customViewParams).forEach((item:any) =>{
let tempParam:any = {};
let curNavParam:any = this.customViewParams[item];
this.handleCustomDataLogic(curNavParam,tempParam,item);
Object.assign(this.viewparams,tempParam);
})
if (Object.keys(this.customViewParams).length > 0) {
Object.keys(this.customViewParams).forEach((item: any) => {
let tempParam: any = {};
let curNavParam: any = this.customViewParams[item];
this.handleCustomDataLogic(curNavParam, tempParam, item);
Object.assign(this.viewparams, tempParam);
});
}
}
/**
* 处理自定义视图数据逻辑
*
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public handleCustomDataLogic(curNavData:any,tempData:any,item:string){
public handleCustomDataLogic(curNavData: any, tempData: any, item: string) {
// 直接值直接赋值
if(curNavData.isRawValue){
if(Object.is(curNavData.value,"null") || Object.is(curNavData.value,"")){
if (curNavData.isRawValue) {
if (
Object.is(curNavData.value, "null") ||
Object.is(curNavData.value, "")
) {
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
writable: true,
enumerable: true,
configurable: true,
});
}else{
} else {
Object.defineProperty(tempData, item.toLowerCase(), {
value: curNavData.value,
writable : true,
enumerable : true,
configurable : true
writable: true,
enumerable: true,
configurable: true,
});
}
}else{
} else {
// 先从导航上下文取数,没有再从导航参数(URL)取数,如果导航上下文和导航参数都没有则为null
if(this.context[(curNavData.value).toLowerCase()]){
if (this.context[curNavData.value.toLowerCase()]) {
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.context[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
value: this.context[curNavData.value.toLowerCase()],
writable: true,
enumerable: true,
configurable: true,
});
}else{
if(this.viewparams[(curNavData.value).toLowerCase()]){
} else {
if (this.viewparams[curNavData.value.toLowerCase()]) {
Object.defineProperty(tempData, item.toLowerCase(), {
value: this.viewparams[(curNavData.value).toLowerCase()],
writable : true,
enumerable : true,
configurable : true
value: this.viewparams[curNavData.value.toLowerCase()],
writable: true,
enumerable: true,
configurable: true,
});
}else{
} else {
Object.defineProperty(tempData, item.toLowerCase(), {
value: null,
writable : true,
enumerable : true,
configurable : true
writable: true,
enumerable: true,
configurable: true,
});
}
}
......@@ -387,6 +535,8 @@
/**
* vue 创建
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public created() {
this.afterCreated();
......@@ -395,28 +545,34 @@
/**
* 执行created后的逻辑
*
* @memberof SYS_USER_ROLEGridViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public afterCreated(){
public afterCreated() {
const secondtag = this.$util.createUUID();
this.$store.commit('viewaction/createdView', { viewtag: this.viewtag, secondtag: secondtag });
this.$store.commit("viewaction/createdView", {
viewtag: this.viewtag,
secondtag: secondtag,
});
this.viewtag = secondtag;
this.parseViewParam();
const _this: any = this;
// 获取父数据
if (_this && _this.viewdata) {
if (typeof _this.viewdata == "string") {
_this.parentData = JSON.parse(_this.viewdata);
} else {
_this.parentData = _this.viewdata;
}
}
if (_this.parentData && _this.parentData.sysrole) {
// console.log("当前角色id:" + _this.parentData.sysrole);
_this.srfparentkey = _this.parentData.sysrole;
}
// 监听父页面
if(this.formDruipart){
this.formDruipart.subscribe((res:any) =>{
if(Object.is(res.action,'load')){
if (this.formDruipart) {
this.formDruipart.subscribe((res: any) => {
if (Object.is(res.action, "load")) {
// 如果是新建角色保存,需要从res中获取父数据主键
if (res.data) {
let parentData = res.data;
......@@ -424,22 +580,22 @@
}
// 父数据保存时调用当前视图的事件
if(this.selectData.length>0){
if (this.selectData.length > 0) {
// 选中了数据
this.onClickOk();
}else{
} else {
// 没选中数据
this.onClear();
}
}
});
}
}
/**
* vue 挂载
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public mounted() {
this.initTree();
......@@ -447,14 +603,18 @@
/**
* 初始化树
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
private initTree() {
const _this = this;
// get全部菜单和数据能力和自定义资源的请求路径
const url = `sysroles/`+_this.srfparentkey+`/sysrolepermissions/tree`;
this.$http.get(url).then((response: any) => {
const url: string = `sysroles/${_this.srfparentkey}/sysrolepermissions/tree`;
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格式化
......@@ -475,7 +635,7 @@
}
// 设置默认选中节点,即当前角色所有权限
this.$nextTick(()=>{
this.$nextTick(() => {
const CDtree: any = this.$refs.CDtree;
const QXtree: any = this.$refs.QXtree;
const ZYtree: any = this.$refs.ZYtree;
......@@ -485,61 +645,61 @@
ZYtree.setCheckedNodes(_this.defaultCheckedNodes);
// 保存初始选中的节点数据,便于后续保存时比较
const arr = CDtree.getCheckedNodes().concat(QXtree.getCheckedNodes()).concat(ZYtree.getCheckedNodes());
const arr = CDtree.getCheckedNodes()
.concat(QXtree.getCheckedNodes())
.concat(ZYtree.getCheckedNodes());
this.ininselectData = arr;
});
}
}).catch((e) => {
console.log(e);
})
.catch((e: any) => {
console.error(typeof e == "string" ? e : JSON.stringify(e));
});
}
/**
* 销毁之前
* vue销毁之前
*
* @memberof SYS_ROLE_PERMISSIONCustomViewBase
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public beforeDestroy() {
// 清空选中数据
this.selectData = {};
// 清空视图选中数据
this.viewSelections = [];
this.$store.commit('viewaction/removeView', this.viewtag);
this.$store.commit("viewaction/removeView", this.viewtag);
}
/**
* 处理选中节点
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
protected handleCheckChange() {
// console.log("SYS_PERMISSIONMPickupView执行了handleCheckChange")
// 获取当前三棵树
const CDtree: any = this.$refs.CDtree;
const QXtree: any = this.$refs.QXtree;
const ZYtree: any = this.$refs.ZYtree;
// 获取选中状态的节点
const arr = CDtree.getCheckedNodes().concat(QXtree.getCheckedNodes()).concat(ZYtree.getCheckedNodes());
const arr = CDtree.getCheckedNodes()
.concat(QXtree.getCheckedNodes())
.concat(ZYtree.getCheckedNodes());
this.selectData = arr;
// console.log("选中的node:" + JSON.stringify(this.selectData));
}
/**
* 容器模型
*/
public containerModel: any = {
view_okbtn: {name: 'okbtn', type: 'button', text: '确定', disabled: true},
};
/**
* 确定
* 保存角色权限
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
public onClickOk(): void {
// 处理选中的数据
if (this.selectData && this.selectData.length > 0) {
// 判断选中的数据和初始数据
if (JSON.stringify(this.selectData) == JSON.stringify(this.ininselectData)) {
if (
JSON.stringify(this.selectData) == JSON.stringify(this.ininselectData)
) {
return;
}
this.selectData.forEach((item: any) => {
......@@ -549,20 +709,25 @@
_item.permissionid = _itemTemp.id;
_item.permissiontype = _itemTemp.type;
_item.permissionname = _itemTemp.fullName;
Object.assign(_item, {_select: false})
Object.assign(_item, { _select: false });
this.viewSelections.push(_item);
}
});
// 保存选中的权限信息
let url = '/sysroles/'+this.srfparentkey+'/sysrolepermissions/refreshbatch';
this.$http.post(url,this.viewSelections).then((response: any) => {
let url: string = `/sysroles/${this.srfparentkey}/sysrolepermissions/refreshbatch`;
this.$http
.post(url, this.viewSelections)
.then((response: any) => {
if (!(!response || response.status !== 200)) {
} else {
this.$Notice.error({title: '错误', desc: response.message});
this.$Notice.error({ title: "错误", desc: response.message });
return;
}
}).catch((e) => {
})
.catch((e: any) => {
console.error(
"保存角色权限失败:" + typeof e == "string" ? e : JSON.stringify(e)
);
});
}
// 清空视图选中数据,避免重复添加
......@@ -570,28 +735,34 @@
}
/**
* 清除
* 清除角色权限
*
* @memberof SYS_ROLE_PERMISSIONCustomView
*/
private onClear(){
private onClear() {
// 未选中数据,即没有赋予任何权限,需要清除当前角色的所有权限
if (this.selectData.length==0) {
if (this.selectData.length == 0) {
// 保存选中的权限信息
let url = '/sysroles/'+this.srfparentkey+'/sysrolepermissions/refreshbatch';
this.$http.post(url,[]).then((response: any) => {
let url: string = `/sysroles/${this.srfparentkey}/sysrolepermissions/refreshbatch`;
this.$http
.post(url, [])
.then((response: any) => {
if (!(!response || response.status !== 200)) {
} else {
this.$Notice.error({title: '错误', desc: response.message});
this.$Notice.error({ title: "错误", desc: response.message });
return;
}
}).catch((e) => {
})
.catch((e: any) => {
console.error(
"清除角色权限失败," + typeof e == "string" ? e : JSON.stringify(e)
);
});
}
}
}
}
</script>
<style lang='less'>
@import './sys-role-permission-custom-view';
@import "./sys-role-permission-custom-view";
</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,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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册