genEntity.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div class="sys-dbEntity-container">
  3. <el-dialog v-model="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="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="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="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="ruleForm.baseClassName" clearable class="w100">
  25. <el-option label="EntityBaseId【基础实体Id】" value="EntityBaseId" />
  26. <el-option label="EntityBase【基础实体】" value="EntityBase" />
  27. <el-option label="EntityTenantId【租户实体Id】" value="EntityTenantId" />
  28. <el-option label="EntityTenant【租户实体】" value="EntityTenant" />
  29. <el-option label="EntityBaseData【业务实体】" value="EntityBaseData" />
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  34. <el-form-item label="存放位置" prop="position">
  35. <el-select v-model="ruleForm.position" clearable class="w100">
  36. <el-option label="Admin.NET.Application" value="Admin.NET.Application" />
  37. <el-option label="Admin.NET.Core" value="Admin.NET.Core" />
  38. </el-select>
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. </el-form>
  43. <template #footer>
  44. <span class="dialog-footer">
  45. <el-button @click="cancel" size="default">取 消</el-button>
  46. <el-button type="primary" @click="submit" size="default">确 定</el-button>
  47. </span>
  48. </template>
  49. </el-dialog>
  50. </div>
  51. </template>
  52. <script lang="ts">
  53. import { reactive, toRefs, defineComponent, ref } from 'vue';
  54. import mittBus from '/@/utils/mitt';
  55. import { getAPI } from '/@/utils/axios-utils';
  56. import { SysDatabaseApi } from '/@/api-services/api';
  57. export default defineComponent({
  58. name: 'sysGenEntity',
  59. components: {},
  60. setup() {
  61. const ruleFormRef = ref();
  62. const state = reactive({
  63. isShowDialog: false,
  64. ruleForm: {} as any,
  65. });
  66. // 打开弹窗
  67. const openDialog = (row: any) => {
  68. state.ruleForm.configId = row.configId;
  69. state.ruleForm.tableName = row.tableName;
  70. state.ruleForm.baseClassName = 'EntityBase';
  71. state.ruleForm.position = 'Admin.NET.Application';
  72. state.isShowDialog = true;
  73. };
  74. // 关闭弹窗
  75. const closeDialog = () => {
  76. mittBus.emit('submitRefreshColumn');
  77. state.isShowDialog = false;
  78. };
  79. // 取消
  80. const cancel = () => {
  81. state.isShowDialog = false;
  82. };
  83. // 提交
  84. const submit = () => {
  85. ruleFormRef.value.validate(async (valid: boolean) => {
  86. if (!valid) return;
  87. await getAPI(SysDatabaseApi).sysDatabaseCreateEntityPost(state.ruleForm);
  88. closeDialog();
  89. });
  90. };
  91. return {
  92. ruleFormRef,
  93. openDialog,
  94. closeDialog,
  95. cancel,
  96. submit,
  97. ...toRefs(state),
  98. };
  99. },
  100. });
  101. </script>