<template>
  <div class="app-container">
    <!-- 顶部操作区域 -->
    <div class="filter-container">
      <div class="filter-control">
        <span>机构ID:</span>
        <el-input
          v-model="listQuery.clubId"
          style="width: 120px"
          placeholder="机构ID"
          clearable
          maxlength="10"
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <span>机构名称:</span>
        <el-input
          v-model="listQuery.name"
          placeholder="机构名称"
          clearable
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <span>手机号:</span>
        <el-input
          v-model="listQuery.bindMobile"
          placeholder="手机号"
          maxlength="11"
          clearable
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <span>联系人:</span>
        <el-input
          v-model="listQuery.linkMan"
          placeholder="联系人名称"
          clearable
          @keyup.enter.native="getList"
          @clear="getList"
        />
      </div>
      <div class="filter-control">
        <el-button type="primary" @click="getList"> 查询 </el-button>
      </div>
    </div>
    <!-- 列表 -->
    <el-table v-loading="isLoading" :data="list" border style="width: 100%" height="660">
      <el-table-column prop="clubId" fixed label="机构ID" align="center" width="80" />
      <el-table-column prop="name" fixed label="机构名称" align="center" />
      <el-table-column prop="linkMan" label="联系人" align="center" />
      <el-table-column prop="spName" label="服务商名称" align="center" />
      <el-table-column prop="contractMobile" label="手机号" align="center">
        <template slot-scope="{ row }">
          {{ row.contractMobile ? row.contractMobile : '---' }}
        </template>
      </el-table-column>
      <el-table-column prop="status" label="机构状态" align="center" width="100">
        <template slot-scope="{ row }">
          <el-tag v-if="row.status === 1" type="warning" size="small">待审核</el-tag>
          <el-tag v-if="row.status === 90" type="success" size="small">已上线</el-tag>
          <el-tag v-if="row.status === 91" type="info" size="small">已下线</el-tag>
          <el-tag v-if="row.status === 92" type="danger" size="small">审核未通过</el-tag>
          <el-tag v-if="row.status === 93" type="warning" size="small">已确认</el-tag>
          <el-tag v-if="row.status === 94" type="danger" size="small">已冻结</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="userIdentity" label="机构级别" align="center">
        <template slot-scope="{ row }">
          <template v-if="row.userIdentity === '4'">
            <el-tag v-if="row.userIdentity === '4' && row.svipUserFlag === 1" type="success" size="small">个人机构(超级会员)</el-tag>
            <el-tag v-else type="info" size="small">个人机构(普通会员)</el-tag>
          </template>
          <template v-if="row.userIdentity === '2'">
            <el-tag v-if="row.userIdentity === '2' && row.svipUserFlag ===1" type="success" size="small">资质机构(超级会员)</el-tag>
            <el-tag v-if="row.userIdentity === '2' && row.svipUserFlag !==1 && !row.medicalPracticeLicenseImg" type="warning" size="small">资质机构(高级会员)</el-tag>
            <el-tag v-if="row.userIdentity === '2' && row.svipUserFlag !==1 && row.medicalPracticeLicenseImg" type="danger" size="small">资质机构(医美会员)</el-tag>
          </template>
        </template>
      </el-table-column>
      <el-table-column prop="addTime" label="注册时间" align="center">
        <template slot-scope="{ row }">
          {{ row.addTime ? row.addTime : '---' }}
        </template>
      </el-table-column>
    </el-table>
    <!-- 页码 -->
    <pagination
      :total="total"
      :page-sizes="[10, 20, 30, 100]"
      :page-size="20"
      :page.sync="listQuery.pageNum"
      :limit.sync="listQuery.pageSize"
      @pagination="providersClubList"
    />
  </div>
</template>

<script>
import { providersClubList } from '@/api/serviceSettlement/service'
import pickerOptions from '@/utils/time-picker.js'
export default {
  name: 'CustomerList',
  filters: {},
  data() {
    return {
      isLoading: true,
      pickerOptions,
      time: [],
      time1: [],
      listQuery: {
        spId: this.$route.query.serviceProviderId,
        clubId: '',
        name: '',
        bindMobile: '',
        linkMan: '',
        pageNum: 1,
        pageSize: 20
      },
      list: [],
      total: 0,
      shopDialogVisible: false,
      dialogFormVisible: false,
      renewCustome: {
        id: '',
        status: ''
      },
      rules: {
        status: [{ required: true, message: '请设置统计状态', trigger: 'blur' }]
      }
    }
  },
  computed: {},
  created() {
    this.getList()
  },
  mounted() {},
  methods: {
    // 获取行为记录列表
    getList() {
      this.list = []
      this.isLoading = true
      this.listQuery.pageNum = 1
      this.providersClubList()
    },
    // 获取机构列表
    async providersClubList() {
      try {
        const res = await providersClubList(this.listQuery)
        this.list = res.data.results
        this.total = res.data.totalRecord
        this.isLoading = false
      } catch (error) {
        console.log(error)
      }
    },
    // 操作
    handleRecordDetail(type, row) {
      switch (type) {
        case 1: // 咨询记录
          this.$router.push({
            path: '/user/consult/list',
            query: { clubName: row.name, clubId: row.clubId }
          })
          break
        case 2: // 行为记录
          this.$router.push({
            path: '/user/record-list',
            query: { type: 'first', corporateName: row.name, clubId: row.clubId }
          })
          break
        case 3: // 机构画像
          this.$router.push({
            path: '/user/club-portrait',
            query: { clubName: row.name, clubId: row.clubId }
          })
          break
      }
    }
  }
}
</script>

<style>
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  float: left;
}
.uploader-tips {
  position: absolute;
  bottom: 0;
  left: 160px;
  line-height: 28px;
  color: red;
  margin: 0;
}
</style>
