cloud_inventory_goods_select.php 5.1 KB

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