<template>
  <!-- 竣工验收 -->
  <div class="items bgc" id="acc3">
    <!-- 标题 -->
    <div class="title">
      <span class="icon"></span>
      <span class="text">竣工验收</span>
    </div>
    <!-- 详情 -->
    <!-- tabs切换 -->
    <div class="main-content">
      <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
        <!-- 专项验收 -->
        <el-tab-pane label="专项验收" name="establishment">
          <div class="table-border">
            <el-table
              :data="data"
              height="200"
              border
              style="width: 100%"
              :header-cell-style="{background: '#f2f2f2', color: '#000'}"
              @row-click="handleRowDBClick"
            >
              <el-table-column
                type="index"
                label="序号"
                width="55"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="acceptanceDate"
                label="验收时间"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <a class="a-link">{{ row.acceptanceDate }}</a>
                </template>
              </el-table-column>
              <ht-table-column
                prop="acceptanceType"
                label="验收类型"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  {{ getDictName('jgys-zxyslx', row.acceptanceType) }}
                </template>
              </ht-table-column>
              <el-table-column
                prop="acceptancePlace"
                label="验收地点"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="remarks"
                label="备注"
                align="center"
                width="120"
                :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>
          </div>
          <el-dialog
            title="专项验收-详情"
            :visible.sync="dialogVisible"
            width="1000px"
          >
            <table align="center">
              <tr>
                <td class="bgColor" style="width: 130px">验收时间</td>
                <td style="width: 240px">{{ formData.acceptanceDate }}</td>
                <td class="bgColor" style="width: 150px">验收类型</td>
                <td>
                  {{ getDictName('jgys-zxyslx', formData.acceptanceType) }}
                </td>
              </tr>
              <tr>
                <td class="bgColor">经办人</td>
                <td>{{ formData.handlerName }}</td>
                <td class="bgColor">验收地点</td>
                <td>{{ formData.acceptancePlace }}</td>
              </tr>
              <tr>
                <td class="bgColor">参建单位</td>
                <td colspan="3">{{ formData.handlerUnit }}</td>
              </tr>
              <tr>
                <td class="bgColor">简述</td>
                <td colspan="3">{{ formData.sketch }}</td>
              </tr>

              <!-- <tr>
                <td class="bgColor">附件信息</td>
                <td colspan="3">
                  <el-link
                    type="primary"
                    @click="handleLook(formData.accessoryInfo)"
                    v-if="
                      formData.accessoryInfo &&
                      formData.accessoryInfo.length > 0
                    "
                  >查看附件({{ formData.accessoryInfo.length }}个)</el-link>
                  <span v-else>无</span>
                </td>
              </tr> -->
              <tr>
                <td class="bgColor">备注</td>
                <td colspan="3">{{ formData.remarks }}</td>
              </tr>
            </table>
            <dialog-accessory
              ref="accessory"
              :accessoryInfo="formData.accessoryInfo"
            />
            <div class="flexEnd">
              <div class="end">
                <span>{{
                  formData.projectInfo && formData.projectInfo.projectManager
                }}</span>
                <span>{{
                  formData.projectInfo && formData.projectInfo.commencementTime
                }}</span>
              </div>
            </div>
          </el-dialog>
        </el-tab-pane>
        <!-- 竣工验收 -->
        <el-tab-pane label="竣工验收" name="completion">
          <div class="table-border">
            <el-table
              :data="data3"
              height="200"
              border
              style="width: 100%"
              :header-cell-style="{background: '#f2f2f2', color: '#000'}"
              @row-click="handleRowDBClick3"
            >
              <el-table-column
                type="index"
                label="序号"
                width="55"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="name"
                label="竣工验收名称"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <a class="a-link">{{ row.name }}</a>
                </template>
              </el-table-column>
              <el-table-column
                prop="completionAcceptanceDate"
                label="竣工验收时间"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="projectAcceptanceScope"
                label="竣工验收范围"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
               <el-table-column
                prop="completionAcceptanceOpinions"
                label="竣工验收意见"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="remarks"
                label="备注"
                align="center"
                width="120"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
            </el-table>
            <div class="page-footer">
              <el-pagination
                @size-change="handleSizeChange3"
                @current-change="handleCurrentChange3"
                :current-page="pageResult3.page"
                :page-sizes="[5, 10, 20, 30, 50]"
                :page-size="pageResult3.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageResult3.total"
              >
              </el-pagination>
            </div>
          </div>
          <el-dialog
            title="竣工验收-详情"
            :visible.sync="dialogVisible3"
            width="1000px"
          >
            <table align="center">
              <tr>
                <td
                  class="bgColor"
                  style="width: 130px"
                >验收工程名称</td>
                <td style="width: 240px" colspan="3">{{ formData3.name }}</td>
              </tr>
              <tr>
                <td class="bgColor">竣工验收日期</td>
                <td colspan="3">{{ formData3.completionAcceptanceDate }}</td>
              </tr>
              <tr>

                <td class="bgColor">工程验收范围</td>
                <td colspan="3">{{ formData3.projectAcceptanceScope }}</td>
              </tr>
              <tr>
                <td class="bgColor">竣工验收意见</td>
                <td colspan="3">{{ formData3.completionAcceptanceOpinions }}</td>
              </tr>
              <tr>
                <td class="bgColor">备注</td>
                <td colspan="3">{{ formData3.remarks }}</td>
              </tr>
            </table>
            <dialog-accessory
              ref="accessory"
              :accessoryInfo="formData3.accessoryInfo"
            />
            <div class="flexEnd">
              <div class="end">
                <span>{{
                  formData3.projectInfo && formData3.projectInfo.projectManager
                }}</span>
                <span>{{
                  formData3.projectInfo && formData3.projectInfo.commencementTime
                }}</span>
              </div>
            </div>
          </el-dialog>
        </el-tab-pane>
         <!-- 专项验收 -->
        <el-tab-pane label="竣工图" name="map">
           <div class="table-border">
              <el-table
              :data="data4"
              height="200"
              border
              style="width: 100%"
              :header-cell-style="{background: '#f2f2f2', color: '#000'}"
              @row-click="handleRowDBClick4"
            >
              <el-table-column
                type="index"
                label="序号"
                width="55"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="sketch"
                label="竣工图主题"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <a class="a-link">{{ row.sketch }}</a>
                </template>
              </el-table-column>
              <el-table-column
                prop="acceptanceDate"
                label="完成时间"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="remarks"
                label="备注"
                align="center"
                width="120"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
            </el-table>
            <div class="page-footer">
              <el-pagination
                @size-change="handleSizeChange4"
                @current-change="handleCurrentChange4"
                :current-page="pageResult4.page"
                :page-sizes="[5, 10, 20, 30, 50]"
                :page-size="pageResult4.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageResult4.total"
              >
              </el-pagination>
            </div>
          </div>
          <el-dialog
            title="竣工图-详情"
            :visible.sync="dialogVisible4"
            width="1000px"
          >
            <table align="center">
              <tr>
                <td
                  class="bgColor"
                  style="width: 130px"
                >竣工图主题</td>
                <td>{{ formData4.sketch }}</td>
                 <td class="bgColor"  style="width: 130px">完成时间</td>
                <td  style="width: 200px">{{ formData4.acceptanceDate }}</td>
              </tr>
              <tr>
                <td class="bgColor">备注</td>
                <td colspan="3">{{ formData4.remarks }}</td>
              </tr>
            </table>
            <dialog-accessory
              ref="accessory"
              :accessoryInfo="formData4.accessoryInfo"
            />
            <div class="flexEnd">
              <div class="end">
                <span>{{
                  formData4.projectInfo && formData4.projectInfo.projectManager
                }}</span>
                <span>{{
                  formData4.projectInfo && formData4.projectInfo.commencementTime
                }}</span>
              </div>
            </div>
          </el-dialog>
        </el-tab-pane>
        <!-- 联合竣工备案 -->
        <el-tab-pane label="联合竣工备案" name="audit">
          <div class="table-border" v-if="show">
            <table align="center" style="height: 230px">
              <tr>
                <td class="bgColor" style="width: 150px">竣工验收日期</td>
                <td style="width: 260px">
                  {{ formData2.completionAcceptanceDate }}
                </td>
                <td class="bgColor" style="width: 150px">备案机关审批人</td>
                <td>{{ formData2.approvalFilingAuthority }}</td>
              </tr>
              <tr>
                <td class="bgColor">备案机关审批日期</td>
                <td>{{ formData2.approvalFilingAuthorityDate }}</td>
                <td class="bgColor">备案机关审批单位</td>
                <td>{{ formData2.approvalUnitFilingAuthority }}</td>
              </tr>
              <tr>
                <td class="bgColor">竣工验收备案登记人</td>
                <td>{{ formData2.completionAcceptanceRegistrant }}</td>
                <td class="bgColor"></td>
                <td></td>
              </tr>
              <tr>
                <td class="bgColor">竣工验收意见</td>

                <!-- {{ formData2.completionAcceptanceOpinions }} -->
                <td colspan="3">
                  <el-tooltip
                    class="item"
                    effect="dark"
                    :content="formData2.completionAcceptanceOpinions"
                    placement="bottom"
                  >
                    <div class="acc-content">
                      {{ formData2.completionAcceptanceOpinions }}
                    </div>
                  </el-tooltip>
                </td>
              </tr>
              <tr>
                <td class="bgColor">备注</td>
                <td colspan="3">{{ formData2.remarks }}</td>
              </tr>
            </table>
            <dialog-accessory
              ref="accessory"
              :accessoryInfo="formData2.accessoryInfo"
            />
            <div class="flexEnd">
              <div class="end">
                <span>{{
                  formData2.projectInfo && formData2.projectInfo.projectManager
                }}</span>
                <span>{{
                  formData2.projectInfo &&
                  formData2.projectInfo.commencementTime
                }}</span>
              </div>
            </div>
          </div>
          <div class="table-border" v-else>
            <el-empty description="暂无数据" :image-size="100"></el-empty>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <!-- <dialog-accessory ref="accessory" /> -->
  </div>
</template>
<script>
import dialogAccessory from '../dialog/dialogAccessory.vue'
import planning from './planning.vue'
export default {
  name: 'completedAccpet',
  components: {
    dialogAccessory,
    planning,
  },
  data() {
    return {
      data: [],
      data3: [],
      data4: [],
      activeName: 'establishment',
      dialogTitle: '详情',
      dialogVisible: false,
      dialogVisible3: false,
      dialogVisible4: false,
      formData: {},
      formData2: {},
      formData3: {},
      formData4: {},
      pageResult: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
      pageResult2: {
        page: 1,
        pageSize: 1,
        total: 0,
      },
      pageResult3: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
       pageResult4: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
      show: true,
    }
  },
  mounted() {
    this.loadData()
  },
  methods: {
    //tabs
    handleClick(tab, even) {
      if(tab.paneName=='completion'){ //竣工验收
        this.loadData3()
      }else if(tab.paneName=='map'){ //竣工图
        this.loadData4()
      }else if(tab.paneName=='audit'){ //联合竣工备案
        this.loadData2()
      }
    },
    //附件
    handleLook(obj) {
      this.$refs.accessory.open(obj)
    },
    handleRowDBClick(data) {
      this.dialogVisible = true
      this.formData = data
    },
    handleRowDBClick3(data) {
      this.dialogVisible3= true
      this.formData3 = data
    },
     handleRowDBClick4(data) {
      this.dialogVisible4= true
      this.formData4= data
    },
    handleSizeChange(val) {
      this.pageResult.pageSize = val
      this.loadData()
    },
    handleCurrentChange(val) {
      this.pageResult.page = val
      this.loadData()
    },
    handleSizeChange3(val) {
      this.pageResult3.pageSize = val
      this.loadData3()
    },
     handleSizeChange4(val) {
      this.pageResult4.pageSize = val
      this.loadData4()
    },
    handleCurrentChange3(val) {
      this.pageResult3.page = val
      this.loadData3()
    },
     handleCurrentChange4(val) {
      this.pageResult4.page = val
      this.loadData4()
    },
    loadData() {
      let param = {
        pageBean: {
          ...this.pageResult,
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id,
          },
        ],
        sorter: [{direction: 'DESC', property: 'acceptanceDate'}],
      }
      this.$http
        .post(
          '${cqxy}/biz/completionAcceptance/recordAcceptanceSpecial/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)
          }
        )
    },
    //竣工图
    loadData4(){
       let param = {
        pageBean: {
          ...this.pageResult4,
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'PROJECT_ID_',
            relation: 'AND',
            value: this.$route.params.id,
          },
        ],
        sorter: [{direction: 'DESC', property: 'acceptanceDate'}]
      }
      this.$http
        .post(
          '${cqxy}/biz/completionAcceptance/AcceptanceDrawings/v1/page',
          param
        )
        .then(
          (resp) => {
            let response = resp.data.value
            this.data4 = response.rows
            this.pageResult4 = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total,
            }
          },
          (error) => {
            reject(error)
          }
        )
    },
    loadData3() {
      let param = {
        pageBean: {
          ...this.pageResult3,
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id,
          },
        ],
        sorter: [{direction: 'DESC', property: 'completionAcceptanceDate'}]
      }
      this.$http
        .post(
          '${cqxy}/biz/completionAcceptance/completionAcceptance/v1/page',
          param
        )
        .then(
          (resp) => {
            let response = resp.data.value
            this.data3 = response.rows
            this.pageResult = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total,
            }
          },
          (error) => {
            reject(error)
          }
        )
    },
    loadData2() {
      let param = {
        pageBean: {
          ...this.pageResult2,
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id,
          },
        ],
      }
      this.$http
        .post(
          '${cqxy}/biz/completionAcceptance/recordAcceptance/v1/page',
          param
        )
        .then(
          (resp) => {
            let data = resp.data.value.rows
            if (data.length > 0) {
              this.formData2 = data[0]
              this.show = true
            } else {
              this.show = false
            }
          },
          (error) => {
            reject(error)
          }
        )
    },
  },
}
</script>
<style lang="scss" scoped>
@import '../css/projectCommon.scss';
/deep/ .el-tabs__content {
  padding: 10px !important;
}
.table-border {
  height: 515px;
  .el-table {
    height: calc(100% - 50px) !important;
  }
}
.page-footer {
  margin-top: 10px;
  height: 30px;
  float: right;
}
.acc-content {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  font-size: 18px;
}
.item {
  width: 100%;
}
</style>