基础模块已调整为微服务的端口进行访问

main
HUOJIN\92525 2026-03-13 10:48:40 +08:00
parent 3be39e53b0
commit d0813512aa
7 changed files with 35 additions and 12 deletions

View File

@ -9,6 +9,7 @@ import { useMethods } from '/@/hooks/system/useMethods';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { filterObj } from '/@/utils/common/compUtils'; import { filterObj } from '/@/utils/common/compUtils';
import { isFunction } from '@/utils/is'; import { isFunction } from '@/utils/is';
import type { VAxios } from '/@/utils/http/axios/Axios';
const { handleExportXls, handleImportXls } = useMethods(); const { handleExportXls, handleImportXls } = useMethods();
// 定义 useListPage 方法所需参数 // 定义 useListPage 方法所需参数
@ -26,6 +27,8 @@ interface ListPageOptions {
name?: string | (() => string); name?: string | (() => string);
//导出参数 //导出参数
params?: object | (() => object); params?: object | (() => object);
// 自定义 HTTP 客户端,用于微服务场景
http?: VAxios;
}; };
// 导入配置 // 导入配置
importConfig?: { importConfig?: {
@ -34,6 +37,8 @@ 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;
// 自定义 HTTP 客户端,用于微服务场景
http?: VAxios;
}; };
} }
@ -65,7 +70,7 @@ export function useListPage(options: ListPageOptions) {
// 导出 excel // 导出 excel
async function onExportXls() { async function onExportXls() {
//update-begin---author:wangshuai ---date:20220411 for导出新增自定义参数------------ //update-begin---author:wangshuai ---date:20220411 for导出新增自定义参数------------
let { url, name, params } = options?.exportConfig ?? {}; let { url, name, params, http } = options?.exportConfig ?? {};
let realUrl = typeof url === 'function' ? url() : url; let realUrl = typeof url === 'function' ? url() : url;
if (realUrl) { if (realUrl) {
let title = typeof name === 'function' ? name() : name; let title = typeof name === 'function' ? name() : name;
@ -108,7 +113,7 @@ export function useListPage(options: ListPageOptions) {
paramsForm['selections'] = selectedRowKeys.value.join(','); paramsForm['selections'] = selectedRowKeys.value.join(',');
} }
console.log() console.log()
return handleExportXls(title as string, realUrl, filterObj(paramsForm)); return handleExportXls(title as string, realUrl, filterObj(paramsForm), http);
//update-end---author:wangshuai ---date:20220411 for导出新增自定义参数-------------- //update-end---author:wangshuai ---date:20220411 for导出新增自定义参数--------------
} else { } else {
$message.createMessage.warn('没有传递 exportConfig.url 参数'); $message.createMessage.warn('没有传递 exportConfig.url 参数');
@ -118,11 +123,11 @@ export function useListPage(options: ListPageOptions) {
// 导入 excel // 导入 excel
function onImportXls(file) { function onImportXls(file) {
let { url, success } = options?.importConfig ?? {}; let { url, success, http } = 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); return handleImportXls(file, realUrl, success || reload, http);
//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 参数');

View File

@ -1,6 +1,7 @@
import { defHttp } from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { useGlobSetting } from '/@/hooks/setting'; import { useGlobSetting } from '/@/hooks/setting';
import type { VAxios } from '/@/utils/http/axios/Axios';
const { createMessage, createWarningModal } = useMessage(); const { createMessage, createWarningModal } = useMessage();
const glob = useGlobSetting(); const glob = useGlobSetting();
@ -19,11 +20,13 @@ export function useMethods() {
* xls * xls
* @param name * @param name
* @param url * @param url
* @param http HTTP
*/ */
async function exportXls(name, url, params, isXlsx = false) { async function exportXls(name, url, params, isXlsx = false, http?: VAxios) {
const httpClient = http || defHttp;
//update-begin---author:wangshuai---date:2024-01-25---for:【QQYUN-8118】导出超时时间设置长点--- //update-begin---author:wangshuai---date:2024-01-25---for:【QQYUN-8118】导出超时时间设置长点---
// 修改为返回原生 response便于获取 headers // 修改为返回原生 response便于获取 headers
const response = await defHttp.get( const response = await httpClient.get(
{ url: url, params: params, responseType: 'blob', timeout: 60000 }, { url: url, params: params, responseType: 'blob', timeout: 60000 },
{ isTransformResponse: false, isReturnNativeResponse: true } { isTransformResponse: false, isReturnNativeResponse: true }
); );
@ -70,8 +73,10 @@ export function useMethods() {
* @param data * @param data
* @param url * @param url
* @param success * @param success
* @param http HTTP
*/ */
async function importXls(data, url, success) { async function importXls(data, url, success, http?: VAxios) {
const httpClient = http || defHttp;
const isReturn = (fileInfo) => { const isReturn = (fileInfo) => {
try { try {
if (fileInfo.code === 201) { if (fileInfo.code === 201) {
@ -101,13 +106,13 @@ export function useMethods() {
typeof success === 'function' ? success(fileInfo) : ''; typeof success === 'function' ? success(fileInfo) : '';
} }
}; };
await defHttp.uploadFile({ url }, { file: data.file }, { success: isReturn }); await httpClient.uploadFile({ url }, { file: data.file }, { success: isReturn });
} }
return { return {
handleExportXls: (name: string, url: string, params?: object) => exportXls(name, url, params), handleExportXls: (name: string, url: string, params?: object, http?: VAxios) => exportXls(name, url, params, false, http),
handleImportXls: (data, url, success) => importXls(data, url, success), handleImportXls: (data, url, success, http?: VAxios) => importXls(data, url, success, http),
handleExportXlsx: (name: string, url: string, params?: object) => exportXls(name, url, params, true), handleExportXlsx: (name: string, url: string, params?: object, http?: VAxios) => exportXls(name, url, params, true, http),
}; };
/** /**

View File

@ -125,7 +125,8 @@ export class VAxios {
formData.append(customFilename, params.file); formData.append(customFilename, params.file);
} }
const glob = useGlobSetting(); const glob = useGlobSetting();
config.baseURL = glob.uploadUrl; const { requestOptions } = this.options;
config.baseURL = requestOptions?.apiUrl || glob.uploadUrl;
if (params.data) { if (params.data) {
Object.keys(params.data).forEach((key) => { Object.keys(params.data).forEach((key) => {
const value = params.data![key]; const value = params.data![key];

View File

@ -94,6 +94,7 @@
import AreaModal from './components/AreaModal.vue'; import AreaModal from './components/AreaModal.vue';
import SwitchStatus from '/@/views/base/SwitchStatus.vue'; import SwitchStatus from '/@/views/base/SwitchStatus.vue';
import { JDictSelectTag } from '@/components/Form'; import { JDictSelectTag } from '@/components/Form';
import { basicHttp } from '/@/utils/http/axios';
const fieldPickers = reactive({}); const fieldPickers = reactive({});
const formRef = ref(); const formRef = ref();
@ -172,10 +173,12 @@
name: '库区', name: '库区',
url: getExportUrl, url: getExportUrl,
params: queryParam, params: queryParam,
http: basicHttp,
}, },
importConfig: { importConfig: {
url: getImportUrl, url: getImportUrl,
success: handleSuccess, success: handleSuccess,
http: basicHttp,
}, },
}); });
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] =

View File

@ -84,6 +84,7 @@
import ItemModal from './components/ItemModal.vue'; import ItemModal from './components/ItemModal.vue';
import SwitchStatus from '/@/views/base/SwitchStatus.vue'; import SwitchStatus from '/@/views/base/SwitchStatus.vue';
import { JDictSelectTag } from '@/components/Form'; import { JDictSelectTag } from '@/components/Form';
import { basicHttp } from '/@/utils/http/axios';
const fieldPickers = reactive({}); const fieldPickers = reactive({});
@ -143,10 +144,12 @@
name: '物料', name: '物料',
url: getExportUrl, url: getExportUrl,
params: queryParam, params: queryParam,
http: basicHttp,
}, },
importConfig: { importConfig: {
url: getImportUrl, url: getImportUrl,
success: handleSuccess, success: handleSuccess,
http: basicHttp,
}, },
}); });
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] =

View File

@ -104,6 +104,7 @@
import SwitchStatus from '/@/views/base/SwitchStatus.vue'; import SwitchStatus from '/@/views/base/SwitchStatus.vue';
import { JDictSelectTag, JSearchSelect } from '@/components/Form'; import { JDictSelectTag, JSearchSelect } from '@/components/Form';
import AreaSelect from '@/views/base/area/components/AreaSelect.vue'; import AreaSelect from '@/views/base/area/components/AreaSelect.vue';
import { basicHttp } from '/@/utils/http/axios';
const fieldPickers = reactive({}); const fieldPickers = reactive({});
@ -166,10 +167,12 @@
name: '库位', name: '库位',
url: getExportUrl, url: getExportUrl,
params: queryParam, params: queryParam,
http: basicHttp,
}, },
importConfig: { importConfig: {
url: getImportUrl, url: getImportUrl,
success: handleSuccess, success: handleSuccess,
http: basicHttp,
}, },
}); });
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext; const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;

View File

@ -86,6 +86,7 @@
import { JDictSelectTag, JSearchSelect } from '@/components/Form'; import { JDictSelectTag, JSearchSelect } from '@/components/Form';
import { JInputTypeEnum } from '@/enums/cpteEnum'; import { JInputTypeEnum } from '@/enums/cpteEnum';
import JInput from '../../../components/Form/src/jeecg/components/JInput.vue'; import JInput from '../../../components/Form/src/jeecg/components/JInput.vue';
import { basicHttp } from '/@/utils/http/axios';
const fieldPickers = reactive({}); const fieldPickers = reactive({});
const formRef = ref(); const formRef = ref();
@ -147,10 +148,12 @@
name: '容器', name: '容器',
url: getExportUrl, url: getExportUrl,
params: queryParam, params: queryParam,
http: basicHttp,
}, },
importConfig: { importConfig: {
url: getImportUrl, url: getImportUrl,
success: handleSuccess, success: handleSuccess,
http: basicHttp,
}, },
}); });
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = const [registerTable, { reload }, { rowSelection, selectedRowKeys }] =