client.data.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. table: {
  38. type: 'html',
  39. formatter: 'formatImg'
  40. }
  41. },
  42. {
  43. title: t('common.status'),
  44. field: 'status',
  45. dictType: DICT_TYPE.COMMON_STATUS,
  46. dictClass: 'number',
  47. isSearch: true
  48. },
  49. {
  50. title: '访问令牌的有效期',
  51. field: 'accessTokenValiditySeconds',
  52. form: {
  53. component: 'InputNumber'
  54. },
  55. table: {
  56. slots: {
  57. default: 'accessTokenValiditySeconds_default'
  58. }
  59. }
  60. },
  61. {
  62. title: '刷新令牌的有效期',
  63. field: 'refreshTokenValiditySeconds',
  64. form: {
  65. component: 'InputNumber'
  66. },
  67. table: {
  68. slots: {
  69. default: 'refreshTokenValiditySeconds_default'
  70. }
  71. }
  72. },
  73. {
  74. title: '授权类型',
  75. field: 'authorizedGrantTypes',
  76. table: {
  77. width: 300,
  78. slots: {
  79. default: 'authorizedGrantTypes_default'
  80. }
  81. }
  82. },
  83. {
  84. title: '授权范围',
  85. field: 'scopes', // TODO @星语:带输入的 SELECT
  86. isTable: false
  87. },
  88. {
  89. title: '自动授权范围',
  90. field: 'autoApproveScopes', // TODO @星语:带输入的 SELECT
  91. isTable: false
  92. },
  93. {
  94. title: '可重定向的 URI 地址',
  95. field: 'redirectUris', // TODO @星语:带输入的 SELECT
  96. isTable: false
  97. },
  98. {
  99. title: '权限',
  100. field: 'authorities',
  101. isTable: false
  102. },
  103. {
  104. title: '资源',
  105. field: 'resourceIds',
  106. isTable: false
  107. },
  108. {
  109. title: '附加信息',
  110. field: 'additionalInformation',
  111. isTable: false,
  112. form: {
  113. component: 'Input',
  114. componentProps: {
  115. type: 'textarea',
  116. rows: 4
  117. },
  118. colProps: {
  119. span: 24
  120. }
  121. }
  122. },
  123. {
  124. title: t('common.createTime'),
  125. field: 'createTime',
  126. formatter: 'formatDate',
  127. isForm: false
  128. }
  129. ]
  130. })
  131. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)