tenant.data.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
  2. import { getTenantPackageList, TenantPackageVO } from '@/api/system/tenantPackage'
  3. import { ComponentOptions } from '@/types/components'
  4. const { t } = useI18n() // 国际化
  5. export const tenantPackageOption: ComponentOptions[] = []
  6. const getTenantPackageOptions = async () => {
  7. const res = await getTenantPackageList()
  8. res.forEach((tenantPackage: TenantPackageVO) => {
  9. tenantPackageOption.push({
  10. key: tenantPackage.id,
  11. value: tenantPackage.id,
  12. label: tenantPackage.name
  13. })
  14. })
  15. return tenantPackageOption
  16. }
  17. getTenantPackageOptions()
  18. // 表单校验
  19. export const rules = reactive({
  20. name: [required],
  21. packageId: [required],
  22. contactName: [required],
  23. contactMobile: [required],
  24. accountCount: [required],
  25. expireTime: [required],
  26. username: [
  27. required,
  28. {
  29. min: 4,
  30. max: 30,
  31. trigger: 'blur',
  32. message: '用户名称长度为 4-30 个字符'
  33. }
  34. ],
  35. password: [
  36. required,
  37. {
  38. min: 4,
  39. max: 16,
  40. trigger: 'blur',
  41. message: '密码长度为 4-16 位'
  42. }
  43. ],
  44. domain: [required],
  45. status: [required]
  46. })
  47. // CrudSchema.
  48. const crudSchemas = reactive<VxeCrudSchema>({
  49. primaryKey: 'id',
  50. primaryTitle: '租户编号',
  51. primaryType: 'id',
  52. action: true,
  53. columns: [
  54. {
  55. title: '租户名称',
  56. field: 'name',
  57. isSearch: true
  58. },
  59. {
  60. title: '租户套餐',
  61. field: 'packageId',
  62. table: {
  63. slots: {
  64. default: 'packageId_default'
  65. }
  66. },
  67. form: {
  68. component: 'Select',
  69. componentProps: {
  70. options: tenantPackageOption
  71. }
  72. }
  73. },
  74. {
  75. title: '联系人',
  76. field: 'contactName',
  77. isSearch: true
  78. },
  79. {
  80. title: '联系手机',
  81. field: 'contactMobile',
  82. isSearch: true
  83. },
  84. {
  85. title: '用户名称',
  86. field: 'username',
  87. isTable: false,
  88. isDetail: false
  89. },
  90. {
  91. title: '用户密码',
  92. field: 'password',
  93. isTable: false,
  94. isDetail: false,
  95. form: {
  96. component: 'InputPassword'
  97. }
  98. },
  99. {
  100. title: '账号额度',
  101. field: 'accountCount',
  102. table: {
  103. slots: {
  104. default: 'accountCount_default'
  105. }
  106. },
  107. form: {
  108. component: 'InputNumber'
  109. }
  110. },
  111. {
  112. title: '过期时间',
  113. field: 'expireTime',
  114. formatter: 'formatDate',
  115. form: {
  116. component: 'DatePicker',
  117. componentProps: {
  118. type: 'datetime',
  119. valueFormat: 'x'
  120. }
  121. }
  122. },
  123. {
  124. title: '绑定域名',
  125. field: 'domain'
  126. },
  127. {
  128. title: '租户状态',
  129. field: 'status',
  130. dictType: DICT_TYPE.COMMON_STATUS,
  131. dictClass: 'number',
  132. isSearch: true
  133. },
  134. {
  135. title: t('table.createTime'),
  136. field: 'createTime',
  137. formatter: 'formatDate',
  138. isForm: false,
  139. search: {
  140. show: true,
  141. itemRender: {
  142. name: 'XDataTimePicker'
  143. }
  144. }
  145. }
  146. ]
  147. })
  148. export const { allSchemas } = useVxeCrudSchemas(crudSchemas)