free-goods-choice.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. /**
  3. * @link:http://www.goodmall.com/
  4. * @copyright: Copyright (c) 2020
  5. * Created by PhpStorm
  6. * Author: ganxiaohao
  7. * Date: 2020-04-24
  8. * Time: 19:33
  9. */
  10. ?>
  11. <style>
  12. .com-dialog-dialog {
  13. min-width: 700px;
  14. }
  15. </style>
  16. <template id="free-goods-choice">
  17. <div class="com-dialog-select">
  18. <el-dialog append-to-body :title="title" :visible.sync="visible" :close-on-click-modal="false"
  19. custom-class="com-dialog-dialog" :before-close="close" @close="close" center>
  20. <div style="display: flex;justify-content: center;">
  21. <el-tag type="danger">下列商品为云库存商品</el-tag>
  22. </div>
  23. <el-table :data="list" v-loading="listLoading" border style="width: 100%;margin-top: 10px;" @selection-change="handleSelectionChange">
  24. <el-table-column type="selection" width="60px" label="ID" props="id" v-if="multiple"></el-table-column>
  25. <el-table-column width="100px" label="商品id" props="id" v-else>
  26. <template slot-scope="props">
  27. <el-radio-group v-model="radioSelection" @change="handleSelectionChange(props.row)">
  28. <el-radio :label="props.row.goods_id"></el-radio>
  29. </el-radio-group>
  30. </template>
  31. </el-table-column>
  32. <el-table-column v-if="multiple" prop="goods_id" label="商品id" width="80" align="center"></el-table-column>
  33. <el-table-column
  34. prop="name"
  35. label="商品名称"
  36. >
  37. <template slot-scope="scope">
  38. <div style="display: flex;align-items: center;">
  39. <img :src="scope.row.cover_pic" style="width: 40px;height: 40px;display: block;margin-right: 5px;" />
  40. <div>{{scope.row.goods_name}}</div>
  41. </div>
  42. </template>
  43. </el-table-column>
  44. </el-table>
  45. <div style="text-align: right;margin: 20px 0;">
  46. <el-pagination
  47. background
  48. @current-change="getDetail"
  49. layout="prev, pager, next"
  50. :page-count="pageCount">
  51. </el-pagination>
  52. </div>
  53. <div style="display: flex;justify-content: center;">
  54. <el-button type="primary" @click="confirm">确定</el-button>
  55. </div>
  56. </el-dialog>
  57. <div @click="click" style="display: inline-block">
  58. <slot></slot>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. Vue.component('free-goods-choice', {
  64. template: '#free-goods-choice',
  65. props: {
  66. url: {
  67. type: String,
  68. default: 'cloud-stock/gift-bag/get-cloud-stock-goods-list',
  69. },
  70. multiple: Boolean,
  71. title: {
  72. type: String,
  73. default: '商品选择'
  74. },
  75. listKey: {
  76. type: String,
  77. default: 'name'
  78. },
  79. params: Object,
  80. display: Boolean,
  81. extraSearch: Object,
  82. },
  83. data() {
  84. return {
  85. visible: false,
  86. listLoading: false,
  87. list: [],
  88. pagination: null,
  89. radioSelection: 0,
  90. search: {
  91. keyword: ''
  92. },
  93. multipleSelection: [],
  94. selectId:0,
  95. tableData:[],
  96. pageCount:0,
  97. keyword:''
  98. }
  99. },
  100. methods: {
  101. close(){
  102. this.visible=false;
  103. this.$emit('close');
  104. },
  105. click() {
  106. this.getDetail(1);
  107. this.visible = !this.visible;
  108. },
  109. getDetail(page) {
  110. this.list = [];
  111. this.listLoading = true;
  112. request({
  113. params: {
  114. r: this.url,
  115. page: page,
  116. limit:10
  117. },
  118. method: 'get',
  119. }).then(e => {
  120. this.listLoading = false;
  121. if(e.data.code == 0){
  122. this.list = e.data.data.list;
  123. this.pageCount = e.data.data.page_count;
  124. }else{
  125. this.$message.error(e.data.msg);
  126. }
  127. }).catch(e => {
  128. this.listLoading = false;
  129. console.log(e);
  130. });
  131. },
  132. handleSelectionChange(val) {
  133. this.multipleSelection = val;
  134. },
  135. confirm() {
  136. this.visible = false;
  137. this.$emit('selected', this.multipleSelection);
  138. this.$emit('input', this.multipleSelection);
  139. },
  140. currentChange(){
  141. }
  142. }
  143. });
  144. </script>