ColumnPreview.vue
6.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<template>
<!-- 栏目预览 -->
<el-dialog
width="80%"
title="栏目预览"
:visible.sync="previewVisible"
append-to-body
@close="closeDialogFn"
>
<div
v-if="currentComponents"
class="box-card"
:class="{ 'column-height': baseColumn.colHeight }"
:style="{ '--columnHeight': `${baseColumn.colHeight}px` }"
>
<component
:is="currentComponents"
:show-data="showData"
:column-title="baseColumn.name"
:is-hide-pagination="isHidePagination"
:show-title="baseColumn.showTitle"
:custom-column-height="baseColumn.colHeight"
:page-size="baseColumn.refeshTime"
:combination-model="designColumn.model"
:more-url="baseColumn.colUrl"
:filter-type="designColumn.filterType"
:filter-scope="designColumn.filterScope"
:alias="baseColumn.alias"
:is-show-set-column="false"
:appid="baseColumn.appid"
:custom-style="baseColumn.colType=='HtCustom'?baseColumn.templateStyle:baseColumn.style"
:current-user="currentUser"
left-bar-top="3px"
:is-show-delete="false"
:is-disabled="true"
></component>
</div>
<el-empty
v-else
:image-size="380"
:image="noDataImg"
description="暂无模版预览哦~"
></el-empty>
</el-dialog>
</template>
<script>
import { mapGetters } from 'vuex'
import portal from '@/api/portal'
export default {
name: 'ColumnPreview',
props: {
previewAlias: {
type: String,
required: true,
},
},
data() {
return {
columnItem: null,
previewVisible: true,
currentComponents: '',
designColumn: {},
showData: null,
currentUser: {},
baseColumn: {},
noDataImg: require('@/assets/nodata_images/no-data.png'),
theme: {
name: 'default',
style: 'light',
layout: 'vertical',
header: 'fixed',
themeColor: '#2F54EB',
},
}
},
computed: {
...mapGetters({
layout: 'settings/layout',
header: 'settings/header',
tabsBar: 'settings/tabsBar',
themeBar: 'settings/themeBar',
style: 'settings/style',
themeColor: 'settings/themeColor',
}),
isHidePagination() {
return this.baseColumn.needPage == '1' ? false : true
},
},
watch: {
previewAlias: {
handler(val) {
if (val) {
this.getColumnDataByAlias(val)
}
},
immediate: true,
},
},
created() {
const theme = localStorage.getItem('eip-front-theme')
if (null !== theme) {
this.theme = JSON.parse(theme)
} else {
this.theme.layout = this.layout
this.theme.header = this.header
this.theme.tabsBar = this.tabsBar
this.theme.style = this.style
this.defaultActiveMap.style = this.style
this.defaultActiveMap.layout = this.layout
this.defaultActiveMap.themeColor = this.themeColor
}
this.handleSetTheme()
},
methods: {
getColumnDataByAlias(alias) {
portal.getColumnByAlias(alias, (data) => {
let componentData = data
this.baseColumn = {
...componentData,
showTitle: componentData.showTitle == 1 ? true : false,
}
this.designColumn = JSON.parse(componentData.dataParam)
this.currentComponents = componentData.colType
if (
['processCenter', 'combination', 'processPublicity'].includes(
this.designColumn.colType
)
) {
this.showData = this.designColumn.selectType
}
if (this.designColumn.colType === 'statisticalChart') {
let data = []
data.push({
dataType: this.designColumn.dataType,
currentDataType: this.designColumn.currentDataType,
})
this.showData = data
}
if (
this.designColumn.colType === 'news' ||
this.designColumn.colType === 'swipeSlide'
) {
this.showData = this.designColumn.announcementOrPictures
}
if (this.designColumn.colType === 'custom') {
this.designColumn.templateHtml2 = Base64.decode(
componentData.templateHtml
)
this.designColumn.templateJavaScript2 = Base64.decode(
componentData.templateJavaScript
)
this.designColumn.templateStyle2 = Base64.decode(
componentData.templateStyle
)
this.showData = componentData
}
if (this.designColumn.colType === 'dataSheets') {
this.showData = this.designColumn.currentSelectedInfo
}
if (['meetingRoom', 'schedule'].includes(this.designColumn.colType)) {
this.$set(
this.currentUser,
'username',
this.$store.state.user.username
)
this.$set(this.currentUser, 'userId', this.$store.state.user.userId)
}
})
},
handleSetTheme() {
let { name, layout, style, header, tabsBar, themeColor } = this.theme
const themeConfig = {
name,
layout,
header,
tabsBar,
style,
themeColor,
}
localStorage.setItem('eip-front-theme', JSON.stringify(themeConfig))
document.body.style = `--themeColor:${themeColor}; --themeColorRgb:${this.hexToRgba(
themeColor
)}`
},
hexToRgba(hex) {
const red = parseInt(`0x${hex.slice(1, 3)}`)
const green = parseInt(`0x${hex.slice(3, 5)}`)
const blue = parseInt(`0x${hex.slice(5, 7)}`)
return `${red},${green},${blue}`
},
//弹窗关闭
closeDialogFn() {
this.previewVisible = false
window.close()
},
},
}
</script>
<style lang="scss" scoped>
::v-deep .el-dialog__body {
padding: 20px;
.follow-theme-color {
color: var(--themeColor) !important;
}
//带透明度的主题背景色
.follow-theme-transparency-bg-color {
background: rgba(0, 128, 254, 0.04) !important;
}
}
.column-height {
// height: var(--columnHeight);
::v-deep {
.column-content {
height: calc(var(--columnHeight) - 104px);
overflow: auto;
//隐藏滚动条
&::-webkit-scrollbar {
width: 0;
background-color: transparent;
}
/*火狐下隐藏滚动条*/
scrollbar-width: none;
}
}
}
::v-deep .ht-custom-title .custom-title::before {
background: var(--themeColor);
}
</style>