<template>
  <div class="Userapplication">
    <div class="UserapplicationMain">
      <div class="CRTop">
        <div>
          <span v-if="MTCompanyID!='10086'">企业设置 / 个人申请管理</span>
          <!-- <span v-if="MTCompanyID=='0'&&LeftToId==0">企业设置 / 团队申请管理</span> -->
          <span v-else>企业设置 / 团队申请管理</span>
        </div>
      </div>
      <el-row>
        <el-tabs
          v-if="MTCompanyID!='10086'"
          class="BCtabs"
          v-model="activeName"
          type="border-card"
          @tab-click="handleClickUser"
        >
          <el-tab-pane :label="'待审核('+UfirstText+')'" name="first">
            <p class="SearchTitle">
              总记录条数
              <span style="color:#379FFF">{{TitleTotal}}</span>条，符合条件
              <span style="color:#379FFF">{{UserapplicationDataTotal}}</span>条
            </p>
            <el-form
              class="TableSelectMain"
              :model="UserapplicationSearch"
              :inline="true"
              label-position="left"
            >
              <el-row>
                <el-form-item style="width: 255px;">
                  <el-input
                    style="width: 255px;"
                    v-model="UserapplicationSearch.queryCondition"
                    placeholder="请输入您要查询的用户名或手机号"
                  ></el-input>
                </el-form-item>
                <el-form-item style="width:15%">
                  <el-button type="primary" round @click="searchUser">查询</el-button>
                </el-form-item>
              </el-row>
            </el-form>
            <el-table
              ref="multipleTable"
              :data="UserapplicationData"
              style="width: 100%"
              :header-cell-style="{'background-color':'rgba(250,250,250,1)'}"
              border
              v-loading="UserapplicationDataLoad"
            >
              <el-table-column label="头像" width="100px;">
                <template slot-scope="props">
                  <img :src="props.row.userAvatarUrl" alt />
                </template>
              </el-table-column>
              <el-table-column prop="userName" label="用户名"></el-table-column>
              <el-table-column prop="userMobile" label="手机号"></el-table-column>
              <!-- <el-table-column label="用户类型">
                <template slot-scope="props">
                  <span>{{props.row.userType==0?'超级管理员':(props.row.userType==1?'平台管理员':(props.row.userType==2?'企业管理员':(props.row.userType==3?'普通用户':'')))}}</span>
                </template>
              </el-table-column>-->
              <el-table-column label="申请事项" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <span>{{props.row.applyType==1?'加入团队':(props.row.applyType==2?'加入项目':'')}}</span>
                </template>
              </el-table-column>
              <el-table-column label="权限" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <span>{{props.row.powerType==21?'查看':(props.row.powerType==22?'评价':'无')}}</span>
                </template>
              </el-table-column>
              <el-table-column prop="applyDate" label="申请时间"></el-table-column>
              <el-table-column label="操作" min-width="200px;">
                <template slot-scope="props">
                  <el-button
                    size="mini"
                    type="primary"
                    plain
                    round
                    style="margin-left: 5px;"
                    v-if="UserapplicationBtn.UserapplicationBtn12"
                    @click="UserApplicationWyUpdate(props.row)"
                  >通过</el-button>

                  <el-button
                    size="mini"
                    type="warning"
                    plain
                    round
                    v-if="UserapplicationBtn.UserapplicationBtn13"
                    @click="UserApplicationWyUpdateUnpass(props.row)"
                  >不通过</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane :label="'已审核('+UsecondText+')'" name="second">
            <p class="SearchTitle">
              总记录条数
              <span style="color:#379FFF">{{TitleTotal}}</span>条，符合条件
              <span style="color:#379FFF">{{UserapplicationDataTotal}}</span>条
            </p>
            <el-form
              class="TableSelectMain"
              :model="UserapplicationSearch"
              :inline="true"
              label-position="left"
            >
              <el-row>
                <el-form-item style="width: 255px;">
                  <el-input
                    style="width: 255px;"
                    v-model="UserapplicationSearch.queryCondition"
                    placeholder="请输入您要查询的用户名或手机号"
                  ></el-input>
                </el-form-item>
                <el-form-item style="width:15%">
                  <el-button type="primary" round @click="searchUser">查询</el-button>
                </el-form-item>
              </el-row>
            </el-form>
            <el-table
              ref="multipleTable"
              :data="UserapplicationData"
              style="width: 100%"
              :header-cell-style="{'background-color':'rgba(250,250,250,1)'}"
              border
              v-loading="UserapplicationDataLoad"
            >
              <el-table-column label="头像" width="100px;">
                <template slot-scope="props">
                  <img :src="props.row.userAvatarUrl" alt />
                </template>
              </el-table-column>
              <el-table-column prop="userName" label="用户名"></el-table-column>
              <el-table-column prop="userMobile" label="手机号"></el-table-column>
              <el-table-column prop="roleName" label="角色名称">
                <!-- <template slot-scope="props">
                  <span>{{props.row.userType==0?'超级管理员':(props.row.userType==1?'平台管理员':(props.row.userType==2?'企业管理员':(props.row.userType==3?'普通用户':'')))}}</span>
                </template>-->
              </el-table-column>
              <el-table-column label="申请事项" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <span>{{props.row.applyType==1?'加入团队':(props.row.applyType==2?'加入项目':'')}}</span>
                </template>
              </el-table-column>
              <el-table-column label="权限" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <span>{{props.row.powerType==21?'查看':(props.row.powerType==22?'评价':'无')}}</span>
                </template>
              </el-table-column>
              <el-table-column prop="applyDate" label="申请时间"></el-table-column>
              <el-table-column prop="dealDate" label="处理时间"></el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane :label="'未通过('+UthirdText+')'" name="third">
            <p class="SearchTitle">
              总记录条数
              <span style="color:#379FFF">{{TitleTotal}}</span>条，符合条件
              <span style="color:#379FFF">{{UserapplicationDataTotal}}</span>条
            </p>
            <el-form
              class="TableSelectMain"
              :model="UserapplicationSearch"
              :inline="true"
              label-position="left"
            >
              <el-row>
                <el-form-item style="width: 255px;">
                  <el-input
                    style="width: 255px;"
                    v-model="UserapplicationSearch.queryCondition"
                    placeholder="请输入您要查询的用户名或手机号"
                  ></el-input>
                </el-form-item>
                <el-form-item style="width:15%">
                  <el-button type="primary" round @click="searchUser">查询</el-button>
                </el-form-item>
              </el-row>
            </el-form>
            <el-table
              ref="multipleTable"
              :data="UserapplicationData"
              style="width: 100%"
              :header-cell-style="{'background-color':'rgba(250,250,250,1)'}"
              border
              v-loading="UserapplicationDataLoad"
            >
              <el-table-column label="头像" width="100px;">
                <template slot-scope="props">
                  <img :src="props.row.userAvatarUrl" alt />
                </template>
              </el-table-column>
              <el-table-column prop="userName" label="用户名"></el-table-column>
              <el-table-column prop="userMobile" label="手机号"></el-table-column>
              <!-- <el-table-column label="用户类型">
                <template slot-scope="props">
                  <span>{{props.row.userType==0?'超级管理员':(props.row.userType==1?'平台管理员':(props.row.userType==2?'企业管理员':(props.row.userType==3?'普通用户':'')))}}</span>
                </template>
              </el-table-column>-->
              <el-table-column label="申请事项" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <span>{{props.row.applyType==1?'加入团队':(props.row.applyType==2?'加入项目':'')}}</span>
                </template>
              </el-table-column>
              <el-table-column label="权限" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <span>{{props.row.powerType==21?'查看':(props.row.powerType==22?'评价':'无')}}</span>
                </template>
              </el-table-column>
              <el-table-column prop="applyDate" label="申请时间"></el-table-column>
              <el-table-column prop="dealDate" label="处理时间"></el-table-column>
            </el-table>
          </el-tab-pane>

          <div class="pagenation">
            <span>
              <el-pagination
                background
                layout="prev, pager, next, sizes, total, jumper"
                :total="UserapplicationDataTotal"
                @current-change="click"
                @size-change="handleSizeChange"
                :page-sizes="[5, 10, 15, 20]"
                :page-size="pagesize"
              ></el-pagination>
            </span>
          </div>
        </el-tabs>
        <!-- v-if="MTCompanyID=='0'&&LeftToId==0" -->
        <el-tabs
          v-if="MTCompanyID=='10086'"
          class="BCtabs"
          v-model="activeName"
          type="border-card"
          @tab-click="handleClickCompany"
        >
          <el-form
            class="TableSelectMain"
            :model="CompanySearch"
            :inline="true"
            label-position="left"
          >
            <el-row>
              <el-form-item style="width: 255px;">
                <el-select
                  style="width: 255px;"
                  clearable
                  filterable
                  v-model="CompanySearch.queryCompanyId"
                  placeholder="请输入您要查询的客户名称"
                >
                  <el-option
                    v-for="item in queryConditionList"
                    :key="item.companyId"
                    :label="item.companyName"
                    :value="item.companyId"
                  ></el-option>
                </el-select>
              </el-form-item>
              <el-form-item style="width:15%">
                <el-button type="primary" round @click="searchCompany">查询</el-button>
              </el-form-item>
            </el-row>
          </el-form>
          <el-tab-pane :label="'待审核('+CfirstText+')'" name="first">
            <p class="SearchTitle">
              总记录条数
              <span style="color:#379FFF">{{CompanyTitleTotal}}</span>条，符合条件
              <span style="color:#379FFF">{{CompanyDataTotal}}</span>条
            </p>
            <!-- <el-form
              class="TableSelectMain"
              :model="CompanySearch"
              :inline="true"
              label-position="left"
            >
              <el-row>
                <el-form-item style="width: 255px;">
                  <el-select style="width: 255px;" v-model="CompanySearch.queryCompanyId" placeholder="请输入您要查询的客户名称">
                    <el-option
                      v-for="item in queryConditionList"
                      :key="item.companyId"
                      :label="item.companyName"
                      :value="item.companyId"
                      clearable filterable
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item style="width:15%">
                  <el-button type="primary" round @click="searchCompany">查询</el-button>
                </el-form-item>
              </el-row>
            </el-form>-->
            <el-table
              :data="CompanyData"
              style="width: 100%"
              :header-cell-style="{'background-color':'rgba(250,250,250,1)'}"
              border
              v-loading="CompanyDataLoad"
            >
              <el-table-column label="团队头像" width="100px;" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <img
                    :src="props.row.logoImg"
                    alt
                    style="width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-left: 30%;"
                  />
                </template>
              </el-table-column>
              <el-table-column
                prop="attestationName"
                label="团队名"
                min-width="250px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column
                prop="contactsTel"
                label="手机号"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column prop="contactsName" label="用户名" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column
                prop="businessLicenseAnnex"
                min-width="120px"
                label="营业执照路径"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="props">
                  <div
                    v-if="props.row.businessLicenseAnnex"
                    class="demo-image"
                    @click="showImage(props.row.businessLicenseAnnex)"
                  >
                    <el-image
                      style="width: 100px; height: 100px;cursor: pointer;"
                      :src="props.row.businessLicenseAnnex"
                      fit="fill"
                    ></el-image>
                  </div>
                  <!-- props.row.imgs[0].imgUrl</span> -->
                </template>
              </el-table-column>
              <el-table-column
                prop="taxRegistration"
                min-width="120px"
                label="资质证书路径"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="props">
                  <div
                    v-if="props.row.taxRegistration"
                    class="demo-image"
                    @click="showImage(props.row.taxRegistration)"
                  >
                    <el-image
                      style="width: 100px; height: 100px;cursor: pointer;"
                      :src="props.row.taxRegistration"
                      fit="fill"
                    ></el-image>
                  </div>
                  <!-- props.row.imgs[0].imgUrl</span> -->
                </template>
              </el-table-column>

              <el-table-column
                prop="createTime"
                label="申请时间"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column label="操作" min-width="150px;">
                <template slot-scope="props">
                  <el-button
                    size="mini"
                    type="primary"
                    plain
                    round
                    style="margin-left: 5px;"
                    @click="CompanyWyUpdate(props.row)"
                  >通过</el-button>

                  <el-button
                    size="mini"
                    type="warning"
                    plain
                    round
                    @click="CompanyWyUpdateUnpass(props.row)"
                  >不通过</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane :label="'已审核('+CsecondText+')'" name="second">
            <p class="SearchTitle">
              总记录条数
              <span style="color:#379FFF">{{CompanyTitleTotal}}</span>条，符合条件
              <span style="color:#379FFF">{{CompanyDataTotal}}</span>条
            </p>
            <el-table
              :data="CompanyData"
              style="width: 100%"
              :header-cell-style="{'background-color':'rgba(250,250,250,1)'}"
              border
              v-loading="CompanyDataLoad"
            >
              <el-table-column label="团队头像" width="100px;" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <img
                    :src="props.row.logoImg"
                    style="width: 50px; height: 50px;border-radius: 50%;margin-left: 30%;"
                  />
                </template>
              </el-table-column>
              <el-table-column
                prop="attestationName"
                label="团队名"
                min-width="250px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column
                prop="contactsTel"
                label="手机号"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column prop="contactsName" label="用户名" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column
                prop="businessLicenseAnnex"
                min-width="120px"
                label="营业执照路径"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="props">
                  <div
                    v-if="props.row.businessLicenseAnnex"
                    class="demo-image"
                    @click="showImage(props.row.businessLicenseAnnex)"
                  >
                    <el-image
                      style="width: 100px; height: 100px;cursor: pointer;"
                      :src="props.row.businessLicenseAnnex"
                      fit="fill"
                    ></el-image>
                  </div>
                  <!-- props.row.imgs[0].imgUrl</span> -->
                </template>
              </el-table-column>
              <el-table-column
                prop="taxRegistration"
                min-width="120px"
                label="资质证书路径"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="props">
                  <div
                    v-if="props.row.taxRegistration"
                    class="demo-image"
                    @click="showImage(props.row.taxRegistration)"
                  >
                    <el-image
                      style="width: 100px; height: 100px;cursor: pointer;"
                      :src="props.row.taxRegistration"
                      fit="fill"
                    ></el-image>
                  </div>
                  <!-- props.row.imgs[0].imgUrl</span> -->
                </template>
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="申请时间"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column
                prop="dealTime"
                label="处理时间"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column label="操作" min-width="200px;">
                <template slot-scope="props">
                  <el-button
                    size="mini"
                    type="primary"
                    plain
                    round
                    style="margin-left: 5px;"
                    @click="UpdateCompanyWyUpdate(props.row)"
                  >修改信息</el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane :label="'未通过('+CthirdText+')'" name="third">
            <p class="SearchTitle">
              总记录条数
              <span style="color:#379FFF">{{CompanyTitleTotal}}</span>条，符合条件
              <span style="color:#379FFF">{{CompanyDataTotal}}</span>条
            </p>
            <!-- <el-form
              class="TableSelectMain"
              :model="CompanySearch"
              :inline="true"
              label-position="left"
            >
              <el-row>
                <el-form-item style="width: 255px;">
                  <el-select style="width: 255px;" clearable filterable v-model="CompanySearch.queryCompanyId" placeholder="请输入您要查询的客户名称">
                    <el-option
                      v-for="item in queryConditionList"
                      :key="item.companyId"
                      :label="item.companyName"
                      :value="item.companyId"
                    ></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item style="width:15%">
                  <el-button type="primary" round @click="searchCompany">查询</el-button>
                </el-form-item>
              </el-row>
            </el-form>-->
            <el-table
              :data="CompanyData"
              style="width: 100%"
              :header-cell-style="{'background-color':'rgba(250,250,250,1)'}"
              border
              v-loading="CompanyDataLoad"
            >
              <el-table-column label="团队头像" width="100px;" :show-overflow-tooltip="true">
                <template slot-scope="props">
                  <img
                    :src="props.row.logoImg"
                    style="width:50px; height:50px;border-radius: 50%;margin-left: 30%;"
                  />
                </template>
              </el-table-column>
              <el-table-column
                prop="attestationName"
                label="团队名"
                min-width="250px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column
                prop="contactsTel"
                label="手机号"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column prop="contactsName" label="用户名" :show-overflow-tooltip="true"></el-table-column>
              <el-table-column
                prop="businessLicenseAnnex"
                min-width="120px"
                label="营业执照路径"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="props">
                  <div
                    v-if="props.row.businessLicenseAnnex"
                    class="demo-image"
                    @click="showImage(props.row.businessLicenseAnnex)"
                  >
                    <el-image
                      style="width: 100px; height: 100px;cursor: pointer;"
                      :src="props.row.businessLicenseAnnex"
                      fit="fill"
                    ></el-image>
                  </div>
                  <!-- props.row.imgs[0].imgUrl</span> -->
                </template>
              </el-table-column>
              <el-table-column
                prop="taxRegistration"
                min-width="120px"
                label="资质证书路径"
                :show-overflow-tooltip="true"
              >
                <template slot-scope="props">
                  <div
                    v-if="props.row.taxRegistration"
                    class="demo-image"
                    @click="showImage(props.row.taxRegistration)"
                  >
                    <el-image
                      style="width: 100px; height: 100px;cursor: pointer;"
                      :src="props.row.taxRegistration"
                      fit="fill"
                    ></el-image>
                  </div>
                  <!-- props.row.imgs[0].imgUrl</span> -->
                </template>
              </el-table-column>
              <el-table-column
                prop="createTime"
                label="申请时间"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
              <el-table-column
                prop="dealTime"
                label="处理时间"
                min-width="120px"
                :show-overflow-tooltip="true"
              ></el-table-column>
            </el-table>
          </el-tab-pane>

          <div class="pagenation">
            <span>
              <el-pagination
                background
                layout="prev, pager, next, sizes, total, jumper"
                :total="CompanyDataTotal"
                @current-change="click1"
                @size-change="handleSizeChange1"
                :page-sizes="[5, 10, 15, 20]"
                :page-size="pagesize1"
              ></el-pagination>
            </span>
          </div>
        </el-tabs>
      </el-row>
    </div>

    <!--分配角色-->
    <div class="AllocationRole">
      <el-dialog
        title="角色列表"
        :visible.sync="dialogAllocationRole"
        width="50%"
        :before-close="handleClose"
      >
        <el-radio-group v-model="roleId">
          <el-radio
            v-for="item in Role"
            :key="item.id"
            :label="item.id"
            :value="item.id"
          >{{item.name}}</el-radio>
        </el-radio-group>
        <div slot="footer" class="dialog-footer Txc">
          <el-button type="primary" @click="submitUPass">确 定</el-button>
          <el-button @click="dialogAllocationRole = false">取 消</el-button>
        </div>
      </el-dialog>
    </div>

    <div class="CompanyEnterprise">
      <el-dialog
        :title="isAddEnterprise==1?'团队信息设置':'团队信息修改'"
        :visible.sync="dialogCompanyEnterprise"
        width="60%"
        :before-close="handleClose"
      >
        <el-form
          class="CompanyEnterpriseForm"
          :model="CompanyEnterpriseForm"
          :inline="true"
          label-position="left"
        >
          <el-row>
            <el-form-item label="VIP用户：">
              <el-radio-group v-model="CompanyEnterpriseForm.vipFlag">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-row>
          <el-row>
            <el-form-item label="电梯台量：">
              <el-input v-model="CompanyEnterpriseForm.limitedNum" placeholder="请输入电梯台量"></el-input>
            </el-form-item>
          </el-row>
          <el-row v-if="isCertificated==2">
            <el-form-item label="是否默认分配菜单：">
              <el-radio-group v-model="CompanyEnterpriseForm.defaultAssign">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-row>
          <div class="radioList" v-if="!CompanyEnterpriseForm.defaultAssign">
            <el-row>菜单列表：</el-row>
            <el-row type="flex" justify="space-between" class="listModal">
              <el-col :span="11" :offset="1">
                <span>主菜单</span>
              </el-col>
              <el-col :span="11" :offset="1" style="padding-left: 2%;">
                <span>子菜单</span>
              </el-col>
              <!-- <el-col :span="14">
                <span>操作权限</span>
              </el-col>-->
            </el-row>
            <el-checkbox-group v-model="checkList">
              <el-row
                v-for="(item,index) in menuList"
                :key="index"
                type="flex"
                justify="space-between"
                class="border1"
              >
                <el-col :span="11" :offset="1">
                  <div>
                    <el-checkbox
                      :label="item.id"
                      v-model="item.id"
                      :checked="item.checked"
                      :disabled="isModal.isCheck"
                      @change="changeOne(item)"
                    >{{item.name}}</el-checkbox>
                  </div>
                </el-col>
                <el-col :span="11" :offset="1">
                  <el-row
                    v-for="(itemTwo,iTwo) in item.children"
                    :key="iTwo"
                    type="flex"
                    justify="space-between"
                  >
                    <el-col :span="22" :offset="1">
                      <div>
                        <el-checkbox
                          :disabled="isModal.isCheck"
                          :label="itemTwo.id"
                          v-model="itemTwo.checked"
                          :checked="itemTwo.checked"
                          @change="changeState(index,item,itemTwo)"
                        >{{itemTwo.name}}</el-checkbox>
                      </div>
                    </el-col>
                    <!-- <el-col :span="16" :offset="1" class="FlexContair">
                      <el-row type="flex" justify="start  ">
                        <el-col
                          :span="6"
                          v-for="(itemThree,iThree) in itemTwo.children"
                          :key="iThree"
                        >
                          <div>
                            <el-checkbox
                              :label="itemThree.id"
                              v-model="itemThree.id"
                              :checked="itemThree.checked"
                              @change="changeState(index,iTwo,itemTwo.id,itemThree.id,'three',item.id)"
                            >{{itemThree.name}}</el-checkbox>
                          </div>
                        </el-col>
                      </el-row>
                    </el-col>-->
                  </el-row>
                </el-col>
              </el-row>
            </el-checkbox-group>
          </div>
        </el-form>

        <div slot="footer" class="dialog-footer Txc">
          <el-button type="primary" @click="submitCompanyEnterprise">确 定</el-button>
          <el-button @click="dialogCompanyEnterprise = false">取 消</el-button>
        </div>
      </el-dialog>
    </div>

    <div class="UserUnPass">
      <el-dialog
        title="不通过"
        :visible.sync="dialogUserUnPass"
        width="30%"
        :before-close="handleClose"
      >
        <p>确定不通过该申请吗？</p>
        <div slot="footer" class="dialog-footer Txc">
          <el-button type="primary" @click="submitUUnPass">确 定</el-button>
          <el-button @click="dialogUserUnPass = false">取 消</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="CUnPass">
      <el-dialog title="审核说明" :visible.sync="dialogCUnPass" width="30%" :before-close="handleClose">
        <el-input type="textarea" v-model="checkFeedBack"></el-input>
        <div slot="footer" class="dialog-footer Txc">
          <el-button type="primary" @click="submitCUnPass">确 定</el-button>
          <el-button @click="dialogCUnPass = false">取 消</el-button>
        </div>
      </el-dialog>
    </div>
    <div class="Image">
      <el-dialog title="图片" :visible.sync="dialogImageUrl" width="780px" :before-close="handleClose">
        <div class="block">
          <div style="width:740px;">
            <img :src="Image" alt="" style="width:100%;">
          </div>
          <!-- <el-carousel height="350px">
            <el-carousel-item v-for="item in Image" :key="item.sort">
              <el-image :src="item.imgUrl" fit="fill"></el-image>
            </el-carousel-item>
          </el-carousel> -->
        </div>
        <div slot="footer" class="dialog-footer Txc">
          <el-button @click="dialogImageUrl = false">关 闭</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  name: "Userapplication",
  data() {
    return {
      MTCompanyID: JSON.parse(sessionStorage.getItem("mtCompanyId")),
      activeName: "first",
      //分页
      pagesize: 10,
      handleClose: null,
      currpage: 1,
      UserapplicationSearch: {
        queryCondition: ""
      },
      CompanySearch: {
        queryCompanyId: ""
      },
      queryConditionList: [],
      dialogUserUnPass: false,
      UserapplicationData: [],
      dialogImageUrl: false,
      Image:"",
      checkFeedBack: "",
      isModal: {
        isAdd: false,
        isCheck: true
      },
      dialogCUnPass: false,
      WaitUserDataPass: [
        {
          ApplyDate: "/Date(1565071276000)/",
          AvatarUrl:
            "https://ty-picture.oss-cn-hangzhou.aliyuncs.com/tx123.png",
          DealDate: "/Date(1565071295000)/",
          DealUserID: 0,
          Description: "1111",
          MTCompanyID: 0,
          Mobile: "13396070523",
          Name: "黄龙山",
          PowerType: 0,
          ProjectID: 0,
          ProjectName: null,
          Status: 2,
          UserID: 1001101131132,
          UserType: 1
        }
      ],
      UserDataPass: [
        {
          ApplyDate: "/Date(1565086684000)/",
          AvatarUrl:
            "https://ty-picture.oss-cn-hangzhou.aliyuncs.com/tx123.png",
          DealDate: "/Date(1565086750000)/",
          DealUserID: 0,
          Description: "uuu",
          MTCompanyID: 0,
          Mobile: "15135779005",
          Name: "杨",
          PowerType: 0,
          ProjectID: 0,
          ProjectName: null,
          Status: 1,
          UserID: 1001101131139,
          UserType: 1
        }
      ],
      UserDataUnPass: [
        {
          ApplyDate: "/Date(1563520460000)/",
          AvatarUrl:
            "https://ty-picture.oss-cn-hangzhou.aliyuncs.com/tx123.png",
          DealDate: "/Date(1563763473000)/",
          DealUserID: 0,
          Description: "",
          MTCompanyID: 0,
          Mobile: "15094965329",
          Name: "刘健良",
          PowerType: 0,
          ProjectID: 0,
          ProjectName: null,
          Status: 2,
          UserID: 1001101131110,
          UserType: 1
        }
      ],
      //模态框
      dialogAllocationRole: false,
      //角色
      Role: [],
      UserapplicationDataTotal: 10,
      TitleTotal: 10,
      UserapplicationStatus: 2,
      CompanyTitleTotal: 10,
      CompanyDataTotal: 10,
      isCertificated: 2,
      pagesize1: 10,
      currpage1: 1,
      CompanyData: [],
      CompanyDataLoad: false,
      roleId: "",
      UserApplicationWyUpdateId: "",
      UserApplicationWyUpdateUnpassId: "",
      CompanyWyUpdateId: "",
      CompanyWyUpdateUnpassId: "",
      UpdateCompanyWyUpdateId: "",
      UfirstText: "",
      UsecondText: "",
      UthirdText: "",
      CfirstText: "",
      CsecondText: "",
      CthirdText: "",
      menuList: [],
      dialogCompanyEnterprise: false,
      CompanyEnterpriseForm: {
        vipFlag: 0,
        limitedNum: "",
        defaultAssign: 0
      },
      checkList: [],
      isAddEnterprise: 1,
      isUnpassCU: 1,
      UserapplicationBtn: {
        Liftcertificate12: 0,
        Liftcertificate13: 0
      }
    };
  },
  created() {
    if (this.MTCompanyID == "10086") {
      this.CompanyQUList();
      this.showCompanyData(2, 1, 10);
    } else {
      this.showUserapplicationData(2, 1, 10);

      var UserapplicationBtn = {};
      this.getButton(11).then(result => {
        if (result.data.statusCode === "1") {
          UserapplicationBtn = result.data.data;
          UserapplicationBtn.map(item => {
            if (item.id == 12) {
              this.UserapplicationBtn.UserapplicationBtn12 = item.checked
                ? 1
                : 0;
            } else if (item.id == 13) {
              this.UserapplicationBtn.UserapplicationBtn13 = item.checked
                ? 1
                : 0;
            }
          });
        }
      });
    }
  },
  methods: {
    // 分页页码
    click(val) {
      this.currpage = val;
      this.showUserapplicationData(
        this.UserapplicationStatus,
        val,
        this.pagesize
      );
    },
    // 分页显示条数
    handleSizeChange(val) {
      this.showUserapplicationData(
        this.UserapplicationStatus,
        this.currpage,
        val
      );
      this.pagesize = val;
    },
    // 分页页码
    click1(val) {
      this.currpage1 = val;
      this.showCompanyData(this.isCertificated, val, this.pagesize1);
    },
    CompanyQUList() {
      var url = "system/attestation/applyCompanyList";
      var param = {
        isCertificated: this.isCertificated
      };
      this.axios.post(url, param).then(result => {
        var data = result;
        if (data.statusCode === "1") {
          this.queryConditionList = data.data;
        } else {
          this.$message.error(data.message);
        }
      });
    },
    // 分页显示条数
    handleSizeChange1(val) {
      this.showCompanyData(this.isCertificated, this.currpage1, val);
      this.pagesize1 = val;
    },
    changeOne(item) {
      var _this = this;
      if (item.children) {
        var a = [];
        for (var i of item.children) {
          a.push(i.id);
          if (i.children) {
            for (var j of i.children) {
              a.push(j.id);
            }
          }
        }
        _this.checkList = _this.checkList.filter(value => {
          return a.every(item => {
            return value !== item;
          });
        });
      }
    },
    showUserapplicationData(status, pageNum, pageSize) {
      this.UserapplicationDataLoad = true;
      var url = "system/userapply/list";
      var param = {
        companyId: JSON.parse(sessionStorage.getItem("mtCompanyId")),
        status: status,
        pageNum: pageNum,
        pageSize: pageSize
      };
      this.UserapplicationSearch.queryCondition
        ? (param.queryCondition = this.UserapplicationSearch.queryCondition)
        : "";
      this.axios.post(url, param).then(result => {
        var data = result;
        console.log(data);
        if (data.statusCode) this.UserapplicationDataLoad = false;
        if (data.statusCode === "1") {
          this.UserapplicationData = data.data.page.rows;
          this.UserapplicationDataTotal = data.data.page.total;
          this.TitleTotal = data.data.count;

          this.UfirstText = data.data.applyWaitCount;
          this.UsecondText = data.data.applyPassCount;
          this.UthirdText = data.data.applyFailCount;
        } else {
          this.$message.error(data.message);
        }
      });
    },
    showCompanyData(isCertificated, pageNum, pageSize) {
      this.CompanyDataLoad = true;
      // var url = "system/attestation/list";
      var url = "system/attestation/list";
      var param = {
        companyId: JSON.parse(sessionStorage.getItem("mtCompanyId")),
        isCertificated: isCertificated,
        userId: sessionStorage.getItem("user"),
        pageNum: pageNum,
        pageSize: pageSize
      };
      this.CompanySearch.queryCompanyId
        ? (param.queryCompanyId = this.CompanySearch.queryCompanyId)
        : "";
      this.axios.post(url, param).then(result => {
        var data = result;
        console.log(data);
        if (data.statusCode) this.CompanyDataLoad = false;
        if (data.statusCode === "1") {
          this.CompanyData = data.data.page.rows;
          this.CompanyDataTotal = data.data.page.total;
          this.CompanyTitleTotal = data.data.count;
          this.CfirstText = data.data.applyWaitCount;
          this.CsecondText = data.data.applyPassCount;
          this.CthirdText = data.data.applyFailCount;
        } else {
          this.$message.error(data.message);
        }
      });
    },
    getRole() {
      var url = "system/role/companyRoleList";
      var param = {
        companyId: JSON.parse(sessionStorage.getItem("mtCompanyId"))
      };

      this.axios.post(url, param).then(result => {
        var data = result;
        console.log(data);
        if (data.statusCode === "1") {
          this.Role = data.data;
          console.log(this.Role);
        } else {
          this.$message.error(data.message);
        }
      });
    },
    showImage(imgUrl) {
      this.Image=imgUrl;
      this.dialogImageUrl = true;
    },
    // 判断是否选了上级
    changeState(...age) {
      var _this = this;
      if (age[2].children) {
        _this.checkList = _this.checkList.filter(value => {
          return age[2].children.every(item => {
            return value !== item.id;
          });
        });
      }
      if (_this.checkList.indexOf(age[1].id) === -1)
        _this.checkList.push(age[1].id);
    },
    changeState2(...age) {
      // 判断是勾选还是取消
      var _this = this;
      if (_this.checkList.indexOf(age[3].id) === -1)
        _this.checkList.push(age[3].id);
      if (_this.checkList.indexOf(age[1].id) === -1)
        _this.checkList.push(age[1].id);
    },
    handleClickUser(tab, event) {
      this.UserapplicationSearch.queryCondition = "";
      if (tab.$el.id == "pane-first") {
        this.UserapplicationStatus = 2;
        this.showUserapplicationData(
          this.UserapplicationStatus,
          this.currpage,
          this.pagesize
        );
      } else if (tab.$el.id == "pane-second") {
        this.UserapplicationStatus = 1;
        this.showUserapplicationData(
          this.UserapplicationStatus,
          this.currpage,
          this.pagesize
        );
      } else if (tab.$el.id == "pane-third") {
        this.UserapplicationStatus = -1;
        this.showUserapplicationData(
          this.UserapplicationStatus,
          this.currpage,
          this.pagesize
        );
      }
      console.log(this.UserapplicationStatus);
    },
    handleClickCompany(tab, event) {
      this.CompanySearch.queryCompanyId = "";
      if (tab.$el.id == "pane-first") {
        this.isCertificated = 2;
        this.showCompanyData(
          this.isCertificated,
          this.currpage1,
          this.pagesize1
        );
      } else if (tab.$el.id == "pane-second") {
        this.isCertificated = 1;
        this.showCompanyData(
          this.isCertificated,
          this.currpage1,
          this.pagesize1
        );
      } else if (tab.$el.id == "pane-third") {
        this.isCertificated = 3;
        this.showCompanyData(
          this.isCertificated,
          this.currpage1,
          this.pagesize1
        );
      }
      this.CompanyQUList();
    },
    CompanyWyUpdate(row) {
      this.isAddEnterprise = 1;
      this.CompanyWyUpdateId = row.id;
      this.isModal.isAdd = true;
      this.isModal.isCheck = false;
      this.menuAll();
      this.dialogCompanyEnterprise = true;
    },
    CompanyWyUpdateUnpass(row) {
      this.CompanyWyUpdateUnpassId = row.id;
      this.isUnpassCU = 0;
      this.dialogCUnPass = true;
    },
    UpdateCompanyWyUpdate(row) {
      this.menuList = [];
      this.checkList = [];
      this.UpdateCompanyWyUpdateId = row.id;
      this.isAddEnterprise = 0;
      var url = "system/menu/all";
      var param = { companyId: row.mtCompanyId };
      this.axios.post(url, param).then(res => {
        if (res.statusCode === "1") {
          this.menuList = res.data;
        } else {
          this.$message({
            type: "info",
            message: res.message
          });
        }
      });
      this.CompanyEnterpriseForm.vipFlag = row.vipFlag;
      this.CompanyEnterpriseForm.limitedNum = row.limitedNum;
      this.CompanyEnterpriseForm.defaultAssign = row.defaultAssign;
      this.isModal.isCheck = false;
      this.isModal.isAdd = true;
      this.dialogCompanyEnterprise = true;
    },
    //通过申请
    UserApplicationWyUpdate(row) {
      this.UserApplicationWyUpdateId = row.id;
      if (row.applyType == 2) {
        var url = "system/userapply/applyPass";
        var param = {
          id: this.UserApplicationWyUpdateId,
          roleId: "",
          userId: sessionStorage.getItem("user")
        };
        this.axios.post(url, param).then(result => {
          var data = result;
          if (data.statusCode === "1") {
            this.$message.success(data.message);
            this.showUserapplicationData(
              this.UserapplicationStatus,
              this.currpage,
              this.pagesize
            );
          } else {
            this.$message.error(data.message);
          }
        });
      } else {
        this.getRole();
        this.dialogAllocationRole = true;
      }
    },
    submitUPass() {
      if (this.roleId) {
        var url = "system/userapply/applyPass";
        var param = {
          id: this.UserApplicationWyUpdateId,
          roleId: this.roleId,
          userId: sessionStorage.getItem("user")
        };
        this.axios.post(url, param).then(result => {
          var data = result;
          if (data.statusCode === "1") {
            this.$message.success(data.message);
            this.showUserapplicationData(
              this.UserapplicationStatus,
              this.currpage,
              this.pagesize
            );
            this.dialogAllocationRole = false;
          } else {
            this.$message.error(data.message);
          }
        });
      } else {
        this.$message.error("请选择角色！");
      }
    },
    submitUUnPass() {
      var url = "system/userapply/applyFail";
      var param = {
        id: this.UserApplicationWyUpdateUnpassId,
        userId: sessionStorage.getItem("user")
      };
      this.axios.post(url, param).then(result => {
        var data = result;
        if (data.statusCode === "1") {
          this.$message.success(data.message);
          this.showUserapplicationData(
            this.UserapplicationStatus,
            this.currpage,
            this.pagesize
          );
          this.dialogUserUnPass = false;
        } else {
          this.$message.error(data.message);
        }
      });
    },
    submitCUnPass() {
      var url = "system/attestation/auditFail";
      var param = {
        id: this.CompanyWyUpdateUnpassId,
        checkFeedBack: this.checkFeedBack
      };
      this.axios.post(url, param).then(result => {
        var data = result;
        if (data.statusCode === "1") {
          this.$message.success(data.message);
          this.showCompanyData(
            this.isCertificated,
            this.currpage1,
            this.pagesize1
          );
          this.dialogCUnPass = false;
        } else {
          this.$message.error(data.message);
        }
      });
    },
    UserApplicationWyUpdateUnpass(row) {
      this.UserApplicationWyUpdateUnpassId = row.id;
      this.isUnpassCU = 1;
      this.dialogUserUnPass = true;
    },
    searchUser() {
      this.showUserapplicationData(this.UserapplicationStatus, 1, 10);
    },
    searchCompany() {
      this.showCompanyData(this.isCertificated, 1, 10);
    },
    menuAll() {
      var url = "system/menu/all";
      var param = {
        companyId: JSON.parse(sessionStorage.getItem("mtCompanyId"))
      };
      this.axios.post(url, param).then(res => {
        if (res.statusCode === "1") {
          this.menuList = res.data;
        } else {
          this.$message({
            type: "info",
            message: res.message
          });
        }
      });
    },
    submitCompanyEnterprise() {
      if (this.CompanyEnterpriseForm.limitedNum) {
        var url = "";
        var param = this.CompanyEnterpriseForm;

        if (this.isAddEnterprise == 0) {
          var menuId = this.checkList ? this.checkList.join(",") : [];
          url = "system/mtcompany/updateCompany";
          param.id = this.UpdateCompanyWyUpdateId;
          param.menuIds = menuId;
        } else if (this.isAddEnterprise == 1) {
          var menuId = this.checkList ? this.checkList.join(",") : [];
          url = "system/attestation/auditPass";
          param.id = this.CompanyWyUpdateId;
          param.customerManagerId = sessionStorage.getItem("user");
          param.menuIds = menuId;
        }
        this.axios.post(url, param).then(res => {
          if (res.statusCode === "1") {
            this.$message({
              type: "success",
              message: res.message
            });
            this.showCompanyData(
              this.isCertificated,
              this.currpage1,
              this.pagesize1
            );
            this.dialogCompanyEnterprise = false;
          } else {
            this.$message.error(res.message);
          }
        });
      } else {
        this.$message.error("请填写电梯台量！");
      }
    }
  }
};
</script>
<style lang="stylus">
.Userapplication {
  height: 100%;

  .UserapplicationMain {
    height: 100%;
    background: #fff;
  }

  .cell {
    text-align: center;
  }

  .el-tabs__header {
    margin: 20px;
  }

  .el-table {
    img {
      width: 100px;
      height: 100px;
    }
  }

  .SearchTitle {
  }

  .el-radio {
    width: 15%;
    padding: 10px;
  }
}

.radioList {
  >.el-row {
    padding: 15px 0;
  }

  >.el-row:first-child {
    padding: 0;
  }

  .border1 {
    border-bottom: 1px solid #E8E8E8;
    padding: 10px 0;
  }

  .FlexContair {
    // .el-row--flex{
    // flex-flow:row wrap;
    // }
    // display: flex;
    // justify-content:start;
    // flex-flow:row wrap;
    // >span{}
  }

  .listModal {
    background: #fafafa;

    [class*=el-col-] {
      text-align: left;
    }
  }
}

.Image .el-image .el-image__inner {
  height: 350px;
}
</style>

