free-goods-choice.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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
  24. :data="list"
  25. v-loading="listLoading"
  26. border
  27. style="width: 100%;margin-top: 10px;"
  28. @selection-change="handleSelectionChange"
  29. >
  30. <el-table-column type="selection" width="60px" label="ID" props="id" v-if="multiple">
  31. </el-table-column>
  32. <el-table-column v-else width="100px" label="ID" align="center">
  33. <template slot-scope="props">
  34. <el-radio-group v-model="selectId" @change="handleSelectionChange(props.row)">
  35. <el-radio :label="props.row.goods_id"></el-radio>
  36. </el-radio-group>
  37. </template>
  38. </el-table-column>
  39. <el-table-column
  40. prop="name"
  41. label="商品名称"
  42. >
  43. <template slot-scope="scope">
  44. <div style="display: flex;align-items: center;">
  45. <img :src="scope.row.cover_pic" style="width: 40px;height: 40px;display: block;margin-right: 5px;" />
  46. <div>{{scope.row.goods_name}}</div>
  47. </div>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <div style="text-align: right;margin: 20px 0;">
  52. <el-pagination
  53. background
  54. @current-change="getDetail"
  55. layout="prev, pager, next"
  56. :page-count="pageCount">
  57. </el-pagination>
  58. </div>
  59. <div style="display: flex;justify-content: center;">
  60. <el-button type="primary" @click="confirm">确定</el-button>
  61. </div>
  62. </el-dialog>
  63. <div @click="click" style="display: inline-block">
  64. <slot></slot>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. Vue.component('free-goods-choice', {
  70. template: '#free-goods-choice',
  71. props: {
  72. url: {
  73. type: String,
  74. default: 'cloud-stock-two/gift-bag/get-cloud-stock-two-goods-list',
  75. },
  76. multiple: Boolean,
  77. title: {
  78. type: String,
  79. default: '商品选择'
  80. },
  81. listKey: {
  82. type: String,
  83. default: 'name'
  84. },
  85. params: Object,
  86. display: Boolean,
  87. extraSearch: Object,
  88. },
  89. data() {
  90. return {
  91. visible: false,
  92. listLoading: false,
  93. list: [],
  94. pagination: null,
  95. radioSelection: 0,
  96. search: {
  97. keyword: ''
  98. },
  99. multipleSelection: [],
  100. selectId:0,
  101. tableData:[],
  102. pageCount:0,
  103. keyword:''
  104. }
  105. },
  106. methods: {
  107. close(){
  108. this.visible=false;
  109. this.$emit('close');
  110. },
  111. click() {
  112. this.getDetail(1);
  113. this.visible = !this.visible;
  114. },
  115. getDetail(page) {
  116. this.list = [];
  117. this.listLoading = true;
  118. request({
  119. params: {
  120. r: this.url,
  121. page: page,
  122. limit:10
  123. },
  124. method: 'get',
  125. }).then(e => {
  126. this.listLoading = false;
  127. if(e.data.code == 0){
  128. this.list = e.data.data.list;
  129. this.pageCount = e.data.data.page_count;
  130. }else{
  131. this.$message.error(e.data.msg);
  132. }
  133. }).catch(e => {
  134. this.listLoading = false;
  135. console.log(e);
  136. });
  137. },
  138. handleSelectionChange(val) {
  139. this.multipleSelection = val;
  140. },
  141. confirm() {
  142. this.visible = false;
  143. this.$emit('selected', this.multipleSelection);
  144. this.$emit('input', this.multipleSelection);
  145. },
  146. currentChange(){
  147. }
  148. }
  149. });
  150. </script>