Browse Source

feat: 类型检查

zhangjie 9 months ago
parent
commit
403a0ae8e7

+ 2 - 2
src/render/ap/resultExport.ts

@@ -55,7 +55,7 @@ export const markSiteDelete = (id: string): Promise<RequestActionResult> =>
   request({
   request({
     url: "/api/admin/mark-site/delete",
     url: "/api/admin/mark-site/delete",
     method: "post",
     method: "post",
-    data,
+    data: { id },
   });
   });
 
 
 // 扫描点代码
 // 扫描点代码
@@ -91,5 +91,5 @@ export const dbfExportProgress = (
   request({
   request({
     url: "/api/admin/subject/data/progress",
     url: "/api/admin/subject/data/progress",
     method: "post",
     method: "post",
-    data,
+    data: { taskId },
   });
   });

+ 2 - 2
src/render/ap/types/common.ts

@@ -1,8 +1,8 @@
-export interface PageResult<T = unknown> {
+export type PageResult<T = unknown> = {
   totalCount: number;
   totalCount: number;
   pageCount: number;
   pageCount: number;
   result: Array<T>;
   result: Array<T>;
-}
+};
 export type PageParams<T = unknown> = T & {
 export type PageParams<T = unknown> = T & {
   pageNumber: number;
   pageNumber: number;
   pageSize: number;
   pageSize: number;

+ 1 - 1
src/render/ap/types/resultExport.ts

@@ -24,7 +24,7 @@ export interface MarkSiteListItem {
   evenNumber: number;
   evenNumber: number;
 }
 }
 
 
-export type MarkSiteListPageResult = PageResult<MarkSiteListItem[]>;
+export type MarkSiteListPageResult = PageResult<MarkSiteListItem>;
 
 
 export interface MarkSiteSaveParams {
 export interface MarkSiteSaveParams {
   id?: string;
   id?: string;

+ 5 - 3
src/render/hooks/useTable.ts

@@ -1,5 +1,7 @@
-import { ref } from "vue";
+import { reactive, ref } from "vue";
+import type { UnwrapRef } from "vue";
 import { PageResult } from "@/ap/types/common";
 import { PageResult } from "@/ap/types/common";
+import type { TablePaginationConfig } from "ant-design-vue";
 
 
 export default function useTable<T extends Record<string, any>>(
 export default function useTable<T extends Record<string, any>>(
   apiFunc: (data: any) => Promise<PageResult<T>>,
   apiFunc: (data: any) => Promise<PageResult<T>>,
@@ -50,11 +52,11 @@ export default function useTable<T extends Record<string, any>>(
     toPage(page);
     toPage(page);
   }
   }
 
 
-  const pagination = ref({
+  const pagination: UnwrapRef<TablePaginationConfig> = reactive({
     total,
     total,
     current: pageNumber,
     current: pageNumber,
     pageSize,
     pageSize,
-    showTotal: true,
+    showTotal: (totalCount: number) => `共${totalCount}页`,
     showQuickJumper: true,
     showQuickJumper: true,
     onChange: toPage,
     onChange: toPage,
   });
   });

+ 5 - 5
src/render/views/ResultExport/BreachImport.vue

@@ -16,9 +16,9 @@
     :loading="loading"
     :loading="loading"
     bordered
     bordered
   >
   >
-    <template #bodyCell="{ column, record }">
+    <template #bodyCell="{ column, index }">
       <template v-if="column.dataIndex === 'operation'">
       <template v-if="column.dataIndex === 'operation'">
-        <qm-button type="text" @click="onImport(record)">导入</qm-button>
+        <qm-button type="text" @click="onImport(index)">导入</qm-button>
       </template>
       </template>
     </template>
     </template>
   </a-table>
   </a-table>
@@ -61,12 +61,12 @@ const columns: TableProps["columns"] = [
 ];
 ];
 
 
 async function getData() {
 async function getData() {
-  const res = await breachList();
+  const res = await breachList({ examId: "" });
   dataList.value = res || [];
   dataList.value = res || [];
 }
 }
 
 
-async function onImport(record: BreachListItem) {
-  console.log(record);
+async function onImport(index: number) {
+  console.log(index);
 }
 }
 
 
 onMounted(() => {
 onMounted(() => {

+ 9 - 9
src/render/views/ResultExport/DbfExport.vue

@@ -15,12 +15,12 @@
     :loading="loading"
     :loading="loading"
     bordered
     bordered
   >
   >
-    <template #bodyCell="{ column, record }">
+    <template #bodyCell="{ column, index }">
       <template v-if="column.dataIndex === 'operation'">
       <template v-if="column.dataIndex === 'operation'">
-        <qm-button type="text" @click="onExportAnswer(record)"
+        <qm-button type="text" @click="onExportAnswer(index)"
           >导出扫描答案DBF</qm-button
           >导出扫描答案DBF</qm-button
         >
         >
-        <qm-button type="text" @click="onExportPackage(record)"
+        <qm-button type="text" @click="onExportPackage(index)"
           >导出打包DBF</qm-button
           >导出打包DBF</qm-button
         >
         >
       </template>
       </template>
@@ -62,21 +62,21 @@ const columns: TableProps["columns"] = [
 
 
 const scanSiteCode = ref("");
 const scanSiteCode = ref("");
 async function getScanSiteCode() {
 async function getScanSiteCode() {
-  const res = await markSiteCodeInfo();
+  const res = await markSiteCodeInfo({ examId: "" });
   scanSiteCode.value = res.scanSite;
   scanSiteCode.value = res.scanSite;
 }
 }
 
 
 async function getData() {
 async function getData() {
-  const res = await subjectList();
+  const res = await subjectList({ examId: "" });
   dataList.value = res || [];
   dataList.value = res || [];
 }
 }
 
 
-async function onExportAnswer(record: SubjectItem) {
-  console.log(record);
+async function onExportAnswer(index: number) {
+  console.log(index);
 }
 }
 
 
-async function onExportPackage(record: SubjectItem) {
-  console.log(record);
+async function onExportPackage(index: number) {
+  console.log(index);
 }
 }
 
 
 onMounted(() => {
 onMounted(() => {

+ 8 - 7
src/render/views/ResultExport/MarkSite.vue

@@ -13,10 +13,10 @@
     :loading="loading"
     :loading="loading"
     bordered
     bordered
   >
   >
-    <template #bodyCell="{ column, record }">
+    <template #bodyCell="{ column, index }">
       <template v-if="column.dataIndex === 'operation'">
       <template v-if="column.dataIndex === 'operation'">
-        <qm-button type="text" @click="onEdit(record)">编辑</qm-button>
-        <qm-button type="text" @click="onDelete(record)">删除</qm-button>
+        <qm-button type="text" @click="onEdit(index)">编辑</qm-button>
+        <qm-button type="text" @click="onDelete(index)">删除</qm-button>
       </template>
       </template>
     </template>
     </template>
   </a-table>
   </a-table>
@@ -82,21 +82,22 @@ const { dataList, pagination, loading, getList, toPage, deletePageLastItem } =
 
 
 const modifyMarkSiteRef = ref();
 const modifyMarkSiteRef = ref();
 function onAdd() {
 function onAdd() {
-  curRow.value = {};
+  curRow.value = {} as MarkSiteListItem;
   modifyMarkSiteRef.value?.open();
   modifyMarkSiteRef.value?.open();
 }
 }
 
 
-async function onEdit(record: MarkSiteListItem) {
-  curRow.value = record;
+async function onEdit(index: number) {
+  curRow.value = dataList.value[index];
   modifyMarkSiteRef.value?.open();
   modifyMarkSiteRef.value?.open();
 }
 }
 
 
-async function onDelete(record: MarkSiteListItem) {
+async function onDelete(index: number) {
   const confirm = await showConfirm({
   const confirm = await showConfirm({
     content: "确定要删除此评卷点信息?",
     content: "确定要删除此评卷点信息?",
   }).catch(() => false);
   }).catch(() => false);
   if (confirm !== "confirm") return;
   if (confirm !== "confirm") return;
 
 
+  const record = dataList.value[index];
   const res = await markSiteDelete(record.id).catch(() => false);
   const res = await markSiteDelete(record.id).catch(() => false);
   if (!res) return;
   if (!res) return;
 
 

+ 2 - 2
src/render/views/ResultExport/ModifyMarkSite.vue

@@ -72,8 +72,8 @@ const defaultFormData = {
   examId: "",
   examId: "",
   subjectCode: "",
   subjectCode: "",
   paperType: "",
   paperType: "",
-  oddNumber: "",
-  evenNumber: "",
+  oddNumber: 0,
+  evenNumber: 0,
 };
 };
 
 
 const props = defineProps<{
 const props = defineProps<{

+ 5 - 4
src/render/views/ResultExport/StudentStatus.vue

@@ -16,9 +16,9 @@
     :loading="loading"
     :loading="loading"
     bordered
     bordered
   >
   >
-    <template #bodyCell="{ column, record }">
+    <template #bodyCell="{ column, index }">
       <template v-if="column.dataIndex === 'operation'">
       <template v-if="column.dataIndex === 'operation'">
-        <qm-button type="text" @click="onImport(record)">导入</qm-button>
+        <qm-button type="text" @click="onImport(index)">导入</qm-button>
       </template>
       </template>
     </template>
     </template>
   </a-table>
   </a-table>
@@ -61,11 +61,12 @@ const columns: TableProps["columns"] = [
 ];
 ];
 
 
 async function getData() {
 async function getData() {
-  const res = await studentStatusList();
+  const res = await studentStatusList({ examId: "" });
   dataList.value = res || [];
   dataList.value = res || [];
 }
 }
 
 
-async function onImport(record: StudentStatusListItem) {
+async function onImport(index: number) {
+  const record = dataList.value[index];
   console.log(record);
   console.log(record);
 }
 }
 
 

+ 1 - 1
tsconfig.json

@@ -30,7 +30,7 @@
     "src/**/*.d.ts",
     "src/**/*.d.ts",
     "src/**/*.tsx",
     "src/**/*.tsx",
     "src/**/*.vue",
     "src/**/*.vue",
-    "types",
+    "types/**/*.d.ts"
   ],
   ],
   "exclude": [
   "exclude": [
     "node_modules",
     "node_modules",

+ 14 - 12
types/global.d.ts

@@ -1,15 +1,17 @@
 import type { Rule } from "ant-design-vue/es/form";
 import type { Rule } from "ant-design-vue/es/form";
 
 
-declare interface Window {
-  $message: any;
-  $notification: any;
-  $info: any;
-  $success: any;
-  $error: any;
-  $warning: any;
-  $confirm: any;
-  $destroyAll: any;
-  electronApi: any;
-}
+declare global {
+  interface Window {
+    $message: any;
+    $notification: any;
+    $info: any;
+    $success: any;
+    $error: any;
+    $warning: any;
+    $confirm: any;
+    $destroyAll: any;
+    electronApi: any;
+  }
 
 
-declare type FormRules<T extends string> = Partial<Record<T, Rule[]>>;
+  type FormRules<T extends string> = Partial<Record<T, Rule[]>>;
+}