<!--  -->
<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"> <!-- 表头  -->
                <h3 class="h2">{{ item.areaname }}市场监督管理局</h3>
                <h3 class="h2">列入经营异常名录异议不予受理通知书</h3>
                <span>{{ item.wrirsno }}</span>
              </div>
              <div class="enter" />
              <div class="paper-content">
                <div class="firstLine">
                  <div class="name"><span class="downLine">{{ item.name }}</span><span>：</span></div>

                </div>
                <el-row style="border: unset"> <!-- contenteditable="true"设置span可编辑 -->
                  <p>{{ item.content }}</p>
                </el-row>
                <!-- <el-row style="border: unset">
                  <p>我局收到你单位提交的列入经营异常名录异议申请书及有关材料。经审查，决定不予受理。</p>
                  <p style="margin-top:0px"> 理由如下：</p>
                  <p id="content" style="margin-top:0px"><span contenteditable="true">{{ item.content }}</span></p>
                </el-row> -->
                <el-row style="border: unset">
                  <div class="enter" />
                  <div class="right_down" style="padding-right: 80px;">{{ item.areaname }}市场监督管理局</div>
                </el-row>
                <el-row style="border: unset">
                  <div class="right_down" style="padding-right: 80px;"><span>{{ item.year }}年{{ item.month }}月{{ item.day }}日</span></div>
                </el-row>
              </div>
              <!-- <div id="saveBtn" style="display: inline-block;">
                <el-button size="medium" @click="saveNoticeContent(item.writsid)">保存</el-button>
              </div> -->
            </div>
          </paper>
        </paper-swiper>
        <div :ref="'paper'" class="paper-box" />
      </div>

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

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import { getNoticePrintInfo, updateResultNotice } from '@/api/abnormal'
export default {
// import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    // 这里存放数据
    return {
      paperInfo: [{ wrirsno: '', name: '' }],
      name: '______________', // 企业名称
      reason: '________', // 原因
      wrirsno: '文书号' // 文书号
    }
  },

  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    // 加载文书号及主体名称  列入经营异常名录异议不予受理通知书--'13'
    getNoticePrintInfo(this.$route.query.bizseq, '13').then(res => {
      if (res.code === 0) {
        this.paperInfo[0].wrirsno = res.data[0].wrirsno
        this.paperInfo[0].name = res.data[0].entname
        this.paperInfo[0].areaname = res.data[0].areaname
        this.paperInfo[0].writsid = res.data[0].writsid
        this.paperInfo[0].content = this.$util.isEmpty(res.data[0].content) ? '手动编辑输入' : res.data[0].content
        const dateArray = this.$util.formatDate.format(new Date(Date.parse(res.data[0].createtime)), 'yyyy-MM-dd').split('-')
        this.paperInfo[0].year = dateArray[0]
        this.paperInfo[0].month = dateArray[1]
        this.paperInfo[0].day = dateArray[2]
      } else {
        this.$message.error('加载文书号失败')
      }
    })
  },
  // 方法集合
  methods: {
    saveNoticeContent(writsid) {
      updateResultNotice({
        writsid: writsid,
        writstype: '13',
        content: document.getElementById('content').innerText
      }).then(res => {
        if (res.data === true) {
          this.$message.success('保存成功')
        }
      })
    },
    printCurrent() {
      // var child = document.getElementById('saveBtn')
      // child.parentNode.removeChild(child)
      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;
    }
  }
  .td{
      text-align: right;
  }
/* 浏览区域 */
  .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{
        width:630PX;
        min-height:891PX;
        background:white;
        border:1PX solid #ccc;
        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,.paper-table th{
    .right{
        text-align: right;
    }
    font-weight: normal;
    padding: 5PX 5PX;
    }
}
/* 标题 */
.paper-header{text-align: center;line-height: 35PX;}
.paper-header>h3{font-weight:600;margin:0}
/* 换行 */
.enter{margin-top:20PX}
.enter:before{content:''}
.right_down{
    text-align: right;
    line-height: 30px;
    padding-right: 60px;
}

</style>
<style lang="scss">

.main-content.abnormal{
    .line2{
      border-top: 0px;
    td,th{
        .right{
            text-align: right;
        }
        font-weight: normal;
        padding: 15PX 5PX;
    }
  }
}

.paper-content{
    .firstLine{
        text-align: left;
    }
 .name{
    display: inline-block;
    }
 .downLine{
     border-bottom: solid 1px;
 }
}
p {
    margin: 10px 0px 0px 0px;
    text-indent: 2em;
    text-align: left;
    line-height: 30px;
    span{
        border-bottom: solid 1px;
    }
}
.mr20 {
  margin-right: 20px;
}
@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;
    }
  }
  .td{
      text-align: right;
  }
/* 浏览区域 */
  .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,.paper-table th{
    .right{
        text-align: right;
    }
    font-weight: normal;
    padding: 5PX 5PX;
    }
/* 标题 */
.paper-header{text-align: center;line-height: 35PX;}
.paper-header>h3{font-weight:600;margin:0}
/* 换行 */
.enter{margin-top:20PX}
.enter:before{content:''}
.right_down{
    text-align: right;
    line-height: 30px;
}
.paper{
       .el-divider--horizontal { //虚线
            margin: 8px 0;
            background: 0 0;
            border-top: 1px dashed #18191a;
        }
}
.line2{
      border-top: 0px;
    td,th{
        .right{
            text-align: right;
        }
        font-weight: normal;
        padding: 15PX 5PX;
    }
    .mr20 {
        margin-right: 20px;
    }
}
  .paper-content{
 .firstLine{
        text-align: left;
    }
 .name{
    display: inline-block;
    }
 .downLine{
     border-bottom: solid 1px;
 }
}
p {
    text-indent: 2em;
    text-align: left;
    line-height: 30px; //行间距
    span{
        border-bottom: solid 1px;
    }
}
.mr20 {
  margin-right: 20px;
}
@page {
    size: auto;
    margin: 0mm;
}
}
</style>
