<!--  -->
<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 tableDataList" :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.entname }}</span><span>：</span></div>

                </div>
                <el-row> <!-- contenteditable="true"设置span可编辑 -->
                  <p>经查，你单位<span class="downLine">{{ item.remreasons }}</span>，根据《企业信息公示暂行条例》第十七条第二款和《经营异常名录管理办法》的相关规定，决定将你单位移出经营异常名录。</p>
                  <p>你单位如不服本决定，可在接到本决定书之日起六十日内向<span contenteditable="true">{{ item.areaname }}</span>人民政府申请行政复议；或者三个月内向铁路法院提起行政诉讼。</p>
                </el-row>
                <el-row>
                  <div class="enter" />
                  <div class="right_down">({{ item.areaname }}市场监督管理局公章)</div>
                </el-row>
                <el-row>
                  <div class="right_down"> <span>{{ item.year }}年{{ item.month }}月{{ item.day }}日</span></div>
                </el-row>
              </div>
              <el-divider />
              <div class="enter" />
              <div class="paper-header"> <!-- 表头  -->
                <div class="enter" />
                <h3 class="h2">送达回证</h3>
              </div>
              <div class="paper-table"><!--  表格 -->
                <table width="100%" border="1" style="border-collapse: collapse;">
                  <tbody>
                    <tr>
                      <th width="15%">送达地点</th>
                      <td width="45%" />
                      <th width="15%">送达方式</th>
                      <td width="25%" />
                    </tr>
                  </tbody>
                </table>
                <table class="line2" width="100%" border="1" style="border-collapse: collapse;">
                  <tbody>
                    <tr>
                      <th width="15%">收件人</th>
                      <td class="td" width="30%"><span>(签名或者盖章)</span><br>
                        <span class="mr20">年</span><span class="mr20">月</span>日</td>
                      <th width="15%">见证人</th>
                      <td class="td" width="40%"><span>(签名或者盖章)</span><br>
                        <span class="mr20">年</span><span class="mr20">月</span>日</td>
                    </tr>
                  </tbody>
                </table>
                <table class="line2" width="100%" border="1" style="border-collapse: collapse;">
                  <tbody>
                    <tr>
                      <th width="15%">送达人</th>
                      <td width="85%"><el-row><el-col :span="12" style="text-align: left;padding-left: 20px">(签名或者盖章)</el-col><el-col :span="12" style="text-align: right;"><span class="mr20">年</span><span class="mr20">月</span>日</el-col></el-row></td>
                    </tr>
                    <tr>
                      <th width="15%">备注</th>
                      <td width="85%" />
                    </tr>
                  </tbody>

                </table>
              </div>
            </div>

          </paper>
        </paper-swiper>
      </div>

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

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import { getWritByBizseq } from '@/api/abnormal'
import { getConstant, getCD72 } from '@/api/system'
export default {
// import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    // 这里存放数据
    return {
      reasonOptions: [],
      tableDataList: [],
      name: '', // 企业名称
      remreasons: '', // 移出原因
      wrirsno: '文书号', // 文书号
      value1: '_____' // 企业监管机关
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    // 加载企业移出原因
    getCD72().then(res => {
      if (res.code === 0) {
        const list = []
        res.data.forEach(each => {
          list.push({
            value: each.code,
            label: each.name
          })
        })
        this.reasonOptions = list
      }
    })
    // //加载主体名称及文书号 移出经营异常名录决定书--'15'
    getWritByBizseq(this.$route.query.bizseq, '15').then(res => {
      if (res.code === 0) {
        res.data.forEach(each => {
          var that = each
          const dateArray = this.$util.formatDate.format(new Date(Date.parse(each.createtime)), 'yyyy-MM-dd').split('-')
          that.year = dateArray[0]
          that.month = dateArray[1]
          that.day = dateArray[2]
          that.remreasons = this.$util.enumFormatter(this.reasonOptions, that.remexcpres)
          this.tableDataList.push(that)
        })
      } else {
        this.$message.error('加载文书号失败')
      }
    })
  },
  // 方法集合
  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.tableDataList.length; i++) {
        const page = swiper.getPaperElement(i)
        // const printHtml = page.outerHTML
        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: 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;
    }
  }
  .td{
      text-align: right;
  }
  .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-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;
}

</style>
<style lang="scss">
.main-content.abnormal{
    .printPaper{
       .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;
    }
  }
}

.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;
}
@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;
  }
  /* 标题 */
.paper-header{text-align: center; line-height: 35PX;}
.paper-header>h3{font-weight:600;margin:0}
/* 浏览区域 */
  .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;
       .el-divider--horizontal {
            margin: 8px 0;
            background: 0 0;
            border-top: 1px dashed #18191a;
        }
    }
/* 表格 */
.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{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>
