style.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var storeShowStyle = '<div>'
  2. storeShowStyle += '<div class="layui-form-item">';
  3. storeShowStyle += '<label class="layui-form-label sm">选择风格</label>';
  4. storeShowStyle += '<div class="layui-input-block">';
  5. storeShowStyle += '<div v-if="data.styleName" class="ns-input-text ns-text-color selected-style" v-on:click="selectGoodsStyle">{{data.styleName}} <i class="layui-icon layui-icon-right"></i></div>';
  6. storeShowStyle += '<div v-else class="ns-input-text selected-style" v-on:click="selectGoodsStyle">选择 <i class="layui-icon layui-icon-right"></i></div>';
  7. storeShowStyle += '</div>';
  8. storeShowStyle += '</div>';
  9. storeShowStyle += '<color v-bind:data="{ defaultcolor: \'#333333\' }"></color>';
  10. storeShowStyle += '<color v-bind:data="{ field : \'backgroundColor\', label : \'背景颜色\' }"></color>';
  11. storeShowStyle += '</div>';
  12. Vue.component("store-show-style", {
  13. template: storeShowStyle,
  14. data: function() {
  15. return {
  16. data: this.$parent.data,
  17. }
  18. },
  19. created:function() {
  20. if(!this.$parent.data.verify) this.$parent.data.verify = [];
  21. this.$parent.data.verify.push(this.verify);//加载验证方法
  22. },
  23. methods: {
  24. verify: function () {
  25. var res = { code: true, message: "" };
  26. return res;
  27. },
  28. selectGoodsStyle: function() {
  29. var self = this;
  30. layer.open({
  31. type: 1,
  32. title: '风格选择',
  33. area:['930px','630px'],
  34. btn: ['确定', '返回'],
  35. content: $(".draggable-element[data-index='" + self.data.index + "'] .edit-attribute .goods-list-style").html(),
  36. success: function(layero, index) {
  37. $(".layui-layer-content input[name='style']").val(self.data.style);
  38. $(".layui-layer-content input[name='style_name']").val(self.data.styleName);
  39. $("body").on("click", ".layui-layer-content .style-list-con-store .style-li-goods", function () {
  40. $(this).addClass("selected ns-border-color").siblings().removeClass("selected ns-border-color");
  41. $(".layui-layer-content input[name='style']").val($(this).index() + 1);
  42. $(".layui-layer-content input[name='style_name']").val($(this).find("span").text());
  43. });
  44. },
  45. yes: function (index, layero) {
  46. self.data.style = $(".layui-layer-content input[name='style']").val();
  47. self.data.styleName = $(".layui-layer-content input[name='style_name']").val();
  48. layer.closeAll()
  49. }
  50. });
  51. },
  52. }
  53. });