manualRunProjectList.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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. v-if="
  113. scope.row.nowRunState === '10' ||
  114. scope.row.nowRunState === '30' ||
  115. scope.row.nowRunState === '40'
  116. "
  117. @click="runRow(scope.row.id)"
  118. class="el-icon-video-play elIcon"
  119. title="运行"
  120. ></i>
  121. <i
  122. v-if="
  123. scope.row.nowRunState === '10' ||
  124. scope.row.nowRunState === '40'
  125. "
  126. @click="editRow(scope.row)"
  127. class="el-icon-edit-outline elIcon"
  128. title="编辑"
  129. ></i>
  130. <i
  131. @click="viewRow(scope.row.id)"
  132. class="el-icon-view elIcon"
  133. title="查看"
  134. ></i>
  135. <i
  136. v-if="scope.row.nowRunState === '20'"
  137. @click="stopRow(scope.row.id)"
  138. class="el-icon-video-pause 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">确 定</el-button>
  180. <el-button @click="cancelDown">取 消</el-button>
  181. </span>
  182. </el-dialog>
  183. </div>
  184. <router-view v-else></router-view>
  185. </div>
  186. </template>
  187. <script>
  188. import searchLayout from "@/components/grid/searchLayout";
  189. import tableList from "@/components/grid/TableList";
  190. export default {
  191. name: "manualRunProjectList", // 手动运行项目列表
  192. components: { searchLayout, tableList },
  193. data() {
  194. return {
  195. searchParams: {
  196. //搜索参数
  197. projectId: "", //项目ID
  198. projectName: "", //项目名称
  199. nowRunState: "", //进度
  200. evaluationLevel: "", //测评等级
  201. createStartDate: "", //创建时间起
  202. createEndDate: "", //创建时间止
  203. finishDateStart: "", //完成时间起
  204. finishDateEnd: "", //完成时间止
  205. },
  206. nowRunStateList: [],
  207. evaluationLevelList: [],
  208. createDate: "",
  209. finishDate: "",
  210. columns: [
  211. {
  212. label: "项目ID",
  213. prop: "projectId",
  214. },
  215. {
  216. label: "项目名称",
  217. prop: "projectName",
  218. },
  219. {
  220. label: "算法名称",
  221. prop: "algorithm",
  222. },
  223. {
  224. label: "创建时间",
  225. prop: "createTimeFmt",
  226. },
  227. {
  228. label: "进度",
  229. prop: "nowRunStateDict",
  230. },
  231. {
  232. label: "评测等级",
  233. prop: "evaluationLevelDict",
  234. },
  235. // {
  236. // label: "停/启用",
  237. // prop: "asd",
  238. // template: true,
  239. // },
  240. {
  241. label: "操作",
  242. prop: "cgInfos",
  243. template: true,
  244. },
  245. ],
  246. pagination: {
  247. //分页使用
  248. currentPage: 1,
  249. pageSize: 10,
  250. position: "right",
  251. pageSizes: [10, 30, 50, 100, 200],
  252. layout: "sizes, total, prev, pager, next, jumper",
  253. },
  254. getDataWay: {
  255. //加载表格数据
  256. dataType: "url",
  257. type: "post",
  258. // firstRequest: false,
  259. data: this.$api.workManagement.selectProject,
  260. param: {},
  261. },
  262. checkedArr: [],
  263. downType: [],
  264. dialogVisible: false,
  265. curRow: {}, // 当前row
  266. downDisabled: false, // 用于判断是否可下载工作报告
  267. };
  268. },
  269. methods: {
  270. doSearch() {
  271. if (this.createDate) {
  272. this.searchParams.createStartDate = `${this.createDate[0]}`;
  273. this.searchParams.createEndDate = `${this.createDate[1]}`;
  274. } else {
  275. this.searchParams.createStartDate = "";
  276. this.searchParams.createEndDate = "";
  277. }
  278. if (this.finishDate) {
  279. this.searchParams.finishDateStart = `${this.finishDate[0]}`;
  280. this.searchParams.finishDateEnd = `${this.finishDate[1]}`;
  281. } else {
  282. this.searchParams.finishDateStart = "";
  283. this.searchParams.finishDateEnd = "";
  284. }
  285. let pageMap = {
  286. projectId: this.searchParams.projectId,
  287. projectName: this.searchParams.projectName,
  288. nowRunState: this.searchParams.nowRunState,
  289. evaluationLevel: this.searchParams.evaluationLevel,
  290. createStartDate: this.searchParams.createStartDate,
  291. createEndDate: this.searchParams.createEndDate,
  292. finishDateStart: this.searchParams.finishDateStart,
  293. finishDateEnd: this.searchParams.finishDateEnd,
  294. };
  295. this.refreshList(pageMap);
  296. },
  297. //刷新table
  298. refreshList(param) {
  299. param
  300. ? this.$refs["table"].loadData(param)
  301. : this.$refs["table"].loadData();
  302. },
  303. doReset() {
  304. this.searchParams = {
  305. projectId: "",
  306. projectName: "",
  307. nowRunState: "",
  308. evaluationLevel: "",
  309. createStartDate: "",
  310. createEndDate: "",
  311. finishDateStart: "",
  312. finishDateEnd: "",
  313. };
  314. this.createDate = "";
  315. this.finishDate = "";
  316. this.doSearch();
  317. },
  318. addOne() {
  319. this.$router.push({ path: "/manualRunProjectDetail" });
  320. },
  321. editRow(row) {
  322. this.$router.push({
  323. path: "/manualRunProjectDetail",
  324. query: {
  325. id: row.id,
  326. },
  327. });
  328. },
  329. runRow(id) {
  330. this.$confirm("确认是否运行?", "提示", {
  331. confirmButtonText: "确定",
  332. cancelButtonText: "取消",
  333. type: "warning",
  334. }).then(() => {
  335. this.$axios({
  336. method: "post",
  337. url: this.$api.workManagement.updateProjectNowRunState,
  338. data: {
  339. id,
  340. nowRunState: "20",
  341. },
  342. }).then((res) => {
  343. if (res.code == 200) {
  344. this.$message.success("运行成功");
  345. } else {
  346. this.$message.error(res.message || "运行失败");
  347. }
  348. this.doSearch();
  349. });
  350. });
  351. },
  352. stopRow(id) {
  353. this.$confirm("确认是否中止?", "提示", {
  354. confirmButtonText: "确定",
  355. cancelButtonText: "取消",
  356. type: "warning",
  357. }).then(() => {
  358. this.$axios({
  359. method: "post",
  360. url: this.$api.workManagement.updateProjectNowRunState,
  361. data: {
  362. id,
  363. nowRunState: "40",
  364. },
  365. }).then((res) => {
  366. if (res.code == 200) {
  367. this.$message.success("中止成功");
  368. } else {
  369. this.$message.error(res.message || "中止失败");
  370. }
  371. this.doSearch();
  372. });
  373. });
  374. },
  375. delRow(ids) {
  376. this.$confirm("确认是否删除?", "提示", {
  377. confirmButtonText: "确定",
  378. cancelButtonText: "取消",
  379. type: "warning",
  380. }).then(() => {
  381. this.$axios({
  382. method: "post",
  383. url: this.$api.workManagement.deleteProjectByids,
  384. data: {
  385. ids,
  386. },
  387. }).then((res) => {
  388. if (res.code == 200) {
  389. this.$message.success("删除成功");
  390. } else {
  391. this.$message.error(res.message || "删除失败");
  392. }
  393. this.doSearch();
  394. });
  395. });
  396. },
  397. delRows() {
  398. let checkedArr = this.checkedArr;
  399. if (checkedArr.length <= 0) {
  400. this.$message.info("请先选择数据");
  401. return;
  402. }
  403. let arr = [];
  404. for (let index = 0; index < checkedArr.length; index++) {
  405. const row = checkedArr[index];
  406. if (row.nowRunState != "10") {
  407. this.$message.error("存在已执行数据,请重新选择");
  408. return;
  409. }
  410. arr.push(row.id);
  411. }
  412. this.delRow(arr.join(","));
  413. },
  414. viewRow(id) {
  415. this.$router.push({ path: "/manualRunProjectList/projectInfo", query: { id } });
  416. },
  417. downRow(row) {
  418. this.curRow = row;
  419. this.downDisabled = row.nowRunState === "30" ? false : true;
  420. this.dialogVisible = true;
  421. },
  422. confirmDown() {
  423. let url = "";
  424. let fileName = this.curRow.projectName;
  425. if (this.downType.length === 0) {
  426. this.$message.info("请先选择下载类型");
  427. return;
  428. } else if (this.downType.length === 1) {
  429. if (this.downType[0] === "工作报告") {
  430. url = this.$api.workManagement.exportProjectReportById;
  431. fileName += ".pdf";
  432. } else {
  433. url = this.$api.workManagement.exportProjectTaskFileById;
  434. fileName += ".zip";
  435. }
  436. } else {
  437. url =
  438. this.$api.workManagement.exportProjectReportAndTaskFileById;
  439. fileName += ".zip";
  440. }
  441. let id = this.curRow.id;
  442. this.curRow = {};
  443. this.$axios({
  444. method: "post",
  445. url,
  446. responseType: "blob",
  447. data: {
  448. id,
  449. },
  450. }).then((res) => {
  451. let blob = new Blob([res]);
  452. if ("download" in document.createElement("a")) {
  453. // 非IE下载
  454. let emlink = document.createElement("a");
  455. emlink.download = fileName;
  456. emlink.style.display = "none";
  457. emlink.href = URL.createObjectURL(blob);
  458. document.body.appendChild(emlink);
  459. emlink.click();
  460. URL.revokeObjectURL(emlink.href);
  461. document.body.removeChild(emlink);
  462. } else {
  463. // IE下载
  464. navigator.msSaveBlob(blob, fileName);
  465. }
  466. });
  467. this.downType = [];
  468. this.dialogVisible = false;
  469. },
  470. cancelDown() {
  471. this.downType = [];
  472. this.dialogVisible = false;
  473. },
  474. },
  475. async mounted() {
  476. console.log(666);
  477. await this.$dicsListsInit({
  478. nowRunStateList: "projectRunState",
  479. evaluationLevelList: "evaluationLevel",
  480. });
  481. console.log(this.$route);
  482. },
  483. activated(){
  484. console.log(6);
  485. }
  486. };
  487. </script>
  488. <style lang='less' scoped>
  489. .btnsPanel {
  490. margin: 45px 40px 15px;
  491. text-align: right;
  492. }
  493. .checkboxPanel {
  494. text-align: center;
  495. .labelA {
  496. margin-right: 60px;
  497. }
  498. }
  499. </style>