<template>
  <div class="p-2">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div v-show="showSearch" class="mb-[10px]">
        <!--店铺名称、负责人、联系人、推广人、店铺类型、地址、签约状态 -->
        <el-card shadow="hover">
          <el-form ref="queryFormRef" :model="queryParams" :inline="true">
            <el-form-item label="团长名字:" prop="spreadUserName" label-width="100px">
              <el-input v-model="queryParams.spreadUserName" placeholder="请输团长名字" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="用户昵称:" prop="nickname" label-width="100px">
              <el-input v-model="queryParams.nickname" placeholder="请输入用户昵称" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="用户手机号:" prop="phoneHidden" label-width="100px">
              <el-input v-model="queryParams.phoneHidden" placeholder="请输入用户手机号" clearable @keyup.enter="handleQuery" />
            </el-form-item>
            <el-form-item label="绑定日期:" prop="spreadTime" label-width="100px">
              <el-date-picker
                v-model="queryParams.spreadTime"
                type="datetimerange"
                clearable
                value-format="YYYY-MM-DD HH:mm:ss"
                placeholder="选择日期"
              />
            </el-form-item>

            <el-form-item>
              <el-button type="primary" icon="Search" @click="handleQuery" v-hasPermi="['system:tenant:query']">搜索</el-button>
              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </div>
    </transition>

    <el-card shadow="hover">
      <el-table border :data="tenantList">
        <el-table-column label="团长姓名" align="center" prop="spreadUserName" />
        <el-table-column label="用户昵称" align="center" prop="nickname" />
        <el-table-column label="用户手机号" align="center" prop="phoneHidden" />
        <el-table-column label="绑定日期" align="center" prop="spreadTime" />
      </el-table>

      <pagination v-show="total > 0" v-model:current="queryParams.current" v-model:size="queryParams.size" :total="total" @pagination="getList" />
    </el-card>
  </div>
</template>

<script setup name="Tenant" lang="ts">
import { listdarrentuser } from '@/api/system/tenant';

const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const loading = ref(true);
const showSearch = ref(true);
const total = ref(0);
const tenantList = ref([]);
const queryFormRef = ref<ElFormInstance>();

interface TenantFormfn {
  current: number;
  size: number;
  spreadUserName: number | string;
  nickname: number | string;
  spreadTime: number | string;
  phoneHidden: number | string;
}
/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.value.current = 1;
  getList();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value?.resetFields();
  handleQuery();
};
const queryParams = ref<TenantFormfn>({
  current: 1,
  size: 10,
  spreadUserName: undefined,
  nickname: undefined,
  spreadTime: undefined,
  phoneHidden: undefined
});
/** 查询租户列表 */
const getList = async () => {
  loading.value = true;
  const res = await listdarrentuser(queryParams.value);
  tenantList.value = res.data.records;
  total.value = res.data.total;
  loading.value = false;
};

onMounted(() => {
  getList();
});
</script>
<style scoped lang="scss">
.form-group {
  margin-bottom: 24px;
}

.group-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 16px;
  color: #1f2937;
  padding-left: 8px;
  border-left: 3px solid #409eff;
}
.upload__tip {
  background: url('./d.png') no-repeat;
  background-size: 100% 100%;
  width: 100%;
  height: 100%;
}
::v-deep {
  #searc {
    .el-form-item--default .el-form-item__label {
      width: 100px;
    }
  }
  .el-form-item__content {
    width: 240px;
  }
  .el-form-item--default .el-form-item__label {
    width: 150px;
  }
  .el-upload--picture-card {
    width: 100px;
    height: 100px;
  }
  .el-upload-list {
    width: 320px;
    .el-upload-list__item {
      width: 100px;
      height: 100px;
    }
  }
}
</style>
