字段信息提取
This commit is contained in:
parent
e35b70afb6
commit
5ebb68075f
|
|
@ -1,9 +1,8 @@
|
|||
NODE_ENV = production
|
||||
NODE_ENV = staging
|
||||
|
||||
# 测试环境配置
|
||||
ENV = 'staging'
|
||||
|
||||
# EBTS/测试环境
|
||||
#VUE_APP_BASE_API = '/dev-api'
|
||||
#VUE_APP_BASE_API = 'https://api.ebts.top/dev-api'
|
||||
VUE_APP_BASE_API = 'http://tapi.ebts.top/dev-api'
|
||||
VUE_APP_BASE_API = 'http://localhost:8085/dev-api'
|
||||
|
|
|
|||
|
|
@ -19,3 +19,4 @@ npm run build:stage
|
|||
# 构建生产环境
|
||||
npm run build:prod
|
||||
```
|
||||
workflowe
|
||||
|
|
@ -6,7 +6,8 @@
|
|||
<el-col :span="18">
|
||||
<el-form-item label-width="1px" label="">
|
||||
<textarea ref="textarea" type="textarea" @change="sqlChang" placeholder="请输入sql"
|
||||
:autosize="{minRows: 7, maxRows: 7}" :style="{width: '100%'}"></textarea>
|
||||
:autosize="{minRows: 7, maxRows: 7}" :style="{width: '100%'}"
|
||||
></textarea>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
|
|
@ -26,13 +27,22 @@
|
|||
<el-button type="text" icon="el-icon-view" size="medium" @click="previewQuery">预览</el-button>
|
||||
<el-button type="text" icon="el-icon-plus" size="medium" @click="handleAdd">新增</el-button>
|
||||
<el-button type="text" icon="el-icon-download" size="medium" @click="handleExport">导出</el-button>
|
||||
<el-button v-if="info.isRelease == 2" type="text" icon="el-icon-success" size="medium" @click="handRelease(1)">发布</el-button>
|
||||
<el-button v-if="info.isRelease == 1" type="text" icon="el-icon-error" size="medium" @click="handRelease(2)">撤销</el-button>
|
||||
<el-button type="text" icon="el-icon-download" size="medium" @click="fieldExtract">字段提取</el-button>
|
||||
<el-button type="text" icon="el-icon-download" size="medium" @click="fieldEdit">字段修改
|
||||
</el-button>
|
||||
<el-button v-if="info.isRelease === 2" type="text" icon="el-icon-success" size="medium"
|
||||
@click="handRelease(1)"
|
||||
>发布
|
||||
</el-button>
|
||||
<el-button v-if="info.isRelease === 1" type="text" icon="el-icon-error" size="medium"
|
||||
@click="handRelease(2)"
|
||||
>撤销
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-form>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight">
|
||||
<el-table ref="dragTable" :data="columns" row-key="columnId" :max-height="tableHeight">
|
||||
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
|
||||
<el-table-column label="查询名称" min-width="10%">
|
||||
<template slot-scope="scope">
|
||||
|
|
@ -90,7 +100,8 @@
|
|||
type="date"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"
|
||||
placeholder="选择日期时间">
|
||||
placeholder="选择日期时间"
|
||||
>
|
||||
</el-date-picker>
|
||||
<el-date-picker v-else-if="scope.row.type ==4"
|
||||
v-model="scope.row.ucMock"
|
||||
|
|
@ -121,10 +132,11 @@
|
|||
<div class="el-table">
|
||||
<el-table v-show="previewDate.open" :data="previewDate.data">
|
||||
<el-table-column v-for="item in previewDate.header"
|
||||
:label="item"
|
||||
:label="item.label"
|
||||
align="center"
|
||||
:key="item"
|
||||
:prop="item"/>
|
||||
:key="item.key"
|
||||
:prop="item.prop"
|
||||
/>
|
||||
</el-table>
|
||||
<pagination
|
||||
v-show="total>0"
|
||||
|
|
@ -134,6 +146,44 @@
|
|||
@pagination="previewQuery"
|
||||
/>
|
||||
</div>
|
||||
<el-dialog
|
||||
title="字段信息"
|
||||
:visible.sync="columnInfo.open"
|
||||
width="40%"
|
||||
>
|
||||
<el-table ref="columnInfoTable" :data="columnInfo.list" row-key="column">
|
||||
<el-table-column label="字段信息" min-width="10%">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.prop"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示名称" min-width="10%">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.label"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" min-width="5%">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="columnInfoDelete(scope.$index,scope.row)"
|
||||
>删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div style="text-align:center;">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
size="medium"
|
||||
@click="resetFieldExtract"
|
||||
>重置字段信息
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
|
@ -150,12 +200,11 @@ import 'codemirror/theme/idea.css'
|
|||
import 'codemirror/mode/sql/sql.js'
|
||||
|
||||
//代码补全提示
|
||||
import 'codemirror/addon/hint/show-hint.css';
|
||||
import 'codemirror/addon/hint/show-hint.js';
|
||||
import 'codemirror/addon/hint/sql-hint.js';
|
||||
import 'codemirror/addon/hint/show-hint.css'
|
||||
import 'codemirror/addon/hint/show-hint.js'
|
||||
import 'codemirror/addon/hint/sql-hint.js'
|
||||
import { getQueryInfo, editQueryInfo, previewQueryData, Release, exportMock } from '@/api/tool/query'
|
||||
import {Message} from "element-ui";
|
||||
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
function JSONString(list) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
|
|
@ -165,12 +214,12 @@ function JSONString(list) {
|
|||
} else if (list[i].type == 4) {
|
||||
let time = {
|
||||
startTime: list[i].ucMock[0],
|
||||
endTime: list[i].ucMock[1],
|
||||
endTime: list[i].ucMock[1]
|
||||
}
|
||||
list[i].ucMock = JSON.stringify(time)
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return list
|
||||
}
|
||||
|
||||
function JSONparse(list) {
|
||||
|
|
@ -182,7 +231,7 @@ function JSONparse(list) {
|
|||
list[i].ucMock = [time.startTime, time.endTime]
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return list
|
||||
}
|
||||
|
||||
export default {
|
||||
|
|
@ -190,10 +239,10 @@ export default {
|
|||
props: [],
|
||||
data() {
|
||||
return {
|
||||
tableHeight: document.documentElement.scrollHeight - 245 + "px",
|
||||
tableHeight: document.documentElement.scrollHeight - 245 + 'px',
|
||||
// 表列信息
|
||||
cloumns: [],
|
||||
sqlconfig: {
|
||||
columns: [],
|
||||
sqlConfig: {
|
||||
// 默认的语法类型
|
||||
mode: 'sql',
|
||||
// 编辑器实例
|
||||
|
|
@ -209,73 +258,165 @@ export default {
|
|||
// 显示行号
|
||||
lineNumbers: true,
|
||||
line: true,
|
||||
extraKeys: {"Tab": "autocomplete"},
|
||||
extraKeys: { 'Tab': 'autocomplete' },
|
||||
lineWrapping: true,//代码折叠
|
||||
matchBrackets: true,//括号匹配
|
||||
},
|
||||
matchBrackets: true//括号匹配
|
||||
}
|
||||
},
|
||||
total: 0,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
pageSize: 10
|
||||
},
|
||||
queryId: null,
|
||||
info: {
|
||||
uqSql: '',
|
||||
uqName: null,
|
||||
uqDescribe: null,
|
||||
columnList: []
|
||||
},
|
||||
columnInfo: {
|
||||
open: false,
|
||||
list: []
|
||||
},
|
||||
|
||||
previewDate: {
|
||||
open: false,
|
||||
data: [],
|
||||
header: [],
|
||||
header: []
|
||||
},
|
||||
rules: {
|
||||
uqName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
uqDescribe: [{required: true, message: '请输入描述', trigger: 'blur'}],
|
||||
},
|
||||
uqDescribe: [{ required: true, message: '请输入描述', trigger: 'blur' }]
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {},
|
||||
watch: {},
|
||||
created() {
|
||||
this.queryId = this.$route.params && this.$route.params.queryId;
|
||||
this.queryId = this.$route.params && this.$route.params.queryId
|
||||
getQueryInfo(this.queryId).then(res => {
|
||||
this.cloumns = []
|
||||
this.columns = []
|
||||
this.info = res.data.info
|
||||
this.cloumns = JSONparse(res.data.list)
|
||||
this.sqlconfig.coder.setValue(this.info.uqSql)
|
||||
this.columns = JSONparse(res.data.list)
|
||||
this.sqlConfig.coder.setValue(this.info.uqSql)
|
||||
})
|
||||
this.$nextTick(function() {
|
||||
this.initialize();
|
||||
});
|
||||
this.initialize()
|
||||
})
|
||||
},
|
||||
mounted() {
|
||||
},
|
||||
methods: {
|
||||
columnInfoDelete(index) {
|
||||
this.columnInfo.list.splice(index, 1)
|
||||
},
|
||||
resetFieldExtract() {
|
||||
this.columnInfo.list = []
|
||||
this.previewDate.header = []
|
||||
this.columnInfo.open = false
|
||||
},
|
||||
/**
|
||||
* 字段提取
|
||||
*/
|
||||
fieldExtract() {
|
||||
let that = this
|
||||
if (that.columnInfo.list.length === 0) {
|
||||
that.doFieldExtract()
|
||||
} else {
|
||||
this.$confirm('已有字段信息,是否覆盖原有数据?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
that.doFieldExtract()
|
||||
})
|
||||
}
|
||||
},
|
||||
fieldEdit() {
|
||||
if (this.columnInfo.list.length === 0) {
|
||||
this.fieldExtract()
|
||||
} else {
|
||||
this.columnInfo.open = true
|
||||
}
|
||||
},
|
||||
doFieldExtractToPreviewData() {
|
||||
if (this.previewDate.header.length === 0) {
|
||||
Message({
|
||||
message: '预览数据为空,无法提取,请先点击预览',
|
||||
type: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
let columnList = []
|
||||
this.previewDate.header.forEach(item => {
|
||||
columnList.push({
|
||||
prop: item.key,
|
||||
label: item.label
|
||||
})
|
||||
})
|
||||
this.columnInfo.list = columnList
|
||||
this.columnInfo.open = true
|
||||
},
|
||||
/**
|
||||
* 获取字段
|
||||
*/
|
||||
doFieldExtract() {
|
||||
let sql = this.info.uqSql.toLowerCase()
|
||||
let selectIndex = sql.indexOf('select')
|
||||
let fromIndex = sql.indexOf('from')
|
||||
let columnStr = sql.slice(selectIndex + 6, fromIndex)
|
||||
let str = columnStr.replace(/\s+/g, '')
|
||||
if (str.length === 1 && str === '*') {
|
||||
let that = this
|
||||
this.$confirm('sql中为*,尝试着从预览数据中获取子弹信息?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'info'
|
||||
}).then(function() {
|
||||
that.doFieldExtractToPreviewData()
|
||||
})
|
||||
return
|
||||
}
|
||||
let columnList = []
|
||||
let columnStrList = columnStr.split(',')
|
||||
for (let column of columnStrList) {
|
||||
let asIndex = column.indexOf('as')
|
||||
if (asIndex > -1) {
|
||||
column = column.slice(asIndex + 2)
|
||||
}
|
||||
column = column.replace(/\s+/g, '')
|
||||
let columnItem = {
|
||||
prop: column,
|
||||
label: column
|
||||
}
|
||||
columnList.push(columnItem)
|
||||
}
|
||||
this.columnInfo.list = columnList
|
||||
this.columnInfo.open = true
|
||||
console.log(this.columnInfo.list)
|
||||
},
|
||||
changUniCon(list) {
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
if (list[i].ucName == "") {
|
||||
if (list[i].ucName == '') {
|
||||
Message({
|
||||
message: "序号" + i + "查询名称不能为空!",
|
||||
message: '序号' + i + '查询名称不能为空!',
|
||||
type: 'error'
|
||||
})
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
if (list[i].ucDescribe == "") {
|
||||
if (list[i].ucDescribe == '') {
|
||||
Message({
|
||||
message: "序号" + i + "描述不能为空!",
|
||||
message: '序号' + i + '描述不能为空!',
|
||||
type: 'error'
|
||||
})
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
if (list[i].ucKey == "") {
|
||||
if (list[i].ucKey == '') {
|
||||
Message({
|
||||
message: "序号" + i + "key不能为空!",
|
||||
message: '序号' + i + 'key不能为空!',
|
||||
type: 'error'
|
||||
})
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
|
|
@ -284,13 +425,13 @@ export default {
|
|||
handRelease(release) {
|
||||
let data = {
|
||||
id: this.queryId,
|
||||
isRelease: release,
|
||||
isRelease: release
|
||||
}
|
||||
Release(data).then(res => {
|
||||
this.info.isRelease = (this.info.isRelease == 1) ? 2 : 1
|
||||
Message({
|
||||
message: res.msg,
|
||||
type:"success"
|
||||
type: 'success'
|
||||
})
|
||||
})
|
||||
},
|
||||
|
|
@ -298,7 +439,7 @@ export default {
|
|||
previewQuery() {
|
||||
this.$refs['elForm'].validate(valid => {
|
||||
if (valid) {
|
||||
let list = JSONString(this.cloumns)
|
||||
let list = JSONString(this.columns)
|
||||
let data = this.info
|
||||
if (list.length > 0) {
|
||||
if (this.changUniCon(list)) {
|
||||
|
|
@ -313,25 +454,39 @@ export default {
|
|||
this.previewDate.data = res.rows
|
||||
this.total = res.total
|
||||
this.previewDate.header = []
|
||||
if (this.columnInfo.list.length > 0) {
|
||||
this.columnInfo.list.forEach(item => {
|
||||
this.previewDate.header.push({
|
||||
key: item.prop,
|
||||
label: item.label,
|
||||
prop: item.prop
|
||||
})
|
||||
})
|
||||
} else {
|
||||
for (var key in this.previewDate.data[0]) {
|
||||
this.previewDate.header.push(key)
|
||||
this.previewDate.header.push({
|
||||
key: key,
|
||||
label: key,
|
||||
prop: key
|
||||
})
|
||||
}
|
||||
}
|
||||
this.previewDate.open = true
|
||||
this.cloumns = JSONparse(list)
|
||||
this.columns = JSONparse(list)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
sqlChang() {
|
||||
console.log(this.sqlconfig.coder.getValue())
|
||||
console.log(this.sqlConfig.coder.getValue())
|
||||
},
|
||||
initialize() {
|
||||
// 初始化编辑器实例,传入需要被实例化的文本域对象和默认配置
|
||||
this.sqlconfig.coder = CodeMirror.fromTextArea(this.$refs.textarea, this.sqlconfig.options)
|
||||
this.sqlConfig.coder = CodeMirror.fromTextArea(this.$refs.textarea, this.sqlConfig.options)
|
||||
// 编辑器赋值
|
||||
this.sqlconfig.coder.setValue(this.info.uqSql)
|
||||
this.sqlConfig.coder.setValue(this.info.uqSql)
|
||||
// 支持双向绑定
|
||||
this.sqlconfig.coder.on('change', (coder) => {
|
||||
this.sqlConfig.coder.on('change', (coder) => {
|
||||
this.info.uqSql = coder.getValue()
|
||||
if (this.$emit) {
|
||||
this.$emit('input', this.info.uqSql)
|
||||
|
|
@ -341,23 +496,23 @@ export default {
|
|||
},
|
||||
/** 删除按钮 */
|
||||
handleDelete(index) {
|
||||
this.cloumns.splice(index, 1);
|
||||
this.columns.splice(index, 1)
|
||||
},
|
||||
ucTypeChang(index, row) {
|
||||
if (row.ucType == 'input' && row.ucCon != 'BETWEEN') {
|
||||
this.cloumns[index].type = 1
|
||||
if (typeof (this.cloumns[index].ucMock) != 'string') {
|
||||
this.cloumns[index].ucMock = ''
|
||||
this.columns[index].type = 1
|
||||
if (typeof (this.columns[index].ucMock) != 'string') {
|
||||
this.columns[index].ucMock = ''
|
||||
}
|
||||
} else if (row.ucType == 'input' && row.ucCon == 'BETWEEN') {
|
||||
this.cloumns[index].type = 2
|
||||
this.cloumns[index].ucMock = {begin: '', end: ''}
|
||||
this.columns[index].type = 2
|
||||
this.columns[index].ucMock = { begin: '', end: '' }
|
||||
} else if (row.ucType == 'datetime' && row.ucCon != 'BETWEEN') {
|
||||
this.cloumns[index].type = 3
|
||||
this.cloumns[index].ucMock = ''
|
||||
this.columns[index].type = 3
|
||||
this.columns[index].ucMock = ''
|
||||
} else if (row.ucType == 'datetime' && row.ucCon == 'BETWEEN') {
|
||||
this.cloumns[index].type = 4
|
||||
this.cloumns[index].ucMock = []
|
||||
this.columns[index].type = 4
|
||||
this.columns[index].ucMock = []
|
||||
}
|
||||
},
|
||||
/** 添加 */
|
||||
|
|
@ -371,20 +526,27 @@ export default {
|
|||
ucKey: '',
|
||||
ucMock: '',
|
||||
ucType: 'input',
|
||||
type: 1,
|
||||
type: 1
|
||||
}
|
||||
this.cloumns.push(row)
|
||||
this.columns.push(row)
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs['elForm'].validate(valid => {
|
||||
if (valid) {
|
||||
let list = JSONString(this.cloumns)
|
||||
let list = JSONString(this.columns)
|
||||
let data = this.info
|
||||
if (list.length > 0) {
|
||||
data.uniCons = list
|
||||
}
|
||||
if (this.columnInfo.list.length === 0){
|
||||
Message({
|
||||
message: '字段信息为空,请提取字段信息',
|
||||
type: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
editQueryInfo(data).then(res => {
|
||||
this.cloumns = JSONparse(list)
|
||||
this.columns = JSONparse(list)
|
||||
Message({
|
||||
message: res.msg,
|
||||
type: 'success'
|
||||
|
|
@ -401,10 +563,10 @@ export default {
|
|||
var that = this
|
||||
let list = JSONString(that.cloumns)
|
||||
let data = that.info
|
||||
this.$confirm('是否确认导出查询数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
this.$confirm('是否确认导出查询数据项?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(function() {
|
||||
if (list.length > 0) {
|
||||
if (that.changUniCon(list)) {
|
||||
|
|
@ -416,7 +578,7 @@ export default {
|
|||
return exportMock(data)
|
||||
}).then(response => {
|
||||
that.cloumns = JSONparse(list)
|
||||
this.download(response.msg);
|
||||
this.download(response.msg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ spring:
|
|||
druid:
|
||||
# 主库数据源
|
||||
master:
|
||||
url: jdbc:mysql://13.75.92.40:3306/gen?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: gen
|
||||
url: jdbc:mysql://162.14.111.170:3306/ebts?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: ebts
|
||||
password: zcsbKxPseM8LhFdT
|
||||
# 从库数据源
|
||||
slave:
|
||||
|
|
@ -28,11 +28,12 @@ spring:
|
|||
password:
|
||||
redis:
|
||||
# 地址
|
||||
host: 13.70.28.14
|
||||
host: 162.14.111.170
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 密码
|
||||
password: 926425
|
||||
database: 5
|
||||
ftp:
|
||||
# ftp服务器ip地址
|
||||
ftpAddress: 13.75.92.40
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ logging:
|
|||
|
||||
# Spring配置
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
# 数据源配置
|
||||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
|
|
@ -119,8 +121,6 @@ spring:
|
|||
messages:
|
||||
# 国际化资源文件路径
|
||||
basename: i18n/messages
|
||||
profiles:
|
||||
active: druid
|
||||
# 文件上传
|
||||
servlet:
|
||||
multipart:
|
||||
|
|
|
|||
Loading…
Reference in New Issue