design.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /**
  2. * 商品搜索·组件
  3. */
  4. var searchHtml = '<div style="display:none;"></div>';
  5. Vue.component("search-resource", {
  6. template: searchHtml,
  7. data: function () {
  8. return {
  9. data: this.$parent.data,
  10. styleList: [
  11. {
  12. label: "样式1",
  13. value: 1,
  14. icon_img: "iconsousuo11",
  15. },
  16. {
  17. label: "样式2",
  18. value: 2,
  19. icon_img: "iconsousuo1",
  20. },
  21. {
  22. label: "样式3",
  23. value: 3,
  24. icon_img: "iconsousuo12",
  25. }
  26. ],
  27. borderList: [
  28. {
  29. label: "方形",
  30. value: 1,
  31. icon_img: "icongl-square",
  32. },
  33. {
  34. label: "圆形",
  35. value: 2,
  36. icon_img: "iconyuanjiao",
  37. },
  38. ],
  39. textAlignList: [
  40. {
  41. label: "居左",
  42. value: "left",
  43. icon_img: "iconzuoduiqi"
  44. },
  45. {
  46. label: "居中",
  47. value: "center",
  48. icon_img: "iconjuzhongduiqi"
  49. },
  50. ],
  51. positionWayList: [
  52. {
  53. label: "正常显示",
  54. value: "static",
  55. },
  56. {
  57. label: "滚动至顶部固定",
  58. value: "fixed",
  59. }
  60. ],
  61. };
  62. },
  63. created: function () {
  64. if (!this.$parent.data.verify) this.$parent.data.verify = [];
  65. this.$parent.data.verify.push(this.verify);//加载验证方法
  66. this.$parent.data.ignore = ['elementAngle', 'componentAngle']; //加载忽略内容 -- 其他设置中的属性设置
  67. this.$parent.data.ignoreLoad = true; // 等待忽略数组赋值后加载
  68. // 组件所需的临时数据
  69. this.$parent.data.tempData = {
  70. styleList: this.styleList,
  71. textAlignList: this.textAlignList,
  72. positionWayList: this.positionWayList,
  73. borderList: this.borderList,
  74. methods: {
  75. addNotice: this.addNotice,
  76. iconStyle: this.iconStyle
  77. }
  78. };
  79. this.fetchIconColor();
  80. },
  81. methods: {
  82. verify: function (index) {
  83. var res = {code: true, message: ""};
  84. return res;
  85. },
  86. /**
  87. * 选择图标风格
  88. * @param event
  89. */
  90. iconStyle(event){
  91. var self = this;
  92. selectIconStyle({
  93. elem: event.currentTarget,
  94. icon: self.data.icon,
  95. callback: function (data) {
  96. if (data) {
  97. self.data.style = data;
  98. } else {
  99. iconStyleSet({
  100. style: JSON.stringify(self.data.style),
  101. query: {
  102. icon: self.data.icon
  103. }
  104. }, function(style){
  105. self.data.style = style;
  106. })
  107. }
  108. }
  109. })
  110. },
  111. /**
  112. * 渲染颜色组件
  113. * @param id
  114. * @param color
  115. * @param callback
  116. */
  117. colorRender(id, color, callback){
  118. setTimeout(function () {
  119. Colorpicker.create({
  120. el: id,
  121. color: color,
  122. change: function (elem, hex) {
  123. callback(elem, hex)
  124. }
  125. });
  126. })
  127. },
  128. /**
  129. * 渲染图标颜色选择器
  130. */
  131. fetchIconColor(){
  132. var self = this;
  133. self.colorRender('search-color-' + self.data.index, '', function (elem, color) {
  134. if (self.data.style.iconBgColor.length || self.data.style.iconBgImg) {
  135. self.data.style.iconBgColor = [color];
  136. } else {
  137. self.data.style.iconColor = [color];
  138. }
  139. self.$forceUpdate();
  140. });
  141. },
  142. }
  143. });