index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="app-container">
  3. <el-form
  4. v-show="showSearch"
  5. ref="queryForm"
  6. :model="queryParams"
  7. size="small"
  8. :inline="true"
  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="multiTarget">
  20. <el-select
  21. v-model="queryParams.multiTarget"
  22. placeholder="请选择多目标类型"
  23. clearable
  24. >
  25. <el-option
  26. v-for="dict in dict.type.uavps_target_formation_type"
  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="创建时间">
  34. <el-date-picker
  35. v-model="daterangeCreateTime"
  36. style="width: 240px"
  37. value-format="yyyy-MM-dd"
  38. type="daterange"
  39. range-separator="-"
  40. start-placeholder="开始日期"
  41. end-placeholder="结束日期"
  42. />
  43. </el-form-item>
  44. <el-form-item>
  45. <el-button
  46. type="primary"
  47. icon="el-icon-search"
  48. size="mini"
  49. @click="handleQuery"
  50. >搜索</el-button
  51. >
  52. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
  53. >重置</el-button
  54. >
  55. </el-form-item>
  56. </el-form>
  57. <el-row :gutter="10" class="mb8">
  58. <el-col :span="1.5">
  59. <el-button
  60. v-hasPermi="['system:task:add']"
  61. type="primary"
  62. plain
  63. icon="el-icon-plus"
  64. size="mini"
  65. @click="handleAdd"
  66. >新增</el-button
  67. >
  68. </el-col>
  69. <el-col :span="1.5">
  70. <el-button
  71. v-hasPermi="['system:task:edit']"
  72. type="success"
  73. plain
  74. icon="el-icon-edit"
  75. size="mini"
  76. :disabled="single"
  77. @click="handleUpdate"
  78. >修改</el-button
  79. >
  80. </el-col>
  81. <el-col :span="1.5">
  82. <el-button
  83. v-hasPermi="['system:task:remove']"
  84. type="danger"
  85. plain
  86. icon="el-icon-delete"
  87. size="mini"
  88. :disabled="multiple"
  89. @click="handleDelete"
  90. >删除</el-button
  91. >
  92. </el-col>
  93. <el-col :span="1.5">
  94. <el-button
  95. v-hasPermi="['system:task:export']"
  96. type="warning"
  97. plain
  98. icon="el-icon-download"
  99. size="mini"
  100. @click="handleExport"
  101. >导出</el-button
  102. >
  103. </el-col>
  104. <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
  105. </el-row>
  106. <el-table
  107. v-loading="loading"
  108. :data="taskList"
  109. @selection-change="handleSelectionChange"
  110. >
  111. <el-table-column type="selection" width="55" align="center" />
  112. <el-table-column label="业务ID" align="center" prop="bizId" />
  113. <el-table-column label="任务名称" align="center" prop="bizName" />
  114. <el-table-column label="多目标类型" align="center" prop="multiTarget">
  115. <template slot-scope="scope">
  116. <dict-tag
  117. :options="dict.type.uavps_target_formation_type"
  118. :value="scope.row.multiTarget"
  119. />
  120. </template>
  121. </el-table-column>
  122. <el-table-column
  123. label="创建时间"
  124. align="center"
  125. prop="createTime"
  126. width="180"
  127. >
  128. <template slot-scope="scope">
  129. <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
  130. </template>
  131. </el-table-column>
  132. <el-table-column
  133. label="更新时间"
  134. align="center"
  135. prop="updateTime"
  136. width="180"
  137. >
  138. <template slot-scope="scope">
  139. <span>{{ parseTime(scope.row.updateTime, "{y}-{m}-{d}") }}</span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column
  143. label="操作"
  144. align="center"
  145. class-name="small-padding fixed-width"
  146. >
  147. <template slot-scope="scope">
  148. <el-button
  149. v-hasPermi="['system:task:edit']"
  150. size="mini"
  151. type="text"
  152. icon="el-icon-s-operation"
  153. @click="handleRun(scope.row)"
  154. >运行</el-button
  155. >
  156. <el-button
  157. v-hasPermi="['system:task:edit']"
  158. size="mini"
  159. type="text"
  160. icon="el-icon-edit"
  161. @click="handleUpdate(scope.row)"
  162. >修改</el-button
  163. >
  164. <el-button
  165. v-hasPermi="['system:task:remove']"
  166. size="mini"
  167. type="text"
  168. icon="el-icon-delete"
  169. @click="handleDelete(scope.row)"
  170. >删除</el-button
  171. >
  172. </template>
  173. </el-table-column>
  174. </el-table>
  175. <pagination
  176. v-show="total > 0"
  177. :total="total"
  178. :page.sync="queryParams.pageNum"
  179. :limit.sync="queryParams.pageSize"
  180. @pagination="getList"
  181. />
  182. <!-- 添加或修改任务数据对话框 -->
  183. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  184. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  185. <el-form-item label="任务名称" prop="bizName">
  186. <el-input v-model="form.bizName" placeholder="请输入任务名称" />
  187. </el-form-item>
  188. <el-form-item label="业务类型" prop="bizType">
  189. <el-select v-model="form.bizType" placeholder="请选择业务类型">
  190. <el-option
  191. v-for="dict in dict.type.uavps_target_formation_type"
  192. :key="dict.value"
  193. :label="dict.label"
  194. :value="dict.value"
  195. />
  196. </el-select>
  197. </el-form-item>
  198. <el-form-item label="多目标类型" prop="multiTarget">
  199. <el-select v-model="form.multiTarget" placeholder="请选择多目标类型">
  200. <el-option
  201. v-for="dict in dict.type.uavps_target_formation_type"
  202. :key="dict.value"
  203. :label="dict.label"
  204. :value="dict.value"
  205. />
  206. </el-select>
  207. </el-form-item>
  208. <el-form-item label="固定翼平台无人机数据" prop="platformUavStr">
  209. <el-input
  210. v-model="form.platformUavStr"
  211. type="textarea"
  212. placeholder="请输入内容"
  213. />
  214. </el-form-item>
  215. <el-form-item
  216. label="固定编队目标数据"
  217. prop="fixedMultiTargetFormationStr"
  218. >
  219. <el-input
  220. v-model="form.fixedMultiTargetFormationStr"
  221. type="textarea"
  222. placeholder="请输入内容"
  223. />
  224. </el-form-item>
  225. <el-form-item
  226. label="自定义编队目标数据"
  227. prop="customizedMultiTargetFormationStr"
  228. >
  229. <el-input
  230. v-model="form.customizedMultiTargetFormationStr"
  231. type="textarea"
  232. placeholder="请输入内容"
  233. />
  234. </el-form-item>
  235. </el-form>
  236. <div slot="footer" class="dialog-footer">
  237. <el-button type="primary" @click="submitForm">确 定</el-button>
  238. <el-button @click="cancel">取 消</el-button>
  239. </div>
  240. </el-dialog>
  241. <el-dialog
  242. :title="title"
  243. :visible.sync="showTrajectory"
  244. @opened="initTrajectory"
  245. :before-close="destroyTrajectory"
  246. :fullscreen="true"
  247. append-to-body
  248. destroy-on-close
  249. ></el-dialog>
  250. </div>
  251. </template>
  252. <script>
  253. import {
  254. listTask,
  255. getTask,
  256. delTask,
  257. addTask,
  258. updateTask,
  259. } from "@/api/system/task";
  260. export default {
  261. name: "Task",
  262. dicts: ["uavps_target_formation_type"],
  263. data() {
  264. return {
  265. // 遮罩层
  266. loading: true,
  267. // 选中数组
  268. ids: [],
  269. // 非单个禁用
  270. single: true,
  271. // 非多个禁用
  272. multiple: true,
  273. // 显示搜索条件
  274. showSearch: true,
  275. // 总条数
  276. total: 0,
  277. // 任务数据表格数据
  278. taskList: [],
  279. // 弹出层标题
  280. title: "",
  281. // 是否显示弹出层
  282. open: false,
  283. // 自定义编队目标数据时间范围
  284. daterangeCreateTime: [],
  285. // 查询参数
  286. queryParams: {
  287. pageNum: 1,
  288. pageSize: 10,
  289. bizName: null,
  290. multiTarget: null,
  291. createTime: null,
  292. },
  293. // 表单参数
  294. form: {},
  295. // 表单校验
  296. rules: {
  297. bizType: [
  298. { required: true, message: "业务类型不能为空", trigger: "change" },
  299. ],
  300. multiTarget: [
  301. { required: true, message: "多目标类型不能为空", trigger: "change" },
  302. ],
  303. },
  304. parameterId: 0,
  305. showTrajectory: false,
  306. webSocket: null,
  307. };
  308. },
  309. created() {
  310. this.getList();
  311. },
  312. methods: {
  313. /** 查询任务数据列表 */
  314. getList() {
  315. this.loading = true;
  316. this.queryParams.params = {};
  317. if (this.daterangeCreateTime != null && this.daterangeCreateTime != "") {
  318. this.queryParams.params["beginCreateTime"] =
  319. this.daterangeCreateTime[0];
  320. this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
  321. }
  322. listTask(this.queryParams).then((response) => {
  323. this.taskList = response.rows;
  324. this.total = response.total;
  325. this.loading = false;
  326. });
  327. },
  328. // 取消按钮
  329. cancel() {
  330. this.open = false;
  331. this.reset();
  332. },
  333. // 表单重置
  334. reset() {
  335. this.form = {
  336. bizId: null,
  337. bizName: null,
  338. bizType: null,
  339. multiTarget: null,
  340. platformUavStr: null,
  341. fixedMultiTargetFormationStr: null,
  342. customizedMultiTargetFormationStr: null,
  343. createBy: null,
  344. createTime: null,
  345. updateBy: null,
  346. updateTime: null,
  347. };
  348. this.resetForm("form");
  349. },
  350. /** 搜索按钮操作 */
  351. handleQuery() {
  352. this.queryParams.pageNum = 1;
  353. this.getList();
  354. },
  355. /** 重置按钮操作 */
  356. resetQuery() {
  357. this.daterangeCreateTime = [];
  358. this.resetForm("queryForm");
  359. this.handleQuery();
  360. },
  361. // 多选框选中数据
  362. handleSelectionChange(selection) {
  363. this.ids = selection.map((item) => item.bizId);
  364. this.single = selection.length !== 1;
  365. this.multiple = !selection.length;
  366. },
  367. /** 新增按钮操作 */
  368. handleAdd() {
  369. this.reset();
  370. this.open = true;
  371. this.title = "添加任务数据";
  372. },
  373. /** 修改按钮操作 */
  374. handleUpdate(row) {
  375. this.reset();
  376. const bizId = row.bizId || this.ids;
  377. getTask(bizId).then((response) => {
  378. this.form = response.data;
  379. this.open = true;
  380. this.title = "修改任务数据";
  381. });
  382. },
  383. /** 提交按钮 */
  384. submitForm() {
  385. this.$refs["form"].validate((valid) => {
  386. if (valid) {
  387. if (this.form.bizId != null) {
  388. updateTask(this.form).then((response) => {
  389. this.$modal.msgSuccess("修改成功");
  390. this.open = false;
  391. this.getList();
  392. });
  393. } else {
  394. addTask(this.form).then((response) => {
  395. this.$modal.msgSuccess("新增成功");
  396. this.open = false;
  397. this.getList();
  398. });
  399. }
  400. }
  401. });
  402. },
  403. /** 删除按钮操作 */
  404. handleDelete(row) {
  405. const bizIds = row.bizId || this.ids;
  406. this.$modal
  407. .confirm('是否确认删除任务数据编号为"' + bizIds + '"的数据项?')
  408. .then(function () {
  409. return delTask(bizIds);
  410. })
  411. .then(() => {
  412. this.getList();
  413. this.$modal.msgSuccess("删除成功");
  414. })
  415. .catch(() => {});
  416. },
  417. /** 导出按钮操作 */
  418. handleExport() {
  419. this.download(
  420. "system/task/export",
  421. {
  422. ...this.queryParams,
  423. },
  424. `task_${new Date().getTime()}.xlsx`
  425. );
  426. },
  427. handleRun(row) {
  428. this.parameterId = row.bizId || this.ids;
  429. this.showTrajectory = true;
  430. this.title = "飞行轨迹";
  431. },
  432. initWebSocket() {
  433. const wsUri = "ws://127.0.0.1:8080/websocket/message";
  434. this.webSocket = new WebSocket(wsUri);
  435. const self = this;
  436. debugger;
  437. this.webSocket.onopen = function (event) {
  438. self.webSocket.send("RUN:" + self.parameterId);
  439. console.log("WebSocket连接成功!");
  440. };
  441. this.webSocket.onmessage = function (event) {
  442. self.processMessage(JSON.parse(event.data));
  443. };
  444. this.webSocket.onclose = function (event) {
  445. console.log("WebSocket连接断开!");
  446. };
  447. this.webSocket.onerror = function (event) {
  448. console.log(
  449. "WebSocket连接异常: " +
  450. event.code +
  451. " " +
  452. event.reason +
  453. " " +
  454. event.wasClean
  455. );
  456. };
  457. },
  458. destroyTrajectory() {
  459. if (this.webSocket) {
  460. this.webSocket.close();
  461. }
  462. this.showTrajectory = false;
  463. },
  464. initTrajectory() {
  465. this.initWebSocket();
  466. },
  467. },
  468. };
  469. </script>