<template>


  <div>

    <el-card style="margin-top: -20px">
      <div style="float: right;margin-bottom: 10px;margin-right: 25px">
        <el-button type="primary" size="small" @click="selectSet()">选入</el-button>
      </div>

      <el-table v-loading="loading" :data="list" style="width: 100%"   border highlight-current-row @selection-change="handleCheckedChange">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column label="序号" type="index"></el-table-column>
        <el-table-column
          label="产品通用名称"
          prop="coName"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="规格型号"
          prop="spec"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="批次号"
          prop="batchNo"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="生产日期"
          prop="productDate"
        ></el-table-column>
        <el-table-column
          label="失效日期"
          prop="expireDate"
        ></el-table-column>
        <el-table-column
          label="单据数量"
          prop="reCount"
        ></el-table-column>
        <el-table-column
          label="价格"
          prop="price"
        ></el-table-column>
        <el-table-column
          label="生产厂家"
          prop="manufacturer"
          show-overflow-tooltip
        ></el-table-column>
        <el-table-column
          label="注册/备案凭证号"
          prop="certCode"
          show-overflow-tooltip
        ></el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="bizQuery.page"
        :limit.sync="bizQuery.limit"
        @pagination="handleCurrentChange"

      ></pagination>
    </el-card>

  </div>

</template>

<script>

import {filterCertSet, selectAllCert} from "@/api/purchase/supCertSet";
import {getResultDetailList} from "@/api/inout/orderDetailResult";
import {insertInvoice} from '@/api/inout/orderDetailBiz'


export default {
  name: "invoiceRegister",

  props: {
    closeInvoice: {
      type: Function,
      required: true,
    },

    inputQueryId: {
      type: Object,
      required: true,
    },


  },

  data() {
    return {
      bizQuery: {
        productName: null,
        orderIdFk: null,
        page: 1,
        limit: 10
      },
      multipleSelection: [],
      list: [],
      total: 0,
      loading: false,
    };
  },
  methods: {
    handleCheckedChange(val) {
      this.multipleSelection = val;
    },
    handleCurrentChange(val) {
      this.query.page = val.page;
      this.getList();
    },

    getList() {
      this.loading = true;
      this.bizQuery.orderIdFk=this.inputQueryId;
      getResultDetailList(this.bizQuery)
        .then(response => {
          this.loading = false;
          this.list = response.data.list || [];
          this.total = response.data.total || 0;
        })
        .catch(() => {
          this.loading = false;
          this.list = [];
          this.total = 0;
        });
    },


    selectSet() {
      var a=JSON.parse(JSON.stringify(this.multipleSelection))
      insertInvoice(a)
        .then(response => {
          if (response.code === 20000) {
            this.closeInvoice();
          } else {
            this.$message.error(response.message);
          }
        })
        .catch(() => {
          this.$message.error(response.message);
        });
    },
  },

  filters: {},
  mounted() {
    document.body.ondrop = function (event) {
      event.preventDefault();
      event.stopPropagation();
    };
  },
  created() {
    this.getList();
  },
}
</script>

<style scoped>

</style>
