editTable.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <el-card>
  3. <el-tabs v-model="activeName">
  4. <el-tab-pane label="基本信息" name="basic">
  5. <basic-info-form ref="basicInfo" :info="info" />
  6. </el-tab-pane>
  7. <el-tab-pane label="字段信息" name="columnInfo">
  8. <el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
  9. <el-table-column label="序号" type="index" min-width="5%" />
  10. <el-table-column label="字段列名" prop="columnName" min-width="10%" :show-overflow-tooltip="true" />
  11. <el-table-column label="字段描述" min-width="10%">
  12. <template #default="scope">
  13. <el-input v-model="scope.row.columnComment"></el-input>
  14. </template>
  15. </el-table-column>
  16. <el-table-column label="物理类型" prop="columnType" min-width="10%" :show-overflow-tooltip="true" />
  17. <el-table-column label="Java类型" min-width="11%">
  18. <template #default="scope">
  19. <el-select v-model="scope.row.javaType">
  20. <el-option label="Long" value="Long" />
  21. <el-option label="String" value="String" />
  22. <el-option label="Integer" value="Integer" />
  23. <el-option label="Double" value="Double" />
  24. <el-option label="BigDecimal" value="BigDecimal" />
  25. <el-option label="Date" value="Date" />
  26. <el-option label="Boolean" value="Boolean" />
  27. </el-select>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="java属性" min-width="10%">
  31. <template #default="scope">
  32. <el-input v-model="scope.row.javaField"></el-input>
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="插入" min-width="5%">
  36. <template #default="scope">
  37. <el-checkbox true-label="1" false-label="0" v-model="scope.row.isInsert"></el-checkbox>
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="编辑" min-width="5%">
  41. <template #default="scope">
  42. <el-checkbox true-label="1" false-label="0" v-model="scope.row.isEdit"></el-checkbox>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="列表" min-width="5%">
  46. <template #default="scope">
  47. <el-checkbox true-label="1" false-label="0" v-model="scope.row.isList"></el-checkbox>
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="查询" min-width="5%">
  51. <template #default="scope">
  52. <el-checkbox true-label="1" false-label="0" v-model="scope.row.isQuery"></el-checkbox>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="查询方式" min-width="10%">
  56. <template #default="scope">
  57. <el-select v-model="scope.row.queryType">
  58. <el-option label="=" value="EQ" />
  59. <el-option label="!=" value="NE" />
  60. <el-option label=">" value="GT" />
  61. <el-option label=">=" value="GE" />
  62. <el-option label="<" value="LT" />
  63. <el-option label="<=" value="LE" />
  64. <el-option label="LIKE" value="LIKE" />
  65. <el-option label="BETWEEN" value="BETWEEN" />
  66. </el-select>
  67. </template>
  68. </el-table-column>
  69. <el-table-column label="必填" min-width="5%">
  70. <template #default="scope">
  71. <el-checkbox true-label="1" false-label="0" v-model="scope.row.isRequired"></el-checkbox>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="显示类型" min-width="12%">
  75. <template #default="scope">
  76. <el-select v-model="scope.row.htmlType">
  77. <el-option label="文本框" value="input" />
  78. <el-option label="文本域" value="textarea" />
  79. <el-option label="下拉框" value="select" />
  80. <el-option label="单选框" value="radio" />
  81. <el-option label="复选框" value="checkbox" />
  82. <el-option label="日期控件" value="datetime" />
  83. <el-option label="图片上传" value="imageUpload" />
  84. <el-option label="文件上传" value="fileUpload" />
  85. <el-option label="富文本控件" value="editor" />
  86. </el-select>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="字典类型" min-width="12%">
  90. <template #default="scope">
  91. <el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
  92. <el-option v-for="dict in dictOptions" :key="dict.dictType" :label="dict.dictName" :value="dict.dictType">
  93. <span style="float: left">{{ dict.dictName }}</span>
  94. <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
  95. </el-option>
  96. </el-select>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. </el-tab-pane>
  101. <el-tab-pane label="生成信息" name="genInfo">
  102. <gen-info-form ref="genInfo" :info="info" :tables="tables" />
  103. </el-tab-pane>
  104. </el-tabs>
  105. <el-form label-width="100px">
  106. <div style="text-align: center;margin-left:-100px;margin-top:10px;">
  107. <el-button type="primary" @click="submitForm()">提交</el-button>
  108. <el-button @click="close()">返回</el-button>
  109. </div>
  110. </el-form>
  111. </el-card>
  112. </template>
  113. <script setup name="GenEdit" lang="ts">
  114. import { getGenTable, updateGenTable } from '@/api/tool/gen';
  115. import { DbColumnVO, DbTableVO } from '@/api/tool/gen/types';
  116. import { optionselect as getDictOptionselect } from '@/api/system/dict/type';
  117. import { DictTypeVO } from '@/api/system/dict/type/types';
  118. import basicInfoForm from './basicInfoForm.vue';
  119. import genInfoForm from "./genInfoForm.vue";
  120. import { ComponentInternalInstance } from "vue";
  121. const route = useRoute();
  122. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  123. const activeName = ref('columnInfo');
  124. const tableHeight = ref(document.documentElement.scrollHeight - 245 + 'px');
  125. const tables = ref<DbTableVO[]>([]);
  126. const columns = ref<DbColumnVO[]>([]);
  127. const dictOptions = ref<DictTypeVO[]>([]);
  128. const info = ref<Partial<DbTableVO>>({});
  129. const basicInfo = ref(basicInfoForm);
  130. const genInfo = ref(genInfoForm);
  131. /** 提交按钮 */
  132. const submitForm = () => {
  133. const basicForm = basicInfo.value.$refs.basicInfoForm;
  134. const genForm = genInfo.value.$refs.genInfoForm;
  135. Promise.all([basicForm, genForm].map(getFormPromise)).then(async res => {
  136. const validateResult = res.every(item => !!item);
  137. if (validateResult) {
  138. const genTable: any = Object.assign({}, info.value);
  139. genTable.columns = columns.value;
  140. genTable.params = {
  141. treeCode: info.value?.treeCode,
  142. treeName: info.value.treeName,
  143. treeParentCode: info.value.treeParentCode,
  144. parentMenuId: info.value.parentMenuId
  145. };
  146. const response = await updateGenTable(genTable);
  147. proxy?.$modal.msgSuccess(response.msg);
  148. if (response.code === 200) {
  149. close();
  150. }
  151. } else {
  152. proxy?.$modal.msgError("表单校验未通过,请重新检查提交内容");
  153. }
  154. });
  155. }
  156. const getFormPromise = (form: any) => {
  157. return new Promise(resolve => {
  158. form.validate((res: any) => {
  159. resolve(res);
  160. });
  161. });
  162. }
  163. const close = () => {
  164. const obj = {path: "/tool/gen", query: {t: Date.now(), pageNum: route.query.pageNum}};
  165. proxy?.$tab.closeOpenPage(obj);
  166. }
  167. (async () => {
  168. const tableId = route.params && route.params.tableId as string;
  169. if (tableId) {
  170. // 获取表详细信息
  171. const res = await getGenTable(tableId);
  172. columns.value = res.data.rows;
  173. info.value = res.data.info;
  174. tables.value = res.data.tables;
  175. /** 查询字典下拉列表 */
  176. const response = await getDictOptionselect();
  177. dictOptions.value = response.data;
  178. }
  179. })();
  180. </script>