-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from zjutjh/dev
Dev
- Loading branch information
Showing
5 changed files
with
166 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "text-ci", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"private": true, | ||
"type": "module", | ||
"scripts": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<template> | ||
<div> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>序号</th> | ||
<th>时间</th> | ||
<th v-for="ans in answers"> | ||
{{ ans.title }} | ||
<el-tag type="primary" size="small" class="ml-3">{{ answersType.get(ans.question_type) }}</el-tag> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="(t, index) in time"> | ||
<th>{{ index+1 }}</th> | ||
<th>{{ t }}</th> | ||
<th v-for="ans in answers">{{ ans.answers[index] }}</th> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<el-pagination | ||
:current-page="pageNum" | ||
layout="prev, pager, next" | ||
:page-count="totalPageNum" | ||
@current-change="handleCurrentChange" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import {ElNotification, ElPagination} from 'element-plus'; | ||
import { getAnswersAPI } from '@/apis'; | ||
import { ref, watch } from 'vue'; | ||
import { useMainStore } from '@/stores'; | ||
import { useRequest } from 'vue-hooks-plus'; | ||
const tempStore = useMainStore().useTempStore(); | ||
const props = defineProps<{ | ||
keyText: string, | ||
isUnique: boolean, | ||
}>(); | ||
const answersType = new Map([ | ||
[1, '单选'], | ||
[2, '多选'], | ||
[3, '填空'], | ||
[4, '简答'], | ||
[5, '图片'], | ||
]); | ||
const handleCurrentChange = (val: number) => { | ||
pageNum.value = val; | ||
getAnswers(); | ||
} | ||
const pageNum = ref(1); | ||
const totalPageNum = ref(2); | ||
const pageSize = ref(10); | ||
const answers = ref(); | ||
const time = ref(); | ||
const getAnswers = () => { | ||
useRequest(() => getAnswersAPI({ | ||
id: tempStore.checkId, | ||
page_num: pageNum.value, | ||
page_size: pageSize.value, | ||
text: props.keyText === "" ? undefined : props.keyText, | ||
unique: props.isUnique, | ||
}), { | ||
debounceWait: 400, | ||
onSuccess(res: any) { | ||
console.log(res); | ||
if(res.code === 200) { | ||
totalPageNum.value = res.data.total_page_num; | ||
answers.value = res.data.answers_data.question_answers; | ||
time.value = res.data.answers_data.time; | ||
} | ||
}, | ||
onError(e: any) { | ||
ElNotification.error('获取失败,请重试' + e); | ||
}, | ||
}) | ||
} | ||
getAnswers(); | ||
watch(props, getAnswers); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<template> | ||
<div> | ||
<div class="gap-8 m-5 grid grid-cols-2 mt-30"> | ||
<n-card v-for="obj in staticsData" v-bind:key='obj'> | ||
<div class="font-bold">{{ obj.serial_num }}. {{ obj.question }}</div> | ||
<div v-for="opt in obj.options" class="m-6"> | ||
<div class="relative border rounded"> | ||
<span class="ml-4">{{ opt.content }}</span> | ||
<span class="absolute right-4">{{ (opt.count/totalNum*100).toFixed(2) }}%</span> | ||
<div class="inline absolute left-0 rounded bg-cyan-400 h-full opacity-15" :style="{width: 100*opt.count/totalNum+'%'}"></div> | ||
</div> | ||
</div> | ||
</n-card> | ||
</div> | ||
<el-pagination | ||
:current-page="pageNum" | ||
layout="prev, pager, next" | ||
:page-count="totalPageNum" | ||
@current-change="handleCurrentChange" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { useRequest } from 'vue-hooks-plus'; | ||
import { getStaticsDataAPI } from '@/apis'; | ||
import { useMainStore } from '@/stores'; | ||
import {ElNotification, ElPagination} from 'element-plus'; | ||
import { ref } from 'vue'; | ||
import { NCard } from 'naive-ui'; | ||
const tempStore = useMainStore().useTempStore(); | ||
const pageNum = ref(1); | ||
const pageSize = 8; | ||
const totalPageNum = ref(); | ||
const totalNum = ref(); | ||
const staticsData = ref(); | ||
const handleCurrentChange = (val: number) => { | ||
pageNum.value = val; | ||
getAnswers(); | ||
} | ||
const getAnswers = () => { | ||
useRequest(() => getStaticsDataAPI({ | ||
id: tempStore.checkId, | ||
page_num: pageNum.value, | ||
page_size: pageSize, | ||
}), { | ||
onSuccess(res: any) { | ||
if(res.code === 200) { | ||
staticsData.value = res.data.statistics; | ||
totalNum.value = res.data.total; | ||
totalPageNum.value = res.data.total_sum_page; | ||
} | ||
}, | ||
onError(e: any) { | ||
ElNotification.error('获取失败,请重试' + e); | ||
} | ||
}) | ||
} | ||
getAnswers(); | ||
</script> |