Browse Source

👣 制定代码规范模板团队规则

master
wangxiang 3 years ago
parent
commit
022c4dbce8
  1. 25
      kicc-ui/src/utils/http/axios/Axios.ts
  2. 7
      kicc-ui/src/views/system/menu/index.vue
  3. 7
      kicc-ui/src/views/system/user/index.vue

25
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 headers = config.headers || this.options.headers;
const contentType = headers?.['Content-Type'] || headers?.['content-type']; const contentType = headers?.['Content-Type'] || headers?.['content-type'];
const arrayFormat = headers.arrayFormat || 'indices';
if ( if (config.method?.toUpperCase() === RequestEnum.POST && contentType === ContentTypeEnum.FORM_URLENCODED) {
contentType !== ContentTypeEnum.FORM_URLENCODED || // post请求参数处理
!Reflect.has(config, 'data') || config.data = qs.stringify(config.data, { allowDots: true, arrayFormat: arrayFormat });
config.method?.toUpperCase() === RequestEnum.GET } else if (config.method?.toUpperCase() === RequestEnum.GET) {
) { // get请求参数处理
return config; config.params = qs.stringify(config.params, { allowDots: true, arrayFormat: arrayFormat });
config.params = qs.parse(config.params);
} }
return { return config;
...config,
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> {
@ -207,7 +206,7 @@ export class VAxios {
} }
conf.requestOptions = opt; conf.requestOptions = opt;
conf = this.supportFormData(conf); conf = this.transformConfigFormat(conf);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.axiosInstance this.axiosInstance

7
kicc-ui/src/views/system/menu/index.vue

@ -56,7 +56,6 @@
import { listToTree } from '/@/utils/helper/treeHelper'; import { listToTree } from '/@/utils/helper/treeHelper';
import { columns, searchFormSchema } from './menu.data'; import { columns, searchFormSchema } from './menu.data';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { convertDateRange } from '/@/utils/dateUtil';
import MenuModal from './MenuModal.vue'; import MenuModal from './MenuModal.vue';
/** 通用变量统一声明区域 */ /** 通用变量统一声明区域 */
@ -70,7 +69,8 @@
formConfig: { formConfig: {
labelWidth: 120, labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter: true autoSubmitOnEnter: true,
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']],
}, },
isTreeTable: true, isTreeTable: true,
pagination: false, pagination: false,
@ -87,8 +87,7 @@
slots: { customRender: 'action' }, slots: { customRender: 'action' },
fixed: false fixed: false
}, },
afterFetch: (result) => listToTree(result), afterFetch: (result) => listToTree(result)
handleSearchInfoFn: (queryParams) => convertDateRange(queryParams, 'dateRange')
}); });
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ /** 新增按钮操作,行内新增与工具栏局域新增通用 */

7
kicc-ui/src/views/system/user/index.vue

@ -72,7 +72,6 @@
import UserModal from './UserModal.vue'; import UserModal from './UserModal.vue';
import { columns, searchFormSchema } from './user.data'; import { columns, searchFormSchema } from './user.data';
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { convertDateRange } from "/@/utils/dateUtil";
export default defineComponent({ export default defineComponent({
name: 'UserManagement', name: 'UserManagement',
@ -109,7 +108,8 @@
formConfig: { formConfig: {
labelWidth: 120, labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter: true autoSubmitOnEnter: true,
fieldMapToTime: [['dateRange', ['beginTime', 'endTime'], 'YYYY-MM-DD']],
}, },
rowSelection: { type: 'checkbox' }, rowSelection: { type: 'checkbox' },
useSearchForm: true, useSearchForm: true,
@ -124,8 +124,7 @@
dataIndex: 'action', dataIndex: 'action',
slots: { customRender: 'action' }, slots: { customRender: 'action' },
fixed: false fixed: false
}, }
handleSearchInfoFn: (queryParams) => convertDateRange(queryParams, 'dateRange')
}); });
/** 处理多选框选中数据 */ /** 处理多选框选中数据 */

Loading…
Cancel
Save