<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="({tsserillegallist,tsBizSerIllegal,tsWrit,eBaseinfo}, index) in paperInfo" :key="index" style="width:700px;line-height: 30px;margin: 0 auto;">
            <!--标题-->
            <div style="font-size:25px;text-align:center">
              <span>&nbsp;&nbsp;{{ tsserillegallist.decorgCn }}&nbsp;&nbsp;</span>
              <br>
              <br>
              <span>列入严重违法失信名单决定书</span>
            </div>
            <!--副标题，决定书号-->
            <div style="text-align:center;font-size:16px;transform: scale(0.8)">
              <h2 style="font-weight:normal">{{ tsWrit.writsno }}</h2>
            </div>
            <br>
            <br>
            <!--主内容-->
            <div style="font-size:16px">
              当事人：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.party || eBaseinfo.entname }}&nbsp;</span><br>
              主体资格证照名称：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.certificate || eBaseinfo.entname }}&nbsp;</span><br>
              统一信用代码/身份证件号码：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.usccId || eBaseinfo.uniscid || eBaseinfo.regno }}&nbsp;</span><br>
              住所/经营场所（住址）：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.residence || eBaseinfo.dom }}&nbsp;</span><br>
              法定代表人（负责人、经营者）姓名：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.legalName || eBaseinfo.lerep }}&nbsp;</span><br>
              身份证件号码：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.idNumber || eBaseinfo.cerno }}&nbsp;</span><br>
              联系电话：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.phone || eBaseinfo.phone }}&nbsp;</span><br>其他联系方式：<span style="text-decoration:underline">&nbsp;{{ tsBizSerIllegal.otherCert || eBaseinfo.tel }}&nbsp;</span><br>
              <br>
              <!--法院-->
              <div
                v-if="tsBizSerIllegal.sourceType ==='3'"
                style="text-indent: 2em;"
                v-html="tsWrit.content.substring(tsWrit.content.indexOf('）：我局')+2).replace('\n','<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;') "
              />
              <!--满三年和法院-->
              <div
                v-else
                style="text-indent: 2em;"
                v-html="tsWrit.content.substring(tsWrit.content.indexOf('）：经查')+2).replace('\n','<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;') "
              />
              <br>
              <br>
              <span style="float:right">{{ tsserillegallist.decorgCn }}&nbsp;</span>
              <br>
              <span style="float:right">{{ $moment(tsserillegallist.abntime).format('YYYY') }}&nbsp;年&nbsp;{{ $moment(tsserillegallist.abntime).format('M') }}&nbsp;月&nbsp;{{ $moment(tsserillegallist.abntime).format('D') }}&nbsp;日</span>
              <br>
              <br>
              <br>
              <br>
              <!-- <span style="text-align:center;margin-left:auto;margin-right:auto;"> <font style="text-align:center" contenteditable="true">
                注：本文书适用于因具有《严重违法失信企业名单管理暂行办法》第五条第一款第（一）项规定的情形，被列入严重违法失信企业名单的企业。
              </font> </span> -->
            </div>
          </paper>
        </paper-swiper>
      </div>
    </div>
  </div>
</template>

<script>
import { getIllegalInclusionDecWrit } from '@/api/illegal'
export default {
  data() {
    return {
      workflowId: '',
      bizseq: '',
      tasklistid: '',
      historyLog: [], // 意见记录
      opinioncontent: '111',
      tableDataList: [1, 2],
      paperInfo: [],
      name: '',
      uscc: '',
      isPlaceholder: true
    }
  },
  mounted() {
    this.bizseq = this.$route.query.bizseq
    // 获取文书信息
    getIllegalInclusionDecWrit(this.bizseq).then(res => {
      if (res.code === 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: 10pt;
    .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>
