left_toolbar.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. <template>
  2. <div id="left_toolbar">
  3. <ul class="list-1">
  4. <li
  5. v-on:mouseout="mouseoutActive(item)"
  6. v-on:mouseover="mouseoverActive(item)"
  7. v-for="(item,i) in baseChoice"
  8. :key="i"
  9. @click="toolActionClick(item)"
  10. :class="{ actives:item.isChoice}"
  11. >
  12. <div class="item">
  13. <img
  14. v-show="!item.isHover && !item.isChoice"
  15. :src="require(`./../../assets/images/${item.img}`)"
  16. alt
  17. />
  18. <img
  19. v-show="item.isHover || item.isChoice "
  20. :src="require(`./../../assets/images/${item.hoverImg}`)"
  21. alt
  22. />
  23. </div>
  24. </li>
  25. </ul>
  26. <div class="border-line"></div>
  27. <ul class="list-2">
  28. <li
  29. v-on:mouseout="mouseoutActive(item)"
  30. v-on:mouseover="mouseoverActive(item)"
  31. v-for="(item,i) in systemChoice"
  32. @click="showDrawer(item)"
  33. :key="i"
  34. v-bind:class="{ actives:item.isChoice}"
  35. >
  36. <div class="item">
  37. <img v-show="!item.isHover" :src="require(`./../../assets/images/${item.img}`)" alt />
  38. <img v-show="item.isHover" :src="require(`./../../assets/images/${item.hoverImg}`)" alt />
  39. <div>{{item.name}}</div>
  40. </div>
  41. </li>
  42. </ul>
  43. <div class="border-line"></div>
  44. <!-- 提取-->
  45. <ul class="list-2 border-top">
  46. <li
  47. v-on:mouseout="mouseoutActive(item)"
  48. v-on:mouseover="mouseoverActive(item)"
  49. v-for="(item,i) in extractChoice"
  50. :key="i"
  51. @click="extractItem"
  52. >
  53. <div class="item">
  54. <img v-show="!item.isHover" :src="require(`./../../assets/images/${item.img}`)" alt />
  55. <img v-show="item.isHover" :src="require(`./../../assets/images/${item.hoverImg}`)" alt />
  56. <div>{{item.name}}</div>
  57. </div>
  58. </li>
  59. </ul>
  60. <a-popover trigger="click" placement="rightBottom" v-model="drawerVisible">
  61. <template slot="content">
  62. <itemTree
  63. @getSelectId="getSelectId"
  64. :drawerVisible="drawerVisible"
  65. :categoryIdS="categoryIdS"
  66. ></itemTree>
  67. </template>
  68. <div class="bottom-item">
  69. <a-icon type="ellipsis" />
  70. <span>选择元件</span>
  71. </div>
  72. </a-popover>
  73. <!-- 打开弹窗 -->
  74. <transition name="fade">
  75. <div class="drawer-model" id="drawer-model" v-show="visible">
  76. <a-drawer
  77. placement="left"
  78. :closable="false"
  79. :visible="visible"
  80. :wrap-style="{ position: 'absolute',}"
  81. @close="onClose"
  82. :getContainer="false"
  83. :mask="false"
  84. :wrapClassName="isExtract?'edit-drawer':''"
  85. >
  86. <a-spin :spinning="spinning">
  87. <div class="drawer-model-body" v-if="!isExtract">
  88. <div class="btn-list">
  89. <Tabs
  90. type="card"
  91. v-if="showDrawerItem.type == 'Zone'"
  92. :data="tabData"
  93. v-model="tabActive"
  94. />
  95. </div>
  96. <div class="list" v-for="(item,index) in itemList" :key="index">
  97. <div class="title" v-show="item.GraphElements.length">{{item.Name}}</div>
  98. <ul class="example">
  99. <li
  100. @click="getexampleItem(items,indexs,index)"
  101. v-for="(items,indexs) in item.GraphElements"
  102. :key="indexs"
  103. :class="[activeIndexs==indexs &&activeIndex==index ?'active-li':'']"
  104. :title="items.Name"
  105. >
  106. <img
  107. :class="['item',`item-${items.Type}`]"
  108. :src="'/serve/topology-wanda/Picture/query/'+ items.Url"
  109. alt
  110. />
  111. <div class="text">{{items.Name}}</div>
  112. </li>
  113. </ul>
  114. </div>
  115. </div>
  116. <div v-else class="drawer-model-body drawer-model-body-extract">
  117. <a-table :columns="columns" :data-source="data" size="small" :pagination="false">
  118. <template slot="age" slot-scope="text, record, index">
  119. <div>
  120. <img
  121. :class="['item',`item-${text.Type}`, 'exportImg']"
  122. :src="'/serve/topology-wanda/Picture/query/'+ text.Url"
  123. alt
  124. v-if="text.Url"
  125. />
  126. <span v-else>无对应图例</span>
  127. </div>
  128. </template>
  129. <template slot="address" slot-scope="text, record, index">
  130. <div
  131. style="color:#0091FFFF;cursor:pointer;"
  132. @click="pickUp(text, record, index)"
  133. >{{ text }}</div>
  134. </template>
  135. </a-table>
  136. </div>
  137. </a-spin>
  138. </a-drawer>
  139. </div>
  140. </transition>
  141. </div>
  142. </template>
  143. <script>
  144. import itemTree from "./leftbar_components/itemTree";
  145. import { graphElementGroup, graphElementSearch } from "@/api/editer.js";
  146. import bus from "@/bus";
  147. import { queryGroup } from "@/api/editer.js";
  148. import { mapState, mapActions } from "vuex";
  149. const columns = [
  150. {
  151. title: "名称",
  152. dataIndex: "name"
  153. },
  154. {
  155. title: "图例",
  156. dataIndex: "age",
  157. scopedSlots: { customRender: "age" }
  158. },
  159. {
  160. title: "数量",
  161. dataIndex: "number"
  162. },
  163. {
  164. title: "操作",
  165. dataIndex: "address",
  166. scopedSlots: { customRender: "address" }
  167. }
  168. ];
  169. const data = [];
  170. export default {
  171. components: { itemTree },
  172. props: {
  173. cmdType: {
  174. type: String,
  175. default: "",
  176. required: false
  177. }
  178. },
  179. data() {
  180. return {
  181. // 基础选择
  182. baseChoice: [
  183. {
  184. img: "t-select.png", //logo
  185. hoverImg: "t-select-hover.png", //hoverlogo
  186. isHover: false, //是否hover
  187. isChoice: true,
  188. name: "选择", //类型
  189. type: "choice"
  190. },
  191. {
  192. img: "t-line.png", //logo
  193. hoverImg: "t-line-hover.png", //hoverlogo
  194. isHover: false, //是否hover
  195. isChoice: false,
  196. name: "画线", //类型
  197. type: "baseLine"
  198. },
  199. {
  200. img: "t-text.png", //logo
  201. hoverImg: "t-text-hover.png", //hoverlogo
  202. isHover: false, //是否hover
  203. isChoice: false,
  204. name: "画文字", //类型
  205. type: "baseText"
  206. },
  207. {
  208. img: "t-img.png", //logo
  209. hoverImg: "t-img-hover.png", //hoverlogo
  210. isHover: false, //是否hover
  211. isChoice: false,
  212. name: "画图片", //类型
  213. type: "baseImage"
  214. }
  215. ],
  216. // 系统选择
  217. systemChoice: [
  218. {
  219. img: "t-position.png", //logo
  220. hoverImg: "t-position-hover.png", //hoverlogo
  221. isHover: false, //是否hover
  222. isChoice: false,
  223. name: "位置区域", //类型
  224. type: "Zone"
  225. },
  226. {
  227. img: "t-equipment.png", //logo
  228. hoverImg: "t-equipment-hover.png", //hoverlogo
  229. isHover: false, //是否hover
  230. isChoice: false,
  231. name: "设备设施", //类型
  232. type: "Image"
  233. },
  234. {
  235. img: "t-papeline.png", //logo
  236. hoverImg: "t-papeline-hover.png", //hoverlogo
  237. isHover: false, //是否hover
  238. isChoice: false,
  239. name: "管线桥架", //类型
  240. type: "Line"
  241. }
  242. ],
  243. visible: false,
  244. //提取
  245. extractChoice: [
  246. {
  247. img: "t-slices.png", //logo
  248. hoverImg: "t-slices-hover.png", //hoverlogo
  249. isHover: false, //是否hover
  250. name: "提取" //类型
  251. }
  252. ],
  253. isExtract: false, //是否为提取框
  254. data,
  255. columns,
  256. itemList: [], //图例数组
  257. categoryIdS: [],
  258. categoryId: "",
  259. activeIndex: -1, //选中的图例的父级
  260. activeIndexs: -1, //选中的图例
  261. drawerVisible: false,
  262. spinning: false,
  263. showDrawerItem: {},
  264. tabData: [
  265. { name: "绘制", id: "draw" },
  266. { name: "点选", id: "select" }
  267. ],
  268. tabActive: "select"
  269. };
  270. },
  271. computed: {
  272. ...mapState({
  273. GraphCategoryIds: "GraphCategoryIds",
  274. TypeIdToGraphElement: "TypeIdToGraphElement"
  275. })
  276. },
  277. methods: {
  278. // 触入
  279. mouseoverActive(item) {
  280. item.isHover = true;
  281. },
  282. mouseoutActive(item) {
  283. item.isHover = false;
  284. },
  285. toolActionClick(items) {
  286. this.visible = false;
  287. this.baseChoice.map(item => {
  288. item.isChoice = false;
  289. });
  290. this.systemChoice.map(a => {
  291. a.isChoice = false;
  292. });
  293. items.isChoice = true;
  294. this.$emit("setCmdType", items.type);
  295. },
  296. showDrawer(item) {
  297. this.showDrawerItem = item;
  298. this.isExtract = false;
  299. if (item.isChoice) {
  300. item.isChoice = false;
  301. this.visible = false;
  302. } else {
  303. this.baseChoice.map(a => {
  304. a.isChoice = false;
  305. });
  306. this.systemChoice.map(a => {
  307. a.isChoice = false;
  308. });
  309. this.visible = true;
  310. item.isChoice = true;
  311. // 打开侧边框
  312. // 接口请求
  313. this.itemList = [];
  314. this.spinning = true;
  315. const data = {
  316. GraphCategoryIds: this.categoryId,
  317. Type: item.type
  318. };
  319. queryGroup(data).then(res => {
  320. this.itemList = res.Data;
  321. });
  322. const arr = {
  323. InfoSystems: this.categoryIdS,
  324. Type: item.type
  325. };
  326. graphElementGroup(arr).then(res => {
  327. this.spinning = false;
  328. res.Data.map(item => {
  329. this.itemList.push(item);
  330. });
  331. });
  332. }
  333. },
  334. getSelectId(data) {
  335. this.categoryIdS = data;
  336. this.drawerVisible = false;
  337. },
  338. onClose() {
  339. this.visible = false;
  340. this.systemChoice.forEach(a => {
  341. a.isChoice = false;
  342. });
  343. },
  344. getexampleItem(item, indexs, index) {
  345. if (this.showDrawerItem.type == "Zone") {
  346. if (
  347. (item.SubType && item.SubType == "SCPZ") ||
  348. (item.SubType && item.SubType == "FHFQ")
  349. ) {
  350. this.tabActive = "draw"; //
  351. } else {
  352. this.tabActive = "select";
  353. }
  354. }
  355. this.activeIndex = index;
  356. this.activeIndexs = indexs;
  357. this.$emit("toolActionClick", item);
  358. },
  359. // 提取元素
  360. extractItem() {
  361. // 打开提取元素列表
  362. let isChoice = false;
  363. this.baseChoice.map(item => {
  364. if (item.isChoice) {
  365. isChoice = true;
  366. }
  367. item.isChoice = false;
  368. });
  369. this.systemChoice.map(a => {
  370. if (a.isChoice) {
  371. isChoice = true;
  372. }
  373. a.isChoice = false;
  374. });
  375. this.isExtract = true;
  376. if (isChoice) {
  377. this.visible = true;
  378. } else {
  379. this.visible = !this.visible;
  380. }
  381. bus.$emit("extractItem");
  382. },
  383. getBus() {
  384. bus.$on("exportItem", data => {
  385. this.data = [];
  386. if (data.length) {
  387. data.forEach(t => {
  388. const pa = {
  389. Deleted: false,
  390. InfoTypeIds: [t.key],
  391. PageSize: 1000,
  392. Type: t.type
  393. };
  394. this.spinning = true;
  395. graphElementSearch(pa).then(res => {
  396. this.spinning = false;
  397. if (res.Content && res.Content.length) {
  398. t.age = res.Content[0];
  399. t.name = this.TypeIdToGraphElement[t.key].Name;
  400. t.properties = this.TypeIdToGraphElement[t.key];
  401. this.data.push(t);
  402. }
  403. });
  404. });
  405. }
  406. });
  407. },
  408. pickUp(text, record, index) {
  409. bus.$emit("exportByKey", record);
  410. },
  411. changeDrawType(v) {
  412. // bus.$emit("changeDrawType", v.target.value);
  413. bus.$emit("changeDrawType", v);
  414. }
  415. },
  416. watch: {
  417. cmdType(cmd) {
  418. this.baseChoice.forEach(item => {
  419. item.isChoice = false;
  420. if (item.type == cmd) {
  421. item.isChoice = true;
  422. }
  423. });
  424. if (cmd == "choice") {
  425. this.activeIndex = -1;
  426. }
  427. },
  428. drawerVisible(val) {
  429. if (this.visible) {
  430. this.showDrawer(this.showDrawerItem);
  431. }
  432. },
  433. tabActive: {
  434. handler: function(val) {
  435. this.changeDrawType(val);
  436. },
  437. immediate: true
  438. }
  439. },
  440. mounted() {
  441. const ele = document.getElementById("drawer-model");
  442. ele.style.width = "270px";
  443. this.getBus();
  444. },
  445. created() {
  446. const href = window.location.href;
  447. // 路由
  448. // const route = href.split("?")[0];
  449. // 参数处理
  450. let params = href.split("?")[1];
  451. if (!params) {
  452. // 参数有问题
  453. return false;
  454. }
  455. params = decodeURIComponent(params);
  456. // params = "categoryId=NTXT&ProjectID=5&BuildingID=1&FloorID=1"; // mock 参数
  457. const paramsArr = params.split("&");
  458. const obj = {};
  459. paramsArr.map(item => {
  460. const arr = item.split("=");
  461. obj[arr[0]] = arr[1];
  462. });
  463. this.categoryId = obj.categoryId;
  464. this.categoryIdS.push(obj.categoryId);
  465. this.categoryId;
  466. }
  467. };
  468. </script>
  469. <style lang="less" scoped>
  470. /deep/ .ant-spin-nested-loading {
  471. height: 100% !important;
  472. .ant-spin-container {
  473. height: 100% !important;
  474. }
  475. }
  476. /deep/ .ant-drawer-body {
  477. height: 100% !important;
  478. padding: 12px;
  479. }
  480. /deep/ .ant-drawer-content-wrapper{
  481. width: 270px !important;
  482. }
  483. #left_toolbar {
  484. min-width: 80px;
  485. height: 100%;
  486. background: rgba(255, 255, 255, 1);
  487. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.11);
  488. padding: 0 0 12px 0;
  489. box-sizing: border-box;
  490. position: relative;
  491. ul,
  492. li {
  493. padding: 0;
  494. margin: 0;
  495. list-style: none;
  496. }
  497. .list-1 {
  498. padding-top: 1px;
  499. box-sizing: border-box;
  500. /*border-bottom: 1px solid #c3c7cb;*/
  501. li {
  502. width: 64px;
  503. min-height: 42px;
  504. margin: 6px auto;
  505. display: flex;
  506. align-items: center;
  507. justify-content: center;
  508. position: relative;
  509. cursor: pointer;
  510. .item {
  511. margin: 0 auto;
  512. display: flex;
  513. flex-direction: column;
  514. position: relative;
  515. cursor: pointer;
  516. font-size: 12px;
  517. img {
  518. width: 25px;
  519. height: 25px;
  520. }
  521. }
  522. &:hover {
  523. background: #e1f2ff;
  524. border-radius: 4px;
  525. opacity: 0.89;
  526. color: #fff;
  527. }
  528. .tooltip {
  529. position: absolute;
  530. left: 90px;
  531. top: 0;
  532. }
  533. }
  534. }
  535. .list-2 {
  536. padding-top: 1px;
  537. box-sizing: border-box;
  538. li {
  539. width: 64px;
  540. min-height: 42px;
  541. margin: 6px auto;
  542. display: flex;
  543. align-items: center;
  544. justify-content: center;
  545. position: relative;
  546. .item {
  547. margin: 0 auto;
  548. height: 54px;
  549. display: flex;
  550. flex-direction: column;
  551. position: relative;
  552. cursor: pointer;
  553. align-items: center;
  554. font-size: 12px;
  555. img {
  556. width: 25px;
  557. height: 25px;
  558. margin-top: 6px;
  559. }
  560. }
  561. &:hover {
  562. background: #e1f2ff;
  563. border-radius: 8px;
  564. opacity: 0.89;
  565. color: #0091ff;
  566. }
  567. .tooltip {
  568. position: absolute;
  569. left: 90px;
  570. top: 0;
  571. }
  572. }
  573. }
  574. .bottom-item {
  575. position: absolute;
  576. font-size: 18px;
  577. width: 100%;
  578. bottom: 12px;
  579. height: 54px;
  580. left: 0;
  581. display: flex;
  582. align-items: center;
  583. justify-content: center;
  584. flex-direction: column;
  585. cursor: pointer;
  586. span {
  587. font-size: 12px;
  588. }
  589. &:hover {
  590. background: #e1f2ff;
  591. border-radius: 8px;
  592. opacity: 0.89;
  593. color: #0091ff;
  594. height: 54px;
  595. }
  596. }
  597. .actives {
  598. background: #e1f2ff;
  599. border-radius: 8px;
  600. opacity: 0.89;
  601. color: #0091ff;
  602. }
  603. .fade-enter,
  604. .fade-leave-to {
  605. transition: all 0.3s ease;
  606. }
  607. .drawer-model {
  608. position: absolute;
  609. left: 80px;
  610. border-left: 1px solid #e8e8e8;
  611. top: 0;
  612. overflow: hidden;
  613. width: 100%;
  614. height: 100%;
  615. z-index: 0;
  616. .drawer-model-body {
  617. width: 100%;
  618. .btn-list {
  619. width: 123px;
  620. margin: 0 auto;
  621. }
  622. .list {
  623. .title {
  624. font-size: 16px;
  625. border-left: 4px solid #0091ff;
  626. margin-top: 20px;
  627. text-indent: 8px;
  628. height: 20px;
  629. line-height: 20px;
  630. color: #1f2329;
  631. margin-bottom: 12px;
  632. }
  633. .example {
  634. width: 100%;
  635. display: flex;
  636. flex-wrap: wrap;
  637. li {
  638. width: 80px;
  639. height: 60px;
  640. display: flex;
  641. justify-content: center;
  642. flex-direction: column;
  643. border: 1px solid #ffffff;
  644. cursor: pointer;
  645. &:hover {
  646. background: #F5F6F7;
  647. border: 1px solid #D9DBDE;
  648. border-radius: 5px;
  649. }
  650. .item {
  651. width: 30px;
  652. height: 22px;
  653. margin: 0 auto;
  654. }
  655. .item-Image {
  656. width: 18px;
  657. height: 18px;
  658. margin: 0 auto;
  659. }
  660. .item-Line {
  661. width: 40px;
  662. height: 30px;
  663. margin: 0 auto;
  664. }
  665. .item-pip {
  666. width: 28px;
  667. height: 16px;
  668. border: #0091ff solid 1px;
  669. margin: 0 auto;
  670. background: #fff;
  671. }
  672. .text {
  673. width: 100%;
  674. padding:6px 2px 0;
  675. font-size: 12px;
  676. text-align: center;
  677. overflow: hidden;
  678. text-overflow: ellipsis;
  679. white-space: nowrap;
  680. }
  681. }
  682. .active-li {
  683. background: #DFEFFE;
  684. border: 1px solid #98C8FA ;
  685. border-radius: 5px;
  686. }
  687. }
  688. }
  689. }
  690. /deep/ .edit-drawer .ant-drawer-body {
  691. padding: 0;
  692. .ant-table-small {
  693. border-left: none;
  694. border-right: none;
  695. border-radius: 0;
  696. }
  697. .ant-table-small > .ant-table-content > .ant-table-body {
  698. margin: 0;
  699. .ant-table-thead {
  700. font-size: 12px;
  701. }
  702. }
  703. }
  704. .drawer-model-body-extract {
  705. padding: 0;
  706. position: absolute;
  707. left: 0;
  708. right: 0;
  709. /deep/ .ant-table-thead tr th {
  710. background: #f8f9fa;
  711. }
  712. .exportImg.item-Zone {
  713. width: 28px;
  714. height: 16px;
  715. }
  716. .exportImg.item-Image {
  717. width: 20px;
  718. height: 20px;
  719. }
  720. .ant-table-small {
  721. border: none !important;
  722. }
  723. }
  724. }
  725. .border-top {
  726. /*border-top: 1px solid #c3c7cb;*/
  727. }
  728. .border-line {
  729. width: 48px;
  730. height: 2px;
  731. background: #c3c7cb;
  732. margin: 0 auto;
  733. }
  734. }
  735. </style>