<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="$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="(item,index) in tableDataList" :key="index" style="width:730px">
            <!-- <iframe-pdf src="http://172.22.80.35/aiccs-fileupload/6cf55cba-8140-4efe-a07f-c9bd377b7b71/%E5%88%97%E5%BC%82%E5%86%B3%E5%AE%9A%E4%B9%A6.pdf" /> -->

            <div class="printPaper">
              <div class="paper-header"> <!-- 表头  -->
                <h2 style="margin-bottom: 0px;margin-top: 0px;">{{ item.decorgCn }}</h2>
                <h2 class="h2" style="margin-top: 0px;">标记经营异常状态审批表</h2>
              </div>
              <div class="enter" />

              <div class="paper-table">  <!-- 表格  -->
                <table width="100%" border="1" style="border-collapse: collapse;">
                  <tbody>
                    <tr>
                      <th width="22%">个体工商户名称</th>
                      <td colspan="7" style="text-align: left;padding: 10px">{{ item.entname }}</td>
                    </tr>
                    <tr>
                      <th>注册号</th>
                      <td colspan="7" style="text-align: left;padding: 10px">{{ item.regno }}</td>
                    </tr>
                    <!-- <tr>
                      <th>事实和理由</th>
                      <td colspan="7">
                        <div style="height:auto">
                          <p>{{ item.spereasons }}</p>
                        </div>
                      </td>
                    </tr> -->
                    <tr>
                      <th>列入原因</th>
                      <td colspan="7">
                        <div style="height:auto">
                          {{ item.specausestring }}
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <th>初审意见</th>
                      <td colspan="7">
                        <div style="min-height:80px">
                          <p>{{ historyLog[0].opinioncontent }}</p>
                        </div>
                        <div>
                          <div style="text-align: right;">经办人：<span style="display:inline-block;min-width:35%;text-align: left;">{{ historyLog[0].handler }}</span></div>
                          <!-- <span style="display:inline-block;width:45%">经办人：{{ historyLog[0].handler }}</span> -->
                          <span style="display:inline-block;width:98%;text-align:right">{{ historyLog[0].year }}年{{ historyLog[0].month }}月{{ historyLog[0].day }}日</span>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <th>审核意见</th>
                      <td colspan="7">
                        <div style="min-height:80px">
                          <p>{{ historyLog[1].opinioncontent }}</p>
                        </div>
                        <div>
                          <div style="text-align: right;">审核人：<span style="display:inline-block;min-width:35%;text-align: left;">{{ historyLog[1].handler }}</span></div>
                          <!-- <span style="display:inline-block;width:45%">审核人：{{ historyLog[1].handler }}</span> -->
                          <span style="display:inline-block;width:98%;text-align:right">{{ historyLog[1].year }}年{{ historyLog[1].month }}月{{ historyLog[1].day }}日</span>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <th>审批意见</th>
                      <td colspan="7">
                        <div style="min-height:80px">
                          <p>{{ historyLog[2].opinioncontent }}</p>
                        </div>
                        <div>
                          <div style="text-align: right;">审核人：<span style="display:inline-block;min-width:35%;text-align: left;">{{ historyLog[2].handler }}</span></div>
                          <!-- <span style="display:inline-block;width:45%">审批人：{{ historyLog[2].handler }}</span> -->
                          <span style="display:inline-block;width:98%;text-align:right">{{ historyLog[2].year }}年{{ historyLog[2].month }}月{{ historyLog[2].day }}日</span>
                        </div>
                      </td>
                    </tr>
                    <tr>
                      <th>备注</th>
                      <td colspan="7">
                        <div style="min-height:60px">
                          <p>{{ item.remark }}</p>
                        </div>
                      </td>
                    </tr>
                  </tbody>
                </table>
              </div>
            </div>
          </paper>
        </paper-swiper>

      </div>

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

<script>
import { listAbnormalByBizSeq } from '@/api/abnormal'
import { opinionPrint } from '@/api/task'
import { getConstant } from '@/api/system'
import iframePdf from '../../../../components/IframePdf/iframePdf.vue'
// import { getDetail } from '@/api/company/company'
// import { createApplyRecord } from '@/api/process/dissent'
export default {
  components: { iframePdf },
  data() {
    return {
      workflowId: '',
      bizseq: '',
      tasklistid: '',
      historyLog: [{ opinioncontent: '' }, { opinioncontent: '' }, { opinioncontent: '' }], // 意见记录
      opinioncontent: '111',
      tableDataList: [{

      }],
      name: '',
      uscc: '',
      isPlaceholder: true,
      reasonList: []
    }
  },

  mounted() {
    this.bizseq = this.$route.query.bizseq
    this.workflowId = this.$route.query.workflowId
    this.tasklistid = this.$route.query.tasklistid

    // 个体工商户标记经营异常状态原因
    getConstant('CD75').then(res => {
      if (res.code === 0) {
        const list = []
        res.data.forEach(each => {
          list.push({
            value: each.code,
            label: each.name
          })
        })
        this.reasonList = list
      }
    })
    // 加载主体名称和注册号
    listAbnormalByBizSeq(this.bizseq).then(res => {
      if (res.code === 0) {
        res.data.forEach(each => {
          if (each.remark === 'null') {
            each.remark = ''
          }
          each.specausestring = this.$util.enumFormatter(this.reasonList, each.specause)
          // each.uscc = each.uniscid ? each.uniscid : each.regno
        })
        this.tableDataList = res.data
      } else {
        this.$message.error('加载主体信息失败')
      }
    })
    // 加载同意意见列表
    opinionPrint(this.workflowId).then(res => {
      if (res.code === 0) {
        const list = []
        res.data.forEach(each => {
          const dateArray = this.$util.formatDate.format(new Date(Date.parse(each.handledate)), 'yyyy-MM-dd').split('-')
          each.year = dateArray[0]
          each.month = dateArray[1]
          each.day = dateArray[2]
          list.push(each)
        })
        this.historyLog = list
      } 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.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:700PX;
        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{
    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:''}
p {
    text-indent: 2em;
    text-align: left;
    line-height: 30px;
    margin-block-start: auto;
    margin-block-end: auto;
}
</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
    }
    .paper{
        width:630PX;
        min-height:891PX;
        background:white;
        padding:40PX 100PX
    }
  .printPaper{
        min-height:891PX;
        background:white;
        padding:40PX 120PX;
    }
/* 表格 */
.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:''}
p {
    text-indent: 2em;
    text-align: left;
    line-height: 30px;
    margin-block-start: auto;
    margin-block-end: auto;
}
//去掉页眉页脚及打印链接
@page {
    size: auto;
    margin: 0mm;
}
}
</style>
