top_toolbar.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div id="top_toolbar">
  3. <!-- 顶部编辑器 -->
  4. <div class="tit">
  5. <!-- <a-icon type="left" /> -->
  6. {{this.urlMsg.floorName}}
  7. </div>
  8. <div class="tool">
  9. <ul>
  10. <li @click="saveMsg">
  11. <img class="lock" :src="require(`./../../assets/images/t-save.png`)" alt />
  12. <span>保存</span>
  13. </li>
  14. <!-- <li>
  15. <a-icon type="edit" />
  16. <span>撤销</span>
  17. </li>
  18. <li>
  19. <a-icon type="edit" />
  20. <span>重做</span>
  21. </li>-->
  22. <li class="zoom-window">
  23. <div>
  24. <img class="lock" :src="require(`./../../assets/images/缩小.png`)" alt />
  25. <span class="percentage">100%</span>
  26. <img class="lock" :src="require(`./../../assets/images/放大 amplification.png`)" alt />
  27. </div>
  28. <span>缩放窗口</span>
  29. </li>
  30. <li>
  31. <a-dropdown :trigger="['click']">
  32. <div class="ant-dropdown-link dropdown-flex" @click="e => e.preventDefault()">
  33. <div>
  34. <img class="lock" :src="require(`./../../assets/images/t-format.png`)" alt />
  35. <div>对齐</div>
  36. </div>
  37. <a-icon type="caret-down" class="down-icon" />
  38. </div>
  39. <a-menu slot="overlay">
  40. <a-menu-item
  41. v-for="item in alignmentOptions"
  42. :key="item.value"
  43. @click="changeAlignItem(item.value)"
  44. >
  45. <img
  46. style="width: 16px;margin-right: 5px;"
  47. :src="require(`./../../assets/images/`+item.img+`.png`)"
  48. alt
  49. />
  50. <span>{{item.label}}</span>
  51. </a-menu-item>
  52. </a-menu>
  53. </a-dropdown>
  54. </li>
  55. <!-- <li>
  56. <a-icon type="edit" />
  57. <span>图层</span>
  58. </li>
  59. <li>
  60. <a-icon type="edit" />
  61. <span>组合</span>
  62. </li>
  63. <li>
  64. <a-icon type="edit" />
  65. <span>打散</span>
  66. </li>-->
  67. <li @click="lockItem">
  68. <Icon :name="!isLock?'lock':'unlock'" />
  69. <span>{{isLock?"解锁":"锁定"}}</span>
  70. </li>
  71. <li @click="deleteItem">
  72. <a-icon type="delete" />
  73. <span>删除</span>
  74. </li>
  75. </ul>
  76. </div>
  77. <div class="btn-list">
  78. <div class="btn-list-item">
  79. <Icon name="release" />
  80. <span>发布</span>
  81. </div>
  82. </div>
  83. </div>
  84. </template>
  85. <script>
  86. import bus from "@/bus";
  87. import { SGraphLayoutType } from "@saga-web/graph/lib";
  88. export default {
  89. data() {
  90. return {
  91. isLock: false, //是否锁定
  92. focusItem: null,
  93. alignmentOptions: [
  94. //对齐数据
  95. {
  96. value: SGraphLayoutType.Left,
  97. label: "左对齐",
  98. img: "t-left"
  99. },
  100. {
  101. value: SGraphLayoutType.Right,
  102. label: "右对齐",
  103. img: "t-right"
  104. },
  105. {
  106. value: SGraphLayoutType.Top,
  107. label: "顶对齐",
  108. img: "t-top"
  109. },
  110. {
  111. value: SGraphLayoutType.Bottom,
  112. label: "底对齐",
  113. img: "t-bottom"
  114. },
  115. {
  116. value: SGraphLayoutType.Center,
  117. label: "水平居中对齐",
  118. img: "t-center"
  119. },
  120. {
  121. value: SGraphLayoutType.Middle,
  122. label: "垂直居中对齐",
  123. img: "t-topandbottm"
  124. },
  125. {
  126. value: SGraphLayoutType.Vertical,
  127. label: "垂直分布",
  128. img: "t-vertical"
  129. },
  130. {
  131. value: SGraphLayoutType.Horizontal,
  132. label: "水平分布",
  133. img: "t-level"
  134. }
  135. ]
  136. };
  137. },
  138. methods: {
  139. FocusItemChanged(itemMsg) {
  140. this.focusItem = null;
  141. if (itemMsg.itemList.length == 1) {
  142. this.isLock = itemMsg.itemList[0].moveable;
  143. this.focusItem = itemMsg.itemList[0];
  144. }
  145. },
  146. lockItem() {
  147. if (this.focusItem) {
  148. this.isLock = !this.isLock;
  149. this.focusItem.moveable = this.isLock;
  150. } else {
  151. this.$message.error("请选择指定对象!", 1);
  152. }
  153. },
  154. saveMsg() {
  155. // this.$message.success("保存成功!", 1);
  156. bus.$emit("saveMsgItem");
  157. },
  158. // 删除item
  159. deleteItem() {
  160. console.log(this.focusItem);
  161. if (this.focusItem) {
  162. bus.$emit("deleiteItem");
  163. this.focusItem = null;
  164. this.$message.success("删除成功", 1);
  165. } else {
  166. this.$message.error("请选择指定对象!", 1);
  167. }
  168. },
  169. // 对齐item
  170. changeAlignItem(val) {
  171. bus.$emit("changeAlignItem", val);
  172. }
  173. },
  174. mounted() {
  175. bus.$on("FocusItemChanged", itemMsg => {
  176. console.log("itemMsg", itemMsg);
  177. this.FocusItemChanged(itemMsg);
  178. });
  179. },
  180. created() {
  181. const href = window.location.href;
  182. // 路由
  183. // const route = href.split("?")[0];
  184. // 参数处理
  185. let params = href.split("?")[1];
  186. if (!params) {
  187. // 参数有问题
  188. return false;
  189. }
  190. params = decodeURIComponent(params);
  191. // params = "categoryId=NTXT&ProjectID=5&BuildingID=1&FloorID=1"; // mock 参数
  192. const paramsArr = params.split("&");
  193. console.log("paramsArr", paramsArr);
  194. const obj = {};
  195. paramsArr.map(item => {
  196. const arr = item.split("=");
  197. obj[arr[0]] = arr[1];
  198. });
  199. this.urlMsg = obj;
  200. // ///////////测试代码
  201. this.urlMsg.floorName = "消防系统-4F";
  202. }
  203. };
  204. </script>
  205. <style lang="less" scoped>
  206. ul,
  207. li {
  208. /*margin: 0;*/
  209. /*padding: 0;*/
  210. list-style: none;
  211. }
  212. #top_toolbar {
  213. width: 100%;
  214. height: 60px;
  215. background: rgba(255, 255, 255, 1);
  216. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  217. display: flex;
  218. align-items: center;
  219. justify-content: space-between;
  220. padding: 0 24px 0 24px;
  221. .tit {
  222. // flex: 1;
  223. font-size: 18px;
  224. font-weight: bold;
  225. color: #1f2429;
  226. }
  227. .tool {
  228. ul {
  229. display: flex;
  230. li {
  231. display: flex;
  232. justify-content: center;
  233. flex-direction: column;
  234. /*width: 62px;*/
  235. padding: 0 7px;
  236. margin-left: 7px;
  237. font-size: 12px;
  238. align-items: center;
  239. text-align: center;
  240. cursor: pointer;
  241. img {
  242. width: 16px;
  243. height: 16px;
  244. }
  245. .percentage {
  246. border-bottom: 1px solid #c3c7cb;
  247. margin: 0 13px;
  248. font-size: 14px;
  249. }
  250. .dropdown-flex {
  251. display: flex;
  252. align-items: center;
  253. .down-icon {
  254. margin-left: 12px;
  255. }
  256. }
  257. }
  258. li:hover {
  259. background: #f5f6f7;
  260. }
  261. .zoom-window {
  262. border-left: 1px solid #8d9399;
  263. border-right: 1px solid #8d9399;
  264. }
  265. }
  266. }
  267. .btn-list {
  268. display: flex;
  269. align-items: center;
  270. justify-content: center;
  271. width: 72px;
  272. .btn-list-item {
  273. display: flex;
  274. justify-content: center;
  275. flex-direction: column;
  276. span {
  277. font-size: 12px;
  278. }
  279. cursor: pointer;
  280. }
  281. }
  282. }
  283. /deep/ .ant-dropdown-menu-item {
  284. display: flex;
  285. align-items: center;
  286. }
  287. </style>