Browse Source

fix types

Michael Wang 3 years ago
parent
commit
f14e652291

+ 5 - 4
src/api/paperAnalysisPage.ts

@@ -1,13 +1,14 @@
 import { httpApp } from "@/plugins/axiosApp";
+import { SASQuestion, SASPaper, Paper, SASQuestionGroup } from "@/types";
 
 /** 试卷查询 */
 export function getPaper(id: number) {
-  return httpApp.post("/api/ess/paper/" + id);
+  return httpApp.post<any, { data: Paper }>("/api/ess/paper/" + id);
 }
 
 /** 试卷分析-查询指定试卷全卷信息 */
 export function getSasPaper(id: number) {
-  return httpApp.post(
+  return httpApp.post<any, { data: SASPaper }>(
     "/api/ess/sasPaper/findOne",
     new URLSearchParams([["paperId", id + ""]])
   );
@@ -15,7 +16,7 @@ export function getSasPaper(id: number) {
 
 /** 试题题目编排,试卷特征量数,试题难度分组分布 */
 export function getPaperQuestions(paperId: number) {
-  return httpApp.post(
+  return httpApp.post<any, { data: SASQuestion[] }>(
     "/api/ess/sasQuestion/list",
     new URLSearchParams([["paperId", paperId + ""]])
   );
@@ -23,7 +24,7 @@ export function getPaperQuestions(paperId: number) {
 
 /** 题型难度分布、题型区分度分布 */
 export function getPaperQuestionGroups(projectId: number, paperId: number) {
-  return httpApp.post(
+  return httpApp.post<any, { data: SASQuestionGroup[] }>(
     "/api/ess/sasQuestionGroup/list",
     new URLSearchParams([
       ["projectId", projectId + ""],

+ 5 - 1
src/api/projectManagementPage.ts

@@ -1,5 +1,6 @@
 import { httpApp } from "@/plugins/axiosApp";
 import { responseToFile } from "@/utils/utils";
+import { ProjectResponse } from "@/types";
 
 /** 项目分页查询 */
 export function getProjectList(params: {
@@ -10,7 +11,10 @@ export function getProjectList(params: {
   pageNo?: number;
   pageSize?: number;
 }) {
-  return httpApp.post("/api/ess/project/page", params);
+  return httpApp.post<any, { data: ProjectResponse }>(
+    "/api/ess/project/page",
+    params
+  );
 }
 
 /** 更新项目 */

+ 2 - 2
src/features/paperAnalysis/DiscriminationDistriTable.vue

@@ -78,7 +78,7 @@
 </template>
 
 <script setup lang="ts">
-import { QuestionGroup } from "@/types";
+import { SASQuestionGroup } from "@/types";
 
-const props = defineProps<{ questions: QuestionGroup[] }>();
+const props = defineProps<{ questions: SASQuestionGroup[] }>();
 </script>

+ 34 - 27
src/features/paperAnalysis/PaperAnalysis.vue

@@ -2,22 +2,18 @@
   <div>
     <div class="tw-bg-white tw-p-5 tw-rounded-xl tw-mb-5">
       <ProjectSelect
-        disabled
-        :project-id="projectId"
         v-model:value="projectId"
-      />
-      <span class="tw-mr-4"></span>
-      <CourseSelect
         disabled
-        :root-org-id="rootOrgId"
-        v-model:value="courseId"
+        :projectId="projectId"
       />
       <span class="tw-mr-4"></span>
-      <PaperTypeSelect disabled v-model:value="paperType" />
+      <CourseSelect v-model:value="courseId" disabled :rootOrgId="rootOrgId" />
+      <span class="tw-mr-4"></span>
+      <PaperTypeSelect v-model:value="paperType" disabled />
       <span class="tw-mr-4"></span>
       试卷名称: <a-input disabled :value="paperName" style="width: 120px" />
       <span class="tw-mr-4"></span>
-      <a-button @click="search" class="query-btn">查询</a-button>
+      <a-button class="query-btn" @click="search">查询</a-button>
 
       <div class="tw-float-right">
         <a-button @click="goBack">返回</a-button>
@@ -42,13 +38,13 @@
       </div>
       <div v-if="activeTab === '3'">
         <QuestionTypeDifficulty
-          :project-id="projectId"
+          :projectId="projectId"
           :questions="paperQuestionGroups"
         />
       </div>
       <div v-if="activeTab === '4'">
         <QuestionTypeDiscrimination
-          :project-id="projectId"
+          :projectId="projectId"
           :questions="paperQuestionGroups"
         />
       </div>
@@ -56,10 +52,10 @@
         <QuestionDifficultyGroup
           :questions="paperQuestions"
           :totalScore="paper.totalScore"
-          :project-id="projectId"
+          :projectId="projectId"
           :courseId="courseId"
           :paperId="paperId"
-          :range-config="paper.difficulityRangeConfig"
+          :rangeConfig="paper.difficulityRangeConfig"
         />
       </div>
     </div>
@@ -69,7 +65,7 @@
 <script setup lang="ts">
 import { useMainStore } from "@/store";
 import { goBack } from "@/utils/utils";
-import { watch, onMounted, ref, toRaw } from "vue";
+import { watch, onMounted } from "vue";
 import { useRoute } from "vue-router";
 import ProjectSelect from "@/components/ProjectSelect.vue";
 import {
@@ -83,6 +79,7 @@ import QuestionAttr from "./QuestionAttr.vue";
 import QuestionDifficultyGroup from "./QuestionDifficultyGroup.vue";
 import QuestionTypeDifficulty from "./QuestionTypeDifficulty.vue";
 import QuestionTypeDiscrimination from "./QuestionTypeDiscrimination.vue";
+import { Paper, SASQuestion, SASQuestionGroup } from "@/types";
 
 const store = useMainStore();
 store.currentLocation = "项目管理 / 项目列表 / 试卷分析";
@@ -97,13 +94,13 @@ const route = useRoute();
 const projectId = +route.params.projectId;
 const paperId = +route.params.paperId;
 
-let paper = $ref({});
+let paper = $ref<Paper>({} as Paper);
 let pageSize = $ref(10);
 let pageNo = $ref(1);
 
-let paperQuestions = $ref([]);
-let paperQuestionGroups = $ref([]);
-let sasPaper = $ref({});
+let paperQuestions = $ref<SASQuestion[]>([]);
+let paperQuestionGroups = $ref<SASQuestionGroup[]>([]);
+// let sasPaper = $ref<SASPaper>({} as SASPaper);
 
 async function search() {
   pageNo = 1;
@@ -122,8 +119,12 @@ async function fetchData() {
 
   const res2 = await getPaperQuestions(paperId);
   res2.data = res2.data.map((q) => {
-    q.difficulityLevel = JSON.parse(q.difficulityLevel || "[]");
-    q.difficulityGroupLevel = JSON.parse(q.difficulityGroupLevel || "[]");
+    q.difficulityLevel = JSON.parse(
+      <string>(<unknown>q.difficulityLevel) || "[]"
+    );
+    q.difficulityGroupLevel = JSON.parse(
+      <string>(<unknown>q.difficulityGroupLevel) || "[]"
+    );
     q.avgScore = Math.round(q.avgScore * 100) / 100;
     q.stdev = Math.round(q.stdev * 100) / 100;
     q.coefficient = Math.round(q.coefficient * 100) / 100;
@@ -134,20 +135,26 @@ async function fetchData() {
   paperQuestions = res2.data;
 
   const res4 = await getSasPaper(paperId);
-  res4.data.difficulityLevel = JSON.parse(res4.data.difficulityLevel || "[]");
+  res4.data.difficulityLevel = JSON.parse(
+    <string>(<unknown>res4.data.difficulityLevel) || "[]"
+  );
   res4.data.discriminationLevel = JSON.parse(
-    res4.data.discriminationLevel || "[]"
+    <string>(<unknown>res4.data.discriminationLevel) || "[]"
   );
-  // console.log(res4.data);
-  sasPaper = res4.data;
+  // // console.log(res4.data);
+  // sasPaper = res4.data;
 
   const res3 = await getPaperQuestionGroups(projectId, paperId);
   res3.data = res3.data.map((q) => {
-    q.difficulityLevel = JSON.parse(q.difficulityLevel || "[]");
-    q.discriminationLevel = JSON.parse(q.discriminationLevel || "[]");
+    q.difficulityLevel = JSON.parse(
+      <string>(<unknown>q.difficulityLevel) || "[]"
+    );
+    q.discriminationLevel = JSON.parse(
+      <string>(<unknown>q.discriminationLevel) || "[]"
+    );
     return q;
   });
-  res3.data.push(res4.data);
+  res3.data.push(<SASQuestionGroup>(<unknown>res4.data));
   paperQuestionGroups = res3.data;
 }
 

+ 3 - 3
src/features/paperAnalysis/QuestionAttr.vue

@@ -6,7 +6,7 @@
 
     <a-table
       style="width: 100%; overflow-x: scroll"
-      row-key="id"
+      rowKey="id"
       :columns="columns"
       :data-source="props.questions"
       :pagination="{ pageSize: 200, hideOnSinglePage: true }"
@@ -16,9 +16,9 @@
 
 <script setup lang="ts">
 import EventBus from "@/plugins/eventBus";
-import { Question } from "@/types";
+import { SASQuestion } from "@/types";
 
-const props = defineProps<{ questions: Question[] }>();
+const props = defineProps<{ questions: SASQuestion[] }>();
 
 const columns = [
   {

+ 4 - 4
src/features/paperAnalysis/QuestionBianPai.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="tw-flex tw-gap-4" style="background-color: #e1e6f1">
     <a-table
-      row-key="id"
+      rowKey="id"
       :columns="columns"
       :data-source="props.questions"
       :pagination="{ pageSize: 200, hideOnSinglePage: true }"
@@ -27,10 +27,10 @@
 
 <script setup lang="ts">
 import EventBus from "@/plugins/eventBus";
-import { Question } from "@/types";
+import { SASQuestion } from "@/types";
 import { EChartsOption } from "echarts";
 
-const props = defineProps<{ questions: Question[] }>();
+const props = defineProps<{ questions: SASQuestion[] }>();
 
 const columns = [
   {
@@ -54,7 +54,7 @@ function openModal() {
   EventBus.emit("SHOW_SETTING", "DESCRIBE050");
 }
 
-function chartOption(questions: any) {
+function chartOption(questions: SASQuestion[]) {
   console.log(questions);
   return {
     title: {

+ 3 - 2
src/features/paperAnalysis/QuestionTypeDifficulty.vue

@@ -161,13 +161,14 @@
 <script setup lang="ts">
 import { importQuestionGroups } from "@/api/paperAnalysisPage";
 import EventBus from "@/plugins/eventBus";
-import { QuestionGroup } from "@/types";
+import { SASQuestionGroup } from "@/types";
 import { downloadFileURL } from "@/utils/utils";
 import { message } from "ant-design-vue";
 import { h } from "vue";
 import DifficultyDistriTable from "./DifficultyDistriTable.vue";
 
-const props = defineProps<{ questions: QuestionGroup[]; projectId: number }>();
+const props =
+  defineProps<{ questions: SASQuestionGroup[]; projectId: number }>();
 
 function openModalDESCRIBE070() {
   EventBus.emit("SHOW_SETTING", "DESCRIBE070");

+ 3 - 2
src/features/paperAnalysis/QuestionTypeDiscrimination.vue

@@ -161,13 +161,14 @@
 <script setup lang="ts">
 import { importQuestionGroups } from "@/api/paperAnalysisPage";
 import EventBus from "@/plugins/eventBus";
-import { QuestionGroup } from "@/types";
+import { SASQuestionGroup } from "@/types";
 import { downloadFileURL } from "@/utils/utils";
 import { message } from "ant-design-vue";
 import { h } from "vue";
 import DiscriminationDistriTable from "./DiscriminationDistriTable.vue";
 
-const props = defineProps<{ questions: QuestionGroup[]; projectId: number }>();
+const props =
+  defineProps<{ questions: SASQuestionGroup[]; projectId: number }>();
 
 function openModalDESCRIBE160() {
   EventBus.emit("SHOW_SETTING", "DESCRIBE160");

+ 22 - 21
src/features/projectManagement/ProjectManagement.vue

@@ -33,12 +33,12 @@
           pageSize: pageSize,
           current: pageNo,
           total: totalElements,
-          showTotal: (total: number) => ``,
-          onChange: (pageNoChanged: number, pageSizeChanged: number) => {
-            selectIds = []
-            pageNo = pageNoChanged; 
+          showTotal: () => ``,
+          onChange: (pageNoChanged, pageSizeChanged) => {
+            selectIds = [];
+            pageNo = pageNoChanged;
             pageSize = pageSizeChanged;
-          }
+          },
         }"
       >
         <template #status="{ text }">
@@ -183,6 +183,7 @@ import {
 } from "@/api/projectManagementPage";
 import router from "@/router";
 import { useMainStore } from "@/store";
+import { Project } from "@/types";
 import { message, Modal } from "ant-design-vue";
 import { watch, onMounted, ref, reactive, toRaw } from "vue";
 
@@ -193,7 +194,7 @@ let rootOrgId = $ref(undefined as unknown as number);
 let name = $ref("");
 let projectStatus = $ref(undefined as undefined | string);
 
-let data = $ref([]);
+let data = $ref<Project[]>([]);
 let pageSize = $ref(10);
 let pageNo = $ref(1);
 let totalElements = $ref(0);
@@ -218,8 +219,8 @@ async function fetchData() {
     pageNo,
   });
   // console.log(res);
-  res.data.content = res.data.content.map((p: any) => {
-    p.changeInfo = JSON.parse(p.changeInfo || "{}");
+  res.data.content = res.data.content.map((p) => {
+    p.changeInfo = JSON.parse(<string>(<unknown>p.changeInfo) || "{}");
     return p;
   });
   data = res.data.content;
@@ -284,7 +285,7 @@ const showModal = (record: any) => {
   visible.value = true;
 };
 
-const handleOk = async (e: MouseEvent) => {
+const handleOk = async () => {
   await updateProject(toRaw(projectObj));
   visible.value = false;
   await search();
@@ -301,7 +302,7 @@ const initProject = {
 };
 const projectObj = reactive({ ...initProject });
 
-const newProject = async () => {
+const newProject = () => {
   Object.assign(projectObj, initProject);
   showModal(projectObj);
 };
@@ -314,7 +315,7 @@ function checkEmpty(selectIds: number[]): boolean {
     return true;
   }
 }
-async function handleDeleteProjects(ids: number[]) {
+function handleDeleteProjects(ids: number[]) {
   if (checkEmpty(ids)) return;
   Modal.confirm({
     title: "提示",
@@ -337,7 +338,7 @@ const rowSelection = {
   },
 };
 
-async function handleCancelProject(id: number) {
+function handleCancelProject(id: number) {
   Modal.confirm({
     title: "提示",
     content: "确认取消计算?",
@@ -352,12 +353,12 @@ async function handleCancelProject(id: number) {
 }
 
 let showRestartModalVisible = $ref(false);
-let selectedProject = reactive({ id: 0 });
+let selectedProject = reactive<Project>({ id: 0 } as Project);
 function selectRestartProject(p: any) {
   Object.assign(selectedProject, p);
   showRestartModalVisible = true;
 }
-async function handleRestartProject() {
+function handleRestartProject() {
   Modal.confirm({
     title: "提示",
     content: "确认重新计算?",
@@ -377,20 +378,20 @@ async function handleLogsOfProject(id: number) {
   void message.success({ content: "操作成功" });
 }
 
-function goProjectDataSource(id: number) {
-  router.push("datasource/" + id);
+async function goProjectDataSource(id: number) {
+  await router.push("datasource/" + id);
 }
 
-function goProjectParams(id: number) {
-  router.push("params/" + id);
+async function goProjectParams(id: number) {
+  await router.push("params/" + id);
 }
 
-function goProjectPapers(id: number) {
-  router.push("papers/" + id);
+async function goProjectPapers(id: number) {
+  await router.push("papers/" + id);
 }
 
 async function goAllAnalysis(projectId: number) {
-  router.push(`/project/allAnalysis/${projectId}`);
+  await router.push(`/project/allAnalysis/${projectId}`);
 }
 </script>
 

+ 152 - 100
src/types/index.ts

@@ -8,106 +8,6 @@ export type Course_Type = "PUBLIC" | "MAJOR";
 
 export type Privilege_Type = "COURSE" | "ORG";
 
-export interface Question {
-  id: number;
-  createTime: string;
-  updateTime: string;
-  projectId: number;
-  courseId: number;
-  paperId: number;
-  questionName: string;
-  mainNumber: number;
-  subNumber: number;
-  subIndex: null;
-  objective: boolean;
-  totalScore: number;
-  maxScore: number;
-  minScore: number;
-  avgScore: number;
-  stdev: number;
-  coefficient: number;
-  difficulty: number;
-  discrimination: number;
-  zeroCount: number;
-  fullCount: number;
-  effectiveCount: number;
-  options: null;
-  optionLevel: null;
-  answer: null;
-  difficulityLevel: number[];
-  difficulityGroupLevel: number[];
-}
-
-// Generated by https://quicktype.io
-
-export interface QuestionGroup {
-  avgScore: number;
-  coefficient: number;
-  courseId: number;
-  createTime: string;
-  difficulityLevel: {
-    high: {
-      questionCount: number;
-      fullScore: number;
-      percent: number;
-    };
-    middle: {
-      questionCount: number;
-      fullScore: number;
-      percent: number;
-    };
-    low: {
-      questionCount: number;
-      fullScore: number;
-      percent: number;
-    };
-  };
-  difficulty: number;
-  discrimination: number;
-  discriminationLevel: {
-    excellent: {
-      questionCount: number;
-      fullScore: number;
-    };
-    good: {
-      questionCount: number;
-      fullScore: number;
-    };
-    general: {
-      questionCount: number;
-      fullScore: number;
-    };
-    bad: {
-      questionCount: number;
-      fullScore: number;
-    };
-  };
-  fullCount: number;
-  groupName: string;
-  id: number;
-  maxScore: number;
-  minScore: number;
-  objective: boolean;
-  paperId: number;
-  projectId: number;
-  questionCount: number;
-  realityCount: number;
-  stdev: number;
-  totalScore: number;
-  type:
-    | "TYPE1"
-    | "TYPE2"
-    | "TYPE3"
-    | "CONTENT1"
-    | "CONTENT2"
-    | "CONTENT3"
-    | "ABILITY1"
-    | "ABILITY2"
-    | "ABILITY3";
-  updateTime: string;
-  zeroCount: number;
-}
-
 // 科目成绩(总分)频率分布-科目成绩占初试总分权重
 export interface SasCourse {
   courseCode: string;
@@ -177,3 +77,155 @@ export interface Pagination {
 export interface SASPaperResponse extends Pagination {
   content: SASPaper[];
 }
+
+export interface Project {
+  changeInfo: {
+    ITEM1: boolean;
+    ITEM2: boolean;
+    ITEM3: boolean;
+    ITEM4: boolean;
+    ITEM5: boolean;
+    ITEM6: boolean;
+  };
+  createTime: string;
+  creator: string;
+  id: number;
+  name: string;
+  needCompute: boolean;
+  rootOrgCode: string;
+  rootOrgName: string;
+  status: string;
+  updateTime: string;
+  updater: string;
+}
+
+export interface ProjectResponse extends Pagination {
+  content: Project[];
+}
+
+// 试题题目编排,试卷特征量数,试题难度分组分布
+export interface SASQuestion {
+  answer: string;
+  avgScore: number;
+  coefficient: number;
+  courseId: number;
+  createTime: string;
+  difficulityGroupLevel: number[];
+  difficulityLevel: DifficulityLevel;
+  difficulty: number;
+  discrimination: number;
+  effectiveCount: number;
+  fullCount: number;
+  id: number;
+  mainNumber: number;
+  maxScore: number;
+  minScore: number;
+  objective: boolean;
+  optionLevel: string;
+  options: string;
+  paperId: number;
+  projectId: number;
+  questionName: string;
+  stdev: number;
+  subIndex: number;
+  subNumber: number;
+  totalScore: number;
+  updateTime: string;
+  zeroCount: number;
+}
+
+interface LevelDetail {
+  questionCount: number;
+  fullScore: number;
+  percent: number;
+}
+export interface DifficulityLevel {
+  high: LevelDetail;
+  middle: LevelDetail;
+  low: LevelDetail;
+}
+
+// 试卷分析-查询指定试卷全卷信息
+export interface SASPaper {
+  allRange: number;
+  avgScore: number;
+  coefficient: number;
+  courseId: number;
+  createTime: string;
+  difficulityLevel: DifficulityLevel;
+  difficulityRangeConfig: string;
+  difficulty: number;
+  discriminationLevel: DiscriminationLevel;
+  id: number;
+  maxScore: number;
+  minScore: number;
+  paperId: number;
+  projectId: number;
+  questionCount: number;
+  reliability1: number;
+  reliability2: number;
+  stdev: number;
+  totalCount: number;
+  totalScore: number;
+  updateTime: string;
+}
+
+export interface DiscriminationLevel {
+  excellent: LevelDetail;
+  good: LevelDetail;
+  general: LevelDetail;
+  bad: LevelDetail;
+}
+
+// 题型难度分布、题型区分度分布
+export interface SASQuestionGroup {
+  avgScore: number;
+  coefficient: number;
+  courseId: number;
+  createTime: string;
+  difficulityLevel: DifficulityLevel;
+  difficulty: number;
+  discrimination: number;
+  discriminationLevel: DiscriminationLevel;
+  fullCount: number;
+  groupName: string;
+  id: number;
+  maxScore: number;
+  minScore: number;
+  objective: boolean;
+  paperId: number;
+  projectId: number;
+  questionCount: number;
+  realityCount: number;
+  stdev: number;
+  totalScore: number;
+  type:
+    | "TYPE1"
+    | "TYPE2"
+    | "TYPE3"
+    | "CONTENT1"
+    | "CONTENT2"
+    | "CONTENT3"
+    | "ABILITY1"
+    | "ABILITY2"
+    | "ABILITY3";
+  updateTime: string;
+  zeroCount: number;
+}
+
+// 查询指定试卷
+export interface Paper {
+  courseId: number;
+  createTime: string;
+  creatorId: number;
+  difficulityRangeConfig: string;
+  id: number;
+  optionRangeConfig: string;
+  paperName: string;
+  paperType: string;
+  projectId: number;
+  rootOrgId: number;
+  totalScore: number;
+  updateTime: string;
+  updaterId: number;
+}