feat: bidataset修改数据

This commit is contained in:
caoqianming 2023-11-14 10:26:36 +08:00
parent 283321f238
commit 5d5ea3e1c3
3 changed files with 258 additions and 285 deletions

View File

@ -2090,39 +2090,39 @@ const routes = [
// },
// ]
// },
// //报表
// {
// "name": "bi",
// "path": "/bi",
// "meta": {
// "title": "报表",
// "icon": "el-icon-trend-charts",
// "type": "menu",
// "perms": ["bi"]
// },
// "children": [
// {
// "name": "dataset",
// "path": "/bi/dataset",
// "meta": {
// "title": "数据集",
// "icon": "el-icon-grid",
// "perms": ["dataset"]
// },
// "component": "bi/dataset"
// },
// {
// "name": "graph",
// "path": "/bi/graph",
// "meta": {
// "title": "测试图",
// "icon": "el-icon-grid",
// "perms": ["dataset"]
// },
// "component": "bi/graph"
// }
// ]
// },
//报表
{
"name": "bi",
"path": "/bi",
"meta": {
"title": "报表",
"icon": "el-icon-trend-charts",
"type": "menu",
"perms": ["bi"]
},
"children": [
{
"name": "dataset",
"path": "/bi/dataset",
"meta": {
"title": "数据集",
"icon": "el-icon-grid",
"perms": ["dataset"]
},
"component": "bi/dataset"
},
{
"name": "graph",
"path": "/bi/graph",
"meta": {
"title": "测试图",
"icon": "el-icon-grid",
"perms": ["dataset"]
},
"component": "bi/graph"
}
]
},
// //电石渣
// {
// "name": "enm_slag",

View File

@ -8,56 +8,27 @@
</div>
<div class="right-panel">
<div class="right-panel-search">
<el-input
v-model="query.search"
placeholder="名称"
clearable
@keyup.enter="handleQuery"
></el-input>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
></el-button>
<el-input v-model="query.search" placeholder="名称" clearable @keyup.enter="handleQuery"></el-input>
<el-button type="primary" icon="el-icon-search" @click="handleQuery"></el-button>
</div>
</div>
</el-header>
<el-main class="nopadding">
<scTable
ref="table"
:apiObj="apiObj"
row-key="id"
stripe
>
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe>
<el-table-column label="#" type="index" width="50"></el-table-column>
<el-table-column label="名称" prop="name" width="200" :show-overflow-tooltip="true"></el-table-column>
<el-table-column label="名称" prop="name" width="200" :show-overflow-tooltip="true"></el-table-column>
<el-table-column label="sql语句" prop="sql_query" :show-overflow-tooltip="true"></el-table-column>
<el-table-column label="操作" fixed="right" align="left" width="200">
<template #default="scope">
<el-button
type="primary"
plain
size="small"
@click="handleShow(scope.row)"
v-auth="'dataset.exec'"
>预览</el-button
>
<el-button
plain
type="warning"
size="small"
@click="table_edit(scope.row, scope.$index)"
v-auth="'dataset.update'"
>编辑</el-button
>
<el-popconfirm
title="确定删除吗?"
@confirm="table_del(scope.row, scope.$index)"
>
<template #reference>
<el-button plain type="danger" size="small" v-auth="'dataset.delete'">删除</el-button>
</template>
</el-popconfirm>
<el-button type="primary" plain size="small" @click="handleShow(scope.row)"
v-auth="'dataset.exec'">预览</el-button>
<el-button plain type="warning" size="small" @click="table_edit(scope.row, scope.$index)"
v-auth="'dataset.update'">编辑</el-button>
<el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index)">
<template #reference>
<el-button plain type="danger" size="small" v-auth="'dataset.delete'">删除</el-button>
</template>
</el-popconfirm>
</template>
</el-table-column>
</scTable>
@ -65,177 +36,211 @@
</el-container>
</el-aside>
<el-main>
<div style="background-color: white;">
<el-row>
<div style="width: 100%;background-color: white;font-size: 14px; margin-top:2px"
v-for="(value, key, index) in bidata" :key="index">
<table class="custom-table">
<thead>
<tr>
<th v-for="(header, index) in value[0]" :key="index">{{ header }}</th>
</tr>
</thead>
<tbody>
<tr v-for="(row, rowIndex) in value.slice(1)" :key="rowIndex">
<td v-for="(cell, cellIndex) in row" :key="cellIndex">{{ cell }}</td>
</tr>
</tbody>
</table>
</div>
</el-row>
<div style="height:8px"></div>
<el-row>
<div style="width: 100%;background-color: white;">
<scEcharts height="360px" :option="myOption" v-if="chartShow"></scEcharts>
</div>
</div>
</el-row>
</el-main>
</el-container>
<save-dialog
v-if="dialog.save"
ref="saveDialog"
@success="handleSaveSuccess"
@closed="dialog.save = false"
></save-dialog>
<save-dialog v-if="dialog.save" ref="saveDialog" @success="handleSaveSuccess"
@closed="dialog.save = false"></save-dialog>
</template>
<style scoped>
.custom-table {
width: 100%;
border-collapse: collapse;
}
th,
td {
border: 1px solid #ddd;
padding: 2px;
text-align: left;
}
th {
background-color: #f2f2f2;
}
</style>
<script>
import scEcharts from "@/components/scEcharts";
import saveDialog from "./dataset_form.vue";
export default {
name: "dataset",
components: {
saveDialog,
scEcharts,
},
data() {
return {
chartShow: false,
myOption: null,
dialog: {
save: false,
permission: false,
},
adminform:{
admin: null,
username:"",
},
apiObj: this.$API.bi.dataset.list,
query: {},
selection: [],
search: {
keyword: null,
},
datasetID:"",
adminvisible:false,
//
rules: {
phone: [
{required: true, message: '请输入'}
],
name: [
{required: true, message: '请输入'}
],
username: [
{required: true, message: '请输入'}
],
},
};
},
methods: {
Func(func,res){
var _this = "_this";
var dom = new Function(`return ${func}`)();
console.log(dom,'dom');
dom && dom(_this,res);
import scEcharts from "@/components/scEcharts";
import saveDialog from "./dataset_form.vue";
export default {
name: "dataset",
components: {
saveDialog,
scEcharts,
},
data() {
return {
chartShow: false,
myOption: null,
dialog: {
save: false,
permission: false,
},
handleShow(row) {
// var func = 'function test(_this,res){res.name="sj";console.log(res,"===",_this)}';
// var res = {name:'***',age:'21',sex:1,list:[1,2,3]};
// debugger;
// console.log(func)
// this.Func(func,res);
// this.$router.push({
// path: "graph",
// query: {
// datasetId: row.id,
// },
// });
this.chartShow = false;
this.$API.bi.dataset.exec
adminform: {
admin: null,
username: "",
},
apiObj: this.$API.bi.dataset.list,
query: {},
selection: [],
search: {
keyword: null,
},
datasetID: "",
adminvisible: false,
bidata: [],
//
rules: {
phone: [
{ required: true, message: '请输入' }
],
name: [
{ required: true, message: '请输入' }
],
username: [
{ required: true, message: '请输入' }
],
},
};
},
methods: {
Func(func, res) {
var _this = "_this";
var dom = new Function(`return ${func}`)();
console.log(dom, 'dom');
dom && dom(_this, res);
},
handleShow(row) {
// var func = 'function test(_this,res){res.name="sj";console.log(res,"===",_this)}';
// var res = {name:'***',age:'21',sex:1,list:[1,2,3]};
// debugger;
// console.log(func)
// this.Func(func,res);
// this.$router.push({
// path: "graph",
// query: {
// datasetId: row.id,
// },
// });
this.chartShow = false;
this.$API.bi.dataset.exec
.req(row.id, { is_test: true })
.then((res) => {
this.bidata = res.data
if (res.echart_options) {
this.myOption = JSON.parse(res.echart_options);
this.chartShow = true;
}
});
},
//
add() {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add");
});
},
getAdmin(data) {
this.adminform.admin = data.id;
this.adminform.admin_name = data.name;
this.adminform.name = data.name;
this.adminform.phone = data.phone;
this.adminform.username = data.username;
},
//
table_edit(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("edit").setData(row);
});
},
//
table_show(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("show").setData(row);
});
},
//
table_admin(row) {
this.adminvisible = true;
this.datasetID = row.id;
},
//FROM
submitAdmin() {
this.$API.rpm.dataset.admin.req(
this.datasetID,
this.adminform
).then((res) => {
this.$message.success("账号分配成功");
this.adminvisible = false;
this.$refs.table.refresh()
})
.catch((err) => {
return err;
});;
},
//
permission() {
this.dialog.permission = true;
this.$nextTick(() => {
this.$refs.permissionDialog.open();
});
},
//
async table_del(row) {
this.$API.rpm.dataset.delete
.req(row.id)
.then((res) => {
this.myOption = JSON.parse(res.echart_options);
debugger;
console.log(this.myOption)
this.chartShow = true;
this.$message.success("删除成功");
return res;
})
.catch((err) => {
return err;
});
},
//
add() {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add");
});
},
getAdmin(data){
this.adminform.admin=data.id;
this.adminform.admin_name=data.name;
this.adminform.name = data.name;
this.adminform.phone = data.phone;
this.adminform.username = data.username;
},
//
table_edit(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("edit").setData(row);
});
},
//
table_show(row) {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("show").setData(row);
});
},
//
table_admin(row)
{
this.adminvisible=true;
this.datasetID=row.id;
},
//FROM
submitAdmin(){
this.$API.rpm.dataset.admin.req(
this.datasetID,
this.adminform
).then((res) => {
this.$message.success("账号分配成功");
this.adminvisible = false;
this.$refs.table.refresh()
})
.catch((err) => {
return err;
});;
},
//
permission() {
this.dialog.permission = true;
this.$nextTick(() => {
this.$refs.permissionDialog.open();
});
},
//
async table_del(row) {
this.$API.rpm.dataset.delete
.req(row.id)
.then((res) => {
this.$message.success("删除成功");
return res;
})
.catch((err) => {
return err;
});
},
//
handleSaveSuccess(data, mode) {
if (mode == "add") {
this.$refs.table.refresh();
} else if (mode == "edit") {
this.$refs.table.refresh();
}
},
handleQuery() {
this.$refs.table.queryData(this.query)
},
resetQuery() {
this.query = {};
},
},
};
</script>
//
handleSaveSuccess(data, mode) {
if (mode == "add") {
this.$refs.table.refresh();
} else if (mode == "edit") {
this.$refs.table.refresh();
}
},
handleQuery() {
this.$refs.table.queryData(this.query)
},
resetQuery() {
this.query = {};
},
},
};
</script>

View File

@ -1,75 +1,44 @@
<template>
<el-drawer
:title="titleMap[mode]"
v-model="visible"
:size="1000"
destroy-on-close
@closed="$emit('closed')"
>
<el-drawer :title="titleMap[mode]" v-model="visible" :size="1000" destroy-on-close @closed="$emit('closed')">
<el-container v-loading="loading">
<el-main style="padding: 0 20px 20px 20px">
<el-form
ref="dialogForm"
:model="form"
:rules="rules"
:disabled="mode == 'show'"
label-width="80px"
>
<el-form ref="dialogForm" :model="form" :rules="rules" :disabled="mode == 'show'" label-width="80px">
<el-row>
<el-col :md="8" :sm="12" :xs="24">
<el-form-item label="名称" prop="name">
<el-input
v-model="form.name"
type="text"
clearable
></el-input>
<el-input v-model="form.name" type="text" clearable></el-input>
</el-form-item>
</el-col>
<el-col :md="8" :sm="12" :xs="24">
<el-form-item label="编号" prop="code">
<el-input
v-model="form.code"
type="text"
clearable
></el-input>
<el-input v-model="form.code" type="text" clearable></el-input>
</el-form-item>
</el-col>
<el-col :md="24" :sm="24" :xs="24">
<el-form-item label="说明">
<el-input
v-model="form.description"
clearable
type="textarea"
></el-input>
<el-input v-model="form.description" clearable type="textarea"></el-input>
</el-form-item>
</el-col>
<el-col :md="24" :sm="24" :xs="24">
<el-form-item label="sql语句">
<el-input
v-model="form.sql_query"
clearable
type="textarea"
:rows="10"
></el-input>
<el-input v-model="form.sql_query" clearable type="textarea" :rows="8"></el-input>
</el-form-item>
</el-col>
<el-col :md="24" :sm="24" :xs="24">
<el-form-item label="图表配置">
<el-input
v-model="form.echart_options"
clearable
type="textarea"
:rows="10"
></el-input>
<el-input v-model="form.echart_options" clearable type="textarea" :rows="8"></el-input>
</el-form-item>
</el-col>
<el-col :md="24" :sm="24" :xs="24">
<el-form-item label="默认参数">
<el-input v-model="form.default_param" clearable type="textarea" :rows="8"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
</el-main>
<el-footer>
<el-button type="primary" :loading="isSaveing" @click="submit"
>保存</el-button
>
<el-button type="primary" :loading="isSaveing" @click="submit">保存</el-button>
<el-button @click="visible = false">取消</el-button>
</el-footer>
</el-container>
@ -158,5 +127,4 @@ export default {
};
</script>
<style>
</style>
<style></style>