<template>
  <!-- 质量管理 -->
  <div
    class="items bgc"
    id="work4"
  >
    <!-- 标题 -->
    <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="60"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="qualityCode"
                label="巡检编号"
                align="center"
                :show-overflow-tooltip="true"
              >
               <template v-slot="{row}">
          <a
            class="a-link"
            >{{ row.qualityCode }}</a
          >
        </template>
              </el-table-column>
              <el-table-column
                prop="qualityUserName"
                label="质检员姓名"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <ht-table-column
                prop="qualityInspectPosition"
                label="检测部位"
                align="center"
                :show-overflow-tooltip="true"
              >
              </ht-table-column>
              <el-table-column
                prop="checkSituation"
                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.qualityCode }}
                </td>
                <td
                  class="bgColor"
                  style="width: 130px"
                >质检员姓名</td>
                <td style="width:200px">{{ formData.qualityUserName }}</td>
              </tr>
              <tr>
                <td class="bgColor">检查部位</td>
                <td colspan="3">{{ formData.qualityInspectPosition }}</td>
              </tr>
              <tr>
                <td class="bgColor">纠正预防措施</td>
                <td colspan="3">{{ formData.preventionMeasures }}</td>
              </tr>
              <tr>
                <td class="bgColor">检查情况</td>
                <td colspan="3">{{ formData.checkSituation }}</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="audit"
        >
          <div class="table-border">
            <el-table
              :data="data2"
              height="200"
              border
              style="width: 100%"
              :header-cell-style="{background: '#f2f2f2', color: '#000'}"
              @row-click="handleRowDBClick2"
            >
              <el-table-column
                type="index"
                label="序号"
                width="60"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="rectificationDate"
                label="整改时间"
                align="center"
                :show-overflow-tooltip="true"
              >
               <template v-slot="{row}">
          <a
            class="a-link"
            >{{ row.rectificationDate }}</a
          >
        </template>
              </el-table-column>
              <el-table-column
                prop="assignUserName"
                label="指派人员"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="rectificationPosition"
                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="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-dialog
            title="质量整改-详情"
            :visible.sync="dialogVisible2"
            width="1000px"
          >
            <table align="center">
              <tr>
                <td
                  class="bgColor"
                  style="width: 130px"
                >整改时间</td>
                <td style="width: 350px">
                  {{ formData2.rectificationDate }}
                </td>
                <td
                  class="bgColor"
                  style="width: 150px"
                >指派人员</td>
                <td>{{ formData2.assignUserName }}</td>
              </tr>
              <tr>
                <td class="bgColor">部位</td>
                <td colspan="3">{{ formData2.rectificationPosition }}</td>
              </tr>
              <tr>
                <td class="bgColor">质量问题</td>
                <td colspan="3">{{ formData2.qualityProblem }}</td>
              </tr>
              <tr>
                <td class="bgColor">整改内容</td>
                <td colspan="3">{{ formData2.rectificationContent }}</td>
              </tr>
              <tr>
                <td class="bgColor">整改情况反馈</td>
                <td colspan="3">
                  {{ formData2.rectificationSituation }}
                </td>
              </tr>
              <!-- <tr>
                <td class="bgColor">附件信息</td>
                <td colspan="3">
                  <el-link
                    type="primary"
                    @click="handleLook(formData2.accessoryInfo)"
                    v-if="
                      formData2.accessoryInfo &&
                      formData2.accessoryInfo.length > 0
                    "
                  >查看附件({{ formData2.accessoryInfo.length }}个)</el-link>
                  <span v-else>无</span>
                </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.projectName}}</span> -->
                <span>{{formData2.projectInfo && formData2.projectInfo.projectManager}}</span>
                <span>{{formData2.projectInfo && formData2.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 planning from './planning.vue'
export default {
  name: 'quality',
  components: {
    dialogAccessory,
    planning
  },
  data() {
    return {
      data: [],
      data2: [],
      activeName: 'establishment',
      dialogTitle: '详情',
      dialogVisible: false,
      formData: {},
      formData2: {},
      dialogVisible2: false,
      pageResult: {
        page: 1,
        pageSize: 10,
        total: 0
      },
      pageResult2: {
        page: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  mounted() {
    this.loadData()
    this.loadData2()
  },
  methods: {
    //tabs
    handleClick(tab, even) {
      // console.log(tab.paneName)
    },
    //附件
    handleLook(obj) {
      this.$refs.accessory.open(obj)
    },
    handleRowDBClick(data) {
      this.dialogVisible = true
      this.formData = data
    },
    handleRowDBClick2(data) {
      this.dialogVisible2 = true
      this.formData2 = 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()
    },
    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/qualityInspection/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: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id
          }
        ]
      }
      this.$http
        .post(
          '${cqxy}/biz/processManagement/qualityRectification/v1/page',
          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)
          }
        )
    }
  }
}
</script>
<style lang="scss" scoped>
@import '../css/projectCommon.scss';
/deep/ .el-tabs__item {
  font-size: 18px !important;
}
/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>