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 { @@ -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'];
const arrayFormat = headers.arrayFormat || 'indices';
if (
contentType !== ContentTypeEnum.FORM_URLENCODED ||
!Reflect.has(config, 'data') ||
config.method?.toUpperCase() === RequestEnum.GET
) {
return config;
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<T = any>(config: AxiosRequestConfig, options?: RequestOptions): Promise<T> {
@ -207,7 +206,7 @@ export class VAxios { @@ -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

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

@ -56,7 +56,6 @@ @@ -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 @@ @@ -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 @@ @@ -87,8 +87,7 @@
slots: { customRender: 'action' },
fixed: false
},
afterFetch: (result) => listToTree(result),
handleSearchInfoFn: (queryParams) => convertDateRange(queryParams, 'dateRange')
afterFetch: (result) => listToTree(result)
});
/** 新增按钮操作,行内新增与工具栏局域新增通用 */

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

@ -72,7 +72,6 @@ @@ -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 @@ @@ -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 @@ @@ -124,8 +124,7 @@
dataIndex: 'action',
slots: { customRender: 'action' },
fixed: false
},
handleSearchInfoFn: (queryParams) => convertDateRange(queryParams, 'dateRange')
}
});
/** 处理多选框选中数据 */

Loading…
Cancel
Save