2022-07-05 16:03:25 +08:00
|
|
|
<template>
|
|
|
|
<div class="el-view-select" :class="selectClass">
|
|
|
|
<el-select
|
|
|
|
ref="select"
|
|
|
|
v-model="innerValues"
|
|
|
|
popper-class="view-select-option"
|
|
|
|
style="width: 100%;"
|
|
|
|
multiple
|
|
|
|
clearable
|
|
|
|
@remove-tag="_selectRemoveTag"
|
|
|
|
@clear="_selectClearFun"
|
|
|
|
@focus="_popoverShowFun"
|
|
|
|
>
|
|
|
|
<el-option
|
2022-07-11 16:39:36 +08:00
|
|
|
v-for="item in selectOptions"
|
|
|
|
:key="item.id"
|
|
|
|
:label="item.name"
|
|
|
|
:value="item.id"
|
2022-07-05 16:03:25 +08:00
|
|
|
/>
|
|
|
|
</el-select>
|
|
|
|
|
2022-07-22 15:00:13 +08:00
|
|
|
|
2022-07-06 14:10:41 +08:00
|
|
|
|
2022-07-22 15:00:13 +08:00
|
|
|
|
|
|
|
<el-dialog
|
|
|
|
:visible="dialogShow"
|
|
|
|
:show-close="false"
|
|
|
|
class="dialog-css"
|
|
|
|
:fullscreen="true"
|
|
|
|
>
|
|
|
|
<div ref="contaninerDiv" :style="{'height': panelHeight + 'px'}" v-if="dialogShow && viewLoaded">
|
|
|
|
<Preview
|
|
|
|
:component-data="componentData"
|
|
|
|
:canvas-style-data="canvasStyleData"
|
|
|
|
:panel-info="panelInfo"
|
|
|
|
:show-position="showPosition"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div slot="title" class="dialog-footer title-text">
|
|
|
|
<span style="font-size: 14px;">
|
|
|
|
选择视图
|
|
|
|
</span>
|
|
|
|
<span style="float: right;">
|
|
|
|
<el-button type="primary" size="mini" @click="closeDialog()">{{ $t('commons.confirm') }}</el-button>
|
|
|
|
<el-button size="mini" @click="cancelDialog()">{{ $t('commons.cancel') }}</el-button>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</el-dialog>
|
2022-07-05 16:03:25 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import Preview from '@/components/canvas/components/Editor/Preview'
|
2022-07-06 14:10:41 +08:00
|
|
|
import { findOne } from '@/api/panel/panel'
|
2022-07-11 16:39:36 +08:00
|
|
|
import { viewOptions } from '@/api/chart/chart'
|
2022-07-06 14:10:41 +08:00
|
|
|
import { panelDataPrepare } from '@/components/canvas/utils/utils'
|
2022-07-05 16:03:25 +08:00
|
|
|
export default {
|
|
|
|
name: 'DeViewSelect',
|
|
|
|
components: { Preview },
|
|
|
|
props: {
|
|
|
|
value: {
|
|
|
|
type: Array,
|
|
|
|
default: () => []
|
|
|
|
},
|
2022-07-06 14:10:41 +08:00
|
|
|
panelId: {
|
|
|
|
type: String,
|
2022-07-05 16:03:25 +08:00
|
|
|
default: null
|
|
|
|
}
|
2022-07-06 14:10:41 +08:00
|
|
|
|
2022-07-05 16:03:25 +08:00
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
visible: false,
|
|
|
|
placement: 'bottom',
|
|
|
|
transition: 'el-zoom-in-top',
|
|
|
|
width: 500,
|
|
|
|
selectClass: 'my-top-class',
|
|
|
|
innerValues: [],
|
|
|
|
panelHeight: 450,
|
2022-07-06 14:10:41 +08:00
|
|
|
showPosition: 'email-task',
|
2022-07-11 16:39:36 +08:00
|
|
|
viewLoaded: false,
|
2022-07-22 15:00:13 +08:00
|
|
|
selectOptions: [],
|
|
|
|
dialogShow: false,
|
|
|
|
idsBeforeOpen: []
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
popperClass() {
|
|
|
|
const _c = 'el-view-select-popper ' + this.popoverClass
|
|
|
|
return this.disabled ? _c + ' disabled ' : _c
|
|
|
|
},
|
|
|
|
selectedViews() {
|
|
|
|
return this.$store.getters.panelViews[this.panelId]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
value(val, old) {
|
|
|
|
this.innerValues = val
|
|
|
|
},
|
|
|
|
innerValues(val, old) {
|
|
|
|
if (val !== old) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
panelId(val, old) {
|
2022-07-06 14:10:41 +08:00
|
|
|
if (val !== old) {
|
2022-07-11 16:39:36 +08:00
|
|
|
this.innerValues = []
|
2022-07-06 14:10:41 +08:00
|
|
|
this.loadView()
|
|
|
|
}
|
2022-07-05 16:03:25 +08:00
|
|
|
},
|
|
|
|
selectedViews: {
|
|
|
|
handler(val) {
|
|
|
|
if (!val || !JSON.stringify(val)) {
|
|
|
|
this.innerValues = []
|
|
|
|
return
|
|
|
|
}
|
2022-07-11 16:39:36 +08:00
|
|
|
const viewIds = JSON.parse(JSON.stringify(val))
|
|
|
|
|
2022-07-05 16:03:25 +08:00
|
|
|
this.innerValues = JSON.parse(JSON.stringify(viewIds))
|
|
|
|
},
|
|
|
|
deep: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this._updateH()
|
2022-07-22 15:00:13 +08:00
|
|
|
|
2022-07-05 16:03:25 +08:00
|
|
|
},
|
|
|
|
beforeDestroy() {
|
2022-07-11 16:39:36 +08:00
|
|
|
this._selectClearFun()
|
2022-07-22 15:00:13 +08:00
|
|
|
|
2022-07-05 16:03:25 +08:00
|
|
|
},
|
2022-07-06 14:10:41 +08:00
|
|
|
created() {
|
|
|
|
this.loadView()
|
|
|
|
},
|
2022-07-05 16:03:25 +08:00
|
|
|
methods: {
|
2022-07-06 14:10:41 +08:00
|
|
|
loadView() {
|
2022-07-11 16:39:36 +08:00
|
|
|
this._selectClearFun()
|
|
|
|
this.innerValues = this.value
|
2022-07-06 14:10:41 +08:00
|
|
|
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,
|
2022-07-22 13:20:13 +08:00
|
|
|
status: response.data.status,
|
|
|
|
createBy: response.data.createBy,
|
|
|
|
createTime: response.data.createTime,
|
|
|
|
updateBy: response.data.updateBy,
|
|
|
|
updateTime: response.data.updateTime
|
2022-07-06 14:10:41 +08:00
|
|
|
}
|
|
|
|
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
|
2022-07-11 16:39:36 +08:00
|
|
|
this.loadOptions()
|
2022-07-06 14:10:41 +08:00
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
2022-07-11 16:39:36 +08:00
|
|
|
|
|
|
|
loadOptions() {
|
|
|
|
this.panelId && viewOptions(this.panelId).then(res => {
|
|
|
|
this.selectOptions = res.data
|
|
|
|
this.init()
|
|
|
|
})
|
|
|
|
},
|
2022-07-05 16:03:25 +08:00
|
|
|
_updateH() {
|
|
|
|
this.$nextTick(() => {
|
2022-07-22 15:00:13 +08:00
|
|
|
if(this.$refs.contaninerDiv) {
|
|
|
|
this.width = this.$refs.contaninerDiv.clientWidth
|
|
|
|
this.panelHeight = this.width * 9 / 16
|
|
|
|
}
|
|
|
|
|
2022-07-05 16:03:25 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
_popoverShowFun(val) {
|
2022-07-22 15:00:13 +08:00
|
|
|
this.openDialog()
|
2022-07-05 16:03:25 +08:00
|
|
|
this._updateH()
|
|
|
|
this.$emit('onFoucs')
|
|
|
|
},
|
2022-07-22 15:00:13 +08:00
|
|
|
|
|
|
|
|
2022-07-05 16:03:25 +08:00
|
|
|
_selectRemoveTag(viewId) {
|
|
|
|
this.selectedViews.forEach(item => {
|
2022-07-22 15:00:13 +08:00
|
|
|
if (item === viewId) {
|
|
|
|
this.$store.dispatch('task/delView', { 'panelId': this.panelId, 'viewId': item })
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
_selectClearFun() {
|
2022-07-11 16:39:36 +08:00
|
|
|
this.$store.dispatch('task/delPanelViews', this.panelId)
|
|
|
|
},
|
|
|
|
init() {
|
|
|
|
if (this.value && this.value.length) {
|
|
|
|
const viewIds = JSON.parse(JSON.stringify(this.value))
|
|
|
|
this.$store.dispatch('task/initPanelView', { 'panelId': this.panelId, 'viewIds': viewIds })
|
|
|
|
}
|
2022-07-22 15:00:13 +08:00
|
|
|
},
|
|
|
|
openDialog() {
|
|
|
|
if (this.value && this.value.length) {
|
|
|
|
this.idsBeforeOpen = JSON.parse(JSON.stringify(this.value))
|
|
|
|
}
|
|
|
|
this.dialogShow = true
|
|
|
|
},
|
|
|
|
closeDialog() {
|
|
|
|
this.dialogShow = false
|
|
|
|
},
|
|
|
|
cancelDialog() {
|
|
|
|
this.innerValues = JSON.parse(JSON.stringify(this.idsBeforeOpen))
|
|
|
|
const viewIds = JSON.parse(JSON.stringify(this.innerValues))
|
|
|
|
this.$store.dispatch('task/initPanelView', { 'panelId': this.panelId, 'viewIds': viewIds })
|
|
|
|
this.closeDialog()
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.el-view-select .view-select-option {
|
2022-07-06 14:10:41 +08:00
|
|
|
display: none !important;
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
|
|
|
|
2022-07-22 15:00:13 +08:00
|
|
|
.my-top-class {
|
|
|
|
width: 100%;
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
2022-07-22 15:00:13 +08:00
|
|
|
.dialog-css ::v-deep .el-dialog__title {
|
|
|
|
font-size: 14px;
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
|
|
|
|
2022-07-22 15:00:13 +08:00
|
|
|
.dialog-css ::v-deep .el-dialog__header {
|
|
|
|
padding: 20px 20px 0;
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
|
|
|
|
2022-07-22 15:00:13 +08:00
|
|
|
.dialog-css ::v-deep .el-dialog__body {
|
|
|
|
padding: 10px 20px 20px;
|
2022-07-05 16:03:25 +08:00
|
|
|
}
|
|
|
|
</style>
|