<template>
  <div class="product-select" >
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
      <el-form-item label="商品名称" prop="productName">
        <el-input
          style="width:200px"
          v-model="queryParams.productName"
          placeholder="请输入商品名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      </el-form-item>
    </el-form>
    <el-table border v-loading="loading" :data="list">
      <el-table-column label="商品编号" align="center" prop="barCode" />
      <el-table-column label="商品图片" align="center" width="100">
        <template slot-scope="scope">
          <el-popover
            placement="right"
            title=""
            trigger="hover"
          >
            <img slot="reference" :src="scope.row.image" width="80">
            <img :src="scope.row.image" style="max-width: 80px;">
          </el-popover>
        </template>
      </el-table-column>
      <el-table-column label="商品名称" show-overflow-tooltip align="center" prop="productName" />
      <el-table-column label="店铺名称" show-overflow-tooltip align="center" prop="storeName" />
      <el-table-column label="包装规格" align="center" prop="prescribeSpec" />
      <el-table-column label="商品规格" align="center" prop="sku" />
      <el-table-column label="库存" align="center" prop="stock" />
      <el-table-column label="单价" align="center" prop="price" />
      <el-table-column label="成本价" align="center" prop="costPrice" />
      <el-table-column label="操作" align="center" width="100px" >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleSelect(scope.row)"
          >选择</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      style="padding-bottom:10px;"
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { getStoreProductAttrValueList,listStore } from "@/api/his/storeProduct";
export default {
  name: "selectProduct",
  data() {
    return {
      loading: true,
      list:[],
      total: 0,
      queryParams: {
        productName:"",
        pageNum: 1,
        pageSize: 10,
        isPackage:0,
        storeId:null,
      }
    };
  },
  created() {

  },
  methods: {
    getData(isPackage){
      this.queryParams.isPackage=isPackage;
      this.getList();

    },
    handleSelect(row){
      this.$emit('selectProduct',row);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    getDetails(storeId){
      this.queryParams.storeId=storeId;
      this.getList();
    },
    getList(){
      this.loading = true;
      getStoreProductAttrValueList(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    }
  }
};
</script>
<style scoped>

.product-select{
  padding-bottom: 15px;
}
</style>
