|
@@ -77,7 +77,7 @@
|
|
|
>
|
|
|
<template slot-scope="scope">
|
|
|
<el-popover trigger="hover" placement="top">
|
|
|
- <p v-for="(item,index) in scope.row.contentList"> {{ item.tableName}}</p>
|
|
|
+ <p v-for="(item,index) in scope.row.contentList"> {{ item.tableName }}</p>
|
|
|
|
|
|
<div slot="reference" class="name-wrapper">
|
|
|
<el-tag size="medium">{{ scope.row.tableKey }}</el-tag>
|
|
@@ -139,13 +139,28 @@
|
|
|
class="mb10"
|
|
|
>新增</el-button
|
|
|
>
|
|
|
-
|
|
|
- <div class="nameipt">
|
|
|
- <span>表格组名:</span><el-input v-model="groupname" placeholder="请输入表格组名"></el-input>
|
|
|
- <span class="desc">描述:</span><el-input v-model="groupdescribe" placeholder="请输入相关描述"></el-input>
|
|
|
- </div>
|
|
|
-
|
|
|
- <el-table
|
|
|
+ <el-form :model="groupForm" :rules="grouprules" ref="groupForm" label-width="100px" class="demo-ruleForm">
|
|
|
+ <el-form-item label="表格组名" prop="groupname">
|
|
|
+ <el-input v-model="groupForm.groupname" placeholder="请输入表格组名"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="表格描述" prop="groupdescribe">
|
|
|
+ <el-input v-model="groupForm.groupdescribe" placeholder="请输入表格描述"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="菜单路由" prop="routePath">
|
|
|
+ <div class="treeselect">
|
|
|
+ <treeselect
|
|
|
+ :append-to-body="true"
|
|
|
+ v-model="groupForm.routePath"
|
|
|
+ :options="menus"
|
|
|
+ :normalizer="normalizer"
|
|
|
+ :show-count="true"
|
|
|
+ placeholder="请选择父级路由"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-table
|
|
|
:data="tableDataList"
|
|
|
border
|
|
|
stripe
|
|
@@ -196,32 +211,34 @@
|
|
|
</el-dropdown>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- </el-table>
|
|
|
- </div>
|
|
|
- <template #footer>
|
|
|
- <span>
|
|
|
+ </el-table>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item class="btn">
|
|
|
<el-button @click="isShowTable = false">取消</el-button>
|
|
|
- <el-button type="primary" @click="addTableGroup">确认</el-button>
|
|
|
- </span>
|
|
|
- </template>
|
|
|
+ <el-button type="primary" @click="addTableGroup('groupForm')">确认</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 编辑某一条表格数据弹窗 -->
|
|
|
- <el-dialog :title="relateTitle ? '添加关联表格' :'修改关联表格' " :visible.sync="isShowForm" width="800px">
|
|
|
+ <el-dialog :title="relateTitle ? '添加关联表格' :'修改关联表格' " :visible.sync="isShowForm" >
|
|
|
<div class="formWrap">
|
|
|
<el-form
|
|
|
+ :rules="tableItemRules"
|
|
|
ref="tableItemForm"
|
|
|
- style="max-width: 750px; width: 700px"
|
|
|
+ style="max-width: 750px; width: 1000px"
|
|
|
:model="tableItemForm"
|
|
|
label-width="100px"
|
|
|
>
|
|
|
- <el-form-item label="表格标题:">
|
|
|
+ <el-form-item label="表格标题:" prop="title">
|
|
|
<el-input
|
|
|
v-model="tableItemForm.title"
|
|
|
style="max-width: 221px"
|
|
|
></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="表格名称:">
|
|
|
+ <el-form-item label="表格名称:" prop="tableName">
|
|
|
<el-select
|
|
|
v-model="tableItemForm.tableName"
|
|
|
@change="getList()"
|
|
@@ -240,7 +257,7 @@
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="关联字段:">
|
|
|
+ <el-form-item label="关联字段:" prop="selectFields">
|
|
|
<el-select
|
|
|
v-model="tableItemForm.selectFields"
|
|
|
placeholder="请选择关联字段"
|
|
@@ -258,13 +275,14 @@
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="展示字段:">
|
|
|
+ <el-form-item label="展示字段:" prop="FieldList">
|
|
|
<el-table
|
|
|
:data="tableFieldList"
|
|
|
border
|
|
|
ref="dragTable"
|
|
|
row-key="id"
|
|
|
max-height="500px"
|
|
|
+ class="tablefiled"
|
|
|
>
|
|
|
|
|
|
<el-table-column
|
|
@@ -274,8 +292,7 @@
|
|
|
class-name="allowDrag"
|
|
|
>
|
|
|
</el-table-column>
|
|
|
- <el-table-column prop="fieldName" label="数据字段">
|
|
|
- </el-table-column>
|
|
|
+ <el-table-column prop="fieldName" label="数据字段"></el-table-column>
|
|
|
<el-table-column prop="fieldDescription" label="字段描述">
|
|
|
<template slot-scope="scope">
|
|
|
<input
|
|
@@ -292,42 +309,171 @@
|
|
|
/>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column width="95px" prop="relationTable" label="关联表">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.relationTable"
|
|
|
+ :disabled="
|
|
|
+ !scope.row.relationTableList ||
|
|
|
+ !scope.row.relationTableList.length
|
|
|
+ "
|
|
|
+ placeholder="请选择关联的表"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ @change="ralationTableChange(scope.row)"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in scope.row.relationTableList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.tableComment"
|
|
|
+ :value="item.tableName"
|
|
|
+ >
|
|
|
+ <span style="float: left">{{ item.tableComment }}</span>
|
|
|
+ <span
|
|
|
+ style="float: right; color: #8492a6; font-size: 13px"
|
|
|
+ >{{ item.tableName }}</span
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column width="95px" prop="relationFieldName" label="关联条件字段">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.relationFieldName"
|
|
|
+ @change="relationFieldChange(scope.row)"
|
|
|
+ :disabled="!scope.row.disableRelaFieldName"
|
|
|
+ placeholder="关联字段"
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in scope.row.relaFieldNameList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.fieldDescription"
|
|
|
+ :value="item.fieldName"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column width="95px" prop="relationType" label="关联方式">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-select
|
|
|
+ v-model="scope.row.relationType"
|
|
|
+ placeholder="请选择关联方式"
|
|
|
+ :disabled="!scope.row.disableRelaType"
|
|
|
+ @change="relationTypeChangeHandler(scope.row)"
|
|
|
+ filterable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in relaTypeList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="isShow" label="是否显示">
|
|
|
<template slot-scope="scope">
|
|
|
<el-switch v-model="scope.row.isShow"> </el-switch>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column prop="isSearch" label="是否包含查询">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-switch v-model="scope.row.isSearch"> </el-switch>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
</el-table>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item class="btn">
|
|
|
+ <el-button @click="isShowForm = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="confirmAddHandler('tableItemForm')">确认</el-button>
|
|
|
+ </el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
- <template #footer>
|
|
|
- <span>
|
|
|
- <el-button @click="isShowForm = false">取消</el-button>
|
|
|
- <el-button type="primary" @click="confirmAddHandler">确认</el-button>
|
|
|
- </span>
|
|
|
- </template>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
import { listTable, removeTableList } from "@/api/dragform/tableList";
|
|
|
-import {
|
|
|
- getFormName,
|
|
|
- getListName,
|
|
|
- dragTablePreview,
|
|
|
-} from "@/api/dragform/form.js";
|
|
|
+import { getFormName, getListName, dragTablePreview, } from "@/api/dragform/form.js";
|
|
|
import { delMenu } from "@/api/system/menu";
|
|
|
-import { addGroup } from '@/api/relateTable/index.js'
|
|
|
+import { getMenuList, addMenu } from "@/api/menu.js";
|
|
|
+import { addGroup, listGroup } from '@/api/relateTable/index.js'
|
|
|
import { addDragTable } from "@/api/tablelist/commonTable.js";
|
|
|
import { mapGetters, mapState } from "vuex";
|
|
|
import DictData from "@/components/DictData";
|
|
|
-import { FastBackwardFill } from "@/components/updateModule/k-form-design/lib/k-form-design.common";
|
|
|
+import { FastBackwardFill, async } from "@/components/updateModule/k-form-design/lib/k-form-design.common";
|
|
|
+import { v4 as uuidv4 } from "uuid";
|
|
|
+import Treeselect from "@riophae/vue-treeselect";
|
|
|
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
|
+import json from "highlight.js/lib/languages/json";
|
|
|
|
|
|
export default {
|
|
|
name: "relateTable",
|
|
|
+ components: { Treeselect },
|
|
|
+
|
|
|
data() {
|
|
|
return {
|
|
|
+ addDragData:[],
|
|
|
+ // 创建data需要的参数
|
|
|
+ // data: {
|
|
|
+ // tId:'',
|
|
|
+ // dtName: '表格标题',
|
|
|
+ // tableKey: 'uuid随机生成',
|
|
|
+ // dtTableName: '表格名称',
|
|
|
+ // primaryKey: '关联字段',
|
|
|
+ // // 排序依赖字段可以为空
|
|
|
+ // orderByColumn: '',
|
|
|
+ // sortOrder: false,
|
|
|
+ // sqlKey:'uuid随机生成',
|
|
|
+ // // getcol递归获取
|
|
|
+ // dtColumnName: 'columns',
|
|
|
+ // timeFormat: 'yyyy-MM-dd',
|
|
|
+ // // 是否包含查询['表格名称.包含查询得数据字段']
|
|
|
+ // searchFieldList: [],
|
|
|
+ // tableSql: this.getSQLStr(),
|
|
|
+ // echoData: JSON.stringify()
|
|
|
+ // },
|
|
|
+ groupList:[],
|
|
|
+ menus: [], //路由列表数据
|
|
|
+ // 添加关联表格校验规则
|
|
|
+ tableItemRules:{
|
|
|
+ title:[{ required: true, message: '请输入表格标题', trigger: 'blur' }],
|
|
|
+ tableName:[{ required: true, message: '请选择表格名称', trigger: 'change' }],
|
|
|
+ selectFields: [{ required: true, message: '请选择关联字段', trigger: 'change' }],
|
|
|
+ },
|
|
|
+ groupForm: {
|
|
|
+ groupname: '',
|
|
|
+ groupdescribe:'',
|
|
|
+ routePath: undefined,
|
|
|
+ },
|
|
|
+ grouprules:{
|
|
|
+ groupname:[{ required: true, message: '请输入表格组名', trigger: 'blur' }],
|
|
|
+ groupdescribe:[{ required: true, message: '请输入表格描述', trigger: 'blur' }],
|
|
|
+ routePath: [
|
|
|
+ { required: true, message: "请选择路由", trigger: "change" },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ menuOrderNum: 0,
|
|
|
+ // 关联方式
|
|
|
+ relaTypeList: [
|
|
|
+ {
|
|
|
+ label: "等值连接",
|
|
|
+ value: "INNER JOIN",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "左连接",
|
|
|
+ value: "LEFT JOIN",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "右连接",
|
|
|
+ value: "RIGHT JOIN",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ searchFieldList: [],
|
|
|
// 修改row
|
|
|
updataGroupRow:{},
|
|
|
// 遮罩层
|
|
@@ -387,19 +533,21 @@ export default {
|
|
|
relateFieldList: [], //子集关联字段数据
|
|
|
groupTitle: true,
|
|
|
tableItemForm: {
|
|
|
+ rowId: "",
|
|
|
title: "",
|
|
|
tableName: "",
|
|
|
selectFields: "",
|
|
|
},
|
|
|
- groupname: '',
|
|
|
- groupdescribe: '',
|
|
|
tableGroupList: [],
|
|
|
// 成员表格提示
|
|
|
tableKeyContent: '',
|
|
|
+
|
|
|
};
|
|
|
},
|
|
|
- created() {
|
|
|
+ created() {},
|
|
|
// this.getList();
|
|
|
+ async mounted() {
|
|
|
+ await this.getMenuList();
|
|
|
},
|
|
|
computed: {
|
|
|
selectRelate(){
|
|
@@ -431,8 +579,95 @@ export default {
|
|
|
this.relationTableList = [];
|
|
|
}
|
|
|
},
|
|
|
+ 'groupForm.routePath'(nval, oval) {
|
|
|
+ let targetMenu = this.getTargetMenu(this.menus);
|
|
|
+ this.menuOrderNum = targetMenu.children ? targetMenu.children.length : 0;
|
|
|
+ },
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 获取路由表单数据
|
|
|
+ async getMenuList() {
|
|
|
+ let res = await listGroup();
|
|
|
+ console.log('res', res);
|
|
|
+ this.menus = this.handleTree(res.data, "menuId");
|
|
|
+ },
|
|
|
+ // 递归拼接查询语句
|
|
|
+ getSQLString(tableFieldList, fieldArr, tableArr, sqlType = "mysql") {
|
|
|
+ let prefix = "{DBNAME}.";
|
|
|
+ let asOrSpace = sqlType == "oracle" ? " " : " AS ";
|
|
|
+ for (let i = 0; i < tableFieldList.length; i++) {
|
|
|
+ let temp = tableFieldList[i];
|
|
|
+ if (temp.isShow) {
|
|
|
+ let tempArr = prefix + temp.tableName + "." + temp.fieldName;
|
|
|
+ if (temp.isChildren) {
|
|
|
+ tempArr += asOrSpace + temp.tableName + "_" + temp.fieldName;
|
|
|
+ }
|
|
|
+ fieldArr.push(tempArr);
|
|
|
+ }
|
|
|
+ if (temp.relationTable && temp.relationFieldName && temp.relationType) {
|
|
|
+ let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
|
|
|
+ tableArr.push(
|
|
|
+ temp.relationType +
|
|
|
+ " " +
|
|
|
+ isNeedUsername +
|
|
|
+ prefix +
|
|
|
+ temp.relationTable +
|
|
|
+ asOrSpace +
|
|
|
+ temp.relationTable +
|
|
|
+ " ON " +
|
|
|
+ prefix +
|
|
|
+ temp.relationTable +
|
|
|
+ "." +
|
|
|
+ temp.relationFieldName +
|
|
|
+ " = " +
|
|
|
+ prefix +
|
|
|
+ temp.tableName +
|
|
|
+ "." +
|
|
|
+ temp.fieldName
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 如果主键不包含显示,则添加至sql语句中
|
|
|
+ let isNotInclude = this.tableFieldList.find(
|
|
|
+ (val) => !val.isShow && val.fieldName == this.tableItemForm.selectFields
|
|
|
+ );
|
|
|
+ if (isNotInclude) {
|
|
|
+ fieldArr.push(
|
|
|
+ prefix + isNotInclude.tableName + "." + isNotInclude.fieldName
|
|
|
+ );
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 拼接查询sql语句
|
|
|
+ getSQLStr() {
|
|
|
+ let prefix = "{DBNAME}.";
|
|
|
+ let sqlType = this.databaseType; //数据库类型
|
|
|
+ // let sqlType = "oracle";
|
|
|
+ let sql = "";
|
|
|
+ // mysql
|
|
|
+ sql += "SELECT ";
|
|
|
+ let fieldNameArr = [],
|
|
|
+ relaTypeArr = [];
|
|
|
+ this.getSQLString(
|
|
|
+ this.tableFieldList,
|
|
|
+ fieldNameArr,
|
|
|
+ relaTypeArr,
|
|
|
+ sqlType
|
|
|
+ );
|
|
|
+ let isNeedUsername = sqlType == "oracle" ? this.username + "." : "";
|
|
|
+ let asOrSpace = sqlType == "oracle" ? " " : " AS ";
|
|
|
+ sql +=
|
|
|
+ fieldNameArr.join(",") +
|
|
|
+ " FROM " +
|
|
|
+ isNeedUsername +
|
|
|
+ prefix +
|
|
|
+ this.tableItemForm.tableName +
|
|
|
+ asOrSpace +
|
|
|
+ this.tableItemForm.tableName;
|
|
|
+ if (relaTypeArr.length) {
|
|
|
+ sql += " " + relaTypeArr.join(" ");
|
|
|
+ }
|
|
|
+ return sql;
|
|
|
+ },
|
|
|
/** 查询列表 */
|
|
|
getList(queryParams) {
|
|
|
if (!this.tableItemForm.tableName) return;
|
|
@@ -467,6 +702,112 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+ },
|
|
|
+ // 关联表变化回调
|
|
|
+ async ralationTableChange(row) {
|
|
|
+ this.tableFieldList = this.tableFieldList.filter((item) => {
|
|
|
+ return !row.relationFieldList.some((val) => {
|
|
|
+ return val.id == item.id;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ row.relationFieldName = "";
|
|
|
+ row.relationType = "";
|
|
|
+ row.disableRelaFieldName = false;
|
|
|
+ row.disableRelaType = false;
|
|
|
+ row.relationFieldList = [];
|
|
|
+ if (!row.relationTable) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 获取关联表的字段
|
|
|
+ let data = {
|
|
|
+ databaseName: this.databaseName,
|
|
|
+ databaseType: this.databaseType,
|
|
|
+ tableName: row.relationTable,
|
|
|
+ };
|
|
|
+ let res = await getListName(data);
|
|
|
+ // 关联字段下拉列表数据
|
|
|
+ row.relaFieldNameList = res.map((item) => {
|
|
|
+ return {
|
|
|
+ fieldName: item.fieldName,
|
|
|
+ fieldDescription: item.fieldDescription,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ let relationTableList = row.relationTableList.filter(
|
|
|
+ (item) => row.relationTable != item.tableName
|
|
|
+ );
|
|
|
+ row.relationFieldList = row.relaFieldNameList.map((item, index) => {
|
|
|
+ return {
|
|
|
+ id: row.relationTable + "_" + item.fieldName,
|
|
|
+ fieldName: item.fieldName,
|
|
|
+ fieldDescription: item.fieldDescription,
|
|
|
+ relationTable: "",
|
|
|
+ relationFieldName: "",
|
|
|
+ relaFieldNameList: [],
|
|
|
+ disableRelaFieldName: false,
|
|
|
+ relationType: "",
|
|
|
+ relationShowField: [],
|
|
|
+ relationShowFiledList: [],
|
|
|
+ disableRelaType: false,
|
|
|
+ isShow: true,
|
|
|
+ isSearch: false,
|
|
|
+ isExport: true,
|
|
|
+ relationTableList,
|
|
|
+ tableName: row.relationTable,
|
|
|
+ relationFieldList: [],
|
|
|
+ isChildren: true,
|
|
|
+ };
|
|
|
+ });
|
|
|
+ row.disableRelaFieldName = true;
|
|
|
+ },
|
|
|
+ // 关联类型变化回调
|
|
|
+ relationTypeChangeHandler(row) {
|
|
|
+ let tempRelationFieldList = row.relationFieldList.filter((item) => {
|
|
|
+ return !this.tableFieldList.find((val) => val.id === item.id);
|
|
|
+ });
|
|
|
+ this.tableFieldList = [...this.tableFieldList, ...tempRelationFieldList];
|
|
|
+ },
|
|
|
+ // 关联字段回调
|
|
|
+ relationFieldChange(row) {
|
|
|
+ if (!row.relationFieldName) {
|
|
|
+ row.relationType = "";
|
|
|
+ row.disableRelaType = false;
|
|
|
+ row.relaFieldNameList = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ row.disableRelaType = true;
|
|
|
+ },
|
|
|
+ // 递归获取列表信息
|
|
|
+ getCol(
|
|
|
+ tableFieldList,
|
|
|
+ columns,
|
|
|
+ searchFieldList = [],
|
|
|
+ tableExportField = {}
|
|
|
+ ) {
|
|
|
+ if (!tableFieldList.length) return;
|
|
|
+ for (let i = 0; i < tableFieldList.length; i++) {
|
|
|
+ let temp = tableFieldList[i];
|
|
|
+ let tempFieldName = "",
|
|
|
+ exportFieldName = "";
|
|
|
+ if (temp.isChildren) {
|
|
|
+ tempFieldName = temp.tableName + "_" + temp.fieldName;
|
|
|
+ exportFieldName = temp.tableName + "@" + temp.fieldName;
|
|
|
+ } else {
|
|
|
+ tempFieldName = temp.fieldName;
|
|
|
+ exportFieldName = temp.fieldName;
|
|
|
+ }
|
|
|
+ if (temp.isShow) {
|
|
|
+ let tempObj = {};
|
|
|
+ tempObj[tempFieldName] = temp.fieldDescription;
|
|
|
+ columns.push(tempObj);
|
|
|
+ }
|
|
|
+ if (temp.isSearch) {
|
|
|
+ searchFieldList.push(temp.tableName + "." + temp.fieldName);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (temp.isExport) {
|
|
|
+ tableExportField[exportFieldName] = temp.fieldDescription;
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
// 获取所有表格
|
|
|
async getAllTable() {
|
|
@@ -486,59 +827,233 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
// 确认添加一个表格
|
|
|
- confirmAddHandler() {
|
|
|
- console.log(this.tableItemForm);
|
|
|
- if(this.tableItemForm.title == ''){
|
|
|
- this.$message.error("字段不能为空");
|
|
|
- return
|
|
|
- }
|
|
|
- if(this.relateTitle){
|
|
|
- this.tableItemForm.rowId = Date.now();
|
|
|
- this.tableDataList.push(this.tableItemForm);
|
|
|
- } else {
|
|
|
- this.tableDataList.forEach((item, index) => {
|
|
|
- if(item.rowId == this.tableItemForm){
|
|
|
- this.tableDataList[index] = this.tableItemForm
|
|
|
+ confirmAddHandler(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let columns = [],
|
|
|
+ searchFieldList = []
|
|
|
+ this.getCol(
|
|
|
+ this.tableFieldList,
|
|
|
+ columns,
|
|
|
+ searchFieldList,
|
|
|
+ );
|
|
|
+ // 判断是否有包含查询字段
|
|
|
+ if (!searchFieldList.length) {
|
|
|
+ this.$message.warning("请至少选择一个包含查询字段");
|
|
|
+ return false;
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- this.isShowForm = false;
|
|
|
- this.tableItemForm = {}
|
|
|
+ // 判断是新增还是修改 true新增
|
|
|
+ if(this.relateTitle){
|
|
|
+
|
|
|
+ let echoData = {
|
|
|
+ tableName: this.tableItemForm.tableName,
|
|
|
+ tableFieldData: this.tableFieldList,
|
|
|
+ formData: this.groupForm,
|
|
|
+ }
|
|
|
+ let tableKey = uuidv4();
|
|
|
+ let sqlKey = uuidv4();
|
|
|
+ this.addDragData.push({
|
|
|
+ tId: this.tId,
|
|
|
+ dtName: this.tableItemForm.title,
|
|
|
+ tableKey: tableKey,
|
|
|
+ dtTableName: this.tableItemForm.tableName,
|
|
|
+ primaryKey: this.tableItemForm.selectFields,
|
|
|
+ orderByColumn: '',
|
|
|
+ sortOrder: false,
|
|
|
+ sqlKey: sqlKey,
|
|
|
+ dtColumnName: columns,
|
|
|
+ timeFormat: 'yyyy-MM-dd',
|
|
|
+ searchFieldList: searchFieldList,
|
|
|
+ tableSql: this.getSQLStr(),
|
|
|
+ tableExportField: '',
|
|
|
+ echoData: JSON.stringify(echoData),
|
|
|
+ })
|
|
|
+
|
|
|
+ this.tableItemForm.rowId = Date.now();
|
|
|
+ this.groupList.push({tableFieldList: this.tableFieldList, tableItemForm: this.tableItemForm})
|
|
|
+
|
|
|
+ this.tableDataList.push(this.tableItemForm);
|
|
|
+ } else {
|
|
|
+ let columns = [],
|
|
|
+ searchFieldList = []
|
|
|
+ this.getCol(
|
|
|
+ this.tableFieldList,
|
|
|
+ columns,
|
|
|
+ searchFieldList,
|
|
|
+ );
|
|
|
+ let echoData = {
|
|
|
+ tableName: this.tableItemForm.tableName,
|
|
|
+ tableFieldData: this.tableFieldList,
|
|
|
+ formData: this.groupForm,
|
|
|
+ }
|
|
|
+ console.log(this.tableDataList)
|
|
|
+ console.log('修改')
|
|
|
+ }
|
|
|
+ console.log(this.addDragData);
|
|
|
+
|
|
|
+ this.isShowForm = false
|
|
|
+ this.tableItemForm = {}
|
|
|
+ this.tableFieldList = []
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.$message.error("请完善表单信息");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
// 修改一个表格数据
|
|
|
relateOne(row){
|
|
|
- console.log(row);
|
|
|
+ // console.log(row);
|
|
|
+ // console.log('修改', this.groupList);
|
|
|
+ // 展示字段的回显
|
|
|
+ this.groupList.forEach(item => {
|
|
|
+ if(item.tableItemForm.rowId == row.rowId) {
|
|
|
+ this.tableFieldList = item.tableFieldList
|
|
|
+ }
|
|
|
+ })
|
|
|
this.relateTitle = false
|
|
|
this.isShowForm = true;
|
|
|
this.tableItemForm = row
|
|
|
},
|
|
|
+ // 更新路由
|
|
|
+ reloadRouter() {
|
|
|
+ this.$store.dispatch("GenerateRoutes").then((accessRoutes) => {
|
|
|
+ this.$router.addRoutes(accessRoutes); // 动态添加可访问路由表
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取目标menu
|
|
|
+ getTargetMenu(menus) {
|
|
|
+ for (let i = 0; i < menus.length; i++) {
|
|
|
+ if (menus[i].menuId == this.groupForm.routePath) {
|
|
|
+ return menus[i];
|
|
|
+ } else if (menus.children?.length) {
|
|
|
+ return this.getTargetMenu(menus.children);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ // 获取父级menuId
|
|
|
+ getParentMenuId(menuId, menus) {
|
|
|
+ let res;
|
|
|
+ for (let i = 0; i < menus.length; i++) {
|
|
|
+ let item = menus[i];
|
|
|
+ if (item.menuId == menuId) {
|
|
|
+ res = item.parentId;
|
|
|
+ break;
|
|
|
+ } else if (item.children?.length) {
|
|
|
+ if (
|
|
|
+ this.getParentMenuId(
|
|
|
+ menuId,
|
|
|
+ JSON.parse(JSON.stringify(item.children))
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ res = this.getParentMenuId(
|
|
|
+ menuId,
|
|
|
+ JSON.parse(JSON.stringify(item.children))
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ },
|
|
|
// 新增动态表格组
|
|
|
- addTableGroup(){
|
|
|
- let tableKey = this.tableDataList[0].tableName
|
|
|
- this.tableGroupList.push({
|
|
|
- rowId: Date.now(),
|
|
|
- tableDataList: this.tableDataList,
|
|
|
- contentList: this.tableDataList.splice(1),
|
|
|
- groupname: this.groupname,
|
|
|
- groupdescribe: this.groupdescribe,
|
|
|
- groupcount: this.tableDataList.length,
|
|
|
- tableKey: this.tableDataList[0].tableName
|
|
|
- })
|
|
|
-
|
|
|
- this.isShowTable = false
|
|
|
- this.tableDataList = []
|
|
|
- this.groupname = ''
|
|
|
- this.groupdescribe = ''
|
|
|
+ addTableGroup(formName){
|
|
|
+ this.$refs[formName].validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // console.log('groupList', this.groupList);
|
|
|
+ let groupKeyObj = {
|
|
|
+ groupKey: uuidv4(),
|
|
|
+ };
|
|
|
+ let payLoad = {
|
|
|
+ component: "relateTable/relateTableEdit",
|
|
|
+ icon: "",
|
|
|
+ isCache: "0",
|
|
|
+ isFrame: "1",
|
|
|
+ menuName: this.groupForm.groupname,
|
|
|
+ menuType: "C",
|
|
|
+ orderNum: this.menuOrderNum,
|
|
|
+ parentId: this.groupForm.routePath,
|
|
|
+ path: groupKeyObj.groupKey,
|
|
|
+ query: JSON.stringify(groupKey),
|
|
|
+ status: "0",
|
|
|
+ visible: "0",
|
|
|
+ };
|
|
|
+ let result;
|
|
|
+ result = await addMenu(payLoad);
|
|
|
+
|
|
|
+ if(result.code == 200){
|
|
|
+ this.reloadRouter();
|
|
|
+ let data = {
|
|
|
+ groupName: '',
|
|
|
+ groupDescription: '',
|
|
|
+ groupTableInfo: [],
|
|
|
+ dragTables:[]
|
|
|
+ }
|
|
|
+ this.addDragData.forEach((item, index) => {
|
|
|
+ item.menuId = result.data;
|
|
|
+ item.sqlKey = tableKeyObj.tableKey
|
|
|
+ let echo = JSON.parse(item.echoData)
|
|
|
+ echo.formData = this.groupForm
|
|
|
+ item.echoData = JSON.stringify(echo)
|
|
|
+ data.groupTableInfo.push({
|
|
|
+ tableKey: item.tableKey,
|
|
|
+ sort: index
|
|
|
+ })
|
|
|
+ })
|
|
|
+ data.groupName = this.groupForm.groupname
|
|
|
+ data.groupDescription = this.groupForm.groupdescribe
|
|
|
+ data.groupTableInfo = JSON.stringify(data.groupTableInfo)
|
|
|
+ data.dragTables = this.addDragData
|
|
|
+
|
|
|
+ let res = await addGroup(data)
|
|
|
+ if(res.code == 200){
|
|
|
+ this.$message.success("创建成功");
|
|
|
+
|
|
|
+ this.isShowTable = false
|
|
|
+ this.groupForm = {}
|
|
|
+ } else {
|
|
|
+ this.$message.success("创建失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ this.$message.error("请完善表单信息");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
/** 新增按钮操作 */
|
|
|
- handleAdd() {
|
|
|
+ async handleAdd() {
|
|
|
// this.$router.push({
|
|
|
// path: "/system/fromModel/index/relateMange",
|
|
|
// });
|
|
|
+ await this.getMenuList();
|
|
|
+
|
|
|
+ if (this.$route.query.tId) {
|
|
|
+ this.tId = this.$route.query.tId;
|
|
|
+ // 修改表格回显数据
|
|
|
+ // this.initTableData(this.tId);
|
|
|
+ }
|
|
|
this.groupTitle = true
|
|
|
this.isShowTable=true
|
|
|
},
|
|
|
+ // 获取路由表单数据
|
|
|
+ async getMenuList() {
|
|
|
+ let res = await getMenuList();
|
|
|
+ this.menus = this.handleTree(res.data, "menuId");
|
|
|
+ console.log(this.menus);
|
|
|
+ },
|
|
|
+ /** 转换菜单数据结构 */
|
|
|
+ normalizer(node) {
|
|
|
+ if (node.children && !node.children.length) {
|
|
|
+ delete node.children;
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ id: node.menuId,
|
|
|
+ label: node.menuName,
|
|
|
+ children: node.children,
|
|
|
+ };
|
|
|
+ },
|
|
|
// 修改动态表格组
|
|
|
UpdateTableGroup(row){
|
|
|
console.log(row);
|
|
@@ -708,6 +1223,20 @@ export default {
|
|
|
};
|
|
|
</script>
|
|
|
<style scoped lang="scss">
|
|
|
+::v-deep .el-dialog:not(.is-fullscreen){
|
|
|
+ width: 900px !important;
|
|
|
+}
|
|
|
+.tablefiled{
|
|
|
+ ::v-deep .el-input--medium .el-input__inner{
|
|
|
+ width: 70px !important;
|
|
|
+ }
|
|
|
+}
|
|
|
+::v-deep .el-input--medium .el-input__inner{
|
|
|
+ width: 230px !important;
|
|
|
+}
|
|
|
+::v-deep .btn{
|
|
|
+ text-align: right !important;
|
|
|
+}
|
|
|
.ipt {
|
|
|
height: 36px;
|
|
|
line-height: 36px;
|
|
@@ -728,6 +1257,9 @@ export default {
|
|
|
.ipt:focus {
|
|
|
border-color: #1890ff;
|
|
|
}
|
|
|
+::v-deep .vue-treeselect--has-value .vue-treeselect__input {
|
|
|
+ vertical-align: middle !important;
|
|
|
+}
|
|
|
.formWrap {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
@@ -749,4 +1281,20 @@ export default {
|
|
|
.desc{
|
|
|
margin-left: 10px;
|
|
|
}
|
|
|
+::v-deep .vue-treeselect--has-value .vue-treeselect__input {
|
|
|
+ vertical-align: middle !important;
|
|
|
+
|
|
|
+}
|
|
|
+.treeselect{
|
|
|
+ .vue-treeselect{
|
|
|
+ width: 230px !important;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+
|
|
|
+.vue-treeselect{
|
|
|
+ z-index: 9999 !important;
|
|
|
+}
|
|
|
+</style>
|