<template>
  <div class="modals">
    <BasicModal
      v-bind="$attrs"
      destroyOnClose
      @register="registerModal"
      :title="getTitle"
      @ok="handleSubmit"
      okText="打印"
      :width="600"
      @cancel="handleCancel"
    >
      <div class="!pl-8 !pt-4 !pr-8" ref="printCard">
        <div class="printTitle">耗材统计单</div>
        <a-divider />
        <div class="printRow" v-for="(item, index) in fromDatas" :key="index">
          <div>{{ item.name }}</div>
          <div>{{ item.count + item.unit }}</div>
        </div>
      </div>
    </BasicModal>
  </div>
</template>
<script lang="ts" setup>
  import { ref } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';

  import { estimatePrint } from '/@/api/biz/inventory/estimateApi';

  const getTitle = ref('耗材统计单');
  const fromDatas = ref([] as any);
  const [registerModal, { closeModal }] = useModalInner(async data => {
    console.log('datas:::', data);
    const params = {
      partWardId: data.partWardId,
      time: data.time,
      suppliesName: data.suppliesName,
    };
    fromDatas.value = await estimatePrint(params);
  });

  // 提交按钮事件
  async function handleSubmit() {
    console.log('print.......');
  }
  async function handleCancel() {
    closeModal();
  }
</script>
<style lang="less" scoped>
  ::v-deep(.ant-modal) {
    background-color: #000;
  }

  .printTitle {
    font-size: 52px;
    font-weight: 600;
    text-align: center;
    color: #000a18;
  }

  .printRow {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 26px;
    font-weight: 500;
    color: #000a18;
  }
</style>
