client.data.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import { reactive } from 'vue'
  2. import { useI18n } from '@/hooks/web/useI18n'
  3. import { required } from '@/utils/formRules'
  4. import { DICT_TYPE } from '@/utils/dict'
  5. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  6. const { t } = useI18n() // 国际化
  7. // 表单校验
  8. export const rules = reactive({
  9. clientId: [required],
  10. secret: [required],
  11. name: [required],
  12. logo: [required],
  13. status: [required],
  14. accessTokenValiditySeconds: [required],
  15. refreshTokenValiditySeconds: [required],
  16. redirectUris: [required],
  17. authorizedGrantTypes: [required]
  18. })
  19. // CrudSchema
  20. const crudSchemas = reactive<VxeCrudSchema>({
  21. primaryKey: 'clientId',
  22. primaryType: 'seq',
  23. action: true,
  24. columns: [
  25. {
  26. title: '客户端密钥',
  27. field: 'secret'
  28. },
  29. {
  30. title: '应用名',
  31. field: 'name',
  32. isSearch: true
  33. },
  34. {
  35. title: '应用图标',
  36. field: 'logo'
  37. },
  38. {
  39. title: t('common.status'),
  40. field: 'status',
  41. dictType: DICT_TYPE.COMMON_STATUS,
  42. isSearch: true
  43. },
  44. {
  45. title: '访问令牌的有效期',
  46. field: 'accessTokenValiditySeconds'
  47. },
  48. {
  49. title: '刷新令牌的有效期',
  50. field: 'refreshTokenValiditySeconds'
  51. },
  52. {
  53. title: '授权类型',
  54. field: 'authorizedGrantTypes',
  55. dictType: DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE,
  56. form: {
  57. component: 'Select'
  58. }
  59. },
  60. {
  61. title: '授权范围',
  62. field: 'scopes',
  63. isTable: false
  64. },
  65. {
  66. title: '自动授权范围',
  67. field: 'autoApproveScopes',
  68. isTable: false
  69. },
  70. {
  71. title: '可重定向的 URI 地址',
  72. field: 'redirectUris',
  73. isTable: false
  74. },
  75. {
  76. title: '权限',
  77. field: 'authorities',
  78. isTable: false
  79. },
  80. {
  81. title: '资源',
  82. field: 'resourceIds',
  83. isTable: false
  84. },
  85. {
  86. title: '附加信息',
  87. field: 'additionalInformation',
  88. isTable: false,
  89. form: {
  90. component: 'Input',
  91. componentProps: {
  92. type: 'textarea',
  93. rows: 4
  94. },
  95. colProps: {
  96. span: 24
  97. }
  98. }
  99. },
  100. {
  101. title: t('common.createTime'),
  102. field: 'createTime',
  103. formatter: 'formatDate',
  104. isForm: false
  105. }
  106. ]
  107. })
  108. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)