client.data.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: 'seq',
  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. type: 'html',
  40. formatter: 'formatImg'
  41. }
  42. },
  43. {
  44. title: t('common.status'),
  45. field: 'status',
  46. dictType: DICT_TYPE.COMMON_STATUS,
  47. dictClass: 'number',
  48. isSearch: true
  49. },
  50. {
  51. title: '访问令牌的有效期',
  52. field: 'accessTokenValiditySeconds',
  53. form: {
  54. component: 'InputNumber'
  55. },
  56. table: {
  57. slots: {
  58. default: 'accessTokenValiditySeconds_default'
  59. }
  60. }
  61. },
  62. {
  63. title: '刷新令牌的有效期',
  64. field: 'refreshTokenValiditySeconds',
  65. form: {
  66. component: 'InputNumber'
  67. },
  68. table: {
  69. slots: {
  70. default: 'refreshTokenValiditySeconds_default'
  71. }
  72. }
  73. },
  74. {
  75. title: '授权类型',
  76. field: 'authorizedGrantTypes',
  77. table: {
  78. width: 400,
  79. slots: {
  80. default: 'authorizedGrantTypes_default'
  81. }
  82. },
  83. form: {
  84. component: 'Select',
  85. componentProps: {
  86. options: authorizedGrantOptions,
  87. props: {
  88. multiple: true,
  89. filterable: true
  90. }
  91. }
  92. }
  93. },
  94. {
  95. title: '授权范围',
  96. field: 'scopes',
  97. isTable: false,
  98. form: {
  99. component: 'Select',
  100. componentProps: {
  101. options: [],
  102. props: {
  103. multiple: true,
  104. filterable: true,
  105. allowCreate: true,
  106. defaultFirstOption: true
  107. }
  108. }
  109. }
  110. },
  111. {
  112. title: '自动授权范围',
  113. field: 'autoApproveScopes',
  114. isTable: false,
  115. form: {
  116. component: 'Select',
  117. componentProps: {
  118. options: [],
  119. props: {
  120. multiple: true,
  121. filterable: true,
  122. allowCreate: true,
  123. defaultFirstOption: true
  124. }
  125. }
  126. }
  127. },
  128. {
  129. title: '可重定向的 URI 地址',
  130. field: 'redirectUris',
  131. isTable: false,
  132. form: {
  133. component: 'Select',
  134. componentProps: {
  135. options: [],
  136. props: {
  137. multiple: true,
  138. filterable: true,
  139. allowCreate: true,
  140. defaultFirstOption: true
  141. }
  142. }
  143. }
  144. },
  145. {
  146. title: '权限',
  147. field: 'authorities',
  148. isTable: false,
  149. form: {
  150. component: 'Select',
  151. componentProps: {
  152. options: [],
  153. props: {
  154. multiple: true,
  155. filterable: true,
  156. allowCreate: true,
  157. defaultFirstOption: true
  158. }
  159. }
  160. }
  161. },
  162. {
  163. title: '资源',
  164. field: 'resourceIds',
  165. isTable: false,
  166. form: {
  167. component: 'Select',
  168. componentProps: {
  169. options: [],
  170. props: {
  171. multiple: true,
  172. filterable: true,
  173. defaultFirstOption: true
  174. }
  175. }
  176. }
  177. },
  178. {
  179. title: '附加信息',
  180. field: 'additionalInformation',
  181. isTable: false,
  182. form: {
  183. component: 'Input',
  184. componentProps: {
  185. type: 'textarea',
  186. rows: 4
  187. },
  188. colProps: {
  189. span: 24
  190. }
  191. }
  192. },
  193. {
  194. title: t('common.createTime'),
  195. field: 'createTime',
  196. formatter: 'formatDate',
  197. isForm: false
  198. }
  199. ]
  200. })
  201. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)