﻿<template>
  <div class="product-select" >
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="90px">
      <el-form-item label="商品名称" prop="productName">
        <el-input
          style="width:200px"
          v-model="queryParams.packageName"
          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 height="600" v-loading="loading" border :data="list" >
      <el-table-column label="ID" align="center" prop="packageId" />
      <el-table-column label="套餐包名称" align="center" prop="packageName" />
      <el-table-column label="疗法图片" align="center" prop="imgUrl">
        <template slot-scope="scope">
            <img :src="scope.row.imgUrl" style="height: 80px;">
        </template>
      </el-table-column>
      <el-table-column label="别名" align="center" prop="secondName" />
      <el-table-column label="类型" align="center" prop="packageType">
        <template slot-scope="scope">
          <dict-tag :options="packageTypeOptions" :value="scope.row.packageType"/>
        </template>
      </el-table-column>
      <el-table-column label="子类型" align="center" prop="packageSubType">
        <template slot-scope="scope">
          <dict-tag :options="packageSubTypeOptions" :value="scope.row.packageSubType"/>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <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 { listPackage } from "@/api/his/package";
import { listPackage } from '../../../api/his/package'

export default {
  name: "selectPackage",
  data() {
    return {
      loading: true,
      list:[],
      packageTypeOptions:[],
      packageSubTypeOptions:[],
      total: 0,
      queryParams: {
        packageName:"",
        secondName:"",
        status:1,
        isShow:1,
        pageNum: 1,
        pageSize: 10,
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("sys_package_type").then(response => {
      this.packageTypeOptions = response.data;
    });
    this.getDicts("sys_package_sub_type").then(response => {
      this.packageSubTypeOptions = response.data;
    });
  },
  methods: {
    handleSelect(row){
      this.$emit('selectPackage',row);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    getDetails(){
      this.getList();
    },
    getList(){
      this.loading = true;
      listPackage(this.queryParams).then(response => {
        this.list = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    }
  }
};
</script>
<style scoped>

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