fix: 移动端查看分享仪表板报错

This commit is contained in:
fit2cloud-chenyw 2022-03-22 15:20:26 +08:00
parent 6e82e7072d
commit 3749e9c0d4
16 changed files with 140 additions and 69 deletions

View File

@ -1,15 +1,16 @@
package io.dataease.base.mapper.ext;
import io.dataease.mobile.dto.HomeItemDTO;
import io.dataease.mobile.dto.HomeItemShareDTO;
import java.util.List;
import java.util.Map;
public interface HomeMapper {
List<HomeItemDTO> queryStore(Map<String, Object> param);
List<HomeItemDTO> queryHistory();
List<HomeItemDTO> queryShare(Map<String, Object> param);
List<HomeItemShareDTO> queryShare(Map<String, Object> param);
}

View File

@ -18,14 +18,17 @@
order by s.create_time desc
</select>
<select id="queryShare" resultType="io.dataease.mobile.dto.HomeItemDTO">
<select id="queryShare" resultType="io.dataease.mobile.dto.HomeItemShareDTO">
select
distinct(s.panel_group_id) as id,
g.name as title,
s.create_time as `time`
s.create_time as `time`,
u.nick_name,
u.user_id
from panel_share s
inner join panel_group g
on s.panel_group_id = g.id
left join sys_user u on u.username = IFNULL(s.granter,g.create_by)
where
g.mobile_layout = 1 and (
( s.target_id = #{userId} and s.type = 0 ) or

View File

@ -2,6 +2,7 @@ package io.dataease.mobile.api;
import io.dataease.commons.utils.Pager;
import io.dataease.mobile.dto.HomeItemDTO;
import io.dataease.mobile.dto.HomeItemShareDTO;
import io.dataease.mobile.dto.HomeRequest;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@ -15,6 +16,8 @@ public interface HomeApi {
@PostMapping("/query")
Pager<List<HomeItemDTO>> query(@RequestBody HomeRequest request);
@PostMapping("/queryShares")
Pager<List<HomeItemShareDTO>> queryShares(@RequestBody HomeRequest request);
@PostMapping("/detail/{id}")
Object detail(@PathVariable String id);

View File

@ -0,0 +1,11 @@
package io.dataease.mobile.dto;
import lombok.Data;
@Data
public class HomeItemShareDTO extends HomeItemDTO {
private String nickName;
private Long userId;
}

View File

@ -3,6 +3,7 @@ package io.dataease.mobile.server;
import io.dataease.commons.utils.Pager;
import io.dataease.mobile.api.HomeApi;
import io.dataease.mobile.dto.HomeItemDTO;
import io.dataease.mobile.dto.HomeItemShareDTO;
import io.dataease.mobile.dto.HomeRequest;
import io.dataease.mobile.service.HomeService;
import org.springframework.web.bind.annotation.RestController;
@ -15,8 +16,6 @@ public class HomeServer implements HomeApi {
@Resource
private HomeService homeService;
@Override
public Pager<List<HomeItemDTO>> query(HomeRequest request) {
return homeService.query(request);
@ -27,5 +26,10 @@ public class HomeServer implements HomeApi {
return null;
}
@Override
public Pager<List<HomeItemShareDTO>> queryShares(HomeRequest request) {
return homeService.queryShares(request);
}
}

View File

@ -8,6 +8,7 @@ import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager;
import io.dataease.mobile.dto.HomeItemDTO;
import io.dataease.mobile.dto.HomeItemShareDTO;
import io.dataease.base.mapper.ext.HomeMapper;
import io.dataease.mobile.dto.HomeRequest;
import org.springframework.stereotype.Service;
@ -29,27 +30,28 @@ public class HomeService {
Map<String, Object> param = new HashMap<>();
param.put("userId", user.getUserId());
switch (request.getType()){
case 2:
Long deptId = user.getDeptId();
List<Long> roleIds = user.getRoles().stream().map(CurrentRoleDto::getId).collect(Collectors.toList());
param.put("deptId", deptId);
param.put("roleIds", roleIds);
if (null != request.getLastTime()) {
param.put("lastTime", request.getLastTime());
}
return PageUtils.setPageInfo(page, homeMapper.queryShare(param));
default:
param.put("userId", user.getUserId());
if (null != request.getLastTime()) {
param.put("lastTime", request.getLastTime());
}
return PageUtils.setPageInfo(page, homeMapper.queryStore(param));
param.put("userId", user.getUserId());
if (null != request.getLastTime()) {
param.put("lastTime", request.getLastTime());
}
return PageUtils.setPageInfo(page, homeMapper.queryStore(param));
}
public Pager<List<HomeItemShareDTO>> queryShares(HomeRequest request) {
CurrentUserDto user = AuthUtils.getUser();
Page<Object> page = PageHelper.startPage(1, 13, true);
Map<String, Object> param = new HashMap<>();
param.put("userId", user.getUserId());
Long deptId = user.getDeptId();
List<Long> roleIds = user.getRoles().stream().map(CurrentRoleDto::getId).collect(Collectors.toList());
param.put("deptId", deptId);
param.put("roleIds", roleIds);
if (null != request.getLastTime()) {
param.put("lastTime", request.getLastTime());
}
return PageUtils.setPageInfo(page, homeMapper.queryShare(param));
}
}

View File

@ -22,7 +22,7 @@ export function proxyInitPanelData(panelId, proxy, callback) {
queryPanelJumpInfo(panelId, proxy).then(rsp => {
store.commit('setNowPanelJumpInfo', rsp.data)
})
callback(response)
callback && callback(response)
})
}

View File

@ -8,6 +8,7 @@ import Preview from './Preview'
import { uuid } from 'vue-uuid'
import { initPanelData } from '@/api/panel/panel'
import { queryTargetPanelJumpInfo } from '@/api/panel/linkJump'
import { proxyInitPanelData } from '@/api/panel/shareProxy'
export default {
components: { Preview },
@ -15,12 +16,8 @@ export default {
return {
dataLoading: false,
backScreenShot: false,
mainHeight: '100vh!important'
}
},
watch: {
'$route.params.reportId': function() {
this.restore()
mainHeight: '100vh!important',
shareUserId: null
}
},
computed: {
@ -37,6 +34,7 @@ export default {
this.restore()
}
},
mounted() {
this.restore()
},
@ -45,35 +43,59 @@ export default {
this.mainHeight = mainHeight
},
restore() {
debugger
const _this = this
_this.dataLoading = true
_this.panelId = this.$route.params.reportId
if (!this.$route.params.reportId) {
return
}
const arr = this.$route.params.reportId.split('|')
if (!arr || arr.length === 0) {
return
}
_this.panelId = arr[0]
if (arr.length > 1) {
this.shareUserId = arr[1]
}
if (_this.$route.params.backScreenShot !== undefined) {
_this.backScreenShot = _this.$route.params.backScreenShot
}
//
initPanelData(this.panelId, function() {
_this.dataLoading = false
//
const tempParam = localStorage.getItem('jumpInfoParam')
if (tempParam) {
localStorage.removeItem('jumpInfoParam')
const jumpParam = JSON.parse(tempParam)
const jumpRequestParam = {
sourcePanelId: jumpParam.sourcePanelId,
sourceViewId: jumpParam.sourceViewId,
sourceFieldId: jumpParam.sourceFieldId,
targetPanelId: _this.panelId
}
_this.dataLoading = true
//
queryTargetPanelJumpInfo(jumpRequestParam).then(rsp => {
_this.dataLoading = false
_this.$store.commit('setNowTargetPanelJumpInfo', rsp.data)
_this.$store.commit('addViewTrackFilter', jumpParam)
})
if (this.shareUserId !== null) {
const param = { userId: this.shareUserId }
proxyInitPanelData(this.panelId, param, () => {
this.initCallBack()
})
} else {
initPanelData(this.panelId, () => {
this.initCallBack()
})
}
},
initCallBack() {
this.dataLoading = false
//
const tempParam = localStorage.getItem('jumpInfoParam')
if (tempParam) {
localStorage.removeItem('jumpInfoParam')
const jumpParam = JSON.parse(tempParam)
const jumpRequestParam = {
sourcePanelId: jumpParam.sourcePanelId,
sourceViewId: jumpParam.sourceViewId,
sourceFieldId: jumpParam.sourceFieldId,
targetPanelId: this.panelId
}
})
this.dataLoading = true
//
queryTargetPanelJumpInfo(jumpRequestParam).then(rsp => {
this.dataLoading = false
this.$store.commit('setNowTargetPanelJumpInfo', rsp.data)
this.$store.commit('addViewTrackFilter', jumpParam)
})
}
},
resetID(data) {
if (data) {

View File

@ -110,6 +110,7 @@ export default {
const param = { userId: data.userId }
proxyInitPanelData(data.id, param, function() {
bus.$emit('set-panel-show-type', 1)
bus.$emit('set-panel-share-user', data.userId)
})
this.$refs['botTree'].setCurrentKey(null)
},

View File

@ -137,7 +137,7 @@ import bus from '@/utils/bus'
import { queryAll } from '@/api/panel/pdfTemplate'
import ShareHead from '@/views/panel/GrantAuth/ShareHead'
import { initPanelData } from '@/api/panel/panel'
import { proxyInitPanelData } from '@/api/panel/shareProxy'
export default {
name: 'PanelViewShow',
components: { Preview, SaveToTemplate, PDFPreExport, ShareHead },
@ -162,7 +162,8 @@ export default {
snapshotInfo: '',
showType: 0,
dataLoading: false,
exporting: false
exporting: false,
shareUserId: null
}
},
computed: {
@ -214,6 +215,9 @@ export default {
bus.$on('set-panel-show-type', type => {
this.showType = type || 0
})
bus.$on('set-panel-share-user', userId => {
this.shareUserId = userId
})
this.initPdfTemplate()
},
methods: {
@ -227,7 +231,10 @@ export default {
this.fullscreen = true
},
newTab() {
const url = '#/preview/' + this.$store.state.panel.panelInfo.id
let url = '#/preview/' + this.$store.state.panel.panelInfo.id
if (this.showType === 1 && this.shareUserId !== null) {
url += ('|' + this.shareUserId)
}
window.open(url, '_blank')
},
saveToTemplate() {
@ -344,7 +351,10 @@ export default {
this.$emit('editPanel')
},
refreshPanel() {
initPanelData(this.panelInfo.id)
if (this.showType === 1 && this.shareUserId !== null) {
const param = { userId: this.shareUserId }
proxyInitPanelData(this.panelInfo.id, param, null)
} else { initPanelData(this.panelInfo.id) }
}
}
}

View File

@ -1,8 +1,12 @@
import request from '@/common/js/request'
export function requestHome(data) {
let url = '/mobile/home/query'
if (data && data.type === 2) {
url = 'mobile/home/queryShares'
}
return request({
url: '/mobile/home/query',
url: url,
method: 'post',
loading: true,
data

View File

@ -75,7 +75,8 @@ export default {
const param = {
id: node.id,
title: node.text,
index: 4
index: 4,
userId: node.userId
}
if(node.type === 'panel') {

View File

@ -72,7 +72,8 @@ export default {
const param = {
id: node.id,
title: node.text,
index: 4
index: 4,
userId: node.userId
}
if(node.type === 'panel') {

View File

@ -101,7 +101,8 @@ export default {
const param = {
id: node.id,
title: node.text,
index: 4
index: 4,
userId: node.userId
}
if(node.type === 'panel') {

View File

@ -133,7 +133,7 @@
methods: {
addRecent() {
const item = {id: this.banner.id, title: this.banner.title, index: this.banner.index}
const item = {id: this.banner.id, title: this.banner.title, index: this.banner.index, userId: this.banner.userId}
addRecent(item)
},
enshrine() {
@ -167,9 +167,11 @@
})
},
loadLinkUrl() {
this.url = process.env.VUE_APP_BASE_API + 'tempMobileLink/' + this.banner.id + "/" + getToken()
this.url = process.env.VUE_APP_BASE_API + 'tempMobileLink/' + this.banner.id + "/" + getToken()
if (this.banner.index && this.banner.index === 2 && this.banner.userId) {
this.url = process.env.VUE_APP_BASE_API + 'tempMobileLink/' + this.banner.id + '|' + this.banner.userId + "/" + getToken()
}
const url = this.url
/* uni.hideLoading() */
setTimeout(() => {

View File

@ -118,6 +118,9 @@
datas.forEach(item => {
item.article_type = 1
item.image_url = '../../../static/yibiaobans.png'
if(item.nickName) {
item.title += ('(' + item.nickName + ')')
}
if(item.time)
item.rightText = formatHistoryDate(item.time)
})
@ -151,10 +154,12 @@
const param = {
id: node.id,
title: node.title,
index: this.tabIndex
index: this.tabIndex,
userId: node.userId
}
if(this.tabIndex === 1) {
param.index = node.index
param.userId = node.userId
}
uni.navigateTo({