client.data.ts 2.9 KB

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