client.data.ts 4.3 KB

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