genSeedData.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="sys-dbEntity-container">
  3. <el-dialog v-model="state.isShowDialog" draggable :close-on-click-modal="false" width="700px">
  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" label-width="auto" :rules="state.rules">
  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="suffix">
  19. <el-input v-model="state.ruleForm.suffix" 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="position">
  24. <!-- <el-input v-model="state.ruleForm.position" placeholder="存放位置" clearable >Admin.NET.Core</el-input> -->
  25. <el-select v-model="state.ruleForm.position" filterable clearable class="w100" placeholder="存放位置">
  26. <el-option v-for="(item, index) in props.applicationNamespaces" :key="index" :label="item" :value="item" />
  27. </el-select>
  28. </el-form-item>
  29. </el-col>
  30. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
  31. <el-form-item label="过滤重复数据" prop="filterExistingData">
  32. <el-switch v-model="state.ruleForm.filterExistingData" ></el-switch>
  33. </el-form-item>
  34. </el-col>
  35. </el-row>
  36. </el-form>
  37. <template #footer>
  38. <span class="dialog-footer">
  39. <el-button @click="cancel">取 消</el-button>
  40. <el-button type="primary" @click="submit">确 定</el-button>
  41. </span>
  42. </template>
  43. </el-dialog>
  44. </div>
  45. </template>
  46. <script lang="ts" setup name="sysGenEntity">
  47. import { onMounted, reactive, ref } from 'vue';
  48. import { getAPI } from '/@/utils/axios-utils';
  49. import { SysDatabaseApi, SysDictTypeApi } from '/@/api-services/api';
  50. const emits = defineEmits(['handleQueryColumn']);
  51. const props = defineProps({
  52. applicationNamespaces: { type: Array },
  53. });
  54. const ruleFormRef = ref();
  55. const state = reactive({
  56. isShowDialog: false,
  57. ruleForm: {} as any,
  58. codeGenBaseClassName: [] as any,
  59. rules: { position: [{ required: true, message: '请选择存放位置', trigger: 'blur' }] },
  60. });
  61. onMounted(async () => {
  62. let resDicData = await getAPI(SysDictTypeApi).apiSysDictTypeDataListGet('code_gen_base_class');
  63. state.codeGenBaseClassName = resDicData.data.result;
  64. });
  65. // 打开弹窗
  66. const openDialog = (row: any) => {
  67. state.ruleForm.configId = row.configId;
  68. state.ruleForm.tableName = row.tableName;
  69. state.ruleForm.position = row.position;
  70. state.ruleForm.filterExistingData = false;
  71. state.isShowDialog = true;
  72. };
  73. // 关闭弹窗
  74. const closeDialog = () => {
  75. emits('handleQueryColumn');
  76. state.isShowDialog = false;
  77. };
  78. // 取消
  79. const cancel = () => {
  80. state.isShowDialog = false;
  81. };
  82. // 提交
  83. const submit = () => {
  84. ruleFormRef.value.validate(async (valid: boolean) => {
  85. if (!valid) return;
  86. await getAPI(SysDatabaseApi).apiSysDatabaseCreateSeedDataPost(state.ruleForm);
  87. closeDialog();
  88. });
  89. };
  90. // 导出对象
  91. defineExpose({ openDialog });
  92. </script>