<!-- 采购入库单 -->
<!--未被使用，但打印已改成vue-easy-print-->
<template>
  <modal v-model="modal" width="700px" class-name="vertical-center-modal">
    <!--  表单主要内容  -->
    <div class="content" ref="print">
      <div class="title" style="text-align: center;font-size: 20px;font-weight: bold;">
        采购入库单
      </div>
      <div class="sub-title border"
           style="display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 10px;
          font-size: 14px;
          border-bottom: 1px solid #000000;
          font-weight: bold;"
      >
        <span>申购信息</span>
      </div>
      <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
        <div class="col" style="flex: 1;display: flex;align-items: center;">
          <div class="label">申购单号：</div>
          <div class="value">{{ data.applyBillNo }}</div>
        </div>
        <div class="col" style="flex: 1;display: flex;align-items: center;">
          <div class="label">申请日期：</div>
          <div class="value">{{ data.applyDate }}</div>
        </div>
      </div>
      <div class="sub-title border"
           style="display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 10px;
          font-size: 14px;
          border-bottom: 1px solid #000000;
          font-weight: bold;"
      >
        <span>入库信息</span>
      </div>
      <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
        <div class="col" style="flex: 1;display: flex;align-items: center;">
          <div class="label">物料编码：</div>
          <div class="value">{{ data.materialCode }}</div>
        </div>
        <div class="col" style="flex: 1;display: flex;align-items: center;">
          <div class="label">物料名称：</div>
          <div class="value">{{ data.materialName }}</div>
        </div>
      </div>
      <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
        <div class="col" style="flex: 1;display: flex;align-items: center;">
          <div class="label">物料规格：</div>
          <div class="value">{{ data.spec }}</div>
        </div>
      </div>
      <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
        <div class="col" style="flex: 1;display: flex;align-items: center;">
          <div class="label">请购数量：</div>
          <div class="value">{{ data.quantity }}</div>
        </div>
      </div>
      <div class="sub-title border"
           style="display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 10px;
          font-size: 14px;
          border-bottom: 1px solid #000000;
          font-weight: bold;"
      >
        <span>入库明细</span>
      </div>
      <div class="row">
        <div class="col">
          <div class="table">
            <table style="border-collapse:collapse;border:none;width: 100%;">
              <tr>
                <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">序号</th>
                <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">入库日期</th>
                <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">入库数量</th>
                <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">操作员</th>
              </tr>
              <tr v-for="(item, index) in data.inStockDetailList" :key="index">
                <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ index + 1 }}</td>
                <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ item.date }}</td>
                <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ item.quantity }}</td>
                <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ item.operateUser }}</td>
              </tr>
            </table>
          </div>
        </div>
      </div>
    </div>
    <div class="footer" slot="footer">
      <Button @click="cfm" class="btn" type="primary">打印</Button>
      <Button @click="cancel" class="btn">关闭</Button>
    </div>
    <vue-easy-print ref="print">
      <template>
        <div class="content" ref="print">
          <div class="title" style="text-align: center;font-size: 20px;font-weight: bold;">
            采购入库单
          </div>
          <div class="sub-title border"
               style="display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 10px;
          font-size: 14px;
          border-bottom: 1px solid #000000;
          font-weight: bold;"
          >
            <span>申购信息</span>
          </div>
          <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
            <div class="col" style="flex: 1;display: flex;align-items: center;">
              <div class="label">申购单号：</div>
              <div class="value">{{ data.applyBillNo }}</div>
            </div>
            <div class="col" style="flex: 1;display: flex;align-items: center;">
              <div class="label">申请日期：</div>
              <div class="value">{{ data.applyDate }}</div>
            </div>
          </div>
          <div class="sub-title border"
               style="display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 10px;
          font-size: 14px;
          border-bottom: 1px solid #000000;
          font-weight: bold;"
          >
            <span>入库信息</span>
          </div>
          <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
            <div class="col" style="flex: 1;display: flex;align-items: center;">
              <div class="label">物料编码：</div>
              <div class="value">{{ data.materialCode }}</div>
            </div>
            <div class="col" style="flex: 1;display: flex;align-items: center;">
              <div class="label">物料名称：</div>
              <div class="value">{{ data.materialName }}</div>
            </div>
          </div>
          <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
            <div class="col" style="flex: 1;display: flex;align-items: center;">
              <div class="label">物料规格：</div>
              <div class="value">{{ data.spec }}</div>
            </div>
          </div>
          <div class="row" style="padding: 0 20px;margin-bottom: 5px;display: flex;justify-content: space-between;align-items: center;">
            <div class="col" style="flex: 1;display: flex;align-items: center;">
              <div class="label">请购数量：</div>
              <div class="value">{{ data.quantity }}</div>
            </div>
          </div>
          <div class="sub-title border"
               style="display: flex;
          justify-content: space-between;
          align-items: center;
          margin: 10px;
          font-size: 14px;
          border-bottom: 1px solid #000000;
          font-weight: bold;"
          >
            <span>入库明细</span>
          </div>
          <div class="row">
            <div class="col">
              <div class="table">
                <table style="border-collapse:collapse;border:none;width: 100%;">
                  <tr>
                    <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">序号</th>
                    <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">入库日期</th>
                    <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">入库数量</th>
                    <th style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">操作员</th>
                  </tr>
                  <tr v-for="(item, index) in data.inStockDetailList" :key="index">
                    <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ index + 1 }}</td>
                    <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ item.date }}</td>
                    <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ item.quantity }}</td>
                    <td style="border:solid #dcdee2 1px;padding: 5px;text-align: center;position: relative;font-size: 12px;">{{ item.operateUser }}</td>
                  </tr>
                </table>
              </div>
            </div>
          </div>
        </div>
      </template>
    </vue-easy-print>
  </modal>
</template>

<script>
import VueEasyPrint from 'vue-easy-print'
export default {
  name: 'store-in-form',
  data () {
    return {
      modal: false
    }
  },
  components: {
    VueEasyPrint
  },
  props: {
    data: {
      type: Object,
      default () {
        return {}
      }
    },
    value: {
      type: Boolean,
      default: false,
      require: true
    }
  },
  watch: {
    value: {
      handler (n) {
        this.modal = n
      },
      immediate: true
    },
    modal (n) {
      this.$emit('input', n)
    }
  },
  methods: {
    cfm () {
      this.$refs.print.print()
    },
    cancel () {
      this.modal = false
    }
  }
}
</script>

<style lang="less" scoped>
.content {
  .title {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
  }
  .sub-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 10px;
    font-size: 14px;
    font-weight: bold;
    &.border {
      border-bottom: 1px solid #000000;
    }
    .go {
      font-size: 10px;
      font-weight: normal;
      color: #0000ff;
    }
  }
  .row {
    padding: 0 20px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .col {
      flex: 1;
      display: flex;
      align-items: center;
      .table {
        width: 100%;
        table {
          border-collapse:collapse;
          border:none;
          width: 100%;
          tr {
            th {
              background-color: #eeeeee;
            }
            td,th {
              padding: 5px;
              text-align: center;
              border:solid #dcdee2 1px;
              position: relative;
              font-size: 12px;
            }
          }
        }
      }
    }
  }
  .card {
    margin-bottom: 5px;
    background-color: #FFFFFF;
    border: 1px solid rgba(215, 215, 215, 1);
    border-radius: 5px;
    .border {
      border-bottom: 1px solid #5d6c7b;
    }
    .line {
      width: 100%;
      border-bottom: 1px solid #5d6c7b;
    }
  }
}
</style>
