index.vue 82 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. :model="queryParams"
  5. ref="queryForm"
  6. size="small"
  7. :inline="true"
  8. v-show="showSearch"
  9. label-width="68px"
  10. >
  11. <el-form-item label="任务名称" prop="bizName">
  12. <el-input
  13. v-model="queryParams.bizName"
  14. placeholder="请输入任务名称"
  15. clearable
  16. @keyup.enter.native="handleQuery"
  17. />
  18. </el-form-item>
  19. <el-form-item label="状态" prop="status">
  20. <el-select
  21. v-model="queryParams.status"
  22. placeholder="请选择状态"
  23. clearable
  24. >
  25. <el-option
  26. v-for="dict in dict.type.uavps_task_status"
  27. :key="dict.value"
  28. :label="dict.label"
  29. :value="dict.value"
  30. />
  31. </el-select>
  32. </el-form-item>
  33. <el-form-item label="开始时间" prop="startTime">
  34. <el-date-picker
  35. clearable
  36. v-model="queryParams.startTime"
  37. type="date"
  38. value-format="yyyy-MM-dd"
  39. placeholder="请选择开始时间"
  40. >
  41. </el-date-picker>
  42. </el-form-item>
  43. <el-form-item label="结束时间" prop="endTime">
  44. <el-date-picker
  45. clearable
  46. v-model="queryParams.endTime"
  47. type="date"
  48. value-format="yyyy-MM-dd"
  49. placeholder="请选择结束时间"
  50. >
  51. </el-date-picker>
  52. </el-form-item>
  53. <el-form-item label="创建时间">
  54. <el-date-picker
  55. v-model="daterangeCreateTime"
  56. style="width: 240px"
  57. value-format="yyyy-MM-dd"
  58. type="daterange"
  59. range-separator="-"
  60. start-placeholder="开始日期"
  61. end-placeholder="结束日期"
  62. ></el-date-picker>
  63. </el-form-item>
  64. <el-form-item>
  65. <el-button
  66. type="primary"
  67. icon="el-icon-search"
  68. size="mini"
  69. @click="handleQuery"
  70. >搜索</el-button
  71. >
  72. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  73. >重置</el-button
  74. >
  75. </el-form-item>
  76. </el-form>
  77. <el-row :gutter="10" class="mb8">
  78. <el-col :span="1.5">
  79. <el-button
  80. type="primary"
  81. plain
  82. icon="el-icon-plus"
  83. size="mini"
  84. @click="handleAdd"
  85. v-hasPermi="['system:task:add']"
  86. >新增</el-button
  87. >
  88. </el-col>
  89. <el-col :span="1.5">
  90. <el-button
  91. type="success"
  92. plain
  93. icon="el-icon-edit"
  94. size="mini"
  95. :disabled="single"
  96. @click="handleUpdate"
  97. v-hasPermi="['system:task:edit']"
  98. >修改</el-button
  99. >
  100. </el-col>
  101. <el-col :span="1.5">
  102. <el-button
  103. type="danger"
  104. plain
  105. icon="el-icon-delete"
  106. size="mini"
  107. :disabled="multiple"
  108. @click="handleDelete"
  109. v-hasPermi="['system:task:remove']"
  110. >删除</el-button
  111. >
  112. </el-col>
  113. <el-col :span="1.5">
  114. <el-button
  115. type="warning"
  116. plain
  117. icon="el-icon-download"
  118. size="mini"
  119. @click="handleExport"
  120. v-hasPermi="['system:task:export']"
  121. >导出</el-button
  122. >
  123. </el-col>
  124. <right-toolbar
  125. :showSearch.sync="showSearch"
  126. @queryTable="getList"
  127. ></right-toolbar>
  128. </el-row>
  129. <el-table
  130. v-loading="loading"
  131. :data="taskList"
  132. @selection-change="handleSelectionChange"
  133. >
  134. <el-table-column type="selection" width="55" align="center" />
  135. <el-table-column label="业务ID" align="center" prop="bizId" />
  136. <el-table-column label="任务名称" align="center" prop="bizName" />
  137. <el-table-column label="状态" align="center" prop="status">
  138. <template slot-scope="scope">
  139. <dict-tag
  140. :options="dict.type.uavps_task_status"
  141. :value="scope.row.status"
  142. />
  143. </template>
  144. </el-table-column>
  145. <el-table-column
  146. label="开始时间"
  147. align="center"
  148. prop="startTime"
  149. width="180"
  150. >
  151. <template slot-scope="scope">
  152. <span>{{
  153. parseTime(scope.row.startTime, "{y}-{m}-{d} {h}:{m}:{s}")
  154. }}</span>
  155. </template>
  156. </el-table-column>
  157. <el-table-column
  158. label="结束时间"
  159. align="center"
  160. prop="endTime"
  161. width="180"
  162. >
  163. <template slot-scope="scope">
  164. <span>{{
  165. parseTime(scope.row.endTime, "{y}-{m}-{d} {h}:{m}:{s}")
  166. }}</span>
  167. </template>
  168. </el-table-column>
  169. <el-table-column
  170. label="创建时间"
  171. align="center"
  172. prop="createTime"
  173. width="180"
  174. >
  175. <template slot-scope="scope">
  176. <span>{{
  177. parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{m}:{s}")
  178. }}</span>
  179. </template>
  180. </el-table-column>
  181. <el-table-column
  182. label="更新时间"
  183. align="center"
  184. prop="updateTime"
  185. width="180"
  186. >
  187. <template slot-scope="scope">
  188. <span>{{
  189. parseTime(scope.row.updateTime, "{y}-{m}-{d} {h}:{m}:{s}")
  190. }}</span>
  191. </template>
  192. </el-table-column>
  193. <el-table-column
  194. label="操作"
  195. align="center"
  196. class-name="small-padding fixed-width"
  197. >
  198. <template slot-scope="scope">
  199. <el-button
  200. v-hasPermi="['system:task:edit']"
  201. size="mini"
  202. type="text"
  203. icon="el-icon-s-operation"
  204. @click="handleRun(scope.row)"
  205. >运行</el-button
  206. >
  207. <el-button
  208. size="mini"
  209. type="text"
  210. icon="el-icon-view"
  211. @click="handlePlayback(scope.row)"
  212. v-hasPermi="['uavps:parameter:run']"
  213. :disabled="scope.row.status == '1'"
  214. >回放</el-button
  215. >
  216. <el-button
  217. size="mini"
  218. type="text"
  219. icon="el-icon-edit"
  220. @click="handleUpdate(scope.row)"
  221. v-hasPermi="['system:task:edit']"
  222. >修改</el-button
  223. >
  224. <el-button
  225. size="mini"
  226. type="text"
  227. icon="el-icon-delete"
  228. @click="handleDelete(scope.row)"
  229. v-hasPermi="['system:task:remove']"
  230. >删除</el-button
  231. >
  232. </template>
  233. </el-table-column>
  234. </el-table>
  235. <pagination
  236. v-show="total > 0"
  237. :total="total"
  238. :page.sync="queryParams.pageNum"
  239. :limit.sync="queryParams.pageSize"
  240. @pagination="getList"
  241. />
  242. <!-- 添加或修改算法任务对话框 -->
  243. <el-dialog
  244. :title="title"
  245. :visible.sync="open"
  246. width="75%"
  247. :close-on-click-modal="false"
  248. append-to-body
  249. :before-close="cancel"
  250. >
  251. <el-form
  252. ref="form"
  253. :inline="true"
  254. :model="form"
  255. :rules="rules"
  256. label-width="120px"
  257. >
  258. <el-row>
  259. <el-form-item label="任务名称" prop="bizName">
  260. <el-input v-model="form.bizName" placeholder="请输入任务名称" />
  261. </el-form-item>
  262. <el-form-item label="编队类型">
  263. <el-select
  264. v-model="form.multiTarget"
  265. @change="typeChange"
  266. placeholder="请选择"
  267. :disabled="form.multiTarget == '1' || title == '修改任务数据'"
  268. >
  269. <el-option
  270. v-for="item in formationTypeList"
  271. :key="item.value"
  272. :label="item.label"
  273. :value="item.value"
  274. >
  275. </el-option>
  276. </el-select>
  277. </el-form-item>
  278. </el-row>
  279. <el-row>
  280. <el-form-item label="噪声类型">
  281. <el-select v-model="form.noiseType" placeholder="请选择">
  282. <el-option
  283. v-for="item in noiseTypeList"
  284. :key="item.value"
  285. :label="item.label"
  286. :value="item.value"
  287. >
  288. </el-option>
  289. </el-select>
  290. </el-form-item>
  291. <el-form-item label="噪声方差" prop="noiseVariance">
  292. <el-input
  293. v-model="form.noiseVariance"
  294. placeholder="请输入噪声方差"
  295. />
  296. </el-form-item>
  297. <el-form-item label="噪声均值" prop="noiseMean">
  298. <el-input v-model="form.noiseMean" placeholder="请输入噪声均值" />
  299. </el-form-item>
  300. </el-row>
  301. <el-divider content-position="left">平台无人机</el-divider>
  302. <el-form-item label="经度" prop="platformUav.longitude">
  303. <el-input
  304. v-model="form.platformUav.longitude"
  305. placeholder="请输入经度"
  306. />
  307. </el-form-item>
  308. <el-form-item label="纬度" prop="platformUav.latitude">
  309. <el-input
  310. v-model="form.platformUav.latitude"
  311. placeholder="请输入纬度"
  312. />
  313. </el-form-item>
  314. <el-form-item label="海拔" prop="platformUav.altitude">
  315. <el-input
  316. v-model="form.platformUav.altitude"
  317. placeholder="请输入海拔"
  318. />
  319. </el-form-item>
  320. <el-form-item label="东向速度" prop="platformUav.eastSpeed">
  321. <el-input
  322. v-model="form.platformUav.eastSpeed"
  323. placeholder="请输入东向速度"
  324. />
  325. </el-form-item>
  326. <el-form-item label="北向速度" prop="platformUav.northSpeed">
  327. <el-input
  328. v-model="form.platformUav.northSpeed"
  329. placeholder="请输入北向速度"
  330. />
  331. </el-form-item>
  332. <el-form-item label="天向速度" prop="platformUav.skySpeed">
  333. <el-input
  334. v-model="form.platformUav.skySpeed"
  335. placeholder="请输入天向速度"
  336. />
  337. </el-form-item>
  338. <div v-if="form.multiTarget == '1'">
  339. <el-divider content-position="left">固定编队无人机</el-divider>
  340. <el-form-item
  341. label="飞机数量"
  342. prop="fixedMultiTargetFormation.targetTotal"
  343. >
  344. <el-input-number
  345. v-model="form.fixedMultiTargetFormation.targetTotal"
  346. :min="1"
  347. :max="50"
  348. label="请输入飞机数量"
  349. ></el-input-number>
  350. </el-form-item>
  351. <el-form-item label="经度" prop="fixedMultiTargetFormation.longitude">
  352. <el-input
  353. v-model="form.fixedMultiTargetFormation.longitude"
  354. placeholder="请输入经度"
  355. />
  356. </el-form-item>
  357. <el-form-item label="纬度" prop="fixedMultiTargetFormation.latitude">
  358. <el-input
  359. v-model="form.fixedMultiTargetFormation.latitude"
  360. placeholder="请输入纬度"
  361. />
  362. </el-form-item>
  363. <el-form-item label="海拔" prop="fixedMultiTargetFormation.altitude">
  364. <el-input
  365. v-model="form.fixedMultiTargetFormation.altitude"
  366. placeholder="请输入海拔"
  367. />
  368. </el-form-item>
  369. <el-form-item
  370. label="东向速度"
  371. prop="fixedMultiTargetFormation.eastSpeed"
  372. >
  373. <el-input
  374. v-model="form.fixedMultiTargetFormation.eastSpeed"
  375. placeholder="请输入东向速度"
  376. />
  377. </el-form-item>
  378. <el-form-item
  379. label="北向速度"
  380. prop="fixedMultiTargetFormation.northSpeed"
  381. >
  382. <el-input
  383. v-model="form.fixedMultiTargetFormation.northSpeed"
  384. placeholder="请输入北向速度"
  385. />
  386. </el-form-item>
  387. <el-form-item
  388. label="天向速度"
  389. prop="fixedMultiTargetFormation.skySpeed"
  390. >
  391. <el-input
  392. v-model="form.fixedMultiTargetFormation.skySpeed"
  393. placeholder="请输入天向速度"
  394. />
  395. </el-form-item>
  396. </div>
  397. <div v-show="form.multiTarget == '2'" style="width: 100%">
  398. <el-divider content-position="left">自定义编队无人机</el-divider>
  399. <div style="width: 100%">
  400. <el-form
  401. ref="canvasInfoFormRef"
  402. :inline="true"
  403. :model="canvasInfo"
  404. :rules="infoRules"
  405. class="demo-form-inline"
  406. :disabled="submitInfoFlag"
  407. v-show="this.title == '修改任务数据' ? false : true"
  408. >
  409. <el-form-item label="中心点-经度" prop="centerLongitude">
  410. <el-input
  411. v-model="canvasInfo.centerLongitude"
  412. placeholder="中心点-经度"
  413. ></el-input>
  414. </el-form-item>
  415. <el-form-item label="中心点-纬度" prop="centerLatitude">
  416. <el-input
  417. v-model="canvasInfo.centerLatitude"
  418. placeholder="中心点-纬度"
  419. ></el-input>
  420. </el-form-item>
  421. <el-form-item label="边长距离" prop="lengthKm">
  422. <el-input v-model="canvasInfo.lengthKm" placeholder="边长距离">
  423. <template slot="append">km</template>
  424. </el-input>
  425. </el-form-item>
  426. <el-form-item>
  427. <el-button type="primary" @click="canvasInfoSubmit"
  428. >确 定</el-button
  429. >
  430. </el-form-item>
  431. </el-form>
  432. </div>
  433. <div
  434. style="
  435. width: 100%;
  436. height: 800px;
  437. display: flex;
  438. justify-content: space-evenly;
  439. "
  440. >
  441. <div
  442. ref="pixiCanvas"
  443. class="left"
  444. style="width: 800px; position: relative; height: 800px"
  445. >
  446. <div style="position: absolute; top: 5px; left: 5px">
  447. <span>经度:{{ nowlongitude }}</span
  448. ><br />
  449. <span>纬度:{{ nowlatitude }}</span>
  450. </div>
  451. </div>
  452. <div class="right" style="width: 25%; height: 800px">
  453. <el-divider content-position="left">编队信息</el-divider>
  454. <div style="overflow-y: scroll; width: 100%; height: 750px">
  455. <li
  456. v-for="(item, index) in formationInfoList"
  457. :key="index"
  458. @dblclick="editFormationInfo(item)"
  459. >
  460. <div style="cursor: pointer">
  461. <div>
  462. <span>编号:&nbsp;&nbsp;</span
  463. ><label>{{ item.number }}</label>
  464. </div>
  465. <div>
  466. <span>经度:&nbsp;&nbsp;</span
  467. ><label>{{ item.longitude }}</label>
  468. </div>
  469. <div>
  470. <span>纬度:&nbsp;&nbsp;</span
  471. ><label>{{ item.latitude }}</label>
  472. </div>
  473. <div>
  474. <span>海拔:&nbsp;&nbsp;</span
  475. ><label>{{ item.altitude }}</label>
  476. </div>
  477. <div>
  478. <span>东向速度:&nbsp;&nbsp;</span
  479. ><label>{{ item.eastSpeed }}(m/s)</label>
  480. </div>
  481. <div>
  482. <span>北向速度:&nbsp;&nbsp;</span
  483. ><label>{{ item.northSpeed }}(m/s)</label>
  484. </div>
  485. <div>
  486. <span>天向速度:&nbsp;&nbsp;</span
  487. ><label>{{ item.skySpeed }}(m/s)</label>
  488. </div>
  489. <div>
  490. <span>航线类型:&nbsp;&nbsp;</span
  491. ><label>{{ item.flightPathType }}(m/s)</label>
  492. </div>
  493. <div>
  494. <span>噪音:&nbsp;&nbsp;</span
  495. ><label>{{ item.positionNoise }}(m/s)</label>
  496. </div>
  497. </div>
  498. </li>
  499. </div>
  500. </div>
  501. </div>
  502. </div>
  503. </el-form>
  504. <div slot="footer" class="dialog-footer">
  505. <el-button type="primary" @click="submitForm">确 定</el-button>
  506. <el-button @click="cancel">取 消</el-button>
  507. </div>
  508. </el-dialog>
  509. <el-drawer
  510. title="设置参数"
  511. size="20%"
  512. :visible.sync="drawerOpen"
  513. direction="rtl"
  514. :before-close="drawerClose"
  515. :show-close="false"
  516. :wrapperClosable="false"
  517. >
  518. <div class="demo-drawer__content" style="width: 80%; margin-left: 20px">
  519. <el-form
  520. label-width="80px"
  521. ref="formationInfoRef"
  522. :rules="formationInfoRules"
  523. :model="formationInfoForm"
  524. >
  525. <el-form-item label="编号" prop="number">
  526. <el-input
  527. v-model="formationInfoForm.number"
  528. placeholder="请输入编号"
  529. :disabled="this.addOrUpdate == 'update'"
  530. />
  531. </el-form-item>
  532. <el-form-item label="经度" prop="longitude">
  533. <el-input
  534. v-model="formationInfoForm.longitude"
  535. oninput="value=value.replace(/[^\d.]/g,'')"
  536. placeholder="请输入经度"
  537. />
  538. </el-form-item>
  539. <el-form-item label="纬度" prop="latitude">
  540. <el-input
  541. v-model="formationInfoForm.latitude"
  542. oninput="value=value.replace(/[^\d.]/g,'')"
  543. placeholder="请输入纬度"
  544. />
  545. </el-form-item>
  546. <el-form-item label="海拔" prop="altitude">
  547. <el-input
  548. v-model="formationInfoForm.altitude"
  549. placeholder="请输入海拔"
  550. />
  551. </el-form-item>
  552. <el-form-item label="东向速度" prop="eastSpeed">
  553. <el-input
  554. v-model="formationInfoForm.eastSpeed"
  555. placeholder="请输入东向速度"
  556. >
  557. <template slot="append">m/s</template>
  558. </el-input>
  559. </el-form-item>
  560. <el-form-item label="北向速度" prop="northSpeed">
  561. <el-input
  562. v-model="formationInfoForm.northSpeed"
  563. placeholder="请输入北向速度"
  564. >
  565. <template slot="append">m/s</template>
  566. </el-input>
  567. </el-form-item>
  568. <el-form-item label="天向速度" prop="skySpeed">
  569. <el-input
  570. v-model="formationInfoForm.skySpeed"
  571. placeholder="请输入天向速度"
  572. >
  573. <template slot="append">m/s</template>
  574. </el-input>
  575. </el-form-item>
  576. <el-form-item label="航线类型" prop="flightPathType">
  577. <el-select
  578. v-model="formationInfoForm.flightPathType"
  579. placeholder="航线类型"
  580. >
  581. <el-option label="直线" value="直线"></el-option>
  582. </el-select>
  583. </el-form-item>
  584. <el-form-item label="噪声" prop="positionNoise">
  585. <el-input
  586. v-model="formationInfoForm.positionNoise"
  587. placeholder="请输入噪声"
  588. />
  589. </el-form-item>
  590. </el-form>
  591. <div class="demo-drawer__footer">
  592. <el-button
  593. type="danger"
  594. :disabled="this.addOrUpdate == 'add'"
  595. @click="canvasInfoDel"
  596. >删 除</el-button
  597. >
  598. <el-button type="primary" @click="handleDrawerSubmit"
  599. >确 定</el-button
  600. >
  601. </div>
  602. <ul style="color: rgb(125 121 121)">
  603. <li>
  604. <span class="info">左上角:</span><br />
  605. 经度:{{ this.siJiaoInfo.leftTop.lng }}<br />
  606. 纬度:{{ this.siJiaoInfo.leftTop.lat }}
  607. </li>
  608. <li>
  609. <span class="info">右上角:</span><br />
  610. 经度:{{ this.siJiaoInfo.rightTop.lng }}<br />纬度:{{
  611. this.siJiaoInfo.rightTop.lat
  612. }}
  613. </li>
  614. <li>
  615. <span class="info">左下角:</span><br />
  616. 经度:{{ this.siJiaoInfo.leftBottom.lng }}<br />纬度:{{
  617. this.siJiaoInfo.leftBottom.lat
  618. }}
  619. </li>
  620. <li>
  621. <span class="info">右下角:</span><br />
  622. 经度:{{ this.siJiaoInfo.rightBottom.lng }}<br />纬度:{{
  623. this.siJiaoInfo.rightBottom.lat
  624. }}
  625. </li>
  626. </ul>
  627. </div>
  628. </el-drawer>
  629. <!-- 飞行轨迹展示对话框 -->
  630. <el-dialog
  631. :title="title"
  632. :visible.sync="showTrajectory"
  633. @opened="initTrajectory"
  634. :before-close="closeDialog"
  635. :fullscreen="true"
  636. append-to-body
  637. destroy-on-close
  638. :close-on-click-modal="false"
  639. >
  640. <div class="container">
  641. <div>
  642. <el-row type="flex" align="middle" style="height: 40px">
  643. <el-col :span="24">
  644. <el-button @click="handleCenter" type="primary">居中</el-button>
  645. <el-button
  646. v-if="!isUpdateView"
  647. @click="transFormation"
  648. type="warning"
  649. >转换队形</el-button
  650. >
  651. <el-button v-if="!isUpdateView" @click="endHandle" type="danger"
  652. >结束</el-button
  653. >
  654. <div class="distance">
  655. <el-select
  656. v-model="firstAir"
  657. @change="handleFirstAir"
  658. placeholder="请选择"
  659. >
  660. <el-option
  661. v-for="item in allSpriteInfo"
  662. :key="item.id"
  663. :label="item.label"
  664. :value="item.id"
  665. >
  666. </el-option>
  667. </el-select>
  668. ---&gt;
  669. <el-select
  670. v-model="secondAir"
  671. @change="handleSecondAir"
  672. placeholder="请选择"
  673. >
  674. <el-option
  675. v-for="item in allSpriteInfo"
  676. :key="item.id"
  677. :label="item.label"
  678. :value="item.id"
  679. >
  680. </el-option>
  681. </el-select>
  682. =
  683. <el-input
  684. placeholder="距离"
  685. v-model="airDistance"
  686. :disabled="true"
  687. style="width: 220px"
  688. >
  689. <template slot="append">m</template>
  690. </el-input>
  691. </div>
  692. <el-progress
  693. style="width: 600px; display: inline-block; margin-left: 20px"
  694. :text-inside="true"
  695. :stroke-width="26"
  696. v-if="isUpdateView"
  697. :percentage="percentage"
  698. ></el-progress>
  699. </el-col>
  700. </el-row>
  701. <el-row>
  702. <div ref="pixiContainer" class="pixi-container"></div>
  703. </el-row>
  704. </div>
  705. <div class="right-board">
  706. <div style="float: right">
  707. <el-link type="primary" @click="showConfig">显示配置</el-link>
  708. </div>
  709. <el-divider content-position="left">隐藏列表</el-divider>
  710. <div style="height: 30px">
  711. <div style="margin-left: 10px" v-if="hideList.length !== 0">
  712. <el-tag
  713. v-for="item in hideList"
  714. @click="showSprite(item)"
  715. style="cursor: pointer; margin-left: 5px"
  716. >{{ item }}</el-tag
  717. >
  718. </div>
  719. <div style="margin-left: 10px" v-else>暂无</div>
  720. </div>
  721. <el-divider content-position="left">平台无人机</el-divider>
  722. <div style="height: 190px; overflow: auto">
  723. <div v-if="configList.includes('经度')">
  724. <span>经度:&nbsp;&nbsp;</span
  725. ><label>{{ platformInfo.longitude }}</label>
  726. </div>
  727. <div v-if="configList.includes('纬度')">
  728. <span>纬度:&nbsp;&nbsp;</span
  729. ><label>{{ platformInfo.latitude }}</label>
  730. </div>
  731. <div v-if="configList.includes('海拔')">
  732. <span>海拔:&nbsp;&nbsp;</span
  733. ><label>{{ platformInfo.altitude }}m</label>
  734. </div>
  735. <div v-if="configList.includes('东向速度')">
  736. <span>东向速度:&nbsp;&nbsp;</span
  737. ><label>{{ platformInfo.eastSpeed }}m/s</label>
  738. </div>
  739. <div v-if="configList.includes('北向速度')">
  740. <span>北向速度:&nbsp;&nbsp;</span
  741. ><label>{{ platformInfo.northSpeed }}m/s</label>
  742. </div>
  743. <div v-if="configList.includes('天向速度')">
  744. <span>天向速度:&nbsp;&nbsp;</span
  745. ><label>{{ platformInfo.skySpeed }}m/s</label>
  746. </div>
  747. <div>
  748. <span>方位角:&nbsp;&nbsp;</span>
  749. <label>{{ platformInfo.azimuthAngle }}</label>
  750. </div>
  751. <div>
  752. <span>目标飞机:&nbsp;&nbsp;</span>
  753. <label>{{ platformInfo.targetAircraftNumber }}</label>
  754. </div>
  755. <div>
  756. <span>距离目标飞机距离:&nbsp;&nbsp;</span>
  757. <label>{{ platformInfo.distance }}m</label>
  758. </div>
  759. <div>
  760. <span>与目标飞机夹角:&nbsp;&nbsp;</span>
  761. <label>{{ platformInfo.bearing }}</label>
  762. </div>
  763. </div>
  764. <el-divider content-position="left">目标无人机群</el-divider>
  765. <div style="height: 480px; overflow: auto">
  766. <li v-for="(item, key) in targetLblAry" :key="key" class="item">
  767. <div
  768. v-if="!hideList.includes(item.id)"
  769. @click="showSprite(item.id)"
  770. style="cursor: pointer"
  771. >
  772. <div>
  773. <span>编号:&nbsp;&nbsp;</span><label>{{ item.id }}</label>
  774. <!-- <span style="margin-left: 10px" v-if="hideList.includes(item.id)"
  775. >( 隐 藏 )</span
  776. > -->
  777. </div>
  778. <div v-if="configList.includes('经度')">
  779. <span>经度:&nbsp;&nbsp;</span
  780. ><label>{{ item.longitude }}</label>
  781. </div>
  782. <div v-if="configList.includes('纬度')">
  783. <span>纬度:&nbsp;&nbsp;</span
  784. ><label>{{ item.latitude }}</label>
  785. </div>
  786. <div v-if="configList.includes('海拔')">
  787. <span>海拔:&nbsp;&nbsp;</span
  788. ><label>{{ item.altitude }}</label>
  789. </div>
  790. <div v-if="configList.includes('东向速度')">
  791. <span>东向速度:&nbsp;&nbsp;</span
  792. ><label>{{ item.eastSpeed }}</label>
  793. </div>
  794. <div v-if="configList.includes('北向速度')">
  795. <span>北向速度:&nbsp;&nbsp;</span
  796. ><label>{{ item.northSpeed }}</label>
  797. </div>
  798. <div v-if="configList.includes('天向速度')">
  799. <span>天向速度:&nbsp;&nbsp;</span
  800. ><label>{{ item.skySpeed }}</label>
  801. </div>
  802. </div>
  803. </li>
  804. </div>
  805. </div>
  806. </div>
  807. </el-dialog>
  808. <!-- 显示配置对话框 -->
  809. <el-dialog
  810. title="显示配置"
  811. :close-on-click-modal="false"
  812. :visible.sync="showConfigVisible"
  813. width="30%"
  814. >
  815. <el-checkbox-group
  816. v-model="showConfigList"
  817. style="display: flex; flex-direction: column"
  818. >
  819. <el-checkbox
  820. v-for="item in configData"
  821. :label="item.label"
  822. ></el-checkbox>
  823. </el-checkbox-group>
  824. <span slot="footer" class="dialog-footer">
  825. <el-button @click="showConfigVisible = false">取 消</el-button>
  826. <el-button type="primary" @click="selectConfigSubmit">确 定</el-button>
  827. </span>
  828. </el-dialog>
  829. </div>
  830. </template>
  831. <script>
  832. import {
  833. listTask,
  834. getTask,
  835. delTask,
  836. addTask,
  837. updateTask,
  838. } from "@/api/system/task";
  839. import * as PIXI from "pixi.js";
  840. import platformPNG from "../../textures/platform.png";
  841. import uavTarPNG from "../../textures/uav-tar.png";
  842. export default {
  843. name: "Task",
  844. dicts: [
  845. "uavps_task_status",
  846. "uavps_target_formation_type",
  847. "uavps_task_nose_type",
  848. ],
  849. data() {
  850. return {
  851. // 遮罩层
  852. loading: true,
  853. // 选中数组
  854. ids: [],
  855. // 非单个禁用
  856. single: true,
  857. // 非多个禁用
  858. multiple: true,
  859. // 显示搜索条件
  860. showSearch: true,
  861. // 总条数
  862. total: 0,
  863. // 任务数据表格数据
  864. taskList: [],
  865. // 弹出层标题
  866. title: "",
  867. // 是否显示弹出层
  868. open: false,
  869. // 噪声数据文件路径时间范围
  870. daterangeCreateTime: [],
  871. // 查询参数
  872. queryParams: {
  873. pageNum: 1,
  874. pageSize: 10,
  875. bizName: null,
  876. status: null,
  877. startTime: null,
  878. endTime: null,
  879. createTime: null,
  880. },
  881. // 表单参数
  882. form: {
  883. platformUav: {},
  884. fixedMultiTargetFormation: {},
  885. },
  886. // 表单校验
  887. rules: {
  888. bizName: [
  889. { required: true, message: "任务名称不能为空", trigger: "blur" },
  890. ],
  891. multiTarget: [
  892. {
  893. required: true,
  894. message: "编队类型不能为空",
  895. trigger: "change",
  896. },
  897. ],
  898. noiseType: [
  899. {
  900. required: true,
  901. message: "噪声类型不能为空",
  902. trigger: "change",
  903. },
  904. ],
  905. noiseVariance: [
  906. { required: true, message: "噪声方差不能为空", trigger: "blur" },
  907. ],
  908. noiseMean: [
  909. { required: true, message: "噪声均值不能为空", trigger: "blur" },
  910. ],
  911. "platformUav.longitude": [
  912. {
  913. required: true,
  914. message: "平台无人机经度不能为空",
  915. trigger: "blur",
  916. },
  917. ],
  918. "platformUav.latitude": [
  919. {
  920. required: true,
  921. message: "平台无人机纬度不能为空",
  922. trigger: "blur",
  923. },
  924. ],
  925. "platformUav.altitude": [
  926. {
  927. required: true,
  928. message: "平台无人机海拔不能为空",
  929. trigger: "blur",
  930. },
  931. ],
  932. "platformUav.eastSpeed": [
  933. {
  934. required: true,
  935. message: "平台无人机东向速度不能为空",
  936. trigger: "blur",
  937. },
  938. ],
  939. "platformUav.northSpeed": [
  940. {
  941. required: true,
  942. message: "平台无人机北向速度不能为空",
  943. trigger: "blur",
  944. },
  945. ],
  946. "platformUav.skySpeed": [
  947. {
  948. required: true,
  949. message: "平台无人机天向速度不能为空",
  950. trigger: "blur",
  951. },
  952. ],
  953. "fixedMultiTargetFormation.targetTotal": [
  954. {
  955. required: true,
  956. message: "固定编队无人机飞机数量不能为空",
  957. trigger: "blur",
  958. },
  959. ],
  960. "fixedMultiTargetFormation.longitude": [
  961. {
  962. required: true,
  963. message: "固定编队无人机经度不能为空",
  964. trigger: "blur",
  965. },
  966. ],
  967. "fixedMultiTargetFormation.latitude": [
  968. {
  969. required: true,
  970. message: "固定编队无人机纬度不能为空",
  971. trigger: "blur",
  972. },
  973. ],
  974. "fixedMultiTargetFormation.altitude": [
  975. {
  976. required: true,
  977. message: "固定编队无人机海拔不能为空",
  978. trigger: "blur",
  979. },
  980. ],
  981. "fixedMultiTargetFormation.eastSpeed": [
  982. {
  983. required: true,
  984. message: "固定编队无人机东向速度不能为空",
  985. trigger: "blur",
  986. },
  987. ],
  988. "fixedMultiTargetFormation.northSpeed": [
  989. {
  990. required: true,
  991. message: "固定编队无人机北向速度不能为空",
  992. trigger: "blur",
  993. },
  994. ],
  995. "fixedMultiTargetFormation.skySpeed": [
  996. {
  997. required: true,
  998. message: "固定编队无人机天向速度不能为空",
  999. trigger: "blur",
  1000. },
  1001. ],
  1002. },
  1003. infoRules: {
  1004. centerLongitude: [
  1005. { required: true, message: "经度不能为空", trigger: "blur" },
  1006. ],
  1007. centerLatitude: [
  1008. { required: true, message: "纬度不能为空", trigger: "blur" },
  1009. ],
  1010. lengthKm: [
  1011. { required: true, message: "边长距离不能为空", trigger: "blur" },
  1012. ],
  1013. },
  1014. formationInfoRules: {
  1015. number: [{ required: true, message: "编号不能为空", trigger: "blur" }],
  1016. longitude: [
  1017. { required: true, message: "经度不能为空", trigger: "blur" },
  1018. ],
  1019. latitude: [
  1020. { required: true, message: "纬度不能为空", trigger: "blur" },
  1021. ],
  1022. altitude: [
  1023. { required: true, message: "海拔不能为空", trigger: "blur" },
  1024. ],
  1025. eastSpeed: [
  1026. { required: true, message: "东向速度不能为空", trigger: "blur" },
  1027. ],
  1028. northSpeed: [
  1029. { required: true, message: "北向速度不能为空", trigger: "blur" },
  1030. ],
  1031. skySpeed: [
  1032. { required: true, message: "天向速度不能为空", trigger: "blur" },
  1033. ],
  1034. flightPathType: [
  1035. { required: true, message: "航线类型不能为空", trigger: "change" },
  1036. ],
  1037. positionNoise: [
  1038. { required: true, message: "噪音不能为空", trigger: "blur" },
  1039. ],
  1040. },
  1041. parameterId: 0,
  1042. // 是否显示轨迹
  1043. showTrajectory: false,
  1044. pixiApp: null,
  1045. container: null,
  1046. webSocket: null,
  1047. curLongitude: null,
  1048. curLatitude: null,
  1049. curAltitude: null,
  1050. targetTotal: null,
  1051. formationTypeList: [
  1052. {
  1053. value: "1",
  1054. label: "固定编队",
  1055. },
  1056. {
  1057. value: "2",
  1058. label: "自由编队",
  1059. },
  1060. ],
  1061. noiseTypeList: [
  1062. {
  1063. value: "1",
  1064. label: "高斯",
  1065. },
  1066. {
  1067. value: "2",
  1068. label: "瑞利",
  1069. },
  1070. ],
  1071. // 自定义编队信息
  1072. formationInfoList: [],
  1073. formationInfoForm: {
  1074. number: null,
  1075. longitude: null,
  1076. latitude: null,
  1077. altitude: null,
  1078. eastSpeed: null,
  1079. northSpeed: null,
  1080. skySpeed: null,
  1081. flightPathType: "直线",
  1082. positionNoise: null,
  1083. },
  1084. // 判断填写的编队信息是新增加的还是修改之前的
  1085. addOrUpdate: "add",
  1086. // 自定义编队的飞机信息集合
  1087. formationInfoAirDataList: [],
  1088. // 编辑编队信息的
  1089. formationAirPiXiApp: null,
  1090. // 设定的画布信息
  1091. canvasInfo: {
  1092. centerLongitude: null,
  1093. centerLatitude: null,
  1094. lengthKm: null,
  1095. },
  1096. // 编辑编队信息的画布
  1097. pixiCanvas: null,
  1098. // 是否提交了编队信息
  1099. submitInfoFlag: false,
  1100. // 鼠标当前的经纬度
  1101. nowlongitude: null,
  1102. nowlatitude: null,
  1103. targetDataR: {},
  1104. targetDataN: {},
  1105. platformData: [],
  1106. // 真实路径的集合
  1107. pathGraphicsList: {},
  1108. pathGraphicsPointList: {},
  1109. isUpdateView: false, // 是否开启实现追踪,在回放时开启
  1110. percentage: 0,
  1111. // 多久更新一次轨迹
  1112. updatePathFlag: 75,
  1113. cycleCount: 0, // 循环计数
  1114. updatePlatformPathFlag: 75,
  1115. platformCycleCount: 0,
  1116. showConfigVisible: false, //显示配置dialog
  1117. showConfigList: [], // 选择要显示的值
  1118. configList: ["经度", "纬度", "海拔", "东向速度", "北向速度", "天向速度"], // 显示的值
  1119. configData: [
  1120. // 可选择的值
  1121. { key: "longitude", label: "经度" },
  1122. { key: "latitude", label: "纬度" },
  1123. { key: "altitude", label: "海拔" },
  1124. { key: "eastSpeed", label: "东向速度" },
  1125. { key: "northSpeed", label: "北向速度" },
  1126. { key: "skySpeed", label: "天向速度" },
  1127. ],
  1128. hideList: [], // 当下隐藏的飞机数组
  1129. allId: [], // 所有飞机的id
  1130. changeNoList: [], // 需要改变的飞机编号,放有id和应该显示的编号
  1131. targetLblAry: {},
  1132. targetUavAry: [],
  1133. targetUavCircleR: {},
  1134. targetUavCircleN: {},
  1135. targetUavCircleNumR: {},
  1136. targetUavCircleNumN: {},
  1137. drawerOpen: false,
  1138. platformSprite: null, // 平台无人机
  1139. // 平台无人机显示的数据
  1140. platformInfo: {},
  1141. platformPathData: {}, //平台无人机位置
  1142. platformGraphics: null, //平台无人机轨迹
  1143. playbackTime: null, // 回放的时间
  1144. isClickGroup: false, // 是否点击了飞机,在计算两飞机距离时使用
  1145. firstLng: null, // 第一次点击的飞机的经纬度
  1146. firstLat: null,
  1147. airDistance: null, // 两点间距离
  1148. allSpriteInfo: [], // 所有飞机的信息
  1149. firstAir: "",
  1150. secondAir: "",
  1151. siJiaoInfo: {
  1152. leftTop: {},
  1153. rightTop: {},
  1154. leftBottom: {},
  1155. rightBottom: {},
  1156. }, // 自定义画布四个角的经纬度信息
  1157. trackGraphicsLine: null,
  1158. };
  1159. },
  1160. created() {
  1161. this.getList();
  1162. },
  1163. methods: {
  1164. /** 查询任务数据列表 */
  1165. getList() {
  1166. this.loading = true;
  1167. this.queryParams.params = {};
  1168. if (null != this.daterangeCreateTime && "" != this.daterangeCreateTime) {
  1169. this.queryParams.params["beginCreateTime"] =
  1170. this.daterangeCreateTime[0];
  1171. this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
  1172. }
  1173. listTask(this.queryParams).then((response) => {
  1174. this.taskList = response.rows;
  1175. this.total = response.total;
  1176. this.loading = false;
  1177. });
  1178. },
  1179. // 取消按钮
  1180. cancel() {
  1181. this.open = false;
  1182. this.reset();
  1183. this.closeUpdataDialog();
  1184. },
  1185. // 表单重置
  1186. reset() {
  1187. this.form = {
  1188. bizId: null,
  1189. bizName: null,
  1190. bizType: null,
  1191. multiTarget: null,
  1192. noiseType: null,
  1193. noiseVariance: null,
  1194. noiseMean: null,
  1195. platformUav: {},
  1196. fixedMultiTargetFormation: {},
  1197. customizedMultiTargetFormation: null,
  1198. status: null,
  1199. startTime: null,
  1200. endTime: null,
  1201. filePath: null,
  1202. createBy: null,
  1203. createTime: null,
  1204. updateBy: null,
  1205. updateTime: null,
  1206. };
  1207. this.siJiaoInfo = {
  1208. leftTop: {},
  1209. rightTop: {},
  1210. leftBottom: {},
  1211. rightBottom: {},
  1212. };
  1213. this.resetForm("form");
  1214. },
  1215. /** 搜索按钮操作 */
  1216. handleQuery() {
  1217. this.queryParams.pageNum = 1;
  1218. this.getList();
  1219. },
  1220. /** 重置按钮操作 */
  1221. resetQuery() {
  1222. this.daterangeCreateTime = [];
  1223. this.resetForm("queryForm");
  1224. this.handleQuery();
  1225. },
  1226. // 多选框选中数据
  1227. handleSelectionChange(selection) {
  1228. this.ids = selection.map((item) => item.bizId);
  1229. this.single = selection.length !== 1;
  1230. this.multiple = !selection.length;
  1231. },
  1232. /** 新增按钮操作 */
  1233. handleAdd() {
  1234. this.reset();
  1235. this.open = true;
  1236. this.title = "添加任务数据";
  1237. },
  1238. /** 修改按钮操作 */
  1239. handleUpdate(row) {
  1240. this.reset();
  1241. const bizId = row.bizId || this.ids;
  1242. getTask(bizId).then((response) => {
  1243. this.form = response.data;
  1244. if (this.form.multiTarget == "2") {
  1245. const info = this.form.customizedMultiTargetFormation[0];
  1246. this.formationInfoList = this.form.customizedMultiTargetFormation;
  1247. //自由编队
  1248. this.$nextTick(() => {
  1249. this.initFormationApp();
  1250. this.canvasInfo = {
  1251. centerLongitude: info.longitude,
  1252. centerLatitude: info.latitude,
  1253. lengthKm: 20,
  1254. };
  1255. this.airPosShow(
  1256. this.form.customizedMultiTargetFormation,
  1257. "fixedWing"
  1258. );
  1259. const leftTop = this.calculateLatLng(0, 800);
  1260. const rightTop = this.calculateLatLng(800, 0);
  1261. const leftBottom = this.calculateLatLng(0, 800);
  1262. const rightBottom = this.calculateLatLng(800, 800);
  1263. this.siJiaoInfo = { leftTop, rightTop, leftBottom, rightBottom };
  1264. this.addAirSprite();
  1265. });
  1266. }
  1267. this.title = "修改任务数据";
  1268. this.open = true;
  1269. });
  1270. },
  1271. // 根据后端返回的自定义编队信息,显示飞机位置
  1272. airPosShow(info, type) {
  1273. let texture = new PIXI.Texture.from(uavTarPNG);
  1274. info.forEach((item) => {
  1275. const { x, y } = this.calculateXY(item.longitude, item.latitude);
  1276. const sprite = new PIXI.Sprite(texture); // 示例飞机图标
  1277. sprite.anchor.set(0.5, 0.5);
  1278. sprite.scale.set(0.04);
  1279. sprite.x = x;
  1280. sprite.y = y;
  1281. sprite.id = item.number;
  1282. this.formationAirPiXiApp.stage.addChild(sprite);
  1283. });
  1284. },
  1285. calculateXY(longitude, latitude) {
  1286. // 计算每像素对应的实际距离
  1287. const kmPerPixel = this.canvasInfo.lengthKm / this.pixiCanvas.clientWidth;
  1288. // 经纬度差值转实际距离
  1289. const deltaY = (latitude - this.canvasInfo.centerLatitude) * 111;
  1290. const deltaX =
  1291. (longitude - this.canvasInfo.centerLongitude) *
  1292. 111 *
  1293. Math.cos((this.canvasInfo.centerLatitude * Math.PI) / 180);
  1294. // 实际距离转像素偏移量
  1295. const offsetX = deltaX / kmPerPixel;
  1296. const offsetY = deltaY / kmPerPixel;
  1297. // 像素坐标
  1298. const x = this.pixiCanvas.clientWidth / 2 + offsetX;
  1299. const y = this.pixiCanvas.clientHeight / 2 - offsetY;
  1300. return { x, y };
  1301. },
  1302. // 选择第一个飞机
  1303. handleFirstAir(val) {
  1304. this.secondAir = null;
  1305. },
  1306. // 选择第二个飞机
  1307. handleSecondAir(val) {
  1308. let firstLng, firstLat, secondLng, secondLat;
  1309. if (this.firstAir == 100001) {
  1310. firstLng = this.platformInfo.longitude;
  1311. firstLat = this.platformInfo.latitude;
  1312. } else {
  1313. firstLng = this.targetLblAry[`${this.firstAir}`].longitude;
  1314. firstLat = this.targetLblAry[`${this.firstAir}`].latitude;
  1315. }
  1316. if (this.secondAir == 100001) {
  1317. secondLng = this.platformInfo.longitude;
  1318. secondLat = this.platformInfo.latitude;
  1319. } else {
  1320. secondLng = this.targetLblAry[`${val}`].longitude;
  1321. secondLat = this.targetLblAry[`${val}`].latitude;
  1322. }
  1323. this.airDistance = this.calculateDistance(
  1324. firstLat,
  1325. firstLng,
  1326. secondLat,
  1327. secondLng
  1328. );
  1329. },
  1330. /** 提交按钮 */
  1331. submitForm() {
  1332. this.$refs["form"].validate((valid) => {
  1333. if (valid) {
  1334. if (this.form.multiTarget == "2") {
  1335. this.form.customizedMultiTargetFormation = this.formationInfoList;
  1336. }
  1337. if (this.form.bizId != null) {
  1338. updateTask(this.form).then((response) => {
  1339. this.$modal.msgSuccess("修改成功");
  1340. this.open = false;
  1341. this.closeUpdataDialog();
  1342. this.getList();
  1343. });
  1344. } else {
  1345. addTask(this.form).then((response) => {
  1346. this.$modal.msgSuccess("新增成功");
  1347. this.open = false;
  1348. this.closeUpdataDialog();
  1349. this.getList();
  1350. });
  1351. }
  1352. }
  1353. });
  1354. },
  1355. /** 删除按钮操作 */
  1356. handleDelete(row) {
  1357. const bizIds = row.bizId || this.ids;
  1358. this.$modal
  1359. .confirm('是否确认删除任务数据编号为"' + bizIds + '"的数据项?')
  1360. .then(function () {
  1361. return delTask(bizIds);
  1362. })
  1363. .then(() => {
  1364. this.getList();
  1365. this.$modal.msgSuccess("删除成功");
  1366. })
  1367. .catch(() => {});
  1368. },
  1369. /** 导出按钮操作 */
  1370. handleExport() {
  1371. this.download(
  1372. "system/task/export",
  1373. {
  1374. ...this.queryParams,
  1375. },
  1376. `task_${new Date().getTime()}.xlsx`
  1377. );
  1378. },
  1379. showConfig() {
  1380. this.showConfigList = this.configList;
  1381. this.showConfigVisible = true;
  1382. },
  1383. selectConfigSubmit() {
  1384. this.configList = this.showConfigList;
  1385. this.showConfigVisible = false;
  1386. },
  1387. // 选择编队类型
  1388. typeChange(val) {
  1389. if (val == "2") {
  1390. this.$nextTick(() => {
  1391. this.$message.warning(`请先输入画布信息!`);
  1392. this.initFormationApp();
  1393. });
  1394. }
  1395. },
  1396. handleRun(row) {
  1397. this.parameterId = row.bizId || this.ids;
  1398. this.showTrajectory = true;
  1399. this.title = "飞行轨迹";
  1400. },
  1401. handlePlayback(row) {
  1402. this.parameterId = row.bizId || this.ids;
  1403. this.playbackTime = row.totalDuration;
  1404. this.showTrajectory = true;
  1405. this.isUpdateView = true;
  1406. this.title = "回放";
  1407. },
  1408. initWebSocket() {
  1409. const wsUri = "ws://127.0.0.1:8080/websocket/message";
  1410. this.webSocket = new WebSocket(wsUri);
  1411. const self = this;
  1412. this.webSocket.onopen = function (event) {
  1413. if (self.title == "回放") {
  1414. self.webSocket.send("REPLAY:" + self.parameterId);
  1415. } else {
  1416. self.webSocket.send("RUN:" + self.parameterId);
  1417. }
  1418. console.log("WebSocket连接成功!");
  1419. };
  1420. this.webSocket.onmessage = function (event) {
  1421. self.processMessage(JSON.parse(event.data));
  1422. };
  1423. this.webSocket.onclose = function (event) {
  1424. console.log("WebSocket连接断开!");
  1425. };
  1426. this.webSocket.onerror = function (event) {
  1427. console.log(
  1428. "WebSocket连接异常: " +
  1429. event.code +
  1430. " " +
  1431. event.reason +
  1432. " " +
  1433. event.wasClean
  1434. );
  1435. };
  1436. },
  1437. transFormation() {
  1438. let msg = "TRANSFORMATION:" + this.parameterId;
  1439. console.info("transFormation", msg);
  1440. this.webSocket.send(msg);
  1441. },
  1442. endHandle() {
  1443. let msg = "END:" + this.parameterId;
  1444. this.webSocket.send(msg);
  1445. this.getList();
  1446. this.showTrajectory = false;
  1447. },
  1448. // 居中
  1449. handleCenter() {
  1450. const firstKey = Object.keys(this.targetDataR)[0];
  1451. // 获取到第一个飞机的位置
  1452. const posX = this.targetDataR[`${firstKey}`].x;
  1453. const posY = this.targetDataR[`${firstKey}`].y;
  1454. // 获取画布的中心点的位置
  1455. const centerX = this.container.clientWidth / 2;
  1456. const centerY = this.container.clientHeight / 2;
  1457. // 缩放的值
  1458. const scaleX = this.pixiApp.stage.scale.x || 1;
  1459. const scaleY = this.pixiApp.stage.scale.y || 1;
  1460. // 计算需要移动的距离
  1461. const offsetX = centerX - posX * scaleX;
  1462. const offsetY = centerY - posY * scaleY;
  1463. this.pixiApp.stage.position.set(offsetX, offsetY);
  1464. },
  1465. // 销毁画布信息
  1466. destroyTrajectory() {
  1467. if (this.webSocket) {
  1468. this.webSocket.close();
  1469. }
  1470. if (this.pixiApp) {
  1471. // 移除并销毁所有子对象
  1472. const removedChildren = this.pixiApp.stage.removeChildren(
  1473. 0,
  1474. this.pixiApp.stage.children.length
  1475. );
  1476. removedChildren.forEach((child) => {
  1477. child.destroy({
  1478. children: true,
  1479. texture: false,
  1480. baseTexture: false,
  1481. });
  1482. });
  1483. this.pixiApp.stage.removeChildren();
  1484. this.pixiApp.renderer.clear();
  1485. this.pixiApp.destroy(true);
  1486. this.pixiApp = null;
  1487. }
  1488. if (this.platformGraphics && this.platformGraphics.length) {
  1489. if (this.platformGraphics.parent) {
  1490. this.platformGraphics.parent.removeChild(this.platformGraphics);
  1491. }
  1492. this.platformGraphics.clear();
  1493. this.platformGraphics.destroy(true);
  1494. this.platformGraphics = null;
  1495. }
  1496. if (this.trackGraphicsLine && this.trackGraphicsLine.length) {
  1497. if (this.trackGraphicsLine.parent) {
  1498. this.trackGraphicsLine.parent.removeChild(this.trackGraphicsLine);
  1499. }
  1500. this.trackGraphicsLine.clear();
  1501. this.trackGraphicsLine.destroy(true);
  1502. this.trackGraphicsLine = null;
  1503. }
  1504. this.clearAllAry();
  1505. },
  1506. initTrajectory() {
  1507. // this.clearAllAry();
  1508. this.initPixi();
  1509. this.initWebSocket();
  1510. },
  1511. // 处理WebSocket消息
  1512. processMessage(data) {
  1513. if (this.title == "回放") {
  1514. this.percentage = Math.ceil((data.time / this.playbackTime) * 100);
  1515. }
  1516. // type:1平台无人机、2真实目标、3噪声目标
  1517. switch (data.type) {
  1518. case "1": //平台无人机
  1519. this.showPlatformAir(data);
  1520. break;
  1521. case "2": //真实目标 R真实数据
  1522. this.showTargetRAircraft(data, "R");
  1523. break;
  1524. case "3": //噪声目标 N噪声数据
  1525. this.showTargetNAircraft(data, "N");
  1526. break;
  1527. default:
  1528. break;
  1529. }
  1530. },
  1531. initPixi() {
  1532. this.container = this.$refs.pixiContainer;
  1533. if (!this.container) return;
  1534. // 创建Pixi应用
  1535. this.pixiApp = new PIXI.Application({
  1536. width: this.container.clientWidth,
  1537. height: this.container.clientHeight,
  1538. antialias: true,
  1539. transparent: false,
  1540. resolution: 1,
  1541. backgroundAlpha: 0,
  1542. });
  1543. this.pixiApp.renderer.backgroundColor = 0x66ccff;
  1544. this.container.appendChild(this.pixiApp.view);
  1545. // 添加视窗控制
  1546. this.enableViewControl(this.pixiApp);
  1547. // 增加追踪线
  1548. this.trackGraphicsLine = new PIXI.Graphics();
  1549. this.trackGraphicsLine.lineStyle(1, 0xf5f7fa, 1);
  1550. this.pixiApp.stage.addChild(this.trackGraphicsLine);
  1551. },
  1552. // 平台无人机展示
  1553. showPlatformAir(platformData) {
  1554. const data = platformData.platformAircraft;
  1555. if (this.platformData.length == 0) {
  1556. const platformTexture = new PIXI.Texture.from(platformPNG);
  1557. this.platformSprite = new PIXI.Sprite(platformTexture);
  1558. this.platformSprite.anchor.set(0.5, 0.5);
  1559. this.platformSprite.scale.set(0.1);
  1560. this.platformSprite.buttonMode = true; // 鼠标悬停时显示手型
  1561. this.platformSprite.interactive = true;
  1562. this.platformSprite.x = data.coordinateX;
  1563. this.platformSprite.y = data.coordinateY;
  1564. const label = "平台无人机";
  1565. this.allSpriteInfo.push({
  1566. id: 100001,
  1567. label,
  1568. });
  1569. this.platformData.push(this.platformSprite);
  1570. this.pixiApp.stage.addChild(this.platformSprite);
  1571. // 创建路径
  1572. this.platformGraphics = new PIXI.Graphics();
  1573. this.platformGraphics.lineStyle(1, 0x00ee00, 1);
  1574. const point = { x: this.platformSprite.x, y: this.platformSprite.y };
  1575. this.platformPathData = point;
  1576. this.platformInfo = data;
  1577. this.pixiApp.stage.addChild(this.platformGraphics);
  1578. } else {
  1579. this.platformSprite.x = data.coordinateX;
  1580. this.platformSprite.y = data.coordinateY;
  1581. this.platformSprite.rotation = data.azimuthAngle * (Math.PI / 180);
  1582. // this.platformSprite.rotation = Math.atan2(
  1583. // data.northSpeed,
  1584. // data.eastSpeed
  1585. // );
  1586. // this.platformInfo = data;
  1587. Object.assign(this.platformInfo, data);
  1588. if (this.platformCycleCount % this.updatePlatformPathFlag == 0) {
  1589. // 更新路径绘制
  1590. this.updatePlatformPath(this.platformSprite.x, this.platformSprite.y);
  1591. }
  1592. }
  1593. this.platformCycleCount++;
  1594. },
  1595. // 无人机集群 真实数据
  1596. showTargetRAircraft(data) {
  1597. const targetData = data.targetAircraft[0];
  1598. this.targetTotal = targetData.aircrafts.length;
  1599. let empty = Object.keys(this.targetDataR);
  1600. // 还没有真实数据时,先初始化数据。
  1601. if (empty.length == 0) {
  1602. for (let i = 0; i < this.targetTotal; i++) {
  1603. const label = "目标无人机" + targetData.aircrafts[i].aircraftNumber;
  1604. this.allSpriteInfo.push({
  1605. id: targetData.aircrafts[i].aircraftNumber,
  1606. label,
  1607. });
  1608. this.allId.push(targetData.aircrafts[i].aircraftNumber);
  1609. // (飞机相关数据,,是否为真实数据)
  1610. this.addAir(targetData.aircrafts[i], true);
  1611. // 绑定鼠标事件,飞机隐藏
  1612. // group.on("pointerdown", () => {
  1613. // this.hideSprite(group.id);
  1614. // });
  1615. }
  1616. } else {
  1617. // 每次更新
  1618. const newData = data.targetAircraft[0].aircrafts;
  1619. let isHide = false,
  1620. targetDataKeys,
  1621. flagCount = 0;
  1622. if (this.title == "回放") {
  1623. targetDataKeys = Object.keys(this.targetDataR);
  1624. const count = targetDataKeys.length;
  1625. // 当存的数据大于返回数据时,证明有数据隐藏
  1626. if (count > newData.length) {
  1627. isHide = true;
  1628. }
  1629. }
  1630. for (let i = 0; i < newData.length; i++) {
  1631. const id = newData[i].aircraftNumber;
  1632. const targetUav = this.targetDataR[`${id}`];
  1633. if (this.title == "回放" && isHide) {
  1634. targetDataKeys.splice(
  1635. targetDataKeys.findIndex((item) => item === id),
  1636. 1
  1637. );
  1638. flagCount++;
  1639. if (flagCount == newData.length) {
  1640. this.delHideAir(targetDataKeys);
  1641. }
  1642. }
  1643. if (targetUav) {
  1644. targetUav.x = newData[i].coordinateX;
  1645. targetUav.y = newData[i].coordinateY;
  1646. const eastSpeed = newData[i].eastSpeed;
  1647. const northSpeed = newData[i].northSpeed;
  1648. targetUav.rotation = Math.atan2(northSpeed, eastSpeed);
  1649. const cx = targetUav.x - 10;
  1650. const cy = targetUav.y - 6;
  1651. const circle = this.targetUavCircleR[`${id}`];
  1652. circle.x = cx;
  1653. circle.y = cy;
  1654. const text = this.targetUavCircleNumR[`${id}`];
  1655. text.x = cx;
  1656. text.y = cy;
  1657. if (this.platformInfo.targetAircraftNumber == id) {
  1658. this.trackGraphicsLine.clear();
  1659. this.trackGraphicsLine.lineStyle(1, 0xf5f7fa, 1);
  1660. const returnData = this.calculateRelativePosition(
  1661. this.platformInfo.latitude,
  1662. this.platformInfo.longitude,
  1663. 0,
  1664. newData[i].latitude,
  1665. newData[i].longitude,
  1666. 0
  1667. );
  1668. this.platformInfo.distance = Number(
  1669. returnData.distance.toFixed()
  1670. );
  1671. this.platformInfo.bearing = Number(returnData.bearing.toFixed(2));
  1672. this.trackGraphicsLine.moveTo(
  1673. this.platformInfo.coordinateX,
  1674. this.platformInfo.coordinateY
  1675. );
  1676. this.trackGraphicsLine.lineTo(
  1677. newData[i].coordinateX,
  1678. newData[i].coordinateY
  1679. );
  1680. }
  1681. } else {
  1682. this.addAir(newData[i], true);
  1683. const label = "目标无人机" + newData[i].aircraftNumber;
  1684. this.allSpriteInfo.push({
  1685. id: targetData.aircrafts[i].aircraftNumber,
  1686. label,
  1687. });
  1688. }
  1689. if (targetUav && this.cycleCount % this.updatePathFlag == 0) {
  1690. // 更新路径绘制
  1691. this.updatePath(id, targetUav.x, targetUav.y);
  1692. }
  1693. if (this.isUpdateView && i == 0) {
  1694. const viewSprite = this.pixiApp.stage.children.find((item) => {
  1695. return (
  1696. item.id == data.targetAircraft[0].aircrafts[0].aircraftNumber
  1697. );
  1698. });
  1699. // 获取精灵的边界
  1700. const spriteBounds = viewSprite.getBounds();
  1701. // 检测是否移出画布
  1702. if (spriteBounds.left < 0) {
  1703. // 触碰到了左边界
  1704. this.pixiApp.stage.x += this.container.clientWidth / 2;
  1705. } else if (spriteBounds.right > this.container.clientWidth) {
  1706. // 触碰到了右边
  1707. this.pixiApp.stage.x -= this.container.clientWidth / 2;
  1708. } else if (spriteBounds.top < 0) {
  1709. // 触碰到了上边
  1710. this.pixiApp.stage.y += this.container.clientHeight / 2;
  1711. } else if (spriteBounds.bottom > this.container.clientHeight) {
  1712. // 触碰到了下边
  1713. this.pixiApp.stage.y -= this.container.clientHeight / 2;
  1714. }
  1715. }
  1716. this.cycleCount++;
  1717. }
  1718. if (data.targetAircraft != null) {
  1719. for (let i = 0; i < this.targetTotal; i++) {
  1720. const id = targetData.aircrafts[i].aircraftNumber;
  1721. let index = this.changeNoList.findIndex(
  1722. (item) => item.changeNo == id
  1723. );
  1724. // 多目标集群信息显示
  1725. const lbl = {
  1726. id: id,
  1727. longitude: targetData.aircrafts[i].longitude.toFixed(7),
  1728. latitude: targetData.aircrafts[i].latitude.toFixed(7),
  1729. altitude: targetData.aircrafts[i].altitude + " m",
  1730. eastSpeed: targetData.aircrafts[i].eastSpeed.toFixed(1) + " m/s",
  1731. northSpeed:
  1732. targetData.aircrafts[i].northSpeed.toFixed(1) + " m/s",
  1733. skySpeed: targetData.aircrafts[i].skySpeed.toFixed(1) + " m/s",
  1734. };
  1735. if (index !== -1) {
  1736. const findItem = this.changeNoList[index];
  1737. for (const key in this.targetLblAry) {
  1738. if (this.targetLblAry.hasOwnProperty(key)) {
  1739. if (key === findItem.id) {
  1740. delete this.targetLblAry[key];
  1741. // 插入新属性和值
  1742. this.targetLblAry[findItem.changeNo] = lbl;
  1743. this.changeNoList.splice(index, 1);
  1744. }
  1745. }
  1746. }
  1747. }
  1748. this.targetLblAry[`${id}`] = lbl;
  1749. // if (this.targetLblAry.length === 0) {
  1750. // this.targetLblAry.push(lbl);
  1751. // } else {
  1752. // this.targetLblAry.splice(i, 1, lbl);
  1753. // }
  1754. }
  1755. }
  1756. }
  1757. },
  1758. // 新建一个飞机
  1759. addAir(data, isZhen) {
  1760. const targetTexture = new PIXI.Texture.from(uavTarPNG);
  1761. const group = new PIXI.Container();
  1762. group.id = data.aircraftNumber;
  1763. // 创建无人机
  1764. const dude = new PIXI.Sprite(targetTexture);
  1765. dude.anchor.set(0.5, 0.5);
  1766. dude.scale.set(0.01);
  1767. dude.x = data.coordinateX;
  1768. dude.y = data.coordinateY;
  1769. dude.id = data.aircraftNumber;
  1770. const id = dude.id + "";
  1771. group.addChild(dude);
  1772. // 创建圆圈 圆圈相对于飞机的位置
  1773. const cx = dude.x - 10;
  1774. const cy = dude.y - 6;
  1775. //编号-圆圈
  1776. const circle = new PIXI.Graphics();
  1777. circle.beginFill(0xff0000); // 红色
  1778. circle.drawCircle(0, 0, 8);
  1779. circle.endFill();
  1780. circle.x = cx;
  1781. circle.y = cy;
  1782. circle.scale.set(0.4);
  1783. group.addChild(circle);
  1784. //编号-数字
  1785. const text = new PIXI.Text(data.aircraftNumber, {
  1786. fontFamily: "Arial",
  1787. fontSize: 12,
  1788. fill: 0xffffff,
  1789. align: "center",
  1790. });
  1791. text.anchor.set(0.5);
  1792. // 计算文字位置以便在圆形内居中
  1793. text.x = cx;
  1794. text.y = cy;
  1795. text.scale.set(0.4);
  1796. group.addChild(text);
  1797. if (isZhen) {
  1798. group.typeName = "zhenshi";
  1799. group.buttonMode = true; // 鼠标悬停时显示手型
  1800. group.interactive = true;
  1801. this.targetDataR[`${id}`] = dude;
  1802. this.targetUavCircleR[`${id}`] = circle;
  1803. this.targetUavCircleNumR[`${id}`] = text;
  1804. } else {
  1805. dude.alpha = 0.5;
  1806. circle.alpha = 0.5;
  1807. text.alpha = 0.5;
  1808. this.targetDataN[`${id}`] = dude;
  1809. this.targetUavCircleN[`${id}`] = circle;
  1810. this.targetUavCircleNumN[`${id}`] = text;
  1811. }
  1812. this.pixiApp.stage.addChild(group);
  1813. // 真实数据创建路径
  1814. if (isZhen) {
  1815. const pathGraphics = new PIXI.Graphics();
  1816. pathGraphics.lineStyle(1, 0xeeee00, 1);
  1817. const point = { x: dude.x, y: dude.y };
  1818. pathGraphics.id = data.aircraftNumber;
  1819. this.pathGraphicsPointList[`${id}`] = point;
  1820. this.pathGraphicsList[`${id}`] = pathGraphics;
  1821. this.pixiApp.stage.addChild(pathGraphics);
  1822. }
  1823. },
  1824. // 删除回放时隐藏的飞机
  1825. delHideAir(targetDataKeys) {
  1826. const hideId = targetDataKeys[0];
  1827. let group = [];
  1828. this.pixiApp.stage.children.forEach((child) => {
  1829. // 检查 child 是否是 Container 类型
  1830. if (child instanceof PIXI.Container) {
  1831. if (child.id == hideId) {
  1832. group.push(child);
  1833. }
  1834. }
  1835. });
  1836. group.forEach((child) => {
  1837. if (!(child instanceof PIXI.Graphics)) {
  1838. if (child.parent) {
  1839. child.parent.removeChild(child);
  1840. }
  1841. child.destroy();
  1842. if (this.targetDataR[hideId]) {
  1843. delete this.targetDataR[hideId];
  1844. }
  1845. if (this.targetLblAry[hideId]) {
  1846. delete this.targetLblAry[hideId];
  1847. }
  1848. const idx = this.allSpriteInfo.findIndex((info) => {
  1849. return info.id == hideId;
  1850. });
  1851. if (idx > -1) {
  1852. this.allSpriteInfo.splice(idx, 1);
  1853. }
  1854. }
  1855. });
  1856. },
  1857. // 无人机集群 噪音数据
  1858. showTargetNAircraft(data) {
  1859. const targetData = data.targetAircraft[0];
  1860. // this.targetTotal = targetData.aircrafts.length;
  1861. const targetTotal = targetData.aircrafts.length;
  1862. let empty = Object.keys(this.targetDataN);
  1863. // 还没有数据时,先初始化数据。
  1864. if (empty.length == 0) {
  1865. for (let i = 0; i < targetTotal; i++) {
  1866. this.addAir(targetData.aircrafts[i], false);
  1867. }
  1868. } else {
  1869. // 每次更新
  1870. const newData = data.targetAircraft[0].aircrafts;
  1871. let isHide = false,
  1872. targetDataKeys,
  1873. flagCount = 0;
  1874. if (this.title == "回放") {
  1875. targetDataKeys = Object.keys(this.targetDataR);
  1876. const count = targetDataKeys.length;
  1877. // 当存的数据大于返回数据时,证明有数据隐藏
  1878. if (count > newData.length) {
  1879. isHide = true;
  1880. }
  1881. }
  1882. for (let i = 0; i < newData.length; i++) {
  1883. const id = newData[i].aircraftNumber;
  1884. const targetUav = this.targetDataN[`${id}`];
  1885. // 有隐藏的话要删除飞机
  1886. if (this.title == "回放" && isHide) {
  1887. targetDataKeys.splice(
  1888. targetDataKeys.findIndex((item) => item === id),
  1889. 1
  1890. );
  1891. flagCount++;
  1892. if (flagCount == newData.length) {
  1893. this.delHideAir(targetDataKeys);
  1894. }
  1895. }
  1896. if (targetUav) {
  1897. targetUav.x = newData[i].coordinateX;
  1898. targetUav.y = newData[i].coordinateY;
  1899. const eastSpeed = newData[i].eastSpeed;
  1900. const northSpeed = newData[i].northSpeed;
  1901. targetUav.rotation = Math.atan2(northSpeed, eastSpeed);
  1902. const cx = targetUav.x - 10;
  1903. const cy = targetUav.y - 6;
  1904. const circle = this.targetUavCircleN[`${id}`];
  1905. circle.x = cx;
  1906. circle.y = cy;
  1907. const text = this.targetUavCircleNumN[`${id}`];
  1908. text.x = cx;
  1909. text.y = cy;
  1910. } else {
  1911. this.addAir(newData[i], false);
  1912. }
  1913. }
  1914. }
  1915. },
  1916. // 飞机的显示与隐藏
  1917. hideSprite(id) {
  1918. let group = [];
  1919. this.pixiApp.stage.children.forEach((child) => {
  1920. // 检查 child 是否是 Container 类型
  1921. if (child instanceof PIXI.Container) {
  1922. if (child.id == id) {
  1923. group.push(child);
  1924. }
  1925. }
  1926. });
  1927. group.forEach((item) => {
  1928. if (item.typeName) {
  1929. const msg = "DISAPPEAR:" + item.id;
  1930. this.webSocket.send(msg);
  1931. }
  1932. item.visible = false;
  1933. });
  1934. this.hideList.push(id);
  1935. // this.changeNoList.push({ id: id, changeNo: id });
  1936. },
  1937. // 飞机的显示与隐藏
  1938. showSprite(id) {
  1939. if (this.isUpdateView) {
  1940. // 表示是回放,不用隐藏
  1941. return;
  1942. }
  1943. let group = [];
  1944. this.pixiApp.stage.children.forEach((child) => {
  1945. // 检查 child 是否是 Container 类型
  1946. if (child instanceof PIXI.Container) {
  1947. if (child.id == id) {
  1948. group.push(child);
  1949. }
  1950. }
  1951. });
  1952. // group有三个,真实飞机、噪音飞机、轨迹
  1953. if (this.hideList.includes(id)) {
  1954. const maxNum = Math.max(...this.allId) + 1;
  1955. group.forEach((item) => {
  1956. // 已经隐藏了,要显示
  1957. if (item.typeName) {
  1958. const msg = "SHOW:" + item.id;
  1959. this.webSocket.send(msg);
  1960. this.changeNoList.push({ id: id, changeNo: maxNum });
  1961. let index = this.hideList.indexOf(id);
  1962. if (index > -1) {
  1963. this.hideList.splice(index, 1);
  1964. }
  1965. this.allId.push(maxNum);
  1966. if (item.parent) {
  1967. item.parent.removeChild(item);
  1968. }
  1969. // 可选:销毁精灵并释放资源
  1970. item.destroy();
  1971. delete this.targetDataR[item.id];
  1972. }
  1973. // item.visible = true;
  1974. });
  1975. } else {
  1976. // 隐藏
  1977. group.forEach((item) => {
  1978. if (item.typeName) {
  1979. const msg = "DISAPPEAR:" + item.id;
  1980. this.webSocket.send(msg);
  1981. this.hideList.push(id);
  1982. let index = this.allSpriteInfo.findIndex((info) => {
  1983. return info.id == item.id;
  1984. });
  1985. this.allSpriteInfo.splice(index, 1);
  1986. }
  1987. // 只隐藏飞机,不隐藏轨迹
  1988. if (!(item instanceof PIXI.Graphics)) {
  1989. item.visible = false;
  1990. }
  1991. });
  1992. // this.changeNoList.push({ id: id, changeNo: id });
  1993. }
  1994. },
  1995. // 添加视窗控制
  1996. enableViewControl(app) {
  1997. app.stage.interactive = true;
  1998. // 拖曳状态变量
  1999. let dragging = false;
  2000. let lastPosition = null; // 上一次鼠标的位置
  2001. if (!(this.title == "添加任务数据" || this.title == "修改任务数据")) {
  2002. // 鼠标按下事件
  2003. app.view.addEventListener("mousedown", (event) => {
  2004. dragging = true;
  2005. lastPosition = { x: event.clientX, y: event.clientY };
  2006. });
  2007. // 鼠标移出画布时停止拖动
  2008. app.view.addEventListener("mouseleave", () => {
  2009. dragging = false;
  2010. });
  2011. // 鼠标移动事件
  2012. app.view.addEventListener("mousemove", (event) => {
  2013. if (dragging) {
  2014. const currentPosition = { x: event.clientX, y: event.clientY };
  2015. // 计算鼠标移动的距离
  2016. const dx = currentPosition.x - lastPosition.x;
  2017. const dy = currentPosition.y - lastPosition.y;
  2018. // 更新舞台的位置
  2019. app.stage.x += dx;
  2020. app.stage.y += dy;
  2021. // 更新上一次鼠标的位置
  2022. lastPosition = currentPosition;
  2023. }
  2024. });
  2025. // 鼠标松开事件
  2026. app.view.addEventListener("mouseup", () => {
  2027. dragging = false;
  2028. });
  2029. }
  2030. // 鼠标滚轮缩放
  2031. app.renderer.view.addEventListener("wheel", (e) => {
  2032. e.preventDefault();
  2033. const zoomFactor = e.deltaY > 0 ? 0.9 : 1.1;
  2034. app.stage.scale.x *= zoomFactor;
  2035. app.stage.scale.y *= zoomFactor;
  2036. });
  2037. },
  2038. // 更新无人机飞行路径
  2039. updatePath(id, x, y) {
  2040. const lastPointX = this.pathGraphicsPointList[`${id}`].x;
  2041. const lastPointY = this.pathGraphicsPointList[`${id}`].y;
  2042. this.pathGraphicsList[`${id}`].moveTo(lastPointX, lastPointY);
  2043. this.pathGraphicsList[`${id}`].lineTo(x, y);
  2044. this.pathGraphicsPointList[`${id}`].x = x;
  2045. this.pathGraphicsPointList[`${id}`].y = y;
  2046. },
  2047. // 更新平台无人机飞行路径
  2048. updatePlatformPath(x, y) {
  2049. const lastPointX = this.platformPathData.x;
  2050. const lastPointY = this.platformPathData.y;
  2051. this.platformGraphics.moveTo(lastPointX, lastPointY);
  2052. this.platformGraphics.lineTo(x, y);
  2053. this.platformPathData.x = x;
  2054. this.platformPathData.y = y;
  2055. },
  2056. // 确定编队信息
  2057. canvasInfoSubmit() {
  2058. this.$refs["canvasInfoFormRef"].validate((valid) => {
  2059. if (valid) {
  2060. this.submitInfoFlag = true;
  2061. this.addAirSprite();
  2062. }
  2063. });
  2064. },
  2065. // 初始化自定义编队的画布
  2066. initFormationApp() {
  2067. this.pixiCanvas = this.$refs.pixiCanvas;
  2068. if (!this.pixiCanvas) return;
  2069. // 创建Pixi应用
  2070. this.formationAirPiXiApp = new PIXI.Application({
  2071. width: this.pixiCanvas.clientWidth,
  2072. height: this.pixiCanvas.clientHeight,
  2073. antialias: true,
  2074. transparent: false,
  2075. resolution: 1,
  2076. backgroundAlpha: 0,
  2077. });
  2078. this.formationAirPiXiApp.renderer.backgroundColor = 0x1099bb;
  2079. this.pixiCanvas.appendChild(this.formationAirPiXiApp.view);
  2080. // 绘制中心点
  2081. const graphics = new PIXI.Graphics();
  2082. graphics.beginFill(0xe53f32);
  2083. // 绘制一个圆形,半径为 5 像素
  2084. const centerX = this.pixiCanvas.clientWidth / 2;
  2085. const centerY = this.pixiCanvas.clientHeight / 2;
  2086. graphics.drawCircle(centerX, centerY, 3);
  2087. graphics.endFill();
  2088. this.formationAirPiXiApp.stage.addChild(graphics);
  2089. // this.enableViewControl(this.formationAirPiXiApp);
  2090. },
  2091. // 增加飞机编队
  2092. addAirSprite() {
  2093. // 判断是哪个机型
  2094. let texture = new PIXI.Texture.from(uavTarPNG);
  2095. // 创建飞机
  2096. const airSprite = new PIXI.Sprite(texture);
  2097. airSprite.anchor.set(0.5, 0.5);
  2098. airSprite.scale.set(0.04);
  2099. airSprite.position.set(
  2100. this.formationAirPiXiApp.screen.width / 2,
  2101. this.formationAirPiXiApp.screen.height / 2
  2102. );
  2103. this.formationAirPiXiApp.stage.addChild(airSprite);
  2104. this.formationAirPiXiApp.stage.eventMode = "static";
  2105. this.formationAirPiXiApp.stage.hitArea = this.formationAirPiXiApp.screen;
  2106. this.formationAirPiXiApp.view.addEventListener("pointermove", (e) => {
  2107. airSprite.x = e.offsetX;
  2108. airSprite.y = e.offsetY;
  2109. // 计算对应经纬度
  2110. const { lat, lng } = this.calculateLatLng(e.offsetX, e.offsetY);
  2111. this.nowlongitude = lng;
  2112. this.nowlatitude = lat;
  2113. });
  2114. this.formationAirPiXiApp.view.addEventListener("dblclick", (e) => {
  2115. // 创建新精灵
  2116. const newSprite = new PIXI.Sprite(texture);
  2117. newSprite.anchor.set(0.5, 0.5);
  2118. newSprite.scale.set(0.04);
  2119. newSprite.x = e.offsetX;
  2120. newSprite.y = e.offsetY;
  2121. // 计算对应经纬度
  2122. const { lat, lng } = this.calculateLatLng(e.offsetX, e.offsetY);
  2123. this.formationInfoForm = {
  2124. number: null,
  2125. longitude: null,
  2126. latitude: null,
  2127. altitude: null,
  2128. eastSpeed: null,
  2129. northSpeed: null,
  2130. skySpeed: null,
  2131. flightPathType: "直线",
  2132. positionNoise: null,
  2133. };
  2134. this.formationInfoForm.longitude = lng;
  2135. this.formationInfoForm.latitude = lat;
  2136. this.drawerOpen = true;
  2137. this.addOrUpdate = "add";
  2138. this.formationInfoAirDataList.push(newSprite);
  2139. this.formationAirPiXiApp.stage.addChild(newSprite);
  2140. });
  2141. },
  2142. calculateLatLng(x, y) {
  2143. // 计算鼠标相对于画布中心的偏移量(单位:像素)
  2144. const offsetX = x - this.pixiCanvas.clientWidth / 2;
  2145. const offsetY = y - this.pixiCanvas.clientHeight / 2;
  2146. // 将像素偏移量转换为实际距离(单位:公里)
  2147. const kmPerPixel = this.canvasInfo.lengthKm / this.pixiCanvas.clientWidth;
  2148. const deltaX = offsetX * kmPerPixel;
  2149. const deltaY = -offsetY * kmPerPixel; // 注意 y 轴方向相反
  2150. // 将实际距离转换为经纬度差值
  2151. const deltaLat = deltaY / 111; // 每纬度约 111 公里
  2152. const deltaLng =
  2153. deltaX /
  2154. (111 * Math.cos((this.canvasInfo.centerLatitude * Math.PI) / 180)); // 每经度约 111 * cos(lat) 公里
  2155. // 计算最终经纬度
  2156. const lat = Number(this.canvasInfo.centerLatitude) + Number(deltaLat);
  2157. const lng = Number(this.canvasInfo.centerLongitude) + Number(deltaLng);
  2158. return { lat, lng };
  2159. },
  2160. editFormationInfo(row) {
  2161. this.formationInfoForm = row;
  2162. this.drawerOpen = true;
  2163. this.addOrUpdate = "update";
  2164. },
  2165. handleDrawerSubmit() {
  2166. this.$refs["formationInfoRef"].validate((valid) => {
  2167. if (valid) {
  2168. this.formationInfoForm = this.ObjectStringToNumber(
  2169. this.formationInfoForm
  2170. );
  2171. let index = this.formationInfoList.findIndex(
  2172. (item) => item.number == this.formationInfoForm.number
  2173. );
  2174. // 查看是不是已在列表中
  2175. if (index !== -1) {
  2176. if (this.addOrUpdate == "add") {
  2177. // 如果在,并且是新增加的
  2178. this.$message.warning("该编号已存在,请重新输入");
  2179. return;
  2180. } else {
  2181. // 在,是要修改的。修改的还不能列表中的编号相同
  2182. this.formationInfoList[index] = this.formationInfoForm;
  2183. let spriteIndex;
  2184. this.formationAirPiXiApp.stage.children.forEach(
  2185. (child, index) => {
  2186. // 检查 child 是否是 Container 类型
  2187. if (child instanceof PIXI.Sprite) {
  2188. if (child.id == this.formationInfoForm.number) {
  2189. spriteIndex = index;
  2190. }
  2191. }
  2192. }
  2193. );
  2194. const sprite =
  2195. this.formationAirPiXiApp.stage.children[spriteIndex];
  2196. const { x, y } = this.calculateXY(
  2197. this.formationInfoForm.longitude,
  2198. this.formationInfoForm.latitude
  2199. );
  2200. sprite.x = x;
  2201. sprite.y = y;
  2202. this.drawerOpen = false;
  2203. }
  2204. } else {
  2205. //不在列表中
  2206. if (this.addOrUpdate == "add") {
  2207. // 新增加的
  2208. this.formationInfoList.push(this.formationInfoForm);
  2209. const length = this.formationInfoAirDataList.length;
  2210. this.$set(
  2211. this.formationInfoAirDataList[length - 1],
  2212. "id",
  2213. this.formationInfoForm.number
  2214. );
  2215. this.drawerOpen = false;
  2216. }
  2217. }
  2218. }
  2219. });
  2220. },
  2221. // 删除编队信息
  2222. canvasInfoDel() {
  2223. this.$modal
  2224. .confirm("是否确认删除该无人机")
  2225. .then(() => {
  2226. this.formationInfoForm = this.ObjectStringToNumber(
  2227. this.formationInfoForm
  2228. );
  2229. let index = this.formationInfoList.findIndex(
  2230. (item) => item.number == this.formationInfoForm.number
  2231. );
  2232. if (index > -1) {
  2233. this.formationInfoAirDataList =
  2234. this.formationInfoAirDataList.filter((item) => {
  2235. return item.id !== this.formationInfoForm.number;
  2236. });
  2237. this.formationAirPiXiApp.stage.children.forEach((child, index) => {
  2238. // 检查 child 是否是 Container 类型
  2239. if (child instanceof PIXI.Sprite) {
  2240. if (child.id == this.formationInfoForm.number) {
  2241. if (child.parent) {
  2242. child.parent.removeChild(child);
  2243. }
  2244. child.destroy();
  2245. }
  2246. }
  2247. });
  2248. this.formationInfoList.splice(index, 1);
  2249. }
  2250. })
  2251. .then(() => {
  2252. this.drawerOpen = false;
  2253. this.$modal.msgSuccess("删除成功");
  2254. })
  2255. .catch((err) => {
  2256. console.log(err);
  2257. });
  2258. },
  2259. ObjectStringToNumber(obj) {
  2260. for (let key in obj) {
  2261. const parsedValue = Number(obj[key]); // 尝试将值转换为数字
  2262. if (!isNaN(parsedValue)) {
  2263. // 检查是否是有效的数字
  2264. obj[key] = parsedValue; // 如果是数字,更新字段值
  2265. }
  2266. }
  2267. return obj;
  2268. },
  2269. closeDialog() {
  2270. const msg = "END:" + this.parameterId;
  2271. this.webSocket.send(msg);
  2272. this.destroyTrajectory();
  2273. this.showTrajectory = false;
  2274. this.isUpdateView = false;
  2275. this.isClickGroup = false;
  2276. setTimeout(() => {
  2277. this.getList();
  2278. }, 1500);
  2279. },
  2280. closeUpdataDialog() {
  2281. this.destroyTormationInfo();
  2282. this.canvasInfo = {
  2283. centerLongitude: null,
  2284. centerLatitude: null,
  2285. lengthKm: null,
  2286. };
  2287. this.submitInfoFlag = false;
  2288. this.formationAirPiXiApp = null;
  2289. this.pixiCanvas = null;
  2290. this.nowlongitude = null;
  2291. this.nowlatitude = null;
  2292. this.formationInfoList = [];
  2293. this.reset();
  2294. },
  2295. destroyTormationInfo() {
  2296. if (this.formationAirPiXiApp) {
  2297. const removedChildren = this.formationAirPiXiApp.stage.removeChildren(
  2298. 0,
  2299. this.formationAirPiXiApp.stage.children.length
  2300. );
  2301. removedChildren.forEach((child) => {
  2302. child.destroy({
  2303. children: true,
  2304. texture: false,
  2305. baseTexture: false,
  2306. });
  2307. });
  2308. this.formationAirPiXiApp.stage.removeChildren();
  2309. this.formationAirPiXiApp.renderer.clear();
  2310. this.formationAirPiXiApp.destroy(true);
  2311. this.formationAirPiXiApp = null;
  2312. }
  2313. },
  2314. drawerClose() {
  2315. this.formationInfoForm = {
  2316. number: null,
  2317. longitude: null,
  2318. latitude: null,
  2319. altitude: null,
  2320. eastSpeed: null,
  2321. northSpeed: null,
  2322. skySpeed: null,
  2323. flightPathType: "直线",
  2324. positionNoise: null,
  2325. };
  2326. this.addOrUpdate = "add";
  2327. },
  2328. clearAllAry() {
  2329. this.targetLblAry = {};
  2330. this.targetUavAry = [];
  2331. this.targetUavCircleR = {};
  2332. this.targetUavCircleN = {};
  2333. this.targetUavCircleNumR = {};
  2334. this.targetUavCircleNumN = {};
  2335. this.configList = [
  2336. "经度",
  2337. "纬度",
  2338. "海拔",
  2339. "东向速度",
  2340. "北向速度",
  2341. "天向速度",
  2342. ];
  2343. this.lastPosition = {
  2344. x: null,
  2345. y: null,
  2346. };
  2347. this.hideList = [];
  2348. this.allId = [];
  2349. this.changeNoList = [];
  2350. this.curLongitude = null;
  2351. this.curLatitude = null;
  2352. this.curAltitude = null;
  2353. this.pathGraphics = null;
  2354. this.cycleCount = 0;
  2355. this.isUpdateView = false;
  2356. this.pathGraphicsList = {};
  2357. this.pathGraphicsPointList = {};
  2358. this.targetDataR = {};
  2359. this.targetDataN = {};
  2360. this.nowlongitude = null;
  2361. this.nowlatitude = null;
  2362. this.submitInfoFlag = false;
  2363. this.pixiCanvas = null;
  2364. this.canvasInfo = {
  2365. centerLongitude: null,
  2366. centerLatitude: null,
  2367. lengthKm: null,
  2368. heightKm: null,
  2369. };
  2370. this.platformSprite = null;
  2371. this.platformGraphics = null;
  2372. this.platformPathData = {};
  2373. this.platformInfo = {};
  2374. this.platformData = [];
  2375. this.allSpriteInfo = [];
  2376. this.isClickGroup = false;
  2377. this.firstLng = null;
  2378. this.firstLat = null;
  2379. this.playbackTime = null;
  2380. this.firstAir = "";
  2381. this.secondAir = "";
  2382. },
  2383. // 综合计算(距离、方位角、航向夹角)
  2384. calculateRelativePosition(lat1, lon1, heading1, lat2, lon2, heading2) {
  2385. const distance = this.calculateDistance(lat1, lon1, lat2, lon2);
  2386. const bearing = this.calculateBearing(lat1, lon1, lat2, lon2);
  2387. // const headingDiff = this.calculateHeadingDiff(heading1, heading2);
  2388. return {
  2389. distance: distance, // 两飞机距离(米)
  2390. bearing: bearing, // 飞机2相对于飞机1的方位角(0°~360°)
  2391. // headingDiff: headingDiff, // 两飞机航向夹角(0°~180°)
  2392. };
  2393. },
  2394. // 计算两架飞机的航向夹角(航向差)
  2395. calculateHeadingDiff(heading1, heading2) {
  2396. const diff = Math.abs(heading1 - heading2);
  2397. return diff > 180 ? 360 - diff : diff;
  2398. },
  2399. // 计算飞机2相对于飞机1的方位角
  2400. calculateBearing(lat1, lon1, lat2, lon2) {
  2401. const phi1 = (lat1 * Math.PI) / 180;
  2402. const lambda1 = (lon1 * Math.PI) / 180;
  2403. const phi2 = (lat2 * Math.PI) / 180;
  2404. const lambda2 = (lon2 * Math.PI) / 180;
  2405. const y = Math.sin(lambda2 - lambda1) * Math.cos(phi2);
  2406. const x =
  2407. Math.cos(phi1) * Math.sin(phi2) -
  2408. Math.sin(phi1) * Math.cos(phi2) * Math.cos(lambda2 - lambda1);
  2409. let theta = (Math.atan2(y, x) * 180) / Math.PI;
  2410. return (theta + 360) % 360; // 确保在0°~360°范围内
  2411. },
  2412. // 计算两架飞机之间的距离(Haversine 公式)
  2413. calculateDistance(lat1, lon1, lat2, lon2) {
  2414. const R = 6371000; // 地球半径(米)
  2415. const phi1 = (lat1 * Math.PI) / 180;
  2416. const phi2 = (lat2 * Math.PI) / 180;
  2417. const deltaPhi = ((lat2 - lat1) * Math.PI) / 180;
  2418. const deltaLambda = ((lon2 - lon1) * Math.PI) / 180;
  2419. const a =
  2420. Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) +
  2421. Math.cos(phi1) *
  2422. Math.cos(phi2) *
  2423. Math.sin(deltaLambda / 2) *
  2424. Math.sin(deltaLambda / 2);
  2425. const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  2426. return R * c; // 返回距离(米)
  2427. },
  2428. },
  2429. };
  2430. </script>
  2431. <style>
  2432. .el-dialog__body {
  2433. /* padding: 0 !important; */
  2434. padding-top: 10px !important;
  2435. }
  2436. .pixi-container {
  2437. width: 100%;
  2438. /* height: 750px; */
  2439. height: calc(100vh - 140px);
  2440. position: relative;
  2441. }
  2442. .pixi-container canvas {
  2443. width: 100%;
  2444. height: 100%;
  2445. }
  2446. .container {
  2447. display: grid;
  2448. grid-template-columns: 85% 15%; /* 两栏按比例分 */
  2449. }
  2450. .right-board {
  2451. padding: 2px;
  2452. margin: 2px;
  2453. height: 800px;
  2454. /* 当内容超出元素边界时显示滚动条 */
  2455. }
  2456. .distance {
  2457. display: inline-block;
  2458. width: 750px;
  2459. margin-left: 50px;
  2460. }
  2461. .info {
  2462. font-weight: 700;
  2463. color: #4f4a4a;
  2464. }
  2465. </style>