feat:资产授权(初)

master
Jiang Peng 2024-05-01 14:45:21 +08:00
parent d91af21fed
commit e1d2e84519
10 changed files with 615 additions and 620 deletions

View File

@ -0,0 +1,61 @@
import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listAccredit(query) {
return request({
url: '/etl/assetAccredit/list',
method: 'get',
params: query
})
}
// 根据表id查询授权信息
export function getAssetAccreditByDataAssetId(id) {
return request({
url: '/etl/assetAccredit/GetAssetAccreditByDataAssetId?id='+id,
method: 'get'
})
}
// 查询【请填写功能名称】详细
export function getAccredit(id) {
return request({
url: '/etl/assetAccredit/' + id,
method: 'get'
})
}
// 新增【请填写功能名称】
export function addAssetAccredit(data) {
return request({
url: '/etl/assetAccredit',
method: 'post',
data: data
})
}
// 新增【请填写功能名称】
export function deleteAssetAccreditByAssetIds(data) {
return request({
url: '/etl/assetAccredit/DeleteAssetAccreditByAssetIds',
method: 'post',
data: data
})
}
// 修改【请填写功能名称】
export function updateAccredit(data) {
return request({
url: '/etl/assetAccredit',
method: 'put',
data: data
})
}
// 删除【请填写功能名称】
export function delAccredit(id) {
return request({
url: '/etl/assetAccredit/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listData(query) {
return request({
url: '/etl/data/list',
method: 'get',
params: query
})
}
// 查询【请填写功能名称】详细
export function getData(id) {
return request({
url: '/etl/data/' + id,
method: 'get'
})
}
// 新增【请填写功能名称】
export function addData(data) {
return request({
url: '/etl/data',
method: 'post',
data: data
})
}
// 修改【请填写功能名称】
export function updateData(data) {
return request({
url: '/etl/data',
method: 'put',
data: data
})
}
// 删除【请填写功能名称】
export function delData(id) {
return request({
url: '/etl/data/' + id,
method: 'delete'
})
}

View File

@ -0,0 +1,93 @@
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

@ -0,0 +1,61 @@
import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listAccredit(query) {
return request({
url: '/etl/sourceAccredit/list',
method: 'get',
params: query
})
}
// 根据数据源id查询授权信息
export function getSourceAccreditByDataSourceId(id) {
return request({
url: '/etl/sourceAccredit/GetSourceAccreditByDataSourceId?id='+id,
method: 'get'
})
}
// 查询【请填写功能名称】详细
export function getAccredit(id) {
return request({
url: '/etl/sourceAccredit/' + id,
method: 'get'
})
}
// 新增【请填写功能名称】
export function addSourceAccredit(data) {
return request({
url: '/etl/sourceAccredit',
method: 'post',
data: data
})
}
// 新增【请填写功能名称】
export function deleteSourceAccreditBySourceIds(data) {
return request({
url: '/etl/sourceAccredit/DeleteSourceAccreditBySourceIds',
method: 'post',
data: data
})
}
// 修改【请填写功能名称】
export function updateAccredit(data) {
return request({
url: '/etl/sourceAccredit',
method: 'put',
data: data
})
}
// 删除【请填写功能名称】
export function delAccredit(id) {
return request({
url: '/etl/sourceAccredit/' + id,
method: 'delete'
})
}

View File

@ -5,17 +5,17 @@
<el-row>
<el-col :offset="2" :span="8">
<el-form-item label="数据接入名称" prop="nickName">
<el-input v-model="baseInfo.name" disabled/>
<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="baseInfo.systemName" disabled/>
<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="baseInfo.databaseName" disabled/>
<el-input v-model="title.databaseName" disabled/>
</el-form-item>
</el-col>
</el-row>
@ -44,6 +44,7 @@
<el-switch
style="display: block"
v-model="scope.row.isAuth"
@change="authChange(scope.row)"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
@ -52,7 +53,6 @@
</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">
@ -67,6 +67,7 @@
<el-switch
style="display: block"
v-model="scope.row.isAuth"
@change="authChange(scope.row)"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
@ -75,7 +76,7 @@
</template>
</el-table-column>
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
<pagination v-show="userQueryParams.total> 0" :limit.sync="userQueryParams.pageSize" :page.sync="userQueryParams.pageNum" :total="userQueryParams.total"/>
</el-tab-pane>
</el-tabs>
</div>
@ -84,39 +85,150 @@
<script>
import { parseTime } from '@/utils/muyu'
import {
addSourceAccredit,
deleteSourceAccreditBySourceIds,
getSourceAccreditByDataSourceId
} from "@/api/etl/sourceAccredit";
import {listUser} from "@/api/system/user";
import {listDept} from "@/api/system/dept";
export default {
watch:{
'title':{
handler(val){
console.log(val)
this.getSourceAccreditByDataSourceId()
},
immediate:true
}
},
name: "AuthDataSource",
data() {
return {
//
loading: true,
activeName: "dept",
userQueryParams:{
pageNum : 1,
pageSize:10,
total:0
},
sourceAccreditReq:{
deptIds: null,
userId: null,
dataSourceId: null
},
//
total: 0,
pageNum: 1,
pageSize: 1,
//
baseInfo: {
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
},
//
deptList: [],
//
userList: []
userList: [],
userAccreditIds:[],
deptAccreditIds:[]
};
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
this.init()
},
props:{
title:{}
},
methods: {
recursion(deptInfo){
let ids =[]
ids.push(deptInfo.deptId)
if (deptInfo.children){
deptInfo.children.forEach(item => {
ids.push(item.deptId)
if (item.children){
ids.push(...this.recursion(item))
}
})
}
return ids
},
authChange(row) {
this.sourceAccreditReq={
deptIds:null,
userId: null,
dataSourceId: null
}
if (row.nickName){
this.sourceAccreditReq.userId = row.userId
this.sourceAccreditReq.dataSourceId = this.title.id
}else{
let ids=this.recursion(row)
const uniqueIds = [...new Set(ids)];
this.sourceAccreditReq.deptIds = uniqueIds
this.sourceAccreditReq.dataSourceId = this.title.id
}
if (row.isAuth){
addSourceAccredit(this.sourceAccreditReq).then(res => {
this.getSourceAccreditByDataSourceId()
})
}else{
deleteSourceAccreditBySourceIds(this.sourceAccreditReq).then(res => {
this.getSourceAccreditByDataSourceId()
})
}
},
parseTime,
init() {
}
getSourceAccreditByDataSourceId(){
if (this.title.id != undefined){
getSourceAccreditByDataSourceId(this.title.id).then(response => {
console.log(response,"少时诵诗书")
this.deptAccreditIds = response.data.deptAccreditModelIds
this.userAccreditIds = response.data.userAccreditModelIds
setTimeout(() => this.getList(), 50)
setTimeout(() => this.getUserList(), 50)
})
}
},
recursionAuth(deptInfo){
deptInfo.isAuth = this.deptAccreditIds.indexOf(deptInfo.deptId) > -1
if (deptInfo.children){
deptInfo.children.forEach(item => {
item.isAuth = this.deptAccreditIds.indexOf(item.deptId) > -1
if (item.children){
this.recursionAuth(item)
}
})
}
},
/** 查询部门列表 */
getList() {
listDept(this.queryParams).then(response => {
this.deptList = this.handleTree(response.data, "deptId");
this.deptList.forEach(dept => {
this.recursionAuth(dept)
})
console.log(this.deptList)
this.loading = false;
});
},
/** 查询用户列表 */
getUserList() {
listUser(this.addDateRange(this.userQueryParams, [])).then(response => {
this.userList = response.data.rows;
this.userList.forEach(user => {
user.isAuth = this.userAccreditIds.indexOf(user.userId) > -1
})
this.userQueryParams.total = response.data.total;
}
);
},
},
};
</script>

View File

@ -1,36 +1,37 @@
<template>
<div class="app-container">
{{deptAccreditIds}}
<h4 class="form-header h4">基本信息</h4>
<el-form ref="form" :model="baseInfo" label-width="120px">
<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="baseInfo.name" disabled/>
<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="baseInfo.systemName" disabled/>
<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="baseInfo.databaseName" disabled/>
<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="baseInfo.tableName" disabled/>
<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="baseInfo.tableAsName" disabled/>
<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="baseInfo.total" disabled/>
<el-input v-model="title.tableCount" disabled/>
</el-form-item>
</el-col>
</el-row>
@ -59,6 +60,7 @@
<el-switch
style="display: block"
v-model="scope.row.isAuth"
@change="authChange(scope.row)"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
@ -67,7 +69,6 @@
</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">
@ -82,6 +83,7 @@
<el-switch
style="display: block"
v-model="scope.row.isAuth"
@change="authChange(scope.row)"
active-color="#13ce66"
inactive-color="#ff4949"
active-text="已授权"
@ -90,7 +92,7 @@
</template>
</el-table-column>
</el-table>
<pagination v-show="total> 0" :limit.sync="pageSize" :page.sync="pageNum" :total="total"/>
<pagination v-show="userQueryParams.total> 0" :limit.sync="userQueryParams.pageSize" :page.sync="userQueryParams.pageNum" :total="userQueryParams.total"/>
</el-tab-pane>
</el-tabs>
</div>
@ -100,69 +102,140 @@
import { parseTime } from '@/utils/muyu';
import {listDept} from "@/api/system/dept";
import {listRole} from "@/api/system/role";
import {listDatasource} from "@/api/etl/datasource";
import {listUser} from "@/api/system/user";
import {addAssetAccredit, deleteAssetAccreditByAssetIds, getAssetAccreditByDataAssetId} from "@/api/etl/assetAccredit";
export default {
watch:{
'title':{
handler(val){
console.log("啦啦啦",val)
this.getAssetAccreditByDataAssetId()
},
immediate:true
}
},
name: "AuthTable",
data() {
return {
refreshTable: true,
//
loading: true,
activeName: "dept",
//
total: 0,
pageNum: 1,
pageSize: 1,
//
baseInfo: {
name: "1",
systemName: "111",
databaseName: "ry_cloud",
tableName: "sys_user",
tableAsName: "用户表",
total: "3条",
//
userQueryParams: {
pageNum: 1,
pageSize: 10,
total: 0
},
//
deptList: [],
//
userList: [],
arr:[],
source:{}
deptAccreditIds:[],
userAccreditIds:[],
AssetAccreditReq:{
deptIds: null,
userId: null,
dataAssetId: null
},
};
},
props:{
title:{}
},
created() {
this.loading = true;
setTimeout(() => this.loading = false, 200)
this.init()
this.getListDept()
this.getListRole()
this.getSource()
},
methods: {
getSource(){
listDatasource(this.source).then(res=>{
authChange(row){
this.AssetAccreditReq={
deptIds:null,
userId: null,
dataAssetId: null
}
if (row.nickName){
this.AssetAccreditReq.userId = row.userId
this.AssetAccreditReq.dataAssetId = this.title.id
}else{
let ids=this.recursion(row)
const uniqueIds = [...new Set(ids)];
this.AssetAccreditReq.deptIds = uniqueIds
this.AssetAccreditReq.dataAssetId = this.title.id
}
if (row.isAuth){
addAssetAccredit(this.AssetAccreditReq).then(res => {
this.getAssetAccreditByDataAssetId()
})
}else{
deleteAssetAccreditByAssetIds(this.AssetAccreditReq).then(res => {
this.getAssetAccreditByDataAssetId()
})
}
},
getAssetAccreditByDataAssetId(){
getAssetAccreditByDataAssetId(this.title.id).then(res =>{
console.log(res)
this.arr=res.data.rows
this.deptAccreditIds=res.data.daptAccreditModelIds
this.userAccreditIds=res.data.userAccreditModelIds
setTimeout(() => this.getDeptList(),50)
setTimeout(() => this.getUserList,50)
})
},
getListDept(){
listDept().then(res=>{
this.deptList=res.data
console.log(res)
})
},
getListRole(){
listUser().then(res=>{
console.log(res)
this.userList=res.data.rows
})
},
parseTime,
init(){
}
recursion(deptInfo){
let ids = []
ids.push(deptInfo.deptId)
if (deptInfo.children){
deptInfo.children.forEach(item=>{
ids.push(item.deptId)
if (item.children){
ids.push(...this.recursion(item))
}
})
}
return ids
},
recursionAuth(deptInfo){
console.log("列表出不来啊:",deptInfo)
deptInfo.isAuth = this.deptAccreditIds.indexOf(deptInfo.deptId) > -1
if (deptInfo.children){
deptInfo.children.forEach(item =>{
item.isAuth = this.deptAccreditIds.indexOf(item.deptId) > -1
if (item.children){
this.recursionAuth(item)
}
})
}
},
/** 查询部门列表 */
getDeptList() {
this.loading = true;
listDept(this.queryParams).then(response => {
console.log("部门",response)
this.deptList = this.handleTree(response.data, "deptId");
this.deptList.forEach(dept => {
this.recursionAuth(dept)
})
this.loading = false;
});
},
/** 查询用户列表 */
getUserList() {
this.loading = true;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.userList = response.data.rows;
this.userList.forEach(user => {
user.isAuth = this.userAccreditIds.indexOf(user.userId) > -1
})
this.userQueryParams.total = response.data.total;
}
);
},
parseTime,
},
};
</script>

View File

@ -7,10 +7,6 @@
lazy
@node-click="(data) => showAuth=data.type"
:props="defaultProps">
<!-- <div class="custom-tree-node" slot-scope="{ node, data }">-->
<!-- <div v-if="data.type === 'dataSource'">{{ data.name + '('+data.databaseName + '-' + data.systemName+')' }}</div>-->
<!-- <div v-if="data.type === 'dataTable'">{{ data.name + '-'+data.as + '(' + data.dataTotal+')' }}</div>-->
<!-- </div>-->
</el-tree>
</el-aside>
<el-container>

View File

@ -42,6 +42,7 @@
</el-table-column>
<el-table-column prop="defaultValue" label="默认值" />
<el-table-column prop="isDict" label="是否字典" >
<template slot-scope="scope">
<el-tag v-if="scope.row.isDict === 'Y'" size="small" type="success">
{{scope.row.isDict}}
@ -55,13 +56,9 @@
placement="left"
width="200"
trigger="hover">
<el-table :data="[
{ label: '男', value: '1' },
{ label: '女', value: '2' },
{ label: '未知', value: '0' },
]">
<el-table-column property="label" label="字典标签"/>
<el-table-column property="value" label="字典值"/>
<el-table :data="dictList">
<el-table-column prop="label" label="字典标签"/>
<el-table-column prop="val" label="字典值"/>
</el-table>
<el-tag slot="reference">{{scope.row.dictKey}}</el-tag>
</el-popover>
@ -173,7 +170,8 @@
</template>
<script>
import {assetModelList, UpdateAssetModel} from "@/api/etl/datasource";
import {getDictionaryList} from "@/api/etl/dictionary";
import {getDictionaryList, listDictionary} from "@/api/etl/dictionary";
import {listData} from "@/api/etl/data";
export default {
name: 'OverallAssetStructure',
@ -205,6 +203,11 @@ export default {
},
data() {
return {
dictList:[{
label:null,
val:null,
dataSourceId:null,
}],
dictionaryDataList:[],
tableData: [],
form: {},
@ -212,7 +215,17 @@ export default {
dictMap: {}
}
},
created() {
this.listDictionary()
},
methods: {
listDictionary(){
console.log("这是什么",this.title.id)
listData(this.title.id).then(res=>{
console.log("这是字典",res)
this.dictList = res.data.rows
})
},
getDictionaryList(){
getDictionaryList(this.title.dataSourceId).then(res=>{
this.dictMap = res.data

View File

@ -48,48 +48,56 @@
<el-form-item label="字典名称">
<el-input v-model="dictInfo.dictionaryName" style="width: 150px "> </el-input>
</el-form-item>
<el-form-item label="字典值">
<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-form-item>
</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>
</div>
<el-row :gutter="20">
<el-col v-for="dict in dictMap" :md="8" :sm="24" :xs="12">
<el-card class="box-card" style="height: 300px">
<div slot="header" class="clearfix">
<span>{{dict.dictionaryName+'('+dict.dictionaryKey+')'}}</span>
<span>{{dict.dictionaryName+'('+dict.dictionaryKey+')'}}</span>
<el-button style="float: right; padding: 3px 0" type="text" @click="delDict(dict.id)"></el-button>
<el-button style="float: right; padding: 3px 0" type="text" @click="dict.dictionaryDataList.push({label:null,val:null,edit:true})"></el-button>
<el-button style="float: right; padding: 3px 0" type="text" @click="dict.dictionaryDataList.push({ label: null, val: null, isEdit: true})">新增</el-button>
</div>
<el-table :data="dict.dictionaryDataList" style="width: 100%" height="280px">
<el-table-column prop="label" label="标签">
<template slot-scope="scope">
<span v-if="!scope.row.edit">{{scope.row.label}}</span>
<el-input v-if="scope.row.edit" v-model="scope.row.label" size="mini"></el-input>
<span v-if="!scope.row.isEdit">{{scope.row.label}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.label" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column prop="val" label="值">
<template slot-scope="scope">
<span v-if="!scope.row.edit">{{scope.row.val}}</span>
<el-input v-if="scope.row.edit" v-model="scope.row.val" size="mini"></el-input>
<span v-if="!scope.row.isEdit">{{scope.row.val}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.val" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column prop="val" label="操作">
<template slot-scope="scope">
<el-button
v-if="!scope.row.edit"
v-if="!scope.row.isEdit"
size="mini"
type="text"
icon="el-icon-edit"
@click="scope.row.edit = true"
@click="upda(scope.row)"
>修改</el-button>
<el-button
v-if="scope.row.edit"
v-if="!scope.row.isEdit"
size="mini"
type="text"
icon="el-icon-delete-solid"
@click="deleteDictionary(scope.row.id)"
>删除</el-button>
<el-button
v-if="scope.row.isEdit"
@click="editConfirm(dict,scope.row)"
size="mini"
type="text"
@ -105,7 +113,7 @@
<el-col :span="24">
<el-tabs v-model="activeName" type="card">
<el-tab-pane v-for="tableAsset in title.tableList" :label="tableAsset.tableName+'('+tableAsset.tableComment+')'" :name="tableAsset.tableName">
<overall-asset-structure v-if="activeName == tableAsset.tableName" :title="tableAsset"></overall-asset-structure>
<overall-asset-structure v-if="activeName == tableAsset.tableName" :title="tableAsset"></overall-asset-structure>
</el-tab-pane>
</el-tabs>
@ -117,8 +125,8 @@
<script>
import CountTo from 'vue-count-to'
import OverallAssetStructure from './OverallAssetStructure.vue'
import {addDictionary, getDictionaryList} from "@/api/etl/dictionary";
import {addData, updateData} from "@/api/etl/data";
import {addDictionary, delDict, deleteDictionary, getDictionaryList} from "@/api/etl/dictionary";
import {addData, delById, updateData} from "@/api/etl/data";
export default {
watch:{
@ -171,27 +179,75 @@ export default {
created() {
},
methods: {
delDict(){},
deleteDictionary(id){
console.log("删除的Id",id)
delById(id).then(res=>{
if (res.code==200){
this.$message.success('删除成功')
this.getDictionaryList()
}else{
this.$message.error('删除失败')
}
})
},
upda(row){
console.log(row)
console.log(this.dictMap)
this.dictMap.forEach(dict=>{
if (dict.dictionaryDataList.indexOf(row)>-1){
dict.dictionaryDataList.forEach(dictData=>{
if (dictData.id === row.id){
dictData.isEdit = true
}
})
}
})
},
delDict(id){
delDict(id).then(res=>{
this.getDictionaryList()
})
},
getDictionaryList(){
console.log(this.title)
getDictionaryList(this.title.id).then(res=>{
console.log("=========",res)
console.log("这个也是字典",res)
this.dictMap = res.data
console.log("一样一样一月又一月呀呀呀呀呀",this.dictMap)
})
},
editConfirm(dict,row){
console.log(row)
if (!row.label || !row.val) {
this.$message.error('字典标签或字典值,不可为空');
return;
}
if (row.id){
updateData(row)
updateData(row).then(res=>{
this.dictMap.forEach(dict=>{
if (dict.dictionaryDataList.indexOf(row)>-1){
dict.dictionaryDataList.forEach(dictData=>{
if (dictData.id === row.id){
dictData.isEdit = false
}
})
}
})
})
}else{
row.dictionaryId =dict.id
addData(row)
addData(row).then(res=>{
this.dictMap.forEach(dict=>{
if (dict.dictionaryDataList.indexOf(row)>-1){
dict.dictionaryDataList.forEach(dictData=>{
if (dictData.id === row.id){
dictData.isEdit = false
}
})
}
})
})
}
row.edit = false;
this.getDictionaryList()
},
addDict(){
if (!this.dictInfo.dictionaryName){
@ -200,14 +256,23 @@ export default {
}
if (!this.dictInfo.dictionaryKey){
this.$message("数据值,不能为空")
addDictionary(this.dictInfo)
this.dictInfo={
dictionaryName:null,
dictionaryKey: null,
dataSourceId: null
}
this.getDictionaryList()
}
this.dictInfo.dataSourceId = this.title.id
addDictionary(this.dictInfo).then(res=>{
console.log("这是什么值",res)
if (res.code == 200){
this.$message.success("添加成功")
this.getDictionaryList()
}else{
this.$message.error("添加失败")
}
})
this.dictInfo={
dictionaryName:null,
dictionaryKey: null,
dataSourceId: null
}
this.getDictionaryList()
},
handleSetLineChartData(type) {
this.$emit('handleSetLineChartData', type)

View File

@ -1,523 +0,0 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="数据源名称" prop="dataSourceName" label-width="100px">
<el-input
v-model="queryParams.dataSourceName"
placeholder="请输入数据源名称"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="数据源链接地址" prop="linkAddress" label-width="120px">
<el-input
v-model="queryParams.linkAddress"
placeholder="请输入数据源链接地址"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:source:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
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="sourceList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="数据源名称" align="center" prop="dataSourceName" />
<el-table-column label="数据源连接地址" align="center" prop="linkAddress" />
<el-table-column label="数据源连接端口" align="center" prop="port" />
<el-table-column label="数据库名称" align="center" prop="databaseName" />
<el-table-column label="连接用户名" align="center" prop="username" />
<el-table-column label="连接密码" align="center" prop="password" />
<el-table-column label="备注" align="center" prop="remark" />
<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-edit"
@click="testConnection(scope.row)"
>测试连接</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="synchronousData(scope.row)"
>同步资产</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:source:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['system:source:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改请填写功能名称对话框 -->
<el-dialog :title="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>
</template>
<script>
import { listSource, getSource, delSource, addSource, updateSource, testConnection, synchronousData } from "@/api/etl/source";
export default {
name: "Source",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
sourceList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
dataSourceName: null,
linkAddress: null
},
//
form: {},
//
rules: {
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"}
]
},
dataSourceParamList: [
{
name: null,
val: null
}
]
};
},
created() {
this.getList();
},
methods: {
synchronousData(data) {
synchronousData(data).then(res => {
if (res.code === 200) {
this.$message({
message: "同步成功",
type: "success"
});
} else {
this.$message({
message: "同步失败",
type: "error"
});
}
})
},
//
addParam(){
this.dataSourceParamList.push({
name: null,
val: null
})
},
//
deleteParam(index){
if (index != null){
this.dataSourceParamList.splice(index, 1);
}else {
this.dataSourceParamList = []
}
this.processParam();
},
//
processParam(){
this.form.connectionParam = this.dataSourceParamList
.filter(item => item.name != null || item.val != null)
.map(item => {
return item.name + "=" + item.val;
}).join("&")
console.log(this.form.connectionParam)
},
/** 测试连接 */
testConnection(row) {
testConnection(row).then(res => {
if (res.code === 200) {
this.$message({
message: "连接成功",
type: "success"
});
} else {
this.$message({
message: "连接失败",
type: "error"
});
}
})
},
/** 查询数据源列表 */
getList() {
this.loading = true;
listSource(this.queryParams).then(response => {
this.sourceList = response.data.rows;
this.total = response.data.total;
console.log(this.sourceList)
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
dataSourceName: null,
type: null,
systemName: null,
username: null,
password: null,
linkAddress: null,
port: null,
databaseName: null,
connectionParam: null,
initNum: null,
maxNum: null,
maxWaitTime: null,
maxWaitSize: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
remark: 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.dataSourceParamList = [];
this.title = "添加数据接入";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getSource(id).then(response => {
this.form = response.data;
console.log(this.form)
this.dataSourceParamList = [];
this.form.connectionParam.split("&").forEach(param => {
let paramArr = param.split("=");
this.dataSourceParamList.push({
name: paramArr[0],
val: paramArr[1]
})
})
this.open = true;
this.title = "修改数据接入";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateSource(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addSource(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + ids + '"的数据项?').then(function() {
return delSource(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/source/export', {
...this.queryParams
}, `source_${new Date().getTime()}.xlsx`)
}
}
};
</script>