Commit 54f99a8b489e87a790f9653d4fbd0d41ed3ace36

Authored by 杨泽宇
1 parent 0831d929

ts类型补充

src/@type/module/basic.d.ts 0 → 100644
  1 +
  2 +/**
  3 + * 枚举数组中对象类型
  4 + */
  5 +export interface EnumArrayItem {
  6 + label: string,
  7 + value: string | number,
  8 +}
0 9 \ No newline at end of file
... ...
src/@type/vue-router/index.d.ts renamed to src/@type/module/index.d.ts
src/api/request.ts
... ... @@ -26,7 +26,6 @@ instance.interceptors.request.use(
26 26 )
27 27  
28 28 instance.interceptors.response.use(
29   - // @ts-ignore
30 29 response => {
31 30 if (response) {
32 31 if (response?.data?.errorCode === 0) {
... ... @@ -49,6 +48,9 @@ instance.interceptors.response.use(
49 48 ElMessage.error(response?.data?.errorMessage || '操作失败');
50 49 break
51 50 }
  51 + // TIP declare axios 的 module reject就不报ts类型错误
  52 + // declare位置 src/@type/module/index.d.ts
  53 + // 原因还没研究明白呢
52 54 return Promise.reject()
53 55 }
54 56 }
... ...
src/utils/tool.ts
  1 +import type { EnumArrayItem } from "@/@type/module/basic"
  2 +
1 3 /**
2 4 * 页面回退
3 5 */
... ... @@ -143,11 +145,7 @@ export function formatTime(time, option) {
143 145 * @param {Array.EnumData} groupData
144 146 * @returns {string}
145 147 */
146   -interface EnumData {
147   - value: number | string,
148   - label: string
149   -}
150   -export function globalFilters (value: number, groupData: EnumData[]) {
  148 +export function globalFilters (value: number, groupData: EnumArrayItem[]) {
151 149 if(groupData.length && (~~value === 0 || !!value)) {
152 150 return groupData.find(item => ~~item.value === ~~value)['label']
153 151 } else {
... ...
src/views/column/config.ts
1   -interface Type {
2   - label: string,
3   - value: string
4   -}
  1 +import type { EnumArrayItem } from "@/@type/module/basic"
5 2  
6   -// 栏目类型
7   -export const types: Type[] = [
  3 +/**
  4 + * 栏目类型
  5 + */
  6 +export const types: EnumArrayItem[] = [
8 7 {
9 8 label: '权威资讯',
10 9 value: '1'
... ...
src/views/column/index.vue
... ... @@ -4,7 +4,7 @@ import { columnList, columnStatus, columnSort } from "@/api/property/column";
4 4 import Pagination from "@/components/Pagination/index.vue";
5 5 import { ElMessageBox } from "element-plus";
6 6 import { types } from "./config";
7   -import { globalFilters } from "@/utils/tool";
  7 +import { globalFilters, enumArray } from "@/utils/tool";
8 8 interface Form {
9 9 page: number;
10 10 pageSize: number;
... ... @@ -32,6 +32,8 @@ let data: Data = reactive({
32 32 },
33 33 },
34 34 });
  35 +// let testData = new enumArray()
  36 +// console.log(testData)
35 37 /**
36 38 * 列表
37 39 */
... ...
src/views/event/category/index.vue
... ... @@ -44,7 +44,7 @@ let form = reactive({
44 44 id: null,
45 45 createTime: "",
46 46 deleteFlag: "",
47   - oid = useLoginStore()?.getOid ?? 0,
  47 + oid: useLoginStore()?.getOid ?? 0,
48 48 // oid: store?.family?.loginStore()?.organizationId ?? 0,
49 49 });
50 50 /**
... ...
src/views/repair/config.ts
1   -interface Option {
2   - label: string,
3   - value: number
4   -}
  1 +import type { EnumArrayItem } from "@/@type/module/basic"
5 2  
6 3 /**
7 4 * 工单状态
8 5 */
9   -export const status: Option[] = [
  6 +export const status: EnumArrayItem[] = [
10 7 {
11 8 label: '未处理',
12 9 value: 0
... ...