<template>
  <div id="allList-print" class="allList-print">
    <table
      class="allListTable"
      border="0"
      cellspacing="0"
      style="font-size: 14px"
      align="center"
    >
      <THEAD
        style="
          display: table-header-group;
          font-weight: bold;
        "
      >
        <TR style="border-bottom: 1px solid">
          <TD colspan="4" align="center" style="font-size: 20px">
            {{ $store.getters.xt_user.org.org_name }}汇总清单
          </TD>
        </TR>
        <TR>
          <TD colspan="1">科别：门诊</TD>
          <TD width="130">床号：</TD>
          <TD>门诊号：{{ order.mdtrt_id }}</TD>
          <TD>姓名：{{ patient.name }}</TD>
        </TR>
        <TR style="border-bottom: 1px solid">
          <TD colspan="2"> 预交款：</TD>
          <TD>总费用：{{ order.medfee_sumamt }} </TD>
          <TD
            >门诊日期：{{
              hospital.in_hosptial_time
                ? hospital.in_hosptial_time.split(" ")[0]
                : ""
            }}</TD
          >
        </TR>
        <TR>
          <TD colspan="2">
            西药:&nbsp;&nbsp;&nbsp;{{
              order.westernMedicineCostTotal
                ? order.westernMedicineCostTotal.toFixed(2)
                : ""
            }}</TD
          >
          <TD
            >中成药:{{
              order.chineseTraditionalMedicineCostTotal
                ? order.chineseTraditionalMedicineCostTotal.toFixed(2)
                : ""
            }}</TD
          >
          <TD>中草药:</TD>
        </TR>
        <TR>
          <TD colspan="2">
            检查费:{{
              order.checkCostTotal ? order.checkCostTotal.toFixed(2) : ""
            }}</TD
          >
          <TD>输氧费:</TD>
          <TD
            >手术费:{{
              order.operationCostTotal
                ? order.operationCostTotal.toFixed(2)
                : ""
            }}</TD
          >
        </TR>
        <TR>
          <TD colspan="2"
            >化验费:{{
              order.laboratoryCostTotal
                ? order.laboratoryCostTotal.toFixed(2)
                : ""
            }}</TD
          >
          <TD>输血费:</TD>
          <TD
            >诊察费:{{
              order.zhenChaCostTotal ? order.zhenChaCostTotal.toFixed(2) : ""
            }}</TD
          >
        </TR>
        <TR>
          <TD colspan="2"
            >治疗费:{{
              order.treatCostTotal ? order.treatCostTotal.toFixed(2) : ""
            }}</TD
          >
          <TD>护理费:</TD>
          <TD
            >床位费:{{
              order.bedCostTotal ? order.bedCostTotal.toFixed(2) : ""
            }}</TD
          >
        </TR>
        <TR>
          <TD colspan="2">麻醉费:</TD>
          <TD
            >材料费:{{
              order.materialCostTotal ? order.materialCostTotal.toFixed(2) : ""
            }}</TD
          >
          <TD
            >其他:{{
              order.otherCostTotal ? order.otherCostTotal.toFixed(2) : ""
            }}</TD
          >
        </TR>
      </THEAD>

      <TBODY style="text-align: center">
        <TR>
          <TD colspan="4">
            <Table class="allListTable_1" border="1">
              <TR>
                <TH width="70"> 费用类别 </TH>
                <TH width="70"> 项目名称 </TH>
                <TH width="70">单位</TH>
                <TH width="70">数量</TH>
                <TH width="70">单价</TH>
                <TH width="70">金额</TH>
                <TH width="70">医保类型</TH>
              </TR>
              <template v-for="(item, index) in list">
                <tr v-if="item.is_total == 2">
                  <td style="width: 10%">{{ item.med_chrgitm_type }}</td>
                  <td
                    style="
                      width: 35%;
                      white-space: nowrap;
                      overflow: hidden;
                      text-overflow: ellipsis;
                    "
                  >
                    {{ item.name }}{{ item.spec }}
                  </td>
                  <td style="width: 5%">{{ item.unit }}</td>
                  <td style="width: 10%; text-align: right">
                    {{ item.count }}
                  </td>
                  <td style="width: 10%; text-align: right">
                    {{ item.price.toFixed(4) }}
                  </td>
                  <td style="width: 10%; text-align: right">
                    {{ (item.price * item.count).toFixed(2) }}
                  </td>
                  <td style="width: 10%">{{ item.medicine_insurance_kind }}</td>
                </tr>
                <tr v-if="item.is_total == 1">
                  <td style="width: 10%"></td>
                  <td
                    style="
                      width: 35%;
                      white-space: nowrap;
                      overflow: hidden;
                      text-overflow: ellipsis;
                    "
                  >
                    合计
                  </td>
                  <td style="width: 5%"></td>
                  <td style="width: 10%; text-align: right"></td>
                  <td style="width: 10%; text-align: right"></td>
                  <td style="width: 10%; text-align: right">
                    {{ item.total }}
                  </td>
                  <td style="width: 10%"></td>
                </tr>
              </template>
            </Table>
          </TD>
        </TR>
      </TBODY>
    </table>
  </div>
</template>

<script>
import { uParseTime } from "@/utils/tools";

export default {
  props: {
    list: {
      type: Array,
      default: function () {
        return [];
      },
    },
    patient: {
      type: Object,
      default: function () {
        return {};
      },
    },
    order: {
      type: Object,
      default: function () {
        return {};
      },
    },
    admin: {
      type: Object,
      default: function () {
        return {};
      },
    },
    hospital: {
      type: Object,
      default: function () {
        return {};
      },
    },
  },
  data() {
    return {
      page: 1,
      pageArr: [],
    };
  },
  methods: {
    getNowTime: function () {
      let dateTime;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf =
        new Date().getMinutes() < 10
          ? "0" + new Date().getMinutes()
          : new Date().getMinutes();
      let ss =
        new Date().getSeconds() < 10
          ? "0" + new Date().getSeconds()
          : new Date().getSeconds();
      dateTime = yy + "-" + mm + "-" + dd + " " + hh + ":" + mf + ":" + ss;
      return dateTime;
    },
    getTimes(time) {
      return uParseTime(time, "{y}-{m}-{d}");
    },
    getTotal: function (items) {
      let total = 0;
      for (let i = 0; i < items.length; i++) {
        total = total + (items[i].count * items[i].price).toFixed(2);
      }
      return total;
    },
  },
  watch: {
    list: {
      handler(newVal) {
        this.getPage();
      },
      deep: true,
    },
  },
};
</script>

<style lang="scss" scoped>
.allList-print {
  -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27),
    0 0 60px rgba(0, 0, 0, 0.06) inset;
  -moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27),
    0 0 40px rgba(0, 0, 0, 0.06) inset;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.27), 0 0 40px rgba(0, 0, 0, 0.06) inset;
  margin-bottom: 20px;
  padding: 20px 10px;
}

.allListTitle {
  font-size: 24px;
  text-align: center;
  font-weight: bold;
  margin-bottom: 10px;
}

.allListInfo {
  display: flex;
  font-size: 16px;
  justify-content: space-between;
  margin: 10px 0;
}

.allListInfo div {
  min-width: 200px;
}

.allListTable {
  width: 100%;
  text-align: center;
  border-collapse: collapse;
  line-height: 20px;
  font-size: 14px;
  border-color: #000;
  text-align: left;
}

.allListTable tr td {
  padding: 0 5px;
}

.allListTable_1 {
  width: 100%;
  text-align: center;
  border-collapse: collapse;
  line-height: 20px;
  font-size: 14px;
  border-color: #000;
  text-align: left;
}

.allListTable_1 tr td {
  padding: 0 5px;
}

.tableBottom {
  font-size: 16px;
  display: flex;
  margin-top: 20px;
}

.tableBottomOne {
  margin-right: 40px;
}

</style>
