menus.ts 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import { uiType, UIType, graphicState } from "@/hook/useGraphic";
  2. import {
  3. findMenuByAttr,
  4. generateByMenus as generateByMenusRaw,
  5. generateMixMenus as generateMixMenusRaw,
  6. } from "@/utils/menus";
  7. import Message from "@/components/base/components/message/message.vue";
  8. import RoadStructure from "@/graphic/enum/RoadStructure";
  9. import RoadTemplate from "@/graphic/enum/RoadTemplate";
  10. import { computed } from "vue";
  11. import { mount } from "@/components/base/utils/componentHelper";
  12. import Setting from "@/views/graphic/setting.vue";
  13. export enum Mode {
  14. Road,
  15. Photo,
  16. }
  17. export const UITypeExtend = {
  18. structure: "structure",
  19. template: "template",
  20. measure: "measure",
  21. road: "__road",
  22. image: "__image",
  23. line: "__line",
  24. photo: "photo",
  25. setup: "setup",
  26. lineType: "lineType",
  27. width: "width",
  28. lock: "lock",
  29. basemap: "Basemap",
  30. };
  31. export type MenuRaw = {
  32. key: string;
  33. text: string;
  34. onClick?: (data: MenuRaw) => void;
  35. icon?: string;
  36. children?: MenusRaw;
  37. extend?: MenusRaw;
  38. };
  39. export type MenusRaw = Array<MenuRaw>;
  40. export const structureMenusRaw = [
  41. { key: RoadStructure.BranchRoad, icon: "jg_zl-1", text: "支路" },
  42. { key: RoadStructure.NarrowRoad, icon: "jg_zl", text: "窄路" },
  43. { key: RoadStructure.ShoulderRoad, icon: "jg_lj", text: "路肩" },
  44. { key: RoadStructure.ZebraCrossing, icon: "jg_bmx", text: "斑马线" },
  45. { key: RoadStructure.Bridge, icon: "jg_q", text: "桥" },
  46. { key: RoadStructure.Tunnel, icon: "jg_sd", text: "隧道" },
  47. { key: RoadStructure.Sidewalk, icon: "jg_rxd", text: "人行道" },
  48. { key: RoadStructure.ConstructionSection, icon: "jg_sgld", text: "施工路段" },
  49. { key: RoadStructure.Downhill, icon: "jg_road_u", text: "下坡" },
  50. { key: RoadStructure.Uphill, icon: "jg_sp", text: "上坡" },
  51. { key: RoadStructure.RoadsideGutter, icon: "jg_lpsg", text: "路边水沟" },
  52. { key: RoadStructure.RoadsAndRails, icon: "jg_dltlpjk", text: "道路与铁..." },
  53. { key: RoadStructure.FireHydrantWell, icon: "jg_xfsj", text: "消火栓井" },
  54. { key: RoadStructure.Gullies, icon: "jg_ysk", text: "雨水口" },
  55. { key: RoadStructure.RoadPotholes, icon: "jg_lmak", text: "路面凹坑" },
  56. { key: RoadStructure.ProtrudingRoad, icon: "jg_lmtcbf", text: "路面凸出..." },
  57. { key: RoadStructure.WaterOnTheRoad, icon: "jg_lmjs", text: "路面积水" },
  58. ];
  59. export const templateMenusRaw = [
  60. { key: RoadTemplate.SBend, icon: "mb_sxwl", text: "s型弯路" },
  61. { key: RoadTemplate.TJunction, icon: "mb_dzlk", text: "丁字路口" },
  62. { key: RoadTemplate.FiveForks, icon: "mb_wclk", text: "五岔路口" },
  63. { key: RoadTemplate.ExitRamp, icon: "mb_ckzd", text: "出口匝道" },
  64. { key: RoadTemplate.Crossroads, icon: "mb_szlk", text: "十字路口" },
  65. {
  66. key: RoadTemplate.NationalHighwayShoulder,
  67. icon: "mb_gdlj",
  68. text: "国道(路肩)",
  69. },
  70. { key: RoadTemplate.IndoorSection, icon: "mb_snld", text: "室内路段" },
  71. { key: RoadTemplate.Bend, icon: "mb_wd", text: "弯道" },
  72. { key: RoadTemplate.SharpCurve, icon: "mb_jzwd", text: "急转弯道" },
  73. { key: RoadTemplate.SixForkIntersection, icon: "mb_lclk", text: "六岔路口" },
  74. // { key: RoadTemplate.WideNarrowRoad, icon: 'mb_kbzld', text: '宽变窄路段' },
  75. { key: RoadTemplate.Corner, icon: "mb_zjwd", text: "直角弯道" },
  76. { key: RoadTemplate.ImportSmashedRoad, icon: "mb_jkzd", text: "进口匝道" },
  77. {
  78. key: RoadTemplate.HighSpeedTollBooth,
  79. icon: "mb_gssfz",
  80. text: "高速收费站",
  81. },
  82. // { key: RoadTemplate.HighSpeedHarbor, icon: 'mb_gsgw', text: '高速港湾' },
  83. { key: RoadTemplate.HighwaySection, icon: "mb_gsld", text: "高速路段" },
  84. ];
  85. export const measureMenusRaw = [
  86. {
  87. key: UIType.BaseLine,
  88. icon: "line",
  89. text: "基准线",
  90. disabled: computed(() => graphicState.value.existsBaseLine),
  91. },
  92. { key: UIType.BasePoint, text: "基准点", icon: "point", border: true },
  93. // {
  94. // key: UIType.NormalLocationMode,
  95. // text: '垂线定位',
  96. // icon: 'measure_f',
  97. // onClick(data) {
  98. // if (graphicState.value.canVerticalMeasure) {
  99. // uiType.change(data.key);
  100. // } else {
  101. // Message.success({ msg: '请添加基准线后再执行此操作', time: 3000 });
  102. // }
  103. // },
  104. // },
  105. {
  106. desc: "一键测量",
  107. key: UIType.AngleLocationMode,
  108. text: "直角定位法",
  109. icon: "measure_r",
  110. // onClick(data) {
  111. // console.error(graphicState.value.canAllLocationMode);
  112. // if (graphicState.value.canAllLocationMode) {
  113. // uiType.change(data.key);
  114. // } else {
  115. // Message.success({
  116. // msg: "请添加基准线及基准点后再执行此操作",
  117. // time: 3000,
  118. // });
  119. // }
  120. // },
  121. },
  122. // {
  123. // key: UIType.AllLocationMode,
  124. // text: "综合定位法",
  125. // icon: "measure_c",
  126. // // onClick(data) {
  127. // // if (graphicState.value.canAllLocationMode) {
  128. // // uiType.change(data.key);
  129. // // } else {
  130. // // Message.success({
  131. // // msg: "请添加基准线及基准点后再执行此操作",
  132. // // time: 3000,
  133. // // });
  134. // // }
  135. // // },
  136. // border: true,
  137. // },
  138. {
  139. key: UIType.FreeMeasureLine,
  140. text: "自由测量",
  141. icon: "measure_free",
  142. },
  143. ];
  144. export const mainMenusRaw: MenusRaw = [
  145. {
  146. key: UIType.Line,
  147. text: "画线",
  148. icon: "line_d",
  149. // children: [
  150. // {
  151. // key: UIType.Line,
  152. // text: "直线",
  153. // icon: "line_d",
  154. // },
  155. // {
  156. // key: UIType.CurveLine,
  157. // text: "曲线",
  158. // icon: "line_d",
  159. // }
  160. // ]
  161. },
  162. {
  163. key: UITypeExtend.road,
  164. text: "道路",
  165. icon: "road",
  166. children: [
  167. { key: UIType.OneEdgeOneLanRoad, icon: "road_ss", text: "" },
  168. { key: UIType.OneEdgeTwoLanRoad, icon: "road_sd", text: "" },
  169. { key: UIType.OneEdgeThreeLanRoad, icon: "road_st", text: "" },
  170. { key: UIType.TwoEdgeOneLanRoad, icon: "road_ds", text: "" },
  171. { key: UIType.TwoEdgeTwoLanRoad, icon: "road_dd", text: "" },
  172. { key: UIType.TwoEdgeThreeLanRoad, icon: "road_dt", text: "" },
  173. { key: UIType.CurveRoad, icon: "road_wl", text: "" },
  174. // { key: UITypeExtend.structure, icon: 'r_template', text: '道路结构', extend: structureMenusRaw },
  175. {
  176. key: UITypeExtend.template,
  177. icon: "r_structure",
  178. text: "道路模板",
  179. extend: templateMenusRaw,
  180. },
  181. ],
  182. },
  183. {
  184. key: UITypeExtend.image,
  185. text: "图例",
  186. icon: "legend",
  187. // children: [
  188. // { key: UIType.BusPlane, text: "客车平面图" }
  189. // ]
  190. },
  191. { key: UIType.FixPoint, text: "固定点", icon: "point_a" },
  192. {
  193. key: UITypeExtend.measure,
  194. text: "测量",
  195. children: measureMenusRaw,
  196. icon: "measure",
  197. },
  198. { key: UIType.Text, text: "文字", icon: "text" },
  199. { key: UIType.Magnifier, text: "放大镜", icon: "magnify_g" },
  200. // { key: UITypeExtend.photo, text: "照片库" },
  201. {
  202. key: UITypeExtend.setup,
  203. icon: "setting",
  204. text: "设置",
  205. onClick() {
  206. const { destroy } = mount(Setting, {
  207. props: {
  208. close() {
  209. destroy();
  210. },
  211. },
  212. } as any);
  213. },
  214. },
  215. ];
  216. export const photoMenusRaw: MenusRaw = [
  217. { key: UIType.Text, text: "文字", icon: "text" },
  218. { key: UIType.Circle, text: "圈出", icon: "circle" },
  219. { key: UIType.SingleArrow, text: "箭头", icon: "arrows" },
  220. { key: UIType.Magnifier, text: "放大镜", icon: "magnify_g" },
  221. ];
  222. export const headActionMenuRaw = [
  223. { key: UIType.GoBack, text: "回退", icon: "backout" },
  224. { key: UIType.GoAhead, text: "前进", icon: "redo" },
  225. { key: UIType.Clear, text: "清除", icon: "reset" },
  226. { key: UIType.BackImageChange, text: "底图开关", icon: "map" },
  227. ];
  228. export const focusMenuRaw: { [key in string]: MenusRaw } = {};
  229. export const generateByMenus = <T extends MenuRaw>(
  230. generateFn: (men: MenuRaw) => T,
  231. mainMenus: MenusRaw = mainMenusRaw
  232. ) => generateByMenusRaw(generateFn, mainMenus);
  233. export const findMainMenuByAttr = (
  234. value: MenusRaw,
  235. attr = "extend" as const,
  236. mainMenus = mainMenusRaw
  237. ) => findMenuByAttr(value, attr, mainMenus);
  238. export const generateMixMenus = <T extends {}, K extends keyof MenuRaw>(
  239. childKey: K,
  240. generateFn: (men: MenuRaw) => T,
  241. mainMenus: MenusRaw = mainMenusRaw
  242. ) =>
  243. generateMixMenusRaw(
  244. childKey,
  245. generateFn,
  246. mainMenus,
  247. (menu) => {
  248. if (menu.onClick) {
  249. menu.onClick(menu);
  250. } else {
  251. if (menu.key === uiType.current) {
  252. uiType.change(null);
  253. } else {
  254. uiType.change(menu.key as any);
  255. }
  256. }
  257. },
  258. () => uiType.current
  259. );