<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="关键字" prop="keyWord">
        <el-input
          v-model="queryParams.keyWord"
          placeholder="请输入关键字"
          maxlength="60"
          show-word-limit
          clearable v-no-whitespace
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审批状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择审批状态" clearable>
          <el-option
            v-for="dict in statusDict"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="contList">
      <el-table-column
        type="index"
        width="55"
        label="序号"
        align="center"
        :index="indexContinuous(queryParams.pageNum, queryParams.pageSize)"
      />
      <el-table-column label="工程名称" align="center" prop="proName" />
      <el-table-column label="承包商名称" align="center" prop="consName" />
      <el-table-column label="社会统一征信代码" align="center" prop="socialUnifiedCreditCode" />
      <el-table-column label="法人姓名" align="center" prop="corporateName" />
      <el-table-column label="法人联系方式" width="120" align="center">
        <template slot-scope="scope">
          <!-- 检查是否存在身份证号 -->
          <span v-if="scope.row.corporatePhone">{{ hideSensitiveInfo(scope.row.corporatePhone) }}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column label="承包商负责人" align="center" prop="subPrincipal" />
      <el-table-column label="承包商负责人联系方式" width="120" align="center">
        <template slot-scope="scope">
          <!-- 检查是否存在身份证号 -->
          <span v-if="scope.row.subPrincipalPhone">{{ hideSensitiveInfo(scope.row.subPrincipalPhone) }}</span>
          <span v-else>-</span>
        </template>
      </el-table-column>
      <el-table-column label="审批状态" align="center" prop="status" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="handleView(scope.row)"
            v-hasPermi="['system:contList:edit']"
          >查看</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleApprove(scope.row)"
            v-hasPermi="['system:contList:preparation']"
          >审批</el-button>
          <el-button
            size="mini"
            type="text"
            @click="handleAuditRecord(scope.row)"
            v-hasPermi="['system:contList:del']"
          >审核记录</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>

import {dictTableOption} from "@/api/tool/select";
import {getConsEntranceList} from "@/api/pro/approval_cons";
import { hideSensitiveInfo, indexContinuous } from '../../../utils/bonus'
export default {
  name: 'index',
  data() {
    return{
      // 遮罩层
      loading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        keyWord: undefined,
        status: undefined
      },
      // 承包商表格数据
      contList: [],
      //审批状态下拉选
      statusDict: [],
    }
  },

  created() {
    this.getStatus();
    this.getList()
  },

  methods: {
    indexContinuous,
    hideSensitiveInfo,
    /** 查询工程列表 */
    getList() {
      this.loading = true;
      getConsEntranceList(this.queryParams).then(response => {
        this.contList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    //获取工程类型下拉选
    getStatus() {
      const params = {
        dictType: 'sys_approval_state',
        dictValue: ''
      }
      dictTableOption(params).then(response => {
        this.statusDict = response.data;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.keyWord = undefined;
      this.queryParams.status = undefined;
      this.handleQuery();
    },
    /** 查看按钮操作 */
    handleView(row) {
      this.$router.push("/system/subManagement-subDetailsInfo-auth/subApproval/" + 1 +"/"+ 2 +"/"+ 1 +"/" + 1);
    },
    /** 审批按钮操作 */
    handleApprove(row) {
      this.$router.push("/system/subManagement-subDetailsInfo-auth/subApproval/" + 1 +"/"+ 2 +"/"+ 1 +"/" + 2);
    },
    /** 审核记录按钮操作 */
    handleAuditRecord(row) {

    },
  }
};

</script>

<style scoped lang="scss">

</style>
