<template>
  <div>
    <el-dialog title="项目班组的成员" v-model="visible" @close="closeModal">
      <h3>{{ row.teamName }}</h3>
      <div>{{ JSON.stringify(row) }}</div>
      <div>{{ JSON.stringify(projectTeamMemberList) }}</div>
      <!--      <el-form ref="queryFormRef" :model="queryParams" :inline="true">
              <el-form-item label="施工人员" prop="memberId">
                <el-input v-model="queryParams.memberId" placeholder="请输入施工人员id" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item label="岗位" prop="postId">
                <el-input v-model="queryParams.postId" placeholder="请输入岗位" clearable @keyup.enter="handleQuery" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
                <el-button icon="Refresh" @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-form>-->
    </el-dialog>
  </div>
</template>

<script setup lang="ts">
import { ProjectTeamVO } from '@/api/project/projectTeam/types';
import { ProjectTeamMemberVO } from '@/api/project/projectTeamMember/types';
import { listProjectTeamMember } from '@/api/project/projectTeamMember';
import { computed, onMounted, ref } from 'vue';

interface Props {
  row: ProjectTeamVO;
}

const props = withDefaults(defineProps<Props>(), {});
const row = computed(() => {
  return props.row;
});
// 是否可见
const visible = ref(false);
// 搜索条件
const searchParams = ref({
  current: 1,
  pageSize: 10,
  sortField: 'createTime',
  sortOrder: 'descend'
});
const projectTeamMemberList = ref<ProjectTeamMemberVO[]>([]);
const total = ref(0);
const loading = ref(true);

/** 查询项目班组下的成员列表 */
const getList = async () => {
  loading.value = true;
  // 转换搜索参数
  const params = {
    ...searchParams.value
  };
  const res = await listProjectTeamMember(params);
  projectTeamMemberList.value = res.data.records;
  total.value = res.data.total;
  loading.value = false;
};

// 打开弹窗
const openModal = () => {
  visible.value = true;
};

// 关闭弹窗
const closeModal = () => {
  visible.value = false;
};

// 暴露函数给父组件
defineExpose({
  openModal
});

onMounted(() => {
  getList();
});
</script>
