periodicTask.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <div>
  3. <div class="header">
  4. <el-form label-width="120px">
  5. <div style="display: flex; padding: 10px">
  6. <el-form-item label="任务名称:">
  7. <el-input
  8. v-model="form.taskName"
  9. placeholder="请输入任务名称"
  10. style="width: 200px"
  11. ></el-input>
  12. </el-form-item>
  13. <el-form-item label="任务组名:">
  14. <el-select
  15. v-model="form.taskGroupName"
  16. placeholder="请输入任务组名"
  17. style="width: 200px"
  18. >
  19. <el-option
  20. v-for="item in taskGroupOptions"
  21. :key="item.value"
  22. :value="item.value"
  23. :label="item.label"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="任务状态:">
  28. <el-select
  29. v-model="form.taskStatus"
  30. placeholder="请选择任务状态"
  31. style="width: 200px"
  32. >
  33. <el-option
  34. v-for="item in taskStatusOptions"
  35. :key="item.value"
  36. :value="item.value"
  37. :label="item.label"
  38. ></el-option>
  39. </el-select>
  40. </el-form-item>
  41. <el-button class="reset-btn" @click="resetEvent">重置</el-button>
  42. <el-button class="search-btn" @click="searchEvent">查询</el-button>
  43. </div>
  44. </el-form>
  45. </div>
  46. <div class="content">
  47. <div class="content-inner">
  48. <!-- <el-button class="blue-btn" @click="addEvent">新增</el-button> -->
  49. <!-- <el-button class="blue-btn" @click="modifyEvent">修改</el-button> -->
  50. <el-button class="delete-btn" @click="batchDelete">批量删除</el-button>
  51. </div>
  52. <el-table
  53. ref="multipleTable"
  54. :data="tableData"
  55. tooltip-effect="dark"
  56. :header-cell-style="{ textAlign: 'center' }"
  57. :cell-style="{ textAlign: 'center' }"
  58. style="width: 100%"
  59. height="350"
  60. @selection-change="handleSelectionChange"
  61. >
  62. <el-table-column type="selection" width="50"> </el-table-column>
  63. <el-table-column prop="taskID" label="任务编号"> </el-table-column>
  64. <el-table-column prop="taskName" label="任务名称"> </el-table-column>
  65. <el-table-column prop="taskGroupName" label="任务组名">
  66. </el-table-column>
  67. <el-table-column prop="taskDescription" label="任务描述">
  68. </el-table-column>
  69. <el-table-column prop="cron" label="cron 执行表达式"> </el-table-column>
  70. <el-table-column prop="status" label="状态">
  71. <template slot-scope="scope">
  72. <el-switch
  73. v-model="scope.row.status"
  74. active-color="#13ce66"
  75. inactive-color="#ff4949"
  76. ></el-switch>
  77. </template>
  78. </el-table-column>
  79. <el-table-column prop="operation" label="操作">
  80. <template slot-scope="scope">
  81. <!-- <el-button
  82. v-show="scope.row.taskID == null ? false : true"
  83. size="mini"
  84. type="text"
  85. >查看</el-button
  86. > -->
  87. <el-button
  88. v-show="scope.row.taskID == null ? false : true"
  89. size="mini"
  90. type="text"
  91. @click="alterTaskEvent(scope.row)"
  92. >编辑</el-button
  93. >
  94. <el-button
  95. v-show="scope.row.taskID == null ? false : true"
  96. size="mini"
  97. type="text"
  98. @click="deleteEvent(scope.row)"
  99. >删除</el-button
  100. >
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. </div>
  105. <div class="bottom">
  106. <page class="page" :paginationData="paginationData"></page>
  107. </div>
  108. <alterTask ref="altertask" @submitForm="submitForm"></alterTask>
  109. </div>
  110. </template>
  111. <script>
  112. import checkbox from "@/components/Checkbox/index";
  113. import page from "@/components/pagination/index";
  114. import alterTask from "../messageDialog/alterTask";
  115. import publicFunc from "@/utils/publicFunc";
  116. import { getTaskList } from "@/api/security/systemMonitor";
  117. export default {
  118. components: { checkbox, page, alterTask },
  119. data() {
  120. return {
  121. input: "",
  122. show: true,
  123. form: {
  124. taskName: "",
  125. taskGroupName: "",
  126. taskStatus: "",
  127. },
  128. tableData: [
  129. {
  130. id: publicFunc.buildGuid("video"),
  131. taskID: "1",
  132. taskName: "采集视频云平台",
  133. taskGroupName: "系统",
  134. taskDescription: "xxx.xxx.xxx.xxx",
  135. cron: "001***?",
  136. status: "true",
  137. },
  138. {
  139. id: publicFunc.buildGuid("video"),
  140. taskID: "1",
  141. taskName: "采集视频云平台",
  142. taskGroupName: "默认",
  143. taskDescription: "xxx.xxx.xxx.xxx",
  144. cron: "001***?",
  145. status: "true",
  146. },
  147. {
  148. id: publicFunc.buildGuid("video"),
  149. taskID: "1",
  150. taskName: "采集视频云平台",
  151. taskGroupName: "系统",
  152. taskDescription: "xxx.xxx.xxx.xxx",
  153. cron: "001***?",
  154. status: "false",
  155. },
  156. {
  157. id: publicFunc.buildGuid("video"),
  158. taskID: "1",
  159. taskName: "采集视频云平台",
  160. taskGroupName: "系统",
  161. taskDescription: "xxx.xxx.xxx.xxx",
  162. cron: "001***?",
  163. status: "false",
  164. },
  165. {
  166. id: publicFunc.buildGuid("video"),
  167. taskID: "1",
  168. taskName: "采集视频云平台",
  169. taskGroupName: "系统",
  170. taskDescription: "xxx.xxx.xxx.xxx",
  171. cron: "001***?",
  172. status: "false",
  173. },
  174. {
  175. id: publicFunc.buildGuid("video"),
  176. taskID: "1",
  177. taskName: "采集视频云平台",
  178. taskGroupName: "系统",
  179. taskDescription: "xxx.xxx.xxx.xxx",
  180. cron: "001***?",
  181. status: "false",
  182. },
  183. {
  184. id: publicFunc.buildGuid("video"),
  185. taskID: "1",
  186. taskName: "采集视频云平台",
  187. taskGroupName: "系统",
  188. taskDescription: "xxx.xxx.xxx.xxx",
  189. cron: "001***?",
  190. status: "false",
  191. },
  192. {
  193. id: publicFunc.buildGuid("video"),
  194. taskID: "1",
  195. taskName: "采集视频云平台",
  196. taskGroupName: "系统",
  197. taskDescription: "xxx.xxx.xxx.xxx",
  198. cron: "001***?",
  199. status: "false",
  200. },
  201. ],
  202. taskStatusOptions: [
  203. {
  204. value: "",
  205. label: "不限",
  206. },
  207. {
  208. value: 1,
  209. label: "暂停",
  210. },
  211. {
  212. value: 0,
  213. label: "正常",
  214. },
  215. ],
  216. taskGroupOptions: [
  217. {
  218. value: "",
  219. label: "不限",
  220. },
  221. {
  222. value: 1,
  223. label: "系统",
  224. },
  225. ],
  226. multipleSelection: [],
  227. currentPageSize: 10,
  228. currentPage: 1,
  229. paginationData: {
  230. pageSize: 10,
  231. pagerCount: 5,
  232. currentPage: 1,
  233. pageSizes: [5, 10, 20, 30],
  234. total: 30,
  235. currentChange: (val) => {
  236. this.getTableData(val);
  237. },
  238. handleSizeChange: (val) => {
  239. this.handleSizeChange(val);
  240. },
  241. },
  242. };
  243. },
  244. mounted() {
  245. this.initData();
  246. },
  247. methods: {
  248. initData() {
  249. this.getTableData(1);
  250. },
  251. handleSelectionChange(val) {
  252. this.multipleSelection = val;
  253. },
  254. cancleChecked() {
  255. this.$refs.multipleTable.clearSelection();
  256. },
  257. alterTaskEvent(data) {
  258. this.$refs.altertask.dialogVisible = true;
  259. this.$refs.altertask.form.taskID = data.taskID;
  260. this.$refs.altertask.form.name = data.taskName;
  261. this.$refs.altertask.form.groupName = data.taskGroupName;
  262. this.$refs.altertask.form.cron_expression = data.cron;
  263. },
  264. resetEvent() {
  265. this.form.taskName = "";
  266. this.form.taskGroupName = "";
  267. this.form.taskStatus = "";
  268. },
  269. searchEvent() {
  270. console.log(this.form);
  271. this.getTableData(1);
  272. },
  273. getTableData(val) {
  274. this.tableData = [];
  275. getTaskList(
  276. val,
  277. this.currentPageSize,
  278. this.form.taskName,
  279. this.form.taskGroupName,
  280. this.form.taskStatus
  281. ).then((res) => {
  282. if (res.data.code === 0) {
  283. let data = res.data.data.data;
  284. this.paginationData.total = data.total;
  285. this.tableData = data.list.map((v) => {
  286. return {
  287. taskID: v.id,
  288. taskName: v.name,
  289. taskGroupName: v.groupType === 1 ? "系统" : "默认",
  290. taskDescription: v.description,
  291. cron: v.cronExpression,
  292. status: v.status === 0 ? true : false,
  293. };
  294. });
  295. }
  296. });
  297. },
  298. handleSizeChange() {},
  299. deleteEvent(data) {
  300. this.tableData = this.tableData.filter((v) => {
  301. return v.taskID !== data.taskID;
  302. });
  303. },
  304. addEvent() {},
  305. modifyEvent() {},
  306. batchDelete() {
  307. console.log(this.multipleSelection);
  308. let selectedIds = this.multipleSelection.map((v) => v.taskID);
  309. this.tableData = this.tableData.filter(
  310. (v) => !selectedIds.includes(v.taskID)
  311. );
  312. },
  313. submitForm(data) {
  314. this.$refs.altertask.dialogVisible = false;
  315. this.tableData = this.tableData.map((v) => {
  316. if (v.taskID == data.taskID) {
  317. let name = data.name;
  318. let groupName = data.groupName;
  319. return {
  320. taskID: v.taskID,
  321. taskName: name,
  322. taskGroupName: groupName,
  323. taskDescription: v.taskDescription,
  324. cron: data.cron_expression,
  325. };
  326. } else {
  327. return {
  328. taskID: v.taskID,
  329. taskName: v.taskName,
  330. taskGroupName: v.taskGroupName,
  331. taskDescription: v.taskDescription,
  332. cron: v.cron,
  333. status: v.status,
  334. };
  335. }
  336. });
  337. },
  338. },
  339. };
  340. </script>
  341. <style lang="less" scoped>
  342. .header {
  343. margin: 0 2.5%;
  344. height: 60px;
  345. background-color: #fafafa;
  346. position: relative;
  347. .reset-btn,
  348. .search-btn {
  349. height: 30px;
  350. width: 80px;
  351. position: absolute;
  352. color: #fff;
  353. display: flex;
  354. align-items: center;
  355. justify-content: center;
  356. }
  357. .reset-btn {
  358. top: 10px;
  359. background-color: #b3b3b3;
  360. right: 130px;
  361. }
  362. .search-btn {
  363. top: 10px;
  364. background-color: #2ea8e6;
  365. right: 25px;
  366. }
  367. .el-form-item {
  368. margin-bottom: 0 !important;
  369. margin-right: 60px !important;
  370. /deep/.el-form-item {
  371. margin-right: 50px;
  372. margin-bottom: 0;
  373. }
  374. /deep/.el-form-item__content {
  375. margin-left: 120px;
  376. }
  377. }
  378. }
  379. .content {
  380. width: 95%;
  381. position: absolute;
  382. margin-top: 30px;
  383. margin-left: 2.5%;
  384. margin-right: 2.5%;
  385. height: 400px;
  386. &-inner {
  387. height: 30px;
  388. width: 100%;
  389. display: flex;
  390. align-items: center;
  391. .blue-btn,
  392. .delete-btn {
  393. width: 80px;
  394. height: 30px;
  395. display: flex;
  396. align-items: center;
  397. justify-content: center;
  398. margin-right: 10px;
  399. color: #fff;
  400. border-radius: 3px;
  401. }
  402. .blue-btn {
  403. background-color: #2ea8e6;
  404. }
  405. .delete-btn {
  406. background: #b3b3b3;
  407. }
  408. }
  409. .el-table {
  410. position: absolute;
  411. top: 30px;
  412. left: 0;
  413. width: 100%;
  414. height: calc(100% - 30px);
  415. border: 1px solid #f0f2f2;
  416. margin-top: 10px;
  417. font-size: 0.95rem;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #b2b2b2;
  421. background: rgba(255, 255, 255, 0.8);
  422. /deep/th {
  423. background: #f7fbff;
  424. }
  425. /deep/.el-checkbox {
  426. color: #b2b2b2;
  427. .el-checkbox__input.is-checked + .el-checkbox__label {
  428. color: #2ea8e6;
  429. }
  430. .el-checkbox__input.is-checked .el-checkbox__inner::after {
  431. width: 70%;
  432. height: 70%;
  433. background: #2ea8e6;
  434. border-radius: 0;
  435. transform: rotate(0deg) scaleY(1);
  436. position: static;
  437. // border: 1px solid #8DD9FF;
  438. }
  439. .el-checkbox__inner {
  440. border: 1px solid #8dd9ff;
  441. background: rgba(0, 170, 255, 0);
  442. display: flex;
  443. align-items: center;
  444. justify-content: center;
  445. position: static;
  446. &::after {
  447. transition: 0ms;
  448. }
  449. }
  450. .el-checkbox__label {
  451. padding-left: 0;
  452. font-size: 15px;
  453. position: absolute;
  454. top: 1px;
  455. left: 25px;
  456. }
  457. }
  458. }
  459. }
  460. .el-select {
  461. width: 80px;
  462. margin-right: 20px;
  463. }
  464. .bottom {
  465. position: absolute;
  466. bottom: 10px;
  467. left: 50px;
  468. height: 50px;
  469. width: 95%;
  470. line-height: 20px;
  471. background-color: rgba(255, 255, 255, 1);
  472. text-align: center;
  473. }
  474. </style>