index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="border-color">
  3. <el-input
  4. v-model="localValue"
  5. class="bs-el-input"
  6. :placeholder="placeholder"
  7. clearable
  8. />
  9. <el-color-picker
  10. slot="append"
  11. v-model="localValue"
  12. popper-class="bs-el-color-picker"
  13. show-alpha
  14. class="bs-el-color-picker"
  15. :predefine="predefineColors"
  16. />
  17. </div>
  18. </template>
  19. <script>
  20. import {predefineColors} from 'data-room-ui/js/utils/colorList'
  21. export default {
  22. name: 'ColorPicker',
  23. props: {
  24. value: {
  25. type: String,
  26. default: ''
  27. }, // v-model 绑定的值
  28. placeholder: {
  29. type: String,
  30. default: ''
  31. }, // 输入框的占位文本
  32. predefineColors: { // 预定义的主题颜色
  33. type: Array,
  34. default: () => predefineColors
  35. }
  36. },
  37. data () {
  38. return {
  39. localValue: this.value
  40. }
  41. },
  42. watch: {
  43. value (newValue) {
  44. this.localValue = newValue
  45. },
  46. localValue (newValue) {
  47. this.$emit('input', newValue)
  48. }
  49. }
  50. }
  51. </script>
  52. <style lang="scss"></style>
  53. <style lang="scss" scoped>
  54. @import "../assets/style/bsTheme.scss";
  55. .border-color {
  56. display: flex;
  57. ::v-deep .el-input {
  58. width: auto;
  59. position: relative;
  60. margin-right: 5px;
  61. .el-input__inner {
  62. height: 32.5px;
  63. }
  64. }
  65. .el-input-group__append {
  66. width: 32.5px;
  67. height: 32.5px;
  68. background-color: var(--bs-background-1);
  69. .el-color-picker--mini {
  70. position: absolute;
  71. top: 1px;
  72. left: 7px;
  73. }
  74. }
  75. ::v-deep .el-color-picker__trigger {
  76. width: 32.5px;
  77. height: 32.5px;
  78. border-color: var(--bs-el-border);
  79. background-color: var(--bs-background-1);
  80. }
  81. }
  82. </style>