genEntity.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div class="sys-dbEntity-container">
  3. <el-dialog v-model="state.isShowDialog" draggable width="600px">
  4. <template #header>
  5. <div style="color: #fff">
  6. <el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Cpu /> </el-icon>
  7. <span> 生成实体 </span>
  8. </div>
  9. </template>
  10. <el-form :model="state.ruleForm" ref="ruleFormRef" size="default" label-width="100px">
  11. <el-row :gutter="35">
  12. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  13. <el-form-item label="表名" prop="tableName" :rules="[{ required: true, message: '表名不能为空', trigger: 'blur' }]">
  14. <el-input disabled v-model="state.ruleForm.tableName" placeholder="表名" clearable />
  15. </el-form-item>
  16. </el-col>
  17. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  18. <el-form-item label="实体名称" prop="entityName" :rules="[{ required: true, message: '实体名称不能为空', trigger: 'blur' }]">
  19. <el-input v-model="state.ruleForm.entityName" placeholder="实体名称" clearable />
  20. </el-form-item>
  21. </el-col>
  22. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  23. <el-form-item label="基类" prop="baseClassName">
  24. <el-select v-model="state.ruleForm.baseClassName" clearable class="w100">
  25. <el-option v-for="item in state.codeGenBaseClassName" :key="item.value" :label="item.label" :value="item.value" />
  26. </el-select>
  27. </el-form-item>
  28. </el-col>
  29. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  30. <el-form-item label="存放位置" prop="position">
  31. <el-select v-model="state.ruleForm.position" clearable class="w100">
  32. <el-option label="Admin.NET.Application" value="Admin.NET.Application" />
  33. <el-option label="Admin.NET.Core" value="Admin.NET.Core" />
  34. </el-select>
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. </el-form>
  39. <template #footer>
  40. <span class="dialog-footer">
  41. <el-button @click="cancel" size="default">取 消</el-button>
  42. <el-button type="primary" @click="submit" size="default">确 定</el-button>
  43. </span>
  44. </template>
  45. </el-dialog>
  46. </div>
  47. </template>
  48. <script lang="ts" setup name="sysGenEntity">
  49. import { onMounted, reactive, ref } from 'vue';
  50. import mittBus from '/@/utils/mitt';
  51. import { getAPI } from '/@/utils/axios-utils';
  52. import { SysDatabaseApi, SysDictDataApi } from '/@/api-services/api';
  53. const ruleFormRef = ref();
  54. const state = reactive({
  55. isShowDialog: false,
  56. ruleForm: {} as any,
  57. codeGenBaseClassName: [] as any,
  58. });
  59. onMounted(async () => {
  60. let resDicData = await getAPI(SysDictDataApi).apiSysDictDataDataListCodeGet('code_gen_base_class');
  61. state.codeGenBaseClassName = resDicData.data.result;
  62. });
  63. // 打开弹窗
  64. const openDialog = (row: any) => {
  65. state.ruleForm.configId = row.configId;
  66. state.ruleForm.tableName = row.tableName;
  67. state.ruleForm.baseClassName = 'EntityBase';
  68. state.ruleForm.position = 'Admin.NET.Application';
  69. state.isShowDialog = true;
  70. };
  71. // 关闭弹窗
  72. const closeDialog = () => {
  73. mittBus.emit('submitRefreshColumn');
  74. state.isShowDialog = false;
  75. };
  76. // 取消
  77. const cancel = () => {
  78. state.isShowDialog = false;
  79. };
  80. // 提交
  81. const submit = () => {
  82. ruleFormRef.value.validate(async (valid: boolean) => {
  83. if (!valid) return;
  84. await getAPI(SysDatabaseApi).apiSysDatabaseCreateEntityPost(state.ruleForm);
  85. closeDialog();
  86. });
  87. };
  88. // 导出对象
  89. defineExpose({ openDialog });
  90. </script>