<template>
  <div class="main-content abnormal m20" v-loading.fullscreen.lock="fullscreenLoading">
    <DetailHead result="业务信息" />
    <div class="content-body">
      <el-form ref="form" :model="IlcPunInfo" label-width="230px" label-position="right">
        <div class="form">
          <div class="tab">
            <div class="tab-title">
              <label>行政处罚信息</label>
            </div>
          </div>
          <div class="form-body">
            <el-row class="flex-row">
              <el-col :span="12">
                <el-form-item label="统一社会信用代码/注册号">
                  <span class="span-content">{{ IlcPunInfo.uniscid || IlcPunInfo.zch }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="主体名称">
                  <span style="color: #8cc3fb;cursor: pointer;" @click="toEntDetail" class="span-content">{{ IlcPunInfo.dsrmc }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="12">
                <el-form-item label="决定文书编号">
                  <span class="span-content">{{ IlcPunInfo.sbookcode }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="违法行为类型">
                  <span class="span-content">{{ IlcPunInfo.sgisttypename }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="12">
                <el-form-item label="决定机关名称">
                  <span class="span-content">{{ IlcPunInfo.cfdjjg }}</span>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="处罚决定日期">
                  <span class="span-content">{{ this.$moment(IlcPunInfo.cfjdsj).format('YYYY年MM月DD日') }}</span>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="行政处罚内容">
                <span class="span-content">{{ IlcPunInfo.spuncontent }}</span>
              </el-form-item>
            </el-row>
          </div>
        </div>
      </el-form>
    </div>

    <DetailHead result="业务办理" />
    <div class="content-body">
      <el-form ref="businessForm" :model="punishInfo" label-width="230px" label-position="right" :rules="formRules">
        <div class="form">
          <div class="tab">
            <div class="tab-title">
              <label>行政处罚信用修复信息</label>
            </div>
          </div>
          <div class="form-body">
            <el-row class="flex-row">
              <el-col :span="12">
                <el-form-item label="主体申请修复日期" prop="applyDate">
                  <el-date-picker
                    v-model="punishInfo.applyDate"
                    type="date"
                    :disabled="onlyShow"
                    value-format="yyyy-MM-dd"
                    placeholder="选择日期">
                  </el-date-picker>
                </el-form-item>
              </el-col>
<!--              <el-col :span="12">-->
<!--                <el-form-item label="准予修复决定书文号" prop="repairNo">-->
<!--                  <el-input :readonly="true" v-model="punishInfo.repairNo"></el-input>-->
<!--                </el-form-item>-->
<!--              </el-col>-->
              <el-col :span="12">
                <el-form-item label="信用修复决定时间" prop="repairDate">
                  <el-date-picker
                    v-model="punishInfo.repairDate"
                    type="date"
                    :disabled="onlyShow"
                    value-format="yyyy-MM-dd HH:mm:ss"
                    placeholder="选择日期">
                  </el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="24">
                <el-form-item label="作出信用修复决定机关" prop="repairOrgCn">
                  <el-input :readonly="true" v-model="punishInfo.repairOrgCn"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="信用修复申请书" class="upload" prop="files_application">
                <el-upload
                  :action="uploadPath"
                  :data="uploadBodyData('8')"
                  :on-remove="removeFile"
                  :on-success="uploadCallback"
                  :on-preview="previewFile"
                  :before-upload="beforeFileUpload"
                  :before-remove="beforeRemove"
                  accept=".doc,.docx,.xlsx,.xls,.pdf,.jpg,.zip,.rar,.7z,.png"
                  multiple
                  :disabled="onlyShow"
                  name="files"
                  ref="files_application"
                  :file-list="fileListDyn('8')"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList"
                  :class="{disabled: onlyShow}"
                >
                  <div v-if="!onlyShow" style="display: inline-block;">
                    <el-button style="display: inline-block;" size="mini" type="primary">点击上传</el-button>
                    <div slot="tip" style="display: inline-block;" class="el-upload__tip">只能上传jpg/png/pdf/doc/docx/xls/xlsx/rar/zip/7z文件，且单个文件不能超过20M</div>
                  </div>
                </el-upload>
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="守信承诺书" class="upload" prop="files_commitment">
                <el-upload
                  :action="uploadPath"
                  :data="uploadBodyData('2')"
                  :on-remove="removeFile"
                  :on-success="uploadCallback"
                  :on-preview="previewFile"
                  :before-upload="beforeFileUpload"
                  :before-remove="beforeRemove"
                  accept=".doc,.docx,.xlsx,.xls,.pdf,.jpg,.zip,.rar,.7z,.png"
                  multiple
                  :disabled="onlyShow"
                  name="files"
                  ref="files_commitment"
                  :file-list="fileListDyn('2')"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList"
                  :class="{disabled: onlyShow}"
                >
                  <div v-if="!onlyShow" style="display: inline-block;">
                    <el-button style="display: inline-block;" size="mini" type="primary">点击上传</el-button>
                    <div slot="tip" style="display: inline-block;" class="el-upload__tip">只能上传jpg/png/pdf/doc/docx/xls/xlsx/rar/zip/7z文件，且单个文件不能超过20M</div>
                  </div>
                </el-upload>
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="履行法定义务的相关材料" class="upload" prop="files_compliance">
                <el-upload
                  :action="uploadPath"
                  :data="uploadBodyData('3')"
                  :on-remove="removeFile"
                  :on-success="uploadCallback"
                  :on-preview="previewFile"
                  :before-upload="beforeFileUpload"
                  :before-remove="beforeRemove"
                  accept=".doc,.docx,.xlsx,.xls,.pdf,.jpg,.zip,.rar,.7z,.png"
                  multiple
                  :disabled="onlyShow"
                  name="files"
                  ref="files_compliance"
                  :file-list="fileListDyn('3')"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList"
                  :class="{disabled: onlyShow}"
                >
                  <div v-if="!onlyShow" style="display: inline-block;">
                    <el-button style="display: inline-block;" size="mini" type="primary">点击上传</el-button>
                    <div slot="tip" style="display: inline-block;" class="el-upload__tip">只能上传jpg/png/pdf/doc/docx/xls/xlsx/rar/zip/7z文件，且单个文件不能超过20M</div>
                  </div>
                </el-upload>
              </el-form-item>
            </el-row>
            <el-row class="bt0">
              <el-form-item label="补充材料" class="upload" prop="files_supplementary">
                <el-upload
                  :action="uploadPath"
                  :data="uploadBodyData('1')"
                  :on-remove="removeFile"
                  :on-success="uploadCallback"
                  :on-preview="previewFile"
                  :before-upload="beforeFileUpload"
                  :before-remove="beforeRemove"
                  accept=".doc,.docx,.xlsx,.xls,.pdf,.jpg,.zip,.rar,.7z,.png"
                  multiple
                  :disabled="onlyShow"
                  name="files"
                  ref="files_supplementary"
                  :file-list="fileListDyn('1')"
                  style="max-width:800px;display: inline-block"
                  class="uploadFileList"
                  :class="{disabled: onlyShow}"
                >
                  <div v-if="!onlyShow" style="display: inline-block;">
                    <el-button style="display: inline-block;" size="mini" type="primary">点击上传</el-button>
                    <div slot="tip" style="display: inline-block;" class="el-upload__tip">只能上传jpg/png/pdf/doc/docx/xls/xlsx/rar/zip/7z文件，且单个文件不能超过20M</div>
                  </div>
                </el-upload>
              </el-form-item>
            </el-row>
          </div>
        </div>
      </el-form>
    </div>

    <DetailHead result="流程办理" />
    <div class="content-body">
      <el-form ref="form" :model="process" label-width="230px" label-position="right" :rules="processRules">
        <div class="form">
          <div class="tab">
            <div class="tab-title">
              <label>流程办理</label>
            </div>
          </div>
          <div class="form-body">
            <el-row class="flex-row">
              <el-col :span="24">
                <template v-if="taskInfo && taskInfo.origin === '1'">
                  <!-- origin为1时，代表外网申请的 -->
                  <el-form-item label="是否受理：" prop="isAccept">
                    <el-radio v-model="punishInfo.isAccept" label="1" style="font-size: unset" @change="handleAcceptChange" :disabled="punishInfo.linkType !== '1' && onlyShow">受理</el-radio>
                    <el-radio v-model="punishInfo.isAccept" label="0" style="font-size: unset" @change="handleAcceptChange" :disabled="punishInfo.linkType !== '1' && onlyShow">不予受理（回退至申请人）</el-radio>
                  </el-form-item>
                </template>
                <template v-else>
                  <!-- origin不为1时，代表内网发起的 -->
                  <el-form-item label="是否受理：" prop="isAccept">
                    <el-radio v-model="punishInfo.isAccept" label="1" style="font-size: unset" @change="handleAcceptChange" :disabled="punishInfo.linkType !== '1' && onlyShow">受理</el-radio>
                    <el-radio v-model="punishInfo.isAccept" label="0" style="font-size: unset" @change="handleAcceptChange" :disabled="punishInfo.linkType !== '1' && onlyShow">不予受理</el-radio>
                  </el-form-item>
                </template>
              </el-col>
            </el-row>
            <el-row class="flex-row" v-if="punishInfo.isAccept === '1'">
              <el-col :span="24">
                <el-form-item label="是否准予修复：" prop="isAgreeRepair">
                  <el-radio :disabled="onlyShow" v-model="punishInfo.isAgreeRepair" label="1" style="font-size: unset">准予修复</el-radio>
                  <el-radio :disabled="onlyShow" v-model="punishInfo.isAgreeRepair" label="0" style="font-size: unset">不予修复</el-radio>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row" v-if="punishInfo.isAccept === '1'">
              <el-col :span="24">
                <el-form-item label="文书">
                  <el-link v-if="punishInfo.isAgreeRepair === '0'" type="primary" :underline="false" style="font-size: unset;border-bottom:1px solid #409EFF" @click="openDialog('noCreidtRepair')">不予信用修复决定书</el-link>
                  <el-link v-else-if="punishInfo.isAgreeRepair === '1'" type="primary" :underline="false" style="font-size: unset;border-bottom:1px solid #409EFF" @click="openDialog('creidtRepair')">准予信用修复决定书</el-link>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row" v-if="punishInfo.isAccept === '1' && !onlyShow">
              <el-col :span="24">
                <!-- 单选按钮组 -->
                <el-form-item label="下一步操作：" prop="nextNodeId">
                  <el-radio-group v-model="punishInfo.nextNodeId">
                    <template v-if="punishInfo.linkType === '1'">
                      <el-radio label="handleRemPunish">提交至执法人员审核</el-radio>
                    </template>
                    <template v-else-if="punishInfo.linkType === '0'">
                      <el-radio label="approveRemPunish">提交至审批人</el-radio>
                      <el-radio label="returnRemPunish">回退上一步</el-radio>
                    </template>
                    <template v-else-if="punishInfo.linkType === '2'">
                      <el-radio label="endRemPunish">业务结束</el-radio>
                      <el-radio label="returnRemPunish">回退上一步</el-radio>
                    </template>
                  </el-radio-group>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row">
              <el-col :span="24">
                <el-form-item label="意见" prop="opinion">
                  <el-input v-model="punishInfo.opinion" type="textarea" :autosize="{ minRows: 2}" placeholder="1000字内" style="width:100%" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row class="bt0 flex-row" v-if="punishInfo.isAccept === '1' && !(punishInfo.nextNodeId === 'endRemPunish' || punishInfo.nextNodeId === 'returnRemPunish') && punishInfo.linkType !== '2' && !onlyShow">
              <el-col :span="24">
                <el-form-item
                  :label="getOperatorLabel()"
                  prop="nextPerformerids"
                >
                  <el-select
                    v-model="punishInfo.nextPerformerids"
                    placeholder="请选择下一步操作人"
                    filterable
                    class="custom"
                    style="width:40%"
                  >
                    <el-option
                      v-for="item in reviewer"
                      :key="'reviewer'+item.primaryKey"
                      :label="item.name"
                      :value="item.primaryKey"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </div>
      </el-form>

      <div class="submit-box">
        <template v-if="!onlyShow">
          <el-button type="primary" @click="submit" :loading="submitLoading">提交</el-button>
        </template>
        <el-button @click="$router.back()">返回</el-button>
      </div>
    </div>
    <!-- 文书对话框 -->
    <el-dialog
      :title="dialogTitle"
      :visible.sync="eidtDialog"
      :close-on-click-modal="false"
      width="60%"
      center
    >
      <div class="firstEnt">
        <el-form label-position="left" label-width="200px" :model="firstEnt" class="decForm">
          <el-row>
            <el-form-item label="主标题">
              <span>{{ user.orgName }}</span>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="副标题">
              <span>{{ dialogTitle }}</span>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="当事人">
              <span>{{ IlcPunInfo.dsrmc }}</span>
            </el-form-item>
          </el-row>
        </el-form>
      </div>
      <Editor ref="editorDialog" v-model="eidtContent" :is-clear="isClear" :is-disable="editorDisable" @getTextVal="getTextVal" @change="changeEditor" />
      <span slot="footer" class="dialog-footer">
        <el-button v-if="!editorDisable && !onlyShow" type="primary" :loading="submitLoading" @click="saveTempalte(true)">保存</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import DetailHead from '@/components/DetailHead'
import { validBeforeUpload } from '@/api/fileUpload'
import { removeAttachementById } from '@/api/attachment'
import { getInfo, listFile, submitTask } from '@/api/remPunish'
import { getUsersWithPermission } from '@/api/user'
import Editor from '@/components/editor.vue'
import { getRemPunishmentContentsWithBizseq, saveOrUpdateContent } from '@/api/credit'
export default {
  data() {
    return {
      submitLoading: false,
      fullscreenLoading: false,
      user: JSON.parse(sessionStorage.getItem('user')),
      bizSeq: this.$route.query.bizSeq,
      punishInfo: {
        nextNodeId: ''
      },
      IlcPunInfo: {},
      taskInfo: {},
      process: {},
      uploadPath: `${process.env.VUE_APP_BASE_API}/punishment/tBizRemPunishment/upload`,
      onlyShow: this.$route.query.onlyShow === '1',
      fileList: [],
      dialogTitle: '',
      eidtDialog: false,
      firstEnt: {},
      isClear: false,
      editorDisable: false,
      eidtContent: '',
      contentText: '',
      tswrittemplate: {
        bizseq: '',
        writsType: '',
        isTemplate: '',
        type: 'punishment' // 设置为行政处罚类型
      },
      formRules: {
        applyDate: [
          { required: true, message: '请选择主体申请修复日期', trigger: 'blur' }
        ],
        repairDate: [
          { required: true, message: '请选择信用修复决定时间', trigger: 'blur' }
        ],
        repairOrgCn: [
          { required: true, message: '请录入作出信用修复决定机关', trigger: 'blur' }
        ]
      },
      processRules: {
        // opinion: [
        //   { required: true, message: '请填写意见', trigger: 'blur' }
        // ],
        // nextPerformerids: [
        //   { required: true, message: '请选择下一步操作人', trigger: 'blur' }
        // ]
      },
      isAgreeRepair: '',
      formData: {
        opinion: '',
        nextPerformerids: ''
      },
      reviewer: []
    }
  },
  computed: {
    uploadBodyData() {
      return (attachType) => {
        return {
          attachType,
          id: this.bizSeq
        }
      }
    },
    fileListDyn() {
      return (attachType) => {
        return this.fileList.filter(item => item.attachtype === attachType)
      }
    }
  },
  mounted() {
    this.fullscreenLoading = true
    getInfo(this.bizSeq).then(res => {
      this.punishInfo = res.data.punishInfo
      this.IlcPunInfo = res.data.IlcPunInfo
      this.taskInfo = res.data.task

      this.punishInfo.repairOrg = this.user.orgCode
      this.punishInfo.repairOrgCn = this.user.orgName

      this.initFileList()

      // 初始化文书内容
      this.$nextTick(() => {
        if (this.punishInfo.isAgreeRepair === '0') {
          this.getNoRepairDecContent()
        } else if (this.punishInfo.isAgreeRepair === '1') {
          this.getRepairDecContent()
        }
      })
    }).finally(() => {
      this.fullscreenLoading = false
    })
    // 加载审核人
    this.loadReviewer()
  },
  methods: {
    // 动态获取下一步操作人的 label
    getOperatorLabel() {
      if (this.punishInfo.linkType === '1') {
        return '审核人'
      } else if (this.punishInfo.linkType === '0') {
        return '审批人'
      }
      return '下一步操作人' // 默认值
    },
    toEntDetail() {
      this.$router.push({
        path: '/aiccs/comprehensive/details',
        query: {
          pripid: this.punishInfo.pripid
        }
      })
    },
    validateFile(rule, value, callback) {
      const files = this.$refs[rule.field].uploadFiles
      if (!files.length) {
        callback(new Error(rule.message))
      }
      callback()
    },
    submit() {
      this.submitLoading = true
      // 判断是否为"不予受理"状态
      const isNotAgree = this.punishInfo.isAccept === '0'

      if (isNotAgree) {
        // 不需要验证，直接提交
        this.$confirm('确定提交？').then(() => {
          this.performSubmit()
        }).catch(() => {
          this.submitLoading = false
        })
      } else {
        // 需要验证表单
        this.validateBusinessForm()
          .then(() => {
            return this.$confirm('确定提交？')
          })
          .then(() => {
            this.performSubmit()
          })
          .catch(error => {
            console.warn('表单验证失败:', error.message)
            this.submitLoading = false
          })
      }
      this.submitLoading = false
    },
    // 提取公共提交逻辑
    performSubmit() {
      // 构造提交数据
      const submitData = {
        ...this.punishInfo,
        nextNodeId: this.punishInfo.nextNodeId // 携带 nextNodeId
      }
      // 当结束流程时，给出提示
      if (this.punishInfo.nextNodeId === 'endRemPunish') {
        this.$message({
          message: '提醒！后台正在生成文书，过程需要耐心等待，切勿重复点击提交，待生成完毕页面会自动返回待办。',
          type: 'warning',
          duration: 5000 // 5秒后自动消失
        })
      }
      submitTask(submitData).then(res => {
        if (res.code === 0) {
          this.$message.success('提交成功')
          this.$router.back()
        } else if (res.code === 5002) {
          this.$message.error('须保存文书内容')
        } else {
          this.$message.error('提交失败，' + res.msg)
        }
      })
    },
    initFileList() {
      listFile({ id: this.bizSeq }).then(({ data }) => {
        if (data.length !== 0) {
          this.fileList = data.map((item) => {
            return {
              ...item,
              id: item.attachmentid,
              name: item.filename,
              attachtype: item.attachtype,
              url: `${process.env.VUE_APP_BASE_API}/attachment/download?id=${item.id}`
            }
          })
        }
      })
    },
    // 移除文件前
    beforeRemove(file, fileList) {
      if (file && file.status === 'success') {
        return this.$confirm(`确定移除 ${file.name} ？`)
      }
    },
    // 上传文件之前校验大小
    beforeFileUpload(file) {
      const that = this
      return validBeforeUpload(file, that)
    },
    // 上传文件预览
    previewFile(file) {
      window.open(`${process.env.VUE_APP_BASE_API}/attachment/download?id=${file.id}`, '_blank')
    },
    uploadCallback(res, file) {
      if (res.code === 0) {
        this.$message.success('上传成功')
        this.initFileList()
      } else {
        this.$message.error('上传失败')
      }
    },
    // 移除文件回调
    removeFile(file) {
      if (file && file.status === 'success') {
        removeAttachementById(file.id).then(res => {
          if (res.code === 0) {
            this.$message.success('删除成功')
          } else {
            this.$message.error(res.msg)
          }
        })
      }
    },
    // 加载审核人
    loadReviewer() {
      // 根据 linkType 动态设置 permission 参数
      const permission = this.punishInfo.linkType === '1' ? 'exptRemoveHandle' : 'exptRemoveApprove'

      getUsersWithPermission(permission, this.user.orgId).then(res => {
        if (res.code === 0) {
          this.reviewer = res.data
        }
      })
    },
    // 自定义验证方法
    validateBusinessForm() {
      return new Promise((resolve, reject) => {
        // 验证必填字段
        const validations = [
          { field: 'applyDate', name: '主体申请修复日期', value: this.punishInfo.applyDate },
          { field: 'repairDate', name: '信用修复决定时间', value: this.punishInfo.repairDate },
          { field: 'repairOrgCn', name: '作出信用修复决定机关', value: this.punishInfo.repairOrgCn }
        ]

        for (const validation of validations) {
          if (!validation.value) {
            this.$message.warning(`请填写${validation.name}`)
            reject(new Error(`请填写${validation.name}`))
            return
          }
        }

        resolve(true)
      })
    },
    handleAcceptChange(value) {
      // 当选择受理时，清空之前的是否准予修复选择
      if (value === '1') {
        this.punishInfo.isAgreeRepair = ''
        // 如果是 linkType === '1'，自动选择提交至执法人员审核
        if (this.punishInfo.linkType === '1') {
          this.punishInfo.nextNodeId = 'handleRemPunish'
        }
      } else {
        // 当选择不予受理时，清空下一步操作的值
        this.punishInfo.nextNodeId = ''
      }
    },
    openDialog(type) {
      // 验证日期字段是否为空
      if (!this.punishInfo.applyDate) {
        this.$message.warning('请先填写主体申请修复日期')
        return
      }
      if (!this.punishInfo.repairDate) {
        this.$message.warning('请先填写信用修复决定时间')
        return
      }
      var title = ''
      if (type === 'creidtRepair') {
        // 点击准予信用修复决定书时，获取最新内容
        this.getRepairDecContent()
        title = '准予信用修复决定书'
      } else if (type === 'noCreidtRepair') {
        this.getNoRepairDecContent()
        title = '不予信用修复决定书'
      }
      this.eidtDialog = true
      this.dialogLoading = true
      this.dialogTitle = title
    },
    changeEditor(val) {
      // 处理编辑器变化
    },
    getTextVal(res) {
      this.contentText = res
    },
    async saveTempalte(alertMsg) {
      this.submitLoading = true
      this.tswrittemplate.content = this.eidtContent
      var resData = false

      // 这里需要根据实际的API接口调整
      try {
        const response = await saveOrUpdateContent(this.tswrittemplate)
        resData = response.data
      } catch (error) {
        console.error('保存决定书失败:', error)
      }

      if (resData === true) {
        this.submitLoading = false
        this.eidtDialog = false
        if (alertMsg) {
          return this.$message.success('保存成功')
        } else {
          return true
        }
      } else {
        if (alertMsg) {
          return this.$message.error('保存决定书失败')
        } else {
          return false
        }
      }
    },
    // 获取准予信用修复决定书内容
    async getRepairDecContent() {
      this.tswrittemplate.bizseq = this.bizSeq
      this.tswrittemplate.writsType = '65' // 准予信用修复决定书类型码
      this.tswrittemplate.type = 'punishment'
      // 添加日期参数
      this.tswrittemplate.applyDate = this.punishInfo.applyDate
      this.tswrittemplate.repairDate = this.punishInfo.repairDate

      getRemPunishmentContentsWithBizseq(this.tswrittemplate).then(res => {
        if (res.code === 0) {
          this.$nextTick(() => {
            this.$set(this.tswrittemplate, 'content', res.data.content)
            this.$set(this, 'eidtContent', res.data.content)
          })
        }
      })
    },
    // 获取不予信用修复决定书内容
    async getNoRepairDecContent() {
      this.tswrittemplate.bizseq = this.bizSeq
      this.tswrittemplate.writsType = '66' // 不予信用修复决定书类型码
      this.tswrittemplate.type = 'punishment'
      // 添加日期参数
      this.tswrittemplate.applyDate = this.punishInfo.applyDate
      this.tswrittemplate.repairDate = this.punishInfo.repairDate

      getRemPunishmentContentsWithBizseq(this.tswrittemplate).then(res => {
        if (res.code === 0) {
          this.$nextTick(() => {
            this.$set(this.tswrittemplate, 'content', res.data.content)
            this.$set(this.tswrittemplate, 'writsType', res.data.writsType)
            this.$set(this, 'eidtContent', res.data.content)
          })
        }
      })
    }
  },
  components: {
    DetailHead,
    Editor
  }
}
</script>

<style lang="scss" scoped>
.el-row.flex-row{
  display: flex;
  .el-col{
    display: flex;
    .el-form-item{
      width: 100%;
      display: flex;
      /deep/ .el-form-item__label{
        flex-shrink: 0;
      }
      /deep/ .el-form-item__content{
        width: 100%;
        min-height: 60px;
        margin-left: 0px!important;
      }
    }
  }
}
.uploadFileList.disabled{
  /deep/ .el-upload{
    display: none;
  }
}
.main-content{
  font-size: $table-content-font-size;
  /deep/ .el-form-item__content{
    padding: 5px;
  }
  .back-btn{
    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{
        text-align: left;
        padding-left: 20px;
        label{
          color: #000;
          font-weight: bold;
          display:inline-block;
        }
      }
    }
    .form{
      margin-bottom: 20pt;
    }
  }
  .span-content{
    display: block;
    text-indent: 1em;
  }
}
.el-row {
  border-left: 1px solid $color-border;
}
.bt0 {
  /deep/.el-form-item__label{
    border-top: 0!important;
  }
  /deep/.el-form-item__content{
    border-top: 0!important;
  }
}

.main-content.abnormal{
  .el-form-item{
    margin-bottom:0;
    background: $color-form-label;
    .el-form-item__label{
      padding: 10px;
      border-top: 1px solid $color-border;
      font-size: $table-content-font-size;
    }
    .el-form-item__content{
      font-size: 16px;
      background: white;
      font-size: $table-content-font-size;
      border-top: 1px solid $color-border;
      border-right: 1px solid $color-border;
      border-left: 1px solid $color-border;
      padding: 10px;
    }
  }
  .el-form-item:last-child{
    border-bottom: 1px solid $color-border;
  }
  .form-body.history{
    padding:15px;
    border:1px solid $color-border;
  }
  .form-body.history .none{
    font-size: 14px;
  }

  .el-form-item.is-error .custom .el-input__inner{
    border-color:$color-border;
  }
  .el-table-column--selection .cell {
    padding-right: 0px;
  }
  .no {
    padding-left: 0px;
  }
  .el-table_9_column_61.is-left.is-leaf{
    .cell{
      padding-left: 0px;
      padding-right: 0px;
    }
  }
  .el-pagination{
    text-align: right;
  }
  .dialog-box{
    text-align: right;
  }
  .el-textarea.is-disabled .el-textarea__inner{
    color: #1c1e23;
  }
  .el-input.is-disabled .el-input__inner

  .el-input__inner{
    width: 50%;
  }
  .uploadFileList{
    .el-upload-list__item{
      display: inline-block;
      width: auto;
    }
  }
}
@media print{
  /* 浏览区域 */
  .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 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;
  }
  .printPaper{
    width:700PX;
    min-height:891PX;
    background:white;
    padding:40PX 50PX;
  }
  .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: 40px; //行间距
    font-size: 24px
  }
  .mr20 {
    margin-right: 20px;
  }
  .printPaper{
    min-height:891PX;
    background:white;
    padding:40PX 50PX;
    .el-divider--horizontal {
      margin: 8px 0;
      background: 0 0;
      border-top: 1px dashed #18191a;
    }
  }
  @page {
    size: auto;
    margin: 0mm;
  }
}
</style>
