client.data.ts 4.1 KB

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