Commit 06869a45119d0717c12e67393b00d7e72c9fa9cc

Authored by LH_PC
1 parent 45b98e8e

fix:修改测验时长显示不对的逻辑

.gitignore
... ... @@ -27,3 +27,4 @@ pnpm-debug.log*
27 27 *.sw?
28 28 src/views/portrait/test.vue
29 29 /src/.vs
  30 +/.vs
... ...
src/utils/index.js
... ... @@ -411,6 +411,26 @@ export function formatDate(date, fmt) {
411 411 return time_str;
412 412 }
413 413  
  414 +export function formatTimeWithHours(seconds) {
  415 + if (!seconds || seconds <= 0) return "0秒";
  416 + const hours = Math.floor(seconds / 3600);
  417 + const minutes = Math.floor((seconds % 3600) / 60);
  418 + const sec = seconds % 60;
  419 +
  420 + // 根据是否有小时动态调整格式
  421 + var ret = '';
  422 + if (hours > 0) {
  423 + ret += hours + "小时";
  424 + }
  425 + if (minutes > 0) {
  426 + ret += minutes + "分钟";
  427 + }
  428 + if (sec > 0) {
  429 + ret += sec + "秒";
  430 + }
  431 + return ret;
  432 +}
  433 +
414 434 // 获取日期时间戳
415 435 export function getTime(dayNum) {
416 436 var myDate = new Date();
... ... @@ -1266,12 +1286,12 @@ export function tablePrint(options) {
1266 1286 }
1267 1287  
1268 1288 let pagedoc = awin.document.createElement('div')
1269   - pagedoc.className = "page-number"
1270   - awin.document.body.append(pagedoc)
1271   - awin.document.body.append(aDom);
1272   -
1273   - let pagedom = awin.document.querySelectorAll('.page-number');
1274   -
  1289 + pagedoc.className = "page-number"
  1290 + awin.document.body.append(pagedoc)
  1291 + awin.document.body.append(aDom);
  1292 +
  1293 + let pagedom = awin.document.querySelectorAll('.page-number');
  1294 +
1275 1295 awin.print();
1276 1296  
1277 1297 awin.close()
... ...
src/views/basic/askTestQuestion/components/testBzrMulti.vue
... ... @@ -21,7 +21,11 @@
21 21 {{ `${scoped.row.answeredNum}/${scoped.row.classPersonNum}` }}
22 22 </template>
23 23 </el-table-column>
24   - <el-table-column prop="examStartTime" label="测验时长"></el-table-column>
  24 + <el-table-column label="测验时长">
  25 + <template slot-scope="scoped">
  26 + {{ _formatTimeWithHours(scoped.row.duration) }}
  27 + </template>
  28 + </el-table-column>
25 29 </el-table>
26 30 </el-row>
27 31 </div>
... ... @@ -29,8 +33,8 @@
29 33 <el-container style="height: 100%;width: 100%;">
30 34 <el-main id="print-content">
31 35 <el-row class="row-type print-hidden">
32   - <div style="float: left;">
33   - <el-button @click="_backa">返回</el-button>
  36 + <div style="float: left;">
  37 + <el-button @click="_backa">返回</el-button>
34 38 </div>
35 39 <div style="float: right;">
36 40 <el-button type="primary" @click="_import" class="opration-btn"
... ... @@ -52,37 +56,37 @@
52 56 <el-table-column :prop="'examCount' + item" label="测练数"
53 57 :class-name="index % 2 == 0 ? 'bg' : ''">
54 58 <template slot-scope="scoped">{{
55   - scoped.row["examCount" + item] ||
56   - Number(scoped.row["examCount" + item]) === 0
57   - ? scoped.row["examCount" + item]
58   - : "-"
59   - }}</template>
  59 + scoped.row["examCount" + item] ||
  60 + Number(scoped.row["examCount" + item]) === 0
  61 + ? scoped.row["examCount" + item]
  62 + : "-"
  63 + }}</template>
60 64 </el-table-column>
61 65 <el-table-column :prop="'participationCount' + item" label="参与数"
62 66 :class-name="index % 2 == 0 ? 'bg' : ''">
63 67 <template slot-scope="scoped">{{
64   - scoped.row["participationCount" + item] ||
65   - Number(scoped.row["participationCount" + item]) === 0
66   - ? scoped.row["participationCount" + item]
67   - : "-"
68   - }}</template>
  68 + scoped.row["participationCount" + item] ||
  69 + Number(scoped.row["participationCount" + item]) === 0
  70 + ? scoped.row["participationCount" + item]
  71 + : "-"
  72 + }}</template>
69 73 </el-table-column>
70 74 <el-table-column :prop="'score' + item" label="总分"
71 75 :class-name="index % 2 == 0 ? 'bg' : ''">
72 76 <template slot-scope="scoped">{{
73   - scoped.row["score" + item] ||
74   - Number(scoped.row["score" + item]) === 0
75   - ? scoped.row["score" + item]
76   - : "-"
77   - }}</template>
  77 + scoped.row["score" + item] ||
  78 + Number(scoped.row["score" + item]) === 0
  79 + ? scoped.row["score" + item]
  80 + : "-"
  81 + }}</template>
78 82 </el-table-column>
79 83 <el-table-column :prop="'classRank' + item" label="班名"
80 84 :class-name="index % 2 == 0 ? 'bg' : ''">
81 85 <template slot-scope="scoped">{{
82   - scoped.row["classRank" + item] ||
83   - Number(scoped.row["classRank" + item]) === 0
84   - ? scoped.row["classRank" + item]
85   - : "-"
  86 + scoped.row["classRank" + item] ||
  87 + Number(scoped.row["classRank" + item]) === 0
  88 + ? scoped.row["classRank" + item]
  89 + : "-"
86 90 }}</template>
87 91 </el-table-column>
88 92 </el-table-column>
... ... @@ -93,7 +97,7 @@
93 97 </el-table-column>
94 98 </el-table>
95 99 </el-row>
96   - </el-main>
  100 + </el-main>
97 101 </el-container>
98 102  
99 103 </div>
... ... @@ -106,7 +110,7 @@
106 110 </div>
107 111 </template>
108 112 <script>
109   -import { formatDate } from "utils";
  113 +import { formatDate, formatTimeWithHours } from "utils";
110 114 import { downloadFile, tablePrint } from "@/utils";
111 115 import RadarChart from "@/components/charts/radarChart";
112 116 export default {
... ... @@ -168,6 +172,9 @@ export default {
168 172 async created() {
169 173 },
170 174 methods: {
  175 + _formatTimeWithHours(seconds) {
  176 + return formatTimeWithHours(seconds);
  177 + },
171 178 _print() {
172 179 tablePrint({
173 180 id: "print-content",
... ... @@ -177,7 +184,7 @@ export default {
177 184 fixedColumn: 2,
178 185 diffNumber: 2,
179 186 diffStNumber: 15
180   - });
  187 + });
181 188 },
182 189 _checkAll() {
183 190 // this.multipleSelection = [...]
... ... @@ -291,7 +298,7 @@ export default {
291 298 max = score > max ? score : max;
292 299 return item.subjectName;
293 300 });
294   - max += 10;
  301 + max += 10;
295 302 this.radarChart = {
296 303 indicator: [
297 304 {
... ... @@ -338,7 +345,7 @@ export default {
338 345 ];
339 346  
340 347 this.radarChart.title = obj.studentName + "-多科阶段作答表现图";
341   -
  348 +
342 349 this.redarVisible = true;
343 350 },
344 351 async _loadData() {
... ...
src/views/basic/askTestQuestion/components/testListReport.vue
... ... @@ -7,9 +7,13 @@
7 7 <el-table-column prop="examPaperScore" label="卷面分" width="130" />
8 8 <el-table-column prop="classCorrectRate" label="测验人数/班级人数" width="180">
9 9 <template slot-scope="scoped">{{ `${scoped.row.answeredNum}/${scoped.row.classPersonNum}` }}</template>
  10 + </el-table-column>>z
  11 + <el-table-column label="测验时长" width="130" >
  12 + <template slot-scope="scoped">
  13 + {{ _formatTimeWithHours(scoped.row.duration) }}
  14 + </template>
10 15 </el-table-column>
11   - <el-table-column prop="questionNum" label="测验时长" width="130" />
12   - <el-table-column prop="createdTime" label="测验开始时间" width="210" />
  16 + <el-table-column prop="examStartTime" label="测验开始时间" width="210" />
13 17 <el-table-column label="操作" width="240">
14 18 <template slot-scope="scoped">
15 19 <el-button style="margin-right: 10px;" v-if="scoped.row.answerNum != 0 ||
... ... @@ -50,6 +54,7 @@
50 54 </template>
51 55 <script>
52 56 import ScoreSet from "../../test/components/scoreSet.vue";
  57 +import { formatTimeWithHours } from "utils";
53 58 export default {
54 59 name: "testListReport",
55 60 props: {
... ... @@ -89,6 +94,9 @@ export default {
89 94  
90 95 },
91 96 methods: {
  97 + _formatTimeWithHours(seconds){
  98 + return formatTimeWithHours(seconds);
  99 + },
92 100 _linkToDetail(dataRow) {
93 101 this.$router.push({
94 102 path: "/testReportDetail",
... ...
vue.config.js
... ... @@ -26,8 +26,8 @@ module.exports = {
26 26 // target:"http://ezquiz.sunvotecloud.cn",
27 27 // target:"http://192.168.1.151:8089",
28 28 // target: "https://ezquiz.sunvotecloud.cn",
29   - target: "http://121.40.127.171:8090",
30   - // target:"http://127.0.0.1:8089",
  29 + // target: "http://121.40.127.171:8090",
  30 + target:"http://127.0.0.1:8089",
31 31 changeOrigin: true,
32 32 ws: true,
33 33 },
... ...