com-dialog-select-goods.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <?php
  2. /**
  3. * @link:http://www.gdqijianshi.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: 1200px;
  14. }
  15. </style>
  16. <template id="com-dialog-screen-select">
  17. <div class="com-dialog-screen-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">
  20. <div>
  21. <div class="search-box" style="display:flex;">
  22. <div class="input-item" style="margin-right:5px;">
  23. <el-input @keyup.enter.native="getDetail(1)" size="small" placeholder="根据商品名称或商品ID搜索" v-model="keyword"> </el-input>
  24. </div>
  25. <el-button type="primary" size="small" @click="getDetail(1)">搜索</el-button>
  26. <el-button type="warning" size="small" @click="clereSearch" v-if="keyword" style="padding: 9px 15px !important;">重置</el-button>
  27. </div>
  28. <slot name="inputslot"></slot>
  29. <el-tabs v-model="activeName" @tab-click="handleClick">
  30. <el-tab-pane v-for="item in tabs" :key="item.id" :label="item.name"
  31. :name="item.id">
  32. </el-tab-pane>
  33. </el-tabs>
  34. <el-table ref="multipleTable" border v-loading="listLoading" :data="list" style="margin-top: 24px;"
  35. @selection-change="handleSelectionChange" multipe>
  36. <el-table-column type="selection" width="60px" label="ID" props="id" v-if="multiple">
  37. </el-table-column>
  38. <el-table-column width="100px" label="ID" props="id" v-else>
  39. <template slot-scope="props">
  40. <el-radio-group v-model="radioSelection" @change="handleSelectionChange(props.row)">
  41. <el-radio :label="props.row.id"></el-radio>
  42. </el-radio-group>
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="分类" align="center" width="200">
  46. <template slot-scope="scope">
  47. <div class="goods-cat">
  48. <el-tag v-if="scope.row.cats && scope.row.cats.length > 0" size="mini">
  49. {{scope.row.cats[0].name}}
  50. </el-tag>
  51. <el-tooltip v-if="scope.row.cats && scope.row.cats.length > 1" placement="top">
  52. <div slot="content">
  53. <span v-for="item in scope.row.cats" :key="item.id">{{item.name}}&nbsp;</span>
  54. </div>
  55. <span>...</span>
  56. </el-tooltip>
  57. </div>
  58. </template>
  59. </el-table-column>
  60. <el-table-column v-if="multiple" prop="id" label="ID" width="80" align="center"></el-table-column>
  61. <el-table-column label="商品信息">
  62. <template slot-scope="props">
  63. <div style="display: flex;">
  64. <el-image fit="cover" style="width: 40px;height: 40px;display: block;margin-right: 5px;" :src="props.row.cover_pic"></el-image>
  65. <div>
  66. <div style="overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;">
  67. {{props.row[listKey]}}
  68. </div>
  69. <div style="font-size: 12px;color: red;">¥{{props.row.price}}</div>
  70. </div>
  71. </div>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="库存" width="100" prop="stock"></el-table-column>
  75. <el-table-column label="最高盈利" width="100" prop="max_income"></el-table-column>
  76. <el-table-column label="最低提货数量" width="120" prop="min_num"></el-table-column>
  77. <!-- <el-table-column label="商品来源" width="120" prop="goods_source">-->
  78. <!-- <template slot-scope="props">-->
  79. <!-- <span v-if="props.row.goods_source">-->
  80. <!-- <span v-if="props.row.goods_source=='store'">门店商品</span>-->
  81. <!-- <span v-else-if="props.row.goods_source=='JuheShop'">聚合供应链商品</span>-->
  82. <!-- <span v-else-if="props.row.goods_source=='QiJuhe'">七件事供应链商品</span>-->
  83. <!-- <span v-else-if="props.row.goods_source=='StarChain'">怡亚通供应链商品</span>-->
  84. <!-- <span v-else >供应链商品</span>-->
  85. <!-- </span>-->
  86. <!-- <span v-else>本商城商品</span>-->
  87. <!-- </template>-->
  88. <!-- </el-table-column>-->
  89. </el-table>
  90. </div>
  91. <div style="margin-top: 24px;">
  92. <el-row>
  93. <el-pagination
  94. v-if="pagination"
  95. style="display: inline-block;"
  96. background
  97. :page-size="pagination.pageSize"
  98. @current-change="getDetail"
  99. layout="prev, pager, next"
  100. :total="pagination.total_count">
  101. </el-pagination>
  102. <el-button type="primary" size="small" style="float: right" @click="confirm">选择</el-button>
  103. </el-row>
  104. </div>
  105. </el-dialog>
  106. <div @click="click" style="display: inline-block">
  107. <slot></slot>
  108. </div>
  109. </div>
  110. </template>
  111. <script>
  112. Vue.component('com-dialog-screen-select', {
  113. template: '#com-dialog-screen-select',
  114. props: {
  115. /* visible : {
  116. type: String,
  117. }, */
  118. url: {
  119. type: String,
  120. default: 'mall/goods/search'
  121. },
  122. multiple: Boolean,//是否开启选
  123. title: {
  124. type: String,
  125. default: '商品选择'
  126. },
  127. listKey: { //键值
  128. type: String,
  129. default: 'goods_name'
  130. },
  131. params: Object,
  132. display: Boolean,
  133. extraSearch: Object,
  134. },
  135. data() {
  136. return {
  137. activeName:'0',
  138. visible: false,
  139. listLoading: false,
  140. list: [],
  141. total_count:1,
  142. pageSize:20,
  143. pagination: null,
  144. radioSelection: 0,
  145. keyword: null,
  146. multipleSelection: [],
  147. select_main_goods_id:'',
  148. tabs: [
  149. {
  150. name: '全部',
  151. id: '0',
  152. },
  153. ],
  154. }
  155. },
  156. methods: {
  157. handleClick(){
  158. this.getDetail(1)
  159. },
  160. close(){
  161. this.visible=false;
  162. this.$emit('close');
  163. },
  164. click() {
  165. this.getDetail(1);
  166. this.visible = !this.visible;
  167. },
  168. getDetail(page) {
  169. this.list = [];
  170. let self = this;
  171. this.listLoading = true;
  172. let baseParams = {
  173. r: this.url,
  174. keyword: this.keyword,
  175. label_id: this.activeName,
  176. page: page
  177. };
  178. let params = Object.assign({}, baseParams, this.params);
  179. request({
  180. params: params
  181. }).then(e => {
  182. this.listLoading = false;
  183. if (e.data.code === 0) {
  184. this.list = e.data.data.list;
  185. this.pagination = e.data.data.pagination;
  186. this.pagination.pageSize = e.data.data.page_size;
  187. this.pagination.total_count = this.pagination.totalCount;
  188. if(self.tabs.length==1)
  189. {
  190. self.tabs=self.tabs.concat(e.data.data.goods_label)
  191. }
  192. } else {
  193. this.$message.error(e.data.msg);
  194. }
  195. }).catch(e => {
  196. this.listLoading = false;
  197. });
  198. },
  199. chooseAll(){
  200. this.list.forEach(row => {
  201. this.$refs.multipleTable.toggleRowSelection(row);
  202. });
  203. },
  204. clear(){
  205. this.$refs.multipleTable.clearSelection();
  206. },
  207. handleSelectionChange(val) {
  208. this.multipleSelection = val;
  209. },
  210. confirm() {
  211. this.visible = false;
  212. console.log(this.multipleSelection);
  213. this.$emit('selected', this.multipleSelection);
  214. this.$emit('input', this.multipleSelection);
  215. },
  216. clereSearch() {
  217. this.keyword = '';
  218. this.getDetail(1);
  219. },
  220. }
  221. });
  222. </script>