structure.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div>
  3. <el-table :data="structures">
  4. <el-table-column prop="field" :label="$t('generate.schema.structure.field_name.name')" width="100px" />
  5. <el-table-column prop="label" :label="$t('generate.schema.structure.form_label')" width="150px">
  6. <template #default="scope">
  7. <el-input v-model="scope.row.label" />
  8. </template>
  9. </el-table-column>
  10. <el-table-column prop="label" :label="$t('generate.schema.structure.form_component')" width="110px">
  11. <template #default="scope">
  12. <el-select v-model="scope.row.form_component" class="w-full" filterable>
  13. <el-option v-for="component in formComponents" :key="component" :label="component" :value="component" />
  14. </el-select>
  15. </template>
  16. </el-table-column>
  17. <el-table-column prop="list" :label="$t('generate.schema.structure.list')">
  18. <template #default="scope">
  19. <el-switch v-model="scope.row.list" inline-prompt :active-text="$t('system.yes')" :inactive-text="$t('system.no')" width="45px" />
  20. </template>
  21. </el-table-column>
  22. <el-table-column prop="form" :label="$t('generate.schema.structure.form')">
  23. <template #default="scope">
  24. <el-switch v-model="scope.row.form" inline-prompt :active-text="$t('system.yes')" :inactive-text="$t('system.no')" width="45px" />
  25. </template>
  26. </el-table-column>
  27. <el-table-column prop="search" :label="$t('generate.schema.structure.search')">
  28. <template #default="scope">
  29. <el-switch v-model="scope.row.search" inline-prompt :active-text="$t('system.yes')" :inactive-text="$t('system.no')" width="45px" />
  30. </template>
  31. </el-table-column>
  32. <el-table-column prop="search_op" :label="$t('generate.schema.structure.search_op.name')" width="150px">
  33. <template #default="scope">
  34. <el-select v-model="scope.row.search_op" :placeholder="$t('generate.schema.structure.search_op.placeholder')" class="w-full">
  35. <el-option v-for="op in operates" :key="op" :label="op" :value="op" />
  36. </el-select>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="validates" :label="$t('generate.schema.structure.rules.name')" width="250px">
  40. <template #default="scope">
  41. <el-select v-model="scope.row.validates" :placeholder="$t('generate.schema.structure.rules.placeholder')" multiple filterable allow-create clearable class="w-full">
  42. <el-option v-for="validate in validates" :key="validate" :label="validate" :value="validate" />
  43. </el-select>
  44. </template>
  45. </el-table-column>
  46. <!--<el-table-column prop="comment" label="注释" />-->
  47. <el-table-column prop="id" :label="$t('generate.schema.structure.operate')" width="120px">
  48. <template #default="scope">
  49. <el-button type="danger" :icon="Delete" @click="deleteField(scope.row.field)" size="small" />
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. </div>
  54. </template>
  55. <script lang="ts" setup>
  56. import {computed} from 'vue'
  57. import {useGenerateStore} from './store'
  58. import {Delete} from '@element-plus/icons-vue'
  59. const generateStore = useGenerateStore()
  60. const structures = computed(() => {
  61. return generateStore.getStructures
  62. })
  63. const deleteField = (field: string) => {
  64. generateStore.filterStructures(field)
  65. }
  66. const operates: string[] = ['=', '!=', '>', '>=', '<', '<=', 'like', 'RLike', 'LLike', 'in']
  67. const validates: string[] = [
  68. 'required',
  69. 'integer',
  70. 'numeric',
  71. 'string',
  72. 'timezone',
  73. 'url',
  74. 'uuid',
  75. 'date',
  76. 'alpha',
  77. 'alpha_dash',
  78. 'alpha_num',
  79. 'boolean',
  80. 'email',
  81. 'image',
  82. 'file',
  83. 'ip',
  84. 'ipv4',
  85. 'ipv6',
  86. 'mac_address',
  87. 'json',
  88. 'nullable',
  89. 'present',
  90. 'prohibited',
  91. ]
  92. const formComponents: string[] = ['cascader', 'date', 'datetime', 'input', 'input-number', 'radio', 'rate', 'select', 'tree', 'tree-select']
  93. </script>