123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559 |
- <template>
- <div class="app-container">
- <el-form
- :model="queryParams"
- ref="queryForm"
- size="small"
- :inline="true"
- v-show="showSearch"
- label-width="68px"
- >
- <el-form-item label="任务名称" prop="bizName">
- <el-input
- v-model="queryParams.bizName"
- placeholder="请输入任务名称"
- clearable
- @keyup.enter.native="handleQuery"
- />
- </el-form-item>
- <el-form-item label="状态" prop="status">
- <el-select
- v-model="queryParams.status"
- placeholder="请选择状态"
- clearable
- >
- <el-option
- v-for="dict in dict.type.uavps_task_status"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </el-form-item>
- <el-form-item label="开始时间" prop="startTime">
- <el-date-picker
- clearable
- v-model="queryParams.startTime"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="请选择开始时间"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item label="结束时间" prop="endTime">
- <el-date-picker
- clearable
- v-model="queryParams.endTime"
- type="date"
- value-format="yyyy-MM-dd"
- placeholder="请选择结束时间"
- >
- </el-date-picker>
- </el-form-item>
- <el-form-item label="创建时间">
- <el-date-picker
- v-model="daterangeCreateTime"
- style="width: 240px"
- value-format="yyyy-MM-dd"
- type="daterange"
- range-separator="-"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- ></el-date-picker>
- </el-form-item>
- <el-form-item>
- <el-button
- type="primary"
- icon="el-icon-search"
- size="mini"
- @click="handleQuery"
- >搜索</el-button
- >
- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
- >重置</el-button
- >
- </el-form-item>
- </el-form>
- <el-row :gutter="10" class="mb8">
- <el-col :span="1.5">
- <el-button
- type="primary"
- plain
- icon="el-icon-plus"
- size="mini"
- @click="handleAdd"
- v-hasPermi="['system:task:add']"
- >新增</el-button
- >
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="success"
- plain
- icon="el-icon-edit"
- size="mini"
- :disabled="single"
- @click="handleUpdate"
- v-hasPermi="['system:task:edit']"
- >修改</el-button
- >
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="danger"
- plain
- icon="el-icon-delete"
- size="mini"
- :disabled="multiple"
- @click="handleDelete"
- v-hasPermi="['system:task:remove']"
- >删除</el-button
- >
- </el-col>
- <el-col :span="1.5">
- <el-button
- type="warning"
- plain
- icon="el-icon-download"
- size="mini"
- @click="handleExport"
- v-hasPermi="['system:task:export']"
- >导出</el-button
- >
- </el-col>
- <right-toolbar
- :showSearch.sync="showSearch"
- @queryTable="getList"
- ></right-toolbar>
- </el-row>
- <el-table
- v-loading="loading"
- :data="taskList"
- @selection-change="handleSelectionChange"
- >
- <el-table-column type="selection" width="55" align="center" />
- <el-table-column label="业务ID" align="center" prop="bizId" />
- <el-table-column label="任务名称" align="center" prop="bizName" />
- <el-table-column label="状态" align="center" prop="status">
- <template slot-scope="scope">
- <dict-tag
- :options="dict.type.uavps_task_status"
- :value="scope.row.status"
- />
- </template>
- </el-table-column>
- <el-table-column
- label="开始时间"
- align="center"
- prop="startTime"
- width="180"
- >
- <template slot-scope="scope">
- <span>{{
- parseTime(scope.row.startTime, "{y}-{m}-{d} {h}:{m}:{s}")
- }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="结束时间"
- align="center"
- prop="endTime"
- width="180"
- >
- <template slot-scope="scope">
- <span>{{
- parseTime(scope.row.endTime, "{y}-{m}-{d} {h}:{m}:{s}")
- }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="创建时间"
- align="center"
- prop="createTime"
- width="180"
- >
- <template slot-scope="scope">
- <span>{{
- parseTime(scope.row.createTime, "{y}-{m}-{d} {h}:{m}:{s}")
- }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="更新时间"
- align="center"
- prop="updateTime"
- width="180"
- >
- <template slot-scope="scope">
- <span>{{
- parseTime(scope.row.updateTime, "{y}-{m}-{d} {h}:{m}:{s}")
- }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- align="center"
- class-name="small-padding fixed-width"
- >
- <template slot-scope="scope">
- <el-button
- v-hasPermi="['system:task:edit']"
- size="mini"
- type="text"
- icon="el-icon-s-operation"
- @click="handleRun(scope.row)"
- >运行</el-button
- >
- <el-button
- size="mini"
- type="text"
- icon="el-icon-view"
- @click="handlePlayback(scope.row)"
- v-hasPermi="['uavps:parameter:run']"
- :disabled="scope.row.status == '1'"
- >回放</el-button
- >
- <el-button
- size="mini"
- type="text"
- icon="el-icon-edit"
- @click="handleUpdate(scope.row)"
- v-hasPermi="['system:task:edit']"
- >修改</el-button
- >
- <el-button
- size="mini"
- type="text"
- icon="el-icon-delete"
- @click="handleDelete(scope.row)"
- v-hasPermi="['system:task:remove']"
- >删除</el-button
- >
- </template>
- </el-table-column>
- </el-table>
- <pagination
- v-show="total > 0"
- :total="total"
- :page.sync="queryParams.pageNum"
- :limit.sync="queryParams.pageSize"
- @pagination="getList"
- />
- <!-- 添加或修改算法任务对话框 -->
- <el-dialog
- :title="title"
- :visible.sync="open"
- width="75%"
- :close-on-click-modal="false"
- append-to-body
- :before-close="cancel"
- >
- <el-form
- ref="form"
- :inline="true"
- :model="form"
- :rules="rules"
- label-width="120px"
- >
- <el-row>
- <el-form-item label="任务名称" prop="bizName">
- <el-input v-model="form.bizName" placeholder="请输入任务名称" />
- </el-form-item>
- <el-form-item label="编队类型">
- <el-select
- v-model="form.multiTarget"
- @change="typeChange"
- placeholder="请选择"
- :disabled="form.multiTarget == '1' || title == '修改任务数据'"
- >
- <el-option
- v-for="item in formationTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- </el-row>
- <el-row>
- <el-form-item label="噪声类型">
- <el-select v-model="form.noiseType" placeholder="请选择">
- <el-option
- v-for="item in noiseTypeList"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="噪声方差" prop="noiseVariance">
- <el-input
- v-model="form.noiseVariance"
- placeholder="请输入噪声方差"
- />
- </el-form-item>
- <el-form-item label="噪声均值" prop="noiseMean">
- <el-input v-model="form.noiseMean" placeholder="请输入噪声均值" />
- </el-form-item>
- </el-row>
- <el-divider content-position="left">平台无人机</el-divider>
- <el-form-item label="经度" prop="platformUav.longitude">
- <el-input
- v-model="form.platformUav.longitude"
- placeholder="请输入经度"
- />
- </el-form-item>
- <el-form-item label="纬度" prop="platformUav.latitude">
- <el-input
- v-model="form.platformUav.latitude"
- placeholder="请输入纬度"
- />
- </el-form-item>
- <el-form-item label="海拔" prop="platformUav.altitude">
- <el-input
- v-model="form.platformUav.altitude"
- placeholder="请输入海拔"
- />
- </el-form-item>
- <el-form-item label="东向速度" prop="platformUav.eastSpeed">
- <el-input
- v-model="form.platformUav.eastSpeed"
- placeholder="请输入东向速度"
- />
- </el-form-item>
- <el-form-item label="北向速度" prop="platformUav.northSpeed">
- <el-input
- v-model="form.platformUav.northSpeed"
- placeholder="请输入北向速度"
- />
- </el-form-item>
- <el-form-item label="天向速度" prop="platformUav.skySpeed">
- <el-input
- v-model="form.platformUav.skySpeed"
- placeholder="请输入天向速度"
- />
- </el-form-item>
- <div v-if="form.multiTarget == '1'">
- <el-divider content-position="left">固定编队无人机</el-divider>
- <el-form-item
- label="飞机数量"
- prop="fixedMultiTargetFormation.targetTotal"
- >
- <el-input-number
- v-model="form.fixedMultiTargetFormation.targetTotal"
- :min="1"
- :max="50"
- label="请输入飞机数量"
- ></el-input-number>
- </el-form-item>
- <el-form-item label="经度" prop="fixedMultiTargetFormation.longitude">
- <el-input
- v-model="form.fixedMultiTargetFormation.longitude"
- placeholder="请输入经度"
- />
- </el-form-item>
- <el-form-item label="纬度" prop="fixedMultiTargetFormation.latitude">
- <el-input
- v-model="form.fixedMultiTargetFormation.latitude"
- placeholder="请输入纬度"
- />
- </el-form-item>
- <el-form-item label="海拔" prop="fixedMultiTargetFormation.altitude">
- <el-input
- v-model="form.fixedMultiTargetFormation.altitude"
- placeholder="请输入海拔"
- />
- </el-form-item>
- <el-form-item
- label="东向速度"
- prop="fixedMultiTargetFormation.eastSpeed"
- >
- <el-input
- v-model="form.fixedMultiTargetFormation.eastSpeed"
- placeholder="请输入东向速度"
- />
- </el-form-item>
- <el-form-item
- label="北向速度"
- prop="fixedMultiTargetFormation.northSpeed"
- >
- <el-input
- v-model="form.fixedMultiTargetFormation.northSpeed"
- placeholder="请输入北向速度"
- />
- </el-form-item>
- <el-form-item
- label="天向速度"
- prop="fixedMultiTargetFormation.skySpeed"
- >
- <el-input
- v-model="form.fixedMultiTargetFormation.skySpeed"
- placeholder="请输入天向速度"
- />
- </el-form-item>
- </div>
- <div v-show="form.multiTarget == '2'" style="width: 100%">
- <el-divider content-position="left">自定义编队无人机</el-divider>
- <div style="width: 100%">
- <el-form
- ref="canvasInfoFormRef"
- :inline="true"
- :model="canvasInfo"
- :rules="infoRules"
- class="demo-form-inline"
- :disabled="submitInfoFlag"
- v-show="this.title == '修改任务数据' ? false : true"
- >
- <el-form-item label="中心点-经度" prop="centerLongitude">
- <el-input
- v-model="canvasInfo.centerLongitude"
- placeholder="中心点-经度"
- ></el-input>
- </el-form-item>
- <el-form-item label="中心点-纬度" prop="centerLatitude">
- <el-input
- v-model="canvasInfo.centerLatitude"
- placeholder="中心点-纬度"
- ></el-input>
- </el-form-item>
- <el-form-item label="边长距离" prop="lengthKm">
- <el-input v-model="canvasInfo.lengthKm" placeholder="边长距离">
- <template slot="append">km</template>
- </el-input>
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="canvasInfoSubmit"
- >确 定</el-button
- >
- </el-form-item>
- </el-form>
- </div>
- <div
- style="
- width: 100%;
- height: 800px;
- display: flex;
- justify-content: space-evenly;
- "
- >
- <div
- ref="pixiCanvas"
- class="left"
- style="width: 800px; position: relative; height: 800px"
- >
- <div style="position: absolute; top: 5px; left: 5px">
- <span>经度:{{ nowlongitude }}</span
- ><br />
- <span>纬度:{{ nowlatitude }}</span>
- </div>
- </div>
- <div class="right" style="width: 25%; height: 800px">
- <el-divider content-position="left">编队信息</el-divider>
- <div style="overflow-y: scroll; width: 100%; height: 750px">
- <li
- v-for="(item, index) in formationInfoList"
- :key="index"
- @dblclick="editFormationInfo(item)"
- >
- <div style="cursor: pointer">
- <div>
- <span>编号: </span
- ><label>{{ item.number }}</label>
- </div>
- <div>
- <span>经度: </span
- ><label>{{ item.longitude }}</label>
- </div>
- <div>
- <span>纬度: </span
- ><label>{{ item.latitude }}</label>
- </div>
- <div>
- <span>海拔: </span
- ><label>{{ item.altitude }}</label>
- </div>
- <div>
- <span>东向速度: </span
- ><label>{{ item.eastSpeed }}(m/s)</label>
- </div>
- <div>
- <span>北向速度: </span
- ><label>{{ item.northSpeed }}(m/s)</label>
- </div>
- <div>
- <span>天向速度: </span
- ><label>{{ item.skySpeed }}(m/s)</label>
- </div>
- <div>
- <span>航线类型: </span
- ><label>{{ item.flightPathType }}(m/s)</label>
- </div>
- <div>
- <span>噪音: </span
- ><label>{{ item.positionNoise }}(m/s)</label>
- </div>
- </div>
- </li>
- </div>
- </div>
- </div>
- </div>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button type="primary" @click="submitForm">确 定</el-button>
- <el-button @click="cancel">取 消</el-button>
- </div>
- </el-dialog>
- <el-drawer
- title="设置参数"
- size="20%"
- :visible.sync="drawerOpen"
- direction="rtl"
- :before-close="drawerClose"
- :show-close="false"
- :wrapperClosable="false"
- >
- <div class="demo-drawer__content" style="width: 80%; margin-left: 20px">
- <el-form
- label-width="80px"
- ref="formationInfoRef"
- :rules="formationInfoRules"
- :model="formationInfoForm"
- >
- <el-form-item label="编号" prop="number">
- <el-input
- v-model="formationInfoForm.number"
- placeholder="请输入编号"
- :disabled="this.addOrUpdate == 'update'"
- />
- </el-form-item>
- <el-form-item label="经度" prop="longitude">
- <el-input
- v-model="formationInfoForm.longitude"
- oninput="value=value.replace(/[^\d.]/g,'')"
- placeholder="请输入经度"
- />
- </el-form-item>
- <el-form-item label="纬度" prop="latitude">
- <el-input
- v-model="formationInfoForm.latitude"
- oninput="value=value.replace(/[^\d.]/g,'')"
- placeholder="请输入纬度"
- />
- </el-form-item>
- <el-form-item label="海拔" prop="altitude">
- <el-input
- v-model="formationInfoForm.altitude"
- placeholder="请输入海拔"
- />
- </el-form-item>
- <el-form-item label="东向速度" prop="eastSpeed">
- <el-input
- v-model="formationInfoForm.eastSpeed"
- placeholder="请输入东向速度"
- >
- <template slot="append">m/s</template>
- </el-input>
- </el-form-item>
- <el-form-item label="北向速度" prop="northSpeed">
- <el-input
- v-model="formationInfoForm.northSpeed"
- placeholder="请输入北向速度"
- >
- <template slot="append">m/s</template>
- </el-input>
- </el-form-item>
- <el-form-item label="天向速度" prop="skySpeed">
- <el-input
- v-model="formationInfoForm.skySpeed"
- placeholder="请输入天向速度"
- >
- <template slot="append">m/s</template>
- </el-input>
- </el-form-item>
- <el-form-item label="航线类型" prop="flightPathType">
- <el-select
- v-model="formationInfoForm.flightPathType"
- placeholder="航线类型"
- >
- <el-option label="直线" value="直线"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="噪声" prop="positionNoise">
- <el-input
- v-model="formationInfoForm.positionNoise"
- placeholder="请输入噪声"
- />
- </el-form-item>
- </el-form>
- <div class="demo-drawer__footer">
- <el-button
- type="danger"
- :disabled="this.addOrUpdate == 'add'"
- @click="canvasInfoDel"
- >删 除</el-button
- >
- <el-button type="primary" @click="handleDrawerSubmit"
- >确 定</el-button
- >
- </div>
- <ul style="color: rgb(125 121 121)">
- <li>
- <span class="info">左上角:</span><br />
- 经度:{{ this.siJiaoInfo.leftTop.lng }}<br />
- 纬度:{{ this.siJiaoInfo.leftTop.lat }}
- </li>
- <li>
- <span class="info">右上角:</span><br />
- 经度:{{ this.siJiaoInfo.rightTop.lng }}<br />纬度:{{
- this.siJiaoInfo.rightTop.lat
- }}
- </li>
- <li>
- <span class="info">左下角:</span><br />
- 经度:{{ this.siJiaoInfo.leftBottom.lng }}<br />纬度:{{
- this.siJiaoInfo.leftBottom.lat
- }}
- </li>
- <li>
- <span class="info">右下角:</span><br />
- 经度:{{ this.siJiaoInfo.rightBottom.lng }}<br />纬度:{{
- this.siJiaoInfo.rightBottom.lat
- }}
- </li>
- </ul>
- </div>
- </el-drawer>
- <!-- 飞行轨迹展示对话框 -->
- <el-dialog
- :title="title"
- :visible.sync="showTrajectory"
- @opened="initTrajectory"
- :before-close="closeDialog"
- :fullscreen="true"
- append-to-body
- destroy-on-close
- :close-on-click-modal="false"
- >
- <div class="container">
- <div>
- <el-row type="flex" align="middle" style="height: 40px">
- <el-col :span="24">
- <el-button @click="handleCenter" type="primary">居中</el-button>
- <el-button
- v-if="!isUpdateView"
- @click="transFormation"
- type="warning"
- >转换队形</el-button
- >
- <el-button v-if="!isUpdateView" @click="endHandle" type="danger"
- >结束</el-button
- >
- <div class="distance">
- <el-select
- v-model="firstAir"
- @change="handleFirstAir"
- placeholder="请选择"
- >
- <el-option
- v-for="item in allSpriteInfo"
- :key="item.id"
- :label="item.label"
- :value="item.id"
- >
- </el-option>
- </el-select>
- --->
- <el-select
- v-model="secondAir"
- @change="handleSecondAir"
- placeholder="请选择"
- >
- <el-option
- v-for="item in allSpriteInfo"
- :key="item.id"
- :label="item.label"
- :value="item.id"
- >
- </el-option>
- </el-select>
- =
- <el-input
- placeholder="距离"
- v-model="airDistance"
- :disabled="true"
- style="width: 220px"
- >
- <template slot="append">m</template>
- </el-input>
- </div>
- <el-progress
- style="width: 600px; display: inline-block; margin-left: 20px"
- :text-inside="true"
- :stroke-width="26"
- v-if="isUpdateView"
- :percentage="percentage"
- ></el-progress>
- </el-col>
- </el-row>
- <el-row>
- <div ref="pixiContainer" class="pixi-container"></div>
- </el-row>
- </div>
- <div class="right-board">
- <div style="float: right">
- <el-link type="primary" @click="showConfig">显示配置</el-link>
- </div>
- <el-divider content-position="left">隐藏列表</el-divider>
- <div style="height: 30px">
- <div style="margin-left: 10px" v-if="hideList.length !== 0">
- <el-tag
- v-for="item in hideList"
- @click="showSprite(item)"
- style="cursor: pointer; margin-left: 5px"
- >{{ item }}</el-tag
- >
- </div>
- <div style="margin-left: 10px" v-else>暂无</div>
- </div>
- <el-divider content-position="left">平台无人机</el-divider>
- <div style="height: 190px; overflow: auto">
- <div v-if="configList.includes('经度')">
- <span>经度: </span
- ><label>{{ platformInfo.longitude }}</label>
- </div>
- <div v-if="configList.includes('纬度')">
- <span>纬度: </span
- ><label>{{ platformInfo.latitude }}</label>
- </div>
- <div v-if="configList.includes('海拔')">
- <span>海拔: </span
- ><label>{{ platformInfo.altitude }}m</label>
- </div>
- <div v-if="configList.includes('东向速度')">
- <span>东向速度: </span
- ><label>{{ platformInfo.eastSpeed }}m/s</label>
- </div>
- <div v-if="configList.includes('北向速度')">
- <span>北向速度: </span
- ><label>{{ platformInfo.northSpeed }}m/s</label>
- </div>
- <div v-if="configList.includes('天向速度')">
- <span>天向速度: </span
- ><label>{{ platformInfo.skySpeed }}m/s</label>
- </div>
- <div>
- <span>方位角: </span>
- <label>{{ platformInfo.azimuthAngle }}</label>
- </div>
- <div>
- <span>目标飞机: </span>
- <label>{{ platformInfo.targetAircraftNumber }}</label>
- </div>
- <div>
- <span>距离目标飞机距离: </span>
- <label>{{ platformInfo.distance }}m</label>
- </div>
- <div>
- <span>与目标飞机夹角: </span>
- <label>{{ platformInfo.bearing }}</label>
- </div>
- </div>
- <el-divider content-position="left">目标无人机群</el-divider>
- <div style="height: 480px; overflow: auto">
- <li v-for="(item, key) in targetLblAry" :key="key" class="item">
- <div
- v-if="!hideList.includes(item.id)"
- @click="showSprite(item.id)"
- style="cursor: pointer"
- >
- <div>
- <span>编号: </span><label>{{ item.id }}</label>
- <!-- <span style="margin-left: 10px" v-if="hideList.includes(item.id)"
- >( 隐 藏 )</span
- > -->
- </div>
- <div v-if="configList.includes('经度')">
- <span>经度: </span
- ><label>{{ item.longitude }}</label>
- </div>
- <div v-if="configList.includes('纬度')">
- <span>纬度: </span
- ><label>{{ item.latitude }}</label>
- </div>
- <div v-if="configList.includes('海拔')">
- <span>海拔: </span
- ><label>{{ item.altitude }}</label>
- </div>
- <div v-if="configList.includes('东向速度')">
- <span>东向速度: </span
- ><label>{{ item.eastSpeed }}</label>
- </div>
- <div v-if="configList.includes('北向速度')">
- <span>北向速度: </span
- ><label>{{ item.northSpeed }}</label>
- </div>
- <div v-if="configList.includes('天向速度')">
- <span>天向速度: </span
- ><label>{{ item.skySpeed }}</label>
- </div>
- </div>
- </li>
- </div>
- </div>
- </div>
- </el-dialog>
- <!-- 显示配置对话框 -->
- <el-dialog
- title="显示配置"
- :close-on-click-modal="false"
- :visible.sync="showConfigVisible"
- width="30%"
- >
- <el-checkbox-group
- v-model="showConfigList"
- style="display: flex; flex-direction: column"
- >
- <el-checkbox
- v-for="item in configData"
- :label="item.label"
- ></el-checkbox>
- </el-checkbox-group>
- <span slot="footer" class="dialog-footer">
- <el-button @click="showConfigVisible = false">取 消</el-button>
- <el-button type="primary" @click="selectConfigSubmit">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import {
- listTask,
- getTask,
- delTask,
- addTask,
- updateTask,
- } from "@/api/system/task";
- import * as PIXI from "pixi.js";
- import platformPNG from "../../textures/platform.png";
- import uavTarPNG from "../../textures/uav-tar.png";
- export default {
- name: "Task",
- dicts: [
- "uavps_task_status",
- "uavps_target_formation_type",
- "uavps_task_nose_type",
- ],
- data() {
- return {
- // 遮罩层
- loading: true,
- // 选中数组
- ids: [],
- // 非单个禁用
- single: true,
- // 非多个禁用
- multiple: true,
- // 显示搜索条件
- showSearch: true,
- // 总条数
- total: 0,
- // 任务数据表格数据
- taskList: [],
- // 弹出层标题
- title: "",
- // 是否显示弹出层
- open: false,
- // 噪声数据文件路径时间范围
- daterangeCreateTime: [],
- // 查询参数
- queryParams: {
- pageNum: 1,
- pageSize: 10,
- bizName: null,
- status: null,
- startTime: null,
- endTime: null,
- createTime: null,
- },
- // 表单参数
- form: {
- platformUav: {},
- fixedMultiTargetFormation: {},
- },
- // 表单校验
- rules: {
- bizName: [
- { required: true, message: "任务名称不能为空", trigger: "blur" },
- ],
- multiTarget: [
- {
- required: true,
- message: "编队类型不能为空",
- trigger: "change",
- },
- ],
- noiseType: [
- {
- required: true,
- message: "噪声类型不能为空",
- trigger: "change",
- },
- ],
- noiseVariance: [
- { required: true, message: "噪声方差不能为空", trigger: "blur" },
- ],
- noiseMean: [
- { required: true, message: "噪声均值不能为空", trigger: "blur" },
- ],
- "platformUav.longitude": [
- {
- required: true,
- message: "平台无人机经度不能为空",
- trigger: "blur",
- },
- ],
- "platformUav.latitude": [
- {
- required: true,
- message: "平台无人机纬度不能为空",
- trigger: "blur",
- },
- ],
- "platformUav.altitude": [
- {
- required: true,
- message: "平台无人机海拔不能为空",
- trigger: "blur",
- },
- ],
- "platformUav.eastSpeed": [
- {
- required: true,
- message: "平台无人机东向速度不能为空",
- trigger: "blur",
- },
- ],
- "platformUav.northSpeed": [
- {
- required: true,
- message: "平台无人机北向速度不能为空",
- trigger: "blur",
- },
- ],
- "platformUav.skySpeed": [
- {
- required: true,
- message: "平台无人机天向速度不能为空",
- trigger: "blur",
- },
- ],
- "fixedMultiTargetFormation.targetTotal": [
- {
- required: true,
- message: "固定编队无人机飞机数量不能为空",
- trigger: "blur",
- },
- ],
- "fixedMultiTargetFormation.longitude": [
- {
- required: true,
- message: "固定编队无人机经度不能为空",
- trigger: "blur",
- },
- ],
- "fixedMultiTargetFormation.latitude": [
- {
- required: true,
- message: "固定编队无人机纬度不能为空",
- trigger: "blur",
- },
- ],
- "fixedMultiTargetFormation.altitude": [
- {
- required: true,
- message: "固定编队无人机海拔不能为空",
- trigger: "blur",
- },
- ],
- "fixedMultiTargetFormation.eastSpeed": [
- {
- required: true,
- message: "固定编队无人机东向速度不能为空",
- trigger: "blur",
- },
- ],
- "fixedMultiTargetFormation.northSpeed": [
- {
- required: true,
- message: "固定编队无人机北向速度不能为空",
- trigger: "blur",
- },
- ],
- "fixedMultiTargetFormation.skySpeed": [
- {
- required: true,
- message: "固定编队无人机天向速度不能为空",
- trigger: "blur",
- },
- ],
- },
- infoRules: {
- centerLongitude: [
- { required: true, message: "经度不能为空", trigger: "blur" },
- ],
- centerLatitude: [
- { required: true, message: "纬度不能为空", trigger: "blur" },
- ],
- lengthKm: [
- { required: true, message: "边长距离不能为空", trigger: "blur" },
- ],
- },
- formationInfoRules: {
- number: [{ required: true, message: "编号不能为空", trigger: "blur" }],
- longitude: [
- { required: true, message: "经度不能为空", trigger: "blur" },
- ],
- latitude: [
- { required: true, message: "纬度不能为空", trigger: "blur" },
- ],
- altitude: [
- { required: true, message: "海拔不能为空", trigger: "blur" },
- ],
- eastSpeed: [
- { required: true, message: "东向速度不能为空", trigger: "blur" },
- ],
- northSpeed: [
- { required: true, message: "北向速度不能为空", trigger: "blur" },
- ],
- skySpeed: [
- { required: true, message: "天向速度不能为空", trigger: "blur" },
- ],
- flightPathType: [
- { required: true, message: "航线类型不能为空", trigger: "change" },
- ],
- positionNoise: [
- { required: true, message: "噪音不能为空", trigger: "blur" },
- ],
- },
- parameterId: 0,
- // 是否显示轨迹
- showTrajectory: false,
- pixiApp: null,
- container: null,
- webSocket: null,
- curLongitude: null,
- curLatitude: null,
- curAltitude: null,
- targetTotal: null,
- formationTypeList: [
- {
- value: "1",
- label: "固定编队",
- },
- {
- value: "2",
- label: "自由编队",
- },
- ],
- noiseTypeList: [
- {
- value: "1",
- label: "高斯",
- },
- {
- value: "2",
- label: "瑞利",
- },
- ],
- // 自定义编队信息
- formationInfoList: [],
- formationInfoForm: {
- number: null,
- longitude: null,
- latitude: null,
- altitude: null,
- eastSpeed: null,
- northSpeed: null,
- skySpeed: null,
- flightPathType: "直线",
- positionNoise: null,
- },
- // 判断填写的编队信息是新增加的还是修改之前的
- addOrUpdate: "add",
- // 自定义编队的飞机信息集合
- formationInfoAirDataList: [],
- // 编辑编队信息的
- formationAirPiXiApp: null,
- // 设定的画布信息
- canvasInfo: {
- centerLongitude: null,
- centerLatitude: null,
- lengthKm: null,
- },
- // 编辑编队信息的画布
- pixiCanvas: null,
- // 是否提交了编队信息
- submitInfoFlag: false,
- // 鼠标当前的经纬度
- nowlongitude: null,
- nowlatitude: null,
- targetDataR: {},
- targetDataN: {},
- platformData: [],
- // 真实路径的集合
- pathGraphicsList: {},
- pathGraphicsPointList: {},
- isUpdateView: false, // 是否开启实现追踪,在回放时开启
- percentage: 0,
- // 多久更新一次轨迹
- updatePathFlag: 75,
- cycleCount: 0, // 循环计数
- updatePlatformPathFlag: 75,
- platformCycleCount: 0,
- showConfigVisible: false, //显示配置dialog
- showConfigList: [], // 选择要显示的值
- configList: ["经度", "纬度", "海拔", "东向速度", "北向速度", "天向速度"], // 显示的值
- configData: [
- // 可选择的值
- { key: "longitude", label: "经度" },
- { key: "latitude", label: "纬度" },
- { key: "altitude", label: "海拔" },
- { key: "eastSpeed", label: "东向速度" },
- { key: "northSpeed", label: "北向速度" },
- { key: "skySpeed", label: "天向速度" },
- ],
- hideList: [], // 当下隐藏的飞机数组
- allId: [], // 所有飞机的id
- changeNoList: [], // 需要改变的飞机编号,放有id和应该显示的编号
- targetLblAry: {},
- targetUavAry: [],
- targetUavCircleR: {},
- targetUavCircleN: {},
- targetUavCircleNumR: {},
- targetUavCircleNumN: {},
- drawerOpen: false,
- platformSprite: null, // 平台无人机
- // 平台无人机显示的数据
- platformInfo: {},
- platformPathData: {}, //平台无人机位置
- platformGraphics: null, //平台无人机轨迹
- playbackTime: null, // 回放的时间
- isClickGroup: false, // 是否点击了飞机,在计算两飞机距离时使用
- firstLng: null, // 第一次点击的飞机的经纬度
- firstLat: null,
- airDistance: null, // 两点间距离
- allSpriteInfo: [], // 所有飞机的信息
- firstAir: "",
- secondAir: "",
- siJiaoInfo: {
- leftTop: {},
- rightTop: {},
- leftBottom: {},
- rightBottom: {},
- }, // 自定义画布四个角的经纬度信息
- trackGraphicsLine: null,
- };
- },
- created() {
- this.getList();
- },
- methods: {
- /** 查询任务数据列表 */
- getList() {
- this.loading = true;
- this.queryParams.params = {};
- if (null != this.daterangeCreateTime && "" != this.daterangeCreateTime) {
- this.queryParams.params["beginCreateTime"] =
- this.daterangeCreateTime[0];
- this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
- }
- listTask(this.queryParams).then((response) => {
- this.taskList = response.rows;
- this.total = response.total;
- this.loading = false;
- });
- },
- // 取消按钮
- cancel() {
- this.open = false;
- this.reset();
- this.closeUpdataDialog();
- },
- // 表单重置
- reset() {
- this.form = {
- bizId: null,
- bizName: null,
- bizType: null,
- multiTarget: null,
- noiseType: null,
- noiseVariance: null,
- noiseMean: null,
- platformUav: {},
- fixedMultiTargetFormation: {},
- customizedMultiTargetFormation: null,
- status: null,
- startTime: null,
- endTime: null,
- filePath: null,
- createBy: null,
- createTime: null,
- updateBy: null,
- updateTime: null,
- };
- this.siJiaoInfo = {
- leftTop: {},
- rightTop: {},
- leftBottom: {},
- rightBottom: {},
- };
- this.resetForm("form");
- },
- /** 搜索按钮操作 */
- handleQuery() {
- this.queryParams.pageNum = 1;
- this.getList();
- },
- /** 重置按钮操作 */
- resetQuery() {
- this.daterangeCreateTime = [];
- this.resetForm("queryForm");
- this.handleQuery();
- },
- // 多选框选中数据
- handleSelectionChange(selection) {
- this.ids = selection.map((item) => item.bizId);
- this.single = selection.length !== 1;
- this.multiple = !selection.length;
- },
- /** 新增按钮操作 */
- handleAdd() {
- this.reset();
- this.open = true;
- this.title = "添加任务数据";
- },
- /** 修改按钮操作 */
- handleUpdate(row) {
- this.reset();
- const bizId = row.bizId || this.ids;
- getTask(bizId).then((response) => {
- this.form = response.data;
- if (this.form.multiTarget == "2") {
- const info = this.form.customizedMultiTargetFormation[0];
- this.formationInfoList = this.form.customizedMultiTargetFormation;
- //自由编队
- this.$nextTick(() => {
- this.initFormationApp();
- this.canvasInfo = {
- centerLongitude: info.longitude,
- centerLatitude: info.latitude,
- lengthKm: 20,
- };
- this.airPosShow(
- this.form.customizedMultiTargetFormation,
- "fixedWing"
- );
- const leftTop = this.calculateLatLng(0, 800);
- const rightTop = this.calculateLatLng(800, 0);
- const leftBottom = this.calculateLatLng(0, 800);
- const rightBottom = this.calculateLatLng(800, 800);
- this.siJiaoInfo = { leftTop, rightTop, leftBottom, rightBottom };
- this.addAirSprite();
- });
- }
- this.title = "修改任务数据";
- this.open = true;
- });
- },
- // 根据后端返回的自定义编队信息,显示飞机位置
- airPosShow(info, type) {
- let texture = new PIXI.Texture.from(uavTarPNG);
- info.forEach((item) => {
- const { x, y } = this.calculateXY(item.longitude, item.latitude);
- const sprite = new PIXI.Sprite(texture); // 示例飞机图标
- sprite.anchor.set(0.5, 0.5);
- sprite.scale.set(0.04);
- sprite.x = x;
- sprite.y = y;
- sprite.id = item.number;
- this.formationAirPiXiApp.stage.addChild(sprite);
- });
- },
- calculateXY(longitude, latitude) {
- // 计算每像素对应的实际距离
- const kmPerPixel = this.canvasInfo.lengthKm / this.pixiCanvas.clientWidth;
- // 经纬度差值转实际距离
- const deltaY = (latitude - this.canvasInfo.centerLatitude) * 111;
- const deltaX =
- (longitude - this.canvasInfo.centerLongitude) *
- 111 *
- Math.cos((this.canvasInfo.centerLatitude * Math.PI) / 180);
- // 实际距离转像素偏移量
- const offsetX = deltaX / kmPerPixel;
- const offsetY = deltaY / kmPerPixel;
- // 像素坐标
- const x = this.pixiCanvas.clientWidth / 2 + offsetX;
- const y = this.pixiCanvas.clientHeight / 2 - offsetY;
- return { x, y };
- },
- // 选择第一个飞机
- handleFirstAir(val) {
- this.secondAir = null;
- },
- // 选择第二个飞机
- handleSecondAir(val) {
- let firstLng, firstLat, secondLng, secondLat;
- if (this.firstAir == 100001) {
- firstLng = this.platformInfo.longitude;
- firstLat = this.platformInfo.latitude;
- } else {
- firstLng = this.targetLblAry[`${this.firstAir}`].longitude;
- firstLat = this.targetLblAry[`${this.firstAir}`].latitude;
- }
- if (this.secondAir == 100001) {
- secondLng = this.platformInfo.longitude;
- secondLat = this.platformInfo.latitude;
- } else {
- secondLng = this.targetLblAry[`${val}`].longitude;
- secondLat = this.targetLblAry[`${val}`].latitude;
- }
- this.airDistance = this.calculateDistance(
- firstLat,
- firstLng,
- secondLat,
- secondLng
- );
- },
- /** 提交按钮 */
- submitForm() {
- this.$refs["form"].validate((valid) => {
- if (valid) {
- if (this.form.multiTarget == "2") {
- this.form.customizedMultiTargetFormation = this.formationInfoList;
- }
- if (this.form.bizId != null) {
- updateTask(this.form).then((response) => {
- this.$modal.msgSuccess("修改成功");
- this.open = false;
- this.closeUpdataDialog();
- this.getList();
- });
- } else {
- addTask(this.form).then((response) => {
- this.$modal.msgSuccess("新增成功");
- this.open = false;
- this.closeUpdataDialog();
- this.getList();
- });
- }
- }
- });
- },
- /** 删除按钮操作 */
- handleDelete(row) {
- const bizIds = row.bizId || this.ids;
- this.$modal
- .confirm('是否确认删除任务数据编号为"' + bizIds + '"的数据项?')
- .then(function () {
- return delTask(bizIds);
- })
- .then(() => {
- this.getList();
- this.$modal.msgSuccess("删除成功");
- })
- .catch(() => {});
- },
- /** 导出按钮操作 */
- handleExport() {
- this.download(
- "system/task/export",
- {
- ...this.queryParams,
- },
- `task_${new Date().getTime()}.xlsx`
- );
- },
- showConfig() {
- this.showConfigList = this.configList;
- this.showConfigVisible = true;
- },
- selectConfigSubmit() {
- this.configList = this.showConfigList;
- this.showConfigVisible = false;
- },
- // 选择编队类型
- typeChange(val) {
- if (val == "2") {
- this.$nextTick(() => {
- this.$message.warning(`请先输入画布信息!`);
- this.initFormationApp();
- });
- }
- },
- handleRun(row) {
- this.parameterId = row.bizId || this.ids;
- this.showTrajectory = true;
- this.title = "飞行轨迹";
- },
- handlePlayback(row) {
- this.parameterId = row.bizId || this.ids;
- this.playbackTime = row.totalDuration;
- this.showTrajectory = true;
- this.isUpdateView = true;
- this.title = "回放";
- },
- initWebSocket() {
- const wsUri = "ws://127.0.0.1:8080/websocket/message";
- this.webSocket = new WebSocket(wsUri);
- const self = this;
- this.webSocket.onopen = function (event) {
- if (self.title == "回放") {
- self.webSocket.send("REPLAY:" + self.parameterId);
- } else {
- self.webSocket.send("RUN:" + self.parameterId);
- }
- console.log("WebSocket连接成功!");
- };
- this.webSocket.onmessage = function (event) {
- self.processMessage(JSON.parse(event.data));
- };
- this.webSocket.onclose = function (event) {
- console.log("WebSocket连接断开!");
- };
- this.webSocket.onerror = function (event) {
- console.log(
- "WebSocket连接异常: " +
- event.code +
- " " +
- event.reason +
- " " +
- event.wasClean
- );
- };
- },
- transFormation() {
- let msg = "TRANSFORMATION:" + this.parameterId;
- console.info("transFormation", msg);
- this.webSocket.send(msg);
- },
- endHandle() {
- let msg = "END:" + this.parameterId;
- this.webSocket.send(msg);
- this.getList();
- this.showTrajectory = false;
- },
- // 居中
- handleCenter() {
- const firstKey = Object.keys(this.targetDataR)[0];
- // 获取到第一个飞机的位置
- const posX = this.targetDataR[`${firstKey}`].x;
- const posY = this.targetDataR[`${firstKey}`].y;
- // 获取画布的中心点的位置
- const centerX = this.container.clientWidth / 2;
- const centerY = this.container.clientHeight / 2;
- // 缩放的值
- const scaleX = this.pixiApp.stage.scale.x || 1;
- const scaleY = this.pixiApp.stage.scale.y || 1;
- // 计算需要移动的距离
- const offsetX = centerX - posX * scaleX;
- const offsetY = centerY - posY * scaleY;
- this.pixiApp.stage.position.set(offsetX, offsetY);
- },
- // 销毁画布信息
- destroyTrajectory() {
- if (this.webSocket) {
- this.webSocket.close();
- }
- if (this.pixiApp) {
- // 移除并销毁所有子对象
- const removedChildren = this.pixiApp.stage.removeChildren(
- 0,
- this.pixiApp.stage.children.length
- );
- removedChildren.forEach((child) => {
- child.destroy({
- children: true,
- texture: false,
- baseTexture: false,
- });
- });
- this.pixiApp.stage.removeChildren();
- this.pixiApp.renderer.clear();
- this.pixiApp.destroy(true);
- this.pixiApp = null;
- }
- if (this.platformGraphics && this.platformGraphics.length) {
- if (this.platformGraphics.parent) {
- this.platformGraphics.parent.removeChild(this.platformGraphics);
- }
- this.platformGraphics.clear();
- this.platformGraphics.destroy(true);
- this.platformGraphics = null;
- }
- if (this.trackGraphicsLine && this.trackGraphicsLine.length) {
- if (this.trackGraphicsLine.parent) {
- this.trackGraphicsLine.parent.removeChild(this.trackGraphicsLine);
- }
- this.trackGraphicsLine.clear();
- this.trackGraphicsLine.destroy(true);
- this.trackGraphicsLine = null;
- }
- this.clearAllAry();
- },
- initTrajectory() {
- // this.clearAllAry();
- this.initPixi();
- this.initWebSocket();
- },
- // 处理WebSocket消息
- processMessage(data) {
- if (this.title == "回放") {
- this.percentage = Math.ceil((data.time / this.playbackTime) * 100);
- }
- // type:1平台无人机、2真实目标、3噪声目标
- switch (data.type) {
- case "1": //平台无人机
- this.showPlatformAir(data);
- break;
- case "2": //真实目标 R真实数据
- this.showTargetRAircraft(data, "R");
- break;
- case "3": //噪声目标 N噪声数据
- this.showTargetNAircraft(data, "N");
- break;
- default:
- break;
- }
- },
- initPixi() {
- this.container = this.$refs.pixiContainer;
- if (!this.container) return;
- // 创建Pixi应用
- this.pixiApp = new PIXI.Application({
- width: this.container.clientWidth,
- height: this.container.clientHeight,
- antialias: true,
- transparent: false,
- resolution: 1,
- backgroundAlpha: 0,
- });
- this.pixiApp.renderer.backgroundColor = 0x66ccff;
- this.container.appendChild(this.pixiApp.view);
- // 添加视窗控制
- this.enableViewControl(this.pixiApp);
- // 增加追踪线
- this.trackGraphicsLine = new PIXI.Graphics();
- this.trackGraphicsLine.lineStyle(1, 0xf5f7fa, 1);
- this.pixiApp.stage.addChild(this.trackGraphicsLine);
- },
- // 平台无人机展示
- showPlatformAir(platformData) {
- const data = platformData.platformAircraft;
- if (this.platformData.length == 0) {
- const platformTexture = new PIXI.Texture.from(platformPNG);
- this.platformSprite = new PIXI.Sprite(platformTexture);
- this.platformSprite.anchor.set(0.5, 0.5);
- this.platformSprite.scale.set(0.1);
- this.platformSprite.buttonMode = true; // 鼠标悬停时显示手型
- this.platformSprite.interactive = true;
- this.platformSprite.x = data.coordinateX;
- this.platformSprite.y = data.coordinateY;
- const label = "平台无人机";
- this.allSpriteInfo.push({
- id: 100001,
- label,
- });
- this.platformData.push(this.platformSprite);
- this.pixiApp.stage.addChild(this.platformSprite);
- // 创建路径
- this.platformGraphics = new PIXI.Graphics();
- this.platformGraphics.lineStyle(1, 0x00ee00, 1);
- const point = { x: this.platformSprite.x, y: this.platformSprite.y };
- this.platformPathData = point;
- this.platformInfo = data;
- this.pixiApp.stage.addChild(this.platformGraphics);
- } else {
- this.platformSprite.x = data.coordinateX;
- this.platformSprite.y = data.coordinateY;
- this.platformSprite.rotation = data.azimuthAngle * (Math.PI / 180);
- // this.platformSprite.rotation = Math.atan2(
- // data.northSpeed,
- // data.eastSpeed
- // );
- // this.platformInfo = data;
- Object.assign(this.platformInfo, data);
- if (this.platformCycleCount % this.updatePlatformPathFlag == 0) {
- // 更新路径绘制
- this.updatePlatformPath(this.platformSprite.x, this.platformSprite.y);
- }
- }
- this.platformCycleCount++;
- },
- // 无人机集群 真实数据
- showTargetRAircraft(data) {
- const targetData = data.targetAircraft[0];
- this.targetTotal = targetData.aircrafts.length;
- let empty = Object.keys(this.targetDataR);
- // 还没有真实数据时,先初始化数据。
- if (empty.length == 0) {
- for (let i = 0; i < this.targetTotal; i++) {
- const label = "目标无人机" + targetData.aircrafts[i].aircraftNumber;
- this.allSpriteInfo.push({
- id: targetData.aircrafts[i].aircraftNumber,
- label,
- });
- this.allId.push(targetData.aircrafts[i].aircraftNumber);
- // (飞机相关数据,,是否为真实数据)
- this.addAir(targetData.aircrafts[i], true);
- // 绑定鼠标事件,飞机隐藏
- // group.on("pointerdown", () => {
- // this.hideSprite(group.id);
- // });
- }
- } else {
- // 每次更新
- const newData = data.targetAircraft[0].aircrafts;
- let isHide = false,
- targetDataKeys,
- flagCount = 0;
- if (this.title == "回放") {
- targetDataKeys = Object.keys(this.targetDataR);
- const count = targetDataKeys.length;
- // 当存的数据大于返回数据时,证明有数据隐藏
- if (count > newData.length) {
- isHide = true;
- }
- }
- for (let i = 0; i < newData.length; i++) {
- const id = newData[i].aircraftNumber;
- const targetUav = this.targetDataR[`${id}`];
- if (this.title == "回放" && isHide) {
- targetDataKeys.splice(
- targetDataKeys.findIndex((item) => item === id),
- 1
- );
- flagCount++;
- if (flagCount == newData.length) {
- this.delHideAir(targetDataKeys);
- }
- }
- if (targetUav) {
- targetUav.x = newData[i].coordinateX;
- targetUav.y = newData[i].coordinateY;
- const eastSpeed = newData[i].eastSpeed;
- const northSpeed = newData[i].northSpeed;
- targetUav.rotation = Math.atan2(northSpeed, eastSpeed);
- const cx = targetUav.x - 10;
- const cy = targetUav.y - 6;
- const circle = this.targetUavCircleR[`${id}`];
- circle.x = cx;
- circle.y = cy;
- const text = this.targetUavCircleNumR[`${id}`];
- text.x = cx;
- text.y = cy;
- if (this.platformInfo.targetAircraftNumber == id) {
- this.trackGraphicsLine.clear();
- this.trackGraphicsLine.lineStyle(1, 0xf5f7fa, 1);
- const returnData = this.calculateRelativePosition(
- this.platformInfo.latitude,
- this.platformInfo.longitude,
- 0,
- newData[i].latitude,
- newData[i].longitude,
- 0
- );
- this.platformInfo.distance = Number(
- returnData.distance.toFixed()
- );
- this.platformInfo.bearing = Number(returnData.bearing.toFixed(2));
- this.trackGraphicsLine.moveTo(
- this.platformInfo.coordinateX,
- this.platformInfo.coordinateY
- );
- this.trackGraphicsLine.lineTo(
- newData[i].coordinateX,
- newData[i].coordinateY
- );
- }
- } else {
- this.addAir(newData[i], true);
- const label = "目标无人机" + newData[i].aircraftNumber;
- this.allSpriteInfo.push({
- id: targetData.aircrafts[i].aircraftNumber,
- label,
- });
- }
- if (targetUav && this.cycleCount % this.updatePathFlag == 0) {
- // 更新路径绘制
- this.updatePath(id, targetUav.x, targetUav.y);
- }
- if (this.isUpdateView && i == 0) {
- const viewSprite = this.pixiApp.stage.children.find((item) => {
- return (
- item.id == data.targetAircraft[0].aircrafts[0].aircraftNumber
- );
- });
- // 获取精灵的边界
- const spriteBounds = viewSprite.getBounds();
- // 检测是否移出画布
- if (spriteBounds.left < 0) {
- // 触碰到了左边界
- this.pixiApp.stage.x += this.container.clientWidth / 2;
- } else if (spriteBounds.right > this.container.clientWidth) {
- // 触碰到了右边
- this.pixiApp.stage.x -= this.container.clientWidth / 2;
- } else if (spriteBounds.top < 0) {
- // 触碰到了上边
- this.pixiApp.stage.y += this.container.clientHeight / 2;
- } else if (spriteBounds.bottom > this.container.clientHeight) {
- // 触碰到了下边
- this.pixiApp.stage.y -= this.container.clientHeight / 2;
- }
- }
- this.cycleCount++;
- }
- if (data.targetAircraft != null) {
- for (let i = 0; i < this.targetTotal; i++) {
- const id = targetData.aircrafts[i].aircraftNumber;
- let index = this.changeNoList.findIndex(
- (item) => item.changeNo == id
- );
- // 多目标集群信息显示
- const lbl = {
- id: id,
- longitude: targetData.aircrafts[i].longitude.toFixed(7),
- latitude: targetData.aircrafts[i].latitude.toFixed(7),
- altitude: targetData.aircrafts[i].altitude + " m",
- eastSpeed: targetData.aircrafts[i].eastSpeed.toFixed(1) + " m/s",
- northSpeed:
- targetData.aircrafts[i].northSpeed.toFixed(1) + " m/s",
- skySpeed: targetData.aircrafts[i].skySpeed.toFixed(1) + " m/s",
- };
- if (index !== -1) {
- const findItem = this.changeNoList[index];
- for (const key in this.targetLblAry) {
- if (this.targetLblAry.hasOwnProperty(key)) {
- if (key === findItem.id) {
- delete this.targetLblAry[key];
- // 插入新属性和值
- this.targetLblAry[findItem.changeNo] = lbl;
- this.changeNoList.splice(index, 1);
- }
- }
- }
- }
- this.targetLblAry[`${id}`] = lbl;
- // if (this.targetLblAry.length === 0) {
- // this.targetLblAry.push(lbl);
- // } else {
- // this.targetLblAry.splice(i, 1, lbl);
- // }
- }
- }
- }
- },
- // 新建一个飞机
- addAir(data, isZhen) {
- const targetTexture = new PIXI.Texture.from(uavTarPNG);
- const group = new PIXI.Container();
- group.id = data.aircraftNumber;
- // 创建无人机
- const dude = new PIXI.Sprite(targetTexture);
- dude.anchor.set(0.5, 0.5);
- dude.scale.set(0.01);
- dude.x = data.coordinateX;
- dude.y = data.coordinateY;
- dude.id = data.aircraftNumber;
- const id = dude.id + "";
- group.addChild(dude);
- // 创建圆圈 圆圈相对于飞机的位置
- const cx = dude.x - 10;
- const cy = dude.y - 6;
- //编号-圆圈
- const circle = new PIXI.Graphics();
- circle.beginFill(0xff0000); // 红色
- circle.drawCircle(0, 0, 8);
- circle.endFill();
- circle.x = cx;
- circle.y = cy;
- circle.scale.set(0.4);
- group.addChild(circle);
- //编号-数字
- const text = new PIXI.Text(data.aircraftNumber, {
- fontFamily: "Arial",
- fontSize: 12,
- fill: 0xffffff,
- align: "center",
- });
- text.anchor.set(0.5);
- // 计算文字位置以便在圆形内居中
- text.x = cx;
- text.y = cy;
- text.scale.set(0.4);
- group.addChild(text);
- if (isZhen) {
- group.typeName = "zhenshi";
- group.buttonMode = true; // 鼠标悬停时显示手型
- group.interactive = true;
- this.targetDataR[`${id}`] = dude;
- this.targetUavCircleR[`${id}`] = circle;
- this.targetUavCircleNumR[`${id}`] = text;
- } else {
- dude.alpha = 0.5;
- circle.alpha = 0.5;
- text.alpha = 0.5;
- this.targetDataN[`${id}`] = dude;
- this.targetUavCircleN[`${id}`] = circle;
- this.targetUavCircleNumN[`${id}`] = text;
- }
- this.pixiApp.stage.addChild(group);
- // 真实数据创建路径
- if (isZhen) {
- const pathGraphics = new PIXI.Graphics();
- pathGraphics.lineStyle(1, 0xeeee00, 1);
- const point = { x: dude.x, y: dude.y };
- pathGraphics.id = data.aircraftNumber;
- this.pathGraphicsPointList[`${id}`] = point;
- this.pathGraphicsList[`${id}`] = pathGraphics;
- this.pixiApp.stage.addChild(pathGraphics);
- }
- },
- // 删除回放时隐藏的飞机
- delHideAir(targetDataKeys) {
- const hideId = targetDataKeys[0];
- let group = [];
- this.pixiApp.stage.children.forEach((child) => {
- // 检查 child 是否是 Container 类型
- if (child instanceof PIXI.Container) {
- if (child.id == hideId) {
- group.push(child);
- }
- }
- });
- group.forEach((child) => {
- if (!(child instanceof PIXI.Graphics)) {
- if (child.parent) {
- child.parent.removeChild(child);
- }
- child.destroy();
- if (this.targetDataR[hideId]) {
- delete this.targetDataR[hideId];
- }
- if (this.targetLblAry[hideId]) {
- delete this.targetLblAry[hideId];
- }
- const idx = this.allSpriteInfo.findIndex((info) => {
- return info.id == hideId;
- });
- if (idx > -1) {
- this.allSpriteInfo.splice(idx, 1);
- }
- }
- });
- },
- // 无人机集群 噪音数据
- showTargetNAircraft(data) {
- const targetData = data.targetAircraft[0];
- // this.targetTotal = targetData.aircrafts.length;
- const targetTotal = targetData.aircrafts.length;
- let empty = Object.keys(this.targetDataN);
- // 还没有数据时,先初始化数据。
- if (empty.length == 0) {
- for (let i = 0; i < targetTotal; i++) {
- this.addAir(targetData.aircrafts[i], false);
- }
- } else {
- // 每次更新
- const newData = data.targetAircraft[0].aircrafts;
- let isHide = false,
- targetDataKeys,
- flagCount = 0;
- if (this.title == "回放") {
- targetDataKeys = Object.keys(this.targetDataR);
- const count = targetDataKeys.length;
- // 当存的数据大于返回数据时,证明有数据隐藏
- if (count > newData.length) {
- isHide = true;
- }
- }
- for (let i = 0; i < newData.length; i++) {
- const id = newData[i].aircraftNumber;
- const targetUav = this.targetDataN[`${id}`];
- // 有隐藏的话要删除飞机
- if (this.title == "回放" && isHide) {
- targetDataKeys.splice(
- targetDataKeys.findIndex((item) => item === id),
- 1
- );
- flagCount++;
- if (flagCount == newData.length) {
- this.delHideAir(targetDataKeys);
- }
- }
- if (targetUav) {
- targetUav.x = newData[i].coordinateX;
- targetUav.y = newData[i].coordinateY;
- const eastSpeed = newData[i].eastSpeed;
- const northSpeed = newData[i].northSpeed;
- targetUav.rotation = Math.atan2(northSpeed, eastSpeed);
- const cx = targetUav.x - 10;
- const cy = targetUav.y - 6;
- const circle = this.targetUavCircleN[`${id}`];
- circle.x = cx;
- circle.y = cy;
- const text = this.targetUavCircleNumN[`${id}`];
- text.x = cx;
- text.y = cy;
- } else {
- this.addAir(newData[i], false);
- }
- }
- }
- },
- // 飞机的显示与隐藏
- hideSprite(id) {
- let group = [];
- this.pixiApp.stage.children.forEach((child) => {
- // 检查 child 是否是 Container 类型
- if (child instanceof PIXI.Container) {
- if (child.id == id) {
- group.push(child);
- }
- }
- });
- group.forEach((item) => {
- if (item.typeName) {
- const msg = "DISAPPEAR:" + item.id;
- this.webSocket.send(msg);
- }
- item.visible = false;
- });
- this.hideList.push(id);
- // this.changeNoList.push({ id: id, changeNo: id });
- },
- // 飞机的显示与隐藏
- showSprite(id) {
- if (this.isUpdateView) {
- // 表示是回放,不用隐藏
- return;
- }
- let group = [];
- this.pixiApp.stage.children.forEach((child) => {
- // 检查 child 是否是 Container 类型
- if (child instanceof PIXI.Container) {
- if (child.id == id) {
- group.push(child);
- }
- }
- });
- // group有三个,真实飞机、噪音飞机、轨迹
- if (this.hideList.includes(id)) {
- const maxNum = Math.max(...this.allId) + 1;
- group.forEach((item) => {
- // 已经隐藏了,要显示
- if (item.typeName) {
- const msg = "SHOW:" + item.id;
- this.webSocket.send(msg);
- this.changeNoList.push({ id: id, changeNo: maxNum });
- let index = this.hideList.indexOf(id);
- if (index > -1) {
- this.hideList.splice(index, 1);
- }
- this.allId.push(maxNum);
- if (item.parent) {
- item.parent.removeChild(item);
- }
- // 可选:销毁精灵并释放资源
- item.destroy();
- delete this.targetDataR[item.id];
- }
- // item.visible = true;
- });
- } else {
- // 隐藏
- group.forEach((item) => {
- if (item.typeName) {
- const msg = "DISAPPEAR:" + item.id;
- this.webSocket.send(msg);
- this.hideList.push(id);
- let index = this.allSpriteInfo.findIndex((info) => {
- return info.id == item.id;
- });
- this.allSpriteInfo.splice(index, 1);
- }
- // 只隐藏飞机,不隐藏轨迹
- if (!(item instanceof PIXI.Graphics)) {
- item.visible = false;
- }
- });
- // this.changeNoList.push({ id: id, changeNo: id });
- }
- },
- // 添加视窗控制
- enableViewControl(app) {
- app.stage.interactive = true;
- // 拖曳状态变量
- let dragging = false;
- let lastPosition = null; // 上一次鼠标的位置
- if (!(this.title == "添加任务数据" || this.title == "修改任务数据")) {
- // 鼠标按下事件
- app.view.addEventListener("mousedown", (event) => {
- dragging = true;
- lastPosition = { x: event.clientX, y: event.clientY };
- });
- // 鼠标移出画布时停止拖动
- app.view.addEventListener("mouseleave", () => {
- dragging = false;
- });
- // 鼠标移动事件
- app.view.addEventListener("mousemove", (event) => {
- if (dragging) {
- const currentPosition = { x: event.clientX, y: event.clientY };
- // 计算鼠标移动的距离
- const dx = currentPosition.x - lastPosition.x;
- const dy = currentPosition.y - lastPosition.y;
- // 更新舞台的位置
- app.stage.x += dx;
- app.stage.y += dy;
- // 更新上一次鼠标的位置
- lastPosition = currentPosition;
- }
- });
- // 鼠标松开事件
- app.view.addEventListener("mouseup", () => {
- dragging = false;
- });
- }
- // 鼠标滚轮缩放
- app.renderer.view.addEventListener("wheel", (e) => {
- e.preventDefault();
- const zoomFactor = e.deltaY > 0 ? 0.9 : 1.1;
- app.stage.scale.x *= zoomFactor;
- app.stage.scale.y *= zoomFactor;
- });
- },
- // 更新无人机飞行路径
- updatePath(id, x, y) {
- const lastPointX = this.pathGraphicsPointList[`${id}`].x;
- const lastPointY = this.pathGraphicsPointList[`${id}`].y;
- this.pathGraphicsList[`${id}`].moveTo(lastPointX, lastPointY);
- this.pathGraphicsList[`${id}`].lineTo(x, y);
- this.pathGraphicsPointList[`${id}`].x = x;
- this.pathGraphicsPointList[`${id}`].y = y;
- },
- // 更新平台无人机飞行路径
- updatePlatformPath(x, y) {
- const lastPointX = this.platformPathData.x;
- const lastPointY = this.platformPathData.y;
- this.platformGraphics.moveTo(lastPointX, lastPointY);
- this.platformGraphics.lineTo(x, y);
- this.platformPathData.x = x;
- this.platformPathData.y = y;
- },
- // 确定编队信息
- canvasInfoSubmit() {
- this.$refs["canvasInfoFormRef"].validate((valid) => {
- if (valid) {
- this.submitInfoFlag = true;
- this.addAirSprite();
- }
- });
- },
- // 初始化自定义编队的画布
- initFormationApp() {
- this.pixiCanvas = this.$refs.pixiCanvas;
- if (!this.pixiCanvas) return;
- // 创建Pixi应用
- this.formationAirPiXiApp = new PIXI.Application({
- width: this.pixiCanvas.clientWidth,
- height: this.pixiCanvas.clientHeight,
- antialias: true,
- transparent: false,
- resolution: 1,
- backgroundAlpha: 0,
- });
- this.formationAirPiXiApp.renderer.backgroundColor = 0x1099bb;
- this.pixiCanvas.appendChild(this.formationAirPiXiApp.view);
- // 绘制中心点
- const graphics = new PIXI.Graphics();
- graphics.beginFill(0xe53f32);
- // 绘制一个圆形,半径为 5 像素
- const centerX = this.pixiCanvas.clientWidth / 2;
- const centerY = this.pixiCanvas.clientHeight / 2;
- graphics.drawCircle(centerX, centerY, 3);
- graphics.endFill();
- this.formationAirPiXiApp.stage.addChild(graphics);
- // this.enableViewControl(this.formationAirPiXiApp);
- },
- // 增加飞机编队
- addAirSprite() {
- // 判断是哪个机型
- let texture = new PIXI.Texture.from(uavTarPNG);
- // 创建飞机
- const airSprite = new PIXI.Sprite(texture);
- airSprite.anchor.set(0.5, 0.5);
- airSprite.scale.set(0.04);
- airSprite.position.set(
- this.formationAirPiXiApp.screen.width / 2,
- this.formationAirPiXiApp.screen.height / 2
- );
- this.formationAirPiXiApp.stage.addChild(airSprite);
- this.formationAirPiXiApp.stage.eventMode = "static";
- this.formationAirPiXiApp.stage.hitArea = this.formationAirPiXiApp.screen;
- this.formationAirPiXiApp.view.addEventListener("pointermove", (e) => {
- airSprite.x = e.offsetX;
- airSprite.y = e.offsetY;
- // 计算对应经纬度
- const { lat, lng } = this.calculateLatLng(e.offsetX, e.offsetY);
- this.nowlongitude = lng;
- this.nowlatitude = lat;
- });
- this.formationAirPiXiApp.view.addEventListener("dblclick", (e) => {
- // 创建新精灵
- const newSprite = new PIXI.Sprite(texture);
- newSprite.anchor.set(0.5, 0.5);
- newSprite.scale.set(0.04);
- newSprite.x = e.offsetX;
- newSprite.y = e.offsetY;
- // 计算对应经纬度
- const { lat, lng } = this.calculateLatLng(e.offsetX, e.offsetY);
- this.formationInfoForm = {
- number: null,
- longitude: null,
- latitude: null,
- altitude: null,
- eastSpeed: null,
- northSpeed: null,
- skySpeed: null,
- flightPathType: "直线",
- positionNoise: null,
- };
- this.formationInfoForm.longitude = lng;
- this.formationInfoForm.latitude = lat;
- this.drawerOpen = true;
- this.addOrUpdate = "add";
- this.formationInfoAirDataList.push(newSprite);
- this.formationAirPiXiApp.stage.addChild(newSprite);
- });
- },
- calculateLatLng(x, y) {
- // 计算鼠标相对于画布中心的偏移量(单位:像素)
- const offsetX = x - this.pixiCanvas.clientWidth / 2;
- const offsetY = y - this.pixiCanvas.clientHeight / 2;
- // 将像素偏移量转换为实际距离(单位:公里)
- const kmPerPixel = this.canvasInfo.lengthKm / this.pixiCanvas.clientWidth;
- const deltaX = offsetX * kmPerPixel;
- const deltaY = -offsetY * kmPerPixel; // 注意 y 轴方向相反
- // 将实际距离转换为经纬度差值
- const deltaLat = deltaY / 111; // 每纬度约 111 公里
- const deltaLng =
- deltaX /
- (111 * Math.cos((this.canvasInfo.centerLatitude * Math.PI) / 180)); // 每经度约 111 * cos(lat) 公里
- // 计算最终经纬度
- const lat = Number(this.canvasInfo.centerLatitude) + Number(deltaLat);
- const lng = Number(this.canvasInfo.centerLongitude) + Number(deltaLng);
- return { lat, lng };
- },
- editFormationInfo(row) {
- this.formationInfoForm = row;
- this.drawerOpen = true;
- this.addOrUpdate = "update";
- },
- handleDrawerSubmit() {
- this.$refs["formationInfoRef"].validate((valid) => {
- if (valid) {
- this.formationInfoForm = this.ObjectStringToNumber(
- this.formationInfoForm
- );
- let index = this.formationInfoList.findIndex(
- (item) => item.number == this.formationInfoForm.number
- );
- // 查看是不是已在列表中
- if (index !== -1) {
- if (this.addOrUpdate == "add") {
- // 如果在,并且是新增加的
- this.$message.warning("该编号已存在,请重新输入");
- return;
- } else {
- // 在,是要修改的。修改的还不能列表中的编号相同
- this.formationInfoList[index] = this.formationInfoForm;
- let spriteIndex;
- this.formationAirPiXiApp.stage.children.forEach(
- (child, index) => {
- // 检查 child 是否是 Container 类型
- if (child instanceof PIXI.Sprite) {
- if (child.id == this.formationInfoForm.number) {
- spriteIndex = index;
- }
- }
- }
- );
- const sprite =
- this.formationAirPiXiApp.stage.children[spriteIndex];
- const { x, y } = this.calculateXY(
- this.formationInfoForm.longitude,
- this.formationInfoForm.latitude
- );
- sprite.x = x;
- sprite.y = y;
- this.drawerOpen = false;
- }
- } else {
- //不在列表中
- if (this.addOrUpdate == "add") {
- // 新增加的
- this.formationInfoList.push(this.formationInfoForm);
- const length = this.formationInfoAirDataList.length;
- this.$set(
- this.formationInfoAirDataList[length - 1],
- "id",
- this.formationInfoForm.number
- );
- this.drawerOpen = false;
- }
- }
- }
- });
- },
- // 删除编队信息
- canvasInfoDel() {
- this.$modal
- .confirm("是否确认删除该无人机")
- .then(() => {
- this.formationInfoForm = this.ObjectStringToNumber(
- this.formationInfoForm
- );
- let index = this.formationInfoList.findIndex(
- (item) => item.number == this.formationInfoForm.number
- );
- if (index > -1) {
- this.formationInfoAirDataList =
- this.formationInfoAirDataList.filter((item) => {
- return item.id !== this.formationInfoForm.number;
- });
- this.formationAirPiXiApp.stage.children.forEach((child, index) => {
- // 检查 child 是否是 Container 类型
- if (child instanceof PIXI.Sprite) {
- if (child.id == this.formationInfoForm.number) {
- if (child.parent) {
- child.parent.removeChild(child);
- }
- child.destroy();
- }
- }
- });
- this.formationInfoList.splice(index, 1);
- }
- })
- .then(() => {
- this.drawerOpen = false;
- this.$modal.msgSuccess("删除成功");
- })
- .catch((err) => {
- console.log(err);
- });
- },
- ObjectStringToNumber(obj) {
- for (let key in obj) {
- const parsedValue = Number(obj[key]); // 尝试将值转换为数字
- if (!isNaN(parsedValue)) {
- // 检查是否是有效的数字
- obj[key] = parsedValue; // 如果是数字,更新字段值
- }
- }
- return obj;
- },
- closeDialog() {
- const msg = "END:" + this.parameterId;
- this.webSocket.send(msg);
- this.destroyTrajectory();
- this.showTrajectory = false;
- this.isUpdateView = false;
- this.isClickGroup = false;
- setTimeout(() => {
- this.getList();
- }, 1500);
- },
- closeUpdataDialog() {
- this.destroyTormationInfo();
- this.canvasInfo = {
- centerLongitude: null,
- centerLatitude: null,
- lengthKm: null,
- };
- this.submitInfoFlag = false;
- this.formationAirPiXiApp = null;
- this.pixiCanvas = null;
- this.nowlongitude = null;
- this.nowlatitude = null;
- this.formationInfoList = [];
- this.reset();
- },
- destroyTormationInfo() {
- if (this.formationAirPiXiApp) {
- const removedChildren = this.formationAirPiXiApp.stage.removeChildren(
- 0,
- this.formationAirPiXiApp.stage.children.length
- );
- removedChildren.forEach((child) => {
- child.destroy({
- children: true,
- texture: false,
- baseTexture: false,
- });
- });
- this.formationAirPiXiApp.stage.removeChildren();
- this.formationAirPiXiApp.renderer.clear();
- this.formationAirPiXiApp.destroy(true);
- this.formationAirPiXiApp = null;
- }
- },
- drawerClose() {
- this.formationInfoForm = {
- number: null,
- longitude: null,
- latitude: null,
- altitude: null,
- eastSpeed: null,
- northSpeed: null,
- skySpeed: null,
- flightPathType: "直线",
- positionNoise: null,
- };
- this.addOrUpdate = "add";
- },
- clearAllAry() {
- this.targetLblAry = {};
- this.targetUavAry = [];
- this.targetUavCircleR = {};
- this.targetUavCircleN = {};
- this.targetUavCircleNumR = {};
- this.targetUavCircleNumN = {};
- this.configList = [
- "经度",
- "纬度",
- "海拔",
- "东向速度",
- "北向速度",
- "天向速度",
- ];
- this.lastPosition = {
- x: null,
- y: null,
- };
- this.hideList = [];
- this.allId = [];
- this.changeNoList = [];
- this.curLongitude = null;
- this.curLatitude = null;
- this.curAltitude = null;
- this.pathGraphics = null;
- this.cycleCount = 0;
- this.isUpdateView = false;
- this.pathGraphicsList = {};
- this.pathGraphicsPointList = {};
- this.targetDataR = {};
- this.targetDataN = {};
- this.nowlongitude = null;
- this.nowlatitude = null;
- this.submitInfoFlag = false;
- this.pixiCanvas = null;
- this.canvasInfo = {
- centerLongitude: null,
- centerLatitude: null,
- lengthKm: null,
- heightKm: null,
- };
- this.platformSprite = null;
- this.platformGraphics = null;
- this.platformPathData = {};
- this.platformInfo = {};
- this.platformData = [];
- this.allSpriteInfo = [];
- this.isClickGroup = false;
- this.firstLng = null;
- this.firstLat = null;
- this.playbackTime = null;
- this.firstAir = "";
- this.secondAir = "";
- },
- // 综合计算(距离、方位角、航向夹角)
- calculateRelativePosition(lat1, lon1, heading1, lat2, lon2, heading2) {
- const distance = this.calculateDistance(lat1, lon1, lat2, lon2);
- const bearing = this.calculateBearing(lat1, lon1, lat2, lon2);
- // const headingDiff = this.calculateHeadingDiff(heading1, heading2);
- return {
- distance: distance, // 两飞机距离(米)
- bearing: bearing, // 飞机2相对于飞机1的方位角(0°~360°)
- // headingDiff: headingDiff, // 两飞机航向夹角(0°~180°)
- };
- },
- // 计算两架飞机的航向夹角(航向差)
- calculateHeadingDiff(heading1, heading2) {
- const diff = Math.abs(heading1 - heading2);
- return diff > 180 ? 360 - diff : diff;
- },
- // 计算飞机2相对于飞机1的方位角
- calculateBearing(lat1, lon1, lat2, lon2) {
- const phi1 = (lat1 * Math.PI) / 180;
- const lambda1 = (lon1 * Math.PI) / 180;
- const phi2 = (lat2 * Math.PI) / 180;
- const lambda2 = (lon2 * Math.PI) / 180;
- const y = Math.sin(lambda2 - lambda1) * Math.cos(phi2);
- const x =
- Math.cos(phi1) * Math.sin(phi2) -
- Math.sin(phi1) * Math.cos(phi2) * Math.cos(lambda2 - lambda1);
- let theta = (Math.atan2(y, x) * 180) / Math.PI;
- return (theta + 360) % 360; // 确保在0°~360°范围内
- },
- // 计算两架飞机之间的距离(Haversine 公式)
- calculateDistance(lat1, lon1, lat2, lon2) {
- const R = 6371000; // 地球半径(米)
- const phi1 = (lat1 * Math.PI) / 180;
- const phi2 = (lat2 * Math.PI) / 180;
- const deltaPhi = ((lat2 - lat1) * Math.PI) / 180;
- const deltaLambda = ((lon2 - lon1) * Math.PI) / 180;
- const a =
- Math.sin(deltaPhi / 2) * Math.sin(deltaPhi / 2) +
- Math.cos(phi1) *
- Math.cos(phi2) *
- Math.sin(deltaLambda / 2) *
- Math.sin(deltaLambda / 2);
- const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
- return R * c; // 返回距离(米)
- },
- },
- };
- </script>
- <style>
- .el-dialog__body {
- /* padding: 0 !important; */
- padding-top: 10px !important;
- }
- .pixi-container {
- width: 100%;
- /* height: 750px; */
- height: calc(100vh - 140px);
- position: relative;
- }
- .pixi-container canvas {
- width: 100%;
- height: 100%;
- }
- .container {
- display: grid;
- grid-template-columns: 85% 15%; /* 两栏按比例分 */
- }
- .right-board {
- padding: 2px;
- margin: 2px;
- height: 800px;
- /* 当内容超出元素边界时显示滚动条 */
- }
- .distance {
- display: inline-block;
- width: 750px;
- margin-left: 50px;
- }
- .info {
- font-weight: 700;
- color: #4f4a4a;
- }
- </style>
|