<!-- 采购入库单 -->
<template>
  <modal v-model="modal" width="700px">
    <!--  表单主要内容  -->
    <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: flex-start;">
          <div class="label" style="width: 70px;">物料编码：</div>
          <div class="value" style="flex: 1;">{{ data.materialCode }}</div>
        </div>
        <div class="col" style="flex: 1;display: flex;align-items: flex-start;">
          <div class="label" style="width: 70px;">物料名称：</div>
          <div class="value" style="flex: 1;">{{ 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: flex-start;">
          <div class="label" style="width: 70px;">物料规格：</div>
          <div class="value" style="flex: 1;">{{ 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: flex-start;">
          <div class="label" style="width: 70px;">到货数量：</div>
          <div class="value" style="flex: 1;">{{ data.quantity }}</div>
        </div>
        <div class="col" style="flex: 1;display: flex;align-items: flex-start;">
          <div class="label" style="width: 70px;">抽检比例：</div>
          <div class="value" style="flex: 1;">{{ data.checkPercent }}</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="table" style="width: 100%;">
            <table style="border-collapse:collapse;border:none;width: 100%;">
              <tr>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">序号</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">物料标签值</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">抽检米数</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">短少</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">抽纱</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">褶皱</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">赃物</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">破洞</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">缩水</th>
                <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">质检结论</th>
              </tr>
              <tr
                v-for="(item, index) in data.quantityCheckDetails"
                :key="index"
                :class="
                  item.checkJudgment === '不合格' ? 'red' :
                  item.checkJudgment === '目测合格' ? 'orange' : 'green'"
              >
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ index }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.rfidCode }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.quantity }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.lakeNum }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.drawnworkNum }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.foldNum }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.dirtNum }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.potholeNum }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.shrinkPercent }}</td>
                <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.checkJudgment }}</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: flex-start;">
              <div class="label" style="width: 70px;">物料编码：</div>
              <div class="value" style="flex: 1;">{{ data.materialCode }}</div>
            </div>
            <div class="col" style="flex: 1;display: flex;align-items: flex-start;">
              <div class="label" style="width: 70px;">物料名称：</div>
              <div class="value" style="flex: 1;">{{ 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: flex-start;">
              <div class="label" style="width: 70px;">物料规格：</div>
              <div class="value" style="flex: 1;">{{ 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: flex-start;">
              <div class="label" style="width: 70px;">到货数量：</div>
              <div class="value" style="flex: 1;">{{ data.quantity }}</div>
            </div>
            <div class="col" style="flex: 1;display: flex;align-items: flex-start;">
              <div class="label" style="width: 70px;">抽检比例：</div>
              <div class="value" style="flex: 1;">{{ data.checkPercent }}</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="table" style="width: 100%;">
                <table style="border-collapse:collapse;border:none;width: 100%;">
                  <tr>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">序号</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">物料标签值</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">抽检米数</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">短少</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">抽纱</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">褶皱</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">赃物</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">破洞</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">缩水</th>
                    <th style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">质检结论</th>
                  </tr>
                  <tr
                    v-for="(item, index) in data.quantityCheckDetails"
                    :key="index"
                    :class="
                  item.checkJudgment === '不合格' ? 'red' :
                  item.checkJudgment === '目测合格' ? 'orange' : 'green'"
                  >
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ index }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.rfidCode }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.quantity }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.lakeNum }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.drawnworkNum }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.foldNum }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.dirtNum }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.potholeNum }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.shrinkPercent }}</td>
                    <td style="padding: 5px;text-align: center;border:solid #dcdee2 1px;position: relative;font-size: 12px;">{{ item.checkJudgment }}</td>
                  </tr>
                </table>
              </div>
            </div>
          </div>
        </div>
      </template>
    </vue-easy-print>
  </modal>
</template>

<script>
import VueEasyPrint from 'vue-easy-print'
export default {
  name: 'quality-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 () {
      // 被tab-modal引用
      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 {
            td,th {
              padding: 5px;
              text-align: center;
              border:solid #dcdee2 1px;
              position: relative;
              font-size: 12px;
              th {
                background-color: #eeeeee;
              }
            }
            &.green {
              color: #4B7902;
            }
            &.red {
              color: red;
            }
            &.orange {
              color: #B8741A;
            }
          }
        }
      }
    }
  }
  .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>
