zxl
2 天以前 cb084b230023cfed42249b0145e177deb4b8261c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
  <div class="line flex flex-j-sb">
    <div class="column" v-for="(item,index) in data.options.list" :key="index">
      <div v-if="!item.img" class="placeholder">占位符</div>
      <img v-else :src="item.img" class="three-column-img">
    </div>
    <div class="setup-box">
      <div>
        <Button
          size="small"
          @click.stop="handleSelectModel(data.options.list)"
        >编辑</Button
        >
      </div>
    </div>
    <Modal
      v-model="showModal"
      title="装修"
      draggable
      width="800"
      :z-index="100"
      :mask-closable="false"
    >
      <div class="modal-tab-bar">
        <div v-for="(item,index) in data.options.list" :key="index">
          <img :src="item.img" class="three-column-img">
          <div>推荐尺寸:{{item.size}}</div>
          <Button
            size="small"
            class="ml_10"
            type="primary"
            @click="handleSelectImg(index)"
          >选择图片</Button
          >
          <Button
            size="small"
            class="ml_10"
            type="primary"
            @click="handleSelectLink(index)"
          >选择链接</Button
          >
        </div>
 
      </div>
    </Modal>
    <!-- 选择商品。链接 -->
    <liliDialog
      ref="liliDialog"
      @selectedLink="selectedLink"
      @selectedGoodsData="selectedGoodsData"
    ></liliDialog>
    <!-- 选择图片 -->
    <Modal width="1200px" v-model="picModelFlag" footer-hide>
      <ossManage
        @callback="callbackSelected"
        :isComponent="true"
        :initialize="picModelFlag"
        ref="ossManage"
      />
    </Modal>
  </div>
</template>
 
<script>
import ossManage from "@/views/sys/oss-manage/ossManage";
export default {
  name: "oneRowThreeColumns",
  components:{ossManage},
  props: {
    data: {
      type: Object,
      default: {}
    }
  },
  data () {
    return {
      showModal:false,
      selected: {}, // 已选数据
      picModelFlag:false,
      current:0,
    };
  },
  methods: {
    // 回显图片
    callbackSelected(val) {
      this.picModelFlag = false;
      this.selected[this.current].img = val.url;
      console.log(this.selected)
    },
    // 编辑模块
    handleSelectModel(item) {
      this.selected = item;
      this.showModal = true;
 
    },
    // 选择商品回调
    selectedGoodsData(val) {
      console.log(val);
      let goods = val[0];
      this.selected.img = goods.thumbnail;
      this.selected.price = goods.price;
      this.selected.name = goods.goodsName;
      this.selected.url = `/goodsDetail?skuId=${goods.id}&goodsId=${goods.goodsId}`;
    },
    // 选择链接回调
    selectedLink(val) {
      this.selected.url = this.$options.filters.formatLinkType(val);
      this.selected.type =
        val.___type === "other" && val.url === "" ? "link" : "other";
    },
    handleSelectLink(index) {
      // 调起选择链接弹窗
      this.$refs.liliDialog.open("link");
      this.current = index;
    },
    handleSelectImg(index){
      // 选择图片
      this.$refs.ossManage.selectImage = true;
      this.picModelFlag = true;
      this.current = index;
    }
  }
}
</script>
 
<style scoped lang="scss">
@import "./setup-box.scss";
.three-column-img{
  width:385px;
  height: 165px
}
.line:hover{
  >.setup-box{
    display: block;
  }
}
.placeholder{
  background: #666;
  width: 100%;
  height: 100%;
}
.line{
  position: relative;
  justify-content: space-between;
}
.column{
  width: 385px;
  height: 165px;
 
  >img{
    width: 100%;
    height: 100%;
  }
}
</style>