<template>
  <Dialog v-model="dialogVisible" :title="dialogTitle" width="70%">
      <TaskRecord :defaultUserId="userId"/>
      <template #footer>
          <el-button @click="dialogVisible = false" plain>关闭</el-button>
      </template>
  </Dialog>
</template>

<script setup lang="ts" name="TaskRecordTable">
import TaskRecord from '@/views/member/taskRecord/index.vue'

defineOptions({ name: 'TaskRecordTable' })

const props = defineProps({
  defaultUserId: {
    type: Number,
  },
})

const userId = ref(props.defaultUserId)

const { t } = useI18n() // 国际化
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
  userId.value = id
  console.log("task record table user id" + id)
  dialogVisible.value = true
  dialogTitle.value = t('member.taskRecord.' + type)
}
defineExpose({ open }) // 提供 open 方法，用于打开弹窗
</script>