Blame view

admin-web-master/canvas-container/components/toolBar/toolModule/product-source-multiple.vue 3.25 KB
3f535f30   杨鑫   '初始'
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
  <template>
    <div class="product-source-category">
      <div class="porListBox">
        <div class="addProduct">
          <div v-if="productData.imgTextData && productData.imgTextData.length > 0" class="productList">
            <ul @click="addProduct">
              <li v-for="(item,index) in productData.imgTextData" :key="index">
                <el-image
                  style="width: 50px; height: 50px"
                  :src="item.image"
                  fit="contain"></el-image>
              </li>
            </ul>
          </div>
          <div v-else class="addProBtn addImgBtn" @click="addProduct"><span class="iconfont">&#xe685;</span>添加商品</div>
        </div>
      </div>
      <el-dialog title="选择产品" :visible.sync="dialogProduct">
        <product-select ref="productSelect" :selectedRows="productData.imgTextData" :isMultiple="true"></product-select>
        <span slot="footer" class="dialog-footer">
          <el-button @click="dialogProduct = false">取 消</el-button>
          <el-button type="primary" @click="addProductData">确 定</el-button>
        </span>
      </el-dialog>
    </div>
  </template>
  
  <script>
  import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
  import ProductSelect from './product-select'
  import { mapMutations } from 'vuex'
  export default {
  name: "product-source-multiple",
    components: { ProductSelect },
    mixins: [sendReqMixin],
    data () {
      return {
        dialogProduct: false,
      }
    },
    props: {
      productData: {
        type: Object,
        default: () => {}
      },
      type: {
        type: String,
        default: ''
      }
    },
    mounted () {
      this.selsectValue = this.linkValue // props 不能直接修改
    },
    methods: {
      ...mapMutations({
        setNewProductNum: 'SET_NEWPRODUCTNUM',
        setProductNum: 'SET_PRODUCTNUM'
      }),
      // 添加产品
      addProduct () {
        this.dialogProduct = true
      },
      // 确定选择
      addProductData () {
        this.productData.imgTextData = this.$refs.productSelect.multipleSelection
        this.productData.productIdList = []
        let imgTextData = this.productData.imgTextData
        imgTextData.forEach(item => {
          this.productData.productIdList.push(item.productId)
        })
        console.log(this.productData.productIdList,'productIdList')
        this.dialogProduct =  false
        this.viewRefresh()
      },
      // 通知画布刷新
      viewRefresh(){
        if(this.type === 'newProduct'){
          this.setNewProductNum()
        } else {
          this.setProductNum()
        }
      }
    }
  }
  </script>
  
  <style lang="scss" scoped>
  .product-source-category{
    .porListBox {
      padding: 10px;
      background: #F0F3F4;
      .addProduct {
        .productList{
          ul{
            display: flex;
            cursor: pointer;
            flex-wrap: wrap;
            li{
              display: block;
              height: 50px;
              margin: 0 2px 5px 0;
              position: relative;
            }
          }
        }
        .addImgBtn {
          border-radius: 4px;
          background: $mainColor;
          text-align: center;
          height: 36px;
          color: #ffffff;
          font-size: 14px;
          display: flex;
          align-items: center;
          justify-content: center;
          cursor: pointer;
          span {
            font-size: 20px;
            margin-right: 5px;
          }
        }
      }
    }
  }
  </style>