ComputeJobList.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <section class="content">
  3. <div class="box box-info">
  4. <div
  5. class="box-body"
  6. v-loading.body="loading"
  7. v-loading.fullscreen="loading"
  8. element-loading-text="请稍后..."
  9. >
  10. <!-- 表单 -->
  11. <el-form inline :model="formSearch">
  12. <el-form-item>
  13. <el-button
  14. size="small"
  15. type="primary"
  16. icon="el-icon-search"
  17. @click="handleSearchBtn"
  18. >
  19. 刷新
  20. </el-button>
  21. <el-button size="small" type="primary" @click="back">
  22. 返回
  23. </el-button>
  24. </el-form-item>
  25. </el-form>
  26. <div class="block-seperator"></div>
  27. <!-- 页面列表 -->
  28. <el-table
  29. :data="tableData"
  30. border
  31. resizable
  32. stripe
  33. style="width: 100%;"
  34. >
  35. <el-table-column width="50" label="ID">
  36. <span slot-scope="scope">{{ scope.row.id }}</span>
  37. </el-table-column>
  38. <el-table-column width="120" prop="statusName" label="状态">
  39. </el-table-column>
  40. <el-table-column width="180" prop="creationTime" label="任务生成时间">
  41. </el-table-column>
  42. <el-table-column width="180" prop="startTime" label="计算开始时间">
  43. </el-table-column>
  44. <el-table-column width="180" prop="endTime" label="计算结束时间">
  45. </el-table-column>
  46. <el-table-column prop="errorDesc" label="错误信息"> </el-table-column>
  47. <el-table-column :context="_self" label="操作" width="120">
  48. <div slot-scope="scope">
  49. <el-button
  50. size="mini"
  51. type="danger"
  52. plain
  53. :disabled="disStopJob(scope.row)"
  54. @click="stopJob(scope.row)"
  55. >
  56. 终止计算
  57. </el-button>
  58. </div>
  59. </el-table-column>
  60. </el-table>
  61. <div class="page pull-right">
  62. <el-pagination
  63. v-if="paginationShow"
  64. @current-change="handleCurrentChange"
  65. :current-page="currentPage"
  66. :page-size="pageSize"
  67. :page-sizes="[10, 20, 50, 100]"
  68. @size-change="handleSizeChange"
  69. layout="total, sizes, prev, pager, next, jumper"
  70. :total="total"
  71. />
  72. </div>
  73. </div>
  74. </div>
  75. </section>
  76. </template>
  77. <script>
  78. import { TASK_API } from "@/constants/constants.js";
  79. import { mapState } from "vuex";
  80. export default {
  81. name: "ComputeJobList",
  82. data() {
  83. return {
  84. loading: false,
  85. paginationShow: false,
  86. formSearch: {
  87. projectId: ""
  88. },
  89. tableData: [],
  90. currentPage: 1,
  91. pageSize: 10,
  92. total: 10
  93. };
  94. },
  95. computed: {
  96. ...mapState({ user: state => state.user }),
  97. isSuperAdmin() {
  98. return this.user.roleList.some(role => role.roleCode == "SUPER_ADMIN");
  99. }
  100. },
  101. methods: {
  102. back() {
  103. this.$router.push({
  104. path: "/reports/overview"
  105. });
  106. },
  107. disStopJob(row) {
  108. if (row.status != "NONE" && row.status != "COMPUTING") {
  109. return true;
  110. } else {
  111. return false;
  112. }
  113. },
  114. stopJob(row) {
  115. this.loading = true;
  116. let url = TASK_API + "/reportsCompute/stopJob/" + row.id;
  117. this.$httpWithMsg
  118. .post(url)
  119. .then(() => {
  120. this.$notify({
  121. type: "success",
  122. message: "操作成功!"
  123. });
  124. this.searchForm();
  125. })
  126. .finally(() => (this.loading = false));
  127. },
  128. handleSearchBtn() {
  129. this.currentPage = 1;
  130. this.searchForm();
  131. },
  132. handleSizeChange(val) {
  133. this.pageSize = val;
  134. this.currentPage = 1;
  135. this.searchForm();
  136. },
  137. handleCurrentChange(val) {
  138. this.currentPage = val;
  139. this.searchForm();
  140. },
  141. //查询
  142. searchForm() {
  143. this.loading = true;
  144. var url =
  145. TASK_API +
  146. "/reportsCompute/page/" +
  147. this.formSearch.projectId +
  148. "/" +
  149. this.currentPage +
  150. "/" +
  151. this.pageSize;
  152. this.$httpWithMsg
  153. .get(url, { params: this.formSearch })
  154. .then(response => {
  155. this.tableData = response.data.list;
  156. this.total = response.data.total;
  157. this.loading = false;
  158. this.$nextTick(function() {
  159. this.paginationShow = true;
  160. });
  161. })
  162. .finally(() => (this.loading = false));
  163. },
  164. init() {
  165. this.searchForm();
  166. }
  167. },
  168. //初始化查询
  169. created() {
  170. this.formSearch.projectId = this.$route.params.projectId;
  171. this.init();
  172. }
  173. };
  174. </script>
  175. <style scoped>
  176. .page {
  177. margin-top: 10px;
  178. }
  179. .pull-length {
  180. width: 100px;
  181. }
  182. .details-length {
  183. width: 400px;
  184. }
  185. .pull-center {
  186. margin-top: 20px;
  187. }
  188. .editForm .el-form-item {
  189. margin-bottom: 12px;
  190. }
  191. .partition-main-left-div {
  192. width: 300px;
  193. padding: 5px;
  194. float: left;
  195. border: 1px solid #ddd;
  196. margin-left: 5px;
  197. }
  198. .partition-main-rigth-div {
  199. width: 200px;
  200. padding: 5px;
  201. float: right;
  202. border: 1px solid #ddd;
  203. margin-right: 5px;
  204. }
  205. .partition-detail-div {
  206. margin-top: 5px;
  207. }
  208. </style>