DatabaseListView.data.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. import type { FormSchema } from '@/components/Form';
  2. import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable';
  3. const dbTypeList = ['MYSQL', 'SQL_SERVER', 'ORACLE'];
  4. export const tableColumns: SmartColumn[] = [
  5. {
  6. type: 'checkbox',
  7. width: 60,
  8. align: 'center',
  9. fixed: 'left',
  10. },
  11. {
  12. title: '{generator.views.database.table.connectionName}',
  13. field: 'connectionName',
  14. width: 160,
  15. fixed: 'left',
  16. },
  17. {
  18. title: '{generator.views.database.table.databaseName}',
  19. field: 'databaseName',
  20. width: 160,
  21. fixed: 'left',
  22. },
  23. {
  24. title: '{generator.views.database.table.type}',
  25. field: 'type',
  26. width: 120,
  27. },
  28. {
  29. title: '{generator.views.database.table.url}',
  30. field: 'url',
  31. minWidth: 200,
  32. showOverflow: 'tooltip',
  33. },
  34. {
  35. title: '{generator.views.database.table.username}',
  36. field: 'username',
  37. width: 120,
  38. },
  39. {
  40. title: '{generator.views.database.table.tableSchema}',
  41. field: 'tableSchema',
  42. width: 120,
  43. },
  44. {
  45. title: '{common.table.createTime}',
  46. field: 'createTime',
  47. width: 165,
  48. sortable: true,
  49. },
  50. {
  51. title: '{common.table.createUser}',
  52. field: 'createBy',
  53. width: 120,
  54. },
  55. {
  56. title: '{common.table.updateTime}',
  57. field: 'updateTime',
  58. width: 165,
  59. sortable: true,
  60. },
  61. {
  62. title: '{common.table.updateUser}',
  63. field: 'updateBy',
  64. width: 120,
  65. },
  66. {
  67. title: '{common.table.operation}',
  68. field: 'operation',
  69. width: 120,
  70. fixed: 'right',
  71. slots: {
  72. default: 'table-operation',
  73. },
  74. },
  75. ];
  76. export const addEditForm: (t: Function) => Array<FormSchema> = (t: Function) => {
  77. return [
  78. {
  79. field: 'id',
  80. component: 'Input',
  81. show: false,
  82. },
  83. {
  84. field: 'systemId',
  85. component: 'Input',
  86. show: false,
  87. },
  88. {
  89. label: t('generator.views.database.table.connectionName'),
  90. field: 'connectionName',
  91. component: 'Input',
  92. componentProps: {
  93. placeholder: t('generator.views.database.validate.connectionName'),
  94. },
  95. required: true,
  96. },
  97. {
  98. label: t('generator.views.database.table.databaseName'),
  99. field: 'databaseName',
  100. component: 'Input',
  101. componentProps: {
  102. placeholder: t('generator.views.database.validate.databaseName'),
  103. },
  104. required: true,
  105. },
  106. {
  107. label: t('generator.views.database.table.type'),
  108. field: 'type',
  109. component: 'Select',
  110. componentProps: {
  111. placeholder: t('generator.views.database.validate.type'),
  112. options: dbTypeList.map((item) => {
  113. return {
  114. label: item,
  115. value: item,
  116. };
  117. }),
  118. },
  119. rules: [
  120. {
  121. message: t('generator.views.database.validate.type'),
  122. required: true,
  123. trigger: 'change',
  124. },
  125. ],
  126. },
  127. {
  128. label: t('generator.views.database.table.url'),
  129. field: 'url',
  130. component: 'InputTextArea',
  131. componentProps: {
  132. placeholder: t('generator.views.database.validate.url'),
  133. rows: 4,
  134. },
  135. required: true,
  136. },
  137. {
  138. label: t('generator.views.database.table.username'),
  139. field: 'username',
  140. component: 'Input',
  141. componentProps: {
  142. placeholder: t('generator.views.database.validate.username'),
  143. },
  144. required: true,
  145. },
  146. {
  147. label: t('generator.views.database.table.password'),
  148. field: 'password',
  149. component: 'InputPassword',
  150. componentProps: {
  151. placeholder: t('generator.views.database.validate.password'),
  152. },
  153. required: true,
  154. },
  155. {
  156. label: t('generator.views.database.table.tableSchema'),
  157. field: 'tableSchema',
  158. component: 'Input',
  159. componentProps: {},
  160. },
  161. ] as FormSchema[];
  162. };
  163. /**
  164. * 搜索表单配置
  165. * @param t
  166. */
  167. export const searchForm: (t: Function) => SmartSearchFormSchema[] = (t: Function) => {
  168. return [
  169. {
  170. field: 'connectionName',
  171. component: 'Input',
  172. componentProps: {
  173. placeholder: t('generator.views.database.table.connectionName'),
  174. },
  175. colProps: { span: 6 },
  176. searchSymbol: 'likeRight',
  177. label: '',
  178. },
  179. {
  180. field: 'databaseName',
  181. component: 'Input',
  182. componentProps: {
  183. placeholder: t('generator.views.database.table.databaseName'),
  184. },
  185. colProps: { span: 6 },
  186. searchSymbol: '=',
  187. label: '',
  188. },
  189. {
  190. field: 'project',
  191. component: 'Input',
  192. componentProps: {
  193. placeholder: t('generator.views.database.table.project'),
  194. },
  195. colProps: { span: 6 },
  196. searchSymbol: 'likeLeft',
  197. label: '',
  198. },
  199. ];
  200. };