<template>
  <div>

    <!--        企业资质审核       -->
    <el-card>
      <el-form :model="filterQuery" class="query-form" size="mini" label-width="120px" v-show="showSearch">
        <el-row>
          <el-col :span="6">
            <el-form-item label="企业名称:">
              <el-input v-model="filterQuery.companyName" style="width: 90%" placeholder="请输入企业名称"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="统一社会信用号:">
              <el-input v-model="filterQuery.creditNum" style="width: 90%" placeholder="请输入统一社会信用号"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <div class="top-right-btn">
        <el-button-group style="display:flex;">
          <el-button icon="el-icon-view" type="primary" @click="hideSearch">显示/隐藏搜索栏</el-button>
          <el-button type="primary" icon="el-icon-refresh" @click="onReset">重置</el-button>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
        </el-button-group>
      </div>

      <el-divider style="margin: 15px"></el-divider>

      <el-table v-loading="loading" :data="list" style="width: 100%" border highlight-current-row
                @row-click="supCompanyClick">
        <el-table-column type="index" label="序号" width="50"></el-table-column>
        <el-table-column label="企业名称" prop="companyName" width="160" show-overflow-tooltip></el-table-column>
        <el-table-column label="统一社会信用号" prop="creditNum" width="160"></el-table-column>
        <el-table-column label="注册地址" prop="registerAddress" :show-overflow-tooltip="true" width="180"></el-table-column>



      

        <el-table-column label="操作" width="120">
          <template slot-scope="scope">
         
            <el-button
              type="text"
              v-if="scope.row.auditStatus !=6 && scope.row.auditStatus !=3 && scope.row.auditStatus !=4"
              @click.native.stop="editCompany(scope.row)"
            >详情
            </el-button>

          </template>
        </el-table-column>


      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="filterQuery.page"
        :limit.sync="filterQuery.limit"
        @pagination="handleCurrentChange"
      ></pagination>
    </el-card>

    <el-dialog
      :title="formMap[formName]"
      :visible.sync="supCompanyVisible"
      :before-close="close"
      width="80%"
      v-if="supCompanyVisible"
      @close='closeDialog'
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
    
    </el-dialog>


    
    
   

  </div>
</template>

<script>

export default {
  data() {
    return {
      /**-----------------企业资质----------------------------*/
      showSearch: true,
      filterQuery: {
        companyName: "",
        checkStatus: "3",
        creditNum: "",
        page: 1,
        limit: 20,
      },
      loading: false,
      list: [],
      total: 0,
      formName: 1,
      formMap: {
        1: "企业资质详情",
        2: "企业资质审核",
      },
      checkFlag: {
        0: "草稿",
        1: "已通过",
        2: "已拒绝",
        3: "变更未审核",
        6: "未审核",
      },
      companyVisible: false,
      inputQuery: {},
      editType: 0,            //0:新增，1：编辑

      fromOptions: [],
 


    };
  },
  filters: {


    statusFilterType(status) {
      const statusMap = {
        0: "warning",
        1: "success",
        2: "danger",
        6: "warning",
        3: "warning",
      };
      return statusMap[status];
    },
   

    statusFilterName(status) {
      const statusMap = {
        0: "禁用",
        1: "正常",
        2: "未验证",
      };
      return statusMap[status];
    },
  },

  methods: {
    /**-------------------------企业资质--------------------------*/
    onReset() {
      this.$router.push({
        path: "",
      });
      this.filterQuery = {
        companyName: "",
        creditNum: "",
        checkStatus: "3",
        page: 1,
        limit: 20,
      };
      this.getList();
    },
    hideSearch() {
      this.showSearch = !this.showSearch;
    },
    getList() {
      //this.loading = true;
      
    },
    onSubmit() {
      this.getList();
    },
    editCompany(row) {
      if (row.auditStatus == 6 || row.auditStatus == 3 || row.auditStatus == 4) {
        this.formName = 2;
        this.editType = 2;
      } else {
        this.editType = 1;
        this.formName = 1;
      }
      this.supCompanyVisible = true;
      this.inputQuery = row;
    },

    handleCurrentChange(val) {
      this.filterQuery.page = val.page;
      this.getList();
    },
    
    closeDialog() {
      this.supCompanyVisible = false;
    },

  

    registrationDialog(row) {
      if (row.auditStatus == 6 || row.auditStatus == 3 || row.auditStatus == 4) {
        this.formProductName = 2;
        this.editProductType = 2;
      } else {
        this.editProductType = 1;
        this.formProductName = 1;
      }
      this.registrationId = row.id;
      this.inputProudtQuery = row;
      this.registrationVisible = true;
    },
   
    getRegistrationList() {
      this.registrationLoading = true;
      getRegistrationList(this.registrationQuery)
        .then((response) => {
          this.registrationLoading = false;
          this.registrationList = response.data.list || [];
          this.certTotal = response.data.total
        })
        .catch(() => {
          this.registrationLoading = false;
          this.registrationList = [];
        });
    },
    certHandleCurrentChange(val) {
      this.registrationQuery.page = val.page;
      this.getRegistrationList();
    }

  },
  components: {
    
  }
  ,

  created() {
    this.getList();
  },
};
</script>
