Compare commits

...

11 Commits

Author SHA1 Message Date
Binlin B Wang 45a93030f3 Merge remote-tracking branch 'origin/master' 2022-08-02 19:16:54 +08:00
Binlin B Wang d677e7c48e . 2022-08-02 19:16:25 +08:00
clay a334e106a4 导出字段映射升级 2022-08-01 23:02:58 +08:00
clay 3dff38153a 导出字段映射升级 2022-08-01 23:02:30 +08:00
clay 788cd2c0d2 查询升级 2022-08-01 15:17:45 +08:00
Binlin B Wang f261d485a9 查询升级,结合字典类型优化 2022-08-01 14:37:34 +08:00
Binlin B Wang 9da7fc3052 查询优化升级 2022-08-01 14:36:34 +08:00
Binlin B Wang 92e0f136bf 查询优化升级 2022-07-31 22:27:03 +08:00
clay 1feca37cd4 查询升级 2022-07-31 22:25:32 +08:00
Binlin B Wang 1c86d78d1e top升级 2022-07-31 21:05:42 +08:00
clay 047bdad640 top升级 2022-07-31 21:04:29 +08:00
51 changed files with 794 additions and 340 deletions

View File

@ -4,6 +4,7 @@ ENV = 'development'
# EBTS/开发环境
#VUE_APP_BASE_API = '/dev-api'
VUE_APP_BASE_API = 'http://localhost:8085/dev-api'
#VUE_APP_BASE_API = 'https://api.ebts.top/dev-api'
# 路由懒加载

View File

@ -1,14 +1,14 @@
import request from "@/utils/request";
// 获取查询基本信息
export function RealInfo(id){
export function realInfo(id){
return request({
url: "/data/real/"+id,
method: 'get',
})
}
// 查询数据
export function RealData(data){
export function realData(data){
return request({
url: "/data/real",
method: 'put',

View File

@ -61,9 +61,9 @@ export function exportType(query) {
}
// 获取字典选择框列表
export function optionselect() {
export function optionSelect() {
return request({
url: '/system/dict/type/optionselect',
method: 'get'
})
}
}

View File

@ -1,5 +1,5 @@
import request from '@/utils/request'
import { praseStrEmpty } from "@/utils/hcy";
import { praseStrEmpty } from "@/utils/ebts";
// 查询用户列表
export function listUser(query) {

View File

@ -51,7 +51,7 @@ export default {
},
pathCompile(path) {
const { params } = this.$route
var toPath = pathToRegexp.compile(path)
let toPath = pathToRegexp.compile(path)
return toPath(params)
},
handleLink(item) {

View File

@ -18,7 +18,17 @@ import './assets/icons' // icon
import './permission' // permission control
import { getDicts } from "@/api/system/dict/data";
import { getConfigKey } from "@/api/system/config";
import { parseTime, resetForm, addDateRange, addCreateDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/hcy";
import {
parseTime,
resetForm,
addDateRange,
addCreateDateRange,
selectDictLabel,
selectDictLabels,
download,
handleTree,
parseDateOrTime, checkDateType
} from "@/utils/ebts";
import Pagination from "@/components/Pagination";
//自定义表格工具扩展
import RightToolbar from "@/components/RightToolbar"
@ -32,6 +42,8 @@ Vue.prototype.addDateRange = addDateRange
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.addCreateDateRange = addCreateDateRange
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.parseDateOrTime = parseDateOrTime
Vue.prototype.checkDateType = checkDateType
Vue.prototype.download = download
Vue.prototype.handleTree = handleTree

View File

@ -5,6 +5,20 @@
const baseURL = process.env.VUE_APP_BASE_API
export function parseDateOrTime(time){
if (time){
return parseTime(new Date(time),'{y}-{m}-{d} {h}:{m}:{s}')
}
}
/**
* 检查是否为时间类型
* @param prop
*/
export function checkDateType(prop){
prop = prop.toLowerCase().replace('update','')
return !(-1 === prop.indexOf('date') && -1 === prop.indexOf('time'))
}
// 日期格式化
export function parseTime(time, pattern) {
if (arguments.length === 0 || !time) {
@ -55,7 +69,7 @@ export function resetForm(refName) {
// 添加日期范围
export function addDateRange(params, dateRange) {
var search = params;
let search = params;
search.beginTime = "";
search.endTime = "";
if (null != dateRange && '' != dateRange) {
@ -66,7 +80,7 @@ export function addDateRange(params, dateRange) {
}
// 添加搜索创建时间日期范围
export function addCreateDateRange(params, dateRange) {
var search = params;
let search = params;
let data = {
beginCreateTime : "",
endCreateTime : "",
@ -81,9 +95,10 @@ export function addCreateDateRange(params, dateRange) {
// 回显数据字典
export function selectDictLabel(datas, value) {
var actions = [];
console.log(datas)
let actions = [];
Object.keys(datas).some((key) => {
if (datas[key].dictValue == ('' + value)) {
if (datas[key].dictValue === ('' + value)) {
actions.push(datas[key].dictLabel);
return true;
}
@ -93,12 +108,12 @@ export function selectDictLabel(datas, value) {
// 回显数据字典(字符串数组)
export function selectDictLabels(datas, value, separator) {
var actions = [];
var currentSeparator = undefined === separator ? "," : separator;
var temp = value.split(currentSeparator);
let actions = [];
let currentSeparator = undefined === separator ? "," : separator;
let temp = value.split(currentSeparator);
Object.keys(value.split(currentSeparator)).some((val) => {
Object.keys(datas).some((key) => {
if (datas[key].dictValue == ('' + temp[val])) {
if (datas[key].dictValue === ('' + temp[val])) {
actions.push(datas[key].dictLabel + currentSeparator);
}
})
@ -113,9 +128,9 @@ export function download(fileName) {
// 字符串格式化(%s )
export function sprintf(str) {
var args = arguments, flag = true, i = 1;
let args = arguments, flag = true, i = 1;
str = str.replace(/%s/g, function () {
var arg = args[i++];
let arg = args[i++];
if (typeof arg === 'undefined') {
flag = false;
return '';

View File

@ -1,17 +1,17 @@
import { parseTime } from './hcy'
import { parseTime } from './ebts'
/**
* 表格时间格式化
*/
export function formatDate(cellValue) {
if (cellValue == null || cellValue == "") return "";
var date = new Date(cellValue)
var year = date.getFullYear()
var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
var day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
var seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
let date = new Date(cellValue)
let year = date.getFullYear()
let month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
let day = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
let hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
let minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
let seconds = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds()
return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds
}
@ -84,7 +84,7 @@ export function getQueryObject(url) {
export function byteLength(str) {
// returns the byte length of an utf8 string
let s = str.length
for (var i = str.length - 1; i >= 0; i--) {
for (let i = str.length - 1; i >= 0; i--) {
const code = str.charCodeAt(i)
if (code > 0x7f && code <= 0x7ff) s++
else if (code > 0x7ff && code <= 0xffff) s += 2

View File

@ -5,13 +5,13 @@
:key="item.id"
:label="item.ucName">
<el-input v-if="item.type == 1" v-model="item.ucReal"
<el-input v-if="item.type === 1" v-model="item.ucReal"
clearable
:placeholder="outPlaceholder(item)"
size="small"
@keyup.enter.native="handleQuery"
/>
<div style="width: 200px" v-else-if="item.type == 2">
<div style="width: 200px" v-else-if="item.type === 2">
<el-row :gutter="15">
<el-col :span="12">
<el-input size="small" placeholder="开始值" v-model="item.ucReal.begin"></el-input>
@ -22,14 +22,14 @@
</el-row>
</div>
<el-date-picker
v-else-if="item.type ==3"
v-else-if="item.type ===3"
v-model="item.ucReal"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择日期时间">
</el-date-picker>
<el-date-picker v-else-if="item.type ==4"
<el-date-picker v-else-if="item.type ===4"
v-model="item.ucReal"
size="small"
style="width: 240px"
@ -64,8 +64,34 @@
:label="item.label"
align="center"
:key="index"
:prop="item.prop"
/>
:prop="item.prop">
<template slot-scope="scope">
<span v-if="checkDateType(item.prop)">
{{ parseDateOrTime(scope.row[item.prop]) }}
</span>
<span v-else-if="item.dictType!=null">
{{ dictFormat(item.dictType, scope.row[item.prop]) }}
</span>
<span v-else>{{ scope.row[item.prop] }}</span>
</template>
</el-table-column>
<!-- <span v-for="(item,index) in realDate.header">-->
<!-- <el-table-column v-if="checkDateType(item.prop)"-->
<!-- :label="item.label"-->
<!-- align="center"-->
<!-- :key="index"-->
<!-- :prop="item.prop">-->
<!-- <template slot-scope="scope">-->
<!-- {{ parseDateOrTime(scope.row[item.prop]) }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column v-else-->
<!-- :label="item.label"-->
<!-- align="center"-->
<!-- :key="index"-->
<!-- :prop="item.prop"-->
<!-- />-->
<!-- </span>-->
</el-table>
<pagination
v-show="total>0"
@ -78,13 +104,14 @@
</template>
<script>
import {RealInfo, RealData,exportReal} from "@/api/system/data"
import {realInfo, realData, exportReal} from "@/api/system/data"
import {parseTime} from "@/utils/ebts";
function listInit(list) {
for (let i = 0; i < list.length; i++) {
if (list[i].type == 2) {
if (list[i].type === 2) {
list[i].ucReal = {begin: null, end: null}
} else if (list[i].type == 4) {
} else if (list[i].type === 4) {
list[i].ucReal = []
}
}
@ -102,6 +129,7 @@ export default {
data: [],
header: [],
},
dictTypeDataList:{},
total: 0,
queryParams: {
pageNum: 1,
@ -111,14 +139,25 @@ export default {
},
created() {
this.dataId = this.$route.fullPath.split("/")[3]
RealInfo(this.dataId).then(res => {
realInfo(this.dataId).then(res => {
let data = res.data
this.uconList = listInit(data.uniCons)
this.realDate.header = data.infoList
this.dictTypeDataList = data.dictList
})
this.handleQuery()
},
methods: {
/**
* 字典渲染
* @param dictType
* @param data
* @returns {*}
*/
dictFormat(dictType, data) {
return this.selectDictLabel(this.dictTypeDataList[dictType], data)
},
outPlaceholder(item) {
return "请输入" + item.ucName
},
@ -140,27 +179,23 @@ export default {
pageSize: this.queryParams.pageSize,
}
data.uniCons = this.uconList
RealData(data).then(res => {
realData(data).then(res => {
this.realDate.data = res.rows
this.total = res.total
// this.realDate.header = []
// for (var key in this.realDate.data[0]) {
// this.realDate.header.push(key)
// }
})
},
/** 导出按钮操作 */
handleExport() {
var that = this
let that = this
this.$confirm('是否确认导出查询数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function () {
let data = {
id:that.dataId,
uniCons:that.uconList,
id: that.dataId,
uniCons: that.uconList,
}
return exportReal(data)
}).then(response => {

View File

@ -99,9 +99,9 @@ export default {
},
methods: {
transform() {
var mid = this.info.mId
var str = ''
var start = true
let mid = this.info.mId
let str = ''
let start = true
for (let i = 0; i < this.moduleList.length; i++) {
if (mid == this.moduleList[i].id) {
str = this.moduleList[i].mName

View File

@ -314,7 +314,7 @@
getClassPreview(id).then(res =>{
this.preview.data = res.data;
this.preview.open = true;
var keys = Object.keys(res.data)
let keys = Object.keys(res.data)
this.preview.activeName = keys[0]
})
},
@ -325,7 +325,7 @@
/** 高亮显示 */
highlightedCode(code, key) {
const vmName = key;
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
let language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
const result = hljs.highlight(language, code || "", true);
return result.value || '&nbsp;';
},
@ -348,9 +348,9 @@
this.$router.push("/apiclass/edit/" + apiclassId);
},
transform() {
var mid = this.form.mId
var str = ''
var start = true
let mid = this.form.mId
let str = ''
let start = true
for (let i = 0; i < this.moduleList.length; i++) {
if (mid == this.moduleList[i].id) {
str = this.moduleList[i].mName

View File

@ -117,7 +117,7 @@
:value="dict.dictType">
<span style="float: left">{{ dict.dictName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
</el-option>
</el-option>
</el-select>
</template>
</el-table-column>
@ -137,7 +137,7 @@
</template>
<script>
import { getGenTable, updateGenTable } from "@/api/tool/gen";
import { optionselect as getDictOptionselect } from "@/api/system/dict/type";
import { optionSelect as getDictOptionselect } from "@/api/system/dict/type";
import { listMenu as getMenuTreeselect } from "@/api/system/menu";
import basicInfoForm from "./basicInfoForm";
import genInfoForm from "./genInfoForm";

View File

@ -641,7 +641,7 @@ export default {
},
/** 设置关联外键 */
setSubTableColumns(value) {
for (var item in this.tables) {
for (let item in this.tables) {
const name = this.tables[item].tableName;
if (value === name) {
this.subColumns = this.tables[item].columns;

View File

@ -309,7 +309,7 @@ export default {
/** 高亮显示 */
highlightedCode(code, key) {
const vmName = key;
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
let language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
const result = hljs.highlight(language, code || "", true);
return result.value || '&nbsp;';
},

View File

@ -251,7 +251,7 @@ export default {
getModulePreview(id).then(res=>{
this.preview.data = res.data;
this.preview.open = true;
var keys = Object.keys(res.data)
let keys = Object.keys(res.data)
this.preview.activeName = keys[0]
})
},
@ -262,7 +262,7 @@ export default {
/** 高亮显示 */
highlightedCode(code, key) {
const vmName = key;
var language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
let language = vmName.substring(vmName.indexOf(".") + 1, vmName.length);
const result = hljs.highlight(language, code || "", true);
return result.value || '&nbsp;';
},

View File

@ -49,9 +49,9 @@
},
methods:{
transform() {
var mid = this.info.mId
var str = ''
var start = true
let mid = this.info.mId
let str = ''
let start = true
for (let i = 0; i < this.moduleList.length; i++) {
if (mid == this.moduleList[i].id) {
str = this.moduleList[i].mName

View File

@ -46,7 +46,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['tool:query:add']"
>新增</el-button>
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -57,7 +58,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['tool:query:edit']"
>修改</el-button>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -68,7 +70,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['tool:query:remove']"
>删除</el-button>
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -78,16 +81,17 @@
size="mini"
@click="handleExport"
v-hasPermi="['tool:query:export']"
>导出</el-button>
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="queryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="selection" width="55" align="center"/>
<el-table-column type="index" width="50"></el-table-column>
<el-table-column label="名称" align="center" prop="uqName" />
<el-table-column label="描述" align="center" prop="uqDescribe" />
<el-table-column label="名称" align="center" prop="uqName"/>
<el-table-column label="描述" align="center" prop="uqDescribe"/>
<el-table-column label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
@ -100,6 +104,7 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<span v-if="scope.row.isRelease===2">
<el-button
size="mini"
type="text"
@ -113,7 +118,7 @@
icon="el-icon-edit-outline"
@click="handleEditTable(scope.row)"
v-hasPermi="['tool:query:update']"
>编辑</el-button>
>设计</el-button>
<el-button
size="mini"
type="text"
@ -121,6 +126,15 @@
@click="handleDelete(scope.row)"
v-hasPermi="['tool:query:remove']"
>删除</el-button>
</span>
<span v-if="scope.row.isRelease===1">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handRelease(scope.row.id)"
>撤销</el-button>
</span>
</template>
</el-table-column>
</el-table>
@ -137,13 +151,10 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="名称" prop="uqName">
<el-input v-model="form.uqName" placeholder="请输入名称" />
</el-form-item>
<el-form-item label="sql语句" prop="uqSql">
<el-input v-model="form.uqSql" type="textarea" placeholder="请输入内容" />
<el-input v-model="form.uqName" placeholder="请输入名称"/>
</el-form-item>
<el-form-item label="描述" prop="uqDescribe">
<el-input v-model="form.uqDescribe" placeholder="请输入描述" />
<el-input v-model="form.uqDescribe" placeholder="请输入描述"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -155,12 +166,12 @@
</template>
<script>
import { listQuery, getQuery, delQuery, addQuery, updateQuery, exportQuery } from "@/api/tool/query";
import {listQuery, getQuery, delQuery, addQuery, updateQuery, exportQuery, Release} from "@/api/tool/query";
import {Message} from "element-ui";
export default {
name: "Query",
components: {
},
components: {},
data() {
return {
//
@ -189,17 +200,17 @@ export default {
pageSize: 10,
uqName: null,
uqDescribe: null,
type:1
type: 1
},
//
form: {},
//
rules: {
uqName: [
{ required: true, message: "名称不能为空}", trigger: "blur" },
{required: true, message: "名称不能为空}", trigger: "blur"},
],
uqDescribe: [
{ required: true, message: "描述不能为空}", trigger: "blur" },
{required: true, message: "描述不能为空}", trigger: "blur"},
],
}
};
@ -211,7 +222,7 @@ export default {
/** 查询万能查询列表 */
getList() {
this.loading = true;
listQuery(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response =>{
listQuery(this.addCreateDateRange(this.queryParams, this.daterangeCreateTime)).then(response => {
this.queryList = response.rows;
this.total = response.total;
this.loading = false;
@ -227,7 +238,6 @@ export default {
this.form = {
id: null,
uqName: null,
uqSql: null,
uqDescribe: null,
};
this.resetForm("form");
@ -237,9 +247,30 @@ export default {
this.queryParams.pageNum = 1;
this.getList();
},
handleEditTable(row){
handleEditTable(row) {
this.$router.push("/query/edit/" + row.id);
},
/** 发布与撤销 */
handRelease(id) {
let that = this
this.$confirm('是否确认撤销该查询?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
let data = {
id: id,
isRelease: 2
}
Release(data).then(res => {
Message({
message: res.msg,
type: 'success'
})
that.getList()
})
})
},
/** 重置按钮操作 */
resetQuery() {
this.daterangeCreateTime = [];
@ -249,7 +280,7 @@ export default {
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
@ -296,7 +327,7 @@ export default {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
}).then(function () {
return delQuery(ids);
}).then(() => {
this.getList();
@ -310,7 +341,7 @@ export default {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
}).then(function () {
return exportQuery(queryParams);
}).then(response => {
this.download(response.msg);

View File

@ -23,20 +23,19 @@
</el-form-item>
</el-col>
<el-col :span="6">
<span v-if="info.isRelease === 2">
<el-button type="text" icon="el-icon-upload" size="medium" @click="submitForm">提交</el-button>
<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-upload2" size="medium" @click="fieldExtract">字段提取</el-button>
<el-button type="text" icon="el-icon-edit" size="medium" @click="fieldEdit">字段修改</el-button>
</span>
<el-button type="text" icon="el-icon-download" size="medium" @click="handleExport">导出</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)"
>发布
@click="handRelease(1)">发布
</el-button>
<el-button v-if="info.isRelease === 1" type="text" icon="el-icon-error" size="medium"
@click="handRelease(2)"
>撤销
@click="handRelease(2)">撤销
</el-button>
</el-col>
</el-form>
@ -135,8 +134,36 @@
:label="item.label"
align="center"
:key="index"
:prop="item.prop"
/>
:prop="item.prop">
<template slot-scope="scope">
<span v-if="checkDateType(item.prop)">
{{ parseDateOrTime(scope.row[item.prop]) }}
</span>
<span v-else-if="item.dictType!=null">
{{ dictFormat(item.dictType, scope.row[item.prop]) }}
</span>
<span v-else>{{ scope.row[item.prop] }}</span>
</template>
</el-table-column>
<!-- <span v-for="(item,index) in previewDate.header">-->
<!-- <el-table-column v-if="checkDateType(item.prop)"-->
<!-- :label="item.label"-->
<!-- align="center"-->
<!-- :key="index"-->
<!-- :prop="item.prop">-->
<!-- <template slot-scope="scope">-->
<!-- {{ parseDateOrTime(scope.row[item.prop]) }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column v-else-->
<!-- :label="item.label"-->
<!-- align="center"-->
<!-- :key="index"-->
<!-- :prop="item.prop"-->
<!-- />-->
<!-- </span>-->
</el-table>
<pagination
v-show="total>0"
@ -151,7 +178,7 @@
:visible.sync="columnInfo.open"
width="40%"
>
<el-table ref="columnInfoTable" :data="columnInfo.list" row-key="column">
<el-table max-height="650px" 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>
@ -162,6 +189,20 @@
<el-input v-model="scope.row.label"></el-input>
</template>
</el-table-column>
<el-table-column label="显示字典类型" min-width="10%">
<template slot-scope="scope">
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
<el-option
v-for="dict in dictTypeList"
:key="dict.dictType"
:label="dict.dictName"
:value="dict.dictType">
<span style="float: left">{{ dict.dictName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="操作" align="center" min-width="5%">
<template slot-scope="scope">
<el-button
@ -203,15 +244,15 @@ 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 { getQueryInfo, editQueryInfo, previewQueryData, Release, exportMock } from '@/api/tool/query'
import { Message } from 'element-ui'
import {getQueryInfo, editQueryInfo, previewQueryData, Release, exportMock} from '@/api/tool/query'
import {optionSelect} from '@/api/system/dict/type'
import {Message} from 'element-ui'
function JSONString(list) {
for (let i = 0; i < list.length; i++) {
if (list[i].type == 2) {
if (list[i].type === 2) {
list[i].ucMock = JSON.stringify(list[i].ucMock)
} else if (list[i].type == 4) {
} else if (list[i].type === 4) {
let time = {
startTime: list[i].ucMock[0],
endTime: list[i].ucMock[1]
@ -222,11 +263,11 @@ function JSONString(list) {
return list
}
function JSONparse(list) {
function JSONParse(list) {
for (let i = 0; i < list.length; i++) {
if (list[i].type == 2) {
if (list[i].type === 2) {
list[i].ucMock = JSON.parse(list[i].ucMock)
} else if (list[i].type == 4) {
} else if (list[i].type === 4) {
let time = JSON.parse(list[i].ucMock)
list[i].ucMock = [time.startTime, time.endTime]
}
@ -242,6 +283,7 @@ export default {
tableHeight: document.documentElement.scrollHeight - 245 + 'px',
//
columns: [],
dictTypeList:[],
sqlConfig: {
//
mode: 'sql',
@ -258,7 +300,7 @@ export default {
//
lineNumbers: true,
line: true,
extraKeys: { 'Tab': 'autocomplete' },
extraKeys: {'Tab': 'autocomplete'},
lineWrapping: true,//
matchBrackets: true//
}
@ -284,9 +326,10 @@ export default {
data: [],
header: []
},
dictTypeDataList:{},
rules: {
uqName: [{ required: true, message: '请输入名称', trigger: 'blur' }],
uqDescribe: [{ required: true, message: '请输入描述', trigger: 'blur' }]
uqName: [{required: true, message: '请输入名称', trigger: 'blur'}],
uqDescribe: [{required: true, message: '请输入描述', trigger: 'blur'}]
}
}
},
@ -299,19 +342,38 @@ export default {
this.columns = []
this.info = data.info
this.columnInfo.list = data.infoList
this.columns = JSONparse(data.list)
this.columns = JSONParse(data.list)
this.sqlConfig.coder.setValue(this.info.uqSql)
})
this.$nextTick(function() {
optionSelect().then(res =>{
this.dictTypeList = res.data
})
this.$nextTick(function () {
this.initialize()
})
},
mounted() {
},
methods: {
/**
* 字典渲染
* @param dictType
* @param data
* @returns {*}
*/
dictFormat(dictType, data) {
return this.selectDictLabel(this.dictTypeDataList[dictType], data)
},
/**
* 字段信息列删除
* @param index
*/
columnInfoDelete(index) {
this.columnInfo.list.splice(index, 1)
},
/**
* 重置字段信息
*/
resetFieldExtract() {
this.columnInfo.list = []
this.previewDate.header = []
@ -329,7 +391,7 @@ export default {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
}).then(function () {
that.doFieldExtract()
})
}
@ -350,10 +412,12 @@ export default {
return
}
let columnList = []
this.columnInfo.list = []
this.previewDate.header.forEach(item => {
columnList.push({
prop: item.key,
label: item.label
label: item.label,
dictType:null
})
})
this.columnInfo.list = columnList
@ -374,7 +438,7 @@ export default {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'info'
}).then(function() {
}).then(function () {
that.doFieldExtractToPreviewData()
})
return
@ -389,7 +453,8 @@ export default {
column = column.replace(/\s+/g, '')
let columnItem = {
prop: column,
label: column
label: column,
dictType: null
}
columnList.push(columnItem)
}
@ -425,24 +490,35 @@ export default {
},
/** 发布与撤销 */
handRelease(release) {
let data = {
id: this.queryId,
isRelease: release
}
Release(data).then(res => {
this.info.isRelease = (this.info.isRelease == 1) ? 2 : 1
Message({
message: res.msg,
type: 'success'
let that = this
this.$confirm('是否确认'+(release===2?'撤销':'发布')+'该查询?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
let data = {
id: that.queryId,
isRelease: release
}
Release(data).then(res => {
that.info.isRelease = (that.info.isRelease === 1) ? 2 : 1
Message({
message: res.msg,
type: 'success'
})
})
})
},
/** 预览 */
previewQuery() {
this.$refs['elForm'].validate(valid => {
previewQuery(){
this.$refs['elForm'].validate( valid=>{
if (valid) {
let list = JSONString(this.columns)
let data = this.info
let data = {
pageNum: this.queryParams.pageNum,
pageSize: this.queryParams.pageSize,
uqSql: this.info.uqSql
}
if (list.length > 0) {
if (this.changUniCon(list)) {
data.uniCons = list
@ -450,8 +526,17 @@ export default {
return
}
}
data.pageNum = this.queryParams.pageNum
data.pageSize = this.queryParams.pageSize
for (let i = 0; i < this.columnInfo.list.length; i++) {
let info = this.columnInfo.list[i]
if (info.dictType!=null){
this.getDicts(info.dictType).then(res=>{
this.dictTypeDataList[info.dictType] = res.data
})
}
}
/**
* 预览数据请求
*/
previewQueryData(data).then(res => {
this.previewDate.data = res.rows
this.total = res.total
@ -461,20 +546,22 @@ export default {
this.previewDate.header.push({
key: item.prop,
label: item.label,
prop: item.prop
prop: item.prop,
dictType: item.dictType
})
})
} else {
for (var key in this.previewDate.data[0]) {
for (let key in this.previewDate.data[0]) {
this.previewDate.header.push({
key: key,
label: key,
prop: key
prop: key,
dictType:null
})
}
}
this.previewDate.open = true
this.columns = JSONparse(list)
this.columns = JSONParse(list)
})
}
})
@ -499,6 +586,9 @@ export default {
/** 删除按钮 */
handleDelete(index) {
this.columns.splice(index, 1)
if (!this.columns) {
this.columns = []
}
},
ucTypeChang(index, row) {
if (row.ucType == 'input' && row.ucCon != 'BETWEEN') {
@ -508,7 +598,7 @@ export default {
}
} else if (row.ucType == 'input' && row.ucCon == 'BETWEEN') {
this.columns[index].type = 2
this.columns[index].ucMock = { begin: '', end: '' }
this.columns[index].ucMock = {begin: '', end: ''}
} else if (row.ucType == 'datetime' && row.ucCon != 'BETWEEN') {
this.columns[index].type = 3
this.columns[index].ucMock = ''
@ -540,7 +630,7 @@ export default {
if (list.length > 0) {
data.uniCons = list
}
if (this.columnInfo.list.length === 0){
if (this.columnInfo.list.length === 0) {
Message({
message: '字段信息为空,请提取字段信息',
type: 'error'
@ -549,7 +639,7 @@ export default {
}
data.infoList = this.columnInfo.list
editQueryInfo(data).then(res => {
this.columns = JSONparse(list)
this.columns = JSONParse(list)
Message({
message: res.msg,
type: 'success'
@ -563,14 +653,15 @@ export default {
/** 导出按钮操作 */
handleExport() {
var that = this
let list = JSONString(that.cloumns)
let that = this
console.log(this.columns);
let list = JSONString(that.columns)
let data = that.info
this.$confirm('是否确认导出查询数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
}).then(function () {
if (list.length > 0) {
if (that.changUniCon(list)) {
data.uniCons = list
@ -578,9 +669,10 @@ export default {
return
}
}
data.infoList = that.columnInfo.list
return exportMock(data)
}).then(response => {
that.cloumns = JSONparse(list)
that.columns = JSONParse(list)
this.download(response.msg)
})
}

View File

@ -1,4 +1,3 @@
<script src="../../../api/tool/table.js"></script>
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
@ -272,12 +271,12 @@
</div>
</template>
<script>
import { listTable,columns, getTable, delTable, addTable, updateTable, exportTable, listInfoTable } from "@/api/tool/table";
import {listRole} from '../../../api/system/role'
import {listRole} from '@/api/system/role'
import importTopTable from "./importTopTable";
export default {
name: "Table",
components: { importTopTable },
data() {

View File

@ -46,7 +46,8 @@
size="mini"
@click="handleAdd"
v-hasPermi="['tool:query:add']"
>新增</el-button>
>新增
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -57,7 +58,8 @@
:disabled="single"
@click="handleUpdate"
v-hasPermi="['tool:query:edit']"
>修改</el-button>
>修改
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -68,7 +70,8 @@
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['tool:query:remove']"
>删除</el-button>
>删除
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
@ -78,16 +81,17 @@
size="mini"
@click="handleExport"
v-hasPermi="['tool:query:export']"
>导出</el-button>
>导出
</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="queryList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column type="selection" width="55" align="center"/>
<el-table-column type="index" width="50"></el-table-column>
<el-table-column label="名称" align="center" prop="uqName" />
<el-table-column label="描述" align="center" prop="uqDescribe" />
<el-table-column label="名称" align="center" prop="uqName"/>
<el-table-column label="描述" align="center" prop="uqDescribe"/>
<el-table-column label="创建时间" align="center" prop="createTime">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
@ -100,6 +104,7 @@
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<span v-if="scope.row.isRelease===2">
<el-button
size="mini"
type="text"
@ -113,7 +118,7 @@
icon="el-icon-edit-outline"
@click="handleEditTable(scope.row)"
v-hasPermi="['top:edit']"
>编辑</el-button>
>设计</el-button>
<el-button
size="mini"
type="text"
@ -121,6 +126,15 @@
@click="handleDelete(scope.row)"
v-hasPermi="['tool:query:remove']"
>删除</el-button>
</span>
<span v-if="scope.row.isRelease===1">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handRelease(scope.row.id)"
>撤销</el-button>
</span>
</template>
</el-table-column>
</el-table>
@ -137,10 +151,10 @@
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="名称" prop="uqName">
<el-input v-model="form.uqName" placeholder="请输入名称" />
<el-input v-model="form.uqName" placeholder="请输入名称"/>
</el-form-item>
<el-form-item label="描述" prop="uqDescribe">
<el-input v-model="form.uqDescribe" placeholder="请输入描述" />
<el-input v-model="form.uqDescribe" placeholder="请输入描述"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
@ -152,12 +166,12 @@
</template>
<script>
import { listQuery, getQuery, delQuery, addQuery, updateQuery, exportQuery } from "@/api/tool/query";
import {listQuery, getQuery, delQuery, addQuery, updateQuery, exportQuery, Release} from "@/api/tool/query";
import {Message} from "element-ui";
export default {
name: "Query",
components: {
},
components: {},
data() {
return {
//
@ -186,17 +200,17 @@ export default {
pageSize: 10,
uqName: null,
uqDescribe: null,
type:2
type: 2
},
//
form: {},
//
rules: {
uqName: [
{ required: true, message: "名称不能为空}", trigger: "blur" },
{required: true, message: "名称不能为空}", trigger: "blur"},
],
uqDescribe: [
{ required: true, message: "描述不能为空}", trigger: "blur" },
{required: true, message: "描述不能为空}", trigger: "blur"},
],
}
};
@ -208,7 +222,7 @@ export default {
/** 查询万能查询列表 */
getList() {
this.loading = true;
listQuery(this.addCreateDateRange(this.queryParams,this.daterangeCreateTime)).then(response =>{
listQuery(this.addCreateDateRange(this.queryParams, this.daterangeCreateTime)).then(response => {
this.queryList = response.rows;
this.total = response.total;
this.loading = false;
@ -234,8 +248,9 @@ export default {
this.queryParams.pageNum = 1;
this.getList();
},
handleEditTable(row){
this.$router.push("/top/edit/" + row.id);
handleEditTable(row) {
window.open("/top/edit/" + row.id)
// this.$router.push("/top/edit/" + row.id);
},
/** 重置按钮操作 */
resetQuery() {
@ -246,7 +261,7 @@ export default {
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
@ -293,13 +308,34 @@ export default {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
}).then(function () {
return delQuery(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
})
},
/** 发布与撤销 */
handRelease(id) {
let that = this
this.$confirm('是否确认撤销该查询?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function () {
let data = {
id: id,
isRelease: 2
}
Release(data).then(res => {
Message({
message: res.msg,
type: 'success'
})
that.getList()
})
})
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams;
@ -307,7 +343,7 @@ export default {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
}).then(function () {
return exportQuery(queryParams);
}).then(response => {
this.download(response.msg);

View File

@ -49,22 +49,33 @@
<!--<el-button size="mini" @click="$parent.dagreLayoutHandler">层次</el-button>-->
<!-- <el-button size="mini" @click="$parent.autoLayoutHandler">自动old</el-button>-->
<el-button size="mini" v-hasPermi="['top:preview']" @click="$parent.searchPreview">预览</el-button>
<el-button size="mini" v-hasPermi="['top:online']" @click="$parent.searchOnLine">上线</el-button>
<el-button v-if="isRelease === 2" size="mini" @click="$parent.searchOnLine(1)">上线</el-button>
<el-button v-if="isRelease === 1" size="mini" @click="$parent.undoOnLine(2)">撤销</el-button>
<!-- 返回到预览模式 -->
<!-- <top-button size="mini" @click="$parent.changeModeHandler('preview')">返回</top-button>-->
<top-button size="mini" v-hasPermi="['top:edit']" @click="$parent.saveDataHandler">保存</top-button>
<top-button v-if="isRelease === 2" size="mini" v-hasPermi="['top:edit']" @click="$parent.saveDataHandler">保存</top-button>
</div>
</div>
</template>
<script>
import { Button, Dropdown } from '../../elements';
import {eventBus} from "@/views/tool/top/utils/eventBus";
export default {
name: "ToolbarEdit",
components: {
"top-button": Button,
"top-dropdown": Dropdown
},
data(){
return{
isRelease:null
}
},
mounted() {
eventBus.$on('isRelease',(res)=> {
this.isRelease = res
})
}
};
</script>

View File

@ -163,7 +163,7 @@
</ul>
</div>
<div>
<el-dialog :title="selectedNodeParams.label" width="1200px"
<el-dialog :title="selectedNodeParams.label" width="1300px"
:visible.sync="tableColumnEditOpen"
@close="closeEditColumns">
<el-table
@ -203,7 +203,8 @@
<el-input v-model="scope.row.ucName" placeholder="请输入条件描述"/>
</template>
</el-table-column>
<el-table-column label="条件">
<el-table-column label="条件"
width="150px">
<template slot-scope="scope">
<el-select v-model="scope.row.ucCon" @change="ucTypeChang(scope.$index,scope.row)">
<el-option label="=" value="EQ"/>
@ -217,7 +218,8 @@
</el-select>
</template>
</el-table-column>
<el-table-column label="显示类型">
<el-table-column label="显示类型"
width="150px">
<template slot-scope="scope">
<el-select v-model="scope.row.ucType" @change="ucTypeChang(scope.$index,scope.row)">
<el-option label="文本框" value="input"/>
@ -225,7 +227,8 @@
</el-select>
</template>
</el-table-column>
<el-table-column label="模拟数据">
<el-table-column label="模拟数据"
width="260px">
<template slot-scope="scope">
<el-input v-if="scope.row.type == 1" placeholder="请输入模拟数据" v-model="scope.row.ucMock"></el-input>
<div v-else-if="scope.row.type == 2">
@ -258,6 +261,20 @@
></el-date-picker>
</template>
</el-table-column>
<el-table-column label="显示字典类型" width="150px">
<template slot-scope="scope">
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择">
<el-option
v-for="dict in dictTypeList"
:key="dict.dictType"
:label="dict.dictName"
:value="dict.dictType">
<span style="float: left">{{ dict.dictName }}</span>
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.dictType }}</span>
</el-option>
</el-select>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
@ -325,6 +342,7 @@ export default {
nodes: [],
edges: []
},
dictTypeList:[],
// Column
tableColumnEditOpen:false,
loading: false,
@ -332,11 +350,6 @@ export default {
clientHeight: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
//todo 线 er线
edgeShapeList: [
// { guid: "top-line", label: "线", class: "iconfont icon-flow-line" },
// { guid: "dice-er-edge", label: "线", class: "iconfont icon-flow-line" },
// { guid: "top-brokenline", label: "线", class: "iconfont icon-flow-broken" },
// { guid: "top-polyline", label: "线", class: "iconfont icon-flow-broken" },
// { guid: "top-cubic", label: "线", class: "iconfont icon-flow-curve" }
],
graph: null,
grid: null,
@ -510,7 +523,6 @@ export default {
//
editColumns() {
this.tableColumnEditOpen = true
},
// 线
tableCommentChang(e) {
@ -583,6 +595,9 @@ export default {
},
dragendHandler() {
},
tranDictData(list){
this.dictTypeList = list
},
initTopo(graphData) {
let self = this
if (self.graph) {
@ -840,7 +855,8 @@ export default {
},
//
reBack() {
this.$router.replace('/tool/er-top')
window.close()
// this.$router.replace('/tool/er-top')
},
undoHandler() {
if (this.historyIndex > 0 && this.historyIndex - (this.undoCount + 1) >= 0) {
@ -1161,6 +1177,7 @@ export default {
item.type = 1
item.ucMock = ''
item.ucName = item.columnComment
item.dictType = null
columns.push(item)
}
@ -1374,8 +1391,12 @@ export default {
this.$emit('doPreview', graphData)
},
// 线
searchOnLine() {
this.$emit('doOnLine')
searchOnLine(release) {
this.$emit('doOnLine',release)
},
// 线
undoOnLine(release) {
this.$emit('undoOnLine',release)
},
//
saveDataHandler() {

View File

@ -12,7 +12,8 @@
@doChangeMode="doChangeMode"
@doSaveData="doSaveData"
@doPreview="doPreview"
@doOnLine="doOnLine"
@doOnLine="changeOnLine"
@undoOnLine="changeOnLine"
>
</topology>
@ -23,13 +24,13 @@
:label="item.ucName"
>
<el-input v-if="item.type == 1" v-model="item.ucReal"
<el-input v-if="item.type === 1" v-model="item.ucReal"
clearable
:placeholder="outPlaceholder(item)"
size="small"
@keyup.enter.native="handleQuery"
/>
<div style="width: 200px" v-else-if="item.type == 2">
<div style="width: 200px" v-else-if="item.type === 2">
<el-row :gutter="15">
<el-col :span="12">
<el-input size="small" placeholder="开始值" v-model="item.ucReal.begin"></el-input>
@ -40,7 +41,7 @@
</el-row>
</div>
<el-date-picker
v-else-if="item.type ==3"
v-else-if="item.type ===3"
v-model="item.ucReal"
type="date"
format="yyyy-MM-dd"
@ -83,8 +84,17 @@
:label="item.label"
align="center"
:key="index"
:prop="item.prop"
/>
:prop="item.prop">
<template slot-scope="scope">
<span v-if="checkDateType(item.prop)">
{{ parseDateOrTime(scope.row[item.prop]) }}
</span>
<span v-else-if="item.dictType!=null">
{{ dictFormat(item.dictType, scope.row[item.prop]) }}
</span>
<span v-else>{{ scope.row[item.prop] }}</span>
</template>
</el-table-column>
</el-table>
<pagination
v-show="previewDate.total>0"
@ -101,10 +111,14 @@
<script>
/* 局部注册 */
import Topology from './packages/topology/src/topology'
import { deepClone } from './utils/index'
import { getQuery, getTables, updateQuery, preview } from '@/api/tool/top'
import { RealData } from '@/api/system/data'
import { exportReal } from '../../../api/system/data'
import {deepClone} from './utils/index'
import {getQuery, getTables, updateQuery, preview} from '@/api/tool/top'
import {realData} from '@/api/system/data'
import {exportReal} from '@/api/system/data'
import {optionSelect} from "@/api/system/dict/type";
import {eventBus} from "@/views/tool/top/utils/eventBus";
import {Release} from "@/api/tool/query";
import {Message} from "element-ui";
export default {
name: 'DemoTopology',
@ -148,13 +162,17 @@ export default {
tableComment: '主表字段',
relComment: '关联字段'
},
autoRefreshTimer: null
autoRefreshTimer: null,
dictTypeDataList: {}
}
},
mounted() {
this.topId = this.$route.params && this.$route.params.topId
getQuery(this.topId).then(res => {
this.baseData = res.data
eventBus.$emit('isRelease', this.baseData.isRelease)
console.log(res.data)
if (res.data.topJson) {
this.graphData = JSON.parse(res.data.topJson)
} else {
@ -163,6 +181,7 @@ export default {
edges: []
}
}
this.baseData.topJson = null
let graphData = deepClone(this.graphData)
this.$refs.topology.initTopo(graphData)
this.randomChange()
@ -171,8 +190,21 @@ export default {
this.nodeTypeList = res.data.tables
this.relationalMap = res.data.relationalMap
})
optionSelect().then(res => {
this.$refs.topology.tranDictData(res.data)
})
},
methods: {
/**
* 字典渲染
* @param dictType
* @param data
* @returns {*}
*/
dictFormat(dictType, data) {
return this.selectDictLabel(this.dictTypeDataList[dictType], data)
},
/**
* 重置
*/
@ -183,12 +215,12 @@ export default {
},
/** 导出按钮操作 */
handleExport() {
var that = this
let that = this
this.$confirm('是否确认导出查询数据项?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
}).then(function () {
let data = {
id: that.topId,
uniCons: that.previewDate.uconList
@ -206,7 +238,7 @@ export default {
}
data.uniCons = this.previewDate.uconList
//todo
RealData(data).then(res => {
realData(data).then(res => {
this.previewDate.data = res.rows
this.total = res.total
})
@ -245,13 +277,20 @@ export default {
this.msgSuccess(res.msg)
})
},
doOnLine() {
this.$confirm('请确认top图结构无误并预览结果无误后上线?', '警告', {
changeOnLine(release) {
let that = this
this.$confirm(release === 1 ? '请确认top图结构无误并预览结果无误后上线?' : '请确认是否撤销当前发布内容!', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
}).then(function () {
let data = {
id: that.baseData.id,
isRelease: release
}
Release(data).then(res => {
window.close()
})
})
},
//
@ -271,7 +310,7 @@ export default {
let edges = []
edgeList.forEach(edge => {
edges.push({
id:edge.id,
id: edge.id,
label: edge.label,
source: edge.source,
target: edge.target,
@ -286,11 +325,8 @@ export default {
}),
id: this.topId
}
console.log({
nodes: nodes,
edges: edges
})
preview(data).then(res => {
this.dictTypeDataList = res.dictList
this.previewDate.data = res.rows
this.previewDate.total = res.total
this.previewDate.uconList = res.uconList
@ -299,14 +335,14 @@ export default {
}
this.previewDate.header = []
let infoList = res.infoList
infoList.forEach( info=>{
infoList.forEach(info => {
this.previewDate.header.push({
key: info.prop,
label: info.label,
prop: info.prop
prop: info.prop,
dictType: info.dictType
})
})
this.previewDate.title = this.baseData.uqName + '数据预览'
this.previewDate.open = true
})
@ -316,7 +352,6 @@ export default {
},
randomChange() {
let graphData = deepClone(this.$refs.topology.getGraphData())
let { nodes } = graphData
this.$refs.topology.changeGraphData(graphData)
}
}

View File

@ -0,0 +1,3 @@
import Vue from "vue";
export const eventBus = new Vue();

View File

@ -10,6 +10,7 @@ private Long id;
解决方案,将controller层中新增和更新接口中的判空改至实体类层,在controller层只需要添加@Validated注解即可
```java
@PostMapping({"/login"})
public AjaxResult test(@Validated EleUser eleUser){

View File

@ -2,6 +2,8 @@ package com.ebts.web.controller.system;
import com.ebts.common.core.controller.BaseController;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.common.utils.DictUtils;
import com.ebts.common.utils.MapExcelUtil;
import com.ebts.system.entity.RealUniQuery;
import com.ebts.system.entity.RelColumnInfo;
@ -40,13 +42,18 @@ public class RealQueryController extends BaseController {
Result<List<Map<String, Object>>> result = realQueryService.RealData(realUniQuery, 1);
List<RelColumnInfo> infoList = realQueryService.getInfoList(realUniQuery.getId());
if (result.isSuccess()) {
List<Map<String,String>> infoMap = infoList.stream().map(info->{
Map<String,String> map = new HashMap<>();
map.put("label",info.getLabel());
map.put("prop",info.getProp());
Map<String, List<DictData>> dictList = new HashMap<>();
List<Map<String, String>> infoMap = infoList.stream().map(info -> {
Map<String, String> map = new HashMap<>();
map.put("label", info.getLabel());
map.put("prop", info.getProp());
map.put("dictType", info.getDictType());
if (info.getDictType() != null) {
dictList.put(info.getDictType(), DictUtils.getDictCache(info.getDictType()));
}
return map;
}).collect(Collectors.toList());
return new MapExcelUtil().exportExcel(result.getData(), result.getMsg(),infoMap);
return new MapExcelUtil().exportExcel(result.getData(), result.getMsg(), infoMap, dictList);
} else {
return Result.error(result.getMsg());
}

View File

@ -16,9 +16,9 @@ spring:
druid:
# 主库数据源
master:
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
url: jdbc:mysql://162.14.111.170:3306/ebtsup?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: ebtsup
password: CZzZHHn4feSJ2a8k
# 从库数据源
slave:
# 从数据源开关/默认关闭

View File

@ -17,37 +17,6 @@ ebts:
captchaType: math
md5:
#盐
salt: clay
#秘钥
secretKey: xinanjiaodaxinxi
wechat:
# 微信用户小程序appid
userAppid: wx4c2099a19c69664f
# 微信职能小程序appid
funAppid: wx17aa476b91c2a391
# 微信技术端小程序appid
eleAppid: wx17aa476b91c2a391
# 微信用户小程序secret
userSecret: 3c4d9f5deb39bb10319e0ea0582d2bc0
# 微信职能小程序secret
funSecret: 456464645
# 微信技术小程序secret
eleSecret: 456464645
# 微信小程序 grant_type
grant_type: authorization_code
sms:
accessKeyId: LTAI5tKJQmGHKaUuYXco2Jiu
accessKeySecret: VZbBW1Je4zqm028PViqKIYwtDOQcxB
signName: 尊古
# 开发环境配置
server:
# 服务器的HTTP端口默认为8085
@ -63,12 +32,6 @@ server:
# Tomcat启动初始化的线程数默认值25
min-spare-threads: 30
# 日志配置
logging:
level:
com.ebts: debug
org.springframework: warn
# Spring配置
spring:
profiles:
@ -189,3 +152,43 @@ xss:
excludes: /system/notice/*
# 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/*
# 日志配置
logging:
level:
com.ebts: debug
org.springframework: warn'
md5:
#盐
salt: clay
#秘钥
secretKey: xinanjiaodaxinxi
wechat:
# 微信用户小程序appid
userAppid: wx4c2099a19c69664f
# 微信职能小程序appid
funAppid: wx17aa476b91c2a391
# 微信技术端小程序appid
eleAppid: wx17aa476b91c2a391
# 微信用户小程序secret
userSecret: 3c4d9f5deb39bb10319e0ea0582d2bc0
# 微信职能小程序secret
funSecret: 456464645
# 微信技术小程序secret
eleSecret: 456464645
# 微信小程序 grant_type
grant_type: authorization_code
sms:
accessKeyId: LTAI5tKJQmGHKaUuYXco2Jiu
accessKeySecret: VZbBW1Je4zqm028PViqKIYwtDOQcxB
signName: 尊古

View File

@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.InitBinder;
import java.beans.PropertyEditorSupport;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* web层通用数据处理
@ -71,13 +72,14 @@ public class BaseController {
* 响应请求分页数据
*/
@SuppressWarnings({"rawtypes", "unchecked"})
protected TableDataTop getDataTable(List<?> list, List<?> uconList,List<?> infoList) {
protected TableDataTop getDataTable(List<?> list, List<?> uconList, List<?> infoList, Map<String,?> dictList) {
TableDataTop dataTop = new TableDataTop();
dataTop.setCode(HttpStatus.SUCCESS);
dataTop.setMsg("查询成功");
dataTop.setRows(list);
dataTop.setUconList(uconList);
dataTop.setInfoList(infoList);
dataTop.setDictList(dictList);
dataTop.setTotal(new PageInfo(list).getTotal());
return dataTop;
}

View File

@ -2,6 +2,7 @@ package com.ebts.common.core.page;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* 表格分页数据对象
@ -24,6 +25,8 @@ public class TableDataTop implements Serializable {
private List<?> uconList;
private List<?> infoList;
private Map<String,?> dictList;
/**
* 消息状态码
@ -100,4 +103,12 @@ public class TableDataTop implements Serializable {
public void setInfoList(List<?> infoList) {
this.infoList = infoList;
}
public Map<String, ?> getDictList() {
return dictList;
}
public void setDictList(Map<String, ?> dictList) {
this.dictList = dictList;
}
}

View File

@ -2,6 +2,7 @@ package com.ebts.common.utils;
import com.ebts.common.config.EBTSConfig;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.common.exception.CustomException;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
@ -56,6 +57,7 @@ public class MapExcelUtil {
* 注解列表
*/
private List<Map<String, String>> herders;
private Map<String,List<DictData>> dictList;
/**
@ -70,8 +72,9 @@ public class MapExcelUtil {
return exportExcel();
}
public <T>Result<T> exportExcel(List<Map<String, Object>> list, String sheetName,List<Map<String,String>> infoMap) {
public <T>Result<T> exportExcel(List<Map<String, Object>> list, String sheetName, List<Map<String,String>> infoMap, Map<String,List<DictData>> dictList) {
this.herders = infoMap;
this.dictList = dictList;
this.init(list, sheetName);
return exportExcel();
}
@ -180,27 +183,31 @@ public class MapExcelUtil {
int k = 0;
for (Map<String, String> herder : herders) {
// 填充单元格的值
this.addCell(row, herder.get("prop"), i, k++);
this.addCell(row, herder, i, k++);
}
// for (String key : herders) {
// // 填充单元格的值
// this.addCell(row, key, i, k++);
// }
}
}
/**
* 添加单元格
*/
public Cell addCell(Row row, String key, int column, Integer k) {
public Cell addCell(Row row, Map<String, String> herder, int column, Integer k) {
Cell cell = null;
try {
Object value = this.list.get(column).get(herder.get("prop"));
String dictType = herder.get("dictType");
if (dictType!=null&&!"".equals(dictType)){
for (DictData dictData : dictList.get(dictType)) {
if (dictData.getDictValue().equals(value.toString())){
value = dictData.getDictLabel();
}
}
}
// 设置行高
row.setHeight((short) 280);
// 创建cell
cell = row.createCell(k);
cell.setCellStyle(styles.get("data"));
Object value = this.list.get(column).get(key);
cell.setCellValue(value.toString());
} catch (Exception e) {
logger.error("导出Excel失败{}", e);

View File

@ -2,23 +2,26 @@ package com.ebts.generator.controller;
import com.ebts.common.core.controller.BaseController;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.common.utils.DictUtils;
import com.ebts.common.utils.MapExcelUtil;
import com.ebts.common.utils.StringUtils;
import com.ebts.generator.entity.UniColumnInfo;
import com.ebts.generator.entity.bo.UniQueryBo;
import com.ebts.generator.utils.sql.GenSqlUtil;
import com.github.pagehelper.PageHelper;
import com.ebts.generator.entity.UniCon;
import com.ebts.generator.entity.UniQuery;
import com.ebts.generator.service.QueryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -68,7 +71,7 @@ public class QueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('query:edit')")
@PutMapping
public Result<Integer> edit(@Validated @RequestBody UniQuery uniQuery) {
if (uniQuery.getInfoList().size() == 0){
if (uniQuery.getInfoList().size() == 0) {
return Result.error("字段信息为空,请提取字段信息!");
}
return queryService.updateQueryInfo(uniQuery);
@ -85,7 +88,28 @@ public class QueryController extends BaseController {
public Result<Map<String, Object>> export(@Validated @RequestBody UniQuery uniQuery) {
Result<List<Map<String, Object>>> result = queryService.previewQuery(uniQuery);
if (result.isSuccess()) {
return new MapExcelUtil().exportExcel(result.getData(), uniQuery.getUqName());
List<UniColumnInfo> infoList;
Map<String, List<DictData>> dictList = new HashMap<>();
if (uniQuery.getInfoList().size() != 0) {
infoList = uniQuery.getInfoList();
} else {
infoList = new ArrayList<>();
Set<String> keySet = result.getData().get(0).keySet();
keySet.forEach(s -> {
infoList.add(new UniColumnInfo(uniQuery.getId(), s, s, null));
});
}
List<Map<String, String>> infoMap = infoList.stream().map(info -> {
Map<String, String> map = new HashMap<>();
map.put("label", info.getLabel());
map.put("prop", info.getProp());
map.put("dictType", info.getDictType());
if (info.getDictType() != null) {
dictList.put(info.getDictType(), DictUtils.getDictCache(info.getDictType()));
}
return map;
}).collect(Collectors.toList());
return new MapExcelUtil().exportExcel(result.getData(), uniQuery.getUqName(), infoMap, dictList);
} else {
return Result.error(result.getMsg());
}
@ -99,9 +123,11 @@ public class QueryController extends BaseController {
*/
@PreAuthorize("@ebts.hasPermi('query:preview')")
@PutMapping("preview")
public Serializable Preview(@Validated @RequestBody UniQuery uniQuery) {
public Serializable Preview(@Validated @RequestBody UniQueryBo uniQuery) {
UniQuery query = new UniQuery();
BeanUtils.copyProperties(uniQuery, query);
startPage(uniQuery);
Result<List<Map<String, Object>>> result = queryService.previewQuery(uniQuery);
Result<List<Map<String, Object>>> result = queryService.previewQuery(query);
if (result.isSuccess()) {
return getDataTable(result.getData());
} else {
@ -131,7 +157,7 @@ public class QueryController extends BaseController {
/**
* 设置请求分页数据
*/
protected void startPage(UniQuery uniQuery) {
protected void startPage(UniQueryBo uniQuery) {
Integer pageNum = uniQuery.getPageNum();
Integer pageSize = uniQuery.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {

View File

@ -47,7 +47,7 @@ public class TopQueryController extends BaseController {
@GetMapping("/online/{id}")
public Result<String> online(@PathVariable("id") Long id) {
// ServerResult ServerResult = queryService.updateQueryInfo(uniQuery);
// ServerResult ServerResult = queryService.updateQueryInfo(uniQuery);
// if (ServerResult.isStart()) {
// return AjaxResult.success(ServerResult.getData());
// } else {
@ -92,7 +92,7 @@ public class TopQueryController extends BaseController {
Result<TopResult> result = topQueryService.preview(params.get("jsonData"), params.get("id"));
if (result.isSuccess()){
TopResult data = result.getData();
return getDataTable(data.getDataMap(),data.getUniCons(),data.getInfoList());
return getDataTable(data.getDataMap(),data.getUniCons(),data.getInfoList(),data.getDictList());
}else {
return Result.error(result.getMsg());
}

View File

@ -135,7 +135,7 @@ public class TopSearchTableController extends EBTSController {
* 导入表结构保存
*/
@PreAuthorize("@ebts.hasPermi('tool:table:import')")
@Log(title = "代码生成", businessType = BusinessType.IMPORT)
@Log(title = "top表数据维护", businessType = BusinessType.IMPORT)
@PostMapping("/importTopTable")
public Result<String> importTableSave(String tables) {
String[] tableNames = Convert.toStrArray(tables);

View File

@ -67,8 +67,7 @@ public class UniQueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:query:query')")
@GetMapping(value = "/{id}")
public Result<UniQuery> getInfo(@PathVariable("id") Long id) {
Result<UniQuery> result = uniQueryService.selectUniQueryById(id);
return result;
return uniQueryService.selectUniQueryById(id);
}
/**
@ -77,7 +76,7 @@ public class UniQueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('tool:query:add')")
@Log(title = "万能查询", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody @Validated UniQuery uniQuery) {
public Result<Integer> add(@RequestBody @Validated UniQuery uniQuery) {
return uniQueryService.insertUniQuery(uniQuery);
}

View File

@ -2,6 +2,7 @@ package com.ebts.generator.dao;
import com.ebts.generator.entity.UniQuery;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -20,6 +21,13 @@ public interface UniQueryDao {
*/
UniQuery selectUniQueryById(Long id);
/**
* 查询有误已经发布上线的数据
* @param ids
* @return count
*/
int selectUniQueryReleaseByIds(@Param("ids") Long[] ids);
/**
* 查询万能查询列表
*

View File

@ -1,5 +1,6 @@
package com.ebts.generator.dto;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.generator.entity.UniColumnInfo;
import com.ebts.generator.entity.UniCon;
@ -17,11 +18,14 @@ public class TopResult {
private List<UniCon> uniCons;
private List<UniColumnInfo> infoList;
private Map<String,List<DictData>> dictList;
public TopResult(List<Map<String, Object>> dataMap, List<UniCon> uniCons,List<UniColumnInfo> infoList) {
public TopResult(List<Map<String, Object>> dataMap, List<UniCon> uniCons,List<UniColumnInfo> infoList,Map<String,List<DictData>> dictList) {
this.dataMap = dataMap;
this.uniCons = uniCons;
this.infoList = infoList;
this.dictList = dictList;
}
public List<Map<String, Object>> getDataMap() {
@ -47,4 +51,12 @@ public class TopResult {
public void setInfoList(List<UniColumnInfo> infoList) {
this.infoList = infoList;
}
public Map<String, List<DictData>> getDictList() {
return dictList;
}
public void setDictList(Map<String, List<DictData>> dictList) {
this.dictList = dictList;
}
}

View File

@ -10,11 +10,23 @@ public class UniColumnInfo {
private long queryId;
private String prop;
private String label;
private String dictType;
public UniColumnInfo() {
}
public UniColumnInfo(long queryId,String prop, String label) {
public UniColumnInfo(long queryId, String prop, String label, String dictType) {
this.dictType = dictType;
this.queryId = queryId;
if (StringUtils.isNull(label)){
this.label = prop;
}else {
this.label = label;
}
this.prop = prop;
}
public UniColumnInfo(long queryId, String prop, String label) {
this.queryId = queryId;
if (StringUtils.isNull(label)){
this.label = prop;
@ -47,4 +59,12 @@ public class UniColumnInfo {
public void setLabel(String label) {
this.label = label;
}
public String getDictType() {
return dictType;
}
public void setDictType(String dictType) {
this.dictType = dictType;
}
}

View File

@ -15,7 +15,6 @@ import java.util.List;
* @date 2021-01-30
*/
public class UniQuery extends BaseEntity {
/**
* id
*/
@ -52,9 +51,6 @@ public class UniQuery extends BaseEntity {
private List<UniCon> uniCons;
private Integer pageNum;
private Integer pageSize;
private List<UniColumnInfo> infoList;
@ -102,22 +98,6 @@ public class UniQuery extends BaseEntity {
this.isRelease = isRelease;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public List<UniCon> getUniCons() {
if (uniCons == null) {
return uniCons = new ArrayList<UniCon>();

View File

@ -0,0 +1,50 @@
package com.ebts.generator.entity.bo;
import com.ebts.generator.entity.UniCon;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
public class UniQueryBo {
@NotBlank(message = "sql不能为空!")
private String uqSql;
private List<UniCon> uniCons;
@NotNull(message = "pageNum不能为空!")
private Integer pageNum;
@NotNull(message = "pageSize不能为空!")
private Integer pageSize;
public String getUqSql() {
return uqSql;
}
public void setUqSql(String uqSql) {
this.uqSql = uqSql;
}
public List<UniCon> getUniCons() {
return uniCons;
}
public void setUniCons(List<UniCon> uniCons) {
this.uniCons = uniCons;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}

View File

@ -66,25 +66,12 @@ public class QueryServiceImpl implements QueryService {
if (uniQuery.getIsRelease() == 1) {
UniQuery query = uniQueryDao.selectUniQueryById(uniQuery.getId());
Menu Menu = new Menu(query.getId(), query.getUqName(), SecurityUtils.getUserId());
Integer insermenu = queryDao.insertMenu(Menu);
if (insermenu == 0) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.error(ReturnConstants.OP_ERROR);
}
queryDao.insertMenu(Menu);
} else {
Integer deleteMenu = queryDao.deleteMenu("data/" + uniQuery.getId());
if (deleteMenu == 0) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.error(ReturnConstants.OP_ERROR);
}
}
Integer release = queryDao.changeRelease(uniQuery);
if (release > 0) {
return Result.ok();
} else {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.error(ReturnConstants.OP_ERROR);
queryDao.deleteMenu("data/" + uniQuery.getId());
}
queryDao.changeRelease(uniQuery);
return Result.ok();
} else {
return Result.error(ReturnConstants.STATE_ERROR);
}
@ -97,11 +84,11 @@ public class QueryServiceImpl implements QueryService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Result<Integer> updateQueryInfo(UniQuery uniQuery) {
uniQueryDao.updateUniQuery(uniQuery);
queryDao.deleteUniCon(uniQuery.getId());
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
queryDao.deleteUniCon(uniQuery.getId());
queryDao.insertUniCon(uniQuery.getUniCons());
resetColumnInfo(uniQuery);
}
resetColumnInfo(uniQuery);
return Result.ok();
}
@ -114,6 +101,7 @@ public class QueryServiceImpl implements QueryService {
}
@Override
@Transactional(propagation = Propagation.SUPPORTS)
public Result<List<Map<String, Object>>> previewQuery(UniQuery uniQuery) {
StringBuilder sql = new StringBuilder(uniQuery.getUqSql().toLowerCase());
List<UniCon> uniConList = uniQuery.getUniCons();

View File

@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.common.utils.DictUtils;
import com.ebts.common.utils.SecurityUtils;
import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.*;
@ -41,6 +43,8 @@ public class TopQueryServiceImpl implements TopQueryService {
private UniQueryDao uniQueryDao;
@Resource
private UniColumnInfoDao uniColumnInfoDao;
// @Resource
// private Dict
@Override
public Map<String, Object> selectTopSearchTables() {
@ -127,7 +131,7 @@ public class TopQueryServiceImpl implements TopQueryService {
}
if (columns.getJSONObject(i).getInteger("isUse")==1){
// infoList.add(new UniColumnInfo(uniQuery.getId(),node.getRelTable()+"."+column.getString("columnName"),column.getString("columnComment")));
infoList.add(new UniColumnInfo(uniQuery.getId(),column.getString("columnName"),column.getString("columnComment")));
infoList.add(new UniColumnInfo(uniQuery.getId(),column.getString("columnName"),column.getString("columnComment"),column.getString("dictType")));
}
}
}
@ -147,7 +151,15 @@ public class TopQueryServiceImpl implements TopQueryService {
sql.append(selectQuery);
PageHelper.startPage(1, 10, "");
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString());
TopResult topResult = new TopResult(dataMap, uniCons,infoList);
Map<String,List<DictData>> dictList = new HashMap<>();
infoList.forEach(info ->{
if (info.getDictType()!=null){
//todo 后期优化不适用循环
dictList.put(info.getDictType(),DictUtils.getDictCache(info.getDictType()));
}
});
TopResult topResult = new TopResult(dataMap, uniCons,infoList,dictList);
return Result.ok(topResult);
}
@ -173,9 +185,9 @@ public class TopQueryServiceImpl implements TopQueryService {
TopNode getNode(List<TopNode> nodes, String id) {
for (int i = 0; i < nodes.size(); i++) {
if (nodes.get(i).getId().equals(id)) {
return nodes.get(i);
for (TopNode node : nodes) {
if (node.getId().equals(id)) {
return node;
}
}
return null;

View File

@ -23,6 +23,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* top万能查询主Service业务层处理
@ -138,13 +139,6 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
topSearchTableDao.updateTopSearchTable(topSearchTable);
return Result.ok();
}
// void deleteSearchTableRoleById(Long id){
// try {
//
// }catch (RuntimeException e){
// log.error("无数据");
// }
// }
@Override
@ -168,9 +162,10 @@ public class TopSearchTableServiceImpl implements TopSearchTableService {
int row = topSearchTableDao.insertTopSearchTable(table);
if (row > 0) {
List<TopSearchColumn> searchColumns = topSearchTableDao.selectDbTableColumnsByName(tableName);
for (TopSearchColumn searchColumn : searchColumns) {
searchColumn.setSearchTableId(table.getId());
}
searchColumns = searchColumns.stream().peek(column->{
column.setSearchTableId(table.getId());
column.setIsUse(1);
}).collect(Collectors.toList());
if (searchColumns.size() > 0) {
topSearchTableDao.batchTopSearchColumn(searchColumns);
}

View File

@ -91,6 +91,10 @@ public class UniQueryServiceImpl implements UniQueryService {
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Integer> deleteUniQueryByIds(Long[] ids) {
int count = uniQueryDao.selectUniQueryReleaseByIds(ids);
if (count>0){
return Result.error("选择数据中含有已经发布的内容!");
}
uniQueryDao.deleteUniQueryByIds(ids);
uniQueryDao.deleteUniQueryByUqIds(ids);
return Result.ok();

View File

@ -84,11 +84,11 @@
<select id="selectQueryInfo" parameterType="Long" resultMap="QueryResult">
select uq.id, uq.uq_name, uq.uq_sql, uq.uq_describe, uq.create_by, uq.is_release, uq.create_time, uq.update_by, uq.update_time,
uc.id as uc_id, uc.uq_id, uc.uc_name, uc.uc_key, uc.uc_con, uc.uc_mock, uc.uc_describe ,uc.uc_type,uc.type,uci.prop,uci.label
uc.uq_id, uc.uc_name, uc.uc_key, uc.uc_con, uc.uc_mock, uc.uc_describe ,uc.uc_type,uc.type,uci.prop,uci.label
from gen_uni_query uq
left join gen_uni_con uc on uc.uq_id = uq.id
left join gen_uni_column_info uci on uci.query_id = uq.id
where uq.id = #{id}
where uq.id = #{id} and uq.is_release = 2
</select>
<delete id="deleteUniCon">

View File

@ -5,9 +5,9 @@
<mapper namespace="com.ebts.generator.dao.UniColumnInfoDao">
<insert id="insertUniColumnInfo" parameterType="java.util.List">
insert into gen_uni_column_info (query_id,prop,label) values
insert into gen_uni_column_info (query_id,prop,label,dict_type) values
<foreach collection="list" item="item" index="index" separator=",">
(#{item.queryId},#{item.prop},#{item.label})
(#{item.queryId},#{item.prop},#{item.label},#{item.dictType})
</foreach>
</insert>
<delete id="deleteUniColumnInfo">

View File

@ -24,7 +24,7 @@
</sql>
<select id="selectUniQueryList" parameterType="UniQuery" resultMap="UniQueryResult">
<include refid="selectUniQueryVo"/>
select id, uq_name, uq_describe, type, is_release, create_by, create_time, update_by, update_time from gen_uni_query
<where>
<if test="uqName != null and uqName != ''"> and uq_name like concat('%', #{uqName}, '%')</if>
<if test="uqDescribe != null and uqDescribe != ''"> and uq_describe like concat('%', #{uqDescribe}, '%')</if>
@ -34,7 +34,14 @@
</select>
<select id="selectUniQueryById" parameterType="Long" resultMap="UniQueryResult">
select * from gen_uni_query where id = #{id}
select id, uq_name, uq_describe, top_json, type, is_release, create_by, create_time, update_by, update_time from gen_uni_query
where id = #{id} and is_release = 2
</select>
<select id="selectUniQueryReleaseByIds" resultType="java.lang.Integer">
select count(1) from gen_uni_query where is_release = 1 and id in
<foreach collection="ids" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</select>
<insert id="insertUniQuery" parameterType="UniQuery" useGeneratedKeys="true" keyProperty="id">
@ -71,7 +78,7 @@
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
where id = #{id} and is_release = 2
</update>
<delete id="deleteUniQueryById" parameterType="Long">

View File

@ -6,6 +6,8 @@ public class RelColumnInfo {
private String prop;
private String label;
private String dictType;
public long getQueryId() {
return queryId;
}
@ -29,4 +31,12 @@ public class RelColumnInfo {
public void setLabel(String label) {
this.label = label;
}
public String getDictType() {
return dictType;
}
public void setDictType(String dictType) {
this.dictType = dictType;
}
}

View File

@ -4,17 +4,20 @@ import com.ebts.system.entity.RealUniQuery;
import com.ebts.system.entity.RelColumnInfo;
import java.util.List;
import java.util.Map;
public class RealInfo {
private List<RealUniQuery> uniCons;
private List<RelColumnInfo> infoList;
private Map<String,?> dictList;
public RealInfo() {
}
public RealInfo(List<RealUniQuery> uniCons, List<RelColumnInfo> infoList) {
public RealInfo(List<RealUniQuery> uniCons, List<RelColumnInfo> infoList,Map<String,?> dictList) {
this.uniCons = uniCons;
this.infoList = infoList;
this.dictList = dictList;
}
public List<RealUniQuery> getUniCons() {
@ -29,7 +32,16 @@ public class RealInfo {
return infoList;
}
public Map<String, ?> getDictList() {
return dictList;
}
public void setDictList(Map<String, ?> dictList) {
this.dictList = dictList;
}
public void setInfoList(List<RelColumnInfo> infoList) {
this.infoList = infoList;
}
}

View File

@ -3,6 +3,8 @@ package com.ebts.system.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.common.utils.DictUtils;
import com.ebts.system.dao.RealQueryServiceDao;
import com.ebts.system.entity.RealUniCon;
import com.ebts.system.entity.RealUniQuery;
@ -18,6 +20,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -42,7 +45,13 @@ public class RealQueryServiceImpl implements RealQueryService {
public Result<RealInfo> RealInfo(Long id) {
List<RealUniQuery> uniCons = realQueryServiceDao.queryRealInfo(id);
List<RelColumnInfo> infoList = realQueryServiceDao.queryRealColumnInfo(id);
return Result.ok(new RealInfo(uniCons,infoList));
Map<String,List<DictData>> dictList = new HashMap<>();
infoList.forEach(info->{
if (info.getDictType()!=null){
dictList.put(info.getDictType(), DictUtils.getDictCache(info.getDictType()));
}
});
return Result.ok(new RealInfo(uniCons,infoList,dictList));
}
@Override

View File

@ -43,6 +43,6 @@
${paramSQL}
</select>
<select id="queryRealColumnInfo" resultType="com.ebts.system.entity.RelColumnInfo">
select label,prop from gen_uni_column_info where query_id = #{id}
select label,prop,dict_type from gen_uni_column_info where query_id = #{id}
</select>
</mapper>