generateEntity.vue 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <div class="sys-dbColumn-container">
  3. <el-dialog v-model="isShowDialog" title="配置实体" draggable width="600px">
  4. <el-form :model="ruleForm" ref="ruleFormRef" size="default" label-width="100px">
  5. <el-row :gutter="35">
  6. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  7. <el-form-item label="表名" prop="tableName" :rules="[{ required: true, message: '表名不能为空', trigger: 'blur' }]">
  8. <el-input disabled v-model="ruleForm.tableName" placeholder="表名" clearable />
  9. </el-form-item>
  10. </el-col>
  11. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  12. <el-form-item label="实体名称" prop="entityName" :rules="[{ required: true, message: '实体名称不能为空', trigger: 'blur' }]">
  13. <el-input v-model="ruleForm.entityName" placeholder="实体名称" clearable/>
  14. </el-form-item>
  15. </el-col>
  16. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  17. <el-form-item label="基类" prop="baseClassName">
  18. <el-select v-model="ruleForm.baseClassName" clearable>
  19. <el-option label="EntityBaseId" value="EntityBaseId" />
  20. <el-option label="EntityBase" value="EntityBase" />
  21. <el-option label="EntityTenant" value="EntityTenant" />
  22. </el-select>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  26. <el-form-item label="存放位置" prop="position" clearable>
  27. <el-select v-model="ruleForm.position">
  28. <el-option label="Admin.NET.Application" value="Admin.NET.Application" />
  29. <el-option label="Admin.NET.Core" value="Admin.NET.Core" />
  30. </el-select>
  31. </el-form-item>
  32. </el-col>
  33. </el-row>
  34. </el-form>
  35. <template #footer>
  36. <span class="dialog-footer">
  37. <el-button @click="cancel" size="default">取 消</el-button>
  38. <el-button type="primary" @click="submit" size="default">确 定</el-button>
  39. </span>
  40. </template>
  41. </el-dialog>
  42. </div>
  43. </template>
  44. <script lang="ts">
  45. import { reactive, toRefs, defineComponent, getCurrentInstance, ref } from 'vue';
  46. import { createEntity } from '/@/api/system/admin';
  47. export default defineComponent({
  48. name: 'generateEntity',
  49. components: {},
  50. setup() {
  51. const { proxy } = getCurrentInstance() as any;
  52. const ruleFormRef = ref();
  53. const state = reactive({
  54. isShowDialog: false,
  55. ruleForm: {} as any,
  56. });
  57. // 打开弹窗
  58. const openDialog = (row: any) => {
  59. state.ruleForm.configId = row.configId;
  60. state.ruleForm.tableName = row.tableName;
  61. state.ruleForm.baseClassName = 'EntityBase';
  62. state.ruleForm.position = 'Admin.NET.Application';
  63. state.isShowDialog = true;
  64. };
  65. // 关闭弹窗
  66. const closeDialog = () => {
  67. proxy.mittBus.emit('submitRefreshColumn');
  68. state.isShowDialog = false;
  69. };
  70. // 取消
  71. const cancel = () => {
  72. state.isShowDialog = false;
  73. };
  74. // 提交
  75. const submit = () => {
  76. ruleFormRef.value.validate(async (valid: boolean) => {
  77. if (!valid) return;
  78. await createEntity(state.ruleForm);
  79. closeDialog();
  80. });
  81. };
  82. return {
  83. ruleFormRef,
  84. openDialog,
  85. closeDialog,
  86. cancel,
  87. submit,
  88. ...toRefs(state),
  89. };
  90. },
  91. });
  92. </script>