Commit 54f99a8b489e87a790f9653d4fbd0d41ed3ace36
1 parent
0831d929
ts类型补充
Showing
8 changed files
with
25 additions
and
19 deletions
src/@type/module/basic.d.ts
0 → 100644
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,7 +26,6 @@ instance.interceptors.request.use( | ||
| 26 | ) | 26 | ) |
| 27 | 27 | ||
| 28 | instance.interceptors.response.use( | 28 | instance.interceptors.response.use( |
| 29 | - // @ts-ignore | ||
| 30 | response => { | 29 | response => { |
| 31 | if (response) { | 30 | if (response) { |
| 32 | if (response?.data?.errorCode === 0) { | 31 | if (response?.data?.errorCode === 0) { |
| @@ -49,6 +48,9 @@ instance.interceptors.response.use( | @@ -49,6 +48,9 @@ instance.interceptors.response.use( | ||
| 49 | ElMessage.error(response?.data?.errorMessage || '操作失败'); | 48 | ElMessage.error(response?.data?.errorMessage || '操作失败'); |
| 50 | break | 49 | break |
| 51 | } | 50 | } |
| 51 | + // TIP declare axios 的 module reject就不报ts类型错误 | ||
| 52 | + // declare位置 src/@type/module/index.d.ts | ||
| 53 | + // 原因还没研究明白呢 | ||
| 52 | return Promise.reject() | 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,11 +145,7 @@ export function formatTime(time, option) { | ||
| 143 | * @param {Array.EnumData} groupData | 145 | * @param {Array.EnumData} groupData |
| 144 | * @returns {string} | 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 | if(groupData.length && (~~value === 0 || !!value)) { | 149 | if(groupData.length && (~~value === 0 || !!value)) { |
| 152 | return groupData.find(item => ~~item.value === ~~value)['label'] | 150 | return groupData.find(item => ~~item.value === ~~value)['label'] |
| 153 | } else { | 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 | label: '权威资讯', | 8 | label: '权威资讯', |
| 10 | value: '1' | 9 | value: '1' |
src/views/column/index.vue
| @@ -4,7 +4,7 @@ import { columnList, columnStatus, columnSort } from "@/api/property/column"; | @@ -4,7 +4,7 @@ import { columnList, columnStatus, columnSort } from "@/api/property/column"; | ||
| 4 | import Pagination from "@/components/Pagination/index.vue"; | 4 | import Pagination from "@/components/Pagination/index.vue"; |
| 5 | import { ElMessageBox } from "element-plus"; | 5 | import { ElMessageBox } from "element-plus"; |
| 6 | import { types } from "./config"; | 6 | import { types } from "./config"; |
| 7 | -import { globalFilters } from "@/utils/tool"; | 7 | +import { globalFilters, enumArray } from "@/utils/tool"; |
| 8 | interface Form { | 8 | interface Form { |
| 9 | page: number; | 9 | page: number; |
| 10 | pageSize: number; | 10 | pageSize: number; |
| @@ -32,6 +32,8 @@ let data: Data = reactive({ | @@ -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,7 +44,7 @@ let form = reactive({ | ||
| 44 | id: null, | 44 | id: null, |
| 45 | createTime: "", | 45 | createTime: "", |
| 46 | deleteFlag: "", | 46 | deleteFlag: "", |
| 47 | - oid = useLoginStore()?.getOid ?? 0, | 47 | + oid: useLoginStore()?.getOid ?? 0, |
| 48 | // oid: store?.family?.loginStore()?.organizationId ?? 0, | 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 | label: '未处理', | 8 | label: '未处理', |
| 12 | value: 0 | 9 | value: 0 |