| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <?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-select-store">
- <div class="com-dialog-select-store">
- <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-input>
- <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="cost_price"></el-table-column>
- <el-table-column label="库存" width="100" prop="stock"></el-table-column>
- <el-table-column v-if="is_show_store_name" label="所属门店" width="100" prop="store_name"></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-select-store', {
- template: '#com-dialog-select-store',
- props: {
- /* visible : {
- type: String,
- }, */
- url: {
- type: String,
- default: 'store/store-goods/search'
- },
- multiple: Boolean,//是否开启选
- title: {
- type: String,
- default: '商品选择'
- },
- listKey: { //键值
- type: String,
- default: 'goods_name'
- },
- params: Object,
- display: Boolean,
- extraSearch: Object,
- is_show_store_name: {
- type: Boolean,
- default: false,
- },//是否显示门店,
- },
- data() {
- return {
- visible: false,
- listLoading: false,
- list: [],
- total_count:1,
- pageSize:20,
- pagination: null,
- radioSelection: 0,
- keyword: null,
- multipleSelection: []
- }
- },
- methods: {
- close(){
- this.visible=false;
- this.$emit('close');
- },
- click() {
- this.getDetail(1);
- this.visible = !this.visible;
- },
- getDetail(page) {
- this.list = [];
- this.listLoading = true;
- let params = Object.assign({
- r: this.url,
- keyword: this.keyword,
- page: page
- }, 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;
- this.$emit('selected', this.multipleSelection);
- this.$emit('input', this.multipleSelection);
- }
- }
- });
- </script>
|