123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- <template>
- <div class="container">
- <div class="left-pane">
- <el-input
- placeholder="请输入关键字"
- suffix-icon="el-icon-search"
- v-model="filterText"
- ></el-input>
- <div class="tree_container">
- <el-tree
- ref="tree"
- :data="data"
- :props="defaultProps"
- node-key="id"
- default-expand-all
- :filter-node-method="filterNode"
- @node-click="handleNodeClick"
- >
- <span slot-scope="{node,data}">
- <el-image :src="data.url"></el-image>
- <span style="padding-left: 10px; vertical-align: text-bottom;">{{ node.label }}</span>
- <span class="operate_btns">
- <!-- v-if="data.children" -->
- <dropdown
- :events="data.id?menuEvents:subMenuEvents"
- :data="{ node, data }"
- @itemClick="dropDownClick"
- ></dropdown>
- </span>
- </span>
- </el-tree>
- </div>
- <!-- <el-button class="createNewInfoMessageType"><i class="el-icon-s-order"></i>新建信息配置模块</el-button> -->
- </div>
- <div class="right-pane">
- <floorInfo
- v-if="winType == 1"
- v-bind="{
- itemInfo:itemInfo
- }"
- ></floorInfo>
- <SecuritystaffInfo
- v-if="winType == 2"
- v-bind="{
- itemInfo:itemInfo
- }"
- ></SecuritystaffInfo>
- </div>
- <createFloor ref="createFloor"></createFloor>
- <createInfo ref="createInfo"></createInfo>
- </div>
- </template>
- <script>
- import dropdown from "@/components/Dropdown/index";
- import floorInfo from "./floorInfo";
- import SecuritystaffInfo from "./securitystaffInfo";
- import createFloor from "./dailog/createFloor.vue";
- import createInfo from "./dailog/createInfo.vue";
- import louceng from "@/assets/tree/strategy/louceng@3x.png";
- import huiyishi from "@/assets/tree/strategy/huiyishi@3x.png";
- import { isArray } from "@/utils/validate";
- export default {
- components: {
- floorInfo,
- dropdown,
- SecuritystaffInfo,
- createFloor,
- createInfo,
- },
- data() {
- return {
- floorShow: true,
- infoShow: false,
- filterText: "",
- winType: 0,
- itemInfo: null,
- data: [
- {
- id: 1,
- url: louceng,
- type: "floor",
- label: "楼层地图信息配置",
- children: [
- {
- url: huiyishi,
- label: "1F",
- },
- {
- url: huiyishi,
- label: "15F",
- },
- {
- url: huiyishi,
- label: "20F",
- },
- {
- url: huiyishi,
- label: "21F",
- },
- {
- url: huiyishi,
- label: "B1",
- },
- {
- url: huiyishi,
- label: "B3",
- },
- ],
- },
- {
- id: 2,
- url: louceng,
- label: "安保人员信息",
- children: [
- {
- url: huiyishi,
- label: "前台人员排班信息",
- },
- {
- url: huiyishi,
- label: "安防人员排班信息",
- },
- ],
- },
- ],
- defaultProps: {
- children: "children",
- label: "label",
- },
- menuEvents: [{ label: "新建", funcName: "addNode" }],
- subMenuEvents: [
- // { label: "新建", funcName: "addNode" },
- // { label: "上移", funcName: "moveUp" },
- // { label: "下移", funcName: "moveDown" },
- // { label: "编辑", funcName: "editNode" },
- { label: "删除", funcName: "removeNode" },
- ],
- };
- },
- watch: {
- filterText(val) {
- this.$refs.tree.filter(val);
- },
- },
- methods: {
- filterNode(value, data) {
- if (!value) return true;
- return data.label.indexOf(value) !== -1;
- },
- handleNodeClick(data, node) {
- if (!isArray(node.parent.data)) {
- switch (node.parent.data.type) {
- case "floor":
- this.winType = 1;
- break;
- default:
- this.winType = 2;
- break;
- }
- this.itemInfo = {
- data: JSON.parse(JSON.stringify(data)),
- parentData: JSON.parse(JSON.stringify(node.parent.data)),
- };
- }
- },
- dropDownClick(eventType, data) {
- switch (eventType) {
- case "addNode":
- if (data.data.type != "floor") {
- this.$refs.createInfo.dialogVisible = true;
- } else {
- this.$refs.createFloor.dialogVisible = true;
- }
- break;
- case "removeNode":
- // 删除楼层
- this.$confirm(
- "此操作将删除 " + data.data.label + " , 是否继续?",
- "提示",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }
- )
- .then(() => {
- this.$message({
- type: "success",
- message: "删除成功!",
- });
- })
- .catch(() => {
- this.$message({
- type: "info",
- message: "已取消删除",
- });
- });
- break;
- default:
- break;
- }
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .container {
- position: relative;
- height: 100%;
- line-height: 20px;
- background-color: rgba(255, 255, 255, 1);
- color: rgba(16, 16, 16, 1);
- font-size: 14px;
- text-align: center;
- display: flex;
- box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.15);
- .left-pane {
- width: 300px;
- padding: 15px;
- height: calc(100% - 30px);
- .tree_container {
- height: calc(100% - 50px);
- margin-top: 10px;
- margin-bottom: 10px;
- overflow: hidden;
- overflow-y: auto;
- .el-tree {
- height: 100%;
- background-color: #fafafa;
- /deep/.el-tree-node__content {
- align-items: center;
- height: 30px;
- cursor: pointer;
- font-size: 16px;
- position: relative;
- color: #999999;
- padding-top: 10px;
- padding-left: 30px !important;
- .operate_btns {
- position: absolute;
- right: 20px;
- display: none;
- }
- &:hover,
- :focus-within {
- background-color: #f7fbff;
- .operate_btns {
- display: inline;
- }
- }
- }
- /deep/.el-tree-node__children {
- .el-tree-node__content {
- padding-left: 60px !important;
- }
- }
- }
- }
- .createNewInfoMessageType {
- position: relative;
- width: 250px;
- text-align: center;
- font-size: 16px;
- color: #fff;
- background: #3da0d6;
- color: #fff;
- }
- }
- .right-pane {
- width: calc(100% - 330px);
- }
- // .el-button {
- // position: absolute;
- // left: 40px;
- // bottom: 15px;
- // width: 250px;
- // text-align: center;
- // font-size: 16px;
- // color: #fff;
- // background: #3da0d6;
- // }
- }
- // .el-tag {
- // position: absolute;
- // background-color: transparent;
- // border-color: transparent;
- // font-size: 25px;
- // color: #000;
- // top: 20px;
- // left: 20px;
- // }
- // .el-button--text {
- // position: absolute;
- // top: 70px;
- // right: 20px;
- // }
- </style>
|