data.config.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import type {
  2. OnActionClickFn,
  3. VbenFormSchema,
  4. VxeTableGridOptions,
  5. } from '#/adapter';
  6. import type { BasicOptionResult } from '#/api/model';
  7. import type { SpecApi } from '#/api/shop';
  8. import { h } from 'vue';
  9. export const paramsTypeOptions: BasicOptionResult[] = [
  10. { label: '文本框', value: 0, color: 'success' },
  11. { label: '复选框', value: 1, color: 'error' },
  12. { label: '单选框', value: 2, color: 'warning' },
  13. ];
  14. export const useSearchSchema = (): VbenFormSchema[] => {
  15. return [
  16. {
  17. component: 'Input',
  18. fieldName: 'name',
  19. label: '名称',
  20. },
  21. ];
  22. };
  23. export function useColumns(
  24. onActionClick?: OnActionClickFn<SpecApi.RecordItem>,
  25. ): VxeTableGridOptions<SpecApi.RecordItem>['columns'] {
  26. return [
  27. { title: '序号', type: 'seq', width: 50 },
  28. {
  29. align: 'left',
  30. field: 'name',
  31. title: '名称',
  32. width: 82,
  33. },
  34. {
  35. align: 'left',
  36. field: 'specDetails',
  37. title: '规格值',
  38. slots: { default: 'specDetails' },
  39. },
  40. {
  41. field: 'sort',
  42. title: '排序',
  43. width: 82,
  44. },
  45. {
  46. align: 'right',
  47. cellRender: {
  48. attrs: {
  49. nameField: 'name',
  50. nameTitle: '名称',
  51. onClick: onActionClick,
  52. },
  53. name: 'CellAction',
  54. options: [
  55. {
  56. code: 'edit',
  57. auth: ['spec:edit'],
  58. },
  59. {
  60. code: 'delete',
  61. auth: ['spec:delete'],
  62. },
  63. ],
  64. },
  65. field: 'operation',
  66. fixed: 'right',
  67. headerAlign: 'center',
  68. showOverflow: false,
  69. title: '操作',
  70. width: 100,
  71. },
  72. ];
  73. }
  74. export const useSchema = (): VbenFormSchema[] => {
  75. return [
  76. {
  77. component: 'Input',
  78. componentProps: {
  79. placeholder: '请输入',
  80. },
  81. fieldName: 'name',
  82. label: '名称',
  83. rules: 'required',
  84. },
  85. {
  86. component: 'InputNumber',
  87. componentProps: {
  88. placeholder: '请输入排序',
  89. },
  90. fieldName: 'sort',
  91. label: '排序',
  92. rules: 'required',
  93. },
  94. {
  95. component: h('div', { class: 'text-sm font-thin' }, [
  96. h(
  97. 'div',
  98. null,
  99. 'SKU模型值只支持:中文、英文、数字、中文输入大写符号、英文小写二个符号(-、/)',
  100. ),
  101. ]),
  102. formItemClass: 'items-start',
  103. fieldName: 'remark',
  104. label: '说明',
  105. },
  106. {
  107. component: 'Input',
  108. componentProps: {
  109. placeholder: '请输入',
  110. },
  111. fieldName: 'specDetails',
  112. label: '规格值',
  113. },
  114. ];
  115. };