<template><!--发药明细详情-->
  <el-dialog
    title="详情"
    :visible.sync="visibility"
    :close-on-click-modal="isClose"
    :close-on-press-escape="isClose"
  >
<!--    <el-button type="primary" @click="print" class="print_style">详情</el-button>-->
<!--    <el-button  @click="lili" >调试</el-button>-->
    <div id="dialysis-print-box-1" class="dialysis-print-box-1">
      <!-- <div class="list_title">
        <div>药品名称：</div>
        <div>规格：</div>
        <div>发药状态：</div>
        <div v-if="state==2">领药人：</div>
      </div> -->
      <el-table
                style="width: 1020px; margin: 0 auto"
                :data="list"
                border
                max-height="450"
                :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
              >
                <el-table-column prop="Drugname" label="名称" width="160" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.Drugname  ? scope.row.Drugname  : ""}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="SingleDosage" label="单次用量" width="100" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.SingleDosage  ? scope.row.SingleDosage  : ""}}</span>
                  </template>
               </el-table-column>
                <el-table-column prop="Usage" label="用法" width="120" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.Usage  ? scope.row.Usage  : ""}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="Frequency" label="频率" width="120" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.Frequency  ? scope.row.Frequency  : ""}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="Days" label="天数" width="120" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.Days  ? scope.row.Days  : ""}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="Total" label="总量" width="90" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.Total  ? scope.row.Total  : ""}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="UnitPrice" label="单价" width="100" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.UnitPrice  ? scope.row.UnitPrice  : ""}}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="Remarks" label="备注" width="120" align="center">
                  <template slot-scope="scope">
                    <span>{{scope.row.Remarks  ? scope.row.Remarks  : ""}}</span>
                  </template>
                </el-table-column>
              </el-table>
<!--        <el-tab-pane label="病历详情" name="second">病历详情</el-tab-pane>-->
    </div>
  </el-dialog>
</template>
<script>
import Vue from "vue";
import print from "print-js";
import printutils from "./print.js";
import {
  prescriptiondetails
} from "@/api/pharmacy"

export default {
  data() {
    return {
      visibility: false,
      tableData: [{}],
      isClose: false,
      activeName: "first",
      editableTabsValue: "2",
      editableTabs: [],//名字
      // dialysisTabs: [],//名字
      dialysisName:"",
      tabIndex: 2,
      list:[],
    };
  },
  props: {
    propForm: {
      type: Object,
    },

    state: {
      type: Number,
    },
  },

  methods: {
    hide: function () {
      this.visibility = false;
      for (let i = 0; i < this.propForm.goods.length; i++) {
        for (let key in this.propForm.goods[i]) {
          if (key != "index") {
            this.propForm.goods[i][key].isSelected = false;
          }
        }
      }
    },
    init(){
      console.log("初始化中。。。。。。。。。。")
      this.dialysisName = "";
      this.list = [];
      this.editableTabs = [];
    },
    show: function () {
      this.visibility = true;
      console.log("this.visibility",this.visibility)
      this.init();
    },
    lili(){
      console.log("this.list",this.list)
      let v = [];
      //key
      for (let k in this.list){
        v.push(k);
        console.log("k",k)
        console.log("v",this.list[k])
        console.log("editableTabs",this.editableTabs)
        for(let i = 0;i < this.list[k].length;i++){
          this.editableTabs.push(this.list[k][i])
        }
      }

    },
    //发药明细详情
    drugdetails(data){
      console.log("aaaaaaaaaaaaa")
      var params = {
        patient_id: data.PatientID,
        record_date: data.RecordTime,
      }
      prescriptiondetails(params).then((res) => {
        if (res.data.state == 1){
            this.list = res.data.data.list;
            this.lili();
        }else{
          this.$message.error(res.data.msg);
        }
      })

    },

    comfirm: function (formName) {
      this.goodInfo = [];
      this.goodInfoTableData = [];
      this.$emit("dialog-comfirm", this.getValue());
      this.$refs.multipleTable.clearSelection();
      this.$refs.table.setCurrentRow(null);
    },
    getValue() {},

    handleClick(tab, event) {
      console.log(tab, event);
    },
    // 打印
    print() {
      Vue.prototype.printJson = printutils.printJson;
      this.printJson({
        // title: ``, // 打印出来的标题
        data: this.list, // 需要打印的数据
        serial: false, // 是否需要打印序列号
        fields: [
          // 需要打印的字段

          "Drugname",
          "SingleDosage",
          "Usage",
          "Frequency",
          "Days",
          "Total",
          "UnitPrice",
          "Remarks",
        ],
        properties: [
          // 需要打印的字段对应的表头名

          {
            field: "Drugname",
            displayName: "名称",
          },
          {
            field: "SingleDosage",
            displayName: "单次用量",
          },
          {
            field: "Usage",
            displayName: "用法",
          },
          {
            field: "Frequency",
            displayName: "频率",
          },
          {
            field: "Days",
            displayName: "天数",
          },
          {
            field: "Total",
            displayName: "总量",
          },
          {
            field: "UnitPrice",
            displayName: "单价",
          },

          {
            field: "Remarks",
            displayName: "备注",
          },
        ],
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.print_style {
  position: absolute;
  right: 10px;
  top: 42px;
}

.list_title {
  width: 940px;
  border-bottom: 1px solid;
  display: flex;
  margin: 30px auto;

  div {
    width: 230px;
    padding: 10px 0;
  }
}
</style>
