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) {
return request({
url: '/system/access/synchronization',
@ -66,3 +79,5 @@ export function synchronization(data) {
}

View File

@ -1,9 +1,9 @@
import request from '@/utils/request'
// 查询数据接入列表
export function tableNameList() {
export function tableNameList(databaseName) {
return request({
url: '/system/accredit/tableNameList',
url: '/system/accredit/tableNameList/' + databaseName,
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)"
v-hasPermi="['system:access:remove']"
>删除</el-button>
<el-button
size="mini"
icon="el-icon-edit"
:load="expandTable"
@click="ttbb(scope.row)"
v-hasPermi="['system:access:remove']"
>同协</el-button>
</template>
</el-table-column>
</el-table>
@ -179,6 +186,18 @@
</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-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-col :md="12" :sm="24">
<el-form-item label="数据库名称" prop="databaseName">
@ -274,6 +293,7 @@
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
@ -281,10 +301,13 @@
import { listAccess, getAccess, delAccess, addAccess, updateAccess, synchronization } from "@/api/system/access";
import { selJDBCStream } from "@/api/system/accredit";
import Table from '@/views/assets/table/index.vue'
import Authorization from '@/views/assets/authorization/index.vue'
export default {
name: "Access",
data() {
return {
accessId: '',
//
loading: true,
//
@ -346,6 +369,12 @@ export default {
port: [
{ required: true, message: "端口号不能为空", trigger: "blur" }
],
username: [
{ required: true, message: "端口号不能为空", trigger: "blur" }
],
password: [
{ required: true, message: "端口号不能为空", trigger: "blur" }
],
databaseName: [
{ required: true, message: "数据库名称不能为空", trigger: "blur" }
],
@ -380,6 +409,23 @@ export default {
this.getList();
},
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){
synchronization(row).then(res => {
@ -409,7 +455,6 @@ export default {
.map(item => {
return item.name + "=" + item.val;
}).join("&")
console.log(this.form.connectionParam)
},
/** 查询数据接入列表 */
getList() {
@ -418,7 +463,6 @@ export default {
this.accessList = response.data.rows;
this.total = response.data.total;
this.loading = false;
console.log(this.accessList)
});
},
//
@ -471,7 +515,12 @@ export default {
handleCes(row) {
console.log(row)
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) {
console.log(row)
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除数据接入编号为"' + ids + '"的数据项?').then(function() {
return delAccess(ids);

View File

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

View File

@ -54,7 +54,6 @@ export default {
},
methods: {
handleSetLineChartData(type) {
console.log(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-card class="box-card" style="height: 300px">
<div slot="header" class="clearfix">
<span>{{key}}</span>
<span>{{val.dictType}}</span>
<el-button style="float: right; padding: 3px 0"
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>
</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="标签">
<template slot-scope="scope">
<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>
<span v-if="!scope.row.isEdit">{{scope.row.dictLabel}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.dictLabel" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column prop="val" label="值">
<template slot-scope="scope">
<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>
<span v-if="!scope.row.isEdit">{{scope.row.dictValue}}</span>
<el-input v-if="scope.row.isEdit" v-model="scope.row.dictValue" size="mini"></el-input>
</template>
</el-table-column>
<el-table-column prop="val" label="操作">
@ -86,8 +86,15 @@
size="mini"
type="text"
icon="el-icon-edit"
@click="scope.row.isEdit = true"
@click="updData(scope.row)"
>修改</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
v-if="scope.row.isEdit"
@click="editConfirm(scope.row)"
@ -105,11 +112,11 @@
</el-col>
<el-col :span="24" style="margin-top: 20px">
<el-tabs v-model="activeName" type="border-card">
<el-tab-pane label="sys_user(用户表)" name="first">
<overall-asset-structure/>
<el-tabs v-model="activeName" type="border-card" @tab-click="checkTableName">
<el-tab-pane v-for="table in tableList" :label="table.tableName+'('+table.tableAsName+')'"
:name="table.tableName">
<overall-asset-structure v-if="table.tableName === tableParams.tableName" :table-params="tableParams"/>
</el-tab-pane>
<el-tab-pane label="sys_dept(部门表)" name="second">sys_dept(部门表)</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
@ -119,6 +126,8 @@
<script>
import CountTo from 'vue-count-to'
import OverallAssetStructure from './OverallAssetStructure.vue'
import { listDictType, indexDictType, indexDictData, deleteDictData, selectDictData } from "@/api/system/dicts"
import val from "quill";
export default {
props: {
@ -131,16 +140,15 @@ export default {
return {
activeName: null,
dictAddName: null,
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 }
],
dictMap: [],
tableList: [],
tableParams: null,
dictData: {
dictCode: '',
dictType: '',
dictLabel: '',
dictValue: '',
isEdit: false,
}
}
},
@ -149,25 +157,66 @@ export default {
CountTo
},
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) {
if (!row.label || !row.val) {
console.log(row)
if (!row.dictLabel || !row.dictValue) {
this.$message.error('字典标签或字典值,不可为空');
return;
}
// indexDictData(row).then(res => {
// this.$message.success(res.data)
// })
row.isEdit = false;
},
delData(row) {
deleteDictData(row).then(res => {
this.$message.success(res.data)
})
return;
},
addDict() {
if (!this.dictAddName){
this.$message.error('数据字典,不可为空');
return;
}
this.dictMap[this.dictAddName] = []
indexDictType(this.dictAddName).then(res => {
this.$message.success(res.data)
})
this.dictAddName = null
},
handleSetLineChartData(type) {
this.$emit('handleSetLineChartData', type)
},
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",

View File

@ -27,45 +27,20 @@
import OverallSpecificAssets from "@/views/assets/table/dashboard/OverallSpecificAssets.vue";
import OverallAssetStructure from "@/views/assets/table/dashboard/OverallAssetStructure.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 {
name: 'table',
components: { OverallAssetStructure, OverallSpecificAssets, OverallAssets },
data() {
return {
tableName: '',
tableName: {},
mainHeight: window.innerHeight - 85,
defaultProps: {
children: 'childrenList',
label: 'name'
},
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"
},
],
assetStructureList: [],
childrenList: [],
showAssets: null,
title: null
@ -77,33 +52,31 @@ export default {
const {data} = node;
this.showAssets = data.type;
if (data.type === 'dataTable') {
this.tableName = data.name
return resolve([])
}
setTimeout(() => {
resolve(this.childrenList)
resolve(data.tableLists)
}, 500);
},
showAssetsFun(data){
this.title = data.name + '('+data.databaseName + '-' + data.systemName+')'
this.showAssets = data.type;
if (data.as == undefined){
console.log(1)
this.tableName = '';
if (data.as === undefined){
this.tableName = data.databaseName
}else{
console.log(2)
this.tableName = data.name
}
},
thisTable() {
tableNameList().then(res => {
this.childrenList = res.data
init() {
selectFrimary().then(res => {
this.assetStructureList = res.data
})
}
},
// - 访this",
created() {
this.thisTable()
this.init()
},
// - 访DOM",
mounted() {