瀏覽代碼

feat: 类型调整

zhangjie 1 年之前
父節點
當前提交
1036163546
共有 38 個文件被更改,包括 334 次插入423 次删除
  1. 1 0
      .husky/pre-commit
  2. 1 0
      package.json
  3. 155 133
      pnpm-lock.yaml
  4. 3 3
      src/api/base.ts
  5. 4 4
      src/api/order.ts
  6. 11 11
      src/api/types/base.ts
  7. 1 1
      src/api/types/common.ts
  8. 15 15
      src/api/types/order.ts
  9. 1 1
      src/api/types/user.ts
  10. 1 1
      src/components/file-upload/index.vue
  11. 1 1
      src/components/file-upload/types.ts
  12. 2 2
      src/components/import-dialog/index.vue
  13. 3 1
      src/components/svg-icon/index.vue
  14. 1 1
      src/hooks/dict-option.ts
  15. 2 2
      src/hooks/table.ts
  16. 1 1
      src/layout/default-layout.vue
  17. 1 1
      src/store/modules/app/types.ts
  18. 1 1
      src/types/global.ts
  19. 8 63
      src/utils/download.ts
  20. 2 4
      src/utils/filter.ts
  21. 2 2
      src/utils/router-utils.ts
  22. 39 103
      src/utils/utils.ts
  23. 9 9
      src/views/base/agent-manage/index.vue
  24. 2 2
      src/views/base/agent-manage/modifyAgent.vue
  25. 7 7
      src/views/base/room-manage/index.vue
  26. 5 5
      src/views/base/room-manage/modifyRoom.vue
  27. 6 6
      src/views/base/teaching-manage/index.vue
  28. 3 3
      src/views/base/teaching-manage/modifyTeaching.vue
  29. 1 1
      src/views/login/login/ResetPwd.vue
  30. 7 7
      src/views/order/order-record-manage/index.vue
  31. 2 2
      src/views/order/student-import/index.vue
  32. 1 1
      src/views/order/student-manage/index.vue
  33. 17 9
      src/views/order/task-manage/addTimes.vue
  34. 4 4
      src/views/order/task-manage/index.vue
  35. 3 3
      src/views/order/task-manage/modifyTask.vue
  36. 1 1
      src/views/order/task-manage/noticeForm.vue
  37. 8 10
      src/views/order/task-manage/ruleForm.vue
  38. 2 2
      src/views/order/task-manage/timeForm.vue

+ 1 - 0
.husky/pre-commit

@@ -2,3 +2,4 @@
 . "$(dirname "$0")/_/husky.sh"
 
 npm run lint-staged
+# npm run type:check

+ 1 - 0
package.json

@@ -53,6 +53,7 @@
     "@types/lodash": "^4.14.186",
     "@types/mockjs": "^1.0.7",
     "@types/nprogress": "^0.2.0",
+    "@types/vue-ls": "^3.2.7",
     "@typescript-eslint/eslint-plugin": "^5.40.0",
     "@typescript-eslint/parser": "^5.40.0",
     "@vitejs/plugin-vue": "^3.1.2",

File diff suppressed because it is too large
+ 155 - 133
pnpm-lock.yaml


+ 3 - 3
src/api/base.ts

@@ -22,7 +22,7 @@ export function teachingListPage(
 // 教学点管理-新增编辑
 export function updateTeaching(
   datas: TeachingUpdateParams
-): Promise<{ id: string }> {
+): Promise<{ id: number }> {
   return axios.post('/api/admin/teaching/save', datas);
 }
 // 教学点管理-启用禁用
@@ -48,7 +48,7 @@ export function agentListPage(
   return axios.post('/api/admin/agent/query', {}, { params });
 }
 // 考点管理-新增编辑
-export function updateAgent(datas: AgentUpdateParams): Promise<{ id: string }> {
+export function updateAgent(datas: AgentUpdateParams): Promise<{ id: number }> {
   return axios.post('/api/admin/agent/save', datas);
 }
 // 考点管理-启用禁用
@@ -74,7 +74,7 @@ export function roomListPage(
   return axios.post('/api/admin/room/query', {}, { params });
 }
 // 考场管理-新增编辑
-export function updateRoom(datas: RoomUpdateParams): Promise<{ id: string }> {
+export function updateRoom(datas: RoomUpdateParams): Promise<{ id: number }> {
   return axios.post('/api/admin/room/save', datas);
 }
 // 考场管理-启用禁用

+ 4 - 4
src/api/order.ts

@@ -39,25 +39,25 @@ export function taskListPage(
   return axios.post('/api/admin/apply/task/page', {}, { params });
 }
 // 预约任务管理-详情
-export function taskDetailInfo(id: string): Promise<TaskItemDetail> {
+export function taskDetailInfo(id: number): Promise<TaskItemDetail> {
   return axios.post('/api/admin/apply/task/find', {}, { params: { id } });
 }
 // 预约任务管理-新增编辑规则
 export function updateTaskRule(
   datas: TaskRuleUpdateParams
-): Promise<{ id: string }> {
+): Promise<{ id: number }> {
   return axios.post('/api/admin/apply/task/rule/save', datas);
 }
 // 预约任务管理-编辑时段
 export function updateTaskTime(
   datas: TaskTimeUpdateParams
-): Promise<{ id: string }> {
+): Promise<{ id: number }> {
   return axios.post('/api/admin/apply/task/time/save', datas);
 }
 // 预约任务管理-编辑说明
 export function updateTaskNotice(
   datas: TaskNoticeUpdateParams
-): Promise<{ id: string }> {
+): Promise<{ id: number }> {
   return axios.post('/api/admin/apply/task/notice/save', datas);
 }
 // 预约任务管理-启用禁用

+ 11 - 11
src/api/types/base.ts

@@ -23,15 +23,15 @@ export interface TeachingUpdateParams {
   id?: number;
   name: string;
   code: string;
-  cityId: number;
-  capacity: number;
+  cityId: number | undefined;
+  capacity: number | undefined;
   enable?: boolean;
 }
 
 export interface AgentListFilter {
-  teachingId: string;
+  teachingId: number | null;
   name: string;
-  enable: boolean;
+  enable: boolean | undefined;
 }
 export type AgentListPageParam = PageParams<AgentListFilter>;
 
@@ -54,16 +54,16 @@ export interface AgentUpdateParams {
   name: string;
   code: string;
   address: string;
-  teachingId: number;
+  teachingId: number | null;
   guide: string;
   enable?: boolean;
 }
 
 export interface RoomListFilter {
-  teachingId: string;
-  agentId: string;
+  teachingId: number;
+  agentId: number;
   name: string;
-  enable: boolean;
+  enable: boolean | undefined;
 }
 export type RoomListPageParam = PageParams<RoomListFilter>;
 
@@ -87,8 +87,8 @@ export interface RoomUpdateParams {
   name: string;
   code: string;
   address: string;
-  capactiy: number;
-  teachingId: number;
-  agentId: number;
+  capacity: number | undefined;
+  teachingId: number | null;
+  agentId: number | null;
   enable?: boolean;
 }

+ 1 - 1
src/api/types/common.ts

@@ -12,6 +12,6 @@ export type PageParams<T = unknown> = T & {
 
 // page
 export interface AbleParams {
-  id: string;
+  id: number;
   enable: boolean;
 }

+ 15 - 15
src/api/types/order.ts

@@ -11,7 +11,7 @@ export interface TaskListFilter {
 export type TaskListPageParam = PageParams<TaskListFilter>;
 
 export interface TaskItem {
-  id: string;
+  id: number;
   name: string;
   selfApplyStartTime: number;
   selfApplyEndTime: number;
@@ -24,7 +24,7 @@ export interface TaskItem {
 export type TaskListPageRes = PageResult<TaskItem>;
 
 export interface TaskItemDetail {
-  id: string;
+  id: number;
   name: string;
   allowApplyDays: number;
   allowApplyCancelDays: number;
@@ -33,22 +33,22 @@ export interface TaskItemDetail {
   openApplyStartTime: number;
   openApplyEndTime: number;
   timeList: Array<{
-    id: string;
-    startTime: number;
-    endTime: number;
+    id: number | null;
+    startTime: number | undefined;
+    endTime: number | undefined;
   }>;
   notice: string;
 }
 
 export interface TaskRuleUpdateParams {
-  id?: string;
+  id: number | null;
   name: string;
   allowApplyDays: number;
   allowApplyCancelDays: number;
-  selfApplyStartTime: number;
-  selfApplyEndTime: number;
-  openApplyStartTime: number;
-  openApplyEndTime: number;
+  selfApplyStartTime: number | undefined;
+  selfApplyEndTime: number | undefined;
+  openApplyStartTime: number | undefined;
+  openApplyEndTime: number | undefined;
 }
 
 export interface TaskTimeUpdateParams {
@@ -57,12 +57,12 @@ export interface TaskTimeUpdateParams {
 }
 
 export interface TaskNoticeUpdateParams {
-  id: string;
+  id: number;
   notice: string;
 }
 
 export interface OrderRecordItem {
-  id: string;
+  id: number;
   name: string;
   identityNumber: string;
   studentCode: string;
@@ -78,9 +78,9 @@ export interface OrderRecordItem {
 }
 export type OrderRecordListPageRes = PageResult<OrderRecordItem>;
 export interface OrderRecordListFilter {
-  taskId: number;
-  teachingId: number;
-  agentId: number;
+  taskId: number | null;
+  teachingId: number | null;
+  agentId: number | null;
   name: string;
   identityNumber: string;
   studentCode: string;

+ 1 - 1
src/api/types/user.ts

@@ -4,7 +4,7 @@ export interface LoginData {
 }
 
 export interface UpdatePwdData {
-  id: string;
+  id: number;
   oldPassword: string;
   password: string;
 }

+ 1 - 1
src/components/file-upload/index.vue

@@ -77,7 +77,7 @@
     'validError',
   ]);
 
-  const uploadRef = ref(null);
+  const uploadRef = ref();
   const attachmentName = ref('');
   const canUpload = ref(false);
   const uploadDataDict = ref({ md5: '' });

+ 1 - 1
src/components/file-upload/types.ts

@@ -1,5 +1,5 @@
 export interface UploadResponseData {
-  id: string;
+  id: number;
   updateTime: number;
   url: string;
   pages: number;

+ 2 - 2
src/components/import-dialog/index.vue

@@ -90,7 +90,7 @@
   defineExpose({ open, close });
 
   interface PromiseFunc {
-    (): Promise<boolean>;
+    (): Promise<void>;
   }
 
   const props = withDefaults(
@@ -130,7 +130,7 @@
     'validError',
   ]);
 
-  const uploadRef = ref(null);
+  const uploadRef = ref();
   const canUpload = ref(false);
   const uploadDataDict = ref({ md5: '' });
   const headers = ref({});

+ 3 - 1
src/components/svg-icon/index.vue

@@ -39,5 +39,7 @@
     IconDelete,
   };
 
-  const iconComponent = computed(() => icons[snakeToHump(props.name)]);
+  const iconName = snakeToHump(props.name) as keyof typeof icons;
+
+  const iconComponent = computed(() => icons[iconName]);
 </script>

+ 1 - 1
src/hooks/dict-option.ts

@@ -20,7 +20,7 @@ export default function useDictOption(dictType: DictTypeType) {
   const optionList = ref<Options[]>(dictToOption(dicts[dictType] || {}));
 
   function getLabel(val): string {
-    return dicts[dictType][val] || DEFAULT_LABEL;
+    return (dicts[dictType][val] as string) || DEFAULT_LABEL;
   }
 
   return {

+ 2 - 2
src/hooks/table.ts

@@ -2,14 +2,14 @@ import { ref } from 'vue';
 import { PageResult } from '@/api/types/common';
 
 export default function useTable<T>(
-  apiFunc: Promise<PageResult<T>>,
+  apiFunc: (any) => Promise<PageResult<T>>,
   searchModel: object,
   initAutoFetch = false
 ) {
   const pageNumber = ref(1);
   const pageSize = ref(10);
   const total = ref(0);
-  const dataList = ref<T>([]);
+  const dataList = ref<T[]>([]);
 
   async function getList() {
     const datas = {

+ 1 - 1
src/layout/default-layout.vue

@@ -113,7 +113,7 @@
     mobileNumber: 1,
     userId: userStore.id,
   });
-  // const ResetPwdRef = ref(null);
+  // const ResetPwdRef = ref();
 
   function initData() {
     curRouteName.value = route.name;

+ 1 - 1
src/store/modules/app/types.ts

@@ -1,5 +1,5 @@
 export interface UserMenuItem {
-  id: string;
+  id: number;
   name: string;
   url: string;
   type: string;

+ 1 - 1
src/types/global.ts

@@ -5,7 +5,7 @@ export interface AnyObject {
 }
 
 export interface Options {
-  value: unknown;
+  value: number | string | boolean;
   label: string;
 }
 

+ 8 - 63
src/utils/download.ts

@@ -1,5 +1,4 @@
-import { AxiosResponse } from 'axios';
-import { objTypeOf, blobToText, objAssign } from './utils';
+import { objTypeOf, blobToText } from './utils';
 
 const parseDownloadFilename = (dispositionInfo: string): string => {
   if (!dispositionInfo) return '';
@@ -39,7 +38,7 @@ export function downloadByBlob(data: Blob, filename: string): void {
 }
 
 interface ApiFunc {
-  (): Promise<AxiosResponse<Blob, any>>;
+  (): Promise<Blob>;
 }
 
 /**
@@ -48,8 +47,8 @@ interface ApiFunc {
  * @param {String}} fileName 文件名
  * @returns Promise<Boolean>
  */
-export async function downloadByApi(
-  axiosFetchFunc: ApiFunc,
+export async function downloadByApi<T extends ApiFunc>(
+  axiosFetchFunc: T,
   fileName?: string
 ) {
   let errorInfo = null;
@@ -77,7 +76,10 @@ export async function downloadByApi(
  * @param {String} filename 下载的文件名
  * @returns Promise<Boolean>
  */
-export function downloadByImgUrl(url, filename) {
+export function downloadByImgUrl(
+  url: string,
+  filename: string
+): Promise<boolean> {
   return new Promise((resolve, reject) => {
     const img = new Image();
     // 跨域支持,需要服务端辅助配置
@@ -105,60 +107,3 @@ export function downloadByImgUrl(url, filename) {
     img.src = url;
   });
 }
-
-interface XhrDownloadOption {
-  type: 'get' | 'post';
-  url: string;
-  data: object;
-  fileName: string;
-  header: object;
-  responseType: string;
-}
-
-/**
- * 文件流下载
- * @param {Object} option 文件下载设置
- */
-export function xhrDownload(option: XhrDownloadOption) {
-  const defOpt = {
-    type: 'get',
-    url: '',
-    data: {},
-    fileName: '',
-    header: {},
-    responseType: '',
-  };
-  const opt = objAssign(defOpt, option);
-
-  return new Promise((resolve, reject) => {
-    const xhr = new XMLHttpRequest();
-    xhr.open(opt.type.toUpperCase(), opt.url, true);
-    if (opt.responseType) xhr.responseType = opt.responseType;
-
-    // header set
-    if (opt.header && objTypeOf(opt.header) === 'object') {
-      Object.keys(opt.header).forEach((key) => {
-        xhr.setRequestHeader(key, opt.header[key]);
-      });
-    }
-
-    function xhrOnload() {
-      if (this.readyState === 4 && this.status === 200) {
-        resolve(this.response);
-      } else {
-        reject(new Error('请求错误!'));
-      }
-    }
-    xhr.onload = xhrOnload;
-
-    if (opt.type.toUpperCase() === 'POST') {
-      const fromData = new FormData();
-      Object.keys(opt.data).forEach((key) => {
-        fromData.append(key, opt.data[key]);
-      });
-      xhr.send(fromData);
-    } else {
-      xhr.send();
-    }
-  });
-}

+ 2 - 4
src/utils/filter.ts

@@ -1,10 +1,8 @@
 import { DEFAULT_LABEL } from '@/constants/enumerate';
 import { formatDate } from './utils';
 
-export function timestampFilter(val: number | string) {
-  return val
-    ? formatDate('YYYY-MM-DD HH:mm:ss', new Date(val * 1))
-    : DEFAULT_LABEL;
+export function timestampFilter(val: number | null): string {
+  return val ? formatDate('YYYY-MM-DD HH:mm:ss', new Date(val)) : DEFAULT_LABEL;
 }
 
 interface CourseNameCode {

+ 2 - 2
src/utils/router-utils.ts

@@ -1,6 +1,6 @@
-import { useRouter } from 'vue-router';
+import { RouteLocationRaw, useRouter } from 'vue-router';
 
-export function getRouterPath(location) {
+export function getRouterPath(location: RouteLocationRaw) {
   const router = useRouter();
   const { href } = router.resolve(location);
   return href;

+ 39 - 103
src/utils/utils.ts

@@ -2,7 +2,7 @@
  * 判断对象类型
  * @param {*} obj 对象
  */
-export function objTypeOf(obj) {
+export function objTypeOf(obj: any): string {
   const map = {
     '[object Boolean]': 'boolean',
     '[object Number]': 'number',
@@ -24,10 +24,7 @@ export function objTypeOf(obj) {
  * @param {Object} target 目标对象
  * @param {Object} sources 源对象
  */
-export function objAssign<T extends object>(
-  target: object,
-  sources: object
-): T {
+export function objAssign<T extends object>(target: T, sources: object): T {
   const targ = { ...target };
   Object.keys(targ).forEach((k) => {
     targ[k] = Object.prototype.hasOwnProperty.call(sources, k)
@@ -42,7 +39,7 @@ export function objAssign<T extends object>(
  * @param {Object} target 目标对象
  * @param {Object} sources 源对象
  */
-export function objModifyAssign(target: object, sources: object) {
+export function objModifyAssign(target: object, sources: object): void {
   Object.keys(target).forEach((k) => {
     if (Object.prototype.hasOwnProperty.call(sources, k)) {
       target[k] = sources[k];
@@ -50,72 +47,6 @@ export function objModifyAssign(target: object, sources: object) {
   });
 }
 
-/**
- * 文件流下载
- * @param {Object} option 文件下载设置
- */
-export function download(option) {
-  const defOpt = {
-    type: 'get',
-    url: '',
-    data: '',
-    fileName: '',
-    header: '',
-  };
-  const opt = objAssign(defOpt, option);
-
-  return new Promise((resolve, reject) => {
-    const xhr = new XMLHttpRequest();
-    xhr.open(opt.type.toUpperCase(), opt.url, true);
-    xhr.responseType = 'blob';
-
-    // header set
-    if (opt.header && objTypeOf(opt.header) === 'object') {
-      Object.keys(opt.header).forEach((key) => {
-        xhr.setRequestHeader(key, opt.header[key]);
-      });
-    }
-
-    xhr.onload = () => {
-      if (this.readyState === 4 && this.status === 200) {
-        if (this.response.size < 1024) {
-          reject(new Error('文件不存在!'));
-          return;
-        }
-
-        const blob = this.response;
-        let pdfUrl = '';
-        const uRl = window.URL || window.webkitURL;
-        if (uRl && uRl.createObjectURL) {
-          pdfUrl = uRl.createObjectURL(blob);
-        } else {
-          reject(new Error('浏览器不兼容!'));
-        }
-        const a = document.createElement('a');
-        a.download = opt.fileName;
-        a.href = pdfUrl;
-        document.body.appendChild(a);
-        a.click();
-        a.parentNode.removeChild(a);
-        resolve(true);
-      } else {
-        reject(new Error('请求错误!'));
-      }
-    };
-
-    if (opt.type.toUpperCase() === 'POST') {
-      const fromData = new FormData();
-      Object.keys(opt.data).forEach((key) => {
-        fromData.append(key, opt.data[key]);
-      });
-
-      xhr.send(fromData);
-    } else {
-      xhr.send();
-    }
-  });
-}
-
 /**
  * 获取随机code,默认获取16位
  * @param {Number} len 推荐8的倍数
@@ -137,7 +68,7 @@ export function randomCode(len = 16) {
  * 序列化参数
  * @param {Object} params 参数对象
  */
-export function qsParams(params) {
+export function qsParams(params: Record<string, any>) {
   return Object.entries(params)
     .map((el) => `${el[0]}=${el[1]}`)
     .join('&');
@@ -176,7 +107,7 @@ export function formatDate(
  *  获取时间长度文字
  * @param {Number} timeNumber 时间数值,单位:毫秒
  */
-export function timeNumberToText(timeNumber) {
+export function timeNumberToText(timeNumber: number): string {
   const DAY_TIME = 24 * 60 * 60 * 1000;
   const HOUR_TIME = 60 * 60 * 1000;
   const MINUTE_TIME = 60 * 1000;
@@ -187,24 +118,22 @@ export function timeNumberToText(timeNumber) {
   if (residueTime >= DAY_TIME) {
     day = Math.floor(residueTime / DAY_TIME);
     residueTime -= day * DAY_TIME;
-    day += '天';
   }
   if (residueTime >= HOUR_TIME) {
     hour = Math.floor(residueTime / HOUR_TIME);
     residueTime -= hour * HOUR_TIME;
-    hour += '小时';
   }
   if (residueTime >= MINUTE_TIME) {
     minute = Math.floor(residueTime / MINUTE_TIME);
     residueTime -= minute * MINUTE_TIME;
-    minute += '分钟';
   }
   if (residueTime >= SECOND_TIME) {
     second = Math.round(residueTime / SECOND_TIME);
-    second += '秒';
   }
 
-  return [day, hour, minute, second].filter((item) => !!item).join('');
+  return [`${day}天`, `${hour}小时`, `${minute}分钟`, `${second}秒`]
+    .filter((item) => !!item)
+    .join('');
 }
 
 /**
@@ -212,7 +141,7 @@ export function timeNumberToText(timeNumber) {
  * @param {Number} timeNumber 时间数值,单位:毫秒
  * @param {Number} wainingTime 最大剩余警告时间数值,单位:毫秒
  */
-export function residueFloorTime(timeNumber, wainingTime = 0) {
+export function residueFloorTime(timeNumber: number, wainingTime = 0) {
   if (timeNumber < 0) {
     return { status: 'danger', title: '已过期' };
   }
@@ -254,7 +183,7 @@ export function residueFloorTime(timeNumber, wainingTime = 0) {
   };
 }
 
-export function parseTimeRangeDateAndTime(startTime, endTime) {
+export function parseTimeRangeDateAndTime(startTime: number, endTime: number) {
   if (!startTime || !endTime)
     return {
       date: '',
@@ -270,7 +199,10 @@ export function parseTimeRangeDateAndTime(startTime, endTime) {
   };
 }
 
-export function parseTimeRangeDateAndTimeContent(startTime, endTime) {
+export function parseTimeRangeDateAndTimeContent(
+  startTime: number,
+  endTime: number
+) {
   const { date, time } = parseTimeRangeDateAndTime(startTime, endTime);
   return `${date} ${time}`;
 }
@@ -286,7 +218,7 @@ export function localNowDateTime() {
  *
  * @param {Number} time 时间戳
  */
-export function getTimeDatestamp(time) {
+export function getTimeDatestamp(time: number) {
   const date = formatDate('YYYY-MM-DD HH:mm', new Date(time)).split(' ')[0];
   return new Date(`${date} 00:00:00`).getTime();
 }
@@ -295,7 +227,7 @@ export function getTimeDatestamp(time) {
  * 获取指定元素个数的数组
  * @param {Number} num
  */
-export function getNumList(num) {
+export function getNumList(num: number) {
   return '#'.repeat(num).split('');
 }
 
@@ -303,7 +235,7 @@ export function getNumList(num) {
  * 清除html标签
  * @param {String} str html字符串
  */
-export function removeHtmlTag(str) {
+export function removeHtmlTag(str: string) {
   return str.replace(/<[^>]+>/g, '');
 }
 
@@ -311,7 +243,7 @@ export function removeHtmlTag(str) {
  * 计算总数
  * @param {Array} dataList 需要统计的数组
  */
-export function calcSum(dataList) {
+export function calcSum(dataList: number[]) {
   if (!dataList.length) return 0;
   return dataList.reduce((total, item) => {
     return total + item;
@@ -322,31 +254,31 @@ export function calcSum(dataList) {
  * 计算评卷数
  * @param {Array} dataList 需要统计的数组
  */
-export function calcAvg(dataList) {
+export function calcAvg(dataList: number[]) {
   if (!dataList.length) return 0;
   return calcSum(dataList) / dataList.length;
 }
 
 /** 获取数组最大数 */
-export function maxNum(dataList) {
+export function maxNum(dataList: number[]) {
   if (!dataList.length) return 0;
   return Math.max.apply(null, dataList);
 }
 
-export function isEmptyObject(obj) {
+export function isEmptyObject(obj: object) {
   return !Object.keys(obj).length;
 }
 
-export function humpToLowLine(a) {
+export function humpToLowLine(a: string) {
   return a
     .replace(/([A-Z])/g, '-$1')
     .toLowerCase()
     .slice(1);
 }
 
-export function pickByNotNull(params) {
+export function pickByNotNull(params: Record<string, any>) {
   const nData = {};
-  Object.entries(params).forEach(([key, val]) => {
+  (Object.entries(params) as [string, any][]).forEach(([key, val]) => {
     if (val === null || val === 'null' || val === '') return;
     nData[key] = val;
   });
@@ -358,7 +290,7 @@ export function autoSubmitForm(url: string, params: Record<string, any>) {
   form.action = url;
   form.method = 'post';
 
-  Object.entries(params).forEach(([key, val]) => {
+  (Object.entries(params) as [string, any][]).forEach(([key, val]) => {
     const input = document.createElement('input');
     input.type = 'hidden';
     input.name = key;
@@ -369,7 +301,7 @@ export function autoSubmitForm(url: string, params: Record<string, any>) {
   form.submit();
 }
 
-export function blobToText(blob) {
+export function blobToText(blob: Blob): Promise<string | ArrayBuffer | null> {
   return new Promise((resolve, reject) => {
     const reader = new FileReader();
     reader.readAsText(blob, 'utf-8');
@@ -382,16 +314,19 @@ export function blobToText(blob) {
   });
 }
 
-export function parseHrefParam(urlStr, paramName = null): any {
-  if (!urlStr) return '';
+export function parseHrefParam(
+  urlStr: string,
+  paramName = ''
+): Record<string, any> | null {
+  if (!urlStr) return null;
   const url = new URL(urlStr);
 
   const urlParams = new URLSearchParams(url.search);
 
-  if (paramName) return urlParams.get(paramName);
+  if (paramName) return urlParams.get(paramName as string);
 
   const params = {};
-  urlParams.entries().forEach(([k, v]) => {
+  (urlParams.entries() as [string, string][]).forEach(([k, v]) => {
     params[k] = v;
   });
   return params;
@@ -402,14 +337,15 @@ export function parseHrefParam(urlStr, paramName = null): any {
  * @param data 字典数据
  * @returns option列表
  */
-export function dictToOption(
-  dict: Record<any, string>
-): Array<{ value: any; label: string }> {
-  const options = [];
+export function dictToOption(dict: Record<any, string>) {
+  const options = [] as Array<{
+    value: number | string | boolean;
+    label: string;
+  }>;
   const booleanStrs = ['true', 'false'];
   Object.keys(dict).forEach((k) => {
     options.push({
-      value: booleanStrs.includes(k) ? JSON.parse(k) : k,
+      value: booleanStrs.includes(k) ? (JSON.parse(k) as boolean) : k,
       label: dict[k],
     });
   });

+ 9 - 9
src/views/base/agent-manage/index.vue

@@ -96,7 +96,7 @@
   import { reactive, ref } from 'vue';
   import { Message, TableColumnData } from '@arco-design/web-vue';
   import { agentListPage, agentTemplate, ableAgent } from '@/api/base';
-  import { AgentItem } from '@/api/types/base';
+  import { AgentItem, AgentListFilter } from '@/api/types/base';
   import useTable from '@/hooks/table';
   import useDictOption from '@/hooks/dict-option';
   import { modalConfirm } from '@/utils/arco';
@@ -115,10 +115,10 @@
 
   const { optionList: ableOptions } = useDictOption('ABLE_TYPE');
 
-  const searchModel = reactive({
-    teachingId: '',
+  const searchModel = reactive<AgentListFilter>({
+    teachingId: null,
     name: '',
-    enable: null,
+    enable: undefined,
   });
 
   const columns: TableColumnData[] = [
@@ -157,7 +157,7 @@
       cellClass: 'action-column',
     },
   ];
-  const { dataList, pagination, toPage, getList } = useTable<AgentItem[]>(
+  const { dataList, pagination, toPage, getList } = useTable<AgentItem>(
     agentListPage,
     searchModel,
     true
@@ -173,15 +173,15 @@
 
   // table action
   // 导入
-  const importDialogRef = ref(null);
+  const importDialogRef = ref();
   function toImport() {
     importDialogRef.value?.open();
   }
 
-  const modifyAgentRef = ref(null);
-  const curRow = ref({});
+  const modifyAgentRef = ref();
+  const curRow = ref({} as AgentItem);
   function toAdd() {
-    curRow.value = {};
+    curRow.value = {} as AgentItem;
     modifyAgentRef.value?.open();
   }
   function toEdit(row: AgentItem) {

+ 2 - 2
src/views/base/agent-manage/modifyAgent.vue

@@ -79,11 +79,11 @@
   defineExpose({ open, close });
 
   const defaultFormData = {
-    id: null,
+    id: undefined,
     name: '',
     code: '',
     address: '',
-    teachingId: '',
+    teachingId: null,
     guide: '',
   };
 

+ 7 - 7
src/views/base/room-manage/index.vue

@@ -109,10 +109,10 @@
   const { optionList: ableOptions } = useDictOption('ABLE_TYPE');
 
   const searchModel = reactive({
-    teachingId: '',
+    teachingId: null,
     agentId: '',
     name: '',
-    enable: null,
+    enable: undefined,
   });
 
   const columns: TableColumnData[] = [
@@ -155,7 +155,7 @@
       cellClass: 'action-column',
     },
   ];
-  const { dataList, pagination, toPage, getList } = useTable<RoomItem[]>(
+  const { dataList, pagination, toPage, getList } = useTable<RoomItem>(
     roomListPage,
     searchModel,
     true
@@ -171,15 +171,15 @@
 
   // table action
   // 导入
-  const importDialogRef = ref(null);
+  const importDialogRef = ref();
   function toImport() {
     importDialogRef.value?.open();
   }
 
-  const modifyRoomRef = ref(null);
-  const curRow = ref({});
+  const modifyRoomRef = ref();
+  const curRow = ref({} as RoomItem);
   function toAdd() {
-    curRow.value = {};
+    curRow.value = {} as RoomItem;
     modifyRoomRef.value?.open();
   }
   function toEdit(row: RoomItem) {

+ 5 - 5
src/views/base/room-manage/modifyRoom.vue

@@ -86,13 +86,13 @@
   defineExpose({ open, close });
 
   const defaultFormData = {
-    id: null,
+    id: undefined,
     name: '',
     code: '',
     address: '',
-    capactiy: undefined,
-    teachingId: '',
-    agentId: '',
+    capacity: undefined,
+    teachingId: null,
+    agentId: null,
   };
 
   const props = defineProps<{
@@ -105,7 +105,7 @@
 
   const formRef = ref<FormInstance>();
   const formData = reactive<RoomUpdateParams>({ ...defaultFormData });
-  const rules: FormRules<RoomUpdateParams> = {
+  const rules: FormRules<keyof RoomUpdateParams> = {
     name: [
       {
         required: true,

+ 6 - 6
src/views/base/teaching-manage/index.vue

@@ -112,7 +112,7 @@
   const searchModel = reactive({
     name: '',
     code: '',
-    enable: null,
+    enable: undefined,
   });
 
   const columns: TableColumnData[] = [
@@ -146,7 +146,7 @@
       cellClass: 'action-column',
     },
   ];
-  const { dataList, pagination, toPage, getList } = useTable<TeachingItem[]>(
+  const { dataList, pagination, toPage, getList } = useTable<TeachingItem>(
     teachingListPage,
     searchModel,
     true
@@ -162,15 +162,15 @@
 
   // table action
   // 导入
-  const importDialogRef = ref(null);
+  const importDialogRef = ref();
   function toImport() {
     importDialogRef.value?.open();
   }
 
-  const modifyTeachingRef = ref(null);
-  const curRow = ref({});
+  const modifyTeachingRef = ref();
+  const curRow = ref({} as TeachingItem);
   function toAdd() {
-    curRow.value = {};
+    curRow.value = {} as TeachingItem;
     modifyTeachingRef.value?.open();
   }
   function toEdit(row: TeachingItem) {

+ 3 - 3
src/views/base/teaching-manage/modifyTeaching.vue

@@ -74,10 +74,10 @@
   defineExpose({ open, close });
 
   const defaultFormData = {
-    id: null,
+    id: undefined,
     name: '',
     code: '',
-    cityId: null,
+    cityId: undefined,
     capacity: undefined,
   };
 
@@ -91,7 +91,7 @@
 
   const formRef = ref<FormInstance>();
   const formData = reactive<TeachingUpdateParams>({ ...defaultFormData });
-  const rules: FormRules<TeachingUpdateParams> = {
+  const rules: FormRules<keyof TeachingUpdateParams> = {
     name: [
       {
         required: true,

+ 1 - 1
src/views/login/login/ResetPwd.vue

@@ -71,7 +71,7 @@
     ...strictPassword,
     {
       validator: (value, callback) => {
-        if (value === userStore.loginName) {
+        if (value === userStore.account) {
           return callback('禁止使用用户账户号作为密码');
         }
         return callback();

+ 7 - 7
src/views/order/order-record-manage/index.vue

@@ -111,7 +111,7 @@
     orderRecordPrint,
     orderRecordTemplate,
   } from '@/api/order';
-  import { OrderRecordItem } from '@/api/types/order';
+  import { OrderRecordItem, OrderRecordListFilter } from '@/api/types/order';
   import useTable from '@/hooks/table';
   // import useDictOption from '@/hooks/dict-option';
   import useLoading from '@/hooks/loading';
@@ -132,10 +132,10 @@
 
   // const { getLabel: getAbleLabel } = useDictOption('ABLE_TYPE');
 
-  const searchModel = reactive({
-    taskId: '',
-    teachingId: '',
-    agentId: '',
+  const searchModel = reactive<OrderRecordListFilter>({
+    taskId: null,
+    teachingId: null,
+    agentId: null,
     name: '',
     identityNumber: '',
     studentCode: '',
@@ -211,7 +211,7 @@
   const uploadData = computed(() => {
     return searchModel.teachingId ? { teachingId: searchModel.teachingId } : {};
   });
-  const { dataList, pagination, toPage, getList } = useTable<OrderRecordItem[]>(
+  const { dataList, pagination, toPage, getList } = useTable<OrderRecordItem>(
     orderRecordListPage,
     searchModel,
     true
@@ -227,7 +227,7 @@
 
   // table action
   // 导入
-  const importStudentDialogRef = ref(null);
+  const importStudentDialogRef = ref();
   function toImport() {
     importStudentDialogRef.value?.open();
   }

+ 2 - 2
src/views/order/student-import/index.vue

@@ -106,7 +106,7 @@
     //   cellClass: 'action-column',
     // },
   ];
-  const { dataList, pagination, getList } = useTable<StudentExportItem[]>(
+  const { dataList, pagination, getList } = useTable<StudentExportItem>(
     studentImportListPage,
     searchModel,
     true
@@ -122,7 +122,7 @@
 
   // table action
   // 导入
-  const importStudentDialogRef = ref(null);
+  const importStudentDialogRef = ref();
   function toImport() {
     importStudentDialogRef.value?.open();
   }

+ 1 - 1
src/views/order/student-manage/index.vue

@@ -128,7 +128,7 @@
       cellClass: 'action-column',
     },
   ];
-  const { dataList, pagination, toPage, getList } = useTable<OrderRecordItem[]>(
+  const { dataList, pagination, toPage, getList } = useTable<OrderRecordItem>(
     orderRecordListPage,
     searchModel,
     true

+ 17 - 9
src/views/order/task-manage/addTimes.vue

@@ -86,6 +86,7 @@
   import useModal from '@/hooks/modal';
   import { formatDate, objModifyAssign } from '@/utils/utils';
   import { Message } from '@arco-design/web-vue';
+  import { TaskItemDetail } from '@/api/types/order';
 
   defineOptions({
     name: 'AddTimes',
@@ -100,22 +101,29 @@
   function getItemItem() {
     return {
       id: null,
-      startTime: null,
-      endTime: null,
+      startTime: undefined,
+      endTime: undefined,
     };
   }
   function getDefaultFormData() {
     return {
       type: 'simple',
       date: {
-        startTime: null,
-        endTime: null,
+        startTime: undefined,
+        endTime: undefined,
       },
       times: [getItemItem()],
     };
   }
   const formRef = ref<FormInstance>();
-  const formData = reactive(getDefaultFormData());
+  const formData = reactive<{
+    type: string;
+    date: {
+      startTime: number | undefined;
+      endTime: number | undefined;
+    };
+    times: TaskItemDetail['timeList'];
+  }>(getDefaultFormData());
   const IS_LOOP = computed(() => {
     return formData.type === 'loop';
   });
@@ -147,14 +155,14 @@
       return;
     }
 
-    const times = [];
+    const times = [] as TaskItemDetail['timeList'];
     const oneDay = 24 * 60 * 60 * 1000;
     for (
-      let i = formData.date.startTime;
-      i <= formData.date.endTime;
+      let i = formData.date.startTime as number;
+      i <= (formData.date.endTime as number);
       i += oneDay
     ) {
-      const curDate = formatDate('YYYY/MM/DD', new Date(i));
+      const curDate = formatDate('YYYY/MM/DD', new Date(i as number));
       formData.times.forEach((item) => {
         times.push({
           id: null,

+ 4 - 4
src/views/order/task-manage/index.vue

@@ -116,17 +116,17 @@
       cellClass: 'action-column',
     },
   ];
-  const { dataList, pagination, toPage, getList } = useTable<TaskItem[]>(
+  const { dataList, pagination, toPage, getList } = useTable<TaskItem>(
     taskListPage,
     searchModel,
     true
   );
 
   // table action
-  const modifyTaskRef = ref(null);
-  const curRow = ref({});
+  const modifyTaskRef = ref();
+  const curRow = ref({} as TaskItem);
   function toAdd() {
-    curRow.value = {};
+    curRow.value = {} as TaskItem;
     modifyTaskRef.value?.open();
   }
   function toEdit(row: TaskItem) {

+ 3 - 3
src/views/order/task-manage/modifyTask.vue

@@ -62,8 +62,8 @@
     time: timeForm,
     notice: noticeForm,
   };
-
-  const compType = ref('rule');
+  type CompNameType = keyof typeof comps;
+  const compType = ref<CompNameType>('rule');
   const formComp = computed(() => comps[compType.value]);
 
   const taskData = ref<TaskItemDetail | null>(null);
@@ -83,7 +83,7 @@
       taskData.value = null;
       await getDetail();
     } else {
-      taskData.value = {};
+      taskData.value = {} as TaskItemDetail;
     }
     compType.value = 'rule';
   }

+ 1 - 1
src/views/order/task-manage/noticeForm.vue

@@ -41,7 +41,7 @@
   const emit = defineEmits(['cancel', 'modified']);
 
   const defaultFormData = {
-    id: '',
+    id: 0,
     notice: '',
   };
   type FormDataType = typeof defaultFormData;

+ 8 - 10
src/views/order/task-manage/ruleForm.vue

@@ -78,7 +78,7 @@
   import useLoading from '@/hooks/loading';
   import type { FormInstance, FieldRule } from '@arco-design/web-vue/es/form';
   import { objAssign, objModifyAssign } from '@/utils/utils';
-  import { TaskItemDetail } from '@/api/types/order';
+  import { TaskItemDetail, TaskRuleUpdateParams } from '@/api/types/order';
 
   defineOptions({
     name: 'RuleForm',
@@ -89,20 +89,18 @@
   const emit = defineEmits(['cancel', 'modified']);
 
   const defaultFormData = {
-    id: '',
+    id: null,
     name: '',
     allowApplyDays: 1,
     allowApplyCancelDays: 1,
-    selfApplyStartTime: null,
-    selfApplyEndTime: null,
-    openApplyStartTime: null,
-    openApplyEndTime: null,
+    selfApplyStartTime: undefined,
+    selfApplyEndTime: undefined,
+    openApplyStartTime: undefined,
+    openApplyEndTime: undefined,
   };
-  type FormDataType = typeof defaultFormData;
-
   const formRef = ref<FormInstance>();
-  const formData = reactive<FormDataType>({ ...defaultFormData });
-  const rules: Partial<Record<keyof FormDataType, FieldRule[]>> = {
+  const formData = reactive<TaskRuleUpdateParams>({ ...defaultFormData });
+  const rules: Partial<Record<keyof TaskRuleUpdateParams, FieldRule[]>> = {
     name: [
       {
         required: true,

+ 2 - 2
src/views/order/task-manage/timeForm.vue

@@ -52,7 +52,7 @@
 
   interface FormDataType {
     id: number;
-    times: TaskItemDetail.timeList;
+    times: TaskItemDetail['timeList'];
   }
 
   const defaultFormData = {
@@ -79,7 +79,7 @@
     addTimesRef.value?.open();
   }
 
-  function timeSelected(times) {
+  function timeSelected(times: TaskItemDetail['timeList']) {
     formData.times.push(...times);
   }
 

Some files were not shown because too many files changed in this diff