feat:新增字典表(初)

master
Jiang Peng 2024-04-26 14:16:36 +08:00
parent 109aa26961
commit f8f5c81ed5
5 changed files with 300 additions and 695 deletions

View File

@ -0,0 +1,59 @@
import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listDictionary(query) {
return request({
url: '/etl/dictionary/list',
method: 'get',
params: query
})
}
// 查询【请填写功能名称】详细
export function getDictionary(id) {
return request({
url: '/etl/dictionary/' + id,
method: 'get'
})
}
// 根据key删除字典详细
export function deleteDictionary(id) {
return request({
url: '/etl/dictionary/DeleteDictionary?id=' + id,
method: 'get'
})
}
// 新增【请填写功能名称】
export function addDictionary(data) {
return request({
url: '/etl/dictionary',
method: 'post',
data: data
})
}
// 修改【请填写功能名称】
export function updateDictionary(data) {
return request({
url: '/etl/dictionary',
method: 'put',
data: data
})
}
// 删除【请填写功能名称】
export function delDictionary(id) {
return request({
url: '/etl/dictionary/' + id,
method: 'delete'
})
}
export function getDictionaryList(id) {
return request({
url: '/etl/dictionary/GetDictionaryList?dataSourceId=' + id,
method: 'get'
})
}

View File

@ -1,93 +0,0 @@
import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listSource(query) {
return request({
url: '/etl/source/list',
method: 'get',
params: query
})
}
export function dataAssetList(data) {
return request({
url: '/etl/source/DataAssetList',
method: 'post',
data
})
}
export function assetModelList(data) {
return request({
url: '/etl/source/AssetModelList',
method: 'post',
data
})
}
export function assetsList(data) {
return request({
url: '/etl/source/AssetsList',
method: 'post',
data
})
}
export function synchronousData(data) {
return request({
url: '/etl/source/SynchronousData',
method: 'post',
data
})
}
export function structureList(data) {
return request({
url: '/etl/source/StructureList',
method: 'post',
data
})
}
// 查询【请填写功能名称】详细
export function getSource(id) {
return request({
url: '/etl/source/' + id,
method: 'get'
})
}
// 新增【请填写功能名称】
export function addSource(data) {
return request({
url: '/etl/source',
method: 'post',
data: data
})
}
// 测试连接
export function testConnection(data) {
return request({
url: '/etl/source/TestConnection',
method: 'post',
data: data
})
}
// 修改【请填写功能名称】
export function updateSource(data) {
return request({
url: '/etl/source',
method: 'put',
data: data
})
}
// 删除【请填写功能名称】
export function delSource(id) {
return request({
url: '/etl/source/' + id,
method: 'delete'
})
}

View File

@ -150,13 +150,13 @@
<el-col :span="24"> <el-col :span="24">
<el-form-item label="字典"> <el-form-item label="字典">
<el-select v-model="form.dictKey"> <el-select v-model="form.dictKey">
<el-option v-for="(value, key) in dictMap" :key="key" :label="key" :value="key"></el-option> <el-option v-for="dict in dictMap" :label="dict.dictionaryName+'('+dict.dictionaryKey+')'" :value="dict.dictionaryKey"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="24"> <el-col :span="24">
<el-form-item> <el-form-item>
<el-table :data="dictMap[form.dictKey]" striped border> <el-table :data="dictionaryDataList" striped border>
<el-table-column property="label" label="字典标签"/> <el-table-column property="label" label="字典标签"/>
<el-table-column property="val" label="字典值"/> <el-table-column property="val" label="字典值"/>
</el-table> </el-table>
@ -173,19 +173,28 @@
</template> </template>
<script> <script>
import {assetModelList} from "@/api/etl/datasource"; import {assetModelList} from "@/api/etl/datasource";
import {getDictionaryList} from "@/api/etl/dictionary";
export default { export default {
name: 'OverallAssetStructure', name: 'OverallAssetStructure',
watch:{ watch:{
'title':{ 'title':{
handler(val){ handler(val){
console.log(val) this.getDictionaryList()
assetModelList(val).then(res=>{ assetModelList(val).then(res=>{
this.tableData = res.data this.tableData = res.data
}) })
}, },
immediate:true immediate:true
},
'form.dictKey':{
handler(val){
this.dictMap.forEach(dict=>{
if (dict.dictionaryKey === val){
this.dictionaryDataList = dict.dictionaryDataList
}
})
}
} }
}, },
props:{ props:{
@ -195,89 +204,21 @@ export default {
}, },
data() { data() {
return { return {
tableData: [ dictionaryDataList:[],
{ tableData: [],
id: 1,
name: "id",
comment: "主键",
isPrimaryKey: "Y",
type: "bigint",
mappingType: "Long",
length: "-",
decimalPlaces: "-",
isNull: "N",
defaultValue: "-",
isDict: "N",
dictKey: "-",
}, {
id: 2,
name: "name",
comment: "姓名",
isPrimaryKey: "N",
type: "varchar",
mappingType: "String",
length: "64",
decimalPlaces: "-",
isNull: "N",
defaultValue: "-",
isDict: "N",
dictKey: "-",
}, {
id: 3,
name: "sex",
comment: "性别",
isPrimaryKey: "N",
type: "char",
mappingType: "String",
length: "1",
decimalPlaces: "-",
isNull: "N",
defaultValue: "-",
isDict: "Y",
dictKey: "system_sex",
}, {
id: 4,
name: "price",
comment: "金额",
isPrimaryKey: "N",
type: "double",
mappingType: "BigDecimal",
length: "10",
decimalPlaces: "2",
isNull: "N",
defaultValue: "0.00",
isDict: "N",
dictKey: "-",
}, {
id: 5,
name: "create_time",
comment: "创建时间",
isPrimaryKey: "N",
type: "datetime",
mappingType: "Date",
length: "-",
decimalPlaces: "-",
isNull: "Y",
defaultValue: "-",
isDict: "N",
dictKey: "-",
}, ],
form: {}, form: {},
formStatus: false, formStatus: false,
dictMap: { dictMap: {}
"system_sex": [
{ label: '男', val: '1', isEdit: false },
{ label: '女', val: '2', isEdit: false },
{ label: '未知', val: '0', isEdit: false },
],
"system_y_n": [
{ label: '是', val: '1', isEdit: false },
{ label: '否', val: '0', isEdit: false }
],
}
} }
}, },
methods: { methods: {
getDictionaryList(){
getDictionaryList(this.title.id).then(res=>{
console.log("灌灌灌灌灌孤寡孤寡孤寡尴尬",this.title.dataSourceId)
console.log("sourceId",res)
this.dictMap = res.data
})
},
update(row) { update(row) {
this.form = row; this.form = row;
this.formStatus = true; this.formStatus = true;

View File

@ -44,52 +44,53 @@
placement="right" placement="right"
width="400" width="400"
trigger="click"> trigger="click">
<el-row :gutter="20"> <el-form :inline="true" :model="dictInfo" class="demo-form-inline">
<el-col :span="18"> <el-form-item label="字典名称">
<el-input v-model="dictAddName"></el-input> <el-input v-model="dictInfo.dictionaryName" style="width: 150px "> </el-input>
</el-col> </el-form-item>
<el-col :span="6"> <el-form-item label="字典值">
<el-input v-model="dictInfo.dictionaryKey" style="width: 150px"></el-input>
</el-form-item>
<el-form-item>
<el-button @click="addDict"></el-button> <el-button @click="addDict"></el-button>
</el-col> </el-form-item>
</el-row> </el-form>
<el-button style="float: right; padding: 3px 0" type="text" slot="reference">新增字典</el-button> <el-button style="float: right; padding: 3px 0" type="text" slot="reference">新增</el-button>
</el-popover> </el-popover>
</div> </div>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col v-for="(val,key) in dictMap" :md="8" :sm="24" :xs="12"> <el-col v-for="dict in dictMap" :md="8" :sm="24" :xs="12">
<el-card class="box-card" style="height: 300px"> <el-card class="box-card" style="height: 300px">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>{{key}}</span> <span>{{dict.dictionaryName+'('+dict.dictionaryKey+')'}}</span>
<el-button style="float: right; padding: 3px 0" <el-button style="float: right; padding: 3px 0" type="text" @click="delDict(dict.id)"></el-button>
type="text" <el-button style="float: right; padding: 3px 0" type="text" @click="dict.dictionaryDataList.push({label:null,val:null,edit:true})"></el-button>
@click="val.push({ label: null, val: null, isEdit: true })"
>新增</el-button>
</div> </div>
<el-table :data="val" style="width: 100%" height="280px"> <el-table :data="dict.dictionaryDataList" style="width: 100%" height="280px">
<el-table-column prop="label" label="标签"> <el-table-column prop="label" label="标签">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="!scope.row.isEdit">{{scope.row.label}}</span> <span v-if="!scope.row.edit">{{scope.row.label}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.label" size="mini"></el-input> <el-input v-if="scope.row.edit" v-model="scope.row.label" size="mini"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="val" label="值"> <el-table-column prop="val" label="值">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="!scope.row.isEdit">{{scope.row.val}}</span> <span v-if="!scope.row.edit">{{scope.row.val}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.val" size="mini"></el-input> <el-input v-if="scope.row.edit" v-model="scope.row.val" size="mini"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="val" label="操作"> <el-table-column prop="val" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="!scope.row.isEdit" v-if="!scope.row.edit"
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="scope.row.isEdit = true" @click="scope.row.edit = true"
>修改</el-button> >修改</el-button>
<el-button <el-button
v-if="scope.row.isEdit" v-if="scope.row.edit"
@click="editConfirm(scope.row)" @click="editConfirm(dict,scope.row)"
size="mini" size="mini"
type="text" type="text"
icon="el-icon-finished" icon="el-icon-finished"
@ -116,23 +117,30 @@
<script> <script>
import CountTo from 'vue-count-to' import CountTo from 'vue-count-to'
import OverallAssetStructure from './OverallAssetStructure.vue' import OverallAssetStructure from './OverallAssetStructure.vue'
import {addDictionary, getDictionaryList} from "@/api/etl/dictionary";
import {addData, updateData} from "@/api/etl/data";
export default { export default {
watch:{ watch:{
'title':{ 'title':{
handler(val){ handler(val){
console.log(val) this.getDictionaryList()
if (val.tableList.length > 0){
this.activeName = val.tableList[0].tableName this.activeName = val.tableList[0].tableName
this.assetModel = 0 this.assetModel = 0
this.dataModel = 0 this.dataModel = 0
val.tableList.forEach(t =>{ val.tableList.forEach(t =>{
if (t.tableCount !=null){ if (t.tableCount !=null){
this.dataModel = parseInt(this.dataModel) + parseInt(t.tableCount) this.dataModel = parseInt(this.dataModel) + parseInt(t.tableCount)
} }
if (t.fields != null){ if (t.fields != null){
this.assetModel = this.assetModel + t.fields this.assetModel = this.assetModel + t.fields
} }
}) })
}else{
console.error('数据模型为空')
}
}, },
}, },
}, },
@ -142,42 +150,64 @@ export default {
}, },
data() { data() {
return { return {
dictInfo:{
dictionaryName:null,
dictionaryKey:null,
dataSourceId:null
},
assetModel:0, assetModel:0,
dataModel:0, dataModel:0,
activeName: '', activeName: '',
dictAddName: null,
dictMap: { dictMap: {
"性别(system_sex)": [ },
{ label: '男', val: '1', isEdit: false },
{ label: '女', val: '2', isEdit: false },
{ label: '未知', val: '0', isEdit: false },
],
"开关(system_y_n)": [
{ label: '是', val: '1', isEdit: false },
{ label: '否', val: '0', isEdit: false }
],
}
} }
}, },
components: { components: {
OverallAssetStructure, OverallAssetStructure,
CountTo CountTo
}, },
created() {
},
methods: { methods: {
editConfirm(row){ delDict(){},
getDictionaryList(){
console.log(this.title)
getDictionaryList(this.title.id).then(res=>{
console.log("=========",res)
this.dictMap = res.data
})
},
editConfirm(dict,row){
if (!row.label || !row.val) { if (!row.label || !row.val) {
this.$message.error('字典标签或字典值,不可为空'); this.$message.error('字典标签或字典值,不可为空');
return; return;
} }
row.isEdit = false; if (row.id){
updateData(row)
}else{
row.dictionaryId =dict.id
addData(row)
}
row.edit = false;
this.getDictionaryList()
}, },
addDict(){ addDict(){
if (!this.dictAddName){ if (!this.dictInfo.dictionaryName){
this.$message.error('数据字典,不可为空'); this.$message.error('数据字典,不可为空');
return; return;
} }
this.dictMap[this.dictAddName] = [] if (!this.dictInfo.dictionaryKey){
this.dictAddName = null this.$message("数据值,不能为空")
addDictionary(this.dictInfo)
this.dictInfo={
dictionaryName:null,
dictionaryKey: null,
dataSourceId: null
}
this.getDictionaryList()
}
}, },
handleSetLineChartData(type) { handleSetLineChartData(type) {
this.$emit('handleSetLineChartData', type) this.$emit('handleSetLineChartData', type)

View File

@ -1,508 +1,176 @@
<template> <template>
<div class="app-container"> <div>
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-container style="height: 80%; border: 1px solid #eee">
<el-form-item label="数据源名称" prop="dataSourceName" label-width="100px"> <el-aside width="300px" style="background-color: rgb(238, 241, 246)">
<el-input <el-tree :data="sourceList"
v-model="queryParams.dataSourceName" @node-click="handleNodeClick"
placeholder="请输入数据源名称" :props="defaultProps">
clearable </el-tree>
@keyup.enter.native="handleQuery" </el-aside>
/> <el-container>
</el-form-item> <el-main>
<el-form-item label="数据源链接地址" prop="linkAddress" label-width="120px"> <el-tabs v-model="activeName">
<el-input <el-tab-pane label="资产结构" name="structure">
v-model="queryParams.linkAddress" <OverallAssets v-if="showAssets == null"/>
placeholder="请输入数据源链接地址" <overall-specific-assets v-if="showAssets === 'dataSource'" :title="title"/>
clearable <overall-asset-structure v-if="showAssets === 'dataTable'" :title="title"/>
@keyup.enter.native="handleQuery" </el-tab-pane>
/> <el-tab-pane label="资产数据" name="data">
</el-form-item> <el-card style="height: 280px">
<el-form-item> <div slot="header" class="clearfix">
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button> <span>查询语句</span>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button> </div>
</el-form-item> <el-input type="textarea" v-model="source.sql" style="width: 1080px;" :rows="6"></el-input>
</el-form> <el-button style="float: right;margin-top: 20px" @click="sql()"></el-button>
<el-row :gutter="10" class="mb8"> </el-card>
<el-col :span="1.5"> <br>
<el-button <el-card>
type="primary" <div slot="header" class="clearfix">
plain <span>数据资产</span>
icon="el-icon-plus" </div>
size="mini" <el-table :data="structureList" v-if="structureList!=null">
@click="handleAdd" <el-table-column v-for="(assets,index) in assetsList" :label="index+' ('+assets+')'" width="140">
v-hasPermi="['system:source:add']" <template slot-scope="scope">
>新增</el-button> {{scope.row[index].value}}
</el-col> </template>
<el-col :span="1.5"> </el-table-column>
<el-button </el-table>
type="success" </el-card>
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:source:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:source:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
v-hasPermi="['system:source:export']"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="datasourceList" @selection-change="handleSelectionChange"> </el-tab-pane>
<el-table-column type="selection" width="55" align="center" /> </el-tabs>
<el-table-column label="主键" align="center" prop="id" />
<el-table-column label="端口" align="center" prop="port" />
<el-table-column label="用户名" align="center" prop="username" />
<el-table-column label="密码" align="center" prop="password" />
<el-table-column label="连接地址" align="center" prop="linkAddress" />
<el-table-column label="数据源名称" align="center" prop="dataSourceName" />
<el-table-column label="数据库名" align="center" prop="databaseName" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-link"
@click="test(scope.row)"
>测试连接</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-s-open"
@click="synchronization(scope.row)"
>同步资产结构</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['etl:datasource:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['etl:datasource:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination </el-main>
v-show="total>0" </el-container>
:total="total" </el-container>
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改请填写功能名称对话框 -->
<el-dialog :title="title" :visible.sync="open" width="1150px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="140px">
<el-card>
<div slot="header" class="clearfix">
<span>基础配置信息</span>
</div>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="接入源名称" prop="dataSourceName">
<el-input v-model="form.dataSourceName" placeholder="请输入接入源名称" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="数据来源系统名称" prop="systemName">
<el-input v-model="form.systemName" placeholder="请输入数据来源系统名称" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="主机IP" prop="linkAddress">
<el-input v-model="form.linkAddress" placeholder="请输入主机地址" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="主机地址" prop="port">
<el-input v-model="form.port" placeholder="请输入主机地址" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<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-select>
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="数据库名称" prop="databaseName">
<el-input v-model="form.databaseName" placeholder="请输入数据库名称" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="连接用户名" prop="username">
<el-input v-model="form.username" placeholder="请输入连接用户名" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="连接密码" prop="password">
<el-input v-model="form.password" placeholder="请输入连接密码" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-card>
<div slot="header" class="clearfix">
<span>数据连接参数</span>
</div>
<el-col :sm="24">
<el-form-item label="数据连接参数" prop="connectionParam">
<el-input v-model="form.connectionParam" placeholder="请输入内容" />
</el-form-item>
</el-col>
<el-row :gutter="10" style="margin: 10px 0">
<el-col :span="2">
<el-button type="primary" @click="addParam()"></el-button>
</el-col>
<el-col :span="2">
<el-button type="danger" @click="deleteParam(null)"></el-button>
</el-col>
</el-row>
<el-row :gutter="10">
<el-col :md="8" :xs="12" style="margin: 10px 0" v-for="(dataSourceParam, dataSourceParamIndex) in dataSourceParamList">
<el-col :span="10">
<el-input v-model="dataSourceParam.name" placeholder="请输入参数键" @keyup.native="processParam"/>
</el-col>
<el-col :span="1"><span style="font-size: 28px; margin: 0 3px 0 0;">:</span></el-col>
<el-col :span="10">
<el-input v-model="dataSourceParam.val" placeholder="请输入参数值" @keyup.native="processParam"/>
</el-col>
<el-col :span="3">
<el-button type="danger" @click="deleteParam(dataSourceParamIndex)"></el-button>
</el-col>
</el-col>
</el-row>
</el-card>
</el-row>
</el-card>
<el-card style="margin-top: 20px">
<div slot="header" class="clearfix">
<span>连接池配置</span>
</div>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="初始连接数量" prop="initNum">
<el-input v-model="form.initNum" placeholder="请输入初始连接数量" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="最大连接数量" prop="maxNum">
<el-input v-model="form.maxNum" placeholder="请输入最大连接数量" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="最大等待时间" prop="maxWaitTime">
<el-input v-model="form.maxWaitTime" placeholder="请输入最大等待时间" />
</el-form-item>
</el-col>
<el-col :md="12" :sm="24">
<el-form-item label="最大等待次数" prop="maxWaitSize">
<el-input v-model="form.maxWaitSize" placeholder="请输入最大等待次数" />
</el-form-item>
</el-col>
</el-row>
</el-card>
<el-card style="margin-top: 20px">
<div slot="header" class="clearfix">
<span>其他信息</span>
</div>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item>
</el-card>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { //jsjsjson,
listDatasource, //import from ',
getDatasource, import {dataAssetList, listDatasource, structureList} from "@/api/etl/datasource";
addDatasource, import OverallSpecificAssets from "@/views/etl/assets/dashboard/OverallSpecificAssets.vue";
updateDatasource, import OverallAssets from "@/views/etl/assets/dashboard/OverallAssets.vue";
delDatasource, import OverallAssetStructure from "@/views/etl/assets/dashboard/OverallAssetStructure.vue";
test,
synchronization
} from "@/api/etl/datasource";
export default { export default {
name: "Source", components: { OverallSpecificAssets, OverallAssets,OverallAssetStructure},
//import使"
props: {},
data() { data() {
return { return {
datasourceList:[], mainHeight: window.innerHeight - 85,
// assetsCompute:{
loading: true, assetsModuleSum: 0,
// dataModuleSum: 0,
ids: [], dataSourceSum: 0
// },
single: true, showAssets: null,
// title: {},
multiple: true, activeName: 'structure',
//
showSearch: true,
//
total: 0,
//
sourceList: [],
//
title: "",
//
open: false,
datasource:{},
//
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
dataSourceName: null, dataSourceName: null,
linkAddress: null linkAddress: null
}, },
// //
form: {}, total: 0,
// //
rules: { datasourceList:[
dataSourceName: [
{required: true, message: "接入源名称不能为空", trigger: "blur"}
],
systemName: [
{required: true, message: "数据来源系统名称不能为空", trigger: "blur"}
],
type: [
{required: true, message: "数据接入类型不能为空", trigger: "blur"}
],
host: [
{required: true, message: "主机地址不能为空", trigger: "blur"}
],
port: [
{required: true, message: "主机地址不能为空", trigger: "blur"}
],
databaseName: [
{required: true, message: "数据库名称不能为空", trigger: "blur"}
],
connectionParam: [
{required: true, message: "数据连接参数不能为空", trigger: "blur"}
],
initNum: [
{required: true, message: "初始连接数量不能为空", trigger: "blur"}
],
maxNum: [
{required: true, message: "最大连接数量不能为空", trigger: "blur"}
],
maxWaitTime: [
{required: true, message: "最大等待时间不能为空", trigger: "blur"}
],
maxWaitSize: [
{required: true, message: "最大等待次数不能为空", trigger: "blur"}
],
modeName:[
{required: true, message: "数据源模式不能为空", trigger: "blur"}
]
},
dataSourceParamList: [
{
name: null,
val: null
}
],
],
sourceList: [],
assetsList:[],
structureList:[],
tableAssets:[],
defaultProps: {
children: 'tableList',
label: 'label'
},
sourceData:{},
source:{
sql:''
},
statisticsInfo:{}
}; };
}, },
created() { // data",
this.getList(); computed: {},
//data",
}, watch: {},
//",
methods: { methods: {
test(data){
console.log("红红火火恍恍惚惚哈哈哈哈",data)
this.sourceData = data
},
synchronization(data){ handleNodeClick(data) {
synchronization(data).then(res=>{ if (data.dataType === 'dataSource'){
console.log(res) dataAssetList(data).then(res => {
if (res.code == 200){ console.log(res)
this.$message({ res.data.forEach(table => {
message:("成功") table.dataType = "dataTable"
table.label=table.tableName+"-"+table.tableComment+"("+table.tableCount+"条)"
}) })
}else{ data.tableList = res.data
this.$message({ this.sourceList[this.sourceList.indexOf(data)].tableList = res.data
message:("失败") this.title = data
}) })
}
})
},
addParam(){
this.dataSourceParamList.push({
name:null,
val:null
})
},
deleteParam(){
if (index!=null){
this.dataSourceParamList.splice(index,1)
}else{ }else{
this.dataSourceParamList = [] this.title= data
} }
this.processParam() this.showAssets = data.dataType
}, },
processParam(){ sql(){
this.form.connectionParam= this.dataSourceParamList structureList(this.source).then(res => {
.filter(item=>item.name !=null || item .val!=null) this.structureList = res.data.kvtList
.map(ite =>{
return ite.name + "=" + ite.val
}).join("&")
},
//
test(datasource){
test(datasource).then(res=>{
if (res.code == 200){
this.$message({
message:("成功")
})
}else{
this.$message({
message:("失败")
})
}
}) })
}, },
/** 查询数据源列表 */
getList() { getList() {
this.loading = true;
listDatasource(this.queryParams).then(response => { listDatasource(this.queryParams).then(response => {
console.log(response) this.sourceList = response.data.rows;
this.datasourceList = response.data.rows; console.log(this.sourceList)
this.loading = false; this.sourceList.forEach(source => {
}); if (source.type=='PostGre'){
}, source.label=source.dataSourceName+'('+source.databaseName+'-'+source.modeName+'-'+source.systemName+')'
// }else{
cancel() { source.label=source.dataSourceName+'('+source.databaseName+'-'+source.systemName+')'
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
port: null,
username: null,
password: null,
linkAddress: null,
dataSourceName: null,
databaseName: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加数据源";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getDatasource(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改数据源";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateDatasource(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addDatasource(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
} }
}
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;
}); });
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除数据源编号为"' + ids + '"的数据项?').then(function() {
return delDatasource(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('etl/datasource/export', {
...this.queryParams
}, `datasource_${new Date().getTime()}.xlsx`)
} }
},
// - 访this",
created() {
this.getList()
},
// - 访DOM",
mounted() {
} }
}; };
</script> </script>
<style scoped>
.el-header {
background-color: #B3C0D1;
color: #333;
line-height: 60px;
}
.el-aside {
color: #333;
}
</style>