数据集添加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"
>
<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-select
v-model.trim="formData.sourceCode"
@ -53,6 +53,9 @@
</el-form-item>
</el-col>
</el-row>
<el-row v-if="this.setType=='sql'" :gutter="10">
<el-col
:xs="24"
:sm="20"
@ -61,7 +64,7 @@
:xl="22"
class="code-mirror-form"
>
<el-form-item label="查询SQL或请求体">
<el-form-item label="查询SQL">
<div class="codemirror">
<monaco-editor
v-model.trim="formData.dynSentence"
@ -72,6 +75,25 @@
</el-form-item>
</el-col>
</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-col :xs="24" :sm="20" :md="22" :lg="22" :xl="22">
<el-form label-width="100px" class="demo-ruleForm">
@ -508,7 +530,13 @@ export default {
setName: "",
setCode: ""
},
setType: '', //http addSql addHttp edit
httpForm: { //http
apiUrl: '',
method: 'GET',
header: '{"Content-Type":"application/json;charset=UTF-8"}',
body: '',
},
//
dictionaryOptions: [], //
list: null,
@ -541,7 +569,11 @@ export default {
mounted() {},
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();
if (code != "200") return;
@ -636,12 +668,18 @@ export default {
//
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") {
const params = {
sourceCode: this.formData.sourceCode,
dynSentence: this.formData.dynSentence,
dataSetParamDtoList: this.tableData,
dataSetTransformDtoList: this.itemFilterList
dataSetTransformDtoList: this.itemFilterList,
setType: this.setType
};
const { code, data } = await testTransformSet(params);
if (code != "200") return;
@ -831,6 +869,12 @@ export default {
});
},
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) => {
if (valid) {
if (this.testMassageCode == 200) {

@ -1,13 +1,19 @@
<template>
<anji-crud ref="listPage" :option="crudOption">
<template v-slot:buttonLeftOnTable>
<el-button
type="primary"
icon="el-icon-plus"
@click="operateDataset('add')"
v-permission="'resultsetManage:insert'"
>新增
</el-button>
<el-dropdown
placement="bottom"
@command="operateDataset"
>
<el-button type="primary" icon="el-icon-plus">
新增
<i class="el-icon-arrow-down el-icon--right"></i>
</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 slot="edit" slot-scope="props">
@ -15,7 +21,7 @@
type="text"
@click="operateDataset('edit', props)"
v-permission="'resultsetManage:update'"
>编辑
>编辑
</el-button>
</template>
@ -24,7 +30,7 @@
type="text"
@click="dataView(props)"
v-permission="'resultsetManage:query'"
>数据预览
>数据预览
</el-button>
</template>
<!--自定义的卡片插槽将在编辑详情页面出现在底部新卡片-->
@ -95,7 +101,15 @@ export default {
},
label: "数据源",
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: {
@ -143,7 +157,7 @@ export default {
editField: "setCode",
inputType: "input",
rules: [
{ min: 1, max: 50, message: "不超过50个字符", trigger: "blur" }
{min: 1, max: 50, message: "不超过50个字符", trigger: "blur"}
],
disabled: false
},
@ -154,7 +168,7 @@ export default {
editField: "setName",
inputType: "input",
rules: [
{ min: 1, max: 100, message: "不超过100个字符", trigger: "blur" }
{min: 1, max: 100, message: "不超过100个字符", trigger: "blur"}
],
disabled: false
},
@ -165,7 +179,7 @@ export default {
editField: "setDesc",
inputType: "input",
rules: [
{ min: 1, max: 255, message: "不超过255个字符", trigger: "blur" }
{min: 1, max: 255, message: "不超过255个字符", trigger: "blur"}
],
disabled: false
},
@ -176,7 +190,18 @@ export default {
editField: "sourceCode",
inputType: "input",
rules: [
{ min: 1, max: 50, message: "不超过50个字符", trigger: "blur" }
{min: 1, max: 50, message: "不超过50个字符", trigger: "blur"}
],
disabled: false
},
{
label: "数据集类型", //
placeholder: "",
field: "setType",
editField: "setType",
inputType: "input",
rules: [
{min: 1, max: 50, message: "不超过50个字符", trigger: "blur"}
],
disabled: false
},
@ -245,16 +270,19 @@ export default {
};
},
created() {},
created() {
},
methods: {
operateDataset(type, prop) {
debugger
this.dialogVisibleSetDataSet = true;
if (prop) {
if (prop && prop.msg) {
this.dataSet = prop.msg;
type = prop.msg.setType;
} else {
this.dataSet = {};
}
this.$refs.EditDataSet.addOrEditDataSet(this.dataSet);
this.$refs.EditDataSet.addOrEditDataSet(this.dataSet, type);
},
refreshList() {
this.$refs.listPage.handleQueryForm("query");

Loading…
Cancel
Save