componentSetting.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // 用于配置某些组件的常规配置,而无需修改组件
  2. import type { SorterResult } from '../components/Table';
  3. export default {
  4. // 表格配置
  5. table: {
  6. // 表格接口请求通用配置,可在组件prop覆盖
  7. // 支持 xxx.xxx.xxx格式
  8. fetchSetting: {
  9. // 传给后台的当前页字段
  10. pageField: 'pageNo',
  11. // 传给后台的每页显示多少条的字段
  12. sizeField: 'pageSize',
  13. // 接口返回表格数据的字段
  14. listField: 'records',
  15. // 接口返回表格总数的字段
  16. totalField: 'total',
  17. },
  18. // 可选的分页选项
  19. pageSizeOptions: ['10', '30', '50', '100'],
  20. // 表格默认尺寸
  21. defaultSize: 'middle',
  22. //默认每页显示多少条
  23. defaultPageSize: 10,
  24. // 默认排序方法
  25. defaultSortFn: (sortInfo: SorterResult) => {
  26. //update-begin-author:taoyan date:2022-10-21 for: VUEN-2199【表单设计器】多字段排序
  27. if (sortInfo instanceof Array) {
  28. const sortInfoArray: any[] = [];
  29. for (const item of sortInfo) {
  30. const info = getSort(item);
  31. if (info) {
  32. sortInfoArray.push(info);
  33. }
  34. }
  35. return {
  36. sortInfoString: JSON.stringify(sortInfoArray),
  37. };
  38. } else {
  39. const info = getSort(sortInfo);
  40. return info || {};
  41. }
  42. //update-end-author:taoyan date:2022-10-21 for: VUEN-2199【表单设计器】多字段排序
  43. },
  44. // 自定义过滤方法
  45. defaultFilterFn: (data: Partial<Recordable<string[]>>) => {
  46. return data;
  47. },
  48. },
  49. // 滚动组件配置
  50. scrollbar: {
  51. // 是否使用原生滚动样式
  52. // 开启后,菜单,弹窗,抽屉会使用原生滚动条组件
  53. native: false,
  54. },
  55. //表单配置
  56. form: {
  57. labelCol: {
  58. xs: { span: 24 },
  59. sm: { span: 4 },
  60. xl: { span: 6 },
  61. xxl: { span: 4 },
  62. },
  63. wrapperCol: {
  64. xs: { span: 24 },
  65. sm: { span: 18 },
  66. },
  67. //表单默认冒号
  68. colon: true,
  69. },
  70. };
  71. /**
  72. * 获取排序信息
  73. * @param item
  74. */
  75. function getSort(item) {
  76. const { field, order } = item;
  77. if (field && order) {
  78. const sortType = 'ascend' == order ? 'asc' : 'desc';
  79. return {
  80. // 排序字段
  81. column: field,
  82. // 排序方式 asc/desc
  83. order: sortType,
  84. };
  85. }
  86. return '';
  87. }