<template>
  <div class="main-content illegal-print">
    <div class="content-header">
      <span class="title">拟列入严重违法失信企业名录审批表</span>
      <div class="back-btn">
        <el-button type="primary" size="mini" @click="$router.back()">返回</el-button>
        <el-button type="primary" size="mini" @click="printCurrent">打印当前页</el-button>
        <el-button type="primary" size="mini" @click="printAll">全部打印</el-button>
        <!-- <el-button
          type="warning"
          icon="el-icon-caret-left"
          size="mini"
          @click="$router.back()"
        >返回上一层</el-button> -->
      </div>
    </div>
    <div id="content-body" class="content-body">
      <div class="preview-box">
        <paper-swiper ref="swiper">
          <paper
            v-for="(each, index) in paperInfo"
            :key="index"
            style="width: 700px; line-height: 30px; font-family: '宋体'"
          >
            <div style="text-align: center">
              <!-- 表头  -->
              <h3 style="margin-bottom: 5px">
                <font
                  contenteditable="true"
                  style="text-decoration: underline"
                >广州市</font>市场监督管理局
              </h3>
              <h3 style="margin-top: 0">严重违法失信企业名单审批表</h3>
            </div>
            <br>
            <div class="paper-table">
              <!-- 表格  -->
              <table width="100%" border="1" style="border-collapse: collapse">
                <tbody>
                  <tr>
                    <th width="25%" style="text-align: center; padding: 10px">
                      企业名称
                    </th>
                    <td colspan="2" style="padding: 10px">{{ each.entName }}</td>
                  </tr>
                  <tr>
                    <th style="text-align: center; padding: 10px">
                      统一社会信用代码/注册号
                    </th>
                    <td colspan="4" style="padding: 10px">{{ each.regNo }}</td>
                  </tr>
                  <tr>
                    <th style="text-align: center; padding: 50px 10px">
                      列入/移出严重违法失信企业名单的事实和法律依据
                    </th>
                    <td colspan="4">
                      <div style="text-align: left; padding: 10px">
                        {{ each.explain }}
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <th style="text-align: center; padding: 25px 0">初审意见</th>
                    <td colspan="4">
                      <div style="text-align: left; padding: 10px">
                        {{ each.firstOpinion }}
                        <!-- <span style="display:inline-block;width:25%">经办人：</span>
                                                    <span style="display:inline-block;width:73%;text-align:right">年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日</span> -->
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <th style="text-align: center; padding: 25px 0">审核意见</th>
                    <td colspan="4">
                      <div style="text-align: left; padding: 10px" contenteditable="true">
                        {{ each.lastOpinion }}
                        <!-- <span style="display:inline-block;width:25%">审核人：</span>
                                                    <span style="display:inline-block;width:73%;text-align:right">年&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;月&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;日</span> -->
                      </div>
                    </td>
                  </tr>
                  <tr>
                    <th style="text-align: center; padding: 25px 0">备注</th>
                    <td colspan="4" />
                  </tr>
                </tbody>
              </table>
              <p>
                注：1.因列入期限届满或依企业申请移出严重违法失信企业名单的，应在“列入/移出严重违法失信企业名单的事实和法律依据”一栏中写明届满日期、企业申请日期；<br>
                2.“初审意见”主要包括：拟列入、拟不予列入、拟移出、拟不予移出严重违法失信企业名单。
              </p>
            </div>
          </paper>
        </paper-swiper>
      </div>
    </div>
  </div>
</template>

<script>
import { getIllegalExamineTableInfo } from '@/api/illegal'
export default {
  data() {
    return {
      workflowId: '',
      opinioncontent: '111',
      tableDataList: [1, 2],
      paperInfo: [{}],
      isPlaceholder: true
    }
  },
  mounted() {
    this.bizseq = this.$route.query.bizseq
    // 获取文书信息
    getIllegalExamineTableInfo(this.bizseq).then((res) => {
      if (res.code === 0 && res.data && res.data.length > 0) {
        this.paperInfo = res.data
      }
    })
  },
  methods: {
    printCurrent() {
      const swiper = this.$refs.swiper
      const page = swiper.getPaperElement()

      const printHtml = page.outerHTML // 获取到要打印的节点内容
      // 打开新窗口
      const newWindow = window.open('打印', '_blank')
      newWindow.document.write(printHtml)
      // 关闭文档
      newWindow.document.close()
      // 调用打印机
      newWindow.print()
      newWindow.close()
    },
    printAll() {
      let html = ''
      const swiper = this.$refs.swiper
      for (let i = 0; i < this.paperInfo.length; i++) {
        const page = swiper.getPaperElement(i)
        const printHtml = page.outerHTML
        html += printHtml
      }
      const style =
        '<style type="text/css">body>div:not(:first-child){margin-top:600px}</style>'
      html += style
      // 打开新窗口
      const newWindow = window.open('打印', '_blank')
      newWindow.document.write(html)
      // 关闭文档
      newWindow.document.close()
      // 调用打印机
      newWindow.print()
      newWindow.close()
    }
  }
}
</script>
<style lang="scss" scoped>
.main-content {
  padding: 20pt;
  .back-btn {
    display: inline-block;
    position: absolute;
    right: 40pt;
  }
  .content-header,
  .content-body {
    background: white;
    padding: 20px 10px;
    border: 1px solid #eee;
  }
  .content-header {
    height: 60px;
    .title {
      font-weight: 700;
      font-size: $font-size-sub-title;
    }
  }
  .content-body {
    padding: 20pt;
    .tab {
      .tab-title {
        label {
          background: $color-primary;
          display: inline-block;
          color: $color-title-color;
          padding: 5px;
        }
      }
    }
    .form {
      margin-bottom: 20pt;
    }
  }
}
</style>
