mirror of https://github.com/jeecgboot/jeecg-boot
Merge 2af453276b
into d01c1d7d47
commit
edb8944fc3
|
@ -2,15 +2,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="JPopup components-input-demo-presuffix" v-if="avalid">
|
<div class="JPopup components-input-demo-presuffix" v-if="avalid">
|
||||||
<!--输入框-->
|
<!--输入框-->
|
||||||
<a-input @click="handleOpen" :value="innerShowText || showText" :placeholder="placeholder" readOnly v-bind="attrs">
|
<a-input @click="handleOpen" v-model:value="showText" :placeholder="placeholder" v-bind="attrs" allow-clear @change="handleEmpty">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<Icon icon="ant-design:cluster-outlined"></Icon>
|
<Icon icon="ant-design:cluster-outlined"></Icon>
|
||||||
</template>
|
</template>
|
||||||
<!-- update-begin-author:taoyan date:2022-5-31 for: VUEN-1157 popup 选中后,有两个清除图标;后边这个清除,只是把输入框中数据清除,实际值并没有清除 -->
|
|
||||||
<!-- <template #suffix>
|
|
||||||
<Icon icon="ant-design:close-circle-outlined" @click="handleEmpty" title="清空" v-if="showText"></Icon>
|
|
||||||
</template>-->
|
|
||||||
<!-- update-begin-author:taoyan date:2022-5-31 for: VUEN-1157 popup 选中后,有两个清除图标;后边这个清除,只是把输入框中数据清除,实际值并没有清除 -->
|
|
||||||
</a-input>
|
</a-input>
|
||||||
<!-- update-begin--author:liaozhiyang---date:20240515---for:【QQYUN-9260】必填模式下会影响到弹窗内antd组件的样式 -->
|
<!-- update-begin--author:liaozhiyang---date:20240515---for:【QQYUN-9260】必填模式下会影响到弹窗内antd组件的样式 -->
|
||||||
<a-form-item>
|
<a-form-item>
|
||||||
|
@ -116,8 +111,25 @@
|
||||||
/**
|
/**
|
||||||
* TODO 清空
|
* TODO 清空
|
||||||
*/
|
*/
|
||||||
function handleEmpty() {
|
function handleEmpty(e) {
|
||||||
showText.value = '';
|
// showText.value = '';
|
||||||
|
// update-begin--author:huoshicang---date:20250716
|
||||||
|
if (!e.target.value) {
|
||||||
|
// 匹配popup设置的回调值
|
||||||
|
let { fieldConfig } = props;
|
||||||
|
// 初始化数据
|
||||||
|
let values = {};
|
||||||
|
for (let item of fieldConfig) {
|
||||||
|
item.target.split(',').forEach((target) => {
|
||||||
|
// 设置默认值为空字符串
|
||||||
|
values[target] = '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
props.formElRef && props.formElRef.setFieldsValue(values);
|
||||||
|
props.setFieldsValue && props.setFieldsValue(values);
|
||||||
|
emit('popUpChange', values);
|
||||||
|
}
|
||||||
|
// update-end--author:huoshicang---date:20250716
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -34,6 +34,10 @@ interface ListPageOptions {
|
||||||
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
||||||
// 导出成功后的回调
|
// 导出成功后的回调
|
||||||
success?: (fileInfo?: any) => void;
|
success?: (fileInfo?: any) => void;
|
||||||
|
// update-begin--author:huoshicang---date:20250805
|
||||||
|
parameters?: { key: String; value: String };
|
||||||
|
// update-end--author:huoshicang---date:20250805
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,11 +122,13 @@ export function useListPage(options: ListPageOptions) {
|
||||||
|
|
||||||
// 导入 excel
|
// 导入 excel
|
||||||
function onImportXls(file) {
|
function onImportXls(file) {
|
||||||
let { url, success } = options?.importConfig ?? {};
|
let { url, success, parameters = {} } = options?.importConfig ?? {};
|
||||||
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
//update-begin-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
||||||
let realUrl = typeof url === 'function' ? url() : url;
|
let realUrl = typeof url === 'function' ? url() : url;
|
||||||
if (realUrl) {
|
if (realUrl) {
|
||||||
return handleImportXls(file, realUrl, success || reload);
|
// update-begin--author:huoshicang---date:20250805
|
||||||
|
return handleImportXls(file, realUrl, success || reload, parameters);
|
||||||
|
// update-end--author:huoshicang---date:20250805
|
||||||
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
//update-end-author:taoyan date:20220507 for: erp代码生成 子表 导入地址是动态的
|
||||||
} else {
|
} else {
|
||||||
$message.createMessage.warn('没有传递 importConfig.url 参数');
|
$message.createMessage.warn('没有传递 importConfig.url 参数');
|
||||||
|
|
|
@ -59,8 +59,9 @@ export function useMethods() {
|
||||||
* @param data 导入的数据
|
* @param data 导入的数据
|
||||||
* @param url
|
* @param url
|
||||||
* @param success 成功后的回调
|
* @param success 成功后的回调
|
||||||
|
* @param parameters 导入携带的参数
|
||||||
*/
|
*/
|
||||||
async function importXls(data, url, success) {
|
async function importXls(data, url, success, parameters) {
|
||||||
const isReturn = (fileInfo) => {
|
const isReturn = (fileInfo) => {
|
||||||
try {
|
try {
|
||||||
if (fileInfo.code === 201) {
|
if (fileInfo.code === 201) {
|
||||||
|
@ -90,12 +91,14 @@ export function useMethods() {
|
||||||
typeof success === 'function' ? success(fileInfo) : '';
|
typeof success === 'function' ? success(fileInfo) : '';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
await defHttp.uploadFile({ url }, { file: data.file }, { success: isReturn });
|
await defHttp.uploadFile({ url }, { file: data.file }, { success: isReturn }, parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
handleExportXls: (name: string, url: string, params?: object) => exportXls(name, url, params),
|
handleExportXls: (name: string, url: string, params?: object) => exportXls(name, url, params),
|
||||||
handleImportXls: (data, url, success) => importXls(data, url, success),
|
// update-begin--author:huoshicang---date:20250805
|
||||||
|
handleImportXls: (data, url, success, parameters) => importXls(data, url, success, parameters),
|
||||||
|
// update-end--author:huoshicang---date:20250805
|
||||||
handleExportXlsx: (name: string, url: string, params?: object) => exportXls(name, url, params, true),
|
handleExportXlsx: (name: string, url: string, params?: object) => exportXls(name, url, params, true),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import type { AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError } from 'axios';
|
import type {AxiosRequestConfig, AxiosInstance, AxiosResponse, AxiosError} from 'axios';
|
||||||
import type { RequestOptions, Result, UploadFileParams, UploadFileCallBack } from '/#/axios';
|
import type {RequestOptions, Result, UploadFileParams, UploadFileCallBack} from '/#/axios';
|
||||||
import type { CreateAxiosOptions } from './axiosTransform';
|
import type {CreateAxiosOptions} from './axiosTransform';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
import { AxiosCanceler } from './axiosCancel';
|
import {AxiosCanceler} from './axiosCancel';
|
||||||
import { isFunction } from '/@/utils/is';
|
import {isFunction} from '/@/utils/is';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import {cloneDeep} from 'lodash-es';
|
||||||
import { ContentTypeEnum } from '/@/enums/httpEnum';
|
import {ContentTypeEnum} from '/@/enums/httpEnum';
|
||||||
import { RequestEnum } from '/@/enums/httpEnum';
|
import {RequestEnum} from '/@/enums/httpEnum';
|
||||||
import { useGlobSetting } from '/@/hooks/setting';
|
import {useGlobSetting} from '/@/hooks/setting';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import {useMessage} from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
const { createMessage } = useMessage();
|
const {createMessage} = useMessage();
|
||||||
export * from './axiosTransform';
|
export * from './axiosTransform';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -35,7 +35,7 @@ export class VAxios {
|
||||||
}
|
}
|
||||||
|
|
||||||
private getTransform() {
|
private getTransform() {
|
||||||
const { transform } = this.options;
|
const {transform} = this.options;
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,12 @@ export class VAxios {
|
||||||
if (!transform) {
|
if (!transform) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { requestInterceptors, requestInterceptorsCatch, responseInterceptors, responseInterceptorsCatch } = transform;
|
const {
|
||||||
|
requestInterceptors,
|
||||||
|
requestInterceptorsCatch,
|
||||||
|
responseInterceptors,
|
||||||
|
responseInterceptorsCatch
|
||||||
|
} = transform;
|
||||||
|
|
||||||
const axiosCanceler = new AxiosCanceler();
|
const axiosCanceler = new AxiosCanceler();
|
||||||
|
|
||||||
|
@ -79,7 +84,7 @@ export class VAxios {
|
||||||
this.axiosInstance.interceptors.request.use((config: AxiosRequestConfig) => {
|
this.axiosInstance.interceptors.request.use((config: AxiosRequestConfig) => {
|
||||||
// If cancel repeat request is turned on, then cancel repeat request is prohibited
|
// If cancel repeat request is turned on, then cancel repeat request is prohibited
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const { ignoreCancelToken } = config.requestOptions;
|
const {ignoreCancelToken} = config.requestOptions;
|
||||||
|
|
||||||
const ignoreCancel = ignoreCancelToken !== undefined ? ignoreCancelToken : this.options.requestOptions?.ignoreCancelToken;
|
const ignoreCancel = ignoreCancelToken !== undefined ? ignoreCancelToken : this.options.requestOptions?.ignoreCancelToken;
|
||||||
|
|
||||||
|
@ -114,7 +119,11 @@ export class VAxios {
|
||||||
* 文件上传
|
* 文件上传
|
||||||
*/
|
*/
|
||||||
//--@updateBy-begin----author:liusq---date:20211117------for:增加上传回调参数callback------
|
//--@updateBy-begin----author:liusq---date:20211117------for:增加上传回调参数callback------
|
||||||
uploadFile<T = any>(config: AxiosRequestConfig, params: UploadFileParams, callback?: UploadFileCallBack) {
|
// update-begin--author:huoshicang---date:20250805
|
||||||
|
uploadFile<T = any>(config: AxiosRequestConfig, params: UploadFileParams, callback?: UploadFileCallBack, parameters?: {
|
||||||
|
key: String;
|
||||||
|
value: String
|
||||||
|
}) {
|
||||||
//--@updateBy-end----author:liusq---date:20211117------for:增加上传回调参数callback------
|
//--@updateBy-end----author:liusq---date:20211117------for:增加上传回调参数callback------
|
||||||
const formData = new window.FormData();
|
const formData = new window.FormData();
|
||||||
const customFilename = params.name || 'file';
|
const customFilename = params.name || 'file';
|
||||||
|
@ -139,6 +148,11 @@ export class VAxios {
|
||||||
formData.append(key, params.data[key]);
|
formData.append(key, params.data[key]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// update-begin--author:huoshicang---date:20250805
|
||||||
|
if (Object.keys(parameters).length != 0) {
|
||||||
|
for (const key in parameters) formData.append(key, parameters[key]);
|
||||||
|
}
|
||||||
|
// update-end--author:huoshicang---date:20250805
|
||||||
|
|
||||||
return this.axiosInstance
|
return this.axiosInstance
|
||||||
.request<T>({
|
.request<T>({
|
||||||
|
@ -180,35 +194,35 @@ export class VAxios {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...config,
|
...config,
|
||||||
data: qs.stringify(config.data, { arrayFormat: 'brackets' }),
|
data: qs.stringify(config.data, {arrayFormat: 'brackets'}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
get<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
get<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
||||||
return this.request({ ...config, method: 'GET' }, options);
|
return this.request({...config, method: 'GET'}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
post<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
post<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
||||||
return this.request({ ...config, method: 'POST' }, options);
|
return this.request({...config, method: 'POST'}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
put<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
put<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
||||||
return this.request({ ...config, method: 'PUT' }, options);
|
return this.request({...config, method: 'PUT'}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
delete<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
||||||
return this.request({ ...config, method: 'DELETE' }, options);
|
return this.request({...config, method: 'DELETE'}, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
request<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
request<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
|
||||||
let conf: CreateAxiosOptions = cloneDeep(config);
|
let conf: CreateAxiosOptions = cloneDeep(config);
|
||||||
const transform = this.getTransform();
|
const transform = this.getTransform();
|
||||||
|
|
||||||
const { requestOptions } = this.options;
|
const {requestOptions} = this.options;
|
||||||
|
|
||||||
const opt: RequestOptions = Object.assign({}, requestOptions, options);
|
const opt: RequestOptions = Object.assign({}, requestOptions, options);
|
||||||
|
|
||||||
const { beforeRequestHook, requestCatchHook, transformRequestHook } = transform || {};
|
const {beforeRequestHook, requestCatchHook, transformRequestHook} = transform || {};
|
||||||
if (beforeRequestHook && isFunction(beforeRequestHook)) {
|
if (beforeRequestHook && isFunction(beforeRequestHook)) {
|
||||||
conf = beforeRequestHook(conf, opt);
|
conf = beforeRequestHook(conf, opt);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue