OnlinePlotting.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="gradient-text title">实时标绘</div>
  3. <el-select v-model="mouseToolState.lineWidth" placeholder="Select" style="width: 240px">
  4. <el-option v-for="item in lineWidthOptions" :key="item.value" :label="item.name" :value="item.value">
  5. <span>{{ item.name }}</span>
  6. </el-option>
  7. </el-select>
  8. <el-color-picker v-model="mouseToolState.color" popper-class="custom-color-picker" show-alpha size="large" />
  9. <el-button size="large" @click="changeDrawing">{{ drawing ? '关闭' : '开启' }}</el-button>
  10. <div class="tabs1">
  11. <div v-for="(item, index) in menu" :key="index" :class="menuActive1 === index ? 'tab tab_active' : 'tab'" @click="clickTab(index)">
  12. {{ item.name }}
  13. </div>
  14. </div>
  15. <div v-show="menuActive1 === 0" class="tab-content">
  16. <div class="tabs2">
  17. <div
  18. v-for="(item, index) in menu[menuActive1].children"
  19. :key="index"
  20. :class="menuActive2 === index ? 'tab tab_active' : 'tab'"
  21. @click="clickTab2(index)"
  22. >
  23. {{ item.name }}
  24. </div>
  25. <div class="tab-content2">
  26. <div
  27. v-for="(item, index) in menu[menuActive1].children[menuActive2].children"
  28. :key="index"
  29. :class="menuActive2 === index ? 'tab tab_active' : 'tab'"
  30. @click="clickTab3(item.value)"
  31. >
  32. {{ item.name }}
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. <div v-show="menuActive1 === 1" class="tab-content">历史记录</div>
  38. <div v-show="textEditState.showTextEdit" class="text-edit-container">
  39. <el-input v-model="textEditState.text" :rows="8" type="textarea" />
  40. <div class="edit-box">
  41. <div class="flex">
  42. <div class="text">字号</div>
  43. <el-input v-model="textEditState.fonSize" />
  44. </div>
  45. <div class="flex">
  46. <div class="text">颜色</div>
  47. <el-color-picker v-model="textEditState.fontColor" popper-class="custom-color-picker" show-alpha size="large" />
  48. </div>
  49. </div>
  50. <div class="edit-btn-box">
  51. <el-button size="large" @click="textEditState.show = false">取消</el-button>
  52. <el-button type="primary" size="large" @click="addText">确定</el-button>
  53. </div>
  54. </div>
  55. </template>
  56. <script lang="ts" setup>
  57. interface Props {
  58. drawing: boolean;
  59. mouseToolState: MouseTool;
  60. }
  61. const props = withDefaults(defineProps<Props>(), {});
  62. const emits = defineEmits(['updateDrawing', 'updateMouseToolState']);
  63. const menuActive1 = ref(0);
  64. const menuActive2 = ref(0);
  65. const menu = ref([
  66. {
  67. name: '标绘工具',
  68. children: [
  69. {
  70. name: '基本工具',
  71. value: 'basicTools',
  72. children: [
  73. {
  74. name: '直箭头',
  75. value: 'straightArrow'
  76. },
  77. {
  78. name: '矩形',
  79. value: 'rectangle'
  80. },
  81. {
  82. name: '任意面',
  83. value: 'polygon'
  84. },
  85. {
  86. name: '任意线',
  87. value: 'anyLine'
  88. },
  89. {
  90. name: '圆',
  91. value: 'circle'
  92. },
  93. {
  94. name: '直线',
  95. value: 'straightLine'
  96. },
  97. {
  98. name: '文字',
  99. value: 'text'
  100. },
  101. {
  102. name: '面积',
  103. value: ''
  104. }
  105. ]
  106. },
  107. { name: '火点', value: 'firePoint', children: [] },
  108. { name: '火线', value: 'firewire', children: [] },
  109. { name: '火场', value: 'fireGround', children: [] },
  110. { name: '箭头', value: 'arrow', children: [] },
  111. { name: '导航', value: 'navigation', children: [] },
  112. { name: '扑救队伍', value: 'firefightingTeam', children: [] },
  113. { name: '飞机车辆', value: 'aircraftVehicles', children: [] },
  114. { name: '基础设置', value: 'basicSetting', children: [] },
  115. { name: '其他', value: 'other', children: [] }
  116. ]
  117. },
  118. {
  119. name: '历史记录',
  120. children: []
  121. }
  122. ]);
  123. const lineWidthOptions = reactive([
  124. { name: '1像素', value: '1' },
  125. { name: '2像素', value: '2' },
  126. { name: '3像素', value: '3' }
  127. ]);
  128. const textEditState = reactive({
  129. showTextEdit: false,
  130. fontColor: '#f80102',
  131. fontSize: '36',
  132. text: ''
  133. });
  134. // 点击一级菜单
  135. const clickTab = (value: number) => {
  136. menuActive1.value = value;
  137. };
  138. // 点击二级菜单
  139. const clickTab2 = (value: number) => {
  140. menuActive2.value = value;
  141. };
  142. // 点击三级菜单
  143. const clickTab3 = (type) => {
  144. if (props.mouseToolState.graphicsType === type) {
  145. emits('updateDrawing', false);
  146. props.mouseToolState.graphicsType = '';
  147. } else {
  148. emits('updateDrawing', true);
  149. props.mouseToolState.graphicsType = type;
  150. }
  151. };
  152. const handleClick = () => {
  153. textEditState.fontColor = props.mouseToolState.color;
  154. textEditState.fontSize = props.mouseToolState.fontSize;
  155. textEditState.showTextEdit = true;
  156. };
  157. const addText = () => {
  158. emits('updateMouseToolState', {
  159. color: props.mouseToolState.color,
  160. lineWidth: props.mouseToolState.lineWidth,
  161. drawType: props.mouseToolState.drawType,
  162. graphicsType: 'text',
  163. fontColor: textEditState.fontColor,
  164. fontSize: textEditState.fontSize
  165. });
  166. textEditState.showTextEdit = false;
  167. };
  168. const changeDrawing = () => {
  169. emits('updateDrawing', !props.drawing);
  170. };
  171. </script>
  172. <style lang="scss" scoped>
  173. .title {
  174. font-size: 60px;
  175. position: absolute;
  176. top: 12px;
  177. left: 210px;
  178. }
  179. :deep(.el-color-dropdown__link-btn) {
  180. display: none;
  181. }
  182. .text-edit-container {
  183. position: fixed;
  184. top: 500px;
  185. left: 50%;
  186. transform: translateX(-50%);
  187. width: 600px;
  188. height: 400px;
  189. background-color: #fff;
  190. border-radius: 10px;
  191. padding: 20px;
  192. font-size: 36px;
  193. .edit-box {
  194. margin-top: 20px;
  195. display: flex;
  196. .flex {
  197. flex: 1;
  198. margin-right: 20px;
  199. }
  200. .text {
  201. white-space: nowrap;
  202. margin-right: 8px;
  203. }
  204. .edit-btn-box {
  205. margin-top: 20px;
  206. display: flex;
  207. }
  208. }
  209. }
  210. </style>