<template>
|
<div class="tab-container">
|
<split-pane :max-width="500" :default-width="260" split="vertical">
|
<div slot="paneL" class="left-container">
|
<el-form class="form-tool">
|
<el-form-item>
|
<el-input v-model="filterText" placeholder="搜索名称" prefix-icon="el-icon-search" class="search-input">
|
</el-input>
|
<el-button title="刷新" class="btn-refresh" icon="el-icon-yrt-shuaxin" @click.native="treeRefresh"></el-button>
|
</el-form-item>
|
<el-form-item>
|
<!--数据tree-->
|
<el-tree ref="tree" :data="dataTree" :expand-on-click-node="false" :load="(node, resolve)=>{loadTreeNode(node, resolve)}" :filter-node-method="filterTreeNode" lazy highlight-current default-expand-all node-key="treeKey" @node-click="nodeClick">
|
<span slot-scope="{ node, data }" class="custom-tree-node">
|
<span>
|
<i v-if="data.hasChild" class="el-icon-menu"></i>
|
<i v-else class="el-icon-tickets"></i>
|
{{ node.label }}
|
</span>
|
</span>
|
</el-tree>
|
|
</el-form-item>
|
</el-form>
|
</div>
|
|
<!--右侧主区-->
|
<div slot="paneR" class="right-container">
|
<!--数据Table-->
|
<yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :action-field="actionField" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes" :fixed-where="{enable: 1}" @on-delete-after="onDeleteAfter">
|
<template slot="common-column-slot" slot-scope="{row, col}">
|
<template v-if="col.prop=='enable'">
|
<template v-if="row[col.prop]==1">
|
<el-tag color="#7aaffe" style="color:white;border:0">
|
{{ $refs[dataListRef].translateText(col.prop, row[col.prop], col.dropdown_Id) }}
|
</el-tag>
|
</template>
|
<template v-else>
|
<el-tag color="#ffcc33" style="color:white;border:0">
|
{{ $refs[dataListRef].translateText(col.prop, row[col.prop]||0, col.dropdown_Id) }}
|
</el-tag>
|
</template>
|
</template>
|
<template v-else-if="col.prop=='sex'">
|
{{ $refs[dataListRef].translateText(col.prop, row[col.prop]||0, col.dropdown_Id) }}
|
</template>
|
<template v-else>
|
{{ row[col.prop] }}
|
</template>
|
</template>
|
</yrt-data-list>
|
|
<!--数据编辑器Editor-->
|
<yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :auth-nodes="authNodes" @on-focus="onFocus" @on-change="onChange"></yrt-editor>
|
</div>
|
</split-pane>
|
</div>
|
</template>
|
|
<script>
|
import splitPane from "@/components/splitPane";
|
import yrtDataList from "@/components/common/yrtDataList";
|
import yrtEditor from "@/components/common/yrtEditor";
|
import baseLayout from "@/components/common/base-layout.vue";
|
|
export default {
|
// 自定义JSON路由地址
|
custoJsonmRoute: "/sys/permission/user",
|
|
name: "user-tab",
|
components: {
|
splitPane, // 分割器
|
yrtDataList, // 数据管理器
|
yrtEditor // 数据编辑器
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
filterText: "",
|
dataTree: [],
|
// 自定义表格操作按钮
|
actionField: {
|
prop: "_action",
|
label: "操作",
|
width: "120",
|
headerAlign: "center",
|
align: "center",
|
action: [
|
{
|
type: "button",
|
action: "Enable",
|
label: "禁用",
|
onClick: (btnInfo, rowData) => {
|
this.rowDisabledUser(btnInfo, rowData);
|
return true;
|
}
|
},
|
{
|
type: "button",
|
action: "edit",
|
label: "编辑"
|
},
|
{
|
type: "button",
|
action: "delete",
|
label: "删除"
|
}
|
],
|
hidden: false
|
}
|
};
|
},
|
watch: {
|
filterText(val) {
|
this.$refs.tree.filter(val);
|
}
|
},
|
created() {},
|
methods: {
|
// 获得左侧类目导航节点数据
|
loadTreeNode(node, resolve) {
|
var the = this;
|
the.$nextTick(() => {
|
var userInfo = this.common.getUserInfo();
|
var where = "";
|
if (node.level === 0) {
|
where = {
|
userProduct_Id: userInfo.userProduct_Id,
|
parentId: 0
|
};
|
} else {
|
where = {
|
userProduct_Id: userInfo.userProduct_Id,
|
parentId: node.data.dept_Id
|
};
|
}
|
|
var url = "/api/common/loadTreeNode";
|
var params = {
|
openNodeApi: true,
|
folder: "sys/core",
|
DBServer: "Sys",
|
tableName: "Sys_Dept",
|
tableView: "Sys_Dept",
|
keyName: "dept_Id",
|
nodeName: "deptName",
|
fixHasChild: false,
|
isBreakWay: false,
|
displayBreakWay: false,
|
parentName: "parentId",
|
orderBy: "orderNo desc, dept_Id",
|
where: where,
|
extendColumns: ""
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
resolve(res.data);
|
} else {
|
the.$message.error(res.msg);
|
}
|
},
|
true
|
);
|
});
|
},
|
// 搜索导航
|
filterTreeNode(value, data) {
|
if (!value) return true;
|
return data.label.indexOf(value) !== -1;
|
},
|
// 点击tree导航节点
|
nodeClick(data, node, el) {
|
var where = "dept_Id in(Select dept_Id from dbo.[GetDeptTree](" + data.dept_Id + "))";
|
this.dataList.reloadData(where);
|
},
|
|
// 刷新tree
|
treeRefresh() {
|
this.filterText = "";
|
var root = this.$refs.tree.store.root;
|
while (root.childNodes.length) {
|
this.$refs.tree.remove(root.childNodes[0]);
|
}
|
this.loadTreeNode(root, data => {
|
root.doCreateChildren(data);
|
});
|
},
|
|
// 级联获得焦点
|
onFocus(ref, event, field) {
|
if (field.options.prop === "fullPathId" && !field.options.isLoaded) {
|
this.cascaderLoadNode(ref, 0, field);
|
field.options.isLoaded = true;
|
}
|
},
|
// 级联改变数据
|
onChange(ref, val, field) {
|
var editor = this.editor;
|
// 设置表单数据
|
if (field.options.prop === "fullPathId") {
|
editor.formData.parentId = val[val.length - 1];
|
setTimeout(() => {
|
editor.formData.fullPathName = ref.inputValue;
|
}, 500);
|
}
|
},
|
// 级联加载子集数据
|
cascaderLoadNode(ref, val, field) {
|
var the = this;
|
var where = { parentId: 0 };
|
var url = "/api/common/loadTreeNodeAll";
|
var params = {
|
openNodeApi: true,
|
folder: "sys/core",
|
DBServer: "Sys",
|
tableName: "Sys_Dept",
|
tableView: "Sys_Dept",
|
keyName: "dept_Id",
|
nodeName: "deptName",
|
fixHasChild: false,
|
isBreakWay: false,
|
displayBreakWay: false,
|
parentName: "parentId",
|
orderBy: "orderNo desc, dept_Id",
|
where: where,
|
extendColumns: ""
|
};
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
var items = [
|
{
|
value: 0,
|
label: "根",
|
children: res.data
|
}
|
];
|
|
field.options.options = items;
|
} else {
|
the.$message.error(res.msg);
|
}
|
},
|
true
|
);
|
},
|
// 删除节点后刷新数据
|
onDeleteAfter() {
|
this.treeRefresh();
|
},
|
// 单条禁用
|
rowDisabledUser(btnInfo, rowData) {
|
const the = this;
|
this.$confirm("确定要进行禁用操作吗?", "禁用", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "warning"
|
})
|
.then(() => {
|
// 获得已选中的ID
|
const user_Id = rowData.user_Id;
|
const url = "/api/sys/user/disabledUser";
|
const params = {
|
openNodeApi: true,
|
user_Id: user_Id
|
};
|
const ref = the.findRef(the.dataListRef);
|
var callback = res => {
|
the.common.showMsg(res);
|
if (res.result) {
|
ref.loadData();
|
the.editorOptions.config.visible = false;
|
}
|
};
|
the.common.ajax(url, params, callback, ref);
|
})
|
.catch(() => {
|
the.$message({
|
type: "info",
|
message: "已取消"
|
});
|
});
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.tab-container {
|
position: relative;
|
margin: 0px;
|
min-height: calc(100vh - 165px);
|
overflow-x: hidden;
|
|
.left-container {
|
width: 100%;
|
height: 100%;
|
background-color: white;
|
border-radius: 4px;
|
.form-tool {
|
padding-top: 10px;
|
.el-form-item {
|
padding: 0 10px;
|
}
|
.search-input {
|
width: calc(100% - 40px);
|
}
|
.btn-search,
|
.btn-refresh {
|
padding: 10px;
|
}
|
.btn-refresh {
|
margin-left: 0px;
|
}
|
}
|
/deep/ .el-tree-node.is-current > .el-tree-node__content {
|
background-color: #a7ccf7;
|
color: white;
|
.el-button--text {
|
color: white;
|
}
|
}
|
.custom-tree-node {
|
flex: 1;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
font-size: 14px;
|
padding-right: 8px;
|
}
|
}
|
|
.right-container {
|
border-radius: 4px;
|
min-height: 100%;
|
background-color: white;
|
padding: 0 10px;
|
}
|
}
|
</style>
|