<template>
  <!-- 施工许可 -->
  <div
    class="do-jump items bgc"
    id="work1"
  >
    <!-- 标题 -->
     <div class="title">
      <span class="icon"></span>
      <span class="text">施工许可</span>
    </div>

     <!-- 详情 -->
    <div class="table-border">
       <el-table
        :data="data"
        height="230"
        border
        style="width: 100%"
        :default-sort = "{prop: 'establishmentDate', order: 'descending'}"
        :header-cell-style="{background: '#f2f2f2', color: '#000'}"
        @row-click="handleRowDBClick"
        
      >
        <el-table-column type="index" label="序号" width="60" align="center">
        </el-table-column>
         <el-table-column
          prop="code"
          label="证件编号"
          align="center"
          :show-overflow-tooltip="true"
        >
         <template v-slot="{row}">
          <a
            class="a-link"
            >{{ row.code }}</a
          >
        </template>
        </el-table-column>
        <el-table-column
          prop="contractDuration"
          label="合同工期"
          align="center"
          width="150"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="establishmentApprovalUnit"
          label="发证机关"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="establishmentDate"
          label="发证日期"
          align="center"
          width="150"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="establishmentRemarks"
          label="备注"
          align="center"
          width="100"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
       </el-table>
       <div class="page-footer">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageResult.page"
          :page-sizes="[5, 10, 20, 30, 50]"
          :page-size="pageResult.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageResult.total"
        >
        </el-pagination>
      </div>
       <el-dialog
        title="施工许可-详情"
        :visible.sync="dialogVisible"
        width="1000px"
      >
      <table align="center">
        <tr>
          <td
            class="bgColor"
            style="width: 130px"
          >证件编号</td>
          <td>{{ form.code }}</td>
          <td
            class="bgColor"
            style="width: 130px"
          >发证机关</td>
          <!-- <td style="width:220px">{{ form.establishmentApprovalUnit }}</td> -->
          <td>
            <el-tooltip :content="form.establishmentApprovalUnit" placement="top">
                <p class="descStyle">
                  {{form.establishmentApprovalUnit}}
                </p>
              </el-tooltip>
          </td>
            
        </tr>
        <tr>
          <td class="bgColor">发证日期</td>
          <td>{{form.establishmentDate}}</td>
          <td class="bgColor">合同工期</td>
          <td>{{form.contractDuration}}</td>
        </tr>
        <tr>
          <td class="bgColor">建设单位</td>
          <td>{{ form.name }}</td>
          <td class="bgColor">建设单位负责人</td>
          <td>{{ form.person }}</td>
        </tr>
        <tr>
          <td class="bgColor">勘察单位</td>
          <td>
            <el-tooltip
              content="查看合同管理信息"
              placement="top"
            >
              <el-link
                type="primary"
                @click="handleViewDetils(getDictName('sgxk-kcdw',form.surveyUnit))"
              >
                <p class="descStyle">{{ getDictName('sgxk-kcdw',form.surveyUnit)}}</p>
              </el-link>
            </el-tooltip>
          </td>
          <td class="bgColor">勘察单位负责人</td>
          <td>{{ form.surveyUnitPerson }}</td>
        </tr>
        <tr>
          <td class="bgColor">设计单位</td>
          <td>
            <el-tooltip
              content="查看合同管理信息"
              placement="top"
            >
              <el-link
                type="primary"
                @click="handleViewDetils(getDictName('sgxk-sjdw',form.designUnit))"
              >
                <p class="descStyle">{{ getDictName('sgxk-sjdw',form.designUnit)}}</p>
              </el-link>
            </el-tooltip>
          </td>
          <td class="bgColor">设计单位负责人</td>
          <td>{{ form.designUnitPerson }}</td>
        </tr>
        <tr>
          <td class="bgColor">监理单位</td>
          <td>
            <el-tooltip
              content="查看合同管理信息"
              placement="top"
            >
              <el-link
                type="primary"
                @click="handleViewDetils(getDictName('sgxk-jldw',form.supervisorUnit))"
              >
                <p class="descStyle">{{ getDictName('sgxk-jldw',form.supervisorUnit)}}</p>
              </el-link>
            </el-tooltip>
          </td>
          <td class="bgColor"> 监理单位负责人</td>
          <td>{{ form.supervisorUnitPerson }}</td>
        </tr>
        <tr>
          <td class="bgColor">施工单位</td>
          <td>
            <el-tooltip
              content="查看合同管理信息"
              placement="top"
            >
              <el-link
                type="primary"
                @click="handleViewDetils(getDictName('sgxk-sgdw',form.constructionUnit))"
              >
                <p class="descStyle">{{ getDictName('sgxk-sgdw',form.constructionUnit)}}</p>
              </el-link>
            </el-tooltip>
          </td>
          <td class="bgColor">施工单位负责人</td>
          <td>{{ form.constructionUnitPerson }}</td>
        </tr>
        <tr>
          <td class="bgColor">项目地址</td>
          <td :colspan="3">{{ form.proposedLocation }}</td>
        </tr>
        <tr>
          <td class="bgColor">项目规模</td>
          <td :colspan="3">{{ form.proposedLandArea }}</td>
        </tr>
        <!-- <tr>
          <td class="bgColor">附件信息</td>
          <td colspan="3">
            <el-link
              type="primary"
              @click="handleLook(data.accessoryInfo)"
              v-if="data.accessoryInfo && data.accessoryInfo.length > 0"
            >查看附件({{ data.accessoryInfo.length }}个)</el-link>
            <span v-else>无</span>
          </td>
        </tr> -->
        <tr>
          <td class="bgColor">备注</td>
          <td colspan="3">{{ form.establishmentRemarks }}</td>
        </tr>
      </table>
      <dialog-accessory ref="accessory" :accessoryInfo="form.accessoryInfo" />
      <div class="flexEnd">
        <div class="end">
          <!-- <span>项目名称：{{data.projectInfo && data.projectInfo.projectName}}</span> -->
          <span>{{form.projectInfo && form.projectInfo.projectManager}}</span>
          <span>{{form.projectInfo && form.projectInfo.commencementTime}}</span>
        </div>
      </div>
       </el-dialog>

    </div>

    <contractListDialog
      :querysValue='querysValue'
      ref='contractList'
    />
  </div>
</template>
<script>
import dialogAccessory from '../dialog/dialogAccessory.vue'
import contractListDialog from '../dialog/contractListDialog.vue'
export default {
  name: 'licence',
  components: {
    dialogAccessory,
    contractListDialog
  },
  data() {
    return {
      data: [],
      // show: true,
       pageResult: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
      querysValue: '',
      form:{},
      dialogVisible:false,
    }
  },
  mounted() {
    this.loadData()
  },
  methods: {
    //附件
    handleLook(obj) {
      this.$refs.accessory.open(obj)
    },
    handleSizeChange(val) {
      this.pageResult.pageSize = val
      this.loadData()
    },
    handleCurrentChange(val) {
      this.pageResult.page = val
      this.loadData()
    },
    //查看详情
     handleRowDBClick(data) {
      this.dialogVisible = true
      this.form = data
    },
    loadData() {
      let param = {
        pageBean: {
          ...this.pageResult,
        },
        querys: [
          {
            group: 'main',
            operation: 'EQUAL',
            parentGroup: '',
            property: 'PROJECT_ID_ ',
            relation: 'AND',
            value: this.$route.params.id
          }
        ]
      }
      this.$http.post('${cqxy}/biz/constructionPermit/cp/v1/page', param).then(
        resp => {
          let response = resp.data.value
          this.data = response.rows
          this.pageResult = {
            page: response.page,
            pageSize: response.pageSize,
            total: response.total,
          }
        },
        error => {
          reject(error)
        }
      )
    },
    handleViewDetils(value) {
      this.querysValue = value
      this.$refs.contractList.open()
    }
  }
}
</script>
<style lang="scss" scoped>
@import '../css/projectCommon.scss';
.page-footer {
  padding-top: 10px;
  float: right;
}
.table-border {
  height: 515px;
}
/deep/ .el-table {
  height: calc(100% - 32px) !important;
}
</style>