| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- <?php
- /**
- * @link:http://www.gdqijianshi.com/
- * @copyright: Copyright (c) 2020 广东七件事集团
- * Created by PhpStorm
- * Author: ganxiaohao
- * Date: 2020-04-24
- * Time: 19:33
- */
- ?>
- <style>
- .com-dialog-dialog {
- min-width: 700px;
- }
- </style>
- <template id="com-dialog-screen-select">
- <div class="com-dialog-screen-select">
- <el-dialog append-to-body :title="title" :visible.sync="visible" :close-on-click-modal="false"
- custom-class="com-dialog-dialog" :before-close="close" @close="close">
- <div>
- <!-- <el-input v-model="keyword" placeholder="根据商品名称或商品ID搜索" @keyup.enter.native="getDetail(1)">
- <el-button slot="append" @click="getDetail(1)">搜索</el-button>
- <el-button type="warning" size="small" @click="clereSearch" v-if="keyword" style="padding: 9px 15px !important;">清除搜索条件</el-button>
- </el-input> -->
- <div class="search-box" style="display:flex;">
- <div class="input-item" style="margin-right:5px;">
- <el-input @keyup.enter.native="getDetail(1)" size="small" placeholder="根据商品名称或商品ID搜索" v-model="keyword"> </el-input>
- </div>
- <el-button type="primary" size="small" @click="getDetail(1)">搜索</el-button>
- <el-button type="warning" size="small" @click="clereSearch" v-if="keyword" style="padding: 9px 15px !important;">重置</el-button>
- </div>
- <slot name="inputslot"></slot>
- <el-table ref="multipleTable" border v-loading="listLoading" :data="list" style="margin-top: 24px;"
- @selection-change="handleSelectionChange">
- <el-table-column type="selection" width="60px" label="ID" props="id" v-if="multiple">
- </el-table-column>
- <el-table-column width="100px" label="ID" props="id" v-else>
- <template slot-scope="props">
- <el-radio-group v-model="radioSelection" @change="handleSelectionChange(props.row)">
- <el-radio :label="props.row.id"></el-radio>
- </el-radio-group>
- </template>
- </el-table-column>
- <el-table-column v-if="multiple" prop="id" label="ID" width="80" align="center"></el-table-column>
- <el-table-column label="商品信息">
- <template slot-scope="props">
- <div style="display: flex;">
- <el-image fit="cover" style="width: 40px;height: 40px;display: block;margin-right: 5px;" :src="props.row.cover_pic"></el-image>
- <div>
- <com-ellipsis :line="2">{{props.row[listKey]}}</com-ellipsis>
- <div style="font-size: 12px;color: red;">¥{{props.row.price}}</div>
- </div>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="库存" width="100" prop="stock"></el-table-column>
- <el-table-column label="商品来源" width="120" prop="goods_source">
- <template slot-scope="props">
- <span v-if="props.row.goods_source">
- <span v-if="props.row.goods_source=='store'">门店商品</span>
- <span v-else-if="props.row.goods_source=='JuheShop'">聚合供应链商品</span>
- <span v-else-if="props.row.goods_source=='QiJuhe'">七件事供应链商品</span>
- <span v-else-if="props.row.goods_source=='StarChain'">怡亚通供应链商品</span>
- <span v-else >供应链商品</span>
- </span>
- <span v-else>本商城商品</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div style="margin-top: 24px;">
- <el-row>
- <el-pagination
- v-if="pagination"
- style="display: inline-block;"
- background
- :page-size="pagination.pageSize"
- @current-change="getDetail"
- layout="prev, pager, next"
- :total="pagination.total_count">
- </el-pagination>
- <el-button type="primary" size="small" style="float: right" @click="confirm">选择</el-button>
- </el-row>
- </div>
- </el-dialog>
- <div @click="click" style="display: inline-block">
- <slot></slot>
- </div>
- </div>
- </template>
- <script>
- Vue.component('com-dialog-screen-select', {
- template: '#com-dialog-screen-select',
- props: {
- /* visible : {
- type: String,
- }, */
- url: {
- type: String,
- default: 'mall/goods/search'
- },
- multiple: Boolean,//是否开启选
- title: {
- type: String,
- default: '商品选择'
- },
- listKey: { //键值
- type: String,
- default: 'goods_name'
- },
- params: Object,
- display: Boolean,
- extraSearch: Object,
- },
- data() {
- return {
- visible: false,
- listLoading: false,
- list: [],
- total_count:1,
- pageSize:20,
- pagination: null,
- radioSelection: 0,
- keyword: null,
- multipleSelection: [],
- select_main_goods_id:''
- }
- },
- methods: {
- close(){
- this.visible=false;
- this.$emit('close');
- },
- click() {
- this.getDetail(1);
- this.visible = !this.visible;
- },
- getDetail(page) {
- this.list = [];
- this.listLoading = true;
- let baseParams = {
- r: this.url,
- keyword: this.keyword,
- page: page
- };
- let params = Object.assign({}, baseParams, this.params);
- request({
- params: params
- }).then(e => {
- this.listLoading = false;
- //console.log("商品的数据=="+JSON.stringify(e))
- if (e.data.code === 0) {
- this.list = e.data.data.list;
- this.pagination = e.data.data.pagination;
- this.pagination.pageSize = e.data.data.page_size;
- this.pagination.total_count = this.pagination.totalCount;
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.listLoading = false;
- });
- },
- chooseAll(){
- this.list.forEach(row => {
- this.$refs.multipleTable.toggleRowSelection(row);
- });
- },
- clear(){
- this.$refs.multipleTable.clearSelection();
- },
- handleSelectionChange(val) {
- this.multipleSelection = val;
- },
- confirm() {
- this.visible = false;
- console.log(this.multipleSelection);
- this.$emit('selected', this.multipleSelection);
- this.$emit('input', this.multipleSelection);
- },
- clereSearch() {
- this.keyword = '';
- this.getDetail(1);
- },
- }
- });
- </script>
|