<template>
  <!-- <el-dialog
    title="查看"
    width="70%"
    :close-on-click-modal="false"
    :visible.sync="visible"> -->
  <div>
    <div class="my-title">查看</div>
    <div style="margin-left: 20px;margin-right: 20px">
      <!-- 工作流 -->
      <div v-show="dataForm.workFlowBusinessExt">
        <el-steps :active="dataForm.workFlowBusinessExt&&dataForm.workFlowBusinessExt.workFlowProcessStepList?dataForm.workFlowBusinessExt.workFlowProcessStepList.length + 2:0" align-center style="margin-bottom: 20px">
          <template v-for="(item, i) in stepList">
            <el-step :icon="item.icon" :title="item.title" :description="item.description"></el-step>
          </template>
        </el-steps>
        <el-collapse style="margin-bottom: 20px">
          <el-collapse-item>
            <template slot="title">
              <span style="color: red">审批日志（展开查看更多）：</span>
            </template>
            <template v-for="(item, i) in logList">
              <div>{{++i}}：{{item.approverName}}  {{item.createTime}}  {{item.approvalValue}}</div>
            </template>
          </el-collapse-item>
        </el-collapse>
      </div>
      <div v-if="isFlow">
        <approve-component ref="approve" @approveFinished="approveFinished"/>
      </div>
      <e-desc title="基本信息" column="3">
        <e-desc-item label="评审编码">{{dataForm.reCode}}</e-desc-item>
        <e-desc-item label="沟通编码">{{dataForm.coCode}}</e-desc-item>
        <e-desc-item label="评审类别">{{dataForm.reTypeValue}}</e-desc-item>
        <e-desc-item label="客户名称">{{dataForm.customerName}}</e-desc-item>
        <e-desc-item label="联系人" span="2">{{dataForm.bizManagerName}}</e-desc-item>
        <e-desc-item label="备注说明" span="3">{{dataForm.notes}}</e-desc-item>
        <e-desc-item label="与产品有关要求的明确性、符合性" span="3">
          1、顾客对产品的要求与潜在要求是否明确 -- {{ dataForm.part11 ? '是' : '否' }}
          <br>
          2、合同的合法性、完性整性、规范性 -- {{ dataForm.part12 ? '是' : '否' }}
        </e-desc-item>
        <e-desc-item label="风险控制能力" span="3">
          1、图样和技术要求能否满足生产要求，产品服务和培训能否满足要求 -- {{ dataForm.part21 ? '是' : '否' }}
          <br>
          2、外购器材风险的控制情况，能否保障生产 -- {{ dataForm.part22 ? '是' : '否' }}
          <br>
          3、质量控制情况能否满足要求（生产、检验和验收设备能否满足要求） -- {{ dataForm.part23 ? '是' : '否' }}
          <br>
          4、财务能否满足生产要求（成本、价格、结算方式与付款能否接受） -- {{ dataForm.part24 ? '是' : '否' }}
          <br>
          5、规格数量能否满足，运输、交货方式能否满足，生产进度能否满足 -- {{ dataForm.part25 ? '是' : '否' }}
        </e-desc-item>
        <e-desc-item label="满足规定要求的能力" span="3">
          项目组对履行承诺的风险（包括技术、质量、生产能力、进度、经费）识别： {{ dataForm.part31 === 1 ? '高' : dataForm.part31 === 2 ? '中' : '低' }}
          <br>
          控制能力： {{ dataForm.part32 === 1 ? '可控' : dataForm.part32 === 2 ? '基本可控' : '不可控' }}
          <br>
          采取措施： {{ dataForm.takeStep || '无' }}
        </e-desc-item>
      </e-desc>
      <e-desc title="沟通信息表附件">
        <upload-component :display="true" :display-title="false" :accept="'*'" :file-obj-list="fileList1"/>
      </e-desc>
      <e-desc title="合同评审表">
        <upload-component :display="true" :display-title="false" :accept="'*'" :file-obj-list="fileList"/>
      </e-desc>
    </div>
    <span slot="footer" class="dialog-footer">
      <el-button @click="onChose">返回</el-button>
    </span>
  </div>
  <!-- </el-dialog> -->
</template>

<script>
  import EDesc from '../common/e-desc'
  import EDescItem from '../common/e-desc-item'
  import { geTreDetail } from '@/api/cus'
  import uploadComponent from '../common/upload-component'
  import { dealStepData, dealStepLogs } from '@/api/util'
  import ApproveComponent from '../common/approve-component'
  export default {
    name: 'contract-detail',
    components: {
      EDesc, EDescItem, uploadComponent, ApproveComponent
    },
    data () {
      return {
        visible: false,
        isFlow: false,
        id: 0,
        dataForm: {},
        cusRCommProductVOS: [],
        fileList: [],
        fileList1: [],
        stepList: [],
        logList: []
      }
    },
    methods: {
      onChose () {
        this.$emit('onChose')
      },
      async init (id, businessType) {
        this.visible = true
        this.isFlow = !!(businessType && businessType !== '')
        this.id = id || 0
        this.dataForm = {}
        this.cusRCommProductVOS = []
        this.fileList = []
        this.fileList1 = []
        this.stepList = []
        this.logList = []
        this.getDetails(businessType)
      },
      getDetails (businessType) {
        geTreDetail(this.id).then(({data}) => {
          if (data && data.code === '200') {
            this.dataForm = data.data
            // 流程图展示
            if (data.data.workFlowBusinessExt) {
              dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
              dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
            }
            // 合同评审表附件显示
            this.fileList = []
            data.data.attachList.forEach((item) => {
              this.fileList.push({
                name: item.fileName,
                url: item.url,
                id: item.url
              })
            })
            // 沟通信息表附件显示
            this.fileList1 = []
            data.data.communicationAttachList.forEach((item) => {
              this.fileList1.push({
                name: item.fileName,
                url: item.url,
                id: item.url
              })
            })
            // 初始化审批Form
            this.showApproveForm(businessType, this.id)
          }
        })
      },
      // 初始化审批Form
      showApproveForm (businessType, businessId) {
        if (this.isFlow) {
          this.$nextTick(() => {
            this.$refs.approve.init(businessType, businessId)
          })
        }
      },
      // 审批完成
      approveFinished () {
        this.onChose()
        this.$emit('approveFinished')
      }
    }
  }
</script>

<style scoped>
.my-line{
  border-bottom: 1px solid #c0c4cc;
  margin-bottom: 10px;
}
.title{
  padding: 10px 0 ;
}
</style>
