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/开发环境 # EBTS/开发环境
#VUE_APP_BASE_API = '/dev-api' #VUE_APP_BASE_API = '/dev-api'
VUE_APP_BASE_API = 'http://localhost:8085/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"; import request from "@/utils/request";
// 获取查询基本信息 // 获取查询基本信息
export function RealInfo(id){ export function realInfo(id){
return request({ return request({
url: "/data/real/"+id, url: "/data/real/"+id,
method: 'get', method: 'get',
}) })
} }
// 查询数据 // 查询数据
export function RealData(data){ export function realData(data){
return request({ return request({
url: "/data/real", url: "/data/real",
method: 'put', method: 'put',

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -309,7 +309,7 @@ export default {
/** 高亮显示 */ /** 高亮显示 */
highlightedCode(code, key) { highlightedCode(code, key) {
const vmName = 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); const result = hljs.highlight(language, code || "", true);
return result.value || '&nbsp;'; return result.value || '&nbsp;';
}, },

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,7 +12,8 @@
@doChangeMode="doChangeMode" @doChangeMode="doChangeMode"
@doSaveData="doSaveData" @doSaveData="doSaveData"
@doPreview="doPreview" @doPreview="doPreview"
@doOnLine="doOnLine" @doOnLine="changeOnLine"
@undoOnLine="changeOnLine"
> >
</topology> </topology>
@ -23,13 +24,13 @@
:label="item.ucName" :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 clearable
:placeholder="outPlaceholder(item)" :placeholder="outPlaceholder(item)"
size="small" size="small"
@keyup.enter.native="handleQuery" @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-row :gutter="15">
<el-col :span="12"> <el-col :span="12">
<el-input size="small" placeholder="开始值" v-model="item.ucReal.begin"></el-input> <el-input size="small" placeholder="开始值" v-model="item.ucReal.begin"></el-input>
@ -40,7 +41,7 @@
</el-row> </el-row>
</div> </div>
<el-date-picker <el-date-picker
v-else-if="item.type ==3" v-else-if="item.type ===3"
v-model="item.ucReal" v-model="item.ucReal"
type="date" type="date"
format="yyyy-MM-dd" format="yyyy-MM-dd"
@ -83,8 +84,17 @@
:label="item.label" :label="item.label"
align="center" align="center"
:key="index" :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> </el-table>
<pagination <pagination
v-show="previewDate.total>0" v-show="previewDate.total>0"
@ -101,10 +111,14 @@
<script> <script>
/* 局部注册 */ /* 局部注册 */
import Topology from './packages/topology/src/topology' import Topology from './packages/topology/src/topology'
import { deepClone } from './utils/index' import {deepClone} from './utils/index'
import { getQuery, getTables, updateQuery, preview } from '@/api/tool/top' import {getQuery, getTables, updateQuery, preview} from '@/api/tool/top'
import { RealData } from '@/api/system/data' import {realData} from '@/api/system/data'
import { exportReal } 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 { export default {
name: 'DemoTopology', name: 'DemoTopology',
@ -148,13 +162,17 @@ export default {
tableComment: '主表字段', tableComment: '主表字段',
relComment: '关联字段' relComment: '关联字段'
}, },
autoRefreshTimer: null autoRefreshTimer: null,
dictTypeDataList: {}
} }
}, },
mounted() { mounted() {
this.topId = this.$route.params && this.$route.params.topId this.topId = this.$route.params && this.$route.params.topId
getQuery(this.topId).then(res => { getQuery(this.topId).then(res => {
this.baseData = res.data this.baseData = res.data
eventBus.$emit('isRelease', this.baseData.isRelease)
console.log(res.data)
if (res.data.topJson) { if (res.data.topJson) {
this.graphData = JSON.parse(res.data.topJson) this.graphData = JSON.parse(res.data.topJson)
} else { } else {
@ -163,6 +181,7 @@ export default {
edges: [] edges: []
} }
} }
this.baseData.topJson = null
let graphData = deepClone(this.graphData) let graphData = deepClone(this.graphData)
this.$refs.topology.initTopo(graphData) this.$refs.topology.initTopo(graphData)
this.randomChange() this.randomChange()
@ -171,8 +190,21 @@ export default {
this.nodeTypeList = res.data.tables this.nodeTypeList = res.data.tables
this.relationalMap = res.data.relationalMap this.relationalMap = res.data.relationalMap
}) })
optionSelect().then(res => {
this.$refs.topology.tranDictData(res.data)
})
}, },
methods: { methods: {
/**
* 字典渲染
* @param dictType
* @param data
* @returns {*}
*/
dictFormat(dictType, data) {
return this.selectDictLabel(this.dictTypeDataList[dictType], data)
},
/** /**
* 重置 * 重置
*/ */
@ -183,12 +215,12 @@ export default {
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */
handleExport() { handleExport() {
var that = this let that = this
this.$confirm('是否确认导出查询数据项?', '警告', { this.$confirm('是否确认导出查询数据项?', '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(function() { }).then(function () {
let data = { let data = {
id: that.topId, id: that.topId,
uniCons: that.previewDate.uconList uniCons: that.previewDate.uconList
@ -206,7 +238,7 @@ export default {
} }
data.uniCons = this.previewDate.uconList data.uniCons = this.previewDate.uconList
//todo //todo
RealData(data).then(res => { realData(data).then(res => {
this.previewDate.data = res.rows this.previewDate.data = res.rows
this.total = res.total this.total = res.total
}) })
@ -245,13 +277,20 @@ export default {
this.msgSuccess(res.msg) this.msgSuccess(res.msg)
}) })
}, },
doOnLine() { changeOnLine(release) {
this.$confirm('请确认top图结构无误并预览结果无误后上线?', '警告', { let that = this
this.$confirm(release === 1 ? '请确认top图结构无误并预览结果无误后上线?' : '请确认是否撤销当前发布内容!', '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' 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 = [] let edges = []
edgeList.forEach(edge => { edgeList.forEach(edge => {
edges.push({ edges.push({
id:edge.id, id: edge.id,
label: edge.label, label: edge.label,
source: edge.source, source: edge.source,
target: edge.target, target: edge.target,
@ -286,11 +325,8 @@ export default {
}), }),
id: this.topId id: this.topId
} }
console.log({
nodes: nodes,
edges: edges
})
preview(data).then(res => { preview(data).then(res => {
this.dictTypeDataList = res.dictList
this.previewDate.data = res.rows this.previewDate.data = res.rows
this.previewDate.total = res.total this.previewDate.total = res.total
this.previewDate.uconList = res.uconList this.previewDate.uconList = res.uconList
@ -299,14 +335,14 @@ export default {
} }
this.previewDate.header = [] this.previewDate.header = []
let infoList = res.infoList let infoList = res.infoList
infoList.forEach( info=>{ infoList.forEach(info => {
this.previewDate.header.push({ this.previewDate.header.push({
key: info.prop, key: info.prop,
label: info.label, label: info.label,
prop: info.prop prop: info.prop,
dictType: info.dictType
}) })
}) })
this.previewDate.title = this.baseData.uqName + '数据预览' this.previewDate.title = this.baseData.uqName + '数据预览'
this.previewDate.open = true this.previewDate.open = true
}) })
@ -316,7 +352,6 @@ export default {
}, },
randomChange() { randomChange() {
let graphData = deepClone(this.$refs.topology.getGraphData()) let graphData = deepClone(this.$refs.topology.getGraphData())
let { nodes } = graphData
this.$refs.topology.changeGraphData(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注解即可 解决方案,将controller层中新增和更新接口中的判空改至实体类层,在controller层只需要添加@Validated注解即可
```java ```java
@PostMapping({"/login"}) @PostMapping({"/login"})
public AjaxResult test(@Validated EleUser eleUser){ 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.controller.BaseController;
import com.ebts.common.core.entity.Result; 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.MapExcelUtil;
import com.ebts.system.entity.RealUniQuery; import com.ebts.system.entity.RealUniQuery;
import com.ebts.system.entity.RelColumnInfo; 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); Result<List<Map<String, Object>>> result = realQueryService.RealData(realUniQuery, 1);
List<RelColumnInfo> infoList = realQueryService.getInfoList(realUniQuery.getId()); List<RelColumnInfo> infoList = realQueryService.getInfoList(realUniQuery.getId());
if (result.isSuccess()) { if (result.isSuccess()) {
List<Map<String,String>> infoMap = infoList.stream().map(info->{ Map<String, List<DictData>> dictList = new HashMap<>();
Map<String,String> map = new HashMap<>(); List<Map<String, String>> infoMap = infoList.stream().map(info -> {
map.put("label",info.getLabel()); Map<String, String> map = new HashMap<>();
map.put("prop",info.getProp()); 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; return map;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return new MapExcelUtil().exportExcel(result.getData(), result.getMsg(),infoMap); return new MapExcelUtil().exportExcel(result.getData(), result.getMsg(), infoMap, dictList);
} else { } else {
return Result.error(result.getMsg()); return Result.error(result.getMsg());
} }

View File

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

View File

@ -17,37 +17,6 @@ ebts:
captchaType: math 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: server:
# 服务器的HTTP端口默认为8085 # 服务器的HTTP端口默认为8085
@ -63,12 +32,6 @@ server:
# Tomcat启动初始化的线程数默认值25 # Tomcat启动初始化的线程数默认值25
min-spare-threads: 30 min-spare-threads: 30
# 日志配置
logging:
level:
com.ebts: debug
org.springframework: warn
# Spring配置 # Spring配置
spring: spring:
profiles: profiles:
@ -189,3 +152,43 @@ xss:
excludes: /system/notice/* excludes: /system/notice/*
# 匹配链接 # 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/* 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.beans.PropertyEditorSupport;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* web层通用数据处理 * web层通用数据处理
@ -71,13 +72,14 @@ public class BaseController {
* 响应请求分页数据 * 响应请求分页数据
*/ */
@SuppressWarnings({"rawtypes", "unchecked"}) @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(); TableDataTop dataTop = new TableDataTop();
dataTop.setCode(HttpStatus.SUCCESS); dataTop.setCode(HttpStatus.SUCCESS);
dataTop.setMsg("查询成功"); dataTop.setMsg("查询成功");
dataTop.setRows(list); dataTop.setRows(list);
dataTop.setUconList(uconList); dataTop.setUconList(uconList);
dataTop.setInfoList(infoList); dataTop.setInfoList(infoList);
dataTop.setDictList(dictList);
dataTop.setTotal(new PageInfo(list).getTotal()); dataTop.setTotal(new PageInfo(list).getTotal());
return dataTop; return dataTop;
} }

View File

@ -2,6 +2,7 @@ package com.ebts.common.core.page;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 表格分页数据对象 * 表格分页数据对象
@ -24,6 +25,8 @@ public class TableDataTop implements Serializable {
private List<?> uconList; private List<?> uconList;
private List<?> infoList; private List<?> infoList;
private Map<String,?> dictList;
/** /**
* 消息状态码 * 消息状态码
@ -100,4 +103,12 @@ public class TableDataTop implements Serializable {
public void setInfoList(List<?> infoList) { public void setInfoList(List<?> infoList) {
this.infoList = 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.config.EBTSConfig;
import com.ebts.common.core.entity.Result; import com.ebts.common.core.entity.Result;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.common.exception.CustomException; import com.ebts.common.exception.CustomException;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
@ -56,6 +57,7 @@ public class MapExcelUtil {
* 注解列表 * 注解列表
*/ */
private List<Map<String, String>> herders; private List<Map<String, String>> herders;
private Map<String,List<DictData>> dictList;
/** /**
@ -70,8 +72,9 @@ public class MapExcelUtil {
return exportExcel(); 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.herders = infoMap;
this.dictList = dictList;
this.init(list, sheetName); this.init(list, sheetName);
return exportExcel(); return exportExcel();
} }
@ -180,27 +183,31 @@ public class MapExcelUtil {
int k = 0; int k = 0;
for (Map<String, String> herder : herders) { 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; Cell cell = null;
try { 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); row.setHeight((short) 280);
// 创建cell // 创建cell
cell = row.createCell(k); cell = row.createCell(k);
cell.setCellStyle(styles.get("data")); cell.setCellStyle(styles.get("data"));
Object value = this.list.get(column).get(key);
cell.setCellValue(value.toString()); cell.setCellValue(value.toString());
} catch (Exception e) { } catch (Exception e) {
logger.error("导出Excel失败{}", 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.controller.BaseController;
import com.ebts.common.core.entity.Result; 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.MapExcelUtil;
import com.ebts.common.utils.StringUtils; import com.ebts.common.utils.StringUtils;
import com.ebts.generator.entity.UniColumnInfo; import com.ebts.generator.entity.UniColumnInfo;
import com.ebts.generator.entity.bo.UniQueryBo;
import com.ebts.generator.utils.sql.GenSqlUtil; import com.ebts.generator.utils.sql.GenSqlUtil;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.ebts.generator.entity.UniCon; import com.ebts.generator.entity.UniCon;
import com.ebts.generator.entity.UniQuery; import com.ebts.generator.entity.UniQuery;
import com.ebts.generator.service.QueryService; import com.ebts.generator.service.QueryService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.*;
import java.util.List; import java.util.stream.Collectors;
import java.util.Map;
/** /**
@ -68,7 +71,7 @@ public class QueryController extends BaseController {
@PreAuthorize("@ebts.hasPermi('query:edit')") @PreAuthorize("@ebts.hasPermi('query:edit')")
@PutMapping @PutMapping
public Result<Integer> edit(@Validated @RequestBody UniQuery uniQuery) { public Result<Integer> edit(@Validated @RequestBody UniQuery uniQuery) {
if (uniQuery.getInfoList().size() == 0){ if (uniQuery.getInfoList().size() == 0) {
return Result.error("字段信息为空,请提取字段信息!"); return Result.error("字段信息为空,请提取字段信息!");
} }
return queryService.updateQueryInfo(uniQuery); return queryService.updateQueryInfo(uniQuery);
@ -85,7 +88,28 @@ public class QueryController extends BaseController {
public Result<Map<String, Object>> export(@Validated @RequestBody UniQuery uniQuery) { public Result<Map<String, Object>> export(@Validated @RequestBody UniQuery uniQuery) {
Result<List<Map<String, Object>>> result = queryService.previewQuery(uniQuery); Result<List<Map<String, Object>>> result = queryService.previewQuery(uniQuery);
if (result.isSuccess()) { 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 { } else {
return Result.error(result.getMsg()); return Result.error(result.getMsg());
} }
@ -99,9 +123,11 @@ public class QueryController extends BaseController {
*/ */
@PreAuthorize("@ebts.hasPermi('query:preview')") @PreAuthorize("@ebts.hasPermi('query:preview')")
@PutMapping("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); startPage(uniQuery);
Result<List<Map<String, Object>>> result = queryService.previewQuery(uniQuery); Result<List<Map<String, Object>>> result = queryService.previewQuery(query);
if (result.isSuccess()) { if (result.isSuccess()) {
return getDataTable(result.getData()); return getDataTable(result.getData());
} else { } 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 pageNum = uniQuery.getPageNum();
Integer pageSize = uniQuery.getPageSize(); Integer pageSize = uniQuery.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) { if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)) {

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@ package com.ebts.generator.dao;
import com.ebts.generator.entity.UniQuery; import com.ebts.generator.entity.UniQuery;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -20,6 +21,13 @@ public interface UniQueryDao {
*/ */
UniQuery selectUniQueryById(Long id); 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; package com.ebts.generator.dto;
import com.ebts.common.core.entity.entity.DictData;
import com.ebts.generator.entity.UniColumnInfo; import com.ebts.generator.entity.UniColumnInfo;
import com.ebts.generator.entity.UniCon; import com.ebts.generator.entity.UniCon;
@ -17,11 +18,14 @@ public class TopResult {
private List<UniCon> uniCons; private List<UniCon> uniCons;
private List<UniColumnInfo> infoList; 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.dataMap = dataMap;
this.uniCons = uniCons; this.uniCons = uniCons;
this.infoList = infoList; this.infoList = infoList;
this.dictList = dictList;
} }
public List<Map<String, Object>> getDataMap() { public List<Map<String, Object>> getDataMap() {
@ -47,4 +51,12 @@ public class TopResult {
public void setInfoList(List<UniColumnInfo> infoList) { public void setInfoList(List<UniColumnInfo> infoList) {
this.infoList = 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 long queryId;
private String prop; private String prop;
private String label; private String label;
private String dictType;
public UniColumnInfo() { 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; this.queryId = queryId;
if (StringUtils.isNull(label)){ if (StringUtils.isNull(label)){
this.label = prop; this.label = prop;
@ -47,4 +59,12 @@ public class UniColumnInfo {
public void setLabel(String label) { public void setLabel(String label) {
this.label = 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 * @date 2021-01-30
*/ */
public class UniQuery extends BaseEntity { public class UniQuery extends BaseEntity {
/** /**
* id * id
*/ */
@ -52,9 +51,6 @@ public class UniQuery extends BaseEntity {
private List<UniCon> uniCons; private List<UniCon> uniCons;
private Integer pageNum;
private Integer pageSize;
private List<UniColumnInfo> infoList; private List<UniColumnInfo> infoList;
@ -102,22 +98,6 @@ public class UniQuery extends BaseEntity {
this.isRelease = isRelease; 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() { public List<UniCon> getUniCons() {
if (uniCons == null) { if (uniCons == null) {
return uniCons = new ArrayList<UniCon>(); 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) { if (uniQuery.getIsRelease() == 1) {
UniQuery query = uniQueryDao.selectUniQueryById(uniQuery.getId()); UniQuery query = uniQueryDao.selectUniQueryById(uniQuery.getId());
Menu Menu = new Menu(query.getId(), query.getUqName(), SecurityUtils.getUserId()); Menu Menu = new Menu(query.getId(), query.getUqName(), SecurityUtils.getUserId());
Integer insermenu = queryDao.insertMenu(Menu); queryDao.insertMenu(Menu);
if (insermenu == 0) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Result.error(ReturnConstants.OP_ERROR);
}
} else { } else {
Integer deleteMenu = queryDao.deleteMenu("data/" + uniQuery.getId()); 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.changeRelease(uniQuery);
return Result.ok();
} else { } else {
return Result.error(ReturnConstants.STATE_ERROR); return Result.error(ReturnConstants.STATE_ERROR);
} }
@ -97,11 +84,11 @@ public class QueryServiceImpl implements QueryService {
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public Result<Integer> updateQueryInfo(UniQuery uniQuery) { public Result<Integer> updateQueryInfo(UniQuery uniQuery) {
uniQueryDao.updateUniQuery(uniQuery); uniQueryDao.updateUniQuery(uniQuery);
queryDao.deleteUniCon(uniQuery.getId());
if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) { if (uniQuery.getUniCons() != null && uniQuery.getUniCons().size() > 0) {
queryDao.deleteUniCon(uniQuery.getId());
queryDao.insertUniCon(uniQuery.getUniCons()); queryDao.insertUniCon(uniQuery.getUniCons());
resetColumnInfo(uniQuery);
} }
resetColumnInfo(uniQuery);
return Result.ok(); return Result.ok();
} }
@ -114,6 +101,7 @@ public class QueryServiceImpl implements QueryService {
} }
@Override @Override
@Transactional(propagation = Propagation.SUPPORTS)
public Result<List<Map<String, Object>>> previewQuery(UniQuery uniQuery) { public Result<List<Map<String, Object>>> previewQuery(UniQuery uniQuery) {
StringBuilder sql = new StringBuilder(uniQuery.getUqSql().toLowerCase()); StringBuilder sql = new StringBuilder(uniQuery.getUqSql().toLowerCase());
List<UniCon> uniConList = uniQuery.getUniCons(); 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.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ebts.common.core.entity.Result; 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.SecurityUtils;
import com.ebts.common.utils.ServerResult; import com.ebts.common.utils.ServerResult;
import com.ebts.generator.dao.*; import com.ebts.generator.dao.*;
@ -41,6 +43,8 @@ public class TopQueryServiceImpl implements TopQueryService {
private UniQueryDao uniQueryDao; private UniQueryDao uniQueryDao;
@Resource @Resource
private UniColumnInfoDao uniColumnInfoDao; private UniColumnInfoDao uniColumnInfoDao;
// @Resource
// private Dict
@Override @Override
public Map<String, Object> selectTopSearchTables() { public Map<String, Object> selectTopSearchTables() {
@ -127,7 +131,7 @@ public class TopQueryServiceImpl implements TopQueryService {
} }
if (columns.getJSONObject(i).getInteger("isUse")==1){ 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(),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); sql.append(selectQuery);
PageHelper.startPage(1, 10, ""); PageHelper.startPage(1, 10, "");
List<Map<String, Object>> dataMap = queryDao.UniQuery(sql.toString()); 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); return Result.ok(topResult);
} }
@ -173,9 +185,9 @@ public class TopQueryServiceImpl implements TopQueryService {
TopNode getNode(List<TopNode> nodes, String id) { TopNode getNode(List<TopNode> nodes, String id) {
for (int i = 0; i < nodes.size(); i++) { for (TopNode node : nodes) {
if (nodes.get(i).getId().equals(id)) { if (node.getId().equals(id)) {
return nodes.get(i); return node;
} }
} }
return null; return null;

View File

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

View File

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

View File

@ -84,11 +84,11 @@
<select id="selectQueryInfo" parameterType="Long" resultMap="QueryResult"> <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, 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 from gen_uni_query uq
left join gen_uni_con uc on uc.uq_id = uq.id 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 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> </select>
<delete id="deleteUniCon"> <delete id="deleteUniCon">

View File

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

View File

@ -24,7 +24,7 @@
</sql> </sql>
<select id="selectUniQueryList" parameterType="UniQuery" resultMap="UniQueryResult"> <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> <where>
<if test="uqName != null and uqName != ''"> and uq_name like concat('%', #{uqName}, '%')</if> <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> <if test="uqDescribe != null and uqDescribe != ''"> and uq_describe like concat('%', #{uqDescribe}, '%')</if>
@ -34,7 +34,14 @@
</select> </select>
<select id="selectUniQueryById" parameterType="Long" resultMap="UniQueryResult"> <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> </select>
<insert id="insertUniQuery" parameterType="UniQuery" useGeneratedKeys="true" keyProperty="id"> <insert id="insertUniQuery" parameterType="UniQuery" useGeneratedKeys="true" keyProperty="id">
@ -71,7 +78,7 @@
<if test="createBy != null">create_by = #{createBy},</if> <if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if> <if test="updateBy != null">update_by = #{updateBy},</if>
</trim> </trim>
where id = #{id} where id = #{id} and is_release = 2
</update> </update>
<delete id="deleteUniQueryById" parameterType="Long"> <delete id="deleteUniQueryById" parameterType="Long">

View File

@ -6,6 +6,8 @@ public class RelColumnInfo {
private String prop; private String prop;
private String label; private String label;
private String dictType;
public long getQueryId() { public long getQueryId() {
return queryId; return queryId;
} }
@ -29,4 +31,12 @@ public class RelColumnInfo {
public void setLabel(String label) { public void setLabel(String label) {
this.label = 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 com.ebts.system.entity.RelColumnInfo;
import java.util.List; import java.util.List;
import java.util.Map;
public class RealInfo { public class RealInfo {
private List<RealUniQuery> uniCons; private List<RealUniQuery> uniCons;
private List<RelColumnInfo> infoList; private List<RelColumnInfo> infoList;
private Map<String,?> dictList;
public RealInfo() { 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.uniCons = uniCons;
this.infoList = infoList; this.infoList = infoList;
this.dictList = dictList;
} }
public List<RealUniQuery> getUniCons() { public List<RealUniQuery> getUniCons() {
@ -29,7 +32,16 @@ public class RealInfo {
return infoList; return infoList;
} }
public Map<String, ?> getDictList() {
return dictList;
}
public void setDictList(Map<String, ?> dictList) {
this.dictList = dictList;
}
public void setInfoList(List<RelColumnInfo> infoList) { public void setInfoList(List<RelColumnInfo> infoList) {
this.infoList = infoList; this.infoList = infoList;
} }
} }

View File

@ -3,6 +3,8 @@ package com.ebts.system.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.ebts.common.constant.ReturnConstants; import com.ebts.common.constant.ReturnConstants;
import com.ebts.common.core.entity.Result; 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.dao.RealQueryServiceDao;
import com.ebts.system.entity.RealUniCon; import com.ebts.system.entity.RealUniCon;
import com.ebts.system.entity.RealUniQuery; import com.ebts.system.entity.RealUniQuery;
@ -18,6 +20,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -42,7 +45,13 @@ public class RealQueryServiceImpl implements RealQueryService {
public Result<RealInfo> RealInfo(Long id) { public Result<RealInfo> RealInfo(Long id) {
List<RealUniQuery> uniCons = realQueryServiceDao.queryRealInfo(id); List<RealUniQuery> uniCons = realQueryServiceDao.queryRealInfo(id);
List<RelColumnInfo> infoList = realQueryServiceDao.queryRealColumnInfo(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 @Override

View File

@ -43,6 +43,6 @@
${paramSQL} ${paramSQL}
</select> </select>
<select id="queryRealColumnInfo" resultType="com.ebts.system.entity.RelColumnInfo"> <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> </select>
</mapper> </mapper>