|
@@ -0,0 +1,783 @@
|
|
|
+<template>
|
|
|
+ <el-card>
|
|
|
+ <el-row type="flex" v-if="activeName=='basic' || activeName=='cloum'" justify="space-between" style="margin: 10px 0;">
|
|
|
+ <el-col :span="1.5" style="display: flex; align-items: center;">
|
|
|
+ <el-form label-width="100px" style="display: flex; align-items: center;">
|
|
|
+ <el-form-item style="text-align: center;margin-left:-100px;margin-top:0; margin-bottom: 0;">
|
|
|
+ <el-button type="primary" @click="submitForm()">保存</el-button>
|
|
|
+ <el-button @click="close()">返回</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-col>
|
|
|
+ <el-row type="flex" :gutter="10" justify="end">
|
|
|
+ <el-col :span="1.5" style="display: flex; align-items: center;">
|
|
|
+ <el-button type="warning" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['system:post:add']">新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5" style="display: flex; align-items: center;">
|
|
|
+ <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
|
|
+ v-hasPermi="['system:post:remove']">删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> -->
|
|
|
+ </el-row>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <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" @selection-change="handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <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="字段显示规则" align="center" prop="mask" min-width="11%" />
|
|
|
+ <el-table-column label="排序" min-width="8%" align="center" prop="sort" />
|
|
|
+ <el-table-column label="输入字段" min-width="10%">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-checkbox true-label="1" v-model="scope.row.isIn"></el-checkbox>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="显示字段" min-width="10%">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-checkbox true-label="1" v-model="scope.row.isOut"></el-checkbox>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="查询" min-width="8%">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-checkbox true-label="1" v-model="scope.row.isQuery"></el-checkbox>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="关联HR字段" min-width="10%" align="center" prop="hrParentId" />
|
|
|
+ <el-table-column label="缺省值" min-width="10%" align="center" prop="defaultValue" />
|
|
|
+ <el-table-column label="外键" min-width="10%" align="center" prop="foreignKey" />
|
|
|
+ <el-table-column label="必填" min-width="8%">
|
|
|
+ <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="imageUpload" />
|
|
|
+ <el-option label="文件上传" value="fileUpload" />
|
|
|
+ <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-dialog :title="title" :visible.sync="openZd" width="70vw" append-to-body>
|
|
|
+ <el-form ref="formZd" :model="formZd" :rules="rulesZd" label-width="120px">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="字段名:" prop="columnName">
|
|
|
+ <el-input v-model="formZd.columnName" placeholder="请输入字段名" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="字段描述:" prop="columnComment">
|
|
|
+ <el-input v-model="formZd.columnComment" placeholder="请输入字段描述" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="物理类型:" prop="columnType">
|
|
|
+ <el-input v-model="formZd.columnType" placeholder="请输入物理类型" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="字段显示规则:" prop="mask">
|
|
|
+ <el-input v-model="formZd.mask" placeholder="请输入字段显示规则" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="排序:" prop="sort">
|
|
|
+ <el-input v-model="formZd.sort" placeholder="请输入排序" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="查询条件" prop="isQuery">
|
|
|
+ <el-checkbox true-label="Y" false-label="N" v-model="formZd.isQuery"></el-checkbox>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="显示字段" prop="isOut">
|
|
|
+ <el-checkbox true-label="Y" false-label="N" v-model="formZd.isOut"></el-checkbox>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="输入字段" prop="isIn">
|
|
|
+ <el-checkbox true-label="Y" false-label="N" v-model="formZd.isIn"></el-checkbox>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="外键(FK):" prop="foreignKey">
|
|
|
+ <el-select v-model="formZd.foreignKey" placeholder="请选择外键(FK)" clearable size="small">
|
|
|
+ <el-option v-for="dict in columList" :key="dict.columnId" :label="dict.columnName" :value="dict.columnId" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="关联HR字段:" prop="hrParentId">
|
|
|
+ <el-select v-model="formZd.hrParentId" placeholder="请选择关联HR字段" clearable>
|
|
|
+ <el-option v-for="dict in columList" :key="dict.columnId" :label="dict.columnName" :value="dict.columnId" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="缺省值:" prop="defaultValue">
|
|
|
+ <el-input v-model="formZd.defaultValue" placeholder="请输入缺省值" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="行数:" prop="numRows">
|
|
|
+ <el-input-number v-model="formZd.numRows" placeholder="请输入行数" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="列数:" prop="numColumns">
|
|
|
+ <el-input-number v-model="formZd.numColumns" placeholder="请输入列数" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="字段翻译器:" prop="fieldTranslator">
|
|
|
+ <el-input v-model="formZd.fieldTranslator" placeholder="请输入字段翻译器" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="扩展属性:" prop="extendedAttributes">
|
|
|
+ <el-input v-model="formZd.extendedAttributes" placeholder="请输入扩展属性" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="查询方式:" prop="queryType">
|
|
|
+ <el-select v-model="formZd.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>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="显示类型:" prop="htmlType">
|
|
|
+ <el-select v-model="formZd.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="imageUpload" />
|
|
|
+ <el-option label="文件上传" value="fileUpload" />
|
|
|
+ <el-option label="富文本控件" value="editor" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="字典类型:" prop="dictType">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-select v-model="formZd.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-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="必填" prop="isRequired">
|
|
|
+ <el-checkbox true-label="Y" false-label="N" v-model="formZd.isRequired"></el-checkbox>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="submitFormZd">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </el-tab-pane>
|
|
|
+ <!-- <el-tab-pane label="生成信息" name="genInfo">
|
|
|
+ <gen-info-form ref="genInfo" :info="info" :tables="tables" :menus="menus"/>
|
|
|
+ </el-tab-pane> -->
|
|
|
+ <el-tab-pane label="关联表" name="genInfo">
|
|
|
+ <el-row style="margin-bottom: 20px;" type="flex" :gutter="10" justify="end">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button @click="handleAdd_gl" icon="el-icon-plus" size="mini" style="background-color: #FFE9ED;color: #E58481;border: 1px solid #E58481;">新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button icon="el-icon-delete" @click="handleDel_gl" size="mini" style="background-color: #FFD6B0;color: #EA551A;border: 1px solid #F4AD6B;"
|
|
|
+ :disabled="multiple1">删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-table ref="dragTable" @row-dblclick="dbSelected" v-loading="loading" :data="postList" row-key="columnId"
|
|
|
+ align="center" :max-height="tableHeight" @selection-change="handleSelectionChange1">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="id" align="center" prop="id" />
|
|
|
+ <el-table-column label="可用" align="center" prop="isDel">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-checkbox true-label="Y" disabled false-label="N" v-model="scope.row.isDel"></el-checkbox>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="序号" align="center" prop="sort" />
|
|
|
+ <el-table-column label="描述" align="center" prop="description" />
|
|
|
+ <el-table-column label="关联表" align="center" prop="tableName" />
|
|
|
+ <el-table-column label="字段(关联到主表PK)" align="center" prop="columnName" />
|
|
|
+ <el-table-column label="显示条件" align="center" prop="displayConditions" />
|
|
|
+ <el-table-column label="关联方式" align="center" prop="relationType">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{scope.row.relationType | relationTypeFn}}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="内嵌编辑" align="center" prop="embedEdit">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{scope.row.embedEdit | embedEditFn}}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="修改人" align="center" prop="updateBy" />
|
|
|
+ <el-table-column label="修改时间" align="center" prop="updateTime" />
|
|
|
+ </el-table>
|
|
|
+ <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
|
|
+ @pagination="tabList" />
|
|
|
+ </el-tab-pane>
|
|
|
+ <el-tab-pane label="数据库SQL" name="genSql">
|
|
|
+ <el-row>
|
|
|
+ <el-button @click="zxCreaBtn" style="background-color: #FFE9ED;color: #E58481;border: 1px solid #E58481;">执行创建语句</el-button>
|
|
|
+ <el-button @click="sxCreaBtn" style="background-color: #FFD6B0;color: #EA551A;border: 1px solid #F4AD6B;">刷新创建语句</el-button>
|
|
|
+ </el-row>
|
|
|
+ <el-form>
|
|
|
+ <el-form-item label="创建语句:" style="margin-top: 20px;">
|
|
|
+ <div class="resizeNone" v-html="tableSqlData.createSql" style="resize: none;width: 600px;" type="textarea"></div>
|
|
|
+
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="修改日志:">
|
|
|
+ <div class="resizeNone" v-html="tableSqlData.createLog" style="resize: none;width: 600px;" type="textarea"></div>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ <!-- 添加或修改岗位对话框 -->
|
|
|
+ <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
+ <el-form-item label="描述:" prop="postName">
|
|
|
+ <el-input v-model="form.description" placeholder="请输入描述" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="关联表:" prop="relationParentId">
|
|
|
+ <el-select v-model="form.relationParentId" placeholder="请选择关联表" @change="relationFn" v-loadmore="loadMore">
|
|
|
+ <el-option v-for="item in tableList.rows" :key="item.tableId" :label="item.tableComment" :value="item.tableId">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="字段:" prop="relationChildId">
|
|
|
+ <el-select v-model="form.relationChildId" placeholder="请选择字段" v-loadmore="loadMore">
|
|
|
+ <el-option v-for="item in genList" :key="item.columnId" :label="item.columnName" :value="item.columnId">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="显示条件:" prop="displayConditions">
|
|
|
+ <el-input v-model="form.displayConditions" controls-position="right" placeholder="请输入显示条件" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="关联方式:" prop="relationType">
|
|
|
+ <el-select v-model="form.relationType" placeholder="请选择关联方式" clearable size="small">
|
|
|
+ <el-option v-for="dict in relationType" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="内嵌编辑:" prop="embedEdit">
|
|
|
+ <el-select v-model="form.embedEdit" placeholder="岗位状态" clearable size="small">
|
|
|
+ <el-option v-for="dict in embedEdit" :key="dict.dictValue" :label="dict.dictLabel" :value="dict.dictValue" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="序号:" prop="sort">
|
|
|
+ <el-input-number v-model="form.sort" controls-position="right" :min="0" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否可用:" prop="isDel">
|
|
|
+ <el-checkbox true-label="Y" false-label="N" v-model="form.isDel"></el-checkbox>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="addGlfn">确 定</el-button>
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </el-card>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+ import {
|
|
|
+ getGenTable,
|
|
|
+ updateGenTable,
|
|
|
+ delPost,
|
|
|
+ tabList,
|
|
|
+ listTable,
|
|
|
+ addGenTable,
|
|
|
+ setGenTable,
|
|
|
+ delGenTable,
|
|
|
+ listAllColumnsByTableId,
|
|
|
+ tableSql,
|
|
|
+ zxImplement,
|
|
|
+ getReload,
|
|
|
+ addGenTableColumn,
|
|
|
+ qurGenTable
|
|
|
+ } 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'
|
|
|
+
|
|
|
+ let _this = ''
|
|
|
+ export default {
|
|
|
+ name: "GenEdit",
|
|
|
+ components: {
|
|
|
+ basicInfoForm,
|
|
|
+ genInfoForm
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ _this = this
|
|
|
+ return {
|
|
|
+ // 字段信息
|
|
|
+ tableSqlData: [],
|
|
|
+ columList: [],
|
|
|
+ foreignKey: [],
|
|
|
+ openZd: true,
|
|
|
+ formZd: {},
|
|
|
+ rulesZd: {
|
|
|
+ columnName: [{
|
|
|
+ required: true,
|
|
|
+ message: "请输入字段名",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ columnComment: [{
|
|
|
+ required: true,
|
|
|
+ message: "请输入字段描述",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ columnType: [{
|
|
|
+ required: true,
|
|
|
+ message: "请输入物理类型",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ mask: [{
|
|
|
+ required: true,
|
|
|
+ message: "请输入字段显示规则",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ sort: [{
|
|
|
+ required: true,
|
|
|
+ message: "请输入序号",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ },
|
|
|
+ loadingZd: '',
|
|
|
+ // 关联表
|
|
|
+ title: "",
|
|
|
+ loading: false,
|
|
|
+ open: false,
|
|
|
+ form: {},
|
|
|
+ rules: {
|
|
|
+ relationParentId: [{
|
|
|
+ required: true,
|
|
|
+ message: "请选择关联表",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ relationChildId: [{
|
|
|
+ required: true,
|
|
|
+ message: "请选择字段",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ relationType: [{
|
|
|
+ required: true,
|
|
|
+ message: "请选择关联条件",
|
|
|
+ trigger: "blur"
|
|
|
+ }],
|
|
|
+ },
|
|
|
+ postList: [],
|
|
|
+ total: 1,
|
|
|
+ tableList: {},
|
|
|
+ // 关联方式
|
|
|
+
|
|
|
+ // 内嵌编辑
|
|
|
+ genList: [],
|
|
|
+ glbParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ },
|
|
|
+ // 关联表查询参数
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ },
|
|
|
+ // 选中选项卡的 name
|
|
|
+ activeName: "basic",
|
|
|
+ // 表格的高度
|
|
|
+ tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
|
|
+ // 表信息
|
|
|
+ tables: [],
|
|
|
+ // 表列信息
|
|
|
+ cloumns: [],
|
|
|
+ // 字典信息
|
|
|
+ dictOptions: [],
|
|
|
+ // 菜单信息
|
|
|
+ menus: [],
|
|
|
+ // 表详细信息
|
|
|
+ info: {},
|
|
|
+ // 选中数组
|
|
|
+ ids: [],
|
|
|
+ ids1: [],
|
|
|
+ // 非单个禁用
|
|
|
+ single: true,
|
|
|
+ single1: true,
|
|
|
+ // 非多个禁用
|
|
|
+ multiple: true,
|
|
|
+ multiple1: true,
|
|
|
+ // 关联方式
|
|
|
+ relationType: [],
|
|
|
+ // 内嵌编辑
|
|
|
+ embedEdit: [],
|
|
|
+ };
|
|
|
+ },
|
|
|
+ filters: {
|
|
|
+ relationTypeFn(data) {
|
|
|
+ let is = ''
|
|
|
+ for (let item of _this.relationType) {
|
|
|
+ if (item.dictValue == data) {
|
|
|
+ is = item.dictLabel
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return is
|
|
|
+ },
|
|
|
+ embedEditFn(data) {
|
|
|
+ let is = ''
|
|
|
+ for (let item of _this.embedEdit) {
|
|
|
+ if (item.dictValue == data) {
|
|
|
+ is = item.dictLabel
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return is
|
|
|
+ },
|
|
|
+ },
|
|
|
+ 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;
|
|
|
+ this.tables = res.data.tables;
|
|
|
+ });
|
|
|
+ //查询数据库sql
|
|
|
+ tableSql(tableId).then(res => {
|
|
|
+ if(res.data){
|
|
|
+ this.tableSqlData = res.data
|
|
|
+ }
|
|
|
+ })
|
|
|
+ /** 查询字典下拉列表 */
|
|
|
+ getDictOptionselect().then(response => {
|
|
|
+ this.dictOptions = response.data;
|
|
|
+ });
|
|
|
+ // 关联字段
|
|
|
+ listAllColumnsByTableId({
|
|
|
+ tableId
|
|
|
+ }).then(response => {
|
|
|
+ this.columList = response;
|
|
|
+ });
|
|
|
+ // 关联表数据
|
|
|
+ listTable(this.glbParams).then(response => {
|
|
|
+ this.tableList = response;
|
|
|
+ });
|
|
|
+ /** 查询菜单下拉列表 */
|
|
|
+ // getMenuTreeselect().then(response => {
|
|
|
+ // this.menus = this.handleTree(response.data, "menuId");
|
|
|
+ // });
|
|
|
+ // 关联方式
|
|
|
+ this.getDicts("relation_type").then(response => {
|
|
|
+ this.relationType = response.data;
|
|
|
+ });
|
|
|
+ // 内嵌编辑
|
|
|
+ this.getDicts("embed_edit").then(response => {
|
|
|
+ this.embedEdit = response.data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.tabList()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ submitFormZd() {
|
|
|
+ this.$refs["formZd"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ addGenTableColumn(this.formZd).then(response => {
|
|
|
+ this.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ this.tabList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ sxCreaBtn() {
|
|
|
+ getReload({
|
|
|
+ tableId: this.$route.params && this.$route.params.tableId,
|
|
|
+ createSql: this.tableSqlData.createSql,
|
|
|
+ createLog: this.tableSqlData.createLog,
|
|
|
+ id: this.tableSqlData.id
|
|
|
+ }).then(res => {
|
|
|
+ this.msgSuccess('刷新成功')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ zxCreaBtn() {
|
|
|
+ zxImplement({
|
|
|
+ tableId: this.$route.params && this.$route.params.tableId,
|
|
|
+ createSql: this.tableSqlData.createSql,
|
|
|
+ createLog: this.tableSqlData.createLog,
|
|
|
+ id: this.tableSqlData.id
|
|
|
+ }).then(res => {
|
|
|
+ this.msgSuccess('执行成功')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ dbSelected(row) {
|
|
|
+ console.log(row, 133)
|
|
|
+ this.reset();
|
|
|
+ const id = row.id
|
|
|
+ qurGenTable(id).then(response => {
|
|
|
+ let data = response.data
|
|
|
+ data.relationType = data.relationType + ""
|
|
|
+ data.embedEdit = data.embedEdit + ""
|
|
|
+ getGenTable(data.relationParentId).then(res => {
|
|
|
+ this.genList = res.data.rows;
|
|
|
+ this.form = response.data;
|
|
|
+ this.open = true;
|
|
|
+ this.title = "修改关联表";
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ addGlfn() {
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.form.id != undefined) {
|
|
|
+ setGenTable(this.form).then(response => {
|
|
|
+ this.msgSuccess("修改成功");
|
|
|
+ this.open = false;
|
|
|
+ this.tabList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ addGenTable(this.form).then(response => {
|
|
|
+ this.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ this.tabList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ relationFn(data) {
|
|
|
+ getGenTable(data).then(res => {
|
|
|
+ this.genList = res.data.rows;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ loadMore() {
|
|
|
+ const _this = this
|
|
|
+ let num = _this.tableList.total % 10 == 0 ? _this.tableList.total / 10 : ((_this.tableList.total - _this.tableList
|
|
|
+ .total % 10) / 10 + 1)
|
|
|
+ console.log(num, 1)
|
|
|
+ if (this.glbParams.pageNum < num) {
|
|
|
+ this.glbParams.pageNum++
|
|
|
+ // 关联表数据
|
|
|
+ listTable(this.glbParams).then(response => {
|
|
|
+ let data = response
|
|
|
+ data.rows = _this.tableList.rows.concat(data.rows)
|
|
|
+ _this.tableList = data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 取消按钮
|
|
|
+ cancel() {
|
|
|
+ this.open = false;
|
|
|
+ this.reset();
|
|
|
+ this.openZd = false;
|
|
|
+ this.resetZd();
|
|
|
+ },
|
|
|
+ // 关联表数据
|
|
|
+ tabList() {
|
|
|
+ this.loading = true;
|
|
|
+ tabList(this.queryParams).then(response => {
|
|
|
+ this.postList = response.rows;
|
|
|
+ this.total = response.total;
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ /** 新增按钮操作 */
|
|
|
+ handleAdd_gl() {
|
|
|
+ this.reset();
|
|
|
+ this.open = true;
|
|
|
+ this.title = "新增关联表";
|
|
|
+ },
|
|
|
+ handleDel_gl(row) {
|
|
|
+ const ids = row.id || this.ids1;
|
|
|
+ console.log(ids, 1223)
|
|
|
+ this.$confirm('是否确认删除id为"' + ids + '"的数据项?', "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(function() {
|
|
|
+ return delGenTable(ids);
|
|
|
+ }).then(() => {
|
|
|
+ this.tabList();
|
|
|
+ this.msgSuccess("删除成功");
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 表单重置
|
|
|
+ reset() {
|
|
|
+ this.form = {
|
|
|
+
|
|
|
+ };
|
|
|
+ this.resetForm("form");
|
|
|
+ },
|
|
|
+ resetZd() {
|
|
|
+ this.formZd = {
|
|
|
+
|
|
|
+ };
|
|
|
+ this.resetForm("formZd");
|
|
|
+ },
|
|
|
+ /** 提交按钮 */
|
|
|
+ submitForm() {
|
|
|
+ const basicForm = this.$refs.basicInfo.$refs.basicInfoForm;
|
|
|
+ // const genForm = this.$refs.genInfo.$refs.genInfoForm;
|
|
|
+ // console.log(basicForm)
|
|
|
+ Promise.all([basicForm].map(this.getFormPromise)).then(res => {
|
|
|
+ const validateResult = res.every(item => !!item);
|
|
|
+ if (validateResult) {
|
|
|
+ const genTable = Object.assign({}, basicForm.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()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 多选框选中数据
|
|
|
+ handleSelectionChange(selection) {
|
|
|
+ this.ids = selection.map(item => item.columnId)
|
|
|
+ this.single = selection.length != 1
|
|
|
+ this.multiple = !selection.length
|
|
|
+ },
|
|
|
+ // 多选框选中数据
|
|
|
+ handleSelectionChange1(selection) {
|
|
|
+ this.ids1 = selection.map(item => item.id)
|
|
|
+ this.single1 = selection.length != 1
|
|
|
+ this.multiple1 = !selection.length
|
|
|
+ },
|
|
|
+ /** 删除按钮操作 */
|
|
|
+ handleDelete(row) {
|
|
|
+ const ids = row.id || this.ids;
|
|
|
+ this.$confirm('是否确认删除岗位编号为"' + ids + '"的数据项?', "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(function() {
|
|
|
+ return delPost(ids);
|
|
|
+ }).then(() => {
|
|
|
+ this.getlist();
|
|
|
+ this.msgSuccess("删除成功");
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handleAdd() {
|
|
|
+ this.resetZd();
|
|
|
+ this.openZd = true;
|
|
|
+ this.title = "新增字段信息";
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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>
|
|
|
+<style lang="scss">
|
|
|
+ .pagination-container {
|
|
|
+ height: 35px;
|
|
|
+ }
|
|
|
+ .resizeNone{
|
|
|
+ width: 70vw;
|
|
|
+ margin-left: 80px;
|
|
|
+ padding: 8px 10px;
|
|
|
+ border: 1px solid #CDCDCD;
|
|
|
+ border-radius: 3px;
|
|
|
+ }
|
|
|
+</style>
|