deptListComponent.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <div class="deptListComponent">
  3. <div id="tree-box">
  4. <el-form :model="queryParams" class="form-box" ref="queryForm"
  5. :inline="true" style="width:100%;">
  6. <el-form-item label="" prop="state">
  7. <el-input
  8. v-model="queryParams.searchValue"
  9. placeholder="实验室"
  10. clearable
  11. style="width:178px;"
  12. />
  13. </el-form-item>
  14. <p class="form-inquire-common-style-button" @click="handleQuery">查询</p>
  15. <p class="form-reset-common-style-button" @click="resetQuery">重置</p>
  16. </el-form>
  17. <div class="for-level-max-box">
  18. <div class="for-level-box"
  19. @click="checkLevelButton(item,index)"
  20. v-for="(item,index) in levelList" :key="index">
  21. {{item.titleName}}
  22. <p class="checkLevel" v-if="checkLeveList[index].type"><span class="el-icon-check"></span></p>
  23. </div>
  24. </div>
  25. <div class="tree-max-box">
  26. <el-tree
  27. class="tree-line"
  28. @node-click="nodeClickButton"
  29. :indent="0"
  30. :current-node-key="treeId"
  31. :check-on-click-node="false"
  32. check-strictly
  33. highlight-current
  34. :default-expanded-keys="defaultKey"
  35. node-key="treeId"
  36. :data="deptOptions"
  37. :props="defaultProps"
  38. ref="tree"
  39. :load="loadNode"
  40. accordion
  41. lazy>
  42. <template #default="{ node, data }">
  43. <span style="
  44. max-width:255px;
  45. display:block;
  46. overflow:hidden;
  47. text-overflow:ellipsis;
  48. white-space:nowrap;"
  49. :style="!data.level?'font-size:20px':(data.level==1?'font-size:26px':(data.level==2||data.level==3||data.level==4?'font-size:24px':(data.level==5?'font-size:20px':'')))">{{data.deptName}}</span>
  50. </template>
  51. </el-tree>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import {
  58. laboratoryLevelConfigGetLevelTitleList,
  59. laboratoryLabDeptTreeGetTreeList,
  60. laboratoryLabDeptTreeGetRoomList } from "@/api/index";
  61. export default {
  62. name: 'deptListComponent',
  63. data () {
  64. return {
  65. treeList:[],
  66. showType:false,
  67. deptId:null,
  68. deptName:null,
  69. buildId:null,
  70. buildName:null,
  71. floorId:null,
  72. floorName:null,
  73. //新树
  74. deptOptions: null,
  75. defaultKey:null,
  76. defaultProps: {
  77. children: "childTreeList",
  78. label: "deptName",
  79. isLeaf:"leaf",
  80. },
  81. //当前选中ID
  82. treeId:null,
  83. queryParams: {
  84. searchValue: '',
  85. },
  86. levelList:[],
  87. checkLeveList:[],
  88. }
  89. },
  90. created(){
  91. },
  92. mounted(){
  93. this.laboratoryLevelConfigGetLevelTitleList();
  94. this.laboratoryLabDeptTreeGetTreeList()
  95. },
  96. methods:{
  97. //查询按钮
  98. handleQuery(){
  99. this.laboratoryLabDeptTreeGetTreeList();
  100. },
  101. //重置按钮
  102. resetQuery(){
  103. let self = this;
  104. this.$set(this,'queryParams',{
  105. searchValue: '',
  106. });
  107. for(let i=0;i<self.checkLeveList.length;i++){
  108. self.checkLeveList[i].type = false;
  109. }
  110. this.laboratoryLabDeptTreeGetTreeList();
  111. },
  112. //选中级别
  113. checkLevelButton(item,index){
  114. this.$set(this.checkLeveList[index],'type',!this.checkLeveList[index].type);
  115. },
  116. //分级下拉列表
  117. laboratoryLevelConfigGetLevelTitleList(){
  118. laboratoryLevelConfigGetLevelTitleList({}).then(response => {
  119. let list = [];
  120. for (let i=0;i<response.data.length;i++){
  121. list.push({
  122. type:false,
  123. levelId:response.data[i].levelId
  124. })
  125. }
  126. this.$set(this,'levelList',response.data);
  127. this.$set(this,'checkLeveList',list);
  128. });
  129. },
  130. //新树
  131. laboratoryLabDeptTreeGetTreeList() {
  132. let self = this;
  133. let obj = {
  134. searchValue:this.searchValue,
  135. levelIds:[],
  136. }
  137. for(let i=0;i<self.checkLeveList.length;i++){
  138. if(self.checkLeveList[i].type){
  139. obj.levelIds.push(self.checkLeveList[i].levelId)
  140. }
  141. }
  142. laboratoryLabDeptTreeGetTreeList(obj).then(response => {
  143. let self = this;
  144. let list = this.delList(response.data);
  145. this.$nextTick(()=>{
  146. //写入楼层下数据
  147. this.$set(this,'deptOptions',list)
  148. this.$set(this,'defaultKey',[list[0].treeId,list[0].childTreeList[0].treeId,list[0].childTreeList[0].childTreeList[0].treeId,list[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId]);
  149. setTimeout(function(){
  150. self.$refs.tree.setCurrentKey(list[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId);
  151. self.$set(self,'treeId',list[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId);
  152. },200);
  153. //等待后续逻辑-面板展示-实验室信息-视屏信息
  154. // let minObj = JSON.parse(JSON.stringify(obj))
  155. // minObj.floorId = list[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId;
  156. // laboratoryLabDeptTreeGetRoomList(minObj).then(minResponse => {
  157. // for(let i=0;i<minResponse.data.length;i++){
  158. // minResponse.data[i].leaf = true;
  159. // }
  160. // list[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList = minResponse.data[0]?minResponse.data:[];
  161. // //选中逻辑
  162. // this.defaultKey=[list[0].treeId,list[0].childTreeList[0].treeId,list[0].childTreeList[0].childTreeList[0].treeId,list[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId,list[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId]
  163. // this.$nextTick(()=>{
  164. // this.$refs.tree.setCurrentKey(list[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId);
  165. // this.$nextTick(()=>{
  166. // setTimeout(function(){
  167. // self.$refs.tree.setCurrentKey(list[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId);
  168. // self.$set(self,'treeId',list[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList[0].childTreeList[0].treeId);
  169. // },200);
  170. // })
  171. // })
  172. // this.$set(this,'deptOptions',list)
  173. // })
  174. })
  175. })
  176. },
  177. //空数据处理
  178. delList(list){
  179. let self = this;
  180. for(let i=1;i<4;i++){
  181. list.forEach((item,index)=>{
  182. if(item.level != 5){
  183. if(item.childTreeList){
  184. if(!item.childTreeList[0]){
  185. list.splice(index,1)
  186. }else{
  187. self.delList(item.childTreeList);
  188. }
  189. }else{
  190. list.splice(index,1)
  191. }
  192. }
  193. })
  194. }
  195. return list
  196. },
  197. //点击操作
  198. nodeClickButton(e,data){
  199. this.$nextTick(() => {
  200. if (!e.level||e.level == 4||e.level == 5) {
  201. this.treeId = e.treeId;
  202. console.log('chenggong')
  203. //等待后续逻辑-面板展示-实验室信息-视屏信息
  204. }
  205. this.$refs.tree.setCurrentKey(this.treeId);
  206. });
  207. },
  208. //手动加载
  209. loadNode(node, resolve) {
  210. let self = this;
  211. if (node.data){
  212. if(node.data.level == 5){
  213. let obj = {
  214. searchValue:this.searchValue,
  215. levelIds:[],
  216. }
  217. for(let i=0;i<self.checkLeveList.length;i++){
  218. if(self.checkLeveList[i].type){
  219. obj.levelIds.push(self.checkLeveList[i].levelId)
  220. }
  221. }
  222. obj.floorId = node.data.treeId;
  223. laboratoryLabDeptTreeGetRoomList(obj).then(response => {
  224. for(let i=0;i<response.data.length;i++){
  225. response.data[i].leaf = true;
  226. }
  227. resolve(response.data[0]?response.data:[]);
  228. })
  229. }else{
  230. if(node.data.childTreeList){
  231. if(node.data.childTreeList[0]){
  232. if(node.data.level != 4){
  233. node.data.childTreeList.forEach((item)=>{
  234. if(item.childTreeList){
  235. if(!item.childTreeList[0]){
  236. item.leaf = true;
  237. }
  238. }else{
  239. item.leaf = true;
  240. }
  241. })
  242. }
  243. resolve(node.data.childTreeList);
  244. }else{
  245. resolve([]);
  246. }
  247. }else{
  248. resolve([]);
  249. }
  250. }
  251. }
  252. }
  253. },
  254. }
  255. </script>
  256. <style scoped lang="scss">
  257. .deptListComponent{
  258. width:430px;
  259. height:1330px;
  260. overflow-y:hidden;
  261. display: flex;
  262. flex-direction: column;
  263. background: linear-gradient(180deg, rgba(4, 117, 129, 0.2) 0%, rgba(0, 15, 22, 0) 100%);
  264. #tree-box{
  265. flex:1;
  266. overflow-y:hidden;
  267. display: flex;
  268. flex-direction: column;
  269. //检索
  270. .form-box{
  271. padding:32px 0 20px 29px;
  272. .el-input__inner{
  273. height: 40px;
  274. line-height: 38px;
  275. font-size: 16px;
  276. }
  277. ::v-deep .el-form-item__content{
  278. height:40px;
  279. }
  280. ::v-deep .el-input--medium .el-input__inner{
  281. height:40px;
  282. }
  283. .form-reset-common-style-button{
  284. width:80px;
  285. height:40px;
  286. line-height:40px;
  287. font-size:16px;
  288. font-weight:500;
  289. border:1px solid #06DEFF;
  290. color:#06DEFF;
  291. }
  292. .form-inquire-common-style-button{
  293. width:80px;
  294. height:40px;
  295. line-height:40px;
  296. font-size:16px;
  297. font-weight:500;
  298. color:#fff;
  299. background-color: #06DEFF;
  300. margin:0 17px;
  301. }
  302. }
  303. .for-level-max-box{
  304. display: flex;
  305. padding-left:29px;
  306. .for-level-box{
  307. cursor: pointer;
  308. color:#fff;
  309. border: 1px solid #1ED0F8;
  310. width:80px;
  311. height:40px;
  312. text-align: center;
  313. line-height: 40px;
  314. margin-right:17px;
  315. border-radius:4px;
  316. position: relative;
  317. overflow: hidden;
  318. font-size:16px;
  319. font-weight:500;
  320. .checkLevel{
  321. height:25px;
  322. position: absolute;
  323. right: -1px;
  324. bottom: -1px;
  325. span{
  326. font-size:14px;
  327. position: relative;
  328. width: 0;
  329. height: 0;
  330. border-left: 25px solid transparent;
  331. border-right: 0px solid transparent;
  332. border-bottom: 25px solid #06DEFF; /* 三角形的颜色 */
  333. }
  334. .el-icon-check:before{
  335. position: absolute;
  336. left:-14px;
  337. top:10px;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. //新树
  344. .tree-max-box{
  345. flex:1;
  346. margin:30px 0 30px 9px;
  347. overflow-y:scroll;
  348. }
  349. .el-tree{
  350. background-color: transparent;
  351. color:#fff;
  352. }
  353. ::v-deep .tree-line .el-tree-node__expand-icon{
  354. display: block;
  355. height: 60px;
  356. width: 60px;
  357. padding: 0;
  358. line-height: 60px;
  359. text-align: center;
  360. margin-right: auto;
  361. font-size: 24px!important;
  362. color:#15827C;
  363. }
  364. //选中
  365. ::v-deep .is-current{
  366. /*color:#03B7CA;*/
  367. }
  368. ::v-deep .el-tree-node:focus > .el-tree-node__content{
  369. background-color: transparent;
  370. }
  371. ::v-deep .el-tree-node__content{
  372. height:60px;
  373. display: flex;
  374. flex-direction: row-reverse;
  375. }
  376. ::v-deep .el-tree-node__content:hover{
  377. background-color: transparent;
  378. color:#03B7CA;
  379. }
  380. ::v-deep .el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content{
  381. background-color: transparent;
  382. color:#03B7CA;
  383. }
  384. //引导线
  385. ::v-deep .tree-line {
  386. .el-tree-node {
  387. position: relative;
  388. padding-left: 16px; // 缩进量
  389. }
  390. .el-tree-node__children {
  391. padding-left: 16px; // 缩进量
  392. }
  393. // 竖线
  394. .el-tree-node::before {
  395. content: '';
  396. height: 100%;
  397. width: 1px;
  398. position: absolute;
  399. left: -3px;
  400. top: -8px;
  401. border-width: 1px;
  402. border-left: 1px solid #15827C;
  403. }
  404. // 当前层最后一个节点的竖线高度固定
  405. .el-tree-node:last-child::before {
  406. height: 38px; // 可以自己调节到合适数值
  407. }
  408. // 横线
  409. .el-tree-node::after {
  410. content: '';
  411. width: 24px;
  412. height: 20px;
  413. position: absolute;
  414. left: 0px;
  415. top: 30px;
  416. border-width: 1px;
  417. border-top: 1px dashed #15827C;
  418. }
  419. // 去掉最顶层的虚线,放最下面样式才不会被上面的覆盖了
  420. & > .el-tree-node::after {
  421. border-top: none;
  422. }
  423. & > .el-tree-node::before {
  424. border-left: none;
  425. }
  426. // 展开关闭的icon
  427. .el-tree-node__expand-icon {
  428. font-size: 16px;
  429. // 叶子节点(无子节点)
  430. &.is-leaf {
  431. color: transparent;
  432. // display: none; // 也可以去掉
  433. }
  434. }
  435. }
  436. }
  437. .tree-max-box::-webkit-scrollbar {
  438. width: 6px; /*高宽分别对应横竖滚动条的尺寸*/
  439. height: 6px;
  440. }
  441. .tree-max-box::-webkit-scrollbar-thumb {
  442. border-radius: 5px;
  443. -webkit-box-shadow: inset 0 0 5px #07B4C7;
  444. background: #07B4C7;
  445. }
  446. .tree-max-box::-webkit-scrollbar-track {
  447. -webkit-box-shadow: inset 0 0 5px #013138;
  448. border-radius: 0;
  449. background: #013138;
  450. }
  451. </style>