qianlishi 3 years ago
parent 3d71222264
commit 79e8fb0685

@ -1,32 +1,71 @@
<template> <template>
<el-dialog title="项目基础配置" width="50%" :close-on-click-modal="false" center :visible.sync="visib" :before-close="closeDialog"> <el-dialog
<el-form ref="userForm" :model="dialogForm" :rules="rules" size="small" label-width="100px"> title="项目基础配置"
width="50%"
:close-on-click-modal="false"
center
:visible.sync="visib"
:before-close="closeDialog"
>
<el-form
ref="userForm"
:model="dialogForm"
:rules="rules"
size="small"
label-width="100px"
>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :xs="24" :sm="20" :md="8" :lg="8" :xl="8"> <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
<el-form-item label="数据源类型" prop="sourceType"> <el-form-item label="数据源类型" prop="sourceType">
<el-select v-model.trim="dialogForm.sourceType" placeholder="请选择" clearable @change="selectChange"> <el-select
<el-option v-for="item in dictionaryOptions" :key="item.id" :label="item.text" :value="item.id" /> v-model.trim="dialogForm.sourceType"
placeholder="请选择"
clearable
@change="selectChange"
>
<el-option
v-for="item in dictionaryOptions"
:key="item.id"
:label="item.text"
:value="item.id"
/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6"> <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
<el-form-item label="数据源编码" prop="sourceCode"> <el-form-item label="数据源编码" prop="sourceCode">
<el-input :disabled="updataDisabled" v-model.trim="dialogForm.sourceCode" placeholder="唯一标识" /> <el-input
:disabled="updataDisabled"
v-model.trim="dialogForm.sourceCode"
placeholder="唯一标识"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="20" :md="6" :lg="6" :xl="6"> <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
<el-form-item label="数据源名称" prop="sourceName"> <el-form-item label="数据源名称" prop="sourceName">
<el-input v-model.trim="dialogForm.sourceName" /> <el-input v-model.trim="dialogForm.sourceName" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :xs="24" :sm="20" :md="20" :lg="20" :xl="20"> <el-col :xs="24" :sm="20" :md="24" :lg="24" :xl="24">
<el-form-item label="数据源描述"> <el-form-item label="数据源描述">
<el-input v-model.trim="dialogForm.sourceDesc" type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" /> <el-input
v-model.trim="dialogForm.sourceDesc"
type="textarea"
:autosize="{ minRows: 2, maxRows: 4 }"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="10"> <el-row :gutter="10">
<el-col v-for="(data, index) in dataLink" :key="index" :xs="24" :sm="20" :md="20" :lg="20" :xl="20"> <el-col
v-for="(data, index) in dataLink"
:key="index"
:xs="24"
:sm="24"
:md="24"
:lg="24"
:xl="24"
>
<el-form-item :label="data.labelValue"> <el-form-item :label="data.labelValue">
<el-input v-model.trim="data.value" /> <el-input v-model.trim="data.value" />
</el-form-item> </el-form-item>
@ -36,37 +75,44 @@
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="closeDialog"></el-button> <el-button @click="closeDialog"></el-button>
<el-button type="warning" @click="test"></el-button> <el-button type="warning" @click="test"></el-button>
<el-button type="primary" @click="UserConfirm('userForm')"></el-button> <el-button type="primary" @click="UserConfirm('userForm')"
>确定</el-button
>
</div> </div>
</el-dialog> </el-dialog>
</template> </template>
<script> <script>
import { testConnection, reportDataSourceDetail, reportDataSourceAdd, reportDataSourceUpdate } from '@/api/reportDataSource' import {
import { getDictList } from '@/api/dict-data' // testConnection,
import Dictionary from '@/components/Dictionary/index' reportDataSourceDetail,
import {validateEngOrNum} from "@/utils/validate"; reportDataSourceAdd,
reportDataSourceUpdate
} from "@/api/reportDataSource";
import { getDictList } from "@/api/dict-data"; //
import Dictionary from "@/components/Dictionary/index";
import { validateEngOrNum } from "@/utils/validate";
export default { export default {
name: 'Support', name: "Support",
components: { Dictionary }, components: { Dictionary },
props: { props: {
visib: { visib: {
required: true, required: true,
type: Boolean, type: Boolean,
default: false, default: false
}, },
dataSource: { dataSource: {
required: false, required: false,
type: Object, type: Object,
default: () => { default: () => {
return '' return "";
}, }
}, }
}, },
data() { data() {
return { return {
dictionaryOptions: [], // dictionaryOptions: [], //
selectedList: [], selectedList: [],
clickType: '', clickType: "",
formData: {}, formData: {},
list: null, list: null,
totalCount: 0, totalCount: 0,
@ -76,140 +122,139 @@ export default {
dialogFormVisible: false, dialogFormVisible: false,
basicDialog: false, basicDialog: false,
params: { params: {
sourceName: '', sourceName: "",
sourceCode: '', sourceCode: "",
sourceType: '', sourceType: "",
pageNumber: 1, pageNumber: 1,
pageSize: 10, pageSize: 10,
order: 'DESC', order: "DESC",
sort: 'update_time', sort: "update_time"
}, },
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" },
{ validator: validateEngOrNum, trigger: 'blur' }, { validator: validateEngOrNum, trigger: "blur" }
], ],
sourceName: [ sourceName: [
{ required: true, message: '数据源名称必选', trigger: 'blur' }, { required: true, message: "数据源名称必选", trigger: "blur" }
], ]
}, },
value: '', value: "",
updataDisabled: false, updataDisabled: false,
testReplyCode: null, testReplyCode: null
} };
}, },
// beforeCreatethis // beforeCreatethis
beforeCreate: function () {}, beforeCreate: function() {},
mounted() {}, mounted() {},
methods: { methods: {
async setDataSource() { async setDataSource() {
this.dialogForm = { this.dialogForm = {
sourceName: '', sourceName: "",
sourceCode: '', sourceCode: "",
sourceType: '', sourceType: "",
sourceDesc: '', sourceDesc: "",
sourceConfig: '', sourceConfig: ""
} };
//dataSourceId //dataSourceId
if (this.dataSource.id) { if (this.dataSource.id) {
const {code, data} = await reportDataSourceDetail(this.dataSource) const { code, data } = await reportDataSourceDetail(this.dataSource);
if (code != '200') return if (code != "200") return;
this.dialogForm = data this.dialogForm = data;
const newSourceType = this.dialogForm const newSourceType = this.dialogForm;
let newDataLink = [] let newDataLink = [];
this.dictionaryOptions.map((item) => { this.dictionaryOptions.map(item => {
if (item.id == newSourceType.sourceType) { if (item.id == newSourceType.sourceType) {
newDataLink = JSON.parse(item.extend) newDataLink = JSON.parse(item.extend);
var sourceConfigJson = JSON.parse(newSourceType.sourceConfig) var sourceConfigJson = JSON.parse(newSourceType.sourceConfig);
for (var i = 0; i < newDataLink.length; i++) { for (var i = 0; i < newDataLink.length; i++) {
newDataLink[i].value = sourceConfigJson[newDataLink[i].label] newDataLink[i].value = sourceConfigJson[newDataLink[i].label];
} }
} }
}) });
this.dataLink = newDataLink this.dataLink = newDataLink;
} }
}, },
// //
async getSystem() { async getSystem() {
const { code, data } = await getDictList('SOURCE_TYPE') const { code, data } = await getDictList("SOURCE_TYPE");
if (code != '200') return if (code != "200") return;
this.dictionaryOptions = data this.dictionaryOptions = data;
this.dialogForm.sourceType = this.dictionaryOptions[0].text this.dialogForm.sourceType = this.dictionaryOptions[0].text;
this.dataLink = JSON.parse(this.dictionaryOptions[0].extend) this.dataLink = JSON.parse(this.dictionaryOptions[0].extend);
this.setDataSource() this.setDataSource();
}, },
// //
closeDialog() { closeDialog() {
this.$emit('handleClose') this.$emit("handleClose");
}, },
// //
async UserConfirm(formName) { async UserConfirm(formName) {
const newList = {} const newList = {};
this.dataLink.forEach((item) => { this.dataLink.forEach(item => {
newList[item.label] = item.value newList[item.label] = item.value;
}) });
this.dialogForm.sourceConfig = JSON.stringify(newList) this.dialogForm.sourceConfig = JSON.stringify(newList);
this.$refs[formName].validate(async (valid, obj) => { this.$refs[formName].validate(async (valid, obj) => {
if (valid) { if (valid) {
if (this.testReplyCode != '200') { if (this.testReplyCode != "200") {
this.$message.error('测试结果为成功后方可保存!') this.$message.error("测试结果为成功后方可保存!");
return return;
} }
if (this.dialogForm.id == undefined) { if (this.dialogForm.id == undefined) {
const { code } = await reportDataSourceAdd(this.dialogForm) const { code } = await reportDataSourceAdd(this.dialogForm);
if (code != '200') return if (code != "200") return;
// this.queryByPage() // this.queryByPage()
this.$emit('refreshList') this.$emit("refreshList");
} else { } else {
const { code } = await reportDataSourceUpdate(this.dialogForm) const { code } = await reportDataSourceUpdate(this.dialogForm);
if (code != '200') return if (code != "200") return;
// this.queryByPage() // this.queryByPage()
this.$emit('refreshList') this.$emit("refreshList");
} }
this.closeDialog() this.closeDialog();
} else { } else {
return return;
} }
}) });
}, },
selectChange(val) { selectChange(val) {
this.dataLink = [] this.dataLink = [];
const extendJSON = this.dictionaryOptions.find(function (obj) { const extendJSON = this.dictionaryOptions.find(function(obj) {
return obj.id == val return obj.id == val;
}) });
this.dataLink = JSON.parse(extendJSON.extend) this.dataLink = JSON.parse(extendJSON.extend);
}, },
// //
test() { test() {
const newList = {} const newList = {};
this.dataLink.forEach((item) => { this.dataLink.forEach(item => {
newList[item.label] = item.value newList[item.label] = item.value;
}) });
this.dialogForm.sourceConfig = JSON.stringify(newList) this.dialogForm.sourceConfig = JSON.stringify(newList);
testConnection(this.dialogForm).then((data) => { testConnection(this.dialogForm).then(data => {
if (data.code == '200') { if (data.code == "200") {
this.testReplyCode = data.code this.testReplyCode = data.code;
this.$message({ this.$message({
message: '测试成功!', message: "测试成功!",
type: 'success', type: "success"
}) });
} else { } else {
this.testReplyCode = null this.testReplyCode = null;
} }
}) });
}, }
}
}, };
}
</script> </script>

Loading…
Cancel
Save