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
<template>
  <div class="attr-list de-collapse-style">
    <CommonAttr :element="curComponent">
      <el-collapse-item
        effect="dark"
        :title="t('visualization.style')"
        name="decoration_style"
        v-if="curComponent && !mobileInPc"
      >
        <div style="display: flex">
          <el-tooltip effect="dark" placement="bottom">
            <template #content> {{ t('visualization.color_setting', [1]) }} </template>
            <el-form-item
              effect="dark"
              style="margin-left: 12px"
              class="form-item no-margin-bottom"
              :class="'form-item-dark'"
            >
              <el-color-picker
                :title="t('visualization.color_setting', [1])"
                v-model="state.style.color0"
                class="color-picker-style"
                :prefix-icon="dvStyleColor"
                :triggerWidth="80"
                is-custom
                show-alpha
                :predefine="state.predefineColors"
                @change="onStyleChange('color0')"
              >
              </el-color-picker>
            </el-form-item>
          </el-tooltip>
 
          <el-tooltip effect="dark" placement="bottom">
            <template #content> {{ t('visualization.color_setting', [2]) }} </template>
            <el-form-item
              effect="dark"
              style="margin-left: 12px"
              class="form-item no-margin-bottom"
              :class="'form-item-dark'"
            >
              <el-color-picker
                :title="t('visualization.color_setting', [2])"
                v-model="curComponent.style.color1"
                class="color-picker-style"
                :prefix-icon="dvStyleColor"
                :triggerWidth="80"
                is-custom
                show-alpha
                :predefine="state.predefineColors"
                @change="onStyleChange('color0')"
              >
              </el-color-picker>
            </el-form-item>
          </el-tooltip>
        </div>
      </el-collapse-item>
    </CommonAttr>
  </div>
</template>
 
<script setup lang="ts">
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import CommonAttr from '@/custom-component/common/CommonAttr.vue'
import { storeToRefs } from 'pinia'
import { useI18n } from '@/hooks/web/useI18n'
import { onMounted, reactive, watch } from 'vue'
import { COLOR_PANEL } from '@/views/chart/components/editor/util/chart'
import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot'
const { t } = useI18n()
const dvMainStore = dvMainStoreWithOut()
const { curComponent, mobileInPc } = storeToRefs(dvMainStore)
import dvStyleColor from '@/assets/svg/dv-style-color.svg'
const state = reactive({
  style: {
    color0: null,
    color1: null,
    color2: null,
    dur: 6,
    reverse: false
  },
  predefineColors: COLOR_PANEL
})
 
const snapshotStore = snapshotStoreWithOut()
 
const onStyleChange = key => {
  curComponent.value.style[key] = state.style[key]
  snapshotStore.recordSnapshotCache('decoration')
}
 
watch(
  [() => curComponent.value],
  () => {
    init()
  },
  {
    deep: true
  }
)
 
onMounted(() => {
  init()
})
 
const init = () => {
  setTimeout(() => {
    state.style.color0 = curComponent.value.style.color0
    state.style.color1 = curComponent.value.style.color1
    state.style.color2 = curComponent.value.style.color2
  })
}
</script>