<template>
  <!-- 安全文明施工 -->
  <div
    class="items bgc"
    id="work3"
  >
    <!-- 标题 -->
    <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="safety"
        >
          <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="securityInspectCode"
                label="安检编号"
                align="center"
                :show-overflow-tooltip="true"
              >
               <template v-slot="{row}">
          <a
            class="a-link"
            >{{ row.securityInspectCode }}</a
          >
        </template>
              </el-table-column>
              <el-table-column
                prop="inspectDate"
                label="检查日期"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <ht-table-column
                prop="inspectUserName"
                label="检测人"
                align="center"
                :show-overflow-tooltip="true"
              >
              </ht-table-column>
              <el-table-column
                prop="reexaminationUser"
                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>
                  {{ formData.securityInspectCode }}
                </td>
                <td
                  class="bgColor"
                  style="width: 130px"
                >检查日期</td>
                <td>{{ formData.inspectDate }}</td>
              </tr>
              <tr>
                <td class="bgColor">检测人</td>
                <td>{{ formData.inspectUserName }}</td>
                <td class="bgColor">复查人</td>
                <td>{{ formData.reexaminationUser }}</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.projectName}}</span> -->
                <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="environmental"
        >
          <div class="table-border">
            <el-table
              :data="data2"
              height="200"
              border
              style="width: 100%"
              :header-cell-style="{background: '#f2f2f2', color: '#000'}"
            >
              <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"
              >
              </el-table-column>
              <ht-table-column
                prop="type"
                label="文件类型"
                align="center"
                width="130"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  {{ getDictName('tyfj-fjlx', row.type) }}
                </template>
              </ht-table-column>
              <el-table-column
                prop="fileSize"
                label="文件大小"
                align="center"
                width="130"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="createName"
                label="上传人"
                align="center"
                width="120"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="上传时间"
                align="center"
                width="130"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <ht-table-column
                label="操作"
                width="130"
              >
                <template v-slot="{row}">
                  <el-dropdown
                    size="mini"
                    split-button
                    @command="handleCommand"
                    @click="handleCommand({row, command: 'preview'})"
                  >
                    <span> <i class="el-icon-view"></i>查看</span>
                    <el-dropdown-menu slot="dropdown">
                      <el-dropdown-item
                        icon="el-icon-download"
                        :command="{row: row, command: 'download'}"
                      >下载</el-dropdown-item>
                    </el-dropdown-menu>
                  </el-dropdown>
                </template>
              </ht-table-column>
            </el-table>
            <div class="page-footer">
              <el-pagination
                @size-change="handleSizeChange2"
                @current-change="handleCurrentChange2"
                :current-page="pageResult2.page"
                :page-sizes="[5, 10, 20, 30, 50]"
                :page-size="pageResult2.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageResult2.total"
              >
              </el-pagination>
            </div>

          </div>
        </el-tab-pane>
        <!-- 其他 -->
        <el-tab-pane
          label="其他"
          name="other"
        >
          <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="epidemicControlCode"
                label="疫检编号"
                align="center"
                :show-overflow-tooltip="true"
              >
               <template v-slot="{row}">
          <a
            class="a-link"
            >{{ row.epidemicControlCode }}</a
          >
        </template>
              </el-table-column>
              <ht-table-column
                prop="epidemicControlDate"
                label="检查日期"
                align="center"
                :show-overflow-tooltip="true"
              >
              </ht-table-column>
              <el-table-column
                prop="epidemicControlUser"
                label="负责人"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="epidemicControlView"
                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">疫检编号</td>
                <td>{{ formData3.epidemicControlCode }}</td>
                <td class="bgColor">检查日期</td>
                <td>{{ formData3.epidemicControlDate }}</td>
              </tr>
              <tr>
                <td class="bgColor">负责人</td>
                <td>{{ formData3.epidemicControlUser }}</td>
                <td class="bgColor"></td>
                <td></td>
              </tr>
              <tr>
                <td class="bgColor">疫检结果</td>
                <td colspan="3">{{ formData3.epidemicControlView }}</td>
              </tr>
              <tr>
                <td class="bgColor">疫检措施</td>
                <td colspan="3">{{ formData3.progressDescription }}</td>
              </tr>
              <!-- <tr>
                <td class="bgColor">附件信息</td>
                <td colspan="3">
                  <el-link
                    type="primary"
                    @click="handleLook(formData3.accessoryInfo)"
                    v-if="
                            formData3.accessoryInfo &&
                            formData3.accessoryInfo.length > 0
                          "
                  >查看附件({{
                            formData3.accessoryInfo.length
                          }}个)</el-link>
                  <span v-else>无</span>
                </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.projectName}}</span> -->
                <span>{{formData3.projectInfo && formData3.projectInfo.projectManager}}</span>
                <span>{{formData3.projectInfo && formData3.projectInfo.commencementTime}}</span>
              </div>
            </div>
          </el-dialog>
        </el-tab-pane>
      </el-tabs>
    </div>
    <!-- <dialog-accessory ref="accessory" /> -->
  </div>
</template>
<script>
import dialogAccessory from '../dialog/dialogAccessory.vue'
import req from '@/request.js'
export default {
  name: 'construction',
  components: {
    dialogAccessory
  },
  data() {
    return {
      data: [],
      data2: [],
      data3: [],
      activeName: 'safety',
      dialogTitle: '详情',
      dialogVisible: false,
      dialogVisible3: false,
      formData: {},
      formData3: {},
      pageResult: {
        page: 1,
        pageSize: 10,
        total: 0
      },
      pageResult2: {
        page: 1,
        pageSize: 10,
        total: 0
      },
      pageResult3: {
        page: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  mounted() {
    this.loadData()
    this.loadData2()
    this.loadData3()
  },
  methods: {
    //tabs
    handleClick(tab, even) {
      // console.log(tab.paneName)
      // safety安全  environmental环保 other其它
      // if(tab.paneName){}
    },
    //附件
    handleLook(obj) {
      this.$refs.accessory.open(obj)
    },
    handleRowDBClick(data) {
      this.dialogVisible = true
      this.formData = data
    },
    handleRowDBClick3(data) {
      this.dialogVisible3 = true
      this.formData3 = data
    },
    handleSizeChange(val) {
      this.pageResult.pageSize = val
      this.loadData()
    },
    handleCurrentChange(val) {
      this.pageResult.page = val
      this.loadData()
    },
    handleSizeChange2(val) {
      this.pageResult2.pageSize = val
      this.loadData2()
    },
    handleCurrentChange2(val) {
      this.pageResult2.page = val
      this.loadData2()
    },
    handleSizeChange3(val) {
      this.pageResult3.pageSize = val
      this.loadData3()
    },
    handleCurrentChange3(val) {
      this.pageResult3.page = val
      this.loadData3()
    },
    loadData() {
      let param = {
        pageBean: {
          ...this.pageResult
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id
          }
        ]
      }
      this.$http
        .post('${cqxy}/biz/processManagement/securityManage/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)
          }
        )
    },
    loadData2() {
      let param = {
        pageBean: {
          ...this.pageResult2
        },
        querys: [
          {
            group: 'main',
            opener: 'EQUAL',
            property: 'SOURCE_ID_',
            relation: 'AND',
            value: 'environmentalManagement'
          },
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'project_id_',
            relation: 'AND',
            value: this.$route.params.id
          }
        ]
      }
      this.$http
        .post('${cqxy}/biz/universal/accessory/v1/getPageBySourceId', param)
        .then(
          resp => {
            let response = resp.data.value
            this.data2 = response.rows
            this.pageResult2 = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total
            }
          },
          error => {
            reject(error)
          }
        )
    },
    loadData3() {
      let param = {
        pageBean: {
          ...this.pageResult3
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'PROJECT_ID_',
            relation: 'AND',
            value: this.$route.params.id
          }
        ]
      }
      this.$http
        .post(
          '${cqxy}/biz/processManagement/progressManageEpidemicControl/v1/page',
          param
        )
        .then(
          resp => {
            let response = resp.data.value
            this.data3 = response.rows
            this.pageResult3 = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total
            }
          },
          error => {
            reject(error)
          }
        )
    },
    handleCommand(params) {
      console.log(params)
      if (params.command == 'preview') {
        let type = params.row.suffix
        if (
          type.indexOf('xsl') !== -1 ||
          type.indexOf('xslx') !== -1 ||
          type.indexOf('xls') !== -1 ||
          type.indexOf('docx') !== -1 ||
          type.indexOf('doc') !== -1 ||
          type.indexOf('pdf') !== -1 ||
          type.indexOf('jpg') !== -1 ||
          type.indexOf('png') !== -1 ||
          type.indexOf('jpeg') !== -1 ||
          type.indexOf('pptx') !== -1 ||
          type.indexOf('ppt') !== -1
        ) {
          this.dialogVisible = true
          // this.url = encodeURIComponent(row.url)
          this.url = params.row.url
        } else {
          this.$message('当前文件暂不支持预览，请下载查看')
        }
      } else {
        let ids = params.row.id
        let bizPath = 'default'
        let formData = new FormData()
        formData.append('bizPath', bizPath)
        formData.append('ids', ids)
        req
          .downloadPostCopy(
            '${cqxy}/biz/universal/accessory/v1/minIoAllDownFile',
            formData
          )
          .then(res => {
            console.log(res)
          })
      }
    }
  }
}
</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;
}
</style>