client.data.ts 4.2 KB

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