Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
7ebb015bd6
@ -0,0 +1,13 @@
|
||||
package io.dataease.base.mapper.ext;
|
||||
|
||||
import io.dataease.base.mapper.ext.query.GridExample;
|
||||
import io.dataease.controller.sys.request.SimpleTreeNode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ExtSysMenuMapper {
|
||||
|
||||
List<SimpleTreeNode> allNodes();
|
||||
|
||||
List<SimpleTreeNode> nodesByExample(GridExample example);
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="io.dataease.base.mapper.ext.ExtSysMenuMapper">
|
||||
|
||||
<resultMap id="simpleNode" type="io.dataease.controller.sys.request.SimpleTreeNode">
|
||||
<id property="id" column="id" javaType="java.lang.Long" />
|
||||
<result property="pid" column="pid" javaType="java.lang.Long"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="allNodes" resultMap="simpleNode">
|
||||
select menu_id as id, pid from sys_menu
|
||||
</select>
|
||||
|
||||
|
||||
<select id="nodesByExample" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="simpleNode">
|
||||
select menu_id as id, pid from sys_menu
|
||||
<include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -5,8 +5,11 @@ import io.dataease.base.domain.SysMenu;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
|
||||
import io.dataease.controller.handler.annotation.I18n;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.MenuCreateRequest;
|
||||
import io.dataease.controller.sys.request.MenuDeleteRequest;
|
||||
import io.dataease.controller.sys.request.SimpleTreeNode;
|
||||
import io.dataease.controller.sys.response.DeptNodeResponse;
|
||||
import io.dataease.controller.sys.response.MenuNodeResponse;
|
||||
import io.dataease.controller.sys.response.MenuTreeNode;
|
||||
import io.dataease.service.sys.MenuService;
|
||||
@ -37,6 +40,20 @@ public class SysMenuController {
|
||||
return menuService.convert(nodes);
|
||||
}
|
||||
|
||||
@ApiOperation("搜索菜单树")
|
||||
@I18n
|
||||
@PostMapping("/search")
|
||||
public List<MenuNodeResponse> search(@RequestBody BaseGridRequest request) {
|
||||
List<SysMenu> nodes = menuService.nodesTreeByCondition(request);
|
||||
List<MenuNodeResponse> nodeResponses = nodes.stream().map(node -> {
|
||||
MenuNodeResponse menuNodeResponse = BeanUtils.copyBean(new MenuNodeResponse(), node);
|
||||
menuNodeResponse.setHasChildren(node.getSubCount() > 0);
|
||||
menuNodeResponse.setTop(node.getPid() == menuService.MENU_ROOT_PID);
|
||||
return menuNodeResponse;
|
||||
}).collect(Collectors.toList());
|
||||
return nodeResponses;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ApiOperation("新增菜单")
|
||||
|
||||
@ -1,26 +1,24 @@
|
||||
package io.dataease.service.sys;
|
||||
|
||||
import io.dataease.base.domain.SysDept;
|
||||
|
||||
import io.dataease.base.domain.SysMenu;
|
||||
import io.dataease.base.domain.SysMenuExample;
|
||||
import io.dataease.base.mapper.SysMenuMapper;
|
||||
import io.dataease.base.mapper.ext.ExtMenuMapper;
|
||||
import io.dataease.base.mapper.ext.ExtSysMenuMapper;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.controller.sys.base.BaseGridRequest;
|
||||
import io.dataease.controller.sys.request.MenuCreateRequest;
|
||||
import io.dataease.controller.sys.request.MenuDeleteRequest;
|
||||
import io.dataease.controller.sys.response.DeptTreeNode;
|
||||
import io.dataease.controller.sys.request.SimpleTreeNode;
|
||||
import io.dataease.controller.sys.response.MenuNodeResponse;
|
||||
|
||||
import io.dataease.controller.sys.response.MenuTreeNode;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -34,6 +32,8 @@ public class MenuService {
|
||||
@Resource
|
||||
private SysMenuMapper sysMenuMapper;
|
||||
|
||||
@Resource
|
||||
private ExtSysMenuMapper extSysMenuMapper;
|
||||
|
||||
@Resource
|
||||
private ExtMenuMapper extMenuMapper;
|
||||
@ -173,4 +173,54 @@ public class MenuService {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<SysMenu> nodesTreeByCondition(BaseGridRequest request){
|
||||
List<SimpleTreeNode> allNodes = allNodes();
|
||||
List<SimpleTreeNode> targetNodes = nodeByCondition(request);
|
||||
if(org.apache.commons.collections.CollectionUtils.isEmpty(targetNodes)){
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<Long> ids = upTree(allNodes, targetNodes);
|
||||
SysMenuExample example = new SysMenuExample();
|
||||
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(ids)){
|
||||
SysMenuExample.Criteria criteria = example.createCriteria();
|
||||
criteria.andMenuIdIn(ids);
|
||||
}
|
||||
List<SysMenu> sysMenus = sysMenuMapper.selectByExample(example);
|
||||
return sysMenus;
|
||||
}
|
||||
|
||||
public List<SimpleTreeNode> allNodes() {
|
||||
List<SimpleTreeNode> allNodes = extSysMenuMapper.allNodes();
|
||||
return allNodes;
|
||||
}
|
||||
|
||||
public List<SimpleTreeNode> nodeByCondition(BaseGridRequest request) {
|
||||
List<SimpleTreeNode> simpleTreeNodes = extSysMenuMapper.nodesByExample(request.convertExample());
|
||||
return simpleTreeNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 找出目标节点所在路径上的所有节点 向上找
|
||||
* @param allNodes 所有节点
|
||||
* @param targetNodes 目标节点
|
||||
* @return
|
||||
*/
|
||||
private List<Long> upTree(List<SimpleTreeNode> allNodes, List<SimpleTreeNode> targetNodes){
|
||||
final Map<Long, SimpleTreeNode> map = allNodes.stream().collect(Collectors.toMap(SimpleTreeNode::getId, node -> node));
|
||||
List<Long> results = targetNodes.parallelStream().flatMap(targetNode -> {
|
||||
//向上逐级找爹
|
||||
List<Long> ids = new ArrayList<>();
|
||||
SimpleTreeNode node = targetNode;
|
||||
while (node != null) {
|
||||
ids.add(node.getId());
|
||||
Long pid = node.getPid();
|
||||
node = map.get(pid);
|
||||
}
|
||||
return ids.stream();
|
||||
}).distinct().collect(Collectors.toList());
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
<link rel="shortcut icon" href="<%= BASE_URL %>favicon.ico">
|
||||
<title>DataEase</title>
|
||||
</head>
|
||||
<body>
|
||||
<body style="height: 100%;">
|
||||
<div id="link"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -9,6 +9,15 @@ export function post(url, data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function ajaxGetData(id, data) {
|
||||
return request({
|
||||
url: '/chart/view/getData/' + id,
|
||||
method: 'post',
|
||||
loading: true,
|
||||
hideMsg: true,
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function getChartTree(data) {
|
||||
return request({
|
||||
|
||||
@ -53,4 +53,12 @@ export function treeByMenuId(menuId) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { addMenu, editMenu, delMenu, getMenusTree, getChild, treeByMenuId }
|
||||
export function queryCondition(data) {
|
||||
return request({
|
||||
url: '/api/menu/search',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export default { addMenu, editMenu, delMenu, getMenusTree, getChild, treeByMenuId, queryCondition }
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div id="canvasInfo" :style="customStyle" class="bg">
|
||||
<el-row v-if="componentDataShow.length===0" style="height: 100%;" class="custom-position">
|
||||
{{ $t('panel.panel_null') }}
|
||||
<!-- {{ $t('panel.panel_null') }} -->
|
||||
</el-row>
|
||||
<ComponentWrapper
|
||||
v-for="(item, index) in componentDataInfo"
|
||||
|
||||
@ -807,6 +807,12 @@ export default {
|
||||
delete_warning: 'Confirm to delete?'
|
||||
},
|
||||
panel: {
|
||||
copy_link_passwd: 'Copy link and password',
|
||||
copy_link: 'Copy link',
|
||||
passwd_protect: 'Password Protect',
|
||||
link: 'Link',
|
||||
link_share: 'Share Link',
|
||||
link_share_desc: 'After opening the link, anyone can access the dashboard through this link.',
|
||||
share: 'Share',
|
||||
datalist: 'Chart List',
|
||||
group: 'Catalogue',
|
||||
|
||||
@ -806,6 +806,12 @@ export default {
|
||||
delete_warning: '確認刪除?'
|
||||
},
|
||||
panel: {
|
||||
copy_link_passwd: '複製鏈接及密碼',
|
||||
copy_link: '複製鏈接',
|
||||
passwd_protect: '密碼保護',
|
||||
link: '鏈接',
|
||||
link_share: '鏈接分享',
|
||||
link_share_desc: '開啟鏈接後,任何人可通過此鏈接訪問儀表板。',
|
||||
share: '分享',
|
||||
datalist: '視圖列表',
|
||||
group: '目錄',
|
||||
|
||||
@ -808,6 +808,12 @@ export default {
|
||||
delete_warning: '确定要删除吗?'
|
||||
},
|
||||
panel: {
|
||||
copy_link_passwd: '复制链接及密码',
|
||||
copy_link: '复制链接',
|
||||
passwd_protect: '密码保护',
|
||||
link: '链接',
|
||||
link_share: '链接分享',
|
||||
link_share_desc: '开启链接后,任何人可通过此链接访问仪表板。',
|
||||
share: '分享',
|
||||
datalist: '视图列表',
|
||||
group: '目录',
|
||||
|
||||
@ -6,9 +6,11 @@ import '@/styles/index.scss' // global css
|
||||
import i18n from '../lang' // internationalization
|
||||
import ElementUI from 'element-ui'
|
||||
import '@/components/canvas/custom-component' // 注册自定义组件
|
||||
import widgets from '@/components/widget'
|
||||
import * as echarts from 'echarts'
|
||||
Vue.prototype.$echarts = echarts
|
||||
Vue.config.productionTip = false
|
||||
Vue.use(widgets)
|
||||
Vue.use(ElementUI, {
|
||||
|
||||
i18n: (key, value) => i18n.t(key, value)
|
||||
|
||||
@ -162,6 +162,21 @@ export function formatCondition(param) {
|
||||
return result
|
||||
}
|
||||
|
||||
export function formatQuickCondition(param, quickField) {
|
||||
let quickObj = null
|
||||
if (!param || !(quickObj = param.quick) || !quickField) {
|
||||
quickObj && delete param.quick
|
||||
return param
|
||||
}
|
||||
param[quickField] = {
|
||||
field: quickField,
|
||||
operator: 'like',
|
||||
value: quickObj.value
|
||||
}
|
||||
delete param.quick
|
||||
return param
|
||||
}
|
||||
|
||||
export function getQueryVariable(variable) {
|
||||
const query = window.location.search.substring(1)
|
||||
const vars = query.split('&')
|
||||
|
||||
@ -48,6 +48,7 @@ export const DEFAULT_LABEL = {
|
||||
export const DEFAULT_TOOLTIP = {
|
||||
show: true,
|
||||
trigger: 'item',
|
||||
confine: true,
|
||||
textStyle: {
|
||||
fontSize: '10',
|
||||
color: '#909399'
|
||||
|
||||
@ -73,8 +73,8 @@ export default {
|
||||
} else {
|
||||
customStyle = JSON.parse(chart.customStyle)
|
||||
}
|
||||
if (customStyle.background) {
|
||||
this.colorForm = customStyle.background
|
||||
if (customStyle.text) {
|
||||
this.titleForm = customStyle.text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,9 +218,15 @@
|
||||
</el-row>
|
||||
</el-row>
|
||||
<div ref="imageWrapper" style="height: 100%">
|
||||
<chart-component v-if="chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :chart-id="chart.id" :chart="chart" class="chart-class" />
|
||||
<table-normal v-if="chart.type && chart.type.includes('table')" :chart="chart" class="table-class" />
|
||||
<label-normal v-if="chart.type && chart.type.includes('text')" :chart="chart" class="table-class" />
|
||||
<chart-component v-if="httpRequest.status && chart.type && !chart.type.includes('table') && !chart.type.includes('text')" :chart-id="chart.id" :chart="chart" class="chart-class" />
|
||||
<table-normal v-if="httpRequest.status && chart.type && chart.type.includes('table')" :chart="chart" class="table-class" />
|
||||
<label-normal v-if="httpRequest.status && chart.type && chart.type.includes('text')" :chart="chart" class="table-class" />
|
||||
<div v-if="!httpRequest.status" style=";width: 100%;height: 100%;background-color: #ece7e7; text-align: center">
|
||||
<div style="font-size: 12px; color: #9ea6b2;">
|
||||
{{ $t('panel.error_data') }}<br>
|
||||
{{ httpRequest.msg }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</el-row>
|
||||
</el-col>
|
||||
@ -272,7 +278,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { post } from '@/api/dataset/dataset'
|
||||
import { post, ajaxGetData } from '@/api/chart/chart'
|
||||
import draggable from 'vuedraggable'
|
||||
import DimensionItem from '../components/drag-item/DimensionItem'
|
||||
import QuotaItem from '../components/drag-item/QuotaItem'
|
||||
@ -357,11 +363,16 @@ export default {
|
||||
},
|
||||
itemFormRules: {
|
||||
name: [
|
||||
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' }
|
||||
{ required: true, message: this.$t('commons.input_content'), trigger: 'change' },
|
||||
{ max: 50, message: this.$t('commons.char_can_not_more_50'), trigger: 'change' }
|
||||
]
|
||||
},
|
||||
tabStatus: false,
|
||||
data: {}
|
||||
data: {},
|
||||
httpRequest: {
|
||||
status: true,
|
||||
msg: ''
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@ -393,6 +404,11 @@ export default {
|
||||
post('/dataset/table/get/' + id, null).then(response => {
|
||||
this.table = response.data
|
||||
this.initTableField(id)
|
||||
}).catch(err => {
|
||||
this.resetView()
|
||||
this.httpRequest.status = false
|
||||
this.httpRequest.msg = err
|
||||
return true
|
||||
})
|
||||
}
|
||||
},
|
||||
@ -400,6 +416,11 @@ export default {
|
||||
post('/dataset/table/getFieldsFromDE', this.table).then(response => {
|
||||
this.dimension = response.data.dimension
|
||||
this.quota = response.data.quota
|
||||
}).catch(err => {
|
||||
this.resetView()
|
||||
this.httpRequest.status = false
|
||||
this.httpRequest.msg = err
|
||||
return true
|
||||
})
|
||||
},
|
||||
save(getData) {
|
||||
@ -463,7 +484,7 @@ export default {
|
||||
})
|
||||
},
|
||||
closeEdit() {
|
||||
if (this.view.title.length > 50) {
|
||||
if (this.view.title && this.view.title.length > 50) {
|
||||
this.$warning(this.$t('chart.title_limit'))
|
||||
return
|
||||
}
|
||||
@ -521,7 +542,7 @@ export default {
|
||||
},
|
||||
getData(id) {
|
||||
if (id) {
|
||||
post('/chart/view/getData/' + id, {
|
||||
ajaxGetData(id, {
|
||||
filter: []
|
||||
}).then(response => {
|
||||
this.initTableData(response.data.tableId)
|
||||
@ -535,6 +556,12 @@ export default {
|
||||
this.chart = response.data
|
||||
this.data = response.data.data
|
||||
// console.log(JSON.stringify(this.chart))
|
||||
this.httpRequest.status = true
|
||||
}).catch(err => {
|
||||
this.resetView()
|
||||
this.httpRequest.status = false
|
||||
this.httpRequest.msg = err
|
||||
return true
|
||||
})
|
||||
} else {
|
||||
this.view = {}
|
||||
@ -553,6 +580,13 @@ export default {
|
||||
|
||||
response.data.data = this.data
|
||||
this.chart = response.data
|
||||
|
||||
this.httpRequest.status = true
|
||||
}).catch(err => {
|
||||
this.resetView()
|
||||
this.httpRequest.status = false
|
||||
this.httpRequest.msg = err
|
||||
return true
|
||||
})
|
||||
} else {
|
||||
this.view = {}
|
||||
@ -739,13 +773,19 @@ export default {
|
||||
this.renameItem = true
|
||||
},
|
||||
saveRename() {
|
||||
if (this.itemForm.renameType === 'quota') {
|
||||
this.view.yaxis[this.itemForm.index].name = this.itemForm.name
|
||||
} else if (this.itemForm.renameType === 'dimension') {
|
||||
this.view.xaxis[this.itemForm.index].name = this.itemForm.name
|
||||
}
|
||||
this.save(true)
|
||||
this.closeRename()
|
||||
this.$refs['itemForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.itemForm.renameType === 'quota') {
|
||||
this.view.yaxis[this.itemForm.index].name = this.itemForm.name
|
||||
} else if (this.itemForm.renameType === 'dimension') {
|
||||
this.view.xaxis[this.itemForm.index].name = this.itemForm.name
|
||||
}
|
||||
this.save(true)
|
||||
this.closeRename()
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
closeRename() {
|
||||
this.renameItem = false
|
||||
@ -760,6 +800,15 @@ export default {
|
||||
},
|
||||
hideTab() {
|
||||
this.tabStatus = false
|
||||
},
|
||||
resetView() {
|
||||
this.dimension = []
|
||||
this.quota = []
|
||||
this.view = {
|
||||
xAxis: [],
|
||||
yAxis: [],
|
||||
type: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<div>
|
||||
<el-form ref="createOrganization" inline :model="form" size="small" label-width="80px">
|
||||
|
||||
<el-form-item label="链接分享">
|
||||
<el-form-item :label="$t('panel.link_share')">
|
||||
<el-switch
|
||||
v-model="valid"
|
||||
style="width: 370px;"
|
||||
@ -12,9 +12,9 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label=" ">
|
||||
<el-link class="de-link" style="width: 370px;" disabled>开启链接后,任何人可通过此链接访问仪表板。</el-link>
|
||||
<el-link class="de-link" style="width: 370px;" disabled>{{ $t('panel.link_share_desc') }}</el-link>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="valid" label="链接">
|
||||
<el-form-item v-if="valid" :label="$t('panel.link')">
|
||||
<el-input
|
||||
v-model.number="form.uri"
|
||||
disabled
|
||||
@ -23,17 +23,17 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="valid" label=" ">
|
||||
<el-checkbox v-model="form.enablePwd" @change="resetEnablePwd">密码保护</el-checkbox>
|
||||
<el-checkbox v-model="form.enablePwd" @change="resetEnablePwd">{{ $t('panel.passwd_protect') }} </el-checkbox>
|
||||
|
||||
<span v-if="form.enablePwd" class="de-span">{{ form.pwd }}</span>
|
||||
<span v-if="form.enablePwd" class="de-span" @click="resetPwd"><el-link :underline="false" type="primary">重置</el-link></span>
|
||||
<span v-if="form.enablePwd" class="de-span" @click="resetPwd"><el-link :underline="false" type="primary">{{ $t('commons.reset') }}</el-link></span>
|
||||
</el-form-item>
|
||||
|
||||
<div v-if="valid" class="auth-root-class">
|
||||
<span slot="footer">
|
||||
|
||||
<el-button v-if="!form.enablePwd" v-clipboard:copy="form.uri" v-clipboard:success="onCopy" v-clipboard:error="onError" size="mini" type="primary">复制链接</el-button>
|
||||
<el-button v-if="form.enablePwd" v-clipboard:copy="form.uri + ' 密码: '+ form.pwd" v-clipboard:success="onCopy" v-clipboard:error="onError" size="mini" type="primary">复制链接及密码</el-button>
|
||||
<el-button v-if="!form.enablePwd" v-clipboard:copy="form.uri" v-clipboard:success="onCopy" v-clipboard:error="onError" size="mini" type="primary">{{ $t('panel.copy_link') }}</el-button>
|
||||
<el-button v-if="form.enablePwd" v-clipboard:copy="form.uri + ' Password: '+ form.pwd" v-clipboard:success="onCopy" v-clipboard:error="onError" size="mini" type="primary">{{ $t('panel.copy_link_passwd') }}</el-button>
|
||||
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div style="width: 100%;height: 100%;background-color: #f7f8fa">
|
||||
<div style="width: 100%;height: 100vh;background-color: #f7f8fa">
|
||||
<Preview v-if="show" />
|
||||
</div>
|
||||
</template>
|
||||
@ -36,7 +36,7 @@ export default {
|
||||
})
|
||||
},
|
||||
resetID(data) {
|
||||
if( data ) {
|
||||
if (data) {
|
||||
data.forEach(item => {
|
||||
item.id = uuid.v1()
|
||||
})
|
||||
|
||||
@ -316,7 +316,7 @@ export default {
|
||||
const viewIds = this.componentData
|
||||
.filter(item => item.type === 'view' && item.propValue && item.propValue.viewId)
|
||||
.map(item => item.propValue.viewId)
|
||||
viewsWithIds(viewIds).then(res => {
|
||||
viewIds && viewIds.length > 0 && viewsWithIds(viewIds).then(res => {
|
||||
const datas = res.data
|
||||
this.viewInfos = datas
|
||||
})
|
||||
|
||||
@ -93,7 +93,7 @@
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import TreeTable from '@/components/business/tree-table'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import { formatCondition } from '@/utils/index'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { checkPermission } from '@/utils/permission'
|
||||
@ -149,10 +149,9 @@ export default {
|
||||
],
|
||||
searchConfig: {
|
||||
useQuickSearch: true,
|
||||
useComplexSearch: false,
|
||||
quickPlaceholder: '按名称搜索',
|
||||
components: [
|
||||
|
||||
{ field: 'name', label: this.$t('organization.name'), component: 'FuComplexInput' }
|
||||
]
|
||||
},
|
||||
|
||||
@ -260,17 +259,18 @@ export default {
|
||||
},
|
||||
// 加载表格数据
|
||||
search(condition) {
|
||||
// this.setTableAttr()
|
||||
condition = formatQuickCondition(condition, 'name')
|
||||
let conditionExist = false
|
||||
const temp = formatCondition(condition)
|
||||
this.tableData = []
|
||||
let param = {}
|
||||
if (condition && condition.quick) {
|
||||
const con = this.quick_condition(condition)
|
||||
param = formatCondition(con)
|
||||
if (temp && temp.conditions && temp.conditions.length !== 0) {
|
||||
conditionExist = true
|
||||
param = temp
|
||||
} else {
|
||||
param = { conditions: [this.defaultCondition] }
|
||||
}
|
||||
|
||||
// param.conditions.push(this.defaultCondition)
|
||||
loadTable(param).then(res => {
|
||||
let data = res.data
|
||||
data = data.map(obj => {
|
||||
@ -280,11 +280,15 @@ export default {
|
||||
return obj
|
||||
})
|
||||
|
||||
if (condition && condition.quick) {
|
||||
if (conditionExist) {
|
||||
data = this.buildTree(data)
|
||||
// this.setTableAttr(true)
|
||||
}
|
||||
this.tableData = data
|
||||
this.$nextTick(() => {
|
||||
this.tableData.forEach(node => {
|
||||
this.$refs.table.toggleRowExpansion(node, conditionExist)
|
||||
})
|
||||
})
|
||||
this.depts = null
|
||||
})
|
||||
},
|
||||
|
||||
@ -2,9 +2,8 @@
|
||||
<layout-content v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
<tree-table
|
||||
:columns="columns"
|
||||
|
||||
:search-config="searchConfig"
|
||||
@search="initTableData"
|
||||
@search="search"
|
||||
>
|
||||
<template #toolbar>
|
||||
<fu-table-button v-permission="['menu:add']" icon="el-icon-circle-plus-outline" :label="$t('menu.create')" @click="create" />
|
||||
@ -15,7 +14,6 @@
|
||||
:data="tableData"
|
||||
lazy
|
||||
:load="initTableData"
|
||||
|
||||
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
||||
row-key="menuId"
|
||||
>
|
||||
@ -120,7 +118,8 @@ import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import { checkPermission } from '@/utils/permission'
|
||||
import { addMenu, editMenu, delMenu, getMenusTree } from '@/api/system/menu'
|
||||
import { addMenu, editMenu, delMenu, getMenusTree, queryCondition } from '@/api/system/menu'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@ -169,11 +168,10 @@ export default {
|
||||
],
|
||||
searchConfig: {
|
||||
useQuickSearch: true,
|
||||
useComplexSearch: false,
|
||||
quickPlaceholder: '按姓名搜索',
|
||||
quickPlaceholder: '按标题搜索',
|
||||
components: [
|
||||
|
||||
// { field: 'name', label: '姓名', component: 'FuComplexInput' },
|
||||
{ field: 'title', label: this.$t('menu.tile'), component: 'FuComplexInput' }
|
||||
|
||||
// {
|
||||
// field: 'enabled',
|
||||
@ -204,7 +202,61 @@ export default {
|
||||
this.$router.push({ name: 'system-menu-form' })
|
||||
},
|
||||
search(condition) {
|
||||
console.log(condition)
|
||||
condition = formatQuickCondition(condition, 'title')
|
||||
const temp = formatCondition(condition)
|
||||
if (!temp || !temp.conditions || temp.conditions.length === 0) {
|
||||
this.initTableData()
|
||||
this.$nextTick(() => {
|
||||
this.tableData.forEach(node => {
|
||||
this.$refs.table.toggleRowExpansion(node, false)
|
||||
})
|
||||
})
|
||||
return
|
||||
}
|
||||
const param = temp || {}
|
||||
queryCondition(param).then(res => {
|
||||
let data = res.data
|
||||
data = data.map(obj => {
|
||||
if (obj.subCount > 0) {
|
||||
obj.hasChildren = true
|
||||
}
|
||||
return obj
|
||||
})
|
||||
|
||||
if (condition) {
|
||||
data = data.map(node => {
|
||||
delete (node.hasChildren)
|
||||
return node
|
||||
})
|
||||
this.tableData = this.buildTree(data)
|
||||
this.$nextTick(() => {
|
||||
data.forEach(node => {
|
||||
this.$refs.table.toggleRowExpansion(node, true)
|
||||
})
|
||||
})
|
||||
} else {
|
||||
this.tableData = data
|
||||
}
|
||||
})
|
||||
},
|
||||
buildTree(arrs) {
|
||||
const idMapping = arrs.reduce((acc, el, i) => {
|
||||
acc[el.menuId] = i
|
||||
return acc
|
||||
}, {})
|
||||
const roots = []
|
||||
arrs.forEach(el => {
|
||||
// 判断根节点
|
||||
if (el.pid === null || el.pid === 0) {
|
||||
roots.push(el)
|
||||
return
|
||||
}
|
||||
// 用映射表找到父元素
|
||||
const parentEl = arrs[idMapping[el.pid]]
|
||||
// 把当前元素添加到父元素的`children`数组中
|
||||
parentEl.children = [...(parentEl.children || []), el]
|
||||
})
|
||||
return roots
|
||||
},
|
||||
|
||||
// edit(row) {
|
||||
|
||||
@ -81,7 +81,7 @@
|
||||
|
||||
import LayoutContent from '@/components/business/LayoutContent'
|
||||
import ComplexTable from '@/components/business/complex-table'
|
||||
import { formatCondition } from '@/utils/index'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
import { addRole, editRole, delRole, roleGrid, addRoleMenus, menuIds } from '@/api/system/role'
|
||||
|
||||
import { getMenusTree, getChild } from '@/api/system/menu'
|
||||
@ -124,7 +124,7 @@ export default {
|
||||
}
|
||||
],
|
||||
searchConfig: {
|
||||
useQuickSearch: false,
|
||||
useQuickSearch: true,
|
||||
quickPlaceholder: this.$t('role.search_by_name'),
|
||||
components: [
|
||||
{ field: 'name', label: this.$t('role.role_name'), component: 'FuComplexInput' }
|
||||
@ -151,6 +151,7 @@ export default {
|
||||
this.$router.push({ name: 'system-role-form' })
|
||||
},
|
||||
search(condition) {
|
||||
condition = formatQuickCondition(condition, 'name')
|
||||
const temp = formatCondition(condition)
|
||||
const param = temp || {}
|
||||
roleGrid(this.paginationConfig.currentPage, this.paginationConfig.pageSize, param).then(response => {
|
||||
|
||||
@ -145,7 +145,7 @@ import LayoutContent from '@/components/business/LayoutContent'
|
||||
import ComplexTable from '@/components/business/complex-table'
|
||||
|
||||
import { checkPermission } from '@/utils/permission'
|
||||
import { formatCondition } from '@/utils/index'
|
||||
import { formatCondition, formatQuickCondition } from '@/utils/index'
|
||||
import { PHONE_REGEX } from '@/utils/validate'
|
||||
import { LOAD_CHILDREN_OPTIONS, LOAD_ROOT_OPTIONS } from '@riophae/vue-treeselect'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
@ -176,7 +176,8 @@ export default {
|
||||
],
|
||||
searchConfig: {
|
||||
useQuickSearch: true,
|
||||
quickPlaceholder: '按姓名搜索',
|
||||
useComplexSearch: true,
|
||||
quickPlaceholder: '按名称搜索',
|
||||
components: [
|
||||
{ field: 'nick_name', label: '姓名', component: 'FuComplexInput' },
|
||||
{
|
||||
@ -290,6 +291,7 @@ export default {
|
||||
},
|
||||
|
||||
search(condition) {
|
||||
condition = formatQuickCondition(condition, 'username')
|
||||
const temp = formatCondition(condition)
|
||||
const param = temp || {}
|
||||
const { currentPage, pageSize } = this.paginationConfig
|
||||
|
||||
Loading…
Reference in New Issue
Block a user