数据集添加http,单独维护

Raod 3 years ago
parent b660bbde0a
commit 4160b3b1ac

@ -0,0 +1,14 @@
use
aj_report;
-- 增加字段
ALTER TABLE `gaea_report_data_set` DROP COLUMN `set_type`;
-- 将该字段值全更新为sql
update gaea_report_data_set set set_type = 'sql';
-- 字典
INSERT INTO `gaea_dict`(`id`, `dict_name`, `dict_code`, `remark`, `create_by`, `create_time`, `update_by`, `update_time`, `version`) VALUES (default, '数据集类型', 'SET_TYPE', '数据集类型', 'admin', '2021-11-16 14:43:12', 'admin', '2021-11-16 14:43:12', 1);
INSERT INTO `gaea_dict_item`(`id`, `dict_code`, `item_name`, `item_value`, `item_extend`, `enabled`, `locale`, `remark`, `sort`, `create_by`, `create_time`, `update_by`, `update_time`, `version`) VALUES (default , 'SET_TYPE', 'sql', 'sql', NULL, 1, 'zh', NULL, NULL, 'admin', '2021-11-16 14:43:42', 'admin', '2021-11-16 14:43:42', 1);
INSERT INTO `gaea_dict_item`(`id`, `dict_code`, `item_name`, `item_value`, `item_extend`, `enabled`, `locale`, `remark`, `sort`, `create_by`, `create_time`, `update_by`, `update_time`, `version`) VALUES (default , 'SET_TYPE', 'http', 'http', NULL, 1, 'zh', NULL, NULL, 'admin', '2021-11-16 14:43:51', 'admin', '2021-11-16 14:43:51', 1);

@ -15,7 +15,7 @@
label-width="130px" label-width="130px"
> >
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :xs="24" :sm="20" :md="8" :lg="8" :xl="8"> <el-col v-if="this.setType=='sql'" :xs="24" :sm="20" :md="8" :lg="8" :xl="8">
<el-form-item label="数据源" prop="sourceCode"> <el-form-item label="数据源" prop="sourceCode">
<el-select <el-select
v-model.trim="formData.sourceCode" v-model.trim="formData.sourceCode"
@ -53,6 +53,9 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row>
<el-row v-if="this.setType=='sql'" :gutter="10">
<el-col <el-col
:xs="24" :xs="24"
:sm="20" :sm="20"
@ -61,7 +64,7 @@
:xl="22" :xl="22"
class="code-mirror-form" class="code-mirror-form"
> >
<el-form-item label="查询SQL或请求体"> <el-form-item label="查询SQL">
<div class="codemirror"> <div class="codemirror">
<monaco-editor <monaco-editor
v-model.trim="formData.dynSentence" v-model.trim="formData.dynSentence"
@ -72,6 +75,25 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row v-if="this.setType=='http'">
<el-form-item label="请求路径">
<el-input placeholder="请输入请求路径..." v-model="httpForm.apiUrl" class="input-with-select">
<el-select v-model="httpForm.method" slot="prepend" placeholder="请选择">
<el-option label="GET" value="GET"></el-option>
<el-option label="POST" value="POST"></el-option>
<el-option label="PUT" value="PUT"></el-option>
<el-option label="DELETE" value="DELETE"></el-option>
</el-select>
</el-input>
</el-form-item>
<el-form-item label="请求头">
<el-input v-model.trim="httpForm.header" size="mini" placeholder="请输入请求头..."/>
</el-form-item>
<el-form-item label="请求体">
<el-input v-model.trim="httpForm.body" size="mini" placeholder="请输入请求体..."/>
</el-form-item>
</el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :xs="24" :sm="20" :md="22" :lg="22" :xl="22"> <el-col :xs="24" :sm="20" :md="22" :lg="22" :xl="22">
<el-form label-width="100px" class="demo-ruleForm"> <el-form label-width="100px" class="demo-ruleForm">
@ -508,7 +530,13 @@ export default {
setName: "", setName: "",
setCode: "" setCode: ""
}, },
setType: '', //http addSql addHttp edit
httpForm: { //http
apiUrl: '',
method: 'GET',
header: '{"Content-Type":"application/json;charset=UTF-8"}',
body: '',
},
// //
dictionaryOptions: [], // dictionaryOptions: [], //
list: null, list: null,
@ -541,7 +569,11 @@ export default {
mounted() {}, mounted() {},
methods: { methods: {
// , // ,
async addOrEditDataSet(row) { async addOrEditDataSet(row, type) {
this.setType = type
if (type == 'http' && row.dynSentence) {
this.httpForm = JSON.parse(row.dynSentence)
}
// //
const { code, data } = await queryAllDataSourceSet(); const { code, data } = await queryAllDataSourceSet();
if (code != "200") return; if (code != "200") return;
@ -636,12 +668,18 @@ export default {
// //
async handleClickTabs(tab, event) { async handleClickTabs(tab, event) {
if (this.setType == 'http') {
//http
console.log("http数据集" + this.httpForm);
this.formData.dynSentence = JSON.stringify(this.httpForm)
}
if (tab.paneName == "third") { if (tab.paneName == "third") {
const params = { const params = {
sourceCode: this.formData.sourceCode, sourceCode: this.formData.sourceCode,
dynSentence: this.formData.dynSentence, dynSentence: this.formData.dynSentence,
dataSetParamDtoList: this.tableData, dataSetParamDtoList: this.tableData,
dataSetTransformDtoList: this.itemFilterList dataSetTransformDtoList: this.itemFilterList,
setType: this.setType
}; };
const { code, data } = await testTransformSet(params); const { code, data } = await testTransformSet(params);
if (code != "200") return; if (code != "200") return;
@ -831,6 +869,12 @@ export default {
}); });
}, },
async submit(formName) { async submit(formName) {
if (this.setType == 'http') {
//http
console.log("http数据集" + this.httpForm);
this.formData.dynSentence = JSON.stringify(this.httpForm)
}
this.formData.setType = this.setType
this.$refs[formName].validate(async (valid, obj) => { this.$refs[formName].validate(async (valid, obj) => {
if (valid) { if (valid) {
if (this.testMassageCode == 200) { if (this.testMassageCode == 200) {

@ -1,13 +1,19 @@
<template> <template>
<anji-crud ref="listPage" :option="crudOption"> <anji-crud ref="listPage" :option="crudOption">
<template v-slot:buttonLeftOnTable> <template v-slot:buttonLeftOnTable>
<el-button <el-dropdown
type="primary" placement="bottom"
icon="el-icon-plus" @command="operateDataset"
@click="operateDataset('add')" >
v-permission="'resultsetManage:insert'" <el-button type="primary" icon="el-icon-plus">
>新增 新增
<i class="el-icon-arrow-down el-icon--right"></i>
</el-button> </el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="sql">SQL</el-dropdown-item>
<el-dropdown-item command="http">HTTP</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template> </template>
<template slot="edit" slot-scope="props"> <template slot="edit" slot-scope="props">
@ -95,7 +101,15 @@ export default {
}, },
label: "数据源", label: "数据源",
field: "sourceCode" field: "sourceCode"
} },
{
inputType: "anji-select", //form input|input-number|anji-select(urldictCode)|anji-tree()|date|datetime|datetimerange
anjiSelectOption: {
dictCode: "SET_TYPE"
},
label: "数据集类型",
field: "setType"
},
], ],
// //
buttons: { buttons: {
@ -180,6 +194,17 @@ export default {
], ],
disabled: false disabled: false
}, },
{
label: "数据集类型", //
placeholder: "",
field: "setType",
editField: "setType",
inputType: "input",
rules: [
{min: 1, max: 50, message: "不超过50个字符", trigger: "blur"}
],
disabled: false
},
{ {
label: "动态查询sql或者接口中的请求体", //sql label: "动态查询sql或者接口中的请求体", //sql
placeholder: "", placeholder: "",
@ -245,16 +270,19 @@ export default {
}; };
}, },
created() {}, created() {
},
methods: { methods: {
operateDataset(type, prop) { operateDataset(type, prop) {
debugger
this.dialogVisibleSetDataSet = true; this.dialogVisibleSetDataSet = true;
if (prop) { if (prop && prop.msg) {
this.dataSet = prop.msg; this.dataSet = prop.msg;
type = prop.msg.setType;
} else { } else {
this.dataSet = {}; this.dataSet = {};
} }
this.$refs.EditDataSet.addOrEditDataSet(this.dataSet); this.$refs.EditDataSet.addOrEditDataSet(this.dataSet, type);
}, },
refreshList() { refreshList() {
this.$refs.listPage.handleQueryForm("query"); this.$refs.listPage.handleQueryForm("query");

Loading…
Cancel
Save