<!-- 相关素材查看——陈昭宇 -->
<template>
  <div>
    <dialog-edit
      :visible.sync="dialogVisible"
      :form="dialogForm"
      :api="api"
      :editModel="editModel"
      :title="$t('common.view')"
      :footerVisible="footerVisible"
      width="1480px">
      <template>
        <!-- 关联反馈素材相关列表 -->
        <data-table
          :sourceData.sync="sourceData1"
          :columns="columns1"
          :api="api"
          :queryParas="searchFormQueryParas"
          :headTitleFlag="headTitleFlag"
          operateBtnLayout=""
          :headTitle="$t('relatedMaterialIndex.feedbackDetailList')"
          loadPage="getFeedbackList"
          max-height="200px"
          :loadCount.sync="loadCount">
          <!-- 附件 -->
          <el-table-column :label="$t('relatedMaterialIndex.reviewFileName')" align="center" width="80px" fixed="right">
            <template slot-scope="scope">
              <!-- 附件按钮 -->
              <btn-batch-download v-if="scope.row.fileIds !== '' ? true : false"
                                  :fileID="fBatchDownload(scope.row)"
                                  :title="$t('common.downLoad')"
                                  size="small"></btn-batch-download>
            </template>
          </el-table-column>
          <!-- 文字超多 出折叠收起功能 -->
          <template slot="institutionOpinions" slot-scope="scope">
            <span-plus :text="scope.data.row.institutionOpinions"></span-plus>
          </template>
          <!-- 文字超多 出折叠收起功能 -->
          <template slot="hgOpinions" slot-scope="scope">
            <span-plus :text="scope.data.row.hgOpinions"></span-plus>
          </template>
        </data-table>
        <!-- 关联评审素材信息列表 -->
        <data-table
          :sourceData.sync="sourceData2"
          :columns="columns2"
          :api="api"
          :queryParas="searchFormQueryParas"
          :headTitleFlag="headTitleFlag"
          operateBtnLayout=""
          max-height="200px"
          :headTitle="$t('relatedMaterialIndex.reviewDetailList')"
          loadPage="getReviewList"
          :loadCount.sync="loadCount">
          <!-- 附件 -->
          <el-table-column :label="$t('relatedMaterialIndex.reviewFileName')" align="center" width="80px" fixed="right">
            <template slot-scope="scope">
              <!-- 附件按钮 -->
              <btn-batch-download v-if="scope.row.fileIds !== '' ? true : false"
                                  :fileID="fBatchDownload(scope.row)"
                                  :title="$t('common.downLoad')"
                                  size="small"></btn-batch-download>
            </template>
          </el-table-column>
        </data-table>
      </template>
      <!-- 解决弹窗抖动问题 -->
      <div style="height:1px"></div>
    </dialog-edit>
  </div>
</template>

<script>
import { DialogEdit, authButton, DataTable, btnBatchDownload, SpanPlus } from 'newepoch-components'
import BaseEditPage from '@/pages/baseEditPage'
import * as format from '@/filters/index'
import knowledgeBaseApi from '@/api/assetaudit/knowledgeBaseApi'
export default {
  extends: new BaseEditPage(),
  props: {
    keyId: {
      type: [String],
      required: true
    }
  },
  components: {
    DialogEdit,
    authButton,
    DataTable,
    format,
    btnBatchDownload,
    SpanPlus
  },
  data () {
    return {
      dialogForm: {},
      footerVisible: true,
      sourceData1: [],
      sourceData2: [],
      searchFormQueryParas: {
        pageIndex: 1,
        pageSize: 10,
        knowledgeBaseId: ''
      },
      headTitleFlag: true,
      // 反馈素材一览
      columns1: [
        // 反馈素材编号
        {
          prop: 'materialNo',
          align: 'left',
          label: this.$t('relatedMaterialIndex.feedbackMaterialNo'),
          width: '160px'
        },
        // 产品类型
        {
          prop: 'businessType',
          align: 'center',
          label: this.$t('relatedMaterialIndex.feedbackBusinessType'),
          width: '120px',
          format: (row) => {
            // return format.formatDict(row.businessType, 'BUSINESS_TYPE') // 原代码
            return format.formatDict(row.businessType, 'ZD0087') // 临时使用代码
          }
        },
        // 素材来源
        {
          prop: 'materialSourceType',
          align: 'center',
          label: this.$t('relatedMaterialIndex.feedbackMaterialSourceType'),
          width: '120px',
          format: (row) => {
            return format.formatDict(row.materialSourceType, 'MATERIAL_SOURCE')
          }
        },
        // 付款确认书编号
        {
          prop: 'payCode',
          align: 'left',
          label: this.$t('relatedMaterialIndex.feedbackPayCode'),
          width: '200px'
        },
        // 项目
        {
          prop: 'productName',
          align: 'left',
          label: this.$t('relatedMaterialIndex.feedbackProductName'),
          width: '200px'
        },
        // 期数
        {
          prop: 'issue',
          align: 'center',
          label: this.$t('relatedMaterialIndex.feedbackIssue'),
          width: '120px',
          format: (row) => {
            if (row.issue === 0) {
              return ''
            } else {
              return row.issue
            }
          }
        },
        // 第三方机构反馈意见
        {
          prop: 'institutionOpinions',
          align: 'left',
          label: this.$t('relatedMaterialIndex.feedbackInstitutionOpinions'),
          width: '200px',
          slot: true
        },
        // 合规反馈
        {
          prop: 'hgOpinions',
          align: 'left',
          label: this.$t('relatedMaterialIndex.feedbackHgOpinions'),
          width: '200px',
          slot: true
        },
        // 分析时间
        {
          prop: 'analysisTime',
          align: 'center',
          label: this.$t('relatedMaterialIndex.feedbackAnalysisTime'),
          width: '160px',
          format: (row) => {
            return format.formatDateNull(row.analysisTime, 'yyyy-MM-dd hh:mm:ss')
          }
        },
        // 合规对接人
        {
          prop: 'dockPersonName',
          align: 'left',
          label: this.$t('relatedMaterialIndex.feedbackDockPersonName'),
          width: '120px'
        },
        // 分析人员
        {
          prop: 'analysisPersonName',
          align: 'left',
          label: this.$t('relatedMaterialIndex.feedbackAnalysisPersonName'),
          width: '120px'
        }
      ],
      // 评审素材一览
      columns2: [
        // 评审编号
        {
          prop: 'reviewNo',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewNo'),
          width: '160px'
        },
        // 产品类型
        {
          prop: 'businessType',
          align: 'center',
          label: this.$t('relatedMaterialIndex.reviewBusinessType'),
          width: '120px',
          format: (row) => {
            // return format.formatDict(row.businessType, 'BUSINESS_TYPE') // 原代码
            return format.formatDict(row.businessType, 'ZD0087') // 临时使用代码
          }
        },
        // 素材来源
        {
          prop: 'materialSourceType',
          align: 'center',
          label: this.$t('relatedMaterialIndex.reviewMaterialSourceType'),
          width: '120px',
          format: (row) => {
            return format.formatDict(row.materialSourceType, 'MATERIAL_SOURCE')
          }
        },
        // 评审时间
        {
          prop: 'inspectionTime',
          align: 'center',
          label: this.$t('relatedMaterialIndex.reviewInspectionTime'),
          width: '160px',
          format: (row) => {
            return format.formatDateNull(row.inspectionTime, 'yyyy-MM-dd hh:mm:ss')
          }
        },
        // 发起负责人
        {
          prop: 'reviewPromoterName',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewPromoterName'),
          width: '120px'
        },
        // 评审委员会人员
        {
          prop: 'committeeMemberNames',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewCommitteeMemberNames'),
          width: '120px'
        },
        // 付款确认书编号
        {
          prop: 'payCode',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewPayCode'),
          width: '160px'
        },
        // 供应商名称
        {
          prop: 'gysName',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewGysName'),
          width: '200px'
        },
        // 项目公司名称
        {
          prop: 'xmgsName',
          align: 'left',
          label: this.$t('relatedMaterialIndex.revieWxmgsName'),
          width: '200px'
        },
        // 问题摘要
        {
          prop: 'problemSummary',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewProblemSummary'),
          width: '200px'
        },
        // 问题描述
        {
          prop: 'problemDesc',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewProblemDesc'),
          width: '200px'
        },
        // 评审结论
        {
          prop: 'reviewConclusion',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewConclusion'),
          width: '200px'
        },
        // 状态
        {
          prop: 'status',
          align: 'center',
          label: this.$t('relatedMaterialIndex.reviewStatus'),
          width: '120px',
          format: (row) => {
            return format.formatDict(row.status, 'APPRAISAL_STATUS')
          }
        },
        // 备注
        {
          prop: 'remark',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewRemark'),
          width: '200px'
        },
        // 记录者
        {
          prop: 'registrar',
          align: 'left',
          label: this.$t('relatedMaterialIndex.reviewRegistrar'),
          width: '120px'
        }
      ],
      loadCount: 0
    }
  },
  methods: {
    // 附件下载
    fBatchDownload (row) {
      let fileList = []
      if (row.fileIds) {
        fileList = row.fileIds.split(',')
      }
      return fileList
    },
    // 关联评审素材 附件下载
    fileBatchDownload (row) {
      let arr = []
      row.accessoryExtDTO.forEach(res => {
        if (!this.UtilJs.isEmpty(res.fileId) && res.fileId > 0) {
          arr.push(res.fileId)
        }
      })
      return arr
    }
  },
  mounted () {
    this.$nextTick(() => {
      // 获取父组件传递的keyId
      this.searchFormQueryParas.knowledgeBaseId = this.keyId
      this.handleFilter()
    })
  },
  computed: {
    // 查询传入API接口
    api () {
      return knowledgeBaseApi.knowledgeBaseList
    }
  }
}
</script>
