FunctionalTestDetail.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <div>
  3. <page-header
  4. :loading="testDetailLoading"
  5. :routes="[
  6. { name: '代码作业', path: 'code' },
  7. { name: '项目列表', path: `code/${$route.params.homeworkId}` },
  8. {
  9. name: '项目详情',
  10. path: `code/${$route.params.homeworkId}/${
  11. $route.params.projectId
  12. }/test`
  13. },
  14. { name: '页面测试' }
  15. ]"
  16. >
  17. <template slot="title">
  18. 页面测试 #{{ testDetail.id }}
  19. </template>
  20. <template slot="content">
  21. <pass-tag :pass="testDetail.passAll" />
  22. </template>
  23. <template slot="extraContent">
  24. <div class="tag">{{ displayUnixTime(testDetail.time) }}</div>
  25. </template>
  26. </page-header>
  27. <page-body>
  28. <div v-if="testDetailLoading"><page-section-loading show /></div>
  29. <div v-else>
  30. <div class="gap-section">
  31. <div class="page-section">
  32. <a class="button is-small is-info" @click="showLog = !showLog">{{
  33. showLog ? "收起控制台信息" : "查看控制台输出"
  34. }}</a>
  35. <div class="console-section" v-if="showLog">
  36. {{ testDetail.consoleOutput }}
  37. </div>
  38. </div>
  39. </div>
  40. <div
  41. v-for="item in testDetail.detail"
  42. :key="item.id"
  43. class="gap-section"
  44. >
  45. <div class="page-section">
  46. <div>
  47. <pass-tag :pass="item.pass" />
  48. <strong style="padding-left: 10px">
  49. 页面测试用例 : #{{ item.id }}
  50. </strong>
  51. </div>
  52. <div v-if="!item.pass" class="code-section">
  53. {{ item.message }} <br />
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </page-body>
  59. </div>
  60. </template>
  61. <script>
  62. import PageHeader from "@/components/PageHeader";
  63. import PageBody from "@/components/PageBody/index";
  64. import { getFunctionalDetail } from "@/api/codehw";
  65. import timeMixins from "@/mixins/time";
  66. import PassTag from "@/views/student/Code/ProjectDetail/components/PassTag";
  67. import PageSectionLoading from "@/components/PageBody/PageSectionLoading/index";
  68. export default {
  69. components: { PageSectionLoading, PassTag, PageBody, PageHeader },
  70. data() {
  71. return {
  72. testDetail: { detail: [] },
  73. testDetailLoading: false,
  74. showLog: false
  75. };
  76. },
  77. mixins: [timeMixins],
  78. mounted() {
  79. const { functionalTestId } = this.$route.params;
  80. this.testDetailLoading = true;
  81. getFunctionalDetail(functionalTestId).then(value => {
  82. this.testDetail = value.data;
  83. this.testDetailLoading = false;
  84. });
  85. }
  86. };
  87. </script>
  88. <style lang="scss" scoped>
  89. @import "../../../../../assets/scss/app";
  90. .gap-section {
  91. padding-bottom: $default-margin-between;
  92. }
  93. .gap-section:last-child {
  94. padding-bottom: 0;
  95. }
  96. .code-section {
  97. margin: $default-margin-between -#{$default-margin-between} -#{$default-margin-between};
  98. padding: $default-margin-between;
  99. background-color: #2d3044;
  100. color: #cacff1;
  101. }
  102. .console-section {
  103. padding: $default-margin-between $default-margin-between * 1.5;
  104. background-color: #2d3044;
  105. color: #cacff1;
  106. white-space: pre-line;
  107. }
  108. </style>