diff --git a/kicc-ui/src/utils/http/axios/Axios.ts b/kicc-ui/src/utils/http/axios/Axios.ts index 7030dd8e..997ffb7c 100644 --- a/kicc-ui/src/utils/http/axios/Axios.ts +++ b/kicc-ui/src/utils/http/axios/Axios.ts @@ -158,23 +158,22 @@ export class VAxios { }); } - // 支持表单数据 - supportFormData(config: AxiosRequestConfig) { + /** 转换配置数据格式 */ + transformConfigFormat(config: AxiosRequestConfig) { const headers = config.headers || this.options.headers; const contentType = headers?.['Content-Type'] || headers?.['content-type']; - - if ( - contentType !== ContentTypeEnum.FORM_URLENCODED || - !Reflect.has(config, 'data') || - config.method?.toUpperCase() === RequestEnum.GET - ) { - return config; + const arrayFormat = headers.arrayFormat || 'indices'; + + if (config.method?.toUpperCase() === RequestEnum.POST && contentType === ContentTypeEnum.FORM_URLENCODED) { + // post请求参数处理 + config.data = qs.stringify(config.data, { allowDots: true, arrayFormat: arrayFormat }); + } else if (config.method?.toUpperCase() === RequestEnum.GET) { + // get请求参数处理 + config.params = qs.stringify(config.params, { allowDots: true, arrayFormat: arrayFormat }); + config.params = qs.parse(config.params); } - return { - ...config, - data: qs.stringify(config.data, { arrayFormat: 'brackets' }), - }; + return config; } get(config: AxiosRequestConfig, options?: RequestOptions): Promise { @@ -207,7 +206,7 @@ export class VAxios { } conf.requestOptions = opt; - conf = this.supportFormData(conf); + conf = this.transformConfigFormat(conf); return new Promise((resolve, reject) => { this.axiosInstance diff --git a/kicc-ui/src/views/system/menu/index.vue b/kicc-ui/src/views/system/menu/index.vue index 21d65581..e3dfd98f 100644 --- a/kicc-ui/src/views/system/menu/index.vue +++ b/kicc-ui/src/views/system/menu/index.vue @@ -56,7 +56,6 @@ import { listToTree } from '/@/utils/helper/treeHelper'; import { columns, searchFormSchema } from './menu.data'; import { useMessage } from '/@/hooks/web/useMessage'; - import { convertDateRange } from '/@/utils/dateUtil'; import MenuModal from './MenuModal.vue'; /** 通用变量统一声明区域 */ @@ -70,7 +69,8 @@ formConfig: { labelWidth: 120, schemas: searchFormSchema, - autoSubmitOnEnter: true + autoSubmitOnEnter: true, + fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']], }, isTreeTable: true, pagination: false, @@ -87,8 +87,7 @@ slots: { customRender: 'action' }, fixed: false }, - afterFetch: (result) => listToTree(result), - handleSearchInfoFn: (queryParams) => convertDateRange(queryParams, 'dateRange') + afterFetch: (result) => listToTree(result) }); /** 新增按钮操作,行内新增与工具栏局域新增通用 */ diff --git a/kicc-ui/src/views/system/user/index.vue b/kicc-ui/src/views/system/user/index.vue index 218f058c..de4991dd 100644 --- a/kicc-ui/src/views/system/user/index.vue +++ b/kicc-ui/src/views/system/user/index.vue @@ -72,7 +72,6 @@ import UserModal from './UserModal.vue'; import { columns, searchFormSchema } from './user.data'; import { useMessage } from '/@/hooks/web/useMessage'; - import { convertDateRange } from "/@/utils/dateUtil"; export default defineComponent({ name: 'UserManagement', @@ -109,7 +108,8 @@ formConfig: { labelWidth: 120, schemas: searchFormSchema, - autoSubmitOnEnter: true + autoSubmitOnEnter: true, + fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']], }, rowSelection: { type: 'checkbox' }, useSearchForm: true, @@ -124,8 +124,7 @@ dataIndex: 'action', slots: { customRender: 'action' }, fixed: false - }, - handleSearchInfoFn: (queryParams) => convertDateRange(queryParams, 'dateRange') + } }); /** 处理多选框选中数据 */