<template>
  <div>
    <div ref="table">
      <el-form
        ref="queryForm"
        :model="informationqueryParams"
        label-width="80px"
        :inline="true"
      >
        <el-form-item label="服务包名称" prop="packageName" label-width="110">
          <el-input
            v-model="informationqueryParams.packageName"
            placeholder="请输入服务包名称"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="information()"
            >搜索</el-button
          >
          <el-button
            icon="el-icon-refresh"
            size="mini"
            @click="addresetQuerylist"
            >重置</el-button
          >
        </el-form-item>
      </el-form>

      <el-table
        ref="multipleTable"
        v-loading="loading"
        :data="infolist"
        @selection-change="handleSelectionChange"
        :row-key="getRowKey"
        @cell-dblclick="handleRowDbClick"
      >
        <el-table-column
          type="selection"
          width="55"
          align="center"
          :reserve-selection="true"
        />
        <el-table-column label="序号" align="center" type="index" />
        <el-table-column
          label="服务包名称"
          align="center"
          prop="packageName"
          :show-overflow-tooltip="true"
        />
        <el-table-column label="版本号" align="center" prop="packageVersion" />
        <el-table-column
          label="服务期限"
          align="center"
          prop="packageTermAndUnit"
        />
        <el-table-column
          label="服务包简介"
          align="center"
          prop="packageIntroduction"
          :show-overflow-tooltip="true"
        />
        <el-table-column label="备注" align="center" prop="packageRemark" />
        <el-table-column label="是否发布" align="center" prop="whetherRelease">
          <template slot-scope="scope">
            <el-tag type="warning" v-if="scope.row.whetherRelease == '0'"
              >未发布</el-tag
            >
            <el-tag type="success" v-else-if="scope.row.whetherRelease == '1'"
              >已发布</el-tag
            >
          </template>
        </el-table-column>
        <el-table-column
          label="病种名称"
          align="center"
          prop="diseaseTypeName"
        />
      </el-table>
      <div class="bottom">
        <myPagination
          v-show="totaldepartment > 0"
          :total="totaldepartment"
          :pageSize="informationqueryParams.pageSize"
          :indexFromWrap="informationqueryParams.pageNum"
          @updateCPage="updateCPagetwo"
        ></myPagination>
      </div>
    </div>
  </div>
</template>
      <script>
import { getBaseList } from "@/api/system/exportinfo";
export default {
  data() {
    return {
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      infolist: [],
      loading: false,
      datalist: [],
      informationqueryParams: {
        pageNum: 1,
        pageSize: 10,
        type: 'SERVICEPACKAGE',
        hospitalAgencyId: 46,
        packageName: null,
        whetherRelease:null,
        
      },
      totaldepartment: 0,

    }
  },
  watch: {
    datalist(val) {
      this.$emit('submit', val);
    },
  },
  created() {
    this.informationInfoinfo()
  },
  methods: {
    resetTable() {
      this.$refs.multipleTable.clearSelection();
    },
    // 搜索
    information(){
        this.informationqueryParams.whetherRelease='1'
        this.informationInfoinfo()

    },
    // 列表
    informationInfoinfo() {
      getBaseList(this.informationqueryParams).then((response) => {
        this.infolist = response.rows;
        this.totaldepartment = response.total;
        this.loading = false;
      });
    },
    getRowKey(row) {
      return row.id
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      // this.datalist = selection
      this.datalist = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    handleRowDbClick(row, column, event) {// 双击选中该行
      const index = this.datalist.indexOf(row);
      if (index !== -1) {
        this.datalist.splice(index, 1);
      } else {
        this.datalist.push(row);
      }
      // 通过`toggleRowSelection`方法来切换选中状态
      this.$refs.multipleTable.toggleRowSelection(row, index === -1);

    },
    // 重置
    addresetQuerylist() {
      this.informationqueryParams = {
        pageNum: 1,
        pageSize: 10,
        type: 'SERVICEPACKAGE',
        hospitalAgencyId: 46,
      };
      this.informationInfoinfo();
    },
    // 分页
    updateCPagetwo(index, size) {
      this.informationqueryParams.pageNum = index
      this.informationqueryParams.pageSize = size
      this.informationInfoinfo();
    },
  },
  mounted() {

  },

}
      </script>
      
      <style lang="scss" scoped>
.bottom {
  .pagination {
    bottom: 70px !important;
  }
}
</style>