index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <div class="container">
  3. <div class="left-pane">
  4. <el-input
  5. placeholder="请输入关键字"
  6. suffix-icon="el-icon-search"
  7. v-model="filterText"
  8. ></el-input>
  9. <div class="tree_container">
  10. <el-tree
  11. ref="tree"
  12. :data="data"
  13. :props="defaultProps"
  14. node-key="id"
  15. default-expand-all
  16. :filter-node-method="filterNode"
  17. @node-click="handleNodeClick"
  18. >
  19. <span slot-scope="{node,data}">
  20. <el-image :src="data.url"></el-image>
  21. <span style="padding-left: 10px; vertical-align: text-bottom;">{{ node.label }}</span>
  22. <span class="operate_btns">
  23. <!-- v-if="data.children" -->
  24. <dropdown
  25. :events="data.id?menuEvents:subMenuEvents"
  26. :data="{ node, data }"
  27. @itemClick="dropDownClick"
  28. ></dropdown>
  29. </span>
  30. </span>
  31. </el-tree>
  32. </div>
  33. <!-- <el-button class="createNewInfoMessageType"><i class="el-icon-s-order"></i>新建信息配置模块</el-button> -->
  34. </div>
  35. <div class="right-pane">
  36. <floorInfo
  37. v-if="winType == 1"
  38. v-bind="{
  39. itemInfo:itemInfo
  40. }"
  41. ></floorInfo>
  42. <SecuritystaffInfo
  43. v-if="winType == 2"
  44. v-bind="{
  45. itemInfo:itemInfo
  46. }"
  47. ></SecuritystaffInfo>
  48. </div>
  49. <createFloor ref="createFloor"></createFloor>
  50. <createInfo ref="createInfo"></createInfo>
  51. </div>
  52. </template>
  53. <script>
  54. import dropdown from "@/components/Dropdown/index";
  55. import floorInfo from "./floorInfo";
  56. import SecuritystaffInfo from "./securitystaffInfo";
  57. import createFloor from "./dailog/createFloor.vue";
  58. import createInfo from "./dailog/createInfo.vue";
  59. import louceng from "@/assets/tree/strategy/louceng@3x.png";
  60. import huiyishi from "@/assets/tree/strategy/huiyishi@3x.png";
  61. import { isArray } from "@/utils/validate";
  62. export default {
  63. components: {
  64. floorInfo,
  65. dropdown,
  66. SecuritystaffInfo,
  67. createFloor,
  68. createInfo,
  69. },
  70. data() {
  71. return {
  72. floorShow: true,
  73. infoShow: false,
  74. filterText: "",
  75. winType: 0,
  76. itemInfo: null,
  77. data: [
  78. {
  79. id: 1,
  80. url: louceng,
  81. type: "floor",
  82. label: "楼层地图信息配置",
  83. children: [
  84. {
  85. url: huiyishi,
  86. label: "1F",
  87. },
  88. {
  89. url: huiyishi,
  90. label: "15F",
  91. },
  92. {
  93. url: huiyishi,
  94. label: "20F",
  95. },
  96. {
  97. url: huiyishi,
  98. label: "21F",
  99. },
  100. {
  101. url: huiyishi,
  102. label: "B1",
  103. },
  104. {
  105. url: huiyishi,
  106. label: "B3",
  107. },
  108. ],
  109. },
  110. {
  111. id: 2,
  112. url: louceng,
  113. label: "安保人员信息",
  114. children: [
  115. {
  116. url: huiyishi,
  117. label: "前台人员排班信息",
  118. },
  119. {
  120. url: huiyishi,
  121. label: "安防人员排班信息",
  122. },
  123. ],
  124. },
  125. ],
  126. defaultProps: {
  127. children: "children",
  128. label: "label",
  129. },
  130. menuEvents: [{ label: "新建", funcName: "addNode" }],
  131. subMenuEvents: [
  132. // { label: "新建", funcName: "addNode" },
  133. // { label: "上移", funcName: "moveUp" },
  134. // { label: "下移", funcName: "moveDown" },
  135. // { label: "编辑", funcName: "editNode" },
  136. { label: "删除", funcName: "removeNode" },
  137. ],
  138. };
  139. },
  140. watch: {
  141. filterText(val) {
  142. this.$refs.tree.filter(val);
  143. },
  144. },
  145. methods: {
  146. filterNode(value, data) {
  147. if (!value) return true;
  148. return data.label.indexOf(value) !== -1;
  149. },
  150. handleNodeClick(data, node) {
  151. if (!isArray(node.parent.data)) {
  152. switch (node.parent.data.type) {
  153. case "floor":
  154. this.winType = 1;
  155. break;
  156. default:
  157. this.winType = 2;
  158. break;
  159. }
  160. this.itemInfo = {
  161. data: JSON.parse(JSON.stringify(data)),
  162. parentData: JSON.parse(JSON.stringify(node.parent.data)),
  163. };
  164. }
  165. },
  166. dropDownClick(eventType, data) {
  167. switch (eventType) {
  168. case "addNode":
  169. if (data.data.type != "floor") {
  170. this.$refs.createInfo.dialogVisible = true;
  171. } else {
  172. this.$refs.createFloor.dialogVisible = true;
  173. }
  174. break;
  175. case "removeNode":
  176. // 删除楼层
  177. this.$confirm(
  178. "此操作将删除 " + data.data.label + " , 是否继续?",
  179. "提示",
  180. {
  181. confirmButtonText: "确定",
  182. cancelButtonText: "取消",
  183. type: "warning",
  184. }
  185. )
  186. .then(() => {
  187. this.$message({
  188. type: "success",
  189. message: "删除成功!",
  190. });
  191. })
  192. .catch(() => {
  193. this.$message({
  194. type: "info",
  195. message: "已取消删除",
  196. });
  197. });
  198. break;
  199. default:
  200. break;
  201. }
  202. },
  203. },
  204. };
  205. </script>
  206. <style lang="less" scoped>
  207. .container {
  208. position: relative;
  209. height: 100%;
  210. line-height: 20px;
  211. background-color: rgba(255, 255, 255, 1);
  212. color: rgba(16, 16, 16, 1);
  213. font-size: 14px;
  214. text-align: center;
  215. display: flex;
  216. box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.15);
  217. .left-pane {
  218. width: 300px;
  219. padding: 15px;
  220. height: calc(100% - 30px);
  221. .tree_container {
  222. height: calc(100% - 50px);
  223. margin-top: 10px;
  224. margin-bottom: 10px;
  225. overflow: hidden;
  226. overflow-y: auto;
  227. .el-tree {
  228. height: 100%;
  229. background-color: #fafafa;
  230. /deep/.el-tree-node__content {
  231. align-items: center;
  232. height: 30px;
  233. cursor: pointer;
  234. font-size: 16px;
  235. position: relative;
  236. color: #999999;
  237. padding-top: 10px;
  238. padding-left: 30px !important;
  239. .operate_btns {
  240. position: absolute;
  241. right: 20px;
  242. display: none;
  243. }
  244. &:hover,
  245. :focus-within {
  246. background-color: #f7fbff;
  247. .operate_btns {
  248. display: inline;
  249. }
  250. }
  251. }
  252. /deep/.el-tree-node__children {
  253. .el-tree-node__content {
  254. padding-left: 60px !important;
  255. }
  256. }
  257. }
  258. }
  259. .createNewInfoMessageType {
  260. position: relative;
  261. width: 250px;
  262. text-align: center;
  263. font-size: 16px;
  264. color: #fff;
  265. background: #3da0d6;
  266. color: #fff;
  267. }
  268. }
  269. .right-pane {
  270. width: calc(100% - 330px);
  271. }
  272. // .el-button {
  273. // position: absolute;
  274. // left: 40px;
  275. // bottom: 15px;
  276. // width: 250px;
  277. // text-align: center;
  278. // font-size: 16px;
  279. // color: #fff;
  280. // background: #3da0d6;
  281. // }
  282. }
  283. // .el-tag {
  284. // position: absolute;
  285. // background-color: transparent;
  286. // border-color: transparent;
  287. // font-size: 25px;
  288. // color: #000;
  289. // top: 20px;
  290. // left: 20px;
  291. // }
  292. // .el-button--text {
  293. // position: absolute;
  294. // top: 70px;
  295. // right: 20px;
  296. // }
  297. </style>