feat: 增加了不同数据库的数据接入新增,修改,测试连接,同步数据

将后台代码功能完善了一下,使其能添加MySql和PostGre两种数据库的数据接入,并且能够测试连接和同步数据
master
yaoxin 2024-04-23 20:36:20 +08:00
parent 006e1f246b
commit 40069c97b8
6 changed files with 690 additions and 20 deletions

View File

@ -0,0 +1,348 @@
<template>
<div class="app-container">
<h4 class="form-header h4">基本信息</h4>
<el-form ref="form" :model="baseInfo" label-width="120px">
<el-row>
<el-col :offset="2" :span="8">
<el-form-item label="数据接入名称" prop="nickName">
<el-input v-model="title.dataSourceName" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="系统名称" prop="userName">
<el-input v-model="title.systemName" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="数据库名称" prop="nickName">
<el-input v-model="title.databaseName" disabled/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-tabs type="border-card" v-model="activeName">
<el-tab-pane label="部门授权" name="dept">
<el-table
ref="deptTable"
v-loading="loading"
:data="deptList"
:default-expand-all="true"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
row-key="deptId"
>
<el-table-column label="部门名称" prop="deptName" ></el-table-column>
<el-table-column label="部门负责人" prop="leader" ></el-table-column>
<el-table-column label="邮箱" prop="email" ></el-table-column>
<el-table-column align="center" label="创建时间" prop="createTime" >
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作" prop="createTime" >
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权">
</el-switch>
</template>
</el-table-column>
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
</el-tab-pane>
<el-tab-pane label="用户授权" name="user">
<el-table ref="table" v-loading="loading" :data="userList">
<el-table-column align="center" label="用户名称" prop="userName"/>
<el-table-column align="center" label="用户昵称" prop="nickName"/>
<el-table-column align="center" label="用户部门" prop="dept.deptName"/>
<el-table-column align="center" label="用户邮箱" prop="email"/>
<el-table-column align="center" label="用户手机号" prop="phonenumber"/>
<el-table-column align="center" label="创建时间" prop="createTime" />
<el-table-column align="center" label="操作" prop="createTime" >
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权">
</el-switch>
</template>
</el-table-column>
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { parseTime } from '@/utils/muyu'
export default {
props:{
title:{}
},
name: "AuthDataSource",
data() {
return {
//
loading: true,
activeName: "dept",
//
total: 0,
pageNum: 1,
pageSize: 1,
//
baseInfo: {
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
},
//
deptList: [],
//
userList: []
};
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
this.init()
},
methods: {
parseTime,
init(){
let response = {
"code": 200,
"msg": "操作成功",
"data": [
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 100,
"parentId": 0,
"ancestors": "0",
"deptName": "muyu牧鱼科技",
"orderNum": 0,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 101,
"parentId": 100,
"ancestors": "0,100",
"deptName": "深圳总公司",
"orderNum": 1,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 102,
"parentId": 100,
"ancestors": "0,100",
"deptName": "长沙分公司",
"orderNum": 2,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 103,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "研发部门",
"orderNum": 1,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 104,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "市场部门",
"isAuth": true,
"orderNum": 2,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 105,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "测试部门",
"orderNum": 3,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 106,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "财务部门",
"orderNum": 4,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 107,
"parentId": 101,
"ancestors": "0,100,101",
"deptName": "运维部门",
"orderNum": 5,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 108,
"parentId": 102,
"ancestors": "0,100,102",
"deptName": "市场部门",
"orderNum": 1,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
},
{
"createBy": 1,
"createTime": "2023-09-29 11:47:27",
"updateBy": null,
"updateTime": null,
"deptId": 109,
"parentId": 102,
"ancestors": "0,100,102",
"deptName": "财务部门",
"orderNum": 2,
"leader": "muyu牧鱼",
"phone": "15888888888",
"email": "ry@qq.com",
"status": "0",
"delFlag": "0",
"parentName": null,
"children": []
}
]
}
this.deptList = this.handleTree(response.data, "deptId");
this.userList = [
{
"createBy": "admin",
"createTime": "2023-04-23 16:11:38",
"updateBy": null,
"updateTime": null,
"remark": "管理员",
"userId": 1,
"deptId": 103,
"userName": "admin",
"nickName": "智能车联",
"email": "ry@163.com",
"phonenumber": "15888888888",
"isAuth": true,
"dept": {
"deptName": "研发部门"
}
},
{
"createBy": "admin",
"createTime": "2023-04-23 16:11:38",
"updateBy": null,
"updateTime": null,
"remark": "测试员",
"userId": 2,
"deptId": 105,
"userName": "ry",
"nickName": "智能车联",
"email": "ry@qq.com",
"phonenumber": "15666666666",
"dept": {
"deptName": "测试部门"
}
}
]
}
},
};
</script>

View File

@ -0,0 +1,181 @@
<template>
<div class="app-container">
<h4 class="form-header h4">基本信息</h4>
<el-form ref="form" :model="title" label-width="120px">
<el-row>
<el-col :offset="2" :span="8">
<el-form-item label="数据接入名称" prop="nickName">
<el-input v-model="title.dataSourceName" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="系统名称" prop="userName">
<el-input v-model="title.systemName" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="数据库名称" prop="nickName">
<el-input v-model="title.databaseName" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="表名称" prop="nickName">
<el-input v-model="title.tableName" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="表中文名" prop="nickName">
<el-input v-model="title.tableComment" disabled/>
</el-form-item>
</el-col>
<el-col :offset="2" :span="8">
<el-form-item label="数据量" prop="nickName">
<el-input v-model="title.tableCount" disabled/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-tabs type="border-card" v-model="activeName">
<el-tab-pane label="部门授权" name="dept">
<el-table
v-loading="loading"
:data="deptList"
:default-expand-all="isExpandAll"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
row-key="deptId"
>
<el-table-column label="部门名称" prop="deptName" ></el-table-column>
<el-table-column label="排序" prop="orderNum" ></el-table-column>
<el-table-column label="负责人" prop="leader" ></el-table-column>
<el-table-column label="邮箱" prop="email" ></el-table-column>
<el-table-column align="center" label="创建时间" prop="createTime" >
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" label="操作">
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权">
</el-switch>
</template>
</el-table-column>
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
</el-tab-pane>
<el-tab-pane label="用户授权" name="user">
<el-table ref="table" v-loading="loading" :data="userList">
<el-table-column align="center" label="用户名称" prop="userName"/>
<el-table-column align="center" label="用户昵称" prop="nickName"/>
<el-table-column align="center" label="用户部门" prop="dept.deptName"/>
<el-table-column align="center" label="用户邮箱" prop="email"/>
<el-table-column align="center" label="用户手机号" prop="phonenumber"/>
<el-table-column align="center" label="创建时间" prop="createTime" />
<el-table-column align="center" label="操作" prop="createTime" >
<template slot-scope="scope">
<el-switch
style="display: block"
v-model="scope.row.isAuth"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
inactive-text="未授权">
</el-switch>
</template>
</el-table-column>
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
</el-tab-pane>
</el-tabs>
</div>
</template>
<script>
import { parseTime } from '@/utils/muyu'
import {listDept} from "@/api/system/dept";
export default {
props:{
title:{}
},
name: "AuthTable",
data() {
return {
refreshTable: true,
//
loading: true,
activeName: "dept",
//
total: 0,
pageNum: 1,
pageSize: 1,
//
deptList: [],
//
userList: []
};
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
this.getList()
},
methods: {
/** 查询部门列表 */
getList() {
listDept(this.queryParams).then(response => {
console.log(response.data)
this.deptList = this.handleTree(response.data, "deptId");
console.log(this.deptList)
this.loading = false;
});
},
parseTime,
init(){
// this.deptList = this.handleTree(response.data, "deptId");
this.userList = [
{
"createBy": "admin",
"createTime": "2023-04-23 16:11:38",
"updateBy": null,
"updateTime": null,
"remark": "管理员",
"userId": 1,
"deptId": 103,
"userName": "admin",
"nickName": "智能车联",
"email": "ry@163.com",
"phonenumber": "15888888888",
"isAuth": true,
"dept": {
"deptName": "研发部门"
}
},
{
"createBy": "admin",
"createTime": "2023-04-23 16:11:38",
"updateBy": null,
"updateTime": null,
"remark": "测试员",
"userId": 2,
"deptId": 105,
"userName": "ry",
"nickName": "智能车联",
"email": "ry@qq.com",
"phonenumber": "15666666666",
"dept": {
"deptName": "测试部门"
}
}
]
}
},
};
</script>

View File

@ -0,0 +1,117 @@
<template>
<el-container :style="{height: mainHeight + 'px'}">
<el-aside>
<el-menu :default-openeds="['1', '3']">
<el-tree :data="sourceList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</el-menu>
</el-aside>
<el-container>
<el-main>
<auth-data-source v-if="showAuth === 'dataSource'" :title="title"/>
<auth-table v-else-if="showAuth === 'dataTable'" :title="title"/>
</el-main>
</el-container>
</el-container>
</template>
<script>
import AuthDataSource from './auth/AuthDataSource.vue'
import AuthTable from './auth/AuthTable.vue'
import {dataAssetList, listSource} from "@/api/etl/source";
export default {
name: 'assetStructure',
components: { AuthTable, AuthDataSource },
data() {
return {
title: {},
sourceList: [],
mainHeight: window.innerHeight - 85,
defaultProps: {
children: 'tableList',
label: 'label'
},
showAuth: null
}
},
methods: {
handleNodeClick(data) {
if (data.dataType === 'dataSource'){
dataAssetList(data).then(res => {
res.data.forEach(table => {
table.dataType = "dataTable"
table.label=table.tableName+"-"+table.tableComment+"("+table.tableCount+"条)"
})
data.tableList = res.data
this.sourceList[this.sourceList.indexOf(data)].tableList = res.data
this.title = data
})
}else{
this.sourceList.forEach(source => {
if (source.tableList!=null){
source.tableList.forEach(table => {
if (table.tableName === data.tableName){
data.dataSourceName = source.dataSourceName
data.systemName = source.systemName
data.databaseName = source.databaseName
}
})
}
})
this.title= data
}
this.showAuth = data.dataType
},
expandTable( node, resolve){
if (node.level === 0) return resolve(this.assetStructureList);
const {data} = node;
if (data.type === 'dataTable') {
return resolve([])
}
setTimeout(() => {
resolve(this.childrenList)
}, 500);
},
getList() {
this.assetsCompute={
assetsModuleSum: 0,
dataModuleSum: 0,
dataSourceSum: 0
}
listSource(this.queryParams).then(response => {
this.sourceList = response.data.rows;
console.log(this.sourceList)
this.sourceList.forEach(source => {
source.label=source.dataSourceName+'('+source.databaseName+'-'+source.systemName+')'
source.dataType = 'dataSource'
if (source.tableList!=null){
source.tableList.forEach(table => {
table.label = table.tableName+'-'+table.tableComment+'('+table.tableCount+'条)'
table.dataType = 'dataTable'
})
}
})
this.total = response.data.total;
});
}
},
created() {
this.getList()
},
}
</script>
<style scoped lang="scss">
.el-aside {
margin: 0;
padding: 0;
width: 400px;
background-color: white;
}
.el-main {
background-color: #f1f1f1;
}
.custom-tree-node{
height: 30px;
}
</style>

View File

@ -1,15 +1,13 @@
<template>
<div>
<el-container style="height: 80%; border: 1px solid #eee">
<el-aside width="400px" style="background-color: rgb(238, 241, 246)">
<el-menu :default-openeds="['1', '3']">
<el-tree :data="sourceList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</el-menu>
<el-container :style="{height: mainHeight + 'px'}">
<el-aside width="400px" style="background-color: rgb(238, 241, 246);height: 80%">
<el-tree style="background-color: white" :data="sourceList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</el-aside>
<el-container>
<el-main style="height: 100%">
<el-main>
<el-tabs v-model="activeName">
<el-tab-pane label="资产结构" name="structure">
<OverallAssets v-if="showAssets == null" :assets-compute="assetsCompute"/>
@ -76,6 +74,7 @@ export default {
props: {},
data() {
return {
mainHeight: window.innerHeight - 85,
assetsCompute:{
assetsModuleSum: 0,
dataModuleSum: 0,
@ -139,16 +138,16 @@ export default {
})
},
getList() {
this.assetsCompute={
assetsModuleSum: 0,
dataModuleSum: 0,
dataSourceSum: 0
}
listSource(this.queryParams).then(response => {
this.sourceList = response.data.rows;
console.log(this.sourceList)
this.sourceList.forEach(source => {
source.label=source.dataSourceName+'('+source.databaseName+'-'+source.systemName+')'
if (source.type=='PostGre'){
source.label=source.dataSourceName+'('+source.databaseName+'-'+source.modeName+'-'+source.systemName+')'
}else{
source.label=source.dataSourceName+'('+source.databaseName+'-'+source.systemName+')'
}
source.dataType = 'dataSource'
if (source.tableList!=null){
source.tableList.forEach(table => {
@ -171,13 +170,16 @@ export default {
};
</script>
<style scoped>
.el-header {
background-color: #B3C0D1;
color: #333;
line-height: 60px;
}
.el-aside {
color: #333;
margin: 0;
padding: 0;
width: 400px;
background-color: white;
}
.el-main {
background-color: #f1f1f1;
}
.custom-tree-node{
height: 30px;
}
</style>

View File

@ -155,7 +155,7 @@
<el-form-item label="数据接入类型" prop="type">
<el-select style="width: 100%" v-model="form.type">
<el-option label="MySql" value="MySql">MySql</el-option>
<el-option label="Oracle" value="Oracle">Oracle</el-option>
<el-option label="PostGre" value="PostGre">PostGre</el-option>
</el-select>
</el-form-item>
</el-col>
@ -165,6 +165,13 @@
</el-form-item>
</el-col>
</el-row>
<el-row v-if="form.type == 'PostGre'">
<el-col :md="12" :sm="24">
<el-form-item label="模式名称" prop="modeName">
<el-input v-model="form.modeName" placeholder="模式名称" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="连接用户名" prop="username">
@ -274,6 +281,15 @@ import {
} from "@/api/etl/source";
export default {
watch:{
'form.type':{
handler(val) {
if(val != 'PostGre'){
this.form.modeName = ''
}
}
}
},
name: "Source",
data() {
return {
@ -338,6 +354,9 @@ export default {
],
maxWaitSize: [
{required: true, message: "最大等待次数不能为空", trigger: "blur"}
],
modeName: [
{required: true, message: "模式名称不能为空", trigger: "blur"}
]
},
dataSourceParamList: [
@ -440,6 +459,7 @@ export default {
maxNum: null,
maxWaitTime: null,
maxWaitSize: null,
modeName: null,
createBy: null,
createTime: null,
updateBy: null,

View File

@ -60,6 +60,8 @@
>
<el-table-column label="部门名称" prop="deptName" width="260"></el-table-column>
<el-table-column label="排序" prop="orderNum" width="200"></el-table-column>
<el-table-column label="负责人" prop="leader" width="200"></el-table-column>
<el-table-column label="邮箱" prop="email" width="200"></el-table-column>
<el-table-column label="状态" prop="status" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>