<template>
|
<div class="pane-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" :load="(node, resolve)=>{loadTreeNode(node, resolve)}" :expand-on-click-node="false" :filter-node-method="filterTreeNode" :default-expand-all="false" :props="props" node-key="treeKey" highlight-current lazy @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" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes" @on-delete-after="onDeleteAfter">
|
</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 {
|
name: "cms-module",
|
components: {
|
splitPane, // 分割器
|
yrtDataList, // 数据管理器
|
yrtEditor // 数据编辑器
|
},
|
mixins: [baseLayout],
|
data() {
|
return {
|
filterText: "",
|
props: {
|
label: "label",
|
children: "children",
|
isLeaf: "isLeaf"
|
}
|
};
|
},
|
methods: {
|
// 获得左侧类目导航节点数据
|
loadTreeNode(node, resolve) {
|
var the = this;
|
the.$nextTick(() => {
|
var url = "/api/common/loadTreeNode";
|
const where = node.level === 0 ? { parentId: 0 } : { parentId: node.data.module_Id };
|
const params = {
|
folder: "cms/module",
|
dbServer: "Sys",
|
tableName: "Cms_Module",
|
tableView: "Cms_Module",
|
keyName: "module_Id",
|
nodeName: "moduleCnName",
|
fixHasChild: false,
|
isBreakWay: false,
|
displayBreakWay: false,
|
parentName: "parentId",
|
orderBy: "orderNo desc, moduleCnName",
|
where: where,
|
extendColumns: ""
|
};
|
|
the.common.ajax(
|
url,
|
params,
|
res => {
|
if (res.result) {
|
res.data.forEach(element => {
|
element.isLeaf = !element.hasChild;
|
});
|
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 = {
|
module_Id: {
|
operator: "raw",
|
value: "in(Select module_Id from dbo.[GetCmsModuleTree](" + data.module_Id + "))"
|
}
|
};
|
this.dataList.reloadData(where);
|
},
|
|
// 级联获得焦点
|
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 = {
|
folder: "cms/module",
|
dbServer: "Sys",
|
tableName: "Cms_Module",
|
tableView: "Cms_Module",
|
keyName: "module_Id",
|
nodeName: "moduleCnName",
|
fixHasChild: false,
|
isBreakWay: false,
|
displayBreakWay: false,
|
parentName: "parentId",
|
orderBy: "orderNo desc, module_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
|
);
|
},
|
// 刷新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);
|
});
|
},
|
// 删除节点后刷新数据
|
onDeleteAfter() {
|
this.treeRefresh();
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.pane-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>
|