tanghaolin
2022-08-31 244c4241427b9f3316f06f1e0ae2ee571edc1a23
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
<!-- vcolorpicker -->
<template>
  <div class="vcolorpickerbox">
    <span
      class="colorbox"
      @click="isShowColorPicker = true"
      :style="`background-color:${value};`"
    >
    <van-icon class="colorarrow" name="arrow-down" />
    </span>
    
    <div v-show="isShowColorPicker" @click="isShowColorPicker=false" class="mask"></div>
    <div class="sketchpickerbox" v-show="isShowColorPicker" style="">
      <sketch-picker
        style="width: 100%; height: 100%; box-sizing: border-box"
        v-model="model_background_color"
      ></sketch-picker>
      <div class="sketchpickerbtnbox">
        <van-button
          class="sketchpickerbtn"
          @click="isShowColorPicker = false"
          size="mini"
          >取消</van-button
        >
        <van-button
          class="sketchpickerbtn"
          @click="confirm"
          type="info"
          size="mini"
          >确认</van-button
        >
      </div>
    </div>
  </div>
</template>
 
<script>
import { Sketch } from "vue-color";
export default {
  name: "",
  props: ["value"],
  components: { "sketch-picker": Sketch },
  data() {
    return {
      isShowColorPicker: false,
      model_background_color: {
        hex: "#194d33",
        hex8: "#194D33A8",
        hsl: { h: 150, s: 0.5, l: 0.2, a: 1 },
        hsv: { h: 150, s: 0.66, v: 0.3, a: 1 },
        rgba: { r: 25, g: 77, b: 51, a: 1 },
        a: 1,
      },
    };
  },
  created() {},
  mounted() {},
  computed: {},
  watch: {},
  methods: {
    confirm() {
      this.isShowColorPicker = false;
      this.$emit("input", this.model_background_color.hex);
    },
  },
};
</script>
<style scoped>
.vcolorpickerbox {
  width: 40px;
  height: 40px;
  box-sizing: border-box;
  position: relative;
}
.vcolorpickerbox .mask{
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.3);
    z-index: 99998;
}
.vcolorpickerbox .colorbox {
  display: inline-block;
  width: 15px;
  height: 15px;
  cursor: pointer;
  position: absolute;
  top: 13px;
  left: 13px;
  border: 1px solid #666;
}
.vcolorpickerbox .colorarrow{
  color: #fff;
  font-size: 14px;
}
.vcolorpickerbox .sketchpickerbox {
  position: absolute;
  top: 30px;
  left: 13px;
  width: 220px;
  height: 330px;
  z-index: 99999;
}
.sketchpickerbtnbox {
  text-align: right;
  position: absolute;
  bottom: 5px;
  width: 100%;
  padding: 0 10px;
  box-sizing: border-box;
}
.sketchpickerbtn {
  margin: 0 10px;
}
</style>