diff --git a/report-ui/src/views/report/datasource/index.vue b/report-ui/src/views/report/datasource/index.vue index 221f74b5..eedee02b 100644 --- a/report-ui/src/views/report/datasource/index.vue +++ b/report-ui/src/views/report/datasource/index.vue @@ -11,142 +11,64 @@ - + - + - + - 查询 - 重置 + 查询 + 重置 - 新增 + 新增 - - - - - - - - - - + + + + + + + + + +
- +
- - + + - - + + - + @@ -156,24 +78,12 @@ - + - + @@ -183,9 +93,7 @@ @@ -197,19 +105,19 @@ import { testConnection, addDataSource, editDataSource, - deleteDataSource -} from "@/api/report"; -import { getDictList } from "@/api/dict-data"; // 获取数据字典 -import Dictionary from "@/components/Dictionary/index"; + deleteDataSource, +} from '@/api/report' +import { getDictList } from '@/api/dict-data' // 获取数据字典 +import Dictionary from '@/components/Dictionary/index' export default { - name: "Support", + name: 'Support', components: { Dictionary }, data() { return { dictionaryOptions: [], // 数据源类型 selectedList: [], - clickType: "", + clickType: '', formData: {}, list: null, totalCount: 0, @@ -219,206 +127,206 @@ export default { dialogFormVisible: false, basicDialog: false, params: { - sourceName: "", - sourceCode: "", - sourceType: "", + sourceName: '', + sourceCode: '', + sourceType: '', pageNumber: 1, pageSize: 10, - order: "DESC", - sort: "update_time" + order: 'DESC', + sort: 'update_time', }, dialogForm: { - sourceName: "", - sourceCode: "", - sourceType: "", - sourceDesc: "", - sourceConfig: "" + sourceName: '', + sourceCode: '', + sourceType: '', + sourceDesc: '', + sourceConfig: '', }, dataLink: [], rules: { sourceType: [ - { required: true, message: "数据集名称必选", trigger: "change" } + { required: true, message: '数据集名称必选', trigger: 'change' }, ], sourceCode: [ - { required: true, message: "数据集编码必填", trigger: "blur" } + { required: true, message: '数据集编码必填', trigger: 'blur' }, ], sourceName: [ - { required: true, message: "数据源名称必选", trigger: "blur" } - ] + { required: true, message: '数据源名称必选', trigger: 'blur' }, + ], }, - value: "", + value: '', updataDisabled: false, - testReplyCode: null - }; + testReplyCode: null, + } }, watch: {}, // 在生命周期 beforeCreate里面改变this指向 - beforeCreate: function() {}, + beforeCreate: function () {}, mounted() {}, created() { - this.getSystem(); - this.queryByPage(); + this.getSystem() + this.queryByPage() }, methods: { // 查询 search() { - this.params.pageNumber = 1; - this.queryByPage(); + this.params.pageNumber = 1 + this.queryByPage() }, // 重置 reset(formName) { // this.$refs[formName].resetFields() - this.params.sourceName = ""; - this.params.sourceCode = ""; - this.params.pageNumber = 1; - this.params.sourceType = ""; - this.queryByPage(); + this.params.sourceName = '' + this.params.sourceCode = '' + this.params.pageNumber = 1 + this.params.sourceType = '' + this.queryByPage() }, async queryByPage() { - const res = await pageList(this.params); - if (res.code != "200") return; - this.listLoading = true; - this.list = res.data.records; - this.list.forEach(value => { - value["sourceNameCode"] = - value.sourceName + "[" + value.sourceCode + "]"; - }); - this.totalCount = res.data.total; - this.totalPage = res.data.pages; - this.listLoading = false; + const res = await pageList(this.params) + if (res.code != '200') return + this.listLoading = true + this.list = res.data.records + this.list.forEach((value) => { + value['sourceNameCode'] = + value.sourceName + '[' + value.sourceCode + ']' + }) + this.totalCount = res.data.total + this.totalPage = res.data.pages + this.listLoading = false }, handleSizeChange(val) { - this.params.pageSize = val; - this.queryByPage(); + this.params.pageSize = val + this.queryByPage() }, handleCurrentChange(val) { - this.params.pageNumber = val; - this.queryByPage(); + this.params.pageNumber = val + this.queryByPage() }, // 关闭模态框 closeDialog(bool) { // bool && this.search('form') // 点确定关闭弹窗的时候才会刷新列表 // this.$refs['userForm'].resetFields() - this.basicDialog = false; + this.basicDialog = false }, // 打开模态框 showAddLogModel(val) { - this.basicDialog = true; + this.basicDialog = true if (val == undefined) { - this.updataDisabled = false; - this.getSystem(); + this.updataDisabled = false + this.getSystem() this.dialogForm = { - sourceName: "", - sourceCode: "", - sourceType: "", - sourceDesc: "", - sourceConfig: "" - }; + sourceName: '', + sourceCode: '', + sourceType: '', + sourceDesc: '', + sourceConfig: '', + } } else { - this.updataDisabled = true; - this.dialogForm = val; - const newSourceType = this.dialogForm; - let newDataLink = []; - this.dictionaryOptions.map(item => { + this.updataDisabled = true + this.dialogForm = val + const newSourceType = this.dialogForm + let newDataLink = [] + this.dictionaryOptions.map((item) => { if (item.id == newSourceType.sourceType) { - newDataLink = JSON.parse(item.extend); - var sourceConfigJson = JSON.parse(newSourceType.sourceConfig); + newDataLink = JSON.parse(item.extend) + var sourceConfigJson = JSON.parse(newSourceType.sourceConfig) 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() { - const { code, data } = await getDictList("SOURCE_TYPE"); - if (code != "200") return; - this.dictionaryOptions = data; - this.dialogForm.sourceType = this.dictionaryOptions[0].text; - this.dataLink = JSON.parse(this.dictionaryOptions[0].extend); + const { code, data } = await getDictList('SOURCE_TYPE') + if (code != '200') return + this.dictionaryOptions = data + this.dialogForm.sourceType = this.dictionaryOptions[0].text + this.dataLink = JSON.parse(this.dictionaryOptions[0].extend) }, selectChange(val) { - this.dataLink = []; - const extendJSON = this.dictionaryOptions.find(function(obj) { - return obj.id == val; - }); - this.dataLink = JSON.parse(extendJSON.extend); + this.dataLink = [] + const extendJSON = this.dictionaryOptions.find(function (obj) { + return obj.id == val + }) + this.dataLink = JSON.parse(extendJSON.extend) }, // 测试 test() { - const newList = {}; - this.dataLink.forEach(item => { - newList[item.label] = item.value; - }); - this.dialogForm.sourceConfig = JSON.stringify(newList); - testConnection(this.dialogForm).then(data => { - if (data.code == "200") { - this.testReplyCode = data.code; + const newList = {} + this.dataLink.forEach((item) => { + newList[item.label] = item.value + }) + this.dialogForm.sourceConfig = JSON.stringify(newList) + testConnection(this.dialogForm).then((data) => { + if (data.code == '200') { + this.testReplyCode = data.code this.$message({ - message: "测试成功!", - type: "success" - }); + message: '测试成功!', + type: 'success', + }) } else { - this.testReplyCode = null; + this.testReplyCode = null } - }); + }) }, async delData(val) { - this.$confirm("确定删除?", "提示", { - confirmButtonText: "确定", - cancelButtonText: "取消", - type: "warning" + this.$confirm('确定删除?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning', }) .then(async () => { - this.$emit("deletelayer"); - this.visible = false; - const { code, data } = await deleteDataSource(val); - if (code != "200") return; - this.queryByPage(); + this.$emit('deletelayer') + this.visible = false + const { code, data } = await deleteDataSource(val) + if (code != '200') return + this.queryByPage() this.$message({ - type: "success", - message: "删除成功!" - }); + type: 'success', + message: '删除成功!', + }) }) .catch(() => { this.$message({ - type: "info", - message: "已取消删除" - }); - }); + type: 'info', + message: '已取消删除', + }) + }) }, // 提交 async UserConfirm(formName) { - const newList = {}; - this.dataLink.forEach(item => { - newList[item.label] = item.value; - }); - this.dialogForm.sourceConfig = JSON.stringify(newList); + const newList = {} + this.dataLink.forEach((item) => { + newList[item.label] = item.value + }) + this.dialogForm.sourceConfig = JSON.stringify(newList) this.$refs[formName].validate(async (valid, obj) => { if (valid) { - if (this.testReplyCode != "200") { - this.$message.error("测试结果为成功后方可保存!"); - return; + if (this.testReplyCode != '200') { + this.$message.error('测试结果为成功后方可保存!') + return } if (this.dialogForm.id == undefined) { - const { code } = await addDataSource(this.dialogForm); - if (code != "200") return; - this.queryByPage(); + const { code } = await addDataSource(this.dialogForm) + if (code != '200') return + this.queryByPage() } else { - const { code } = await editDataSource(this.dialogForm); - if (code != "200") return; - this.queryByPage(); + const { code } = await editDataSource(this.dialogForm) + if (code != '200') return + this.queryByPage() } - this.closeDialog(false); + this.closeDialog(false) } else { - return; + return } - }); - } - } -}; + }) + }, + }, +}