修改系统
This commit is contained in:
		
							
								
								
									
										61
									
								
								stdiet-ui/src/views/tool/gen/basicInfoForm.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								stdiet-ui/src/views/tool/gen/basicInfoForm.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,61 @@ | ||||
| <template> | ||||
|   <el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px"> | ||||
|     <el-row> | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item label="表名称" prop="tableName"> | ||||
|           <el-input placeholder="请输入仓库名称" v-model="info.tableName" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item label="表描述" prop="tableComment"> | ||||
|           <el-input placeholder="请输入" v-model="info.tableComment" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item label="实体类名称" prop="className"> | ||||
|           <el-input placeholder="请输入" v-model="info.className" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item label="作者" prop="functionAuthor"> | ||||
|           <el-input placeholder="请输入" v-model="info.functionAuthor" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|       <el-col :span="24"> | ||||
|         <el-form-item label="备注" prop="remark"> | ||||
|           <el-input type="textarea" :rows="3" v-model="info.remark"></el-input> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|     </el-row> | ||||
|   </el-form> | ||||
| </template> | ||||
| <script> | ||||
| export default { | ||||
|   name: "BasicInfoForm", | ||||
|   props: { | ||||
|     info: { | ||||
|       type: Object, | ||||
|       default: null | ||||
|     } | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       rules: { | ||||
|         tableName: [ | ||||
|           { required: true, message: "请输入表名称", trigger: "blur" } | ||||
|         ], | ||||
|         tableComment: [ | ||||
|           { required: true, message: "请输入表描述", trigger: "blur" } | ||||
|         ], | ||||
|         className: [ | ||||
|           { required: true, message: "请输入实体类名称", trigger: "blur" } | ||||
|         ], | ||||
|         functionAuthor: [ | ||||
|           { required: true, message: "请输入作者", trigger: "blur" } | ||||
|         ] | ||||
|       } | ||||
|     }; | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										227
									
								
								stdiet-ui/src/views/tool/gen/editTable.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										227
									
								
								stdiet-ui/src/views/tool/gen/editTable.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,227 @@ | ||||
| <template> | ||||
|   <el-card> | ||||
|     <el-tabs v-model="activeName"> | ||||
|       <el-tab-pane label="基本信息" name="basic"> | ||||
|         <basic-info-form ref="basicInfo" :info="info" /> | ||||
|       </el-tab-pane> | ||||
|       <el-tab-pane label="字段信息" name="cloum"> | ||||
|         <el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight"> | ||||
|           <el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" /> | ||||
|           <el-table-column | ||||
|             label="字段列名" | ||||
|             prop="columnName" | ||||
|             min-width="10%" | ||||
|             :show-overflow-tooltip="true" | ||||
|           /> | ||||
|           <el-table-column label="字段描述" min-width="10%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-input v-model="scope.row.columnComment"></el-input> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column | ||||
|             label="物理类型" | ||||
|             prop="columnType" | ||||
|             min-width="10%" | ||||
|             :show-overflow-tooltip="true" | ||||
|           /> | ||||
|           <el-table-column label="Java类型" min-width="11%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-select v-model="scope.row.javaType"> | ||||
|                 <el-option label="Long" value="Long" /> | ||||
|                 <el-option label="String" value="String" /> | ||||
|                 <el-option label="Integer" value="Integer" /> | ||||
|                 <el-option label="Double" value="Double" /> | ||||
|                 <el-option label="BigDecimal" value="BigDecimal" /> | ||||
|                 <el-option label="Date" value="Date" /> | ||||
|               </el-select> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="java属性" min-width="10%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-input v-model="scope.row.javaField"></el-input> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|  | ||||
|           <el-table-column label="插入" min-width="5%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-checkbox true-label="1" v-model="scope.row.isInsert"></el-checkbox> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="编辑" min-width="5%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-checkbox true-label="1" v-model="scope.row.isEdit"></el-checkbox> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="列表" min-width="5%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-checkbox true-label="1" v-model="scope.row.isList"></el-checkbox> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="查询" min-width="5%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-checkbox true-label="1" v-model="scope.row.isQuery"></el-checkbox> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="查询方式" min-width="10%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-select v-model="scope.row.queryType"> | ||||
|                 <el-option label="=" value="EQ" /> | ||||
|                 <el-option label="!=" value="NE" /> | ||||
|                 <el-option label=">" value="GT" /> | ||||
|                 <el-option label=">=" value="GTE" /> | ||||
|                 <el-option label="<" value="LT" /> | ||||
|                 <el-option label="<=" value="LTE" /> | ||||
|                 <el-option label="LIKE" value="LIKE" /> | ||||
|                 <el-option label="BETWEEN" value="BETWEEN" /> | ||||
|               </el-select> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="必填" min-width="5%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-checkbox true-label="1" v-model="scope.row.isRequired"></el-checkbox> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="显示类型" min-width="12%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-select v-model="scope.row.htmlType"> | ||||
|                 <el-option label="文本框" value="input" /> | ||||
|                 <el-option label="文本域" value="textarea" /> | ||||
|                 <el-option label="下拉框" value="select" /> | ||||
|                 <el-option label="单选框" value="radio" /> | ||||
|                 <el-option label="复选框" value="checkbox" /> | ||||
|                 <el-option label="日期控件" value="datetime" /> | ||||
|                 <el-option label="富文本控件" value="editor" /> | ||||
|               </el-select> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|           <el-table-column label="字典类型" min-width="12%"> | ||||
|             <template slot-scope="scope"> | ||||
|               <el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择"> | ||||
|                 <el-option | ||||
|                   v-for="dict in dictOptions" | ||||
|                   :key="dict.dictType" | ||||
|                   :label="dict.dictName" | ||||
|                   :value="dict.dictType"> | ||||
|                   <span style="float: left">{{ dict.dictName }}</span> | ||||
|                   <span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span> | ||||
|               </el-option> | ||||
|               </el-select> | ||||
|             </template> | ||||
|           </el-table-column> | ||||
|         </el-table> | ||||
|       </el-tab-pane> | ||||
|       <el-tab-pane label="生成信息" name="genInfo"> | ||||
|         <gen-info-form ref="genInfo" :info="info" :menus="menus"/> | ||||
|       </el-tab-pane> | ||||
|     </el-tabs> | ||||
|     <el-form label-width="100px"> | ||||
|       <el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;"> | ||||
|         <el-button type="primary" @click="submitForm()">提交</el-button> | ||||
|         <el-button @click="close()">返回</el-button> | ||||
|       </el-form-item> | ||||
|     </el-form> | ||||
|   </el-card> | ||||
| </template> | ||||
| <script> | ||||
| import { getGenTable, updateGenTable } from "@/api/tool/gen"; | ||||
| import { optionselect as getDictOptionselect } from "@/api/system/dict/type"; | ||||
| import { listMenu as getMenuTreeselect } from "@/api/system/menu"; | ||||
| import basicInfoForm from "./basicInfoForm"; | ||||
| import genInfoForm from "./genInfoForm"; | ||||
| import Sortable from 'sortablejs' | ||||
|  | ||||
| export default { | ||||
|   name: "GenEdit", | ||||
|   components: { | ||||
|     basicInfoForm, | ||||
|     genInfoForm | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       // 选中选项卡的 name | ||||
|       activeName: "cloum", | ||||
|       // 表格的高度 | ||||
|       tableHeight: document.documentElement.scrollHeight - 245 + "px", | ||||
|       // 表列信息 | ||||
|       cloumns: [], | ||||
|       // 字典信息 | ||||
|       dictOptions: [], | ||||
|       // 菜单信息 | ||||
|       menus: [], | ||||
|       // 表详细信息 | ||||
|       info: {} | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     const tableId = this.$route.params && this.$route.params.tableId; | ||||
|     if (tableId) { | ||||
|       // 获取表详细信息 | ||||
|       getGenTable(tableId).then(res => { | ||||
|         this.cloumns = res.data.rows; | ||||
|         this.info = res.data.info; | ||||
|       }); | ||||
|       /** 查询字典下拉列表 */ | ||||
|       getDictOptionselect().then(response => { | ||||
|         this.dictOptions = response.data; | ||||
|       }); | ||||
|       /** 查询菜单下拉列表 */ | ||||
|       getMenuTreeselect().then(response => { | ||||
|         this.menus = this.handleTree(response.data, "menuId"); | ||||
|       }); | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 提交按钮 */ | ||||
|     submitForm() { | ||||
|       const basicForm = this.$refs.basicInfo.$refs.basicInfoForm; | ||||
|       const genForm = this.$refs.genInfo.$refs.genInfoForm; | ||||
|       Promise.all([basicForm, genForm].map(this.getFormPromise)).then(res => { | ||||
|         const validateResult = res.every(item => !!item); | ||||
|         if (validateResult) { | ||||
|           const genTable = Object.assign({}, basicForm.model, genForm.model); | ||||
|           genTable.columns = this.cloumns; | ||||
|           genTable.params = { | ||||
|             treeCode: genTable.treeCode, | ||||
|             treeName: genTable.treeName, | ||||
|             treeParentCode: genTable.treeParentCode, | ||||
|             parentMenuId: genTable.parentMenuId | ||||
|           }; | ||||
|           updateGenTable(genTable).then(res => { | ||||
|             this.msgSuccess(res.msg); | ||||
|             if (res.code === 200) { | ||||
|               this.close(); | ||||
|             } | ||||
|           }); | ||||
|         } else { | ||||
|           this.msgError("表单校验未通过,请重新检查提交内容"); | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     getFormPromise(form) { | ||||
|       return new Promise(resolve => { | ||||
|         form.validate(res => { | ||||
|           resolve(res); | ||||
|         }); | ||||
|       }); | ||||
|     }, | ||||
|     /** 关闭按钮 */ | ||||
|     close() { | ||||
|       this.$store.dispatch("tagsView/delView", this.$route); | ||||
|       this.$router.push({ path: "/tool/gen", query: { t: Date.now()}}) | ||||
|     } | ||||
|   }, | ||||
|   mounted() { | ||||
|     const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0]; | ||||
|     const sortable = Sortable.create(el, { | ||||
|       handle: ".allowDrag", | ||||
|       onEnd: evt => { | ||||
|         const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0]; | ||||
|         this.cloumns.splice(evt.newIndex, 0, targetRow); | ||||
|         for (let index in this.cloumns) { | ||||
|           this.cloumns[index].sort = parseInt(index) + 1; | ||||
|         } | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										229
									
								
								stdiet-ui/src/views/tool/gen/genInfoForm.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										229
									
								
								stdiet-ui/src/views/tool/gen/genInfoForm.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,229 @@ | ||||
| <template> | ||||
|   <el-form ref="genInfoForm" :model="info" :rules="rules" label-width="150px"> | ||||
|     <el-row> | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="tplCategory"> | ||||
|           <span slot="label">生成模板</span> | ||||
|           <el-select v-model="info.tplCategory"> | ||||
|             <el-option label="单表(增删改查)" value="crud" /> | ||||
|             <el-option label="树表(增删改查)" value="tree" /> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="packageName"> | ||||
|           <span slot="label"> | ||||
|             生成包路径 | ||||
|             <el-tooltip content="生成在哪个java包下,例如 com.ruoyi.system" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-input v-model="info.packageName" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="moduleName"> | ||||
|           <span slot="label"> | ||||
|             生成模块名 | ||||
|             <el-tooltip content="可理解为子系统名,例如 system" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-input v-model="info.moduleName" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="businessName"> | ||||
|           <span slot="label"> | ||||
|             生成业务名 | ||||
|             <el-tooltip content="可理解为功能英文名,例如 user" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-input v-model="info.businessName" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="functionName"> | ||||
|           <span slot="label"> | ||||
|             生成功能名 | ||||
|             <el-tooltip content="用作类描述,例如 用户" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-input v-model="info.functionName" /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item> | ||||
|           <span slot="label"> | ||||
|             上级菜单 | ||||
|             <el-tooltip content="分配到指定菜单下,例如 系统管理" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <treeselect | ||||
|             :append-to-body="true" | ||||
|             v-model="info.parentMenuId" | ||||
|             :options="menus" | ||||
|             :normalizer="normalizer" | ||||
|             :show-count="true" | ||||
|             placeholder="请选择系统菜单" | ||||
|           /> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item prop="genType"> | ||||
|           <span slot="label"> | ||||
|             生成代码方式 | ||||
|             <el-tooltip content="默认为zip压缩包下载,也可以自定义生成路径" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-radio v-model="info.genType" label="0">zip压缩包</el-radio> | ||||
|           <el-radio v-model="info.genType" label="1">自定义路径</el-radio> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|  | ||||
|       <el-col :span="24" v-if="info.genType == '1'"> | ||||
|         <el-form-item prop="genPath"> | ||||
|           <span slot="label"> | ||||
|             自定义路径 | ||||
|             <el-tooltip content="填写磁盘绝对路径,若不填写,则生成到当前Web项目下" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-input v-model="info.genPath"> | ||||
|             <el-dropdown slot="append"> | ||||
|               <el-button type="primary"> | ||||
|                 最近路径快速选择 | ||||
|                 <i class="el-icon-arrow-down el-icon--right"></i> | ||||
|               </el-button> | ||||
|               <el-dropdown-menu slot="dropdown"> | ||||
|                 <el-dropdown-item @click.native="info.genPath = '/'">恢复默认的生成基础路径</el-dropdown-item> | ||||
|               </el-dropdown-menu> | ||||
|             </el-dropdown> | ||||
|           </el-input> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|     </el-row> | ||||
|  | ||||
|     <el-row v-show="info.tplCategory == 'tree'"> | ||||
|       <h4 class="form-header">其他信息</h4> | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item> | ||||
|           <span slot="label"> | ||||
|             树编码字段 | ||||
|             <el-tooltip content="树显示的编码字段名, 如:dept_id" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-select v-model="info.treeCode" placeholder="请选择"> | ||||
|             <el-option | ||||
|               v-for="column in info.columns" | ||||
|               :key="column.columnName" | ||||
|               :label="column.columnName + ':' + column.columnComment" | ||||
|               :value="column.columnName" | ||||
|             ></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item> | ||||
|           <span slot="label"> | ||||
|             树父编码字段 | ||||
|             <el-tooltip content="树显示的父编码字段名, 如:parent_Id" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-select v-model="info.treeParentCode" placeholder="请选择"> | ||||
|             <el-option | ||||
|               v-for="column in info.columns" | ||||
|               :key="column.columnName" | ||||
|               :label="column.columnName + ':' + column.columnComment" | ||||
|               :value="column.columnName" | ||||
|             ></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|       <el-col :span="12"> | ||||
|         <el-form-item> | ||||
|           <span slot="label"> | ||||
|             树名称字段 | ||||
|             <el-tooltip content="树节点的显示名称字段名, 如:dept_name" placement="top"> | ||||
|               <i class="el-icon-question"></i> | ||||
|             </el-tooltip> | ||||
|           </span> | ||||
|           <el-select v-model="info.treeName" placeholder="请选择"> | ||||
|             <el-option | ||||
|               v-for="column in info.columns" | ||||
|               :key="column.columnName" | ||||
|               :label="column.columnName + ':' + column.columnComment" | ||||
|               :value="column.columnName" | ||||
|             ></el-option> | ||||
|           </el-select> | ||||
|         </el-form-item> | ||||
|       </el-col> | ||||
|     </el-row> | ||||
|   </el-form> | ||||
| </template> | ||||
| <script> | ||||
| import Treeselect from "@riophae/vue-treeselect"; | ||||
| import "@riophae/vue-treeselect/dist/vue-treeselect.css"; | ||||
|  | ||||
| export default { | ||||
|   name: "BasicInfoForm", | ||||
|   components: { Treeselect }, | ||||
|   props: { | ||||
|     info: { | ||||
|       type: Object, | ||||
|       default: null | ||||
|     }, | ||||
|     menus: { | ||||
|       type: Array, | ||||
|       default: [] | ||||
|     }, | ||||
|   }, | ||||
|   data() { | ||||
|     return { | ||||
|       rules: { | ||||
|         tplCategory: [ | ||||
|           { required: true, message: "请选择生成模板", trigger: "blur" } | ||||
|         ], | ||||
|         packageName: [ | ||||
|           { required: true, message: "请输入生成包路径", trigger: "blur" } | ||||
|         ], | ||||
|         moduleName: [ | ||||
|           { required: true, message: "请输入生成模块名", trigger: "blur" } | ||||
|         ], | ||||
|         businessName: [ | ||||
|           { required: true, message: "请输入生成业务名", trigger: "blur" } | ||||
|         ], | ||||
|         functionName: [ | ||||
|           { required: true, message: "请输入生成功能名", trigger: "blur" } | ||||
|         ], | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() {}, | ||||
|   methods: { | ||||
|     /** 转换菜单数据结构 */ | ||||
|     normalizer(node) { | ||||
|       if (node.children && !node.children.length) { | ||||
|         delete node.children; | ||||
|       } | ||||
|       return { | ||||
|         id: node.menuId, | ||||
|         label: node.menuName, | ||||
|         children: node.children | ||||
|       }; | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										117
									
								
								stdiet-ui/src/views/tool/gen/importTable.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								stdiet-ui/src/views/tool/gen/importTable.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,117 @@ | ||||
| <template> | ||||
|   <!-- 导入表 --> | ||||
|   <el-dialog title="导入表" :visible.sync="visible" width="800px" top="5vh" append-to-body> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true"> | ||||
|       <el-form-item label="表名称" prop="tableName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.tableName" | ||||
|           placeholder="请输入表名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="表描述" prop="tableComment"> | ||||
|         <el-input | ||||
|           v-model="queryParams.tableComment" | ||||
|           placeholder="请输入表描述" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item> | ||||
|         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||||
|         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||||
|       </el-form-item> | ||||
|     </el-form> | ||||
|     <el-row> | ||||
|       <el-table @row-click="clickRow" ref="table" :data="dbTableList" @selection-change="handleSelectionChange" height="260px"> | ||||
|         <el-table-column type="selection" width="55"></el-table-column> | ||||
|         <el-table-column prop="tableName" label="表名称" :show-overflow-tooltip="true"></el-table-column> | ||||
|         <el-table-column prop="tableComment" label="表描述" :show-overflow-tooltip="true"></el-table-column> | ||||
|         <el-table-column prop="createTime" label="创建时间"></el-table-column> | ||||
|         <el-table-column prop="updateTime" label="更新时间"></el-table-column> | ||||
|       </el-table> | ||||
|       <pagination | ||||
|         v-show="total>0" | ||||
|         :total="total" | ||||
|         :page.sync="queryParams.pageNum" | ||||
|         :limit.sync="queryParams.pageSize" | ||||
|         @pagination="getList" | ||||
|       /> | ||||
|     </el-row> | ||||
|     <div slot="footer" class="dialog-footer"> | ||||
|       <el-button type="primary" @click="handleImportTable">确 定</el-button> | ||||
|       <el-button @click="visible = false">取 消</el-button> | ||||
|     </div> | ||||
|   </el-dialog> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listDbTable, importTable } from "@/api/tool/gen"; | ||||
| export default { | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       visible: false, | ||||
|       // 选中数组值 | ||||
|       tables: [], | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 表数据 | ||||
|       dbTableList: [], | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         pageNum: 1, | ||||
|         pageSize: 10, | ||||
|         tableName: undefined, | ||||
|         tableComment: undefined | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   methods: { | ||||
|     // 显示弹框 | ||||
|     show() { | ||||
|       this.getList(); | ||||
|       this.visible = true; | ||||
|     }, | ||||
|     clickRow(row) { | ||||
|       this.$refs.table.toggleRowSelection(row); | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.tables = selection.map(item => item.tableName); | ||||
|     }, | ||||
|     // 查询表数据 | ||||
|     getList() { | ||||
|       listDbTable(this.queryParams).then(res => { | ||||
|         if (res.code === 200) { | ||||
|           this.dbTableList = res.rows; | ||||
|           this.total = res.total; | ||||
|         } | ||||
|       }); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     /** 导入按钮操作 */ | ||||
|     handleImportTable() { | ||||
|       importTable({ tables: this.tables.join(",") }).then(res => { | ||||
|         this.msgSuccess(res.msg); | ||||
|         if (res.code === 200) { | ||||
|           this.visible = false; | ||||
|           this.$emit("ok"); | ||||
|         } | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
							
								
								
									
										320
									
								
								stdiet-ui/src/views/tool/gen/index.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										320
									
								
								stdiet-ui/src/views/tool/gen/index.vue
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,320 @@ | ||||
| <template> | ||||
|   <div class="app-container"> | ||||
|     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | ||||
|       <el-form-item label="表名称" prop="tableName"> | ||||
|         <el-input | ||||
|           v-model="queryParams.tableName" | ||||
|           placeholder="请输入表名称" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="表描述" prop="tableComment"> | ||||
|         <el-input | ||||
|           v-model="queryParams.tableComment" | ||||
|           placeholder="请输入表描述" | ||||
|           clearable | ||||
|           size="small" | ||||
|           @keyup.enter.native="handleQuery" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="创建时间"> | ||||
|         <el-date-picker | ||||
|           v-model="dateRange" | ||||
|           size="small" | ||||
|           style="width: 240px" | ||||
|           value-format="yyyy-MM-dd" | ||||
|           type="daterange" | ||||
|           range-separator="-" | ||||
|           start-placeholder="开始日期" | ||||
|           end-placeholder="结束日期" | ||||
|         ></el-date-picker> | ||||
|       </el-form-item> | ||||
|       <el-form-item> | ||||
|         <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | ||||
|         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | ||||
|       </el-form-item> | ||||
|     </el-form> | ||||
|  | ||||
|     <el-row :gutter="10" class="mb8"> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="primary" | ||||
|           icon="el-icon-download" | ||||
|           size="mini" | ||||
|           @click="handleGenTable" | ||||
|           v-hasPermi="['tool:gen:code']" | ||||
|         >生成</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="info" | ||||
|           icon="el-icon-upload" | ||||
|           size="mini" | ||||
|           @click="openImportTable" | ||||
|           v-hasPermi="['tool:gen:import']" | ||||
|         >导入</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="success" | ||||
|           icon="el-icon-edit" | ||||
|           size="mini" | ||||
|           :disabled="single" | ||||
|           @click="handleEditTable" | ||||
|           v-hasPermi="['tool:gen:edit']" | ||||
|         >修改</el-button> | ||||
|       </el-col> | ||||
|       <el-col :span="1.5"> | ||||
|         <el-button | ||||
|           type="danger" | ||||
|           icon="el-icon-delete" | ||||
|           size="mini" | ||||
|           :disabled="multiple" | ||||
|           @click="handleDelete" | ||||
|           v-hasPermi="['tool:gen:remove']" | ||||
|         >删除</el-button> | ||||
|       </el-col> | ||||
|       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | ||||
|     </el-row> | ||||
|  | ||||
|     <el-table v-loading="loading" :data="tableList" @selection-change="handleSelectionChange"> | ||||
|       <el-table-column type="selection" width="55"></el-table-column> | ||||
|       <el-table-column label="序号" type="index" width="50" align="center"> | ||||
|         <template slot-scope="scope"> | ||||
|           <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
|       <el-table-column | ||||
|         label="表名称" | ||||
|         align="center" | ||||
|         prop="tableName" | ||||
|         :show-overflow-tooltip="true" | ||||
|         width="130" | ||||
|       /> | ||||
|       <el-table-column | ||||
|         label="表描述" | ||||
|         align="center" | ||||
|         prop="tableComment" | ||||
|         :show-overflow-tooltip="true" | ||||
|         width="130" | ||||
|       /> | ||||
|       <el-table-column | ||||
|         label="实体" | ||||
|         align="center" | ||||
|         prop="className" | ||||
|         :show-overflow-tooltip="true" | ||||
|         width="130" | ||||
|       /> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="160" /> | ||||
|       <el-table-column label="更新时间" align="center" prop="updateTime" width="160" /> | ||||
|       <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||
|         <template slot-scope="scope"> | ||||
|           <el-button | ||||
|             type="text" | ||||
|             size="small" | ||||
|             icon="el-icon-view" | ||||
|             @click="handlePreview(scope.row)" | ||||
|             v-hasPermi="['tool:gen:preview']" | ||||
|           >预览</el-button> | ||||
|           <el-button | ||||
|             type="text" | ||||
|             size="small" | ||||
|             icon="el-icon-edit" | ||||
|             @click="handleEditTable(scope.row)" | ||||
|             v-hasPermi="['tool:gen:edit']" | ||||
|           >编辑</el-button> | ||||
|           <el-button | ||||
|             type="text" | ||||
|             size="small" | ||||
|             icon="el-icon-delete" | ||||
|             @click="handleDelete(scope.row)" | ||||
|             v-hasPermi="['tool:gen:remove']" | ||||
|           >删除</el-button> | ||||
|           <el-button | ||||
|             type="text" | ||||
|             size="small" | ||||
|             icon="el-icon-refresh" | ||||
|             @click="handleSynchDb(scope.row)" | ||||
|             v-hasPermi="['tool:gen:edit']" | ||||
|           >同步</el-button> | ||||
|           <el-button | ||||
|             type="text" | ||||
|             size="small" | ||||
|             icon="el-icon-download" | ||||
|             @click="handleGenTable(scope.row)" | ||||
|             v-hasPermi="['tool:gen:code']" | ||||
|           >生成代码</el-button> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
|     </el-table> | ||||
|     <pagination | ||||
|       v-show="total>0" | ||||
|       :total="total" | ||||
|       :page.sync="queryParams.pageNum" | ||||
|       :limit.sync="queryParams.pageSize" | ||||
|       @pagination="getList" | ||||
|     /> | ||||
|     <!-- 预览界面 --> | ||||
|     <el-dialog :title="preview.title" :visible.sync="preview.open" width="80%" top="5vh" append-to-body> | ||||
|       <el-tabs v-model="preview.activeName"> | ||||
|         <el-tab-pane | ||||
|           v-for="(value, key) in preview.data" | ||||
|           :label="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" | ||||
|           :name="key.substring(key.lastIndexOf('/')+1,key.indexOf('.vm'))" | ||||
|           :key="key" | ||||
|         > | ||||
|           <pre>{{ value }}</pre> | ||||
|         </el-tab-pane> | ||||
|       </el-tabs> | ||||
|     </el-dialog> | ||||
|     <import-table ref="import" @ok="handleQuery" /> | ||||
|   </div> | ||||
| </template> | ||||
|  | ||||
| <script> | ||||
| import { listTable, previewTable, delTable, genCode, synchDb } from "@/api/tool/gen"; | ||||
| import importTable from "./importTable"; | ||||
| import { downLoadZip } from "@/utils/zipdownload"; | ||||
| export default { | ||||
|   name: "Gen", | ||||
|   components: { importTable }, | ||||
|   data() { | ||||
|     return { | ||||
|       // 遮罩层 | ||||
|       loading: true, | ||||
|       // 唯一标识符 | ||||
|       uniqueId: "", | ||||
|       // 选中数组 | ||||
|       ids: [], | ||||
|       // 选中表数组 | ||||
|       tableNames: [], | ||||
|       // 非单个禁用 | ||||
|       single: true, | ||||
|       // 非多个禁用 | ||||
|       multiple: true, | ||||
|       // 显示搜索条件 | ||||
|       showSearch: true, | ||||
|       // 总条数 | ||||
|       total: 0, | ||||
|       // 表数据 | ||||
|       tableList: [], | ||||
|       // 日期范围 | ||||
|       dateRange: "", | ||||
|       // 查询参数 | ||||
|       queryParams: { | ||||
|         pageNum: 1, | ||||
|         pageSize: 10, | ||||
|         tableName: undefined, | ||||
|         tableComment: undefined | ||||
|       }, | ||||
|       // 预览参数 | ||||
|       preview: { | ||||
|         open: false, | ||||
|         title: "代码预览", | ||||
|         data: {}, | ||||
|         activeName: "domain.java" | ||||
|       } | ||||
|     }; | ||||
|   }, | ||||
|   created() { | ||||
|     this.getList(); | ||||
|   }, | ||||
|   activated() { | ||||
|     const time = this.$route.query.t; | ||||
|     if (time != null && time != this.uniqueId) { | ||||
|       this.uniqueId = time; | ||||
|       this.resetQuery(); | ||||
|     } | ||||
|   }, | ||||
|   methods: { | ||||
|     /** 查询表集合 */ | ||||
|     getList() { | ||||
|       this.loading = true; | ||||
|       listTable(this.addDateRange(this.queryParams, this.dateRange)).then(response => { | ||||
|           this.tableList = response.rows; | ||||
|           this.total = response.total; | ||||
|           this.loading = false; | ||||
|         } | ||||
|       ); | ||||
|     }, | ||||
|     /** 搜索按钮操作 */ | ||||
|     handleQuery() { | ||||
|       this.queryParams.pageNum = 1; | ||||
|       this.getList(); | ||||
|     }, | ||||
|     /** 生成代码操作 */ | ||||
|     handleGenTable(row) { | ||||
|       const tableNames = row.tableName || this.tableNames; | ||||
|       if (tableNames == "") { | ||||
|         this.msgError("请选择要生成的数据"); | ||||
|         return; | ||||
|       } | ||||
|       if(row.genType === "1") { | ||||
|         genCode(row.tableName).then(response => { | ||||
|           this.msgSuccess("成功生成到自定义路径:" + row.genPath); | ||||
|         }); | ||||
|       } else { | ||||
|         downLoadZip("/tool/gen/batchGenCode?tables=" + tableNames, "ruoyi"); | ||||
|       } | ||||
|     }, | ||||
|     /** 同步数据库操作 */ | ||||
|     handleSynchDb(row) { | ||||
|       const tableName = row.tableName; | ||||
|       this.$confirm('确认要强制同步"' + tableName + '"表结构吗?', "警告", { | ||||
|         confirmButtonText: "确定", | ||||
|         cancelButtonText: "取消", | ||||
|         type: "warning" | ||||
|       }).then(function() { | ||||
|           return synchDb(tableName); | ||||
|       }).then(() => { | ||||
|           this.msgSuccess("同步成功"); | ||||
|       }).catch(function() {}); | ||||
|     }, | ||||
|     /** 打开导入表弹窗 */ | ||||
|     openImportTable() { | ||||
|       this.$refs.import.show(); | ||||
|     }, | ||||
|     /** 重置按钮操作 */ | ||||
|     resetQuery() { | ||||
|       this.dateRange = []; | ||||
|       this.resetForm("queryForm"); | ||||
|       this.handleQuery(); | ||||
|     }, | ||||
|     /** 预览按钮 */ | ||||
|     handlePreview(row) { | ||||
|       previewTable(row.tableId).then(response => { | ||||
|         this.preview.data = response.data; | ||||
|         this.preview.open = true; | ||||
|       }); | ||||
|     }, | ||||
|     // 多选框选中数据 | ||||
|     handleSelectionChange(selection) { | ||||
|       this.ids = selection.map(item => item.tableId); | ||||
|       this.tableNames = selection.map(item => item.tableName); | ||||
|       this.single = selection.length != 1; | ||||
|       this.multiple = !selection.length; | ||||
|     }, | ||||
|     /** 修改按钮操作 */ | ||||
|     handleEditTable(row) { | ||||
|       const tableId = row.tableId || this.ids[0]; | ||||
|       this.$router.push("/gen/edit/" + tableId); | ||||
|     }, | ||||
|     /** 删除按钮操作 */ | ||||
|     handleDelete(row) { | ||||
|       const tableIds = row.tableId || this.ids; | ||||
|       this.$confirm('是否确认删除表编号为"' + tableIds + '"的数据项?', "警告", { | ||||
|         confirmButtonText: "确定", | ||||
|         cancelButtonText: "取消", | ||||
|         type: "warning" | ||||
|       }).then(function() { | ||||
|           return delTable(tableIds); | ||||
|       }).then(() => { | ||||
|           this.getList(); | ||||
|           this.msgSuccess("删除成功"); | ||||
|       }).catch(function() {}); | ||||
|     } | ||||
|   } | ||||
| }; | ||||
| </script> | ||||
		Reference in New Issue
	
	Block a user