data.config.ts 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. import type { VbenFormProps } from '#/adapter/form';
  2. import type { VxeGridProps } from '#/adapter/vxe-table';
  3. import { EnumApi, TenantApi } from '#/api';
  4. import { dbTypeOptions, formatterStatus } from '#/api/model';
  5. export const searchFormOptions: VbenFormProps = {
  6. schema: [
  7. {
  8. component: 'Input',
  9. fieldName: 'name',
  10. label: '租户名称',
  11. },
  12. {
  13. component: 'Input',
  14. fieldName: 'phone',
  15. label: '联系人',
  16. },
  17. ],
  18. };
  19. export const gridOptions: VxeGridProps<TenantApi.RecordItem> = {
  20. checkboxConfig: {
  21. highlight: true,
  22. labelField: 'name',
  23. },
  24. toolbarConfig: {
  25. refresh: true,
  26. print: false,
  27. export: false,
  28. zoom: true,
  29. custom: true,
  30. },
  31. columns: [
  32. { title: '序号', type: 'seq', width: 50 },
  33. {
  34. align: 'left',
  35. field: 'name',
  36. title: '租户名称',
  37. // type: 'checkbox',
  38. width: 200,
  39. },
  40. { align: 'left', field: 'adminAccount', title: '联系人', width: 120 },
  41. { align: 'left', field: 'phone', title: '联系电话', width: 120 },
  42. { field: 'tenantTypeName', title: '租户类型', width: 80 },
  43. {
  44. field: 'status',
  45. title: '状态',
  46. width: 60,
  47. formatter: formatterStatus,
  48. },
  49. { field: 'sort', title: '排序', width: 50 },
  50. { align: 'left', field: 'remark', title: '备注' },
  51. {
  52. field: 'action',
  53. fixed: 'right',
  54. slots: { default: 'action' },
  55. title: '操作',
  56. width: 150,
  57. },
  58. ],
  59. height: 'auto',
  60. keepSource: true,
  61. proxyConfig: {
  62. ajax: {
  63. query: async ({ page }, formValues) => {
  64. return await TenantApi.getPage({
  65. pageIndex: page.currentPage,
  66. pageSize: page.pageSize,
  67. ...formValues,
  68. });
  69. },
  70. },
  71. },
  72. };
  73. export const formOptions: VbenFormProps = {
  74. commonConfig: {
  75. componentProps: {
  76. class: 'w-full',
  77. },
  78. },
  79. schema: [
  80. {
  81. component: 'ApiRadio',
  82. componentProps: {
  83. api: {
  84. type: 'enum',
  85. params: EnumApi.EnumType.TenantType,
  86. },
  87. },
  88. fieldName: 'tenantType',
  89. label: '租户类型',
  90. rules: 'required',
  91. },
  92. {
  93. component: 'Input',
  94. componentProps: {
  95. placeholder: '请输入',
  96. },
  97. fieldName: 'name',
  98. label: '租户名称',
  99. rules: 'required',
  100. },
  101. {
  102. component: 'Input',
  103. componentProps: {
  104. placeholder: '请输入',
  105. },
  106. fieldName: 'adminAccount',
  107. label: '管理员',
  108. rules: 'required',
  109. },
  110. {
  111. component: 'Input',
  112. componentProps: {
  113. placeholder: '请输入',
  114. },
  115. fieldName: 'phone',
  116. label: '联系电话',
  117. rules: 'required',
  118. },
  119. {
  120. component: 'Input',
  121. componentProps: {
  122. placeholder: '请输入',
  123. },
  124. fieldName: 'email',
  125. label: '电子邮箱',
  126. rules: 'required',
  127. },
  128. {
  129. component: 'InputNumber',
  130. componentProps: {
  131. placeholder: '请输入',
  132. },
  133. fieldName: 'sort',
  134. label: '排序',
  135. rules: 'required',
  136. },
  137. {
  138. component: 'Select',
  139. componentProps: {
  140. placeholder: '请输入',
  141. options: dbTypeOptions,
  142. },
  143. dependencies: {
  144. show(values) {
  145. return values.tenantType === 1;
  146. },
  147. triggerFields: ['tenantType'],
  148. },
  149. fieldName: 'dbType',
  150. label: '数据库类型',
  151. rules: 'required',
  152. formItemClass: 'col-span-2 items-baseline',
  153. },
  154. {
  155. component: 'Textarea',
  156. componentProps: {
  157. placeholder: '请输入',
  158. },
  159. dependencies: {
  160. show(values) {
  161. return values.tenantType === 1;
  162. },
  163. triggerFields: ['tenantType'],
  164. },
  165. fieldName: 'connection',
  166. label: '连接字符串',
  167. rules: 'required',
  168. formItemClass: 'col-span-2 items-baseline',
  169. },
  170. {
  171. component: 'Input',
  172. componentProps: {
  173. placeholder: '请输入',
  174. },
  175. fieldName: 'remark',
  176. label: '备注',
  177. formItemClass: 'col-span-2 items-baseline',
  178. },
  179. ],
  180. wrapperClass: 'grid-cols-2',
  181. };