fix: 调整网络错误的提示形式,出现网络超时不再踢出登录
fix: 修复当key为数字类型时,联想弹层第一次选择显示title失败的bug
This commit is contained in:
@ -121,6 +121,9 @@ export const basicComponents = [
|
|||||||
typeName: t('计数组件'),
|
typeName: t('计数组件'),
|
||||||
type: 'number',
|
type: 'number',
|
||||||
options: {
|
options: {
|
||||||
|
labelWidthMode: 'fix',
|
||||||
|
labelFixWidth: 120,
|
||||||
|
responsive: false,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
span: '',
|
span: '',
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
@ -1165,6 +1168,9 @@ export const infoComponents = [
|
|||||||
typeName: t('人员选择'),
|
typeName: t('人员选择'),
|
||||||
type: 'user',
|
type: 'user',
|
||||||
options: {
|
options: {
|
||||||
|
labelWidthMode: 'fix',
|
||||||
|
labelFixWidth: 120,
|
||||||
|
responsive: false,
|
||||||
span: '',
|
span: '',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
|
|||||||
@ -2,71 +2,71 @@
|
|||||||
<div>
|
<div>
|
||||||
<a-input
|
<a-input
|
||||||
v-model:value="popupValue"
|
v-model:value="popupValue"
|
||||||
:placeholder="placeholder"
|
|
||||||
:addonBefore="addonBefore"
|
|
||||||
:addonAfter="addonAfter"
|
:addonAfter="addonAfter"
|
||||||
:disabled="disabled"
|
:addonBefore="addonBefore"
|
||||||
:bordered="bordered"
|
:bordered="bordered"
|
||||||
autoComplete="off"
|
:disabled="disabled"
|
||||||
|
:placeholder="placeholder"
|
||||||
:size="size"
|
:size="size"
|
||||||
allowClear
|
allowClear
|
||||||
@click="showDialog"
|
autoComplete="off"
|
||||||
@change="handleChange"
|
@change="handleChange"
|
||||||
|
@click="showDialog"
|
||||||
>
|
>
|
||||||
<template #prefix v-if="prefix">
|
<template v-if="prefix" #prefix>
|
||||||
<Icon :icon="prefix" />
|
<Icon :icon="prefix"/>
|
||||||
</template>
|
</template>
|
||||||
<template #suffix v-if="suffix">
|
<template v-if="suffix" #suffix>
|
||||||
<Icon :icon="suffix" />
|
<Icon :icon="suffix"/>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
<FormItemRest>
|
<FormItemRest>
|
||||||
<MultipleSelect
|
<MultipleSelect
|
||||||
ref="MultipleSelectRef"
|
ref="MultipleSelectRef"
|
||||||
v-model:multipleDialog="multipleDialog"
|
v-model:multipleDialog="multipleDialog"
|
||||||
:popupType="popupType"
|
|
||||||
:dataSourceOptions="dataSourceOptions"
|
|
||||||
:params="params"
|
|
||||||
v-model:value="defaultVal"
|
|
||||||
v-model:popupValue="popupValue"
|
v-model:popupValue="popupValue"
|
||||||
:labelField="labelField"
|
v-model:selectedDataSource="selectedDataSourceVal"
|
||||||
:valueField="valueField"
|
v-model:value="defaultVal"
|
||||||
|
:apiConfig="apiConfig"
|
||||||
|
:dataSourceOptions="dataSourceOptions"
|
||||||
:datasourceType="datasourceType"
|
:datasourceType="datasourceType"
|
||||||
:dicOptions="dicOptions"
|
:dicOptions="dicOptions"
|
||||||
:apiConfig="apiConfig"
|
:labelField="labelField"
|
||||||
v-model:selectedDataSource="selectedDataSourceVal"
|
|
||||||
:mainKey="mainKey"
|
:mainKey="mainKey"
|
||||||
|
:params="params"
|
||||||
|
:popupType="popupType"
|
||||||
:subTableIndex="index"
|
:subTableIndex="index"
|
||||||
@get-list="getList"
|
:valueField="valueField"
|
||||||
@submit="handleSubmit"
|
@submit="handleSubmit"
|
||||||
|
@get-list="getList"
|
||||||
/>
|
/>
|
||||||
</FormItemRest>
|
</FormItemRest>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, watch, nextTick, inject, onMounted } from 'vue';
|
import {ref, watch, nextTick, inject, onMounted} from 'vue';
|
||||||
import { Form } from 'ant-design-vue';
|
import {Form} from 'ant-design-vue';
|
||||||
import { Icon } from '/@/components/Icon';
|
import {Icon} from '/@/components/Icon';
|
||||||
import MultipleSelect from './components/MultipleSelect.vue';
|
import MultipleSelect from './components/MultipleSelect.vue';
|
||||||
import { camelCaseString, isValidJSON } from '/@/utils/event/design';
|
import {camelCaseString, isValidJSON} from '/@/utils/event/design';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
popupType: { type: String },
|
popupType: {type: String},
|
||||||
value: { type: String },
|
value: {type: String},
|
||||||
labelField: { type: String, default: 'label' },
|
labelField: {type: String, default: 'label'},
|
||||||
valueField: { type: String, default: 'value' },
|
valueField: {type: String, default: 'value'},
|
||||||
placeholder: { type: String },
|
placeholder: {type: String},
|
||||||
addonBefore: { type: String },
|
addonBefore: {type: String},
|
||||||
addonAfter: { type: String },
|
addonAfter: {type: String},
|
||||||
prefix: { type: String },
|
prefix: {type: String},
|
||||||
suffix: { type: String },
|
suffix: {type: String},
|
||||||
disabled: { type: Boolean },
|
disabled: {type: Boolean},
|
||||||
params: { type: [Array, Object, String, Number] },
|
params: {type: [Array, Object, String, Number]},
|
||||||
dataSourceOptions: { type: Array },
|
dataSourceOptions: {type: Array},
|
||||||
dicOptions: { type: Array },
|
dicOptions: {type: Array},
|
||||||
//数据来源 默认为空 如果不为空 则参数 api
|
//数据来源 默认为空 如果不为空 则参数 api
|
||||||
datasourceType: String,
|
datasourceType: String,
|
||||||
apiConfig: { type: Object },
|
apiConfig: {type: Object},
|
||||||
bordered: {
|
bordered: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: true,
|
default: true,
|
||||||
@ -115,6 +115,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getSubDatasourceList = async () => {
|
const getSubDatasourceList = async () => {
|
||||||
|
debugger;
|
||||||
let showValueArr: string[] = [];
|
let showValueArr: string[] = [];
|
||||||
await MultipleSelectRef.value?.getDatasourceList();
|
await MultipleSelectRef.value?.getDatasourceList();
|
||||||
|
|
||||||
@ -123,7 +124,12 @@
|
|||||||
const selectedArr = props.value?.split(',');
|
const selectedArr = props.value?.split(',');
|
||||||
dataSourceList.value?.map((item) => {
|
dataSourceList.value?.map((item) => {
|
||||||
selectedArr?.map((selected) => {
|
selectedArr?.map((selected) => {
|
||||||
if (item[props.valueField] === selected) {
|
let itemVal = item[props.valueField];
|
||||||
|
if ((itemVal || itemVal === 0) && typeof selected === 'string') {
|
||||||
|
// 处理当key为数字类型时
|
||||||
|
itemVal += '';
|
||||||
|
}
|
||||||
|
if (itemVal === selected) {
|
||||||
selectedDataSourceVal.value?.push(item);
|
selectedDataSourceVal.value?.push(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -310,11 +310,7 @@ export class VAxios {
|
|||||||
})
|
})
|
||||||
.catch((e: Error | AxiosError) => {
|
.catch((e: Error | AxiosError) => {
|
||||||
if (e.message.includes('timeout') || e.message.includes('Network Error')) {
|
if (e.message.includes('timeout') || e.message.includes('Network Error')) {
|
||||||
const userStore = useUserStore();
|
// 太极端了,这里没必要给人踢回登录页面
|
||||||
userStore.setToken(undefined);
|
|
||||||
userStore.setSessionTimeout(false);
|
|
||||||
userStore.setUserInfo(null);
|
|
||||||
router.push(PageEnum.BASE_LOGIN);
|
|
||||||
}
|
}
|
||||||
if (requestCatchHook && isFunction(requestCatchHook)) {
|
if (requestCatchHook && isFunction(requestCatchHook)) {
|
||||||
reject(requestCatchHook(e, opt));
|
reject(requestCatchHook(e, opt));
|
||||||
|
|||||||
@ -20,11 +20,23 @@ import { useUserStoreWithOut } from '/@/store/modules/user';
|
|||||||
import { AxiosRetry } from '/@/utils/http/axios/axiosRetry';
|
import { AxiosRetry } from '/@/utils/http/axios/axiosRetry';
|
||||||
import { useGo } from '/@/hooks/web/usePage';
|
import { useGo } from '/@/hooks/web/usePage';
|
||||||
import { validateScript } from '/@/utils/event/design';
|
import { validateScript } from '/@/utils/event/design';
|
||||||
|
import { notification } from 'ant-design-vue';
|
||||||
|
import { throttle } from 'lodash-es';
|
||||||
|
|
||||||
const globSetting = useGlobSetting();
|
const globSetting = useGlobSetting();
|
||||||
const urlPrefix = globSetting.urlPrefix;
|
const urlPrefix = globSetting.urlPrefix;
|
||||||
const { createMessage, createErrorModal } = useMessage();
|
const { createMessage, createErrorModal } = useMessage();
|
||||||
|
|
||||||
|
const showNetworkError = function() {
|
||||||
|
notification.error({
|
||||||
|
message: '网络超时,请检查本地网络是否正常,或者稍后再试',
|
||||||
|
placement: 'topRight',
|
||||||
|
duration: 3
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const trNetworkError = throttle(showNetworkError, 5000, { trailing: false });
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 数据处理,方便区分多种处理方式
|
* @description: 数据处理,方便区分多种处理方式
|
||||||
*/
|
*/
|
||||||
@ -127,7 +139,7 @@ const transform: AxiosTransform = {
|
|||||||
if (isBoolean(joinParamsToUrl) && joinParamsToUrl) {
|
if (isBoolean(joinParamsToUrl) && joinParamsToUrl) {
|
||||||
config.url = setObjToUrlParams(
|
config.url = setObjToUrlParams(
|
||||||
config.url as string,
|
config.url as string,
|
||||||
Object.assign({}, config.params, config.data),
|
Object.assign({}, config.params, config.data)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -176,13 +188,10 @@ const transform: AxiosTransform = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
|
if (code === 'ECONNABORTED' && message.indexOf('timeout') !== -1) {
|
||||||
errMessage = t('接口请求超时,请刷新页面重试!');
|
trNetworkError();
|
||||||
}
|
} else if (err?.includes('Network Error')) {
|
||||||
if (err?.includes('Network Error')) {
|
trNetworkError();
|
||||||
errMessage = t('网络异常,请检查您的网络连接是否正常!');
|
} else if (errMessage) {
|
||||||
}
|
|
||||||
|
|
||||||
if (errMessage) {
|
|
||||||
if (errorMessageMode === 'modal') {
|
if (errorMessageMode === 'modal') {
|
||||||
createErrorModal({ title: t('错误提示'), content: errMessage });
|
createErrorModal({ title: t('错误提示'), content: errMessage });
|
||||||
} else if (errorMessageMode === 'message') {
|
} else if (errorMessageMode === 'message') {
|
||||||
@ -204,7 +213,7 @@ const transform: AxiosTransform = {
|
|||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
retryRequest.retry(axiosInstance, error);
|
retryRequest.retry(axiosInstance, error);
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
},
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function createAxios(opt?: Partial<CreateAxiosOptions>) {
|
function createAxios(opt?: Partial<CreateAxiosOptions>) {
|
||||||
@ -251,14 +260,15 @@ function createAxios(opt?: Partial<CreateAxiosOptions>) {
|
|||||||
retryRequest: {
|
retryRequest: {
|
||||||
isOpenRetry: false,
|
isOpenRetry: false,
|
||||||
count: 5,
|
count: 5,
|
||||||
waitTime: 100,
|
waitTime: 100
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
opt || {}
|
||||||
},
|
)
|
||||||
opt || {},
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defHttp = createAxios();
|
export const defHttp = createAxios();
|
||||||
|
|
||||||
// other api url
|
// other api url
|
||||||
|
|||||||
Reference in New Issue
Block a user