top_toolbar.vue 6.4 KB

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