Merge branch 'dev' of http://120.46.213.136:9528/isoftstone/lc_frontend into dev
This commit is contained in:
@@ -6,17 +6,17 @@ import axios, {
|
||||
InternalAxiosRequestConfig
|
||||
} from 'axios'
|
||||
|
||||
import { ElMessage, ElMessageBox, ElNotification, ElButton } from 'element-plus'
|
||||
import {ElMessage, ElMessageBox, ElNotification, ElButton} from 'element-plus'
|
||||
import qs from 'qs'
|
||||
import { config, specificApiTimeoutObj } from '@/config/axios/config'
|
||||
import { getAccessToken, getRefreshToken, getTenantId, removeToken, setToken } from '@/utils/auth'
|
||||
import {config, specificApiTimeoutObj} from '@/config/axios/config'
|
||||
import {getAccessToken, getRefreshToken, getTenantId, removeToken, setToken} from '@/utils/auth'
|
||||
import errorCode from './errorCode'
|
||||
|
||||
import { resetRouter } from '@/router'
|
||||
import { useCache } from '@/hooks/web/useCache'
|
||||
import {resetRouter} from '@/router'
|
||||
import {useCache} from '@/hooks/web/useCache'
|
||||
|
||||
const tenantEnable = import.meta.env.VITE_APP_TENANT_ENABLE
|
||||
const { result_code, base_url, request_timeout } = config
|
||||
const {result_code, base_url, request_timeout} = config
|
||||
|
||||
// 需要忽略的提示。忽略后,自动 Promise.reject('error')
|
||||
const ignoreMsgs = [
|
||||
@@ -24,7 +24,7 @@ const ignoreMsgs = [
|
||||
'刷新令牌已过期' // 使用刷新令牌,刷新获取新的访问令牌时,结果因为过期失败,此时需要忽略。否则,会导致继续 401,无法跳转到登出界面
|
||||
]
|
||||
// 是否显示重新登录
|
||||
export const isRelogin = { show: false }
|
||||
export const isRelogin = {show: false}
|
||||
// Axios 无感知刷新令牌,参考 https://www.dashingdog.cn/article/11 与 https://segmentfault.com/a/1190000020210980 实现
|
||||
// 请求队列
|
||||
let requestList: any[] = []
|
||||
@@ -51,7 +51,7 @@ service.interceptors.request.use(
|
||||
}
|
||||
})
|
||||
if (getAccessToken() && !isToken) {
|
||||
; (config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token
|
||||
;(config as Recordable).headers.Authorization = 'Bearer ' + getAccessToken() // 让每个请求携带自定义token
|
||||
}
|
||||
// 设置租户
|
||||
if (tenantEnable && tenantEnable === 'true') {
|
||||
@@ -74,7 +74,7 @@ service.interceptors.request.use(
|
||||
// get参数编码
|
||||
if (config.method?.toUpperCase() === 'GET' && params) {
|
||||
config.params = {}
|
||||
const paramsStr = qs.stringify(params, { allowDots: true })
|
||||
const paramsStr = qs.stringify(params, {allowDots: true})
|
||||
if (paramsStr) {
|
||||
config.url = config.url + '?' + paramsStr
|
||||
}
|
||||
@@ -91,13 +91,13 @@ service.interceptors.request.use(
|
||||
// response 拦截器
|
||||
service.interceptors.response.use(
|
||||
async (response: AxiosResponse<any>) => {
|
||||
let { data } = response
|
||||
let {data} = response
|
||||
const config = response.config
|
||||
if (!data) {
|
||||
// 返回“[HTTP]请求没有返回值”;
|
||||
throw new Error()
|
||||
}
|
||||
const { t } = useI18n()
|
||||
const {t} = useI18n()
|
||||
// 未设置状态码则默认成功状态
|
||||
// 二进制数据则直接返回,例如说 Excel 导出
|
||||
if (
|
||||
@@ -159,6 +159,8 @@ service.interceptors.response.use(
|
||||
} else if (code === 500) {
|
||||
ElMessage.error(t('sys.api.errMsg500'))
|
||||
return Promise.reject(new Error(msg))
|
||||
} else if (code === 504) {
|
||||
return Promise.reject(new Error(msg))
|
||||
} else if (code === 901) {
|
||||
ElMessage.error({
|
||||
offset: 300,
|
||||
@@ -186,7 +188,7 @@ service.interceptors.response.use(
|
||||
// hard coding:忽略这个提示,直接登出
|
||||
console.log(msg)
|
||||
} else {
|
||||
ElNotification.error({ title: msg })
|
||||
ElNotification.error({title: msg})
|
||||
}
|
||||
return Promise.reject('error')
|
||||
} else {
|
||||
@@ -195,8 +197,8 @@ service.interceptors.response.use(
|
||||
},
|
||||
(error: AxiosError) => {
|
||||
console.log('err' + error) // for debug
|
||||
let { message } = error
|
||||
const { t } = useI18n()
|
||||
let {message} = error
|
||||
const {t} = useI18n()
|
||||
if (message === 'Network Error') {
|
||||
message = t('sys.api.errorMessage')
|
||||
} else if (message.includes('timeout')) {
|
||||
@@ -214,7 +216,7 @@ const refreshToken = async () => {
|
||||
return await axios.post('/system/auth/refresh-token?refreshToken=' + getRefreshToken())
|
||||
}
|
||||
const handleAuthorized = () => {
|
||||
const { t } = useI18n()
|
||||
const {t} = useI18n()
|
||||
if (!isRelogin.show) {
|
||||
// 如果已经到重新登录页面则不进行弹窗提示
|
||||
if (window.location.href.includes('login?redirect=')) {
|
||||
@@ -228,7 +230,7 @@ const handleAuthorized = () => {
|
||||
confirmButtonText: t('login.relogin'),
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const { wsCache } = useCache()
|
||||
const {wsCache} = useCache()
|
||||
resetRouter() // 重置静态路由表
|
||||
wsCache.clear()
|
||||
removeToken()
|
||||
@@ -242,7 +244,7 @@ const handleAuthorized = () => {
|
||||
const handleMoreError = (title, message) => {
|
||||
ElMessageBox.alert(`<div style="white-space: break-spaces;">${message}</div>`, title, {
|
||||
dangerouslyUseHTMLString: true,
|
||||
customStyle: { maxWidth: '40%' }
|
||||
customStyle: {maxWidth: '40%'}
|
||||
})
|
||||
}
|
||||
export { service }
|
||||
export {service}
|
||||
|
||||
@@ -291,10 +291,10 @@ const inProgressCount = ref<number>(0)
|
||||
const finishedCount = ref<number>(0)
|
||||
|
||||
const handleSeverityCountClick = () => {
|
||||
window.open('http://10.0.64.20/configcenter/console/device-manage', '_blank')
|
||||
window.open('http://10.0.64.20/pms/workorder-list', '_blank')
|
||||
}
|
||||
const handleGeneralCountClick = () => {
|
||||
window.open('http://10.0.64.20/configcenter/console/device-manage', '_blank')
|
||||
window.open('http://10.0.64.20/pms/workorder-list', '_blank')
|
||||
}
|
||||
|
||||
const riskStatistics = ref<any>({
|
||||
|
||||
@@ -73,7 +73,7 @@ let scrollTimer: NodeJS.Timeout | null = null
|
||||
let isScrolling = false
|
||||
|
||||
const handleItemClick = (item: AlertItem) => {
|
||||
window.open(`http://10.0.64.20/configcenter/console/device-manage`, '_blank')
|
||||
window.open(`http://10.0.64.20/pms/workorder-list`, '_blank')
|
||||
}
|
||||
|
||||
// 自动滚动功能
|
||||
|
||||
@@ -198,7 +198,7 @@ const top3TypesChartOption = ref<any>({
|
||||
})
|
||||
|
||||
const handleMajorClick = () => {
|
||||
window.open('http://10.0.64.20/configcenter/console/device-manage', '_blank')
|
||||
window.open('http://10.0.64.20/pms/workorder-list', '_blank')
|
||||
}
|
||||
|
||||
watch(() => props.hiddenDangerData?.progress, (newVal) => {
|
||||
|
||||
@@ -597,11 +597,11 @@ const handleRiskTabChange = async (tab: TabType) => {
|
||||
|
||||
// 同时获取维保任务和巡检任务的数据
|
||||
const [maintenanceResponse, inspectionResponse] = await Promise.all([
|
||||
getWorkOrderStatistics({workOrderType, taskType: '维保任务'}).catch(error => {
|
||||
getWorkOrderStatistics({workOrderType, taskType: '维保任务',campus_id: query.campus_id}).catch(error => {
|
||||
console.error('获取维保任务数据失败:', error)
|
||||
return { records: [] }
|
||||
}),
|
||||
getWorkOrderStatistics({workOrderType, taskType: '巡检任务'}).catch(error => {
|
||||
getWorkOrderStatistics({workOrderType, taskType: '巡检任务',campus_id: query.campus_id}).catch(error => {
|
||||
console.error('获取巡检任务数据失败:', error)
|
||||
return { records: [] }
|
||||
})
|
||||
|
||||
@@ -136,7 +136,7 @@ export const batchGetTableList = (reportCodes: string, data?) => {
|
||||
// 统计周期 cycle: day,month,year 对应月日年
|
||||
|
||||
export const getWorkOrderStatistics = (data: {workOrderType: string, taskType: string, campus_id?: string}) => {
|
||||
return request.post({ url: '/jeelowcode/report-data/list/report_work_order_statistics', data: {...data, page: 1, paseSize: 1} })
|
||||
return request.post({ url: '/jeelowcode/report-data/list/report_work_order_statistics', data: {...data, pageNo: 1, pageSize: 10} })
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user