Merge branch 'dev' of github.com:dataease/dataease into dev

This commit is contained in:
taojinlong 2022-07-06 23:41:35 +08:00
commit 0b586c71cc
15 changed files with 140 additions and 79 deletions

View File

@ -54,4 +54,8 @@ public interface ShareApi {
@PostMapping("/removeShares")
void removeShares(PanelShareRemoveRequest request);
@ApiOperation("删除仪表板所有分享")
@PostMapping("/removePanelShares/{panelId}")
void removePanelShares(@PathVariable("panelId") String panelId);
}

View File

@ -52,4 +52,9 @@ public class ShareServer implements ShareApi {
public void removeShares(@RequestBody PanelShareRemoveRequest request) {
shareService.removeShares(request);
}
@Override
public void removePanelShares(String panelId) {
shareService.removeSharesyPanel(panelId);
}
}

View File

@ -26,6 +26,7 @@ import io.dataease.plugins.common.base.mapper.PanelShareMapper;
import io.dataease.service.message.DeMsgutil;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -386,6 +387,54 @@ public class ShareService {
.collect(Collectors.toList());
}
public void removeSharesyPanel(String panelId) {
PanelGroup panelGroup = panelGroupMapper.selectByPrimaryKey(panelId);
PanelShareRemoveRequest request = new PanelShareRemoveRequest();
request.setPanelId(panelId);
List<PanelShareOutDTO> panelShareOutDTOS = queryTargets(panelId);
extPanelShareMapper.removeShares(request);
if (CollectionUtils.isEmpty(panelShareOutDTOS) || ObjectUtils.isEmpty(panelGroup) || StringUtils.isBlank(panelGroup.getName())) {
return;
}
panelShareOutDTOS.forEach(shareOut -> {
SysLogConstants.SOURCE_TYPE buiType = buiType(shareOut.getType());
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelId, panelGroup.getPid(), shareOut.getTargetId(), buiType);
});
Map<Integer, List<PanelShareOutDTO>> listMap = panelShareOutDTOS.stream().collect(Collectors.groupingBy(dto -> dto.getType()));
AuthURD urd = new AuthURD();
for (Map.Entry<Integer, List<PanelShareOutDTO>> entry : listMap.entrySet()) {
List<PanelShareOutDTO> dtoList = entry.getValue();
if(CollectionUtils.isNotEmpty(dtoList)) {
List<Long> curTargetIds = dtoList.stream().map(dto -> Long.parseLong(dto.getTargetId())).collect(Collectors.toList());
buildRedAuthURD(entry.getKey(), curTargetIds, urd);
}
}
Set<Long> userIds = AuthUtils.userIdsByURD(urd);
if (CollectionUtils.isNotEmpty(userIds)) {
CurrentUserDto user = AuthUtils.getUser();
Gson gson = new Gson();
userIds.forEach(userId -> {
if (!user.getUserId().equals(userId)) {
String msg = panelGroup.getName();
List<String> msgParam = new ArrayList<>();
msgParam.add(panelId);
DeMsgutil.sendMsg(userId, 3L, user.getNickName() + " 取消分享了仪表板【" + msg + "】,请查收!", gson.toJson(msgParam));
}
});
}
}
private SysLogConstants.SOURCE_TYPE buiType(Integer type) {
SysLogConstants.SOURCE_TYPE targetType = SysLogConstants.SOURCE_TYPE.USER;
if (type == 1) {
targetType = SysLogConstants.SOURCE_TYPE.ROLE;
}else if (type == 2) {
targetType = SysLogConstants.SOURCE_TYPE.DEPT;
}
return targetType;
}
@Transactional
public void removeShares(PanelShareRemoveRequest removeRequest) {
String panelId = removeRequest.getPanelId();
@ -393,12 +442,7 @@ public class ShareService {
extPanelShareMapper.removeShares(removeRequest);
SysLogConstants.SOURCE_TYPE targetType = SysLogConstants.SOURCE_TYPE.USER;
if (removeRequest.getType() == 1) {
targetType = SysLogConstants.SOURCE_TYPE.ROLE;
}else if (removeRequest.getType() == 2) {
targetType = SysLogConstants.SOURCE_TYPE.DEPT;
}
SysLogConstants.SOURCE_TYPE targetType = buiType(removeRequest.getType());
DeLogUtils.save(SysLogConstants.OPERATE_TYPE.UNSHARE, SysLogConstants.SOURCE_TYPE.PANEL, panelId, panelGroup.getPid(), removeRequest.getTargetId(), targetType);
@ -407,9 +451,8 @@ public class ShareService {
buildRedAuthURD(removeRequest.getType(), removeIds, sharedAuthURD);
CurrentUserDto user = AuthUtils.getUser();
Gson gson = new Gson();
PanelGroup panel = panelGroupMapper.selectByPrimaryKey(panelId);
String msg = panel.getName();
String msg = panelGroup.getName();
List<String> msgParam = new ArrayList<>();
msgParam.add(panelId);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,14 @@ export function removeShares(data) {
})
}
export function removePanelShares(panelId) {
return request({
url: '/api/share/removePanelShares/' + panelId,
method: 'post',
loading: true
})
}
export function loadShares(data) {
return request({
url: '/api/share/queryWithResourceId',

View File

@ -22,17 +22,18 @@
</el-select>
<el-popover ref="popover" v-model="visible" :placement="placement" :transition="transition" :popper-class="popperClass" :width="width" trigger="click">
<el-scrollbar tag="div" wrap-class="el-select-dropdown__wrap" view-class="el-select-dropdown__list" class="is-empty">
<el-scrollbar v-if="viewLoaded" tag="div" wrap-class="el-select-dropdown__wrap" view-class="el-select-dropdown__list" class="is-empty">
<div :style="{'height': panelHeight + 'px'}">
<Preview
v-if="viewLoaded"
:component-data="componentData"
:canvas-style-data="canvasStyleData"
:panel-info="panelInfo"
:show-position="showPosition"
/>
</div>
</el-scrollbar>
<el-empty v-else style="height: 150px;" :image-size="120" description="" />
</el-popover>
</div>
@ -41,6 +42,8 @@
<script>
import { on, off } from './dom'
import Preview from '@/components/canvas/components/Editor/Preview'
import { findOne } from '@/api/panel/panel'
import { panelDataPrepare } from '@/components/canvas/utils/utils'
export default {
name: 'DeViewSelect',
components: { Preview },
@ -49,14 +52,11 @@ export default {
type: Array,
default: () => []
},
viewLoaded: {
type: Boolean,
default: false
},
viewPropData: {
type: Object,
panelId: {
type: String,
default: null
}
},
data() {
return {
@ -68,7 +68,8 @@ export default {
selectClass: 'my-top-class',
innerValues: [],
panelHeight: 450,
showPosition: 'email-task'
showPosition: 'email-task',
viewLoaded: false
}
},
computed: {
@ -76,19 +77,6 @@ export default {
const _c = 'el-view-select-popper ' + this.popoverClass
return this.disabled ? _c + ' disabled ' : _c
},
componentData() {
return this.viewLoaded && this.viewPropData && this.viewPropData.componentData || null
},
canvasStyleData() {
return this.viewLoaded && this.viewPropData && this.viewPropData.canvasStyleData || null
},
panelInfo() {
return this.viewLoaded && this.viewPropData && this.viewPropData.panelInfo || null
},
panelId() {
return this.viewLoaded && this.panelInfo && this.panelInfo.id
},
selectedViews() {
return this.$store.getters.panelViews[this.panelId]
}
@ -103,11 +91,12 @@ export default {
}
},
panelId(val, old) {
if (val !== old) { this.$store.dispatch('panel/setPanelInfo', this.panelInfo) }
if (val !== old) {
this.loadView()
}
},
selectedViews: {
handler(val) {
if (!this.viewLoaded) return
if (!val || !JSON.stringify(val)) {
this.labels = []
this.innerValues = []
@ -135,32 +124,47 @@ export default {
beforeDestroy() {
off(document, 'mouseup', this._popoverHideFun)
},
created() {
this.loadView()
},
methods: {
//
loadView() {
this.viewLoaded = false
this.panelId && findOne(this.panelId).then(response => {
this.panelInfo = {
id: response.data.id,
name: response.data.name,
privileges: response.data.privileges,
sourcePanelName: response.data.sourcePanelName,
status: response.data.status
}
this.$store.dispatch('panel/setPanelInfo', this.panelInfo)
panelDataPrepare(JSON.parse(response.data.panelData), JSON.parse(response.data.panelStyle), rsp => {
this.viewLoaded = true
this.componentData = rsp.componentData
this.canvasStyleData = rsp.componentStyle
})
})
},
_updateH() {
this.$nextTick(() => {
this.width = this.$refs.select.$el.getBoundingClientRect().width
this.panelHeight = this.width * 9 / 16
})
},
// el
_popoverShowFun(val) {
this._updateH()
this.$emit('onFoucs')
},
//
_popoverHideFun(e) {
const path = this._getEventPath(e)
const isInside = path.some(list => {
//
return list.className && typeof list.className === 'string' && list.className.indexOf('el-view-select') !== -1
})
if (!isInside) {
this.visible = false
}
},
// MouseEvent.path ie11,edge,chrome,firefox,safari
_getEventPath(evt) {
const path = (evt.composedPath && evt.composedPath()) || evt.path
const target = evt.target
@ -201,26 +205,26 @@ export default {
<style lang="scss" scoped>
.el-view-select .view-select-option {
display: none !important;
display: none !important;
}
.el-view-select-popper {
max-height: 800px;
overflow: auto;
max-height: 800px;
overflow: auto;
}
.el-view-select-popper.disabled {
display: none !important;
display: none !important;
}
.el-view-select-popper .el-button--small {
width: 25px !important;
min-width: 25px !important;
width: 25px !important;
min-width: 25px !important;
}
.el-view-select-popper[x-placement^='bottom'] {
margin-top: 5px;
margin-top: 5px;
}
.my-top-class {
width: 100%;
width: 100%;
}
</style>

View File

@ -10,6 +10,7 @@ export const DARK_THEME_COLOR_MAIN = '#FFFFFF'
export const DARK_THEME_COLOR_SLAVE1 = '#CCCCCC'
export const DARK_THEME_PANEL_BACKGROUND = '#030B2E'
export const DARK_THEME_COMPONENT_BACKGROUND = '#131E42'
export const DARK_THEME_COMPONENT_BACKGROUND_BACK = '#5a5c62'
export function getStyle(style, filter = []) {
const needUnit = [
@ -298,8 +299,8 @@ export function recursionThemTransObj(template, infoObj, color) {
// 如果是数组 进行赋值计算
if (template[templateKey] instanceof Array) {
template[templateKey].forEach(templateProp => {
if (infoObj[templateKey] && infoObj[templateKey][templateProp]) {
infoObj[templateKey][templateProp] = color
if (infoObj[templateKey]) {
Vue.set(infoObj[templateKey], templateProp, color)
}
})
} else {
@ -332,7 +333,7 @@ export function adaptCurTheme(customStyle, customAttr) {
recursionThemTransObj(THEME_STYLE_TRANS_MAIN, customStyle, DARK_THEME_COLOR_MAIN)
recursionThemTransObj(THEME_STYLE_TRANS_SLAVE1, customStyle, DARK_THEME_COLOR_SLAVE1)
recursionThemTransObj(THEME_ATTR_TRANS_MAIN, customAttr, DARK_THEME_COLOR_MAIN)
recursionThemTransObj(THEME_ATTR_TRANS_SLAVE1_BACKGROUND, customAttr, DARK_THEME_COMPONENT_BACKGROUND)
recursionThemTransObj(THEME_ATTR_TRANS_SLAVE1_BACKGROUND, customAttr, DARK_THEME_COMPONENT_BACKGROUND_BACK)
}
customAttr['color'] = { ...canvasStyle.chartInfo.chartColor }
customStyle['text'] = { ...canvasStyle.chartInfo.chartTitle, title: customStyle['text']['title'] }
@ -375,7 +376,7 @@ export function adaptCurThemeFilterStyleAll(styleKey) {
const filterStyle = store.state.canvasStyleData.chartInfo.filterStyle
componentData.forEach((item) => {
if (isFilterComponent(item.component)) {
item.style[styleKey] = filterStyle[styleKey]
Vue.set(item.style, styleKey, filterStyle[styleKey])
}
})
}

View File

@ -2042,7 +2042,8 @@ export default {
once_a_week: 'Once a week',
once_a_month: 'Once a month',
complex_repeat: 'Complex repeat',
pixel_tip: 'Please code custom pixel(such as 2560 * 1600) or select'
pixel_tip: 'Please code custom pixel(such as 2560 * 1600) or select',
task_type: 'Task type'
},
dynamic_time: {

View File

@ -2054,7 +2054,8 @@ export default {
once_a_week: '每周一次',
once_a_month: '每月一次',
complex_repeat: '複雜重複',
pixel_tip: '可直接輸入分辨率(例如:2560 * 1600)或者選擇'
pixel_tip: '可直接輸入分辨率(例如:2560 * 1600)或者選擇',
task_type: '任務類型'
},
dynamic_time: {

View File

@ -2064,7 +2064,8 @@ export default {
once_a_week: '每周一次',
once_a_month: '每月一次',
complex_repeat: '复杂重复',
pixel_tip: '可直接输入自定义分辨率(例如:2560 * 1600)或选择'
pixel_tip: '可直接输入自定义分辨率(例如:2560 * 1600)或选择',
task_type: '任务类型'
},
dynamic_time: {

View File

@ -22,6 +22,7 @@ import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import './utils/dialog'
import DeComplexInput from '@/components/business/condition-table/DeComplexInput'
import DeComplexSelect from '@/components/business/condition-table/DeComplexSelect'
import DeViewSelect from '@/components/DeViewSelect'
import '@/components/canvas/custom-component' // 注册自定义组件
import '@/utils/DateUtil'
@ -88,6 +89,7 @@ Vue.use(message)
Vue.component('Treeselect', Treeselect)
Vue.component('DeComplexInput', DeComplexInput)
Vue.component('DeComplexSelect', DeComplexSelect)
Vue.component('DeViewSelect', DeViewSelect)
Vue.config.productionTip = false
import vueToPdf from 'vue-to-pdf'

View File

@ -69,7 +69,7 @@
</template>
<script>
import { loadTree, loadShareOutTree, removeShares } from '@/api/panel/share'
import { loadTree, loadShareOutTree, removePanelShares } from '@/api/panel/share'
import { uuid } from 'vue-uuid'
import { initPanelData } from '@/api/panel/panel'
import { proxyInitPanelData } from '@/api/panel/shareProxy'
@ -172,16 +172,12 @@ export default {
})
},
removeCurrent(node) {
const param = {
panelId: node.id
}
this.$confirm(this.$t('panel.remove_share_confirm'), '', {
confirmButtonText: this.$t('commons.confirm'),
cancelButtonText: this.$t('commons.cancel'),
type: 'warning'
}).then(() => {
removeShares(param).then(res => {
removePanelShares(node.id).then(res => {
this.panelInfo && this.panelInfo.id && node.id === this.panelInfo.id && this.setMainNull()
this.initOutData().then(res => {
this.outDatas = res.data

View File

@ -70,6 +70,8 @@ export default {
},
remove(row) {
deleteEnshrine(row.panelGroupId).then(res => {
const msg = this.$t('commons.cancel') + this.$t('panel.store') + this.$t('commons.success')
this.$success(msg)
this.initData()
this.panelInfo && this.panelInfo.id && row.panelGroupId === this.panelInfo.id && this.setMainNull()
})

View File

@ -675,6 +675,7 @@ export default {
onMove(e, originalEvent) {
this.showTips = false
this.moveId = e.draggedContext.element.id
if (this.isTree) return true
const tabelId = e.draggedContext.element.tableId
const prohibit = this.currentElement.options.attrs.dragItems.some(item => item.tableId === tabelId)
if (prohibit) {