client.data.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. import { reactive } from 'vue'
  2. import { useI18n } from '@/hooks/web/useI18n'
  3. import { required } from '@/utils/formRules'
  4. import { DICT_TYPE, getStrDictOptions } from '@/utils/dict'
  5. import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
  6. const { t } = useI18n() // 国际化
  7. const authorizedGrantOptions = getStrDictOptions(DICT_TYPE.SYSTEM_OAUTH2_GRANT_TYPE)
  8. // 表单校验
  9. export const rules = reactive({
  10. clientId: [required],
  11. secret: [required],
  12. name: [required],
  13. logo: [required],
  14. status: [required],
  15. accessTokenValiditySeconds: [required],
  16. refreshTokenValiditySeconds: [required],
  17. redirectUris: [required],
  18. authorizedGrantTypes: [required]
  19. })
  20. // CrudSchema
  21. const crudSchemas = reactive<VxeCrudSchema>({
  22. primaryKey: 'clientId',
  23. primaryType: null,
  24. action: true,
  25. columns: [
  26. {
  27. title: '客户端密钥',
  28. field: 'secret'
  29. },
  30. {
  31. title: '应用名',
  32. field: 'name',
  33. isSearch: true
  34. },
  35. {
  36. title: '应用图标',
  37. field: 'logo',
  38. table: {
  39. cellRender: {
  40. name: 'XImg'
  41. }
  42. }
  43. },
  44. {
  45. title: t('common.status'),
  46. field: 'status',
  47. dictType: DICT_TYPE.COMMON_STATUS,
  48. dictClass: 'number',
  49. isSearch: true
  50. },
  51. {
  52. title: '访问令牌的有效期',
  53. field: 'accessTokenValiditySeconds',
  54. form: {
  55. component: 'InputNumber'
  56. },
  57. table: {
  58. slots: {
  59. default: 'accessTokenValiditySeconds_default'
  60. }
  61. }
  62. },
  63. {
  64. title: '刷新令牌的有效期',
  65. field: 'refreshTokenValiditySeconds',
  66. form: {
  67. component: 'InputNumber'
  68. },
  69. table: {
  70. slots: {
  71. default: 'refreshTokenValiditySeconds_default'
  72. }
  73. }
  74. },
  75. {
  76. title: '授权类型',
  77. field: 'authorizedGrantTypes',
  78. table: {
  79. width: 400,
  80. slots: {
  81. default: 'authorizedGrantTypes_default'
  82. }
  83. },
  84. form: {
  85. component: 'Select',
  86. componentProps: {
  87. options: authorizedGrantOptions,
  88. multiple: true,
  89. filterable: true
  90. }
  91. }
  92. },
  93. {
  94. title: '授权范围',
  95. field: 'scopes',
  96. isTable: false,
  97. form: {
  98. component: 'Select',
  99. componentProps: {
  100. options: [],
  101. multiple: true,
  102. filterable: true,
  103. allowCreate: true,
  104. defaultFirstOption: true
  105. }
  106. }
  107. },
  108. {
  109. title: '自动授权范围',
  110. field: 'autoApproveScopes',
  111. isTable: false,
  112. form: {
  113. component: 'Select',
  114. componentProps: {
  115. options: [],
  116. multiple: true,
  117. filterable: true,
  118. allowCreate: true,
  119. defaultFirstOption: true
  120. }
  121. }
  122. },
  123. {
  124. title: '可重定向的 URI 地址',
  125. field: 'redirectUris',
  126. isTable: false,
  127. form: {
  128. component: 'Select',
  129. componentProps: {
  130. options: [],
  131. multiple: true,
  132. filterable: true,
  133. allowCreate: true,
  134. defaultFirstOption: true
  135. }
  136. }
  137. },
  138. {
  139. title: '权限',
  140. field: 'authorities',
  141. isTable: false,
  142. form: {
  143. component: 'Select',
  144. componentProps: {
  145. options: [],
  146. multiple: true,
  147. filterable: true,
  148. allowCreate: true,
  149. defaultFirstOption: true
  150. }
  151. }
  152. },
  153. {
  154. title: '资源',
  155. field: 'resourceIds',
  156. isTable: false,
  157. form: {
  158. component: 'Select',
  159. componentProps: {
  160. options: [],
  161. multiple: true,
  162. filterable: true,
  163. allowCreate: true,
  164. defaultFirstOption: true
  165. }
  166. }
  167. },
  168. {
  169. title: '附加信息',
  170. field: 'additionalInformation',
  171. isTable: false,
  172. form: {
  173. component: 'Input',
  174. componentProps: {
  175. type: 'textarea',
  176. rows: 4
  177. },
  178. colProps: {
  179. span: 24
  180. }
  181. }
  182. },
  183. {
  184. title: t('common.createTime'),
  185. field: 'createTime',
  186. formatter: 'formatDate',
  187. isForm: false
  188. }
  189. ]
  190. })
  191. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)