wangrong
2026-08-30 4c949c0dc9bcae785c281c9d8125295f09810b15
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
<template>
  <el-drawer
    direction="btt"
    size="90%"
    v-model="dialogShow"
    trigger="click"
    :title="t('visualization.multiplexing')"
    modal-class="custom-drawer"
    @closed="handleClose()"
  >
    <!-- 标识当前在复用页,用于作为轮播提示前缀 -->
    <div v-if="dialogShow" id="multiplexingDrawer" />
    <dashboard-preview-show
      v-if="dialogShow && curDvType === 'dashboard'"
      ref="multiplexingPreviewShowRef"
      class="multiplexing-area"
      no-close
      show-position="multiplexing"
      resource-table="snapshot"
    ></dashboard-preview-show>
    <preview-show
      v-if="dialogShow && curDvType === 'dataV'"
      ref="multiplexingPreviewShowRef"
      class="multiplexing-area"
      no-close
      show-position="multiplexing"
      resource-table="snapshot"
    ></preview-show>
    <template #footer>
      <el-row class="multiplexing-footer">
        <el-col class="adapt-count">
          <span>{{ t('visualization.multi_selected', [selectComponentCount]) }} </span>
        </el-col>
        <el-col class="adapt-select">
          <span class="adapt-text">{{ t('visualization.component_style') }} : </span>
          <el-select
            style="width: 120px"
            v-model="multiplexingStyleAdapt"
            placeholder="Select"
            placement="top-start"
          >
            <el-option
              v-for="item in state.copyOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-col>
        <el-button class="close-button" @click="dialogShow = false">{{
          t('visualization.close')
        }}</el-button>
        <el-button
          type="primary"
          :disabled="!selectComponentCount"
          class="confirm-button"
          @click="saveMultiplexing"
          >{{ t('visualization.multiplexing') }}</el-button
        >
      </el-row>
    </template>
  </el-drawer>
</template>
 
<script setup lang="ts">
import { computed, reactive, ref, nextTick } from 'vue'
import DashboardPreviewShow from '@/views/dashboard/DashboardPreviewShow.vue'
import { copyStoreWithOut } from '@/store/modules/data-visualization/copy'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { storeToRefs } from 'pinia'
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
import PreviewShow from '@/views/data-visualization/PreviewShow.vue'
import { useI18n } from '@/hooks/web/useI18n'
import ChartCarouselTooltip from '@/views/chart/components/js/g2plot_tooltip_carousel'
const dvMainStore = dvMainStoreWithOut()
const snapshotStore = snapshotStoreWithOut()
const dialogShow = ref(false)
const copyStore = copyStoreWithOut()
const multiplexingPreviewShowRef = ref(null)
const { multiplexingStyleAdapt, curMultiplexingComponents } = storeToRefs(dvMainStore)
const curDvType = ref('dashboard')
const { t } = useI18n()
const selectComponentCount = computed(() => Object.keys(curMultiplexingComponents.value).length)
const state = reactive({
  copyOptions: [
    { label: t('visualization.adapt_new_subject'), value: true },
    { label: t('visualization.keep_subject'), value: false }
  ]
})
const dialogInit = (dvType = 'dashboard') => {
  ChartCarouselTooltip.paused()
  curDvType.value = dvType
  dialogShow.value = true
  dvMainStore.initCurMultiplexingComponents()
}
 
const saveMultiplexing = () => {
  dialogShow.value = false
  const previewStateInfo = multiplexingPreviewShowRef.value.getPreviewStateInfo()
  const canvasViewInfoPreview = previewStateInfo.canvasViewInfoPreview
  nextTick(() => {
    copyStore.copyMultiplexingComponents(
      canvasViewInfoPreview,
      undefined,
      undefined,
      undefined,
      previewStateInfo.canvasStylePreview.scale
    )
    snapshotStore.recordSnapshotCache('saveMultiplexing')
  })
}
const handleClose = () => {
  ChartCarouselTooltip.closeEnlargeDialogDestroy()
}
defineExpose({
  dialogInit
})
</script>
 
<style lang="less" scoped>
.close-button {
  position: absolute;
  top: 18px;
  right: 120px;
}
.confirm-button {
  position: absolute;
  top: 18px;
  right: 20px;
}
.multiplexing-area {
  width: 100%;
  height: 100%;
}
.multiplexing-footer {
  position: relative;
}
 
.adapt-count {
  position: absolute;
  top: 18px;
  left: 20px;
  color: #646a73;
  font-size: 14px;
  font-weight: 400;
  line-height: 22px;
}
 
.adapt-select {
  position: absolute;
  top: 18px;
  right: 220px;
}
.adapt-text {
  font-size: 14px;
  font-weight: 400;
  color: #1f2329;
  line-height: 22px;
}
</style>
 
<style lang="less">
.custom-drawer {
  .ed-drawer__footer {
    height: 64px !important;
    padding: 0px !important;
    box-shadow: 0 -1px 0px #d7d7d7 !important;
  }
 
  .ed-drawer__body {
    padding: 0 0 64px 0 !important;
  }
}
</style>