<template>
  <div>
    <div class="level-title">
      <h1>重点工程详情</h1>
    </div>

    <table class="table-ui">
      <tr>
        <td class="bbg-transparent">重点工程名称</td>
        <td colspan="3">{{ pd.OUTSOURCED_NAME }}</td>
      </tr>
      <tr v-if="pd.IS_CORP_TYPE == '0'">
        <td class="bbg-transparent">股份主管部门</td>
        <td>{{ pd.MANAGER_DEPARTMENT_NAME }}</td>
        <td class="bbg-transparent">股份监管部门</td>
        <td>{{ pd.DEPARTMENT_NAME }}</td>
      </tr>
      <tr v-if="pd.IS_CORP_TYPE == '0'">
        <td class="bbg-transparent">辖区单位</td>
        <td colspan="3">{{ pd.JURISDICTION_UNIT_NAME }}</td>
      </tr>
      <tr v-if="pd.IS_CORP_TYPE == '1'">
        <td class="bbg-transparent">企业监督部门</td>
        <td>{{ pd.DEPARTMENT_NAME }}</td>
        <td class="bbg-transparent">企业主管部门</td>
        <td>{{ pd.Q_COMPETENT_DEPT_NAME }}</td>
      </tr>
      <tr v-if="pd.IS_CORP_TYPE == '1'">
        <td class="bbg-transparent">企业辖区部门</td>
        <td colspan="4">{{ pd.INVOLVING_CORPS_DEPART_NAME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">集团单位</td>
        <td colspan="3">{{ pd.GROUP_UNIT_NAME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">计划工期</td>
        <td colspan="3">{{ pd.STARTTIME }} 至 {{ pd.ENDTIME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">施工相关方</td>
        <td colspan="3">{{ pd.UNITS_NAME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">合同号</td>
        <td>{{ pd.CONTRACT_NUM }}</td>
        <td class="bbg-transparent">监理单位名称</td>
        <td>{{ pd.MANAGE_CORPS_NAME }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">相关方单位工程负责人</td>
        <td>{{ pd.UNITS_PIC_NAME }}</td>
        <td class="bbg-transparent">相关方单位负责人手机</td>
        <td>{{ pd.UNITS_PHONE }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">监理单位工程负责人</td>
        <td>{{ pd.MANAGE_PIC }}</td>
        <td class="bbg-transparent">监理单位负责人手机</td>
        <td >{{ pd.MANAGE_PHONE }}</td>
      </tr>
      <tr>
        <td class="bbg-transparent">是否发送短信</td>
        <td >
          <span v-if="pd.IS_SMS === '0'">是</span>
          <span v-if="pd.IS_SMS === '1'">否</span>
        </td>
        <td class="bbg-transparent">状态</td>
        <td>
          <span v-if="pd.STATE == 0">未开工</span>
          <span v-if="pd.STATE == 1">进行中</span>
          <span v-if="pd.STATE == 2">已结束</span>
          <span v-if="pd.STATE == -1">开工申请中</span>
          <span v-if="pd.STATE == -2">结束申请中</span>
        </td>
      </tr>
      <tr v-for="(item, index) in file9" :key="index">
        <td class="bbg-transparent">安全管理协议{{ index + 1 }}</td>
        <td colspan="2">{{ item.FILE_NAME }}</td>
        <td><el-button type="primary" @click="downloadFile(item.FILEPATH)">下载</el-button></td>
      </tr>
      <div class="level-line" />
      <div class="level-title">
        <h1>处罚相关：</h1>
      </div>
      <tr v-for="(item,index) in punishThePerson" :key="index">
        <td class="bbg-transparent">处罚人员部门</td>
        <td>{{ item.punishname }}</td>
        <td class="bbg-transparent">处罚人员</td>
        <td>{{ item.NAME }}</td>
      </tr>

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

<script>
import { requestFN } from '@/utils/request'
import moment from 'moment/moment'

export default {
  props: {
    id: {
      type: String,
      default() {
        return ''
      }
    },
    type: {
      type: String,
      default() {
        return ''
      }
    },
    gangkou: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      config: config,
      pd: {
        WORK_OPERATOR_ID: [],
        WORK_OPERATOR_NAME: [],
        WORK_OPERATOR_NUMBER: []
      },
      punishThePerson: [],
      file9: []
    }
  },
  created() {
    this.getData()
  },
  methods: {
    formatDate(date, format) {
      if (date) {
        return moment(date).format(format)
      } else {
        return ''
      }
    },
    getData() {
      requestFN(
        '/map/keyProject/getById',
        {
          id: this.id,
          TYPE: this.type,
          GANGKOU: this.gangkou
        }
      ).then(data => {
        this.pd = data.pd
        this.punishThePerson = data.punishThePerson
        this.file9 = data.file9
      })
    },
    downloadFile(filePath) {
      this.$confirm('确定要下载此文件吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.listLoading = false
        // window.location.href = config.httpurl + 'outsourced/download?OUTSOURCED_ID=' + OUTSOURCED_ID
        window.open(config.fileUrl + filePath)
      }).catch(() => {
        this.listLoading = false
      })
      this.listLoading = false
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
