select_label.html 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <link rel="stylesheet" href="STATIC_EXT/colorPicker/css/colorpicker.css" />
  4. <link rel="stylesheet" href="STATIC_EXT/diyview/css/diyview.css" />
  5. <style>
  6. .icon-style-set{
  7. padding: 15px 30px;
  8. display: none;
  9. }
  10. </style>
  11. {/block}
  12. {block name="body"}
  13. <div id="app" class="layui-form icon-style-set" >
  14. <div class="layui-form-item tag-wrap" >
  15. <label class="layui-form-label sm">标签</label>
  16. <div class="layui-input-block">
  17. <div @click="labelData.control = true" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : labelData.control}">
  18. <i class="layui-anim layui-icon">{{ labelData.control ? "&#xe643;" : "&#xe63f;" }}</i>
  19. <div>开启</div>
  20. </div>
  21. <div @click="labelData.control = false" :class="{ 'layui-unselect layui-form-radio' : true,'layui-form-radioed' : !labelData.control}">
  22. <i class="layui-anim layui-icon">{{ !labelData.control ? "&#xe643;" : "&#xe63f;" }}</i>
  23. <div>关闭</div>
  24. </div>
  25. </div>
  26. </div>
  27. <div v-show="labelData.control">
  28. <div class="layui-form-item" >
  29. <label class="layui-form-label sm">标签内容</label>
  30. <div class="layui-input-block">
  31. <input type="text" name='text' v-model="labelData.text" maxlength="3" class="layui-input len-short" autocomplete="off" />
  32. </div>
  33. </div>
  34. <div class="layui-form-item flex">
  35. <div class="flex_left">
  36. <label class="layui-form-label sm">标签文字</label>
  37. <slot></slot>
  38. <div class="curr-color">
  39. <span>{{ labelData.textColor ? labelData.textColor : "透明" }}</span>
  40. </div>
  41. <slot name="right"></slot>
  42. </div>
  43. <div class="layui-input-block flex_fill">
  44. <div id="graphgic_nav_tag_color" class="picker colorSelector"><div :style="{ background : labelData.textColor }"></div></div>
  45. <span class="color-selector-reset text-color" @click="reset('textColor')">重置</span>
  46. </div>
  47. </div>
  48. <div class="layui-form-item flex">
  49. <div class="flex_left">
  50. <label class="layui-form-label sm">背景</label>
  51. <slot></slot>
  52. <div class="curr-color">
  53. <span>{{ labelData.bgColorStart ? labelData.bgColorStart : "透明" }}</span>
  54. <span>{{ labelData.bgColorEnd ? labelData.bgColorEnd : "透明" }}</span>
  55. </div>
  56. <slot name="right"></slot>
  57. </div>
  58. <div class="layui-input-block flex_fill">
  59. <div id="bgColorStart" class="picker colorSelector"><div :style="{ background : labelData.bgColorStart }"></div></div>
  60. <div id="bgColorEnd" class="picker colorSelector"><div :style="{ background : labelData.bgColorEnd }"></div></div>
  61. <span class="color-selector-reset text-color" @click="reset('bgColorStart,bgColorEnd')">重置</span>
  62. </div>
  63. </div>
  64. </div>
  65. </div>
  66. {/block}
  67. {block name="script"}
  68. <script src="STATIC_JS/vue.js"></script>
  69. <script src="STATIC_EXT/diyview/js/components.js"></script>
  70. <script src="STATIC_EXT/colorPicker/js/colorpicker.js"></script>
  71. <script>
  72. var form,slider,colorpicker,vue, data;
  73. data = {:json_encode($data)};
  74. layui.use(['form', 'slider', 'colorpicker'], function() {
  75. form = layui.form;
  76. slider = layui.slider;
  77. colorpicker = layui.colorpicker;
  78. vue = new Vue({
  79. el: "#app",
  80. data: {
  81. labelData: {},
  82. defaultColor:{
  83. 'text' : '热门',
  84. 'textColor' : '#FFFFFF',
  85. 'bgColorStart' : '#F83288',
  86. 'bgColorEnd' : '#FE3523',
  87. },
  88. lazyLoad:false,
  89. },
  90. created: function (){
  91. this.labelData = data;
  92. this.labelData.control = this.labelData.control == 'true' ? true : false;
  93. },
  94. methods: {
  95. reset: function (field) {
  96. let self = this;
  97. let field_arr = field.split(',');
  98. for (let i in field_arr) {
  99. self.labelData[field_arr[i]] = this.defaultColor[field_arr[i]];
  100. }
  101. },
  102. colorRender(id, color, callback){
  103. Colorpicker.create({
  104. el: id,
  105. color: color,
  106. change: function (elem, hex) {
  107. callback(hex)
  108. }
  109. });
  110. }
  111. },
  112. mounted(){
  113. var self = this;
  114. self.colorRender('graphgic_nav_tag_color', self.labelData.textColor, function (color) {
  115. self.labelData.textColor = color;
  116. })
  117. self.colorRender('bgColorStart', self.labelData.bgColorStart, function (color) {
  118. self.labelData.bgColorStart = color;
  119. })
  120. self.colorRender('bgColorEnd', self.labelData.bgColorEnd, function (color) {
  121. self.labelData.bgColorEnd = color;
  122. })
  123. setTimeout(function () {
  124. self.lazyLoad = true;
  125. $('.icon-style-set').show()
  126. }, 100)
  127. },
  128. computed: {
  129. }
  130. })
  131. })
  132. function getData(callback) {
  133. var data = ns.deepclone(vue._data.labelData);
  134. callback(data);
  135. }
  136. </script>
  137. {/block}