<template>
  <div class="main-content abnormal">
    <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="(item,index) in paperInfo" :key="index" style="width:730px">
            <div class="printPaper">
              <div class="paper-header"> <!-- 表头  -->
                <h2 class="h2">列入经营异常名录异议申请信息表</h2>
              </div>
              <div class="enter" />

              <div class="paper-table">  <!-- 表格  -->
                <table width="100%" border="1" style="border-collapse: collapse;">
                  <tbody>
                    <tr>
                      <th width="28%" rowspan="3">企业基本情况</th>
                      <th width="20%">企业名称</th>
                      <td colspan="7">{{ item.entname }}</td>
                    </tr>
                    <tr>
                      <th>注册号</th>
                      <td colspan="7">{{ item.regno }}</td>
                    </tr>
                    <tr>
                      <th>法定代表人</th>
                      <td colspan="7">{{ item.lerepname }}</td>
                    </tr>
                    <tr>
                      <th>联系人</th>
                      <td>{{ item.contacts }}</td>

                      <th width="25%">联系电话</th>
                      <td>{{ item.telephone }}</td>
                    </tr>
                    <tr>
                      <th>列入经营异常名录决定书文号</th>
                      <td colspan="7">{{ item.writsno }}</td>
                    </tr>
                    <tr>
                      <th>相关证明材料</th>
                      <td colspan="7">
                        <div style="text-align: left; padding: 10px;min-height:60px">
                          <el-row v-for="item1 in fileList" :key="item1.id">{{ item1.filename }}</el-row>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <th>初审意见</th>
                      <td colspan="7">
                        <p style="text-align: left;text-indent: 2em;min-height:80px">
                          {{ item.firstOpinion }}
                        </p>
                        <div>
                          <!-- <span style="display:inline-block;width:45%">经办人：{{ item.firstHandler }}</span> -->
                          <el-row style="text-align: right;border: unset">经办人：<span style="display:inline-block;min-width:35%;text-align: left;">{{ item.firstHandler }}</span></el-row>
                          <span style="display:block;text-align:right;line-height:initial">{{ item.year1 }}年{{ item.month1 }}月{{ item.day1 }}日</span>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <th>审批意见</th>
                      <td colspan="7">
                        <p style="text-align: left;text-indent: 2em;min-height:80px">
                          {{ item.lastOpinion }}
                        </p>
                        <div>
                          <!-- <span style="display:inline-block;width:45%">审批人：{{ item.lastHandler }}</span> -->
                          <el-row style="text-align: right;border: unset">审批人：<span style="display:inline-block;min-width:35%;text-align: left;">{{ item.lastHandler }}</span></el-row>
                          <span style="display:block;text-align:right;line-height:initial">{{ item.year2 }}年{{ item.month2 }}月{{ item.day2 }}日</span>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <th>备注</th>
                      <td colspan="7">
                        <p style="text-align: left;text-indent: 2em;min-height:40px">
                          {{ item.applyRemark === 'null' ? '' : item.applyRemark }}
                        </p>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </paper>
        </paper-swiper>

      </div>

    </div>
  </div>
</template>

<script>
import { getAbnDissentApplyTabInfo } from '@/api/abnormal'
import { listAttachmentByModelParam } from '@/api/attachment'
export default {
  data() {
    return {
      bizseq: '',
      paperInfo: [],
      name: '',
      uscc: '',
      isPlaceholder: true,
      fileList: []
    }
  },
  // watch: {
  //   isPlaceholder() {
  //     return this.$refs.dissentContent.innerHTML === '点击此处输入异议内容'
  //   }
  // },
  mounted() {
    this.bizseq = this.$route.query.bizseq
    // 加载列入经营异常名录异议申请表信息
    getAbnDissentApplyTabInfo(this.bizseq, 'apply').then(res => {
      if (res.code === 0) {
        let dateArray = this.$util.formatDate.format(new Date(Date.parse(res.data.firstHandleDate)), 'yyyy-MM-dd').split('-')
        res.data.year1 = dateArray[0]
        res.data.month1 = dateArray[1]
        res.data.day1 = dateArray[2]
        dateArray = this.$util.formatDate.format(new Date(Date.parse(res.data.lastHandleDate)), 'yyyy-MM-dd').split('-')
        res.data.year2 = dateArray[0]
        res.data.month2 = dateArray[1]
        res.data.day2 = dateArray[2]
        this.paperInfo.push(res.data)
      } else {
        this.$message.error('加载审批表信息失败')
      }
    })
    // 加载受理环节附件清单
    listAttachmentByModelParam({ bizseq: this.bizseq }).then(data => {
      data.forEach(each => {
        each.id = each.attachmentid
        each.name = each.filename
        each.url = `${process.env.VUE_APP_DOWNLOAD_URL}/` + each.temppath
      })
      this.fileList = data
    })
  },
  methods: {
    printCurrent() {
      const swiper = this.$refs.swiper
      const page = swiper.getPaperElement()

      const printHtml = page.innerHTML// 获取到要打印的节点内容

      window.document.body.innerHTML = printHtml// 把打印内容赋值给页面内容

      window.print()// 调用打印方法
      window.location.reload()// 打印之后页面重新加载
    },
    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.innerHTML
        html += printHtml
      }
      const style = '<style type="text/css">body>div:not(:first-child){margin-top:600px}</style>'
      html += style
      window.document.body.innerHTML = html// 把打印内容赋值给页面内容

      window.print()// 调用打印方法
      window.location.reload()// 打印之后页面重新加载
    }
  }
}
</script>
<style lang='scss' scoped>
//@import url(); 引入公共css类
.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;
    }
  }
  .printPaper{
        width:630PX;
        min-height:891PX;
        background:white;
        border:1PX solid #ccc;
        padding:40PX 50PX;
    }
/* 浏览区域 */
  .preview-box{
      background-color:#e6e6e6;
       text-align:center;
       border:1PX solid #eee;
       min-height:800PX;
       overflow: hidden;
    }
    .paper-box{
        display: inline-block;
        margin-top:10PX
    }
    .paper{
        width:630PX;
        min-height:891PX;
        background:white;
        // border:1PX solid #ccc;
        padding:40PX 50PX
    }
/* 标题 */
.paper-header{text-align: center;line-height: 35PX;}
.paper-header>h3{font-weight:600;margin:0}
/* 表格 */
.paper-table>div{border:1PX solid black;border-bottom: none;}
.paper-table>div:last-child{border-bottom:1PX solid black}
.row-field:not(:first-child){border-top:1PX solid black}
.field{min-height: 45PX;border-left:1PX solid black}
.paper-table td{
    padding:15PX 10PX
}
.paper-table th{
  text-align: center;
  padding:15PX 10PX
}
}
/* 换行 */
.enter{margin-top:20PX}
.enter:before{content:''}
</style>
<style lang="scss">
//打印样式
@media print{
.content-body{
    background: white;
    padding:20PX 10PX;
    border:1PX solid #eee;
}
.content-body{
    padding:20pt;
      .tab{
        .tab-title{
          label{
            background: $color-primary;
            display:inline-block;
            color:$color-title-color;
            padding:5px;
          }
        }
    }
    .form{
      margin-bottom: 20pt;
    }
}
.preview-box{
      background-color:#e6e6e6;
       text-align:center;
       border:1PX solid #eee;
       min-height:800PX;
       overflow: hidden;
    }
    .paper-box{
        display: inline-block;
        margin-top:10PX
    }
  .printPaper{
        min-height:891PX;
        background:white;
        padding:40PX 50PX;
    }

/* 表格 */
.paper-table>div{border:1PX solid black;border-bottom: none;}
.paper-table>div:last-child{border-bottom:1PX solid black}
.row-field:not(:first-child){border-top:1PX solid black}
.field{min-height: 45PX;border-left:1PX solid black}
.paper-table td{
    padding:15PX 10PX
}
.paper-table th{
  text-align: center;
  padding:15PX 10PX
}
/* 标题 */
.paper-header{text-align: center;line-height: 35PX;}
.paper-header>h3{font-weight:600;margin:0}
/* 换行 */
.enter{margin-top:20PX}
.enter:before{content:''}
//去掉页眉页脚及打印链接
@page {
    size: auto;
    margin: 0mm;
}
}
</style>
