feat()资产模型字典表的关联,编辑

dev-1
王熙朝 2024-04-26 22:42:42 +08:00
parent 99701fef6d
commit 744c5c6da2
8 changed files with 246 additions and 74 deletions

View File

@ -57,6 +57,19 @@ export function selectTable(libraryName) {
}) })
} }
export function oneDataAccess(data) {
return request({
url: '/system/access/oneDataAccess',
method: 'post',
data
})
}
/**
* 同步
* @param data
* @returns {AxiosPromise}
*/
export function synchronization(data) { export function synchronization(data) {
return request({ return request({
url: '/system/access/synchronization', url: '/system/access/synchronization',
@ -66,3 +79,5 @@ export function synchronization(data) {
} }

View File

@ -1,9 +1,9 @@
import request from '@/utils/request' import request from '@/utils/request'
// 查询数据接入列表 // 查询数据接入列表
export function tableNameList() { export function tableNameList(databaseName) {
return request({ return request({
url: '/system/accredit/tableNameList', url: '/system/accredit/tableNameList/' + databaseName,
method: 'post' method: 'post'
}) })
} }
@ -74,4 +74,24 @@ export function updateListStructure(data) {
}) })
} }
/**
* 查看父类表
* @param data
* @returns {*}
*/
export function selectFrimary(data) {
return request({
url: '/system/accredit/selectFrimary',
method: 'post',
data
})
}
export function listMiddle(name) {
return request({
url: '/system/accredit/listMiddle?name=' + name,
method: 'post'
})
}

View File

@ -0,0 +1,68 @@
import request from '@/utils/request'
// 查询数据接入列表
export function listDictType(data) {
return request({
url: '/system/dicts/listDictType',
method: 'post',
data
})
}
export function selDictData(dictType) {
return request({
url: '/system/dicts/selDictData/' + dictType,
method: 'post'
})
}
/**
* 新增字典
* @param data
* @returns {AxiosPromise}
*/
export function indexDictType(dictType) {
return request({
url: '/system/dicts/indexDictType/' + dictType,
method: 'post'
})
}
/**
* 添加字典字段
* @param data
* @returns {AxiosPromise}
*/
export function indexDictData(data) {
return request({
url: '/system/dicts/indexDictData',
method: 'post',
data
})
}
/**
* 删除字典字段
* @param data
* @returns {AxiosPromise}
*/
export function deleteDictData(data) {
return request({
url: '/system/dicts/deleteDictData',
method: 'post',
data
})
}
/**
* 查询详情
* @param data
* @returns {AxiosPromise}
*/
export function selectDictData(data) {
return request({
url: '/system/dicts/selectDictData',
method: 'post',
data
})
}

View File

@ -136,6 +136,13 @@
@click="handleDelete(scope.row)" @click="handleDelete(scope.row)"
v-hasPermi="['system:access:remove']" v-hasPermi="['system:access:remove']"
>删除</el-button> >删除</el-button>
<el-button
size="mini"
icon="el-icon-edit"
:load="expandTable"
@click="ttbb(scope.row)"
v-hasPermi="['system:access:remove']"
>同协</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -179,6 +186,18 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row>
<el-col :md="12" :sm="24">
<el-form-item label="用户名" prop="username">
<el-input v-model="form.username" placeholder="请输入用户名"></el-input>
</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-input>
</el-form-item>
</el-col>
</el-row>
<el-row> <el-row>
<el-col :md="12" :sm="24"> <el-col :md="12" :sm="24">
<el-form-item label="数据库名称" prop="databaseName"> <el-form-item label="数据库名称" prop="databaseName">
@ -274,6 +293,7 @@
<el-button @click="cancel"> </el-button> <el-button @click="cancel"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
@ -281,10 +301,13 @@
import { listAccess, getAccess, delAccess, addAccess, updateAccess, synchronization } from "@/api/system/access"; import { listAccess, getAccess, delAccess, addAccess, updateAccess, synchronization } from "@/api/system/access";
import { selJDBCStream } from "@/api/system/accredit"; import { selJDBCStream } from "@/api/system/accredit";
import Table from '@/views/assets/table/index.vue'
import Authorization from '@/views/assets/authorization/index.vue'
export default { export default {
name: "Access", name: "Access",
data() { data() {
return { return {
accessId: '',
// //
loading: true, loading: true,
// //
@ -346,6 +369,12 @@ export default {
port: [ port: [
{ required: true, message: "端口号不能为空", trigger: "blur" } { required: true, message: "端口号不能为空", trigger: "blur" }
], ],
username: [
{ required: true, message: "端口号不能为空", trigger: "blur" }
],
password: [
{ required: true, message: "端口号不能为空", trigger: "blur" }
],
databaseName: [ databaseName: [
{ required: true, message: "数据库名称不能为空", trigger: "blur" } { required: true, message: "数据库名称不能为空", trigger: "blur" }
], ],
@ -380,6 +409,23 @@ export default {
this.getList(); this.getList();
}, },
methods: { methods: {
expandTable( node, resolve){
if (node.level === 0) return resolve(this.assetStructureList);
const {data} = node;
this.showAssets = data.type;
if (data.type === 'dataTable') {
this.tableName = data.name
return resolve([])
}
setTimeout(() => {
resolve(this.childrenList)
}, 500);
},
ttbb(row){
this.accessId = row.id
console.log(row)
},
// //
synchronizations(row){ synchronizations(row){
synchronization(row).then(res => { synchronization(row).then(res => {
@ -409,7 +455,6 @@ export default {
.map(item => { .map(item => {
return item.name + "=" + item.val; return item.name + "=" + item.val;
}).join("&") }).join("&")
console.log(this.form.connectionParam)
}, },
/** 查询数据接入列表 */ /** 查询数据接入列表 */
getList() { getList() {
@ -418,7 +463,6 @@ export default {
this.accessList = response.data.rows; this.accessList = response.data.rows;
this.total = response.data.total; this.total = response.data.total;
this.loading = false; this.loading = false;
console.log(this.accessList)
}); });
}, },
// //
@ -471,7 +515,12 @@ export default {
handleCes(row) { handleCes(row) {
console.log(row) console.log(row)
selJDBCStream(row).then(res => { selJDBCStream(row).then(res => {
this.$message.success(res.data) if (res.data == null){
this.$message.error('连接失败')
}else{
this.$message.success('连接成功')
}
}) })
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
@ -514,7 +563,6 @@ export default {
}, },
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
console.log(row)
const ids = row.id || this.ids; const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除数据接入编号为"' + ids + '"的数据项?').then(function() { this.$modal.confirm('是否确认删除数据接入编号为"' + ids + '"的数据项?').then(function() {
return delAccess(ids); return delAccess(ids);

View File

@ -153,12 +153,12 @@ import {
selNameListStructure, selNameListStructure,
updateListStructure updateListStructure
} from '@/api/system/accredit' } from '@/api/system/accredit'
import data from "@/views/system/dict/data.vue"
export default { export default {
props: { props: {
title: { title: {
tableName: String, type: Object
default: null
}, },
}, },
name: 'OverallAssetStructure', name: 'OverallAssetStructure',
@ -207,17 +207,17 @@ export default {
}) })
}, },
init() { init() {
if (this.title == null){ console.log(this.title)
if (this.title === null){
listListstructure().then(res => { listListstructure().then(res => {
this.childrenList = res.data this.childrenList = res.data
}) })
console.log(this.childrenList)
}else{ }else{
selNameListStructure(this.title).then(res => { selNameListStructure(this.title).then(res => {
this.childrenList = res.data this.childrenList = res.data
}) })
console.log(this.childrenList)
} }
} }
}, },
// - 访this", // - 访this",

View File

@ -54,7 +54,6 @@ export default {
}, },
methods: { methods: {
handleSetLineChartData(type) { handleSetLineChartData(type) {
console.log(type)
this.$emit('handleSetLineChartData', type) this.$emit('handleSetLineChartData', type)
} }
} }

View File

@ -60,23 +60,23 @@
<el-col v-for="(val,key) in dictMap" :md="8" :sm="24" :xs="12"> <el-col v-for="(val,key) 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>{{val.dictType}}</span>
<el-button style="float: right; padding: 3px 0" <el-button style="float: right; padding: 3px 0"
type="text" type="text"
@click="val.push({ label: null, val: null, isEdit: true })" @click="val.dictDataList.push({ dictCode:val.dictDataList.dictCode , dictType:val.dictType, dictLabel: null, dictValue: null, isEdit: true })"
>新增</el-button> >新增</el-button>
</div> </div>
<el-table :data="val" style="width: 100%" height="280px"> <el-table :data="val.dictDataList" 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.isEdit">{{scope.row.dictLabel}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.label" size="mini"></el-input> <el-input v-if="scope.row.isEdit" v-model="scope.row.dictLabel" 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.isEdit">{{scope.row.dictValue}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.val" size="mini"></el-input> <el-input v-if="scope.row.isEdit" v-model="scope.row.dictValue" size="mini"></el-input>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="val" label="操作"> <el-table-column prop="val" label="操作">
@ -86,8 +86,15 @@
size="mini" size="mini"
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="scope.row.isEdit = true" @click="updData(scope.row)"
>修改</el-button> >修改</el-button>
<el-button
v-if="!scope.row.isEdit"
size="mini"
type="text"
icon="el-icon-edit"
@click="delData(scope.row)"
>删除</el-button>
<el-button <el-button
v-if="scope.row.isEdit" v-if="scope.row.isEdit"
@click="editConfirm(scope.row)" @click="editConfirm(scope.row)"
@ -105,11 +112,11 @@
</el-col> </el-col>
<el-col :span="24" style="margin-top: 20px"> <el-col :span="24" style="margin-top: 20px">
<el-tabs v-model="activeName" type="border-card"> <el-tabs v-model="activeName" type="border-card" @tab-click="checkTableName">
<el-tab-pane label="sys_user(用户表)" name="first"> <el-tab-pane v-for="table in tableList" :label="table.tableName+'('+table.tableAsName+')'"
<overall-asset-structure/> :name="table.tableName">
<overall-asset-structure v-if="table.tableName === tableParams.tableName" :table-params="tableParams"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="sys_dept(部门表)" name="second">sys_dept(部门表)</el-tab-pane>
</el-tabs> </el-tabs>
</el-col> </el-col>
</el-row> </el-row>
@ -119,6 +126,8 @@
<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 { listDictType, indexDictType, indexDictData, deleteDictData, selectDictData } from "@/api/system/dicts"
import val from "quill";
export default { export default {
props: { props: {
@ -131,16 +140,15 @@ export default {
return { return {
activeName: null, activeName: null,
dictAddName: null, dictAddName: null,
dictMap: { dictMap: [],
"性别(system_sex)": [ tableList: [],
{ label: '男', val: '1', isEdit: false }, tableParams: null,
{ label: '女', val: '2', isEdit: false }, dictData: {
{ label: '未知', val: '0', isEdit: false }, dictCode: '',
], dictType: '',
"开关(system_y_n)": [ dictLabel: '',
{ label: '是', val: '1', isEdit: false }, dictValue: '',
{ label: '否', val: '0', isEdit: false } isEdit: false,
],
} }
} }
}, },
@ -149,25 +157,66 @@ export default {
CountTo CountTo
}, },
methods: { methods: {
val() {
return val
},
checkTableName(checkTab){
this.tableParams = this.tableList.findLast(item => item.tableName === checkTab.name)
},
updData(row) {
console.log(row)
selectDictData(row).then(res => {
this.dictData = res.data
})
this.dictData = true
},
editConfirm(row) { editConfirm(row) {
if (!row.label || !row.val) { console.log(row)
if (!row.dictLabel || !row.dictValue) {
this.$message.error('字典标签或字典值,不可为空'); this.$message.error('字典标签或字典值,不可为空');
return; return;
} }
// indexDictData(row).then(res => {
// this.$message.success(res.data)
// })
row.isEdit = false; row.isEdit = false;
}, },
delData(row) {
deleteDictData(row).then(res => {
this.$message.success(res.data)
})
return;
},
addDict() { addDict() {
if (!this.dictAddName){ if (!this.dictAddName){
this.$message.error('数据字典,不可为空'); this.$message.error('数据字典,不可为空');
return; return;
} }
this.dictMap[this.dictAddName] = [] indexDictType(this.dictAddName).then(res => {
this.$message.success(res.data)
})
this.dictAddName = null this.dictAddName = null
}, },
handleSetLineChartData(type) { handleSetLineChartData(type) {
this.$emit('handleSetLineChartData', type) this.$emit('handleSetLineChartData', type)
}, },
init() { init() {
listDictType().then(res => {
this.dictMap = res.data
})
let rows = [
{
tableName: "sys_user",
tableAsName: "用户表"
},
{
tableName: "sys_dept",
tableAsName: "部门表"
},
];
this.tableList = rows;
this.activeName = rows[0].tableName;
this.tableParams = rows[0]
} }
}, },
// - 访this", // - 访this",

View File

@ -27,45 +27,20 @@
import OverallSpecificAssets from "@/views/assets/table/dashboard/OverallSpecificAssets.vue"; import OverallSpecificAssets from "@/views/assets/table/dashboard/OverallSpecificAssets.vue";
import OverallAssetStructure from "@/views/assets/table/dashboard/OverallAssetStructure.vue"; import OverallAssetStructure from "@/views/assets/table/dashboard/OverallAssetStructure.vue";
import OverallAssets from "@/views/assets/table/dashboard/OverallAssets.vue"; import OverallAssets from "@/views/assets/table/dashboard/OverallAssets.vue";
import { tableNameList, selNameListStructure, selNameTableList } from "@/api/system/accredit"; import { selectFrimary } from "@/api/system/accredit";
export default { export default {
name: 'table', name: 'table',
components: { OverallAssetStructure, OverallSpecificAssets, OverallAssets }, components: { OverallAssetStructure, OverallSpecificAssets, OverallAssets },
data() { data() {
return { return {
tableName: '', tableName: {},
mainHeight: window.innerHeight - 85, mainHeight: window.innerHeight - 85,
defaultProps: { defaultProps: {
children: 'childrenList', children: 'childrenList',
label: 'name' label: 'name'
}, },
assetStructureList: [ assetStructureList: [],
{
name: "测试1",
systemName: "云计算系统",
databaseName: "yunjisuan",
type: "dataSource"
},
{
name: "测试2",
systemName: "网站系统",
databaseName: "wangzhan",
type: "dataSource"
},
{
name: "测试3",
systemName: "物联网系统",
databaseName: "wulianwang",
type: "dataSource"
},
{
name: "测试4",
systemName: "传媒系统",
databaseName: "chuanmei",
type: "dataSource"
},
],
childrenList: [], childrenList: [],
showAssets: null, showAssets: null,
title: null title: null
@ -77,33 +52,31 @@ export default {
const {data} = node; const {data} = node;
this.showAssets = data.type; this.showAssets = data.type;
if (data.type === 'dataTable') { if (data.type === 'dataTable') {
this.tableName = data.name
return resolve([]) return resolve([])
} }
setTimeout(() => { setTimeout(() => {
resolve(this.childrenList) resolve(data.tableLists)
}, 500); }, 500);
}, },
showAssetsFun(data){ showAssetsFun(data){
this.title = data.name + '('+data.databaseName + '-' + data.systemName+')' this.title = data.name + '('+data.databaseName + '-' + data.systemName+')'
this.showAssets = data.type; this.showAssets = data.type;
if (data.as == undefined){ if (data.as === undefined){
console.log(1) this.tableName = data.databaseName
this.tableName = '';
}else{ }else{
console.log(2)
this.tableName = data.name this.tableName = data.name
} }
}, },
thisTable() { init() {
tableNameList().then(res => { selectFrimary().then(res => {
this.childrenList = res.data this.assetStructureList = res.data
}) })
} }
}, },
// - 访this", // - 访this",
created() { created() {
this.thisTable() this.init()
}, },
// - 访DOM", // - 访DOM",
mounted() { mounted() {