tenant.data.ts 2.8 KB

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