<template>
  <div>
    <el-form :model="filterQuery" label-width="90px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="产品编码:">
            <el-input v-model="filterQuery.unionCode" style="width: 100%" placeholder="请输入DI/医保编码/商品条码"
                      clearable="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="产品通用名:">
            <el-input v-model="filterQuery.cpmctymc" style="width: 100%" placeholder="请输入产品通用名"
                      clearable="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label="规格型号:">
            <el-input v-model="filterQuery.ggxh" style="width: 100%" placeholder="请输入规格型号"
                      clearable="true"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-button-group>
            <el-button type="primary" icon="el-icon-search" @click="getList">查询</el-button>
            <el-button type="primary" icon="el-icon-refresh" @click="getList">更新处方信息</el-button>
          </el-button-group>

        </el-col>
      </el-row>
    </el-form>


    <el-table :data="list" style="width: 100%" border
              max-height="350" height="350"
              highlight-current-row>
      <el-table-column label="序号" type="index"></el-table-column>
      <el-table-column label="处方编码" prop="prescribeCode" width="140" show-overflow-tooltip></el-table-column>
      <el-table-column label="DI标识" prop="diCode" width="140" show-overflow-tooltip></el-table-column>
      <el-table-column label="产品通用名" prop="thrName" width="160" show-overflow-tooltip></el-table-column>
      <el-table-column label="规格型号" prop="ggxh" width="140" show-overflow-tooltip></el-table-column>
      <el-table-column label="计量单位" prop="measureUnit" width="100" show-overflow-tooltip></el-table-column>
      <el-table-column label="数量" header-align="center">
        <el-table-column label="处方数量" prop="measureCount" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="扫码数量" prop="realCount" width="100" show-overflow-tooltip></el-table-column>
      </el-table-column>
      <el-table-column label="价格" header-align="center">
        <el-table-column label="处方金额" prop="amount" width="100" show-overflow-tooltip></el-table-column>
        <el-table-column label="实际金额" prop="realPrice" width="100" show-overflow-tooltip></el-table-column>
      </el-table-column>

      <el-table-column label="注册/备案凭证" prop="zczbhhzbapzbh" width="160" show-overflow-tooltip></el-table-column>
      <el-table-column label="生产企业" prop="manufactory" width="160" show-overflow-tooltip></el-table-column>
      <el-table-column width="60" label="操作" fixed="right">
        <template slot-scope="scope">
          <el-button type="text" @click.native.stop="handleModifyClick(scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>


  </div>
</template>

<script>
import {dlOrFilter, skPrescribeCheck, skPrescribeDi} from "@/api/basic/sicker/skPersonApi";

export default {
  name: "skPrescribeDi",
  props: {
    perscribeData: {
      type: Object,
      required: true,
    },
    sickerAdNum: {
      type: Object,
      required: true,
    },

  },

  data() {
    return {
      filterQuery: {
        cpmctymc: null,
        unionCode: null,
        billNo: null,
        adNum: null,
        page: 1,
        limit: 10,
        ggxh: null,
      },
      total: 0,
      loading: false,
      list: [],
      showSearch: true,
    }
  },
  methods: {
    getList() {
      this.loading = true;
      this.filterQuery.adNum = this.sickerAdNum;
      this.filterQuery.billNo = this.perscribeData.billNo;
      skPrescribeCheck(this.filterQuery)
        .then((response) => {
          this.loading = false;
          this.list = response.data || [];
          // this.total = response.data.total || 0;
        })
        .catch(() => {
          this.loading = false;
          // this.list = [];
          // this.total = 0;
        });
    },

    dlList(sickerAdNum) {
      this.loading = true;
      this.filterQuery.adNum = sickerAdNum;
      dlOrFilter(this.filterQuery)
        .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;
        });
    },

    hideSearch() {
      this.showSearch = !this.showSearch;
    },

    onReset() {
      this.$router.push({
        path: "",
      });
      this.filterQuery = {
        page: 1,
        limit: 10,
      };
      this.getList();
    },
  },
  created() {
    this.getList();
  },
  watch: {
    sickerAdNum: function (val) {
      this.dlList(val);
    }
  },

}
</script>

<style scoped>

</style>
