preview.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <template id="store-search-preview">
  2. <div class="search-box" > <!--:style="{background: computedStyle.searchBox}"-->
  3. <div class="search-ipt" flex="cross:center" :style="{...inputStyle}">
  4. <i class="el-icon-search search-icons" :style="{color: computedStyle.iconsStyle}"></i>
  5. <div class="placeholder" :style="{color: computedStyle.textStyle}">{{ searchData.name || '请输入关键字' }}</div>
  6. </div>
  7. </div>
  8. </template>
  9. <script>
  10. /**
  11. * @descriptions
  12. * 1. 组件名字必须对应模板形式 - 递归组件name
  13. * 2. 样式内容方法尽量内部维护 - 前端方便通用
  14. * 3. 父级组件会传预览数据 - activeItem
  15. */
  16. Vue.component('store-search-preview', {
  17. name: "store-search-preview",
  18. props: {
  19. activeItem: {
  20. type: Object,
  21. default () {
  22. return {}
  23. }
  24. }
  25. },
  26. template: '#store-search-preview',
  27. data() {
  28. return {
  29. }
  30. },
  31. computed: {
  32. computedStyle() {
  33. return this.activeItem.computedStyle
  34. },
  35. searchData() {
  36. return this.activeItem.data
  37. },
  38. inputStyle() {
  39. let tabItem = this.computedStyle.tabItem
  40. let style = {
  41. 'background': this.computedStyle.iptBg,
  42. ...this.computedStyle.searchIpts
  43. }
  44. if (tabItem && tabItem.value == 'border') style.border = '1px solid ' + (tabItem ? tabItem.color : 'transparent')
  45. if (tabItem && tabItem.value == 'shandow') style.boxShadow = tabItem ? '0 0 10px ' + tabItem.color : '0 0 10px rgba(226, 231, 244, 0.7)'
  46. return style
  47. }
  48. },
  49. mounted() {
  50. },
  51. methods: {
  52. }
  53. });
  54. </script>
  55. <style>
  56. .search-box {
  57. padding: 8px 12px;
  58. }
  59. .search-ipt {
  60. background-color: #F3F3F3;
  61. height: 30px;
  62. padding: 0 17px;
  63. }
  64. .placeholder {
  65. font-size: 11px;
  66. color: #999;
  67. font-weight: 700;
  68. padding-left: 10px;
  69. }
  70. .search-icons {
  71. color: #FF0000;
  72. }
  73. .search-shadow {
  74. /* box-shadow: 0 0 10px var(--shadow, rgba(226, 231, 244, 0.7)); */
  75. }
  76. </style>