<template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  <div>
    <el-row>
      <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="true"
               label-width="135px" @submit.native.prevent>

        <el-divider content-position="left"><i class="el-icon-document"></i> 项目信息</el-divider>
        <el-row  :gutter="0">
          <el-col :span="12">
            <el-form-item label="项目名称" prop="projectName"
                          :rules="[
                              {required: true, message:'项目名称不能为空', trigger:'blur'},
                              {required: true, message:'项目名称不能为空', trigger:'change'}
                   ]">
              <!--                <el-input v-model="inputForm.projectName" placeholder="请填写项目名称" clearable></el-input>-->
              <el-input size="medium" :readonly="true" @focus="openContractForm()" v-model="inputForm.projectName" placeholder="请选择项目名称">
                <el-button slot="append" icon="el-icon-search" @click="openContractForm()"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目编号" prop="projectNumber"
                          :rules="[
                   ]">
              <el-input :disabled="true" v-model="inputForm.projectNumber" placeholder="请填写项目编号" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="项目经理" prop="projectMasterName"
                          :rules="[
                   ]">
              <el-input :disabled="true" v-model="inputForm.projectMasterName" placeholder="请填写项目经理" clearable></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="left"><i class="el-icon-document"></i> 基础信息</el-divider>
        <el-row  :gutter="0">
          <el-col :span="12">
            <el-form-item label="单据编号" prop="documentNo"
                          :rules="[

                   ]">
              <el-input :disabled="true" v-model="inputForm.documentNo" placeholder="自动生成" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告所属部门" prop="officeId"
                          :rules="[
                   ]">
              <SelectTree
                ref="officeTree"
                :props="{
                  value: 'id',             // ID字段名
                  label: 'name',         // 显示名称
                  children: 'children'    // 子级字段名
                }"

                :url="`/sys/office/treeData?type=2`"
                :value="inputForm.officeId"
                size="medium"
                :accordion="true"
                @getValue="(value) => {inputForm.officeId=value}"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="盖章类型" prop="signatureType"
                          :rules="[
                              {required: true, message: '盖章类型不能为空', trigger: 'blur'}
                   ]">
              <!--                <el-input v-model="inputForm.signatureType" placeholder="请填写盖章类型" clearable></el-input>-->
              <el-select v-model="inputForm.signatureType" placeholder="请选择盖章类型" clearable style="width: 100%;">
                <el-option
                  v-for="item in $dictUtils.getDictList('cw_signature_type')"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col v-if="inputForm.signatureType === '1' || commonJS.isEmpty(inputForm.signatureType)" :span="12">
            <el-form-item label="签字注师1" prop="signatureAnnotator1"
                          :rules="[
                   ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator1" placeholder="请填写签字注师1" clearable></el-input>-->
              <UserSelect size="medium" ref="userSelect1" :disabled="true" :readonly="true" :limit='1' :value="inputForm.signatureAnnotator1" @getValue='(value) => {changeSignatory1(value)}'></UserSelect>
            </el-form-item>
          </el-col>

          <el-col v-if="inputForm.signatureType === '1' || commonJS.isEmpty(inputForm.signatureType)" :span="12">
            <el-form-item label="签字注师2" prop="signatureAnnotator2"
                          :rules="[
                   ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator2" placeholder="请填写签字注师2" clearable></el-input>-->
              <UserSelect size="medium" ref="userSelect2" :disabled="true" :readonly="true" :limit='1' :value="inputForm.signatureAnnotator2" @getValue='(value) => {changeSignatory2(value)}'></UserSelect>
            </el-form-item>
          </el-col>

          <el-col v-if="inputForm.signatureType === '2'" :span="12">
            <el-form-item label="签字注师1" prop="signatureAnnotator1"
                          :rules="[
                              {required: true, message:'签字注师1不能为空', trigger:'blur'}
                   ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator1" placeholder="请填写签字注师1" clearable></el-input>-->
              <UserSelect size="medium" ref="userSelect1" :disabled="true" :readonly="true" :limit='1' :value="inputForm.signatureAnnotator1" @getValue='(value) => {changeSignatory1(value)}'></UserSelect>
            </el-form-item>
          </el-col>

          <el-col v-if="inputForm.signatureType === '2'" :span="12">
            <el-form-item label="签字注师2" prop="signatureAnnotator2"
                          :rules="[
                              {required: true, message:'签字注师2不能为空', trigger:'blur'}
                   ]">
              <!--                <el-input v-model="inputForm.signatureAnnotator2" placeholder="请填写签字注师2" clearable></el-input>-->
              <UserSelect size="medium" ref="userSelect2" :disabled="true" :readonly="true" :limit='1' :value="inputForm.signatureAnnotator2" @getValue='(value) => {changeSignatory2(value)}'></UserSelect>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="审计收费（元）" prop="auditFees"
                          :rules="[
                   ]">
              <el-input v-model="inputForm.auditFees" placeholder="请填写审计收费（元）" clearable></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="报告实际制作人" prop="realCreate"
                          :rules="[
                   ]">
              <UserSelect size="medium" :readonly="true" :disabled="true" :limit='1' :value="inputForm.realCreate" @getValue='(value) => {inputForm.realCreate = value}'></UserSelect>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="创建时间" prop="createDate"
                          :rules="[
                   ]">
              <el-input :disabled="true" v-model="inputForm.createDate" placeholder="请填写创建时间" clearable></el-input>
            </el-form-item>
          </el-col>

        </el-row>
        <el-divider content-position="left"><i class="el-icon-document"></i> 详细信息</el-divider>
        <el-row  :gutter="0">
          <el-col :span="12">
            <el-form-item label="被服务单位" prop="servedUnitName"
                          :rules="[
                            {required: true, message:'被服务单位不能为空', trigger:'blur'}
                   ]">
              <el-input @focus="openWorkClient()" v-model="inputForm.servedUnitName" placeholder="请填写被服务单位" clearable>
                <el-button slot="append" icon="el-icon-search" @click="openWorkClient()"></el-button>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告日期" prop="reportDate"
                          :rules="[
                            {required: true, message:'报告日期不能为空', trigger:'blur'}
                   ]">
              <el-date-picker
                placement="bottom-start"
                value-format="yyyy-MM-dd"
                v-model="inputForm.reportDate"
                style="width: 100%"
                placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告类型" prop="reportType"
                          :rules="[
                            {required: true, message:'报告类型不能为空', trigger:'blur'}
                   ]">
              <el-select v-model="inputForm.reportType" placeholder="请选择报告类型" style="width:100%;">
                <el-option
                  v-for="item in $dictUtils.getDictList('cw_report_type')"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告流水号" prop="reportNumber"
                          :rules="[
                   ]">
              <el-input :disabled="true" v-model="inputForm.reportNumber" placeholder="自动生成" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="报告文号" prop="reportNo"
                          :rules="[
                   ]">
              <el-input :disabled="true" v-model="inputForm.reportNo" placeholder="自动生成" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-form size="middle" :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''"  :disabled="true"
                   label-width="135px" @submit.native.prevent>
            <el-col :span="12">
              <el-form-item label="意见类型" prop="opinionType"
                            :rules="[
                     ]">
                <el-select v-model="inputForm.opinionType" placeholder="请选择意见类型" style="width:100%;">
                  <el-option
                    v-for="item in $dictUtils.getDictList('cw_opinion_type')"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-form>
          <el-col :span="12">
            <el-form-item label="盖章状态" prop="sealType"
                          :rules="[
                   ]">
              <el-input :disabled="true" v-model="inputForm.sealType" placeholder="请填写盖章状态" clearable></el-input>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <el-tabs v-model="activeName" type="border-card" @tab-click="tabHandleClick">
        <!--        <el-tab-pane label="报告信息列表" name="newRow">-->
        <!--          <el-button type="primary" style="margin-bottom: 15px" size="mini" :disabled="true" @click="sss"-->
        <!--          >-->
        <!--            新增行-->
        <!--          </el-button>-->
        <!--        </el-tab-pane>-->
        <el-tab-pane label="附件" name="archiveFile">
          <!--        附件-->
          <UpLoadComponent ref="archiveFile" @clickSign="clickSign"></UpLoadComponent>
        </el-tab-pane>


      </el-tabs>
    </el-row>
    <!--    <UpLoadComponentDialog ref="upLoadComponentDialog" @getUpload="getUpload"></UpLoadComponentDialog>-->
    <!--    <ProjectInfoForm  ref="projectInfoForm" @getContract="getContract"></ProjectInfoForm>-->
    <ProjectRecoredChooseCom  ref="projectRecoredChooseCom" @getProject="getContract"></ProjectRecoredChooseCom>
    <ReportServiceUnitForm ref="reportServiceUnitForm" @getWorkClientChoose="getWorkClientChoose"></ReportServiceUnitForm>
  </div>
</template>

<script>
  // import UpLoadComponent from '@/views/common/UpLoadComponent'
  import UpLoadComponent from '@/views/common/UpLoadComponentV2.1'
  import SelectUserTree from '@/views/modules/utils/treeUserSelect'
  import SelectTree from '@/components/treeSelect/treeSelect.vue'
  import UserSelect from '../workClientInfo/clientUserSelect'
  import ProjectRecordsService from '@/api/cw/projectRecords/ProjectRecordsService'
  import ProjectReportService from '@/api/cw/reportManagement/ProjectReportService'
  import EnterpriseSearchService from '@/api/cw/common/EnterpriseSearchService'
  // import WorkClientChooseForm from '../workClientInfo/WorkClientChooseForm'
  import ReportServiceUnitForm from './ReportServiceUnitForm'
  // import UpLoadComponentDialog from '@/views/common/UpLoadComponentDialog'
  // import ProjectInfoForm from './ProjectInfoForm'
  import ProjectRecoredChooseCom from '../projectRecords/ProjectRecordsChooseCom'
  export default {
    props: {
      businessId: {
        type: String,
        default: ''
      },
      formReadOnly: {
        type: Boolean,
        default: false
      },
      status: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        title: '',
        method: '',
        loading: false,
        inputForm: {
          opinionType: '',
          reportNo: '',
          reportNumber: '',
          reportType: '',
          reportDate: '',
          servedUnitName: '', // 被服务单位
          auditFees: '',
          projectId: '',
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: JSON.parse(localStorage.getItem('user')).name
          },
          remarks: '',
          documentNo: '',
          projectName: '',
          projectNumber: '',
          officeId: '',
          signatureAnnotator1: '',
          signatureAnnotator2: '',
          signatureType: '',
          projectMasterName: '',
          cwProjectInfoList: [],
          cwFileInfoList: [],
          servedUnitId: '',
          status: '',
          status1: '',
          status2: '',
          realCreate: ''
        },
        keyWatch: '',
        activeName: 'archiveFile',
        tableKey: '',
        tableKeyClient: '1',
        interVal: ''
      }
    },
    projectRecordsService: null,
    ProjectReportService: null,
    enterpriseSearchService: null,
    created () {
      this.enterpriseSearchService = new EnterpriseSearchService()
      this.projectRecordsService = new ProjectRecordsService()
      this.projectReportService = new ProjectReportService()
    },
    deactivated () {
      // 页面关闭（路由跳转）时清除定时器
      clearInterval(this.interVal)
    },
    computed: {
      bus: {
        get () {
          this.$refs.archiveFile.setDividerName('附件', false)
          // this.$refs.uploadComponent.setDividerName('附件', false)
          return this.businessId
        },
        set (val) {
          this.businessId = val
        }
      }
    },
    watch: {
      'keyWatch': {
        handler (newVal) {
          if (this.commonJS.isNotEmpty(this.bus)) {
            this.init('', this.bus)
          } else {
            this.$nextTick(() => {
              this.$refs.inputForm.resetFields()
            })
          }
        }
      }
    },
    components: {
      SelectUserTree,
      UpLoadComponent,
      SelectTree,
      UserSelect,
      ReportServiceUnitForm,
      // ProjectInfoForm,
      ProjectRecoredChooseCom
      // UpLoadComponentDialog
    },
    methods: {
      getKeyWatch (keyWatch) {
        this.keyWatch = keyWatch
      },
      changeSignatory1 (value) {
        if (this.inputForm.signatureAnnotator2 === value && this.commonJS.isNotEmpty(value)) {
          this.$message.warning('首次发行签字注师1和首次发行签字注师2不可以相同')
          this.$nextTick(() => {
            this.inputForm.signatureAnnotator1 = ''
            this.$refs.userSelect1.changeNameValue('')
            this.$refs.userSelect1.clearSelectData()
            this.$forceUpdate()
          })
        } else {
          this.inputForm.signatureAnnotator1 = value
        }
      },
      changeSignatory2 (value) {
        if (this.inputForm.signatureAnnotator1 === value && this.commonJS.isNotEmpty(value)) {
          this.$message.warning('首次发行签字注师1和首次发行签字注师2不可以相同')
          this.$nextTick(() => {
            this.inputForm.signatureAnnotator2 = ''
            this.$refs.userSelect2.changeNameValue('')
            this.$refs.userSelect2.clearSelectData()
            this.$forceUpdate()
          })
        } else {
          this.inputForm.signatureAnnotator2 = value
        }
      },
      init (method, id) {
        this.activeName = 'archiveFile'
        this.projectRecordsService = new ProjectRecordsService()
        this.projectReportService = new ProjectReportService()
        this.method = method
        this.inputForm = {
          servedUnitId: '',  // 被服务单位id
          opinionType: '',
          reportNo: '',
          reportNumber: '',
          reportType: '',
          reportDate: '',
          servedUnitName: '', // 被服务单位
          auditFees: '',
          projectId: '',
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: JSON.parse(localStorage.getItem('user')).name
          },
          remarks: '',
          documentNo: '',
          projectName: '',
          officeId: '',
          projectNumber: '',
          signatureAnnotator1: '',
          signatureAnnotator2: '',
          signatureType: '',
          projectMasterName: '',
          cwProjectInfoList: [],
          status: '',
          status1: '',
          status2: '',
          realCreate: '',
          sid1: '',
          sid2: '',
          signatureContractId: ''
        }
        this.inputForm.id = id
        this.loading = false
        this.$nextTick(() => {
          this.$refs.archiveFile.clearUpload()
          this.$refs.inputForm.resetFields()
          this.loading = true
          this.projectReportService.queryBySignatureId(this.inputForm.id).then(({data}) => {
            this.inputForm.status = data.status
            // this.$refs.uploadComponent.clearUpload()
            this.inputForm = this.recover(this.inputForm, data)
            this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
            if (this.commonJS.isEmpty(this.inputForm.createDate)) {
              this.inputForm.createDate = this.moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
            }
            if (this.commonJS.isEmpty(this.inputForm.officeId)) {
              this.inputForm.officeId = JSON.parse(localStorage.getItem('user')).officeDTO.id
            }
            if (this.commonJS.isEmpty(this.inputForm.realCreate)) {
              this.inputForm.realCreate = JSON.parse(localStorage.getItem('user')).id
            }
            if (this.commonJS.isNotEmpty(this.inputForm.signatureContractId) && this.status === 'audit') {
              this.$refs.archiveFile.newUpload('view', data.cwFileInfoList, 'cwWorkContract', null, null, null, null, false, 'audit')
            } else {
              this.$refs.archiveFile.newUpload('view', data.cwFileInfoList, 'cwWorkContract', null, null, null, null, false)
            }
            this.loading = false
            if (this.status === 'audit') {
              this.$emit('callBackFunc', 'hide')
              this.jobScheduler()
            }
          })
        })
      },
      openContractForm () {
        if (!this.commonJS.isEmpty(this.inputForm.contractId)) {
          // this.$refs.projectInfoForm.init(this.inputForm.contractId)
          this.$refs.projectRecoredChooseCom.init(this.inputForm.contractId)
        } else {
          this.$refs.projectRecoredChooseCom.init()
          // this.$refs.projectInfoForm.init()
        }
      },
      getContract (row) {
        this.inputForm.projectName = row.projectName // 项目名称
        this.inputForm.projectId = row.id // 项目id
        this.inputForm.projectNumber = row.projectNumber // 项目编号
        this.inputForm.projectMasterName = row.projectMasterName // 项目经理
        this.clearClientList()
        this.$forceUpdate()
        this.inputForm.cwProjectInfoList = []
      },
      clearClientList () {
        // 项目直接对接联系人列表清除
        this.inputForm.clientList = []
        this.$forceUpdate()
      },
      saveForm (callback) {
        this.doSubmit('save', callback)
      },
      startForm (callback) {
        // this.doSubmit('start', callback)
        this.loading = true
        this.projectReportService.saveData(this.inputForm).then(({data}) => {
          if (this.inputForm.signatureType === '2') {
            this.inputForm.assignee = this.inputForm.signatureAnnotator1
          }
          callback(data.businessTable, data.businessId, this.inputForm)
          this.loading = false
          throw new Error()
        }).catch(() => {
          this.loading = false
          throw new Error('流程发起失败')
        })
      },
      async agreeForm (callback) {
        if (this.inputForm.signatureType === '1') {
          this.projectReportService.findBySignatureId(this.inputForm.sid1).then(({data}) => {
            if (data.status !== '2') { // status的值不等于“审核中”就弹出提示
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error()
            } else {
              let param = {status: '5', id: this.inputForm.sid1}
              this.projectReportService.updateSignatureStatusById(param)
              let table = 'cw_project_report_signature'
              callback(table, this.inputForm.sid1, this.inputForm)
            }
          })
        }
        if (this.inputForm.signatureType === '2') {
          this.projectReportService.findBySignatureId(this.inputForm.sid2).then(({data}) => {
            if (data.status !== this.inputForm.status2) { // status的值不等于“审核中”就弹出提示
              this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
              throw new Error()
            } else {
              this.projectReportService.getAuditNodeByReportId(this.inputForm.sid2).then(({data}) => {
                console.log('data', data)
                if (data.signatureType === '签字注师1审核') {
                  let param = {status: '6', id: this.inputForm.sid2}
                  this.projectReportService.updateSignatureStatusById(param)
                  this.inputForm.assignee = this.inputForm.signatureAnnotator2
                  let table = 'cw_project_report_signature'
                  callback(table, this.inputForm.sid2, this.inputForm)
                }
                if (data.signatureType === '签字注师2审核') {
                  let param = {status: '7', id: this.inputForm.sid2}
                  this.projectReportService.updateSignatureStatusById(param)
                  callback()
                }
                if (data.signatureType === '签章管理人审核') {
                  let param = {status: '5', id: this.inputForm.sid2}
                  this.projectReportService.updateSignatureStatusById(param)
                  callback()
                }
              })
            }
          })
        }
      },
      async updateStatusById (type) {
        if (await this.$refs.archiveFile.checkProgress()) {
          this.loading = false
          throw new Error()
        } else {
          if (type === 'reject' || type === 'reback') {
            if (this.inputForm.signatureType === '1') {
              await this.projectReportService.findBySignatureId(this.inputForm.sid1).then(({data}) => {
                if (data.status !== this.inputForm.status1) { // status的值不等于“审核中”就弹出提示
                  this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                  throw new Error()
                } else {
                  if (type === 'reject') {
                    // 驳回
                    let param = {status: '4', id: data.id}
                    this.projectReportService.updateSignatureStatusById(param)
                  }
                  if (type === 'reback') {
                    // 撤回
                    let param = {status: '3', id: data.id}
                    this.projectReportService.updateSignatureStatusById(param)
                  }
                }
              })
            }
            if (this.inputForm.signatureType === '2') {
              await this.projectReportService.findBySignatureId(this.inputForm.sid2).then(({data}) => {
                if (data.status !== this.inputForm.status2) { // status的值不等于“审核中”就弹出提示
                  this.$message.error('任务数据已发生改变或不存在，请在待办任务中确认此任务是否存在')
                  throw new Error()
                } else {
                  if (type === 'reject') {
                    // 驳回
                    let param = {status: '4', id: data.id}
                    this.projectReportService.updateSignatureStatusById(param)
                  }
                  if (type === 'reback') {
                    // 撤回
                    let param = {status: '3', id: data.id}
                    this.projectReportService.updateSignatureStatusById(param)
                  }
                }
              })
            }
          }
        }
      },
      close () {
        this.inputForm = {
          id: '',
          createDate: '',
          createBy: {
            id: '',
            name: JSON.parse(localStorage.getItem('user')).name
          },
          remarks: '',
          documentNo: '',
          projectName: '',
          officeId: '',
          projectNumber: '',
          signatureAnnotator1: '',
          signatureAnnotator2: '',
          signatureType: '',
          projectMasterName: '',
          realCreate: '',
          status: '',
          status1: '',
          status2: ''
        }
        // this.$refs.uploadComponent.clearUpload()
        this.$refs.inputForm.resetFields()
      },
      tabHandleClick (event) {
        // console.log(event)
      },
      // 删除
      removeEvent (row, rowIndex, type) {
        if (type === 'client') {
          // this.$refs.clientTable.remove(row)
          // this.inputForm.cwProjectInfoList.splice(rowIndex, 1)
        }
      },
      openWorkClient () {
        this.$refs.reportServiceUnitForm.init(this.inputForm.projectId)
      },
      getWorkClientChoose (list) {
        // if (this.commonJS.isEmpty(this.inputForm.cwProjectInfoList)) {
        //   this.inputForm.cwProjectInfoList = []
        // }
        // eslint-disable-next-line no-unused-vars
        let _this = this
        let _list = list
        const waitForEach = function () {
          return new Promise(function (resolve, reject) {
            _list.forEach((item) => {
              // _this.inputForm.cwProjectInfoList.forEach(client => {
              //   if (item.id === client.servedUnitId) {
              //     // _this.$message.error('已存在客户 “' + client.servedUnitName + '”，请重新选择')
              //     // throw new Error('已存在客户 “' + client.servedUnitName + '”，请重新选择')
              //   }
              // })
            })
            resolve()
          })
        }
        waitForEach().then(() => {
          list.forEach(item => {
            // eslint-disable-next-line no-unused-vars
            // let d = {
            //   servedUnitName: item.name, // 被服务单位名称
            //   // reportNumber: this.inputForm.projectNumber + '-0' + (this.inputForm.cwProjectInfoList.length + 1), // 报告流水号
            //   issueReport: '是',
            //   sealType: '未盖章',
            //   id: this.uuid,
            //   servedUnitId: item.id
            // }
            // this.$refs.clientTable.insertAt(d)
            // this.inputForm.cwProjectInfoList.push(d)
            this.inputForm.servedUnitName = item.name
            this.inputForm.servedUnitId = item.id
            this.inputForm.sealType = '未盖章'
            this.tableKeyClient = Math.random()
          })
        })
      },
      clickSign () {
        this.projectReportService.saveFlowableParam(this.inputForm).then(({data}) => {
          window.open(data, '_blank')
        })
      },
      jobScheduler () {
        this.interVal = setInterval(() => {
          console.log('正在访问签章状态...')
          if (this.inputForm.signatureType === '1') {
            this.projectReportService.getAuditNodeByReportId(this.inputForm.sid1).then(({data}) => {
              if (data.success) {
                this.projectReportService.getSignatureTypeById(this.inputForm.sid1, data.signatureType).then((sign) => {
                  console.log('获取签章状态为' + sign.data.signatureType)
                  if (sign.data.signatureType === '1') {
                    console.log('签章已完成,展示‘同意’按钮')
                    this.$emit('callBackFunc', 'show')
                    this.$refs.archiveFile.hideSign() // 隐藏签章按钮
                    clearInterval(this.interVal)
                    this.showConfirm() // 提示签章操作已完成
                  }
                })
              }
            })
          }
          if (this.inputForm.signatureType === '2') {
            this.projectReportService.getAuditNodeByReportId(this.inputForm.sid2).then(({data}) => {
              if (data.success) {
                this.projectReportService.getSignatureTypeById(this.inputForm.sid2, data.signatureType).then((sign) => {
                  console.log('获取签章状态为' + sign.data.signatureType)
                  if (sign.data.signatureType === '1') {
                    console.log('签章已完成,展示‘同意’按钮')
                    this.$emit('callBackFunc', 'show')
                    this.$refs.archiveFile.hideSign() // 隐藏签章按钮
                    clearInterval(this.interVal)
                    this.showConfirm() // 提示签章操作已完成
                  }
                })
              }
            })
          }
        }, 2000)
      },
      showConfirm () {
        this.$confirm(`签章操作已完成，请进行审核操作`, '提示', {
          confirmButtonText: '确定',
          type: 'warning'
        })
      }
    }
  }
</script>
<style scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
