editline1_copy.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="edit-line">
  3. <div class="btn-list">
  4. <el-button :class="[cmdStatus=='choice' ? 'heightLight' : '']" size="small" @click="choice">选择</el-button>
  5. <el-button :class="[cmdStatus=='create' ? 'heightLight' : '']" size="small" @click="create">画线</el-button>
  6. <el-button :class="[cmdStatus=='edit' ? 'heightLight' : '']" size="small" @click="edit">编辑</el-button>
  7. <el-button :class="[cmdStatus=='deleteItem' ? 'heightLight' : '']" size="small" @click="deleteItem">删除
  8. </el-button>
  9. <el-button :class="[cmdStatus=='undo' ? 'heightLight' : '']" size="small" @click="undo">undo</el-button>
  10. <el-button :class="[cmdStatus=='redo' ? 'heightLight' : '']" size="small" @click="redo">redo</el-button>
  11. <el-button :class="[cmdStatus=='eqDrawLine' ? 'heightLight' : '']" size="small" @click="eqDrawLine">垂直水平划线
  12. </el-button>
  13. </div>
  14. <div class="content">
  15. <div class="left">
  16. <canvas id="edit_line" width="700" height="460" tabindex="0"/>
  17. </div>
  18. <div class="line-property">
  19. <el-card shadow="always">
  20. <div class="always-item">
  21. <span>线宽:</span>
  22. <input type="text"/>
  23. </div>
  24. <div class="always-item">
  25. <span>线类型:</span>
  26. <input type="text"/>
  27. </div>
  28. <div class="always-item">
  29. <span>线颜色:</span>
  30. <input type="text"/>
  31. </div>
  32. </el-card>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. import { SGraphScene, SGraphView } from "@persagy-web/graph/";
  39. import { SItemStatus } from "@persagy-web/big/lib/enums/SItemStatus";
  40. import { EditLineItem } from "./../../../../../guides/edit/items/src/EditLineItem";
  41. //注: 开发者引入 SWallItem 包为: import {SWallItem} from "@persagy-web/edit/";
  42. export default {
  43. name: "line",
  44. data() {
  45. return {
  46. scene: null,
  47. view: null,
  48. isCreated: false, //是否创建完成
  49. cmdStatus: 'choice' //选中状态
  50. };
  51. },
  52. mounted() {
  53. this.view = new SGraphView("edit_line");
  54. this.scene = new SGraphScene();
  55. this.view.scene = this.scene;
  56. },
  57. methods: {
  58. create() {
  59. this.cmdStatus = 'create';
  60. // this.scene.root.children = [];
  61. const lineItem = new EditLineItem(null, []);
  62. lineItem.status = SItemStatus.Create;
  63. lineItem.connect("finishCreated", this, this.finishCreated);
  64. this.scene.addItem(lineItem);
  65. this.scene.grabItem = lineItem;
  66. this.scene.updated()
  67. },
  68. // 完成创建后的回调
  69. finishCreated() {
  70. this.cmdStatus = 'choice'
  71. }
  72. }
  73. };
  74. </script>
  75. <style scoped lang="less">
  76. .edit-line {
  77. width: 100%;
  78. height: 500px;
  79. .content {
  80. display: flex;
  81. .left {
  82. flex: 1;
  83. }
  84. .line-property {
  85. width: 300px;
  86. .always-item {
  87. display: flex;
  88. margin-top: 10px;
  89. justify-content: space-around;
  90. }
  91. }
  92. }
  93. .heightLight {
  94. color: #409EFF;
  95. border-color: #c6e2ff;
  96. background-color: #ecf5ff;
  97. }
  98. }
  99. </style>