update 数据集编辑

qianlishi 3 years ago
parent 057f71c0bf
commit bacef18729

@ -1,7 +1,12 @@
<template> <template>
<div> <div>
<el-dialog :title="dialogFormVisibleTitle" :visible.sync="visib" :close-on-click-modal="false" <el-dialog
:before-close="closeDialog" width="65%"> :title="dialogFormVisibleTitle"
:visible.sync="visib"
:close-on-click-modal="false"
:before-close="closeDialog"
width="65%"
>
<el-form <el-form
ref="form" ref="form"
:model="formData" :model="formData"
@ -38,12 +43,12 @@
</el-col> </el-col>
<el-col :xs="24" :sm="20" :md="8" :lg="8" :xl="8"> <el-col :xs="24" :sm="20" :md="8" :lg="8" :xl="8">
<el-form-item label="数据集名称" prop="setName"> <el-form-item label="数据集名称" prop="setName">
<el-input v-model.trim="formData.setName" size="mini"/> <el-input v-model.trim="formData.setName" size="mini" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<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-item label="数据集描述"> <el-form-item label="数据集描述">
<el-input v-model.trim="formData.setDesc" size="mini"/> <el-input v-model.trim="formData.setDesc" size="mini" />
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -80,17 +85,16 @@
type="text" type="text"
size="small" size="small"
@click="addRow()" @click="addRow()"
>添加 >添加
</el-button </el-button>
>
<el-table :data="tableData" border style="width: 100%"> <el-table :data="tableData" border style="width: 100%">
<el-table-column <el-table-column
align="center" align="center"
label="序号" label="序号"
type="index" type="index"
min-width="40" width="80"
/> />
<el-table-column label="参数名"> <el-table-column label="参数名" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model.trim="tableData[scope.$index].paramName" v-model.trim="tableData[scope.$index].paramName"
@ -101,35 +105,34 @@
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="描述"> <el-table-column label="描述" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model.trim="tableData[scope.$index].paramDesc" v-model.trim="tableData[scope.$index].paramDesc"
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="数据类型"> <el-table-column label="数据类型" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model.trim="tableData[scope.$index].paramType" v-model.trim="tableData[scope.$index].paramType"
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="示例值"> <el-table-column label="示例值" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input <el-input
v-model.trim="tableData[scope.$index].sampleItem" v-model.trim="tableData[scope.$index].sampleItem"
/> />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="校验" width="220"> <el-table-column label="校验" width="220" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-checkbox <el-checkbox
v-model="tableData[scope.$index].mandatory" v-model="tableData[scope.$index].mandatory"
@change="Mandatory(scope.$index)" @change="Mandatory(scope.$index)"
>必选 >必选
</el-checkbox </el-checkbox>
>
<el-button <el-button
type="primary" type="primary"
icon="el-icon-plus" icon="el-icon-plus"
@ -139,7 +142,7 @@
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
type="text" type="text"
@ -147,25 +150,22 @@
@click.native.prevent=" @click.native.prevent="
cutOutRow(scope.$index, tableData) cutOutRow(scope.$index, tableData)
" "
>删除 >删除
</el-button </el-button>
>
<el-button <el-button
type="text" type="text"
size="small" size="small"
@click="addRow(scope.row)" @click="addRow(scope.row)"
>追加 >追加
</el-button </el-button>
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<el-checkbox <el-checkbox
v-model="isShowPagination" v-model="isShowPagination"
@change="changePagination" @change="changePagination"
>加入分页参数 >加入分页参数
</el-checkbox </el-checkbox>
>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="数据转换" name="second"> <el-tab-pane label="数据转换" name="second">
<template> <template>
@ -293,18 +293,17 @@
</el-table> </el-table>
</div> </div>
<el-button type="success" @click="addAllDict()" <el-button type="success" @click="addAllDict()"
>新增 >新增
</el-button </el-button>
>
</div> </div>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="dialogSwitchVisible = false" <el-button @click="dialogSwitchVisible = false"
>取消</el-button >取消</el-button
> >
<el-button <el-button
type="primary" type="primary"
@click="filterScriptConfirm" @click="filterScriptConfirm"
>保存</el-button >保存</el-button
> >
</span> </span>
</el-dialog> </el-dialog>
@ -314,7 +313,7 @@
disabled="true" disabled="true"
@click="addFilter" @click="addFilter"
> >
<i class="el-icon-plus"/><span>新增</span> <i class="el-icon-plus" /><span>新增</span>
</div> </div>
</div> </div>
</div> </div>
@ -360,7 +359,7 @@
<el-button type="warning" @click="testResultset"></el-button> <el-button type="warning" @click="testResultset"></el-button>
<el-button type="primary" @click="dialogValidationRules" <el-button type="primary" @click="dialogValidationRules"
>保存</el-button >保存</el-button
> >
<el-button @click="dialogPermissionVisible = false">关闭</el-button> <el-button @click="dialogPermissionVisible = false">关闭</el-button>
</span> </span>
@ -374,10 +373,10 @@ import {
testTransformSet, testTransformSet,
dataSetPreview, dataSetPreview,
addDataSet, addDataSet,
editDataSet, editDataSet
} from "@/api/report"; } from "@/api/report";
import Dictionary from "@/components/Dictionary/index"; import Dictionary from "@/components/Dictionary/index";
import {codemirror} from "vue-codemirror"; // codeMirror import { codemirror } from "vue-codemirror"; // codeMirror
import "codemirror/mode/sql/sql.js"; import "codemirror/mode/sql/sql.js";
import "codemirror/mode/javascript/javascript.js"; import "codemirror/mode/javascript/javascript.js";
import "codemirror/lib/codemirror.css"; // import "codemirror/lib/codemirror.css"; //
@ -385,21 +384,21 @@ import "codemirror/theme/cobalt.css"; // 引入主题后还需要在 options 中
import vueJsonEditor from "vue-json-editor"; import vueJsonEditor from "vue-json-editor";
export default { export default {
name: 'Support', name: "Support",
components: {Dictionary, codemirror, vueJsonEditor}, components: { Dictionary, codemirror, vueJsonEditor },
props: { props: {
visib: { visib: {
required: true, required: true,
type: Boolean, type: Boolean,
default: false, default: false
}, },
dataSet: { dataSet: {
required: false, required: false,
type: Object, type: Object,
default: () => { default: () => {
return '' return "";
}, }
}, }
}, },
data() { data() {
return { return {
@ -467,13 +466,13 @@ export default {
}, },
formRules: { formRules: {
setName: [ setName: [
{required: true, message: "数据集名称必填", trigger: "blur"} { required: true, message: "数据集名称必填", trigger: "blur" }
], ],
setCode: [ setCode: [
{required: true, message: "数据集编码必填", trigger: "blur"} { required: true, message: "数据集编码必填", trigger: "blur" }
], ],
sourceCode: [ sourceCode: [
{required: true, message: "数据源必选", trigger: "change"} { required: true, message: "数据源必选", trigger: "change" }
] ]
}, },
sourceList: [], sourceList: [],
@ -510,38 +509,36 @@ export default {
list: null, list: null,
basicDialog: false, basicDialog: false,
dialogForm: { dialogForm: {
sourceName: '', sourceName: "",
sourceCode: '', sourceCode: "",
sourceType: '', sourceType: "",
sourceDesc: '', sourceDesc: "",
sourceConfig: '', sourceConfig: ""
}, },
dataLink: [], dataLink: [],
rules: { rules: {
sourceType: [ sourceType: [
{required: true, message: '数据集名称必选', trigger: 'change'}, { required: true, message: "数据集名称必选", trigger: "change" }
], ],
sourceCode: [ sourceCode: [
{required: true, message: '数据集编码必填', trigger: 'blur'}, { required: true, message: "数据集编码必填", trigger: "blur" }
], ],
sourceName: [ sourceName: [
{required: true, message: '数据源名称必选', trigger: 'blur'}, { required: true, message: "数据源名称必选", trigger: "blur" }
], ]
}, },
value: '', value: "",
testReplyCode: null, testReplyCode: null
} };
}, },
// beforeCreatethis // beforeCreatethis
beforeCreate: function () { beforeCreate: function() {},
}, mounted() {},
mounted() {
},
methods: { methods: {
// , // ,
async addOrEditDataSet(row) { async addOrEditDataSet(row) {
// //
const {code, data} = await queryAllDataSourceSet(); const { code, data } = await queryAllDataSourceSet();
if (code != "200") return; if (code != "200") return;
this.sourceList = data; this.sourceList = data;
@ -593,9 +590,9 @@ export default {
for (const i in extendObj) { for (const i in extendObj) {
const children = []; const children = [];
for (const y in extendObj[i]) { for (const y in extendObj[i]) {
children.push({name: y, value: extendObj[i][y]}); children.push({ name: y, value: extendObj[i][y] });
} }
extendArry.push({name: i, children: children}); extendArry.push({ name: i, children: children });
} }
this.tableData2 = extendArry; this.tableData2 = extendArry;
} }
@ -618,14 +615,11 @@ export default {
}, },
// //
closeDialog() { closeDialog() {
this.$emit('handleClose') this.$emit("handleClose");
}, },
onJsonChange(value) {},
onJsonChange(value) { onJsonSave(value) {},
},
onJsonSave(value) {
},
handleClose(done) { handleClose(done) {
this.dialogFormVisible = false; this.dialogFormVisible = false;
}, },
@ -635,7 +629,6 @@ export default {
this.caseResultContent = JSON.parse(item.caseResult); this.caseResultContent = JSON.parse(item.caseResult);
}, },
// //
async handleClickTabs(tab, event) { async handleClickTabs(tab, event) {
if (tab.paneName == "third") { if (tab.paneName == "third") {
@ -645,7 +638,7 @@ export default {
dataSetParamDtoList: this.tableData, dataSetParamDtoList: this.tableData,
dataSetTransformDtoList: this.itemFilterList dataSetTransformDtoList: this.itemFilterList
}; };
const {code, data} = await testTransformSet(params); const { code, data } = await testTransformSet(params);
if (code != "200") return; if (code != "200") return;
this.cols = data.data; this.cols = data.data;
this.testMassageCode = code; this.testMassageCode = code;
@ -697,7 +690,7 @@ export default {
this.dialogSwitchVisible = true; this.dialogSwitchVisible = true;
if (item.transformType == "js") { if (item.transformType == "js") {
this.itemFilterScriptId = item.itemFilterSort; this.itemFilterScriptId = item.itemFilterSort;
const fnCont = `function dataTransform(data){\n\t//自定义脚本内容\n\treturn data;\n}` const fnCont = `function dataTransform(data){\n\t//自定义脚本内容\n\treturn data;\n}`;
this.transformScript = item.transformScript this.transformScript = item.transformScript
? item.transformScript ? item.transformScript
: fnCont; : fnCont;
@ -767,7 +760,7 @@ export default {
this.title = "自定义高级规则"; this.title = "自定义高级规则";
if (this.isRowData.sampleItem != "") { if (this.isRowData.sampleItem != "") {
this.isRowData = row; this.isRowData = row;
const fnCont = `function verification(data){\n\t//自定义脚本内容\n\treturn true;\n}` const fnCont = `function verification(data){\n\t//自定义脚本内容\n\treturn true;\n}`;
this.validationRules = row.validationRules this.validationRules = row.validationRules
? row.validationRules ? row.validationRules
: fnCont; : fnCont;
@ -782,11 +775,11 @@ export default {
addAllDict() { addAllDict() {
this.tableData2.push({ this.tableData2.push({
name: "", name: "",
children: [{name: "", value: ""}] children: [{ name: "", value: "" }]
}); });
}, },
addDict(index, item) { addDict(index, item) {
item.push({name: "", value: ""}); item.push({ name: "", value: "" });
}, },
delAllDict(index, rows) { delAllDict(index, rows) {
rows.splice(index, 1); rows.splice(index, 1);
@ -800,21 +793,19 @@ export default {
}, },
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
// //
changeSource() { changeSource() {},
},
// //
async testResultset() { async testResultset() {
this.isRowData.validationRules = this.validationRules; this.isRowData.validationRules = this.validationRules;
const {code, message, data} = await verificationSet(this.isRowData); const { code, message, data } = await verificationSet(this.isRowData);
if (code == "200") { if (code == "200") {
if (data) { if (data) {
this.$message.success('校验通过'); this.$message.success("校验通过");
}else { } else {
this.$message.warning('当前示例值校验不通过'); this.$message.warning("当前示例值校验不通过");
} }
} else { } else {
this.$message.error(message) this.$message.error(message);
} }
}, },
// //
@ -841,13 +832,13 @@ export default {
this.formData.dataSetTransformDtoList = this.itemFilterList; this.formData.dataSetTransformDtoList = this.itemFilterList;
this.formData.caseResult = JSON.stringify(this.cols); this.formData.caseResult = JSON.stringify(this.cols);
if (this.dialogFormVisibleTitle === "新增数据集") { if (this.dialogFormVisibleTitle === "新增数据集") {
const {code} = await addDataSet(this.formData); const { code } = await addDataSet(this.formData);
if (code != "200") return; if (code != "200") return;
this.closeDialog() this.closeDialog();
} else { } else {
const {code} = await editDataSet(this.formData); const { code } = await editDataSet(this.formData);
if (code != "200") return; if (code != "200") return;
this.closeDialog() this.closeDialog();
} }
} else { } else {
this.$message.error("请先测试预览,操作成功后便可保存!"); this.$message.error("请先测试预览,操作成功后便可保存!");
@ -867,14 +858,14 @@ export default {
for (const key in objfirst) { for (const key in objfirst) {
const newObj = {}; const newObj = {};
objfirst[key].map(ev => { objfirst[key].map(ev => {
Object.assign(newObj, {[ev.name]: ev.value}); Object.assign(newObj, { [ev.name]: ev.value });
}); });
objSecond[key] = newObj; objSecond[key] = newObj;
} }
return objSecond; return objSecond;
} }
}, }
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.code-mirror-form { .code-mirror-form {

Loading…
Cancel
Save