<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="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">
            <!--标题-->
            <div style="font-size:25px;text-align:center">
              <span style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.decOrgName }}&nbsp;&nbsp;</span><br>
              <span>移出严重违法失信企业名单决定书</span>
            </div>
            <br>
            <!--副标题，决定书号-->
            <div style="text-align:center;font-size:12px;transform: scale(0.8)">
              <h2 style="font-weight:normal">（&nbsp;{{ each.writNo }}&nbsp;）</h2>
            </div>
            <br>
            <br>
            <!--主内容-->
            <div style="font-size:16px">
              <span style="text-decoration:underline">&nbsp;{{ each.entname }}&nbsp;</span>
              <br>
              <span>（统一社会信用代码/注册号：<font style="text-decoration:underline">&nbsp;&nbsp;{{ each.regNo }}&nbsp;&nbsp;</font>）:</span>
              <br>
              <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span contenteditable="true" style="word-break: break-all;">你企业因被列入{{ each.serillreaStr }}</span>，于
              <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.incYear }}&nbsp;&nbsp;</font>年
              <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.incMonth }}&nbsp;&nbsp;</font>月
              <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.incDay }}&nbsp;&nbsp;</font>被列入严重违法失信企业名单。
              但<span contenteditable="true">{{ each.removeExplain }}</span>，经审批决定将你企业移出严重违法失信企业名单，并通过企业信用信息公示系统向社会公示。<br>
              <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>你企业如不服本决定，可在接到本决定书之日起60日内向，
              <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.cityName }}&nbsp;&nbsp;</font>市场监督管理局或者
              <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.regionName }}&nbsp;&nbsp;</font>人民政府申请行政复议；或者6个月内向
              <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;&nbsp;&nbsp;</font>人民法院提起行政诉讼。
              <br>
              <br>
              <br>
              <br>
              <br>
              <span style="float:right"><font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.decOrgName }}&nbsp;&nbsp;</font></span><br>
              <span style="float:right"><font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.remYear }}&nbsp;&nbsp;</font>年
                <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.remMonth }}&nbsp;&nbsp;</font>月
                <font style="text-decoration:underline" contenteditable="true">&nbsp;&nbsp;{{ each.remDay }}&nbsp;&nbsp;</font>日
              </span>
              <br>
              <br>
              <br>
              <br>
            </div>
          </paper>
        </paper-swiper>
      </div>
    </div>
  </div>
</template>

<script>
import { getIllegalRemoveDecWrit } 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
    // 获取文书信息
    getIllegalRemoveDecWrit(this.bizseq).then(res => {
      if (res.code === 0) {
        this.paperInfo = res.data
        this.paperInfo.forEach(each => {
          let dateArray = each.incDecDateStr.split('-')
          each.incYear = dateArray[0]
          each.incMonth = dateArray[1]
          each.incDay = dateArray[2]
          dateArray = each.remDecDateStr.split('-')
          each.remYear = dateArray[0]
          each.remMonth = dateArray[1]
          each.remDay = dateArray[2]
        })
      }
    })
  },
  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>
