manualRunProjectList.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <div>
  3. <div v-if="!$route.path.includes('projectInfo')">
  4. <search-layout :needBox="true">
  5. <template slot="searchItem1">
  6. <span class="label">项目ID</span>
  7. <el-input
  8. v-model="searchParams.projectId"
  9. size="small"
  10. clearable
  11. placeholder="请输入"
  12. maxlength="60"
  13. @keyup.enter.native="doSearch"
  14. >
  15. </el-input>
  16. </template>
  17. <template slot="searchItem2">
  18. <span class="label">项目名称</span>
  19. <el-input
  20. v-model="searchParams.projectName"
  21. size="small"
  22. clearable
  23. placeholder="请输入"
  24. maxlength="60"
  25. @keyup.enter.native="doSearch"
  26. >
  27. </el-input>
  28. </template>
  29. <template slot="searchItem3">
  30. <span class="label">进度</span>
  31. <el-select v-model="searchParams.nowRunState">
  32. <el-option
  33. v-for="item in nowRunStateList"
  34. :label="item.caption"
  35. :value="item.code"
  36. :key="item.code"
  37. ></el-option>
  38. </el-select>
  39. </template>
  40. <template slot="searchItem4">
  41. <span class="label">评测等级</span>
  42. <el-select v-model="searchParams.evaluationLevel">
  43. <el-option
  44. v-for="item in evaluationLevelList"
  45. :label="item.caption"
  46. :value="item.code"
  47. :key="item.code"
  48. ></el-option>
  49. </el-select>
  50. </template>
  51. <template slot="searchItem5">
  52. <span class="label">创建时间</span>
  53. <el-date-picker
  54. v-model="createDate"
  55. type="daterange"
  56. format="yyyy-MM-dd"
  57. value-format="yyyy-MM-dd"
  58. range-separator="至"
  59. start-placeholder="开始日期"
  60. end-placeholder="结束日期"
  61. >
  62. </el-date-picker>
  63. </template>
  64. <template slot="searchItem6">
  65. <span class="label">完成时间</span>
  66. <el-date-picker
  67. v-model="finishDate"
  68. type="daterange"
  69. format="yyyy-MM-dd"
  70. value-format="yyyy-MM-dd"
  71. range-separator="至"
  72. start-placeholder="开始日期"
  73. end-placeholder="结束日期"
  74. >
  75. </el-date-picker>
  76. </template>
  77. <template slot="searchBtn1">
  78. <el-button type="primary" @click="doSearch">查询</el-button>
  79. </template>
  80. <template slot="searchBtn2">
  81. <el-button type="primary" @click="doReset">重置</el-button>
  82. </template>
  83. </search-layout>
  84. <div class="btnsPanel">
  85. <el-button
  86. type="primary"
  87. plain
  88. icon="el-icon-delete"
  89. @click="delRows"
  90. >批量删除</el-button
  91. >
  92. <el-button
  93. type="primary"
  94. icon="el-icon-circle-plus-outline"
  95. @click="addOne"
  96. >新增</el-button
  97. >
  98. </div>
  99. <tableList
  100. ref="table"
  101. style="margin: 0 30px"
  102. :columns="columns"
  103. :getDataWay="getDataWay"
  104. :pagination="pagination"
  105. :checkedData="checkedArr"
  106. selection
  107. index
  108. >
  109. <el-table-column label="操作" slot="cgInfos" align="center">
  110. <template v-slot="scope">
  111. <i
  112. @click="viewRow(scope.row.id)"
  113. class="el-icon-view elIcon"
  114. title="查看"
  115. ></i>
  116. <i
  117. v-if="
  118. scope.row.nowRunState === '10' ||
  119. scope.row.nowRunState === '40'
  120. "
  121. @click="editRow(scope.row)"
  122. class="el-icon-edit-outline elIcon"
  123. title="编辑"
  124. ></i>
  125. <i
  126. v-if="
  127. scope.row.nowRunState === '10' ||
  128. scope.row.nowRunState === '30' ||
  129. scope.row.nowRunState === '40'
  130. "
  131. @click="runRow(scope.row.id, scope.row.parallelism)"
  132. class="el-icon-refresh-right elIcon"
  133. title="运行"
  134. ></i>
  135. <i
  136. v-if="scope.row.nowRunState === '20'"
  137. @click="stopRow(scope.row.id)"
  138. class="myIconPause elIcon"
  139. title="中止"
  140. ></i>
  141. <i
  142. v-if="
  143. scope.row.nowRunState === '10' ||
  144. scope.row.nowRunState === '30' ||
  145. scope.row.nowRunState === '40'
  146. "
  147. @click="delRow(scope.row.id)"
  148. class="el-icon-delete elIcon"
  149. title="删除"
  150. ></i>
  151. <i
  152. v-if="scope.row.nowRunState != '10'"
  153. @click="downRow(scope.row)"
  154. class="el-icon-download elIcon"
  155. title="下载"
  156. ></i>
  157. </template>
  158. </el-table-column>
  159. </tableList>
  160. <el-dialog
  161. title="下载"
  162. :visible.sync="dialogVisible"
  163. width="690px"
  164. :close-on-click-modal="false"
  165. :close-on-press-escape="false"
  166. :before-close="cancelDown"
  167. >
  168. <div class="checkboxPanel">
  169. <el-checkbox-group v-model="downType">
  170. <el-checkbox
  171. label="工作报告"
  172. class="labelA"
  173. :disabled="downDisabled"
  174. ></el-checkbox>
  175. <el-checkbox label="任务文件包"></el-checkbox>
  176. </el-checkbox-group>
  177. </div>
  178. <span slot="footer">
  179. <el-button type="primary" @click="confirmDown"
  180. >确 定</el-button
  181. >
  182. <el-button @click="cancelDown">取 消</el-button>
  183. </span>
  184. </el-dialog>
  185. </div>
  186. <router-view v-else></router-view>
  187. </div>
  188. </template>
  189. <script>
  190. import searchLayout from "@/components/grid/searchLayout";
  191. import tableList from "@/components/grid/TableList";
  192. export default {
  193. name: "manualRunProjectList", // 手动运行项目列表
  194. components: { searchLayout, tableList },
  195. data() {
  196. return {
  197. searchParams: {
  198. //搜索参数
  199. projectId: "", //项目ID
  200. projectName: "", //项目名称
  201. nowRunState: "", //进度
  202. evaluationLevel: "", //测评等级
  203. createStartDate: "", //创建时间起
  204. createEndDate: "", //创建时间止
  205. finishDateStart: "", //完成时间起
  206. finishDateEnd: "", //完成时间止
  207. },
  208. nowRunStateList: [],
  209. evaluationLevelList: [],
  210. createDate: "",
  211. finishDate: "",
  212. columns: [
  213. {
  214. label: "项目ID",
  215. prop: "projectId",
  216. },
  217. {
  218. label: "项目名称",
  219. prop: "projectName",
  220. },
  221. {
  222. label: "算法名称",
  223. prop: "algorithm",
  224. },
  225. {
  226. label: "创建时间",
  227. prop: "createTimeFmt",
  228. },
  229. {
  230. label: "进度",
  231. prop: "nowRunStateDict",
  232. },
  233. {
  234. label: "评测等级",
  235. prop: "evaluationLevelDict",
  236. formatter(row) {
  237. switch (row.evaluationLevelDict) {
  238. case "G":
  239. return "优秀(G)";
  240. case "A":
  241. return "良好(A)";
  242. case "M":
  243. return "一般(M)";
  244. case "P":
  245. return "较差(P)";
  246. default:
  247. return "";
  248. }
  249. },
  250. },
  251. // {
  252. // label: "停/启用",
  253. // prop: "asd",
  254. // template: true,
  255. // },
  256. {
  257. label: "操作",
  258. prop: "cgInfos",
  259. template: true,
  260. },
  261. ],
  262. pagination: {
  263. //分页使用
  264. currentPage: 1,
  265. pageSize: 10,
  266. position: "right",
  267. pageSizes: [10, 30, 50, 100, 200],
  268. layout: "sizes, total, prev, pager, next, jumper",
  269. },
  270. getDataWay: {
  271. //加载表格数据
  272. dataType: "url",
  273. type: "post",
  274. // firstRequest: false,
  275. data: this.$api.workManagement.selectProject,
  276. param: {},
  277. },
  278. checkedArr: [],
  279. downType: [],
  280. dialogVisible: false,
  281. curRow: {}, // 当前row
  282. downDisabled: false, // 用于判断是否可下载工作报告
  283. timer: null,
  284. };
  285. },
  286. methods: {
  287. doSearch() {
  288. if (this.createDate) {
  289. this.searchParams.createStartDate = `${this.createDate[0]}`;
  290. this.searchParams.createEndDate = `${this.createDate[1]}`;
  291. } else {
  292. this.searchParams.createStartDate = "";
  293. this.searchParams.createEndDate = "";
  294. }
  295. if (this.finishDate) {
  296. this.searchParams.finishDateStart = `${this.finishDate[0]}`;
  297. this.searchParams.finishDateEnd = `${this.finishDate[1]}`;
  298. } else {
  299. this.searchParams.finishDateStart = "";
  300. this.searchParams.finishDateEnd = "";
  301. }
  302. let pageMap = {
  303. projectId: this.searchParams.projectId,
  304. projectName: this.searchParams.projectName,
  305. nowRunState: this.searchParams.nowRunState,
  306. evaluationLevel: this.searchParams.evaluationLevel,
  307. createStartDate: this.searchParams.createStartDate,
  308. createEndDate: this.searchParams.createEndDate,
  309. finishDateStart: this.searchParams.finishDateStart,
  310. finishDateEnd: this.searchParams.finishDateEnd,
  311. };
  312. this.refreshList(pageMap);
  313. if (this.timer) clearInterval(this.timer);
  314. this.timer = setInterval(() => {
  315. if (this.$refs["table"]) this.doSearch();
  316. }, 1000 * 60);
  317. },
  318. //刷新table
  319. refreshList(param) {
  320. param
  321. ? this.$refs["table"].loadData(param)
  322. : this.$refs["table"].loadData();
  323. },
  324. doReset() {
  325. this.searchParams = {
  326. projectId: "",
  327. projectName: "",
  328. nowRunState: "",
  329. evaluationLevel: "",
  330. createStartDate: "",
  331. createEndDate: "",
  332. finishDateStart: "",
  333. finishDateEnd: "",
  334. };
  335. this.createDate = "";
  336. this.finishDate = "";
  337. this.doSearch();
  338. },
  339. addOne() {
  340. this.$router.push({ path: "/manualRunProjectDetail" });
  341. },
  342. editRow(row) {
  343. this.$router.push({
  344. path: "/manualRunProjectDetail",
  345. query: {
  346. id: row.id,
  347. },
  348. });
  349. },
  350. runRow(id, parallelism) {
  351. this.$confirm("确认是否运行?", "提示", {
  352. confirmButtonText: "确定",
  353. cancelButtonText: "取消",
  354. type: "warning",
  355. }).then(() => {
  356. if (parallelism == "0") {
  357. this.$message.error("并行度为0,不能运行");
  358. return;
  359. }
  360. this.$axios({
  361. method: "post",
  362. url: this.$api.workManagement.updateProjectNowRunState,
  363. data: {
  364. id,
  365. nowRunState: "20",
  366. },
  367. }).then((res) => {
  368. if (res.code == 200) {
  369. this.$message.success("运行成功");
  370. } else {
  371. this.$message.error(res.message || "运行失败");
  372. }
  373. this.doSearch();
  374. });
  375. });
  376. },
  377. stopRow(id) {
  378. this.$confirm("确认是否中止?", "提示", {
  379. confirmButtonText: "确定",
  380. cancelButtonText: "取消",
  381. type: "warning",
  382. }).then(() => {
  383. this.$axios({
  384. method: "post",
  385. url: this.$api.workManagement.updateProjectNowRunState,
  386. data: {
  387. id,
  388. nowRunState: "40",
  389. },
  390. }).then((res) => {
  391. if (res.code == 200) {
  392. this.$message.success("中止成功");
  393. } else {
  394. this.$message.error(res.message || "中止失败");
  395. }
  396. this.doSearch();
  397. });
  398. });
  399. },
  400. delRow(ids) {
  401. this.$confirm("确认是否删除?", "提示", {
  402. confirmButtonText: "确定",
  403. cancelButtonText: "取消",
  404. type: "warning",
  405. }).then(() => {
  406. this.$axios({
  407. method: "post",
  408. url: this.$api.workManagement.deleteProjectByids,
  409. data: {
  410. ids,
  411. },
  412. }).then((res) => {
  413. if (res.code == 200) {
  414. this.$message.success("删除成功");
  415. } else {
  416. this.$message.error(res.message || "删除失败");
  417. }
  418. this.doSearch();
  419. });
  420. });
  421. },
  422. delRows() {
  423. let checkedArr = this.checkedArr;
  424. if (checkedArr.length <= 0) {
  425. this.$message.info("请先选择数据");
  426. return;
  427. }
  428. let arr = [];
  429. for (let index = 0; index < checkedArr.length; index++) {
  430. const row = checkedArr[index];
  431. if (row.nowRunState != "10") {
  432. this.$message.error("存在已执行数据,请重新选择");
  433. return;
  434. }
  435. arr.push(row.id);
  436. }
  437. this.delRow(arr.join(","));
  438. },
  439. viewRow(id) {
  440. this.$router.push({
  441. path: "/manualRunProjectList/projectInfo",
  442. query: { id, projectType: "1" },
  443. });
  444. },
  445. downRow(row) {
  446. this.curRow = row;
  447. this.downDisabled = row.nowRunState === "30" ? false : true;
  448. this.dialogVisible = true;
  449. },
  450. confirmDown() {
  451. let url = "";
  452. let fileName = this.curRow.projectName;
  453. if (this.downType.length === 0) {
  454. this.$message.info("请先选择下载类型");
  455. return;
  456. } else if (this.downType.length === 1) {
  457. if (this.downType[0] === "工作报告") {
  458. url = this.$api.workManagement.exportProjectReportById;
  459. fileName += ".pdf";
  460. } else {
  461. url = this.$api.workManagement.exportProjectTaskFileById;
  462. fileName += ".zip";
  463. }
  464. } else {
  465. url =
  466. this.$api.workManagement.exportProjectReportAndTaskFileById;
  467. fileName += ".zip";
  468. }
  469. let id = this.curRow.id;
  470. this.curRow = {};
  471. this.$axios({
  472. method: "post",
  473. url,
  474. responseType: "blob",
  475. data: {
  476. id,
  477. projectType: "1",
  478. },
  479. }).then((res) => {
  480. let blob = new Blob([res]);
  481. if ("download" in document.createElement("a")) {
  482. // 非IE下载
  483. let emlink = document.createElement("a");
  484. emlink.download = fileName;
  485. emlink.style.display = "none";
  486. emlink.href = URL.createObjectURL(blob);
  487. document.body.appendChild(emlink);
  488. emlink.click();
  489. URL.revokeObjectURL(emlink.href);
  490. document.body.removeChild(emlink);
  491. } else {
  492. // IE下载
  493. navigator.msSaveBlob(blob, fileName);
  494. }
  495. });
  496. this.downType = [];
  497. this.dialogVisible = false;
  498. },
  499. cancelDown() {
  500. this.downType = [];
  501. this.dialogVisible = false;
  502. },
  503. },
  504. async mounted() {
  505. if (this.timer) clearInterval(this.timer);
  506. this.timer = setInterval(() => {
  507. if (this.$refs["table"]) this.doSearch();
  508. }, 1000 * 60);
  509. // console.log(666);
  510. await this.$dicsListsInit({
  511. nowRunStateList: "projectRunState",
  512. evaluationLevelList: "evaluationLevel",
  513. });
  514. },
  515. beforeDestroy() {
  516. clearInterval(this.timer);
  517. },
  518. };
  519. </script>
  520. <style lang='less' scoped>
  521. .btnsPanel {
  522. margin: 45px 40px 15px;
  523. text-align: right;
  524. }
  525. .checkboxPanel {
  526. text-align: center;
  527. .labelA {
  528. margin-right: 60px;
  529. }
  530. }
  531. </style>