product-source-multiple.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="product-source-category">
  3. <div class="porListBox">
  4. <div class="addProduct">
  5. <div v-if="productData.imgTextData && productData.imgTextData.length > 0" class="productList">
  6. <ul @click="addProduct">
  7. <li v-for="(item,index) in productData.imgTextData" :key="index">
  8. <el-image
  9. style="width: 50px; height: 50px"
  10. :src="item.image"
  11. fit="contain"></el-image>
  12. </li>
  13. </ul>
  14. </div>
  15. <div v-else class="addProBtn addImgBtn" @click="addProduct"><span class="iconfont">&#xe685;</span>添加商品</div>
  16. </div>
  17. </div>
  18. <el-dialog title="选择产品" :visible.sync="dialogProduct">
  19. <product-select ref="productSelect" :selectedRows="productData.imgTextData" :isMultiple="true"></product-select>
  20. <span slot="footer" class="dialog-footer">
  21. <el-button @click="dialogProduct = false">取 消</el-button>
  22. <el-button type="primary" @click="addProductData">确 定</el-button>
  23. </span>
  24. </el-dialog>
  25. </div>
  26. </template>
  27. <script>
  28. import {sendReqMixin} from '@@/components/canvasShow/config/mixin'
  29. import ProductSelect from './product-select'
  30. import { mapMutations } from 'vuex'
  31. export default {
  32. name: "product-source-multiple",
  33. components: { ProductSelect },
  34. mixins: [sendReqMixin],
  35. data () {
  36. return {
  37. dialogProduct: false,
  38. }
  39. },
  40. props: {
  41. productData: {
  42. type: Object,
  43. default: () => {}
  44. },
  45. type: {
  46. type: String,
  47. default: ''
  48. }
  49. },
  50. mounted () {
  51. this.selsectValue = this.linkValue // props 不能直接修改
  52. },
  53. methods: {
  54. ...mapMutations({
  55. setNewProductNum: 'SET_NEWPRODUCTNUM',
  56. setProductNum: 'SET_PRODUCTNUM'
  57. }),
  58. // 添加产品
  59. addProduct () {
  60. this.dialogProduct = true
  61. },
  62. // 确定选择
  63. addProductData () {
  64. this.productData.imgTextData = this.$refs.productSelect.multipleSelection
  65. this.productData.productIdList = []
  66. let imgTextData = this.productData.imgTextData
  67. imgTextData.forEach(item => {
  68. this.productData.productIdList.push(item.productId)
  69. })
  70. console.log(this.productData.productIdList,'productIdList')
  71. this.dialogProduct = false
  72. this.viewRefresh()
  73. },
  74. // 通知画布刷新
  75. viewRefresh(){
  76. if(this.type === 'newProduct'){
  77. this.setNewProductNum()
  78. } else {
  79. this.setProductNum()
  80. }
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. .product-source-category{
  87. .porListBox {
  88. padding: 10px;
  89. background: #F0F3F4;
  90. .addProduct {
  91. .productList{
  92. ul{
  93. display: flex;
  94. cursor: pointer;
  95. flex-wrap: wrap;
  96. li{
  97. display: block;
  98. height: 50px;
  99. margin: 0 2px 5px 0;
  100. position: relative;
  101. }
  102. }
  103. }
  104. .addImgBtn {
  105. border-radius: 4px;
  106. background: $mainColor;
  107. text-align: center;
  108. height: 36px;
  109. color: #ffffff;
  110. font-size: 14px;
  111. display: flex;
  112. align-items: center;
  113. justify-content: center;
  114. cursor: pointer;
  115. span {
  116. font-size: 20px;
  117. margin-right: 5px;
  118. }
  119. }
  120. }
  121. }
  122. }
  123. </style>