<template>
  <div class="xuxibiji">
    <div class="list_item padding16 border_radius_16 flex-center-between bg_color_fff mb20" 
    v-for="(item, index) in 4" :key="index">
      <div class="flex_1">
        <div class="bold font_size18">这是笔记名称</div>
        <div class="gray999 mt5">{{$t('common.genxinyu')}} 2025-11-08 03:26</div>
      </div>
      <div>
        <el-button type="primary" plain size="large" @click="openAddDialog()">
          <el-icon><EditPen /></el-icon>
          <span class="ml10">{{$t('common.edit')}}</span>
        </el-button>
        <el-button type="danger" plain size="large" @click="del(index)">
          <el-icon><Delete /></el-icon>
          <span class="ml10">{{$t('common.delete')}}</span>
        </el-button>
      </div>
    </div>
    <Pagination 
      :total="listTotal"
      :page-size="searchFom.pageSize"
      :current-page="searchFom.pageNum"
      @page-change="handlePageChange"
    />
    <BlockNoteEditorDialog ref="blockNoteEditorDialogRef" />
  </div>
</template>
<script setup>
import { ElMessageBox } from 'element-plus'
import addIcon from '@/assets/imgs/add.png'
import BlockNoteEditorDialog from '@/components/BlockNoteEditorDialog.vue'
import Pagination from '@/components/Pagination.vue'
import { getCourseList } from '@/api/course.js'
import { ref, onMounted,reactive } from 'vue'
import { useAppStore } from '@/pinia/appStore'
const appStore = useAppStore()
defineProps({
  info: {
    type: Object,
    default: () => ({})
  }
})
const comments = ref('');
const listTotal = ref(0);
const searchFom = reactive({
  pageNum: 1,
  pageSize: 10,
})
const list = ref([]);

onMounted(() => {
  getList();
});

const handlePageChange = (page) => {
  searchFom.pageNum = page
  // 这里可以添加获取数据的逻辑
  console.log('当前页:', page);
  getList();
}
// 查询寻找工作流列表
const getList = async (type) => {
  if(type === 'init'){
    searchFom.pageNum = 1
  }
  // const res = await getQuestList(searchFom)
  // if(res.code === 200){
  //   listTotal.value = res.total
  //   list.value = res.rows
  // }
};
// 打开添加对话框
const blockNoteEditorDialogRef = ref(null)
const openAddDialog = () => {
  blockNoteEditorDialogRef.value.openDialog();
};
// 删除笔记
const del = (index) => {
  // list.value.splice(index, 1)
  ElMessageBox.confirm('确定删除吗？', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    getList();
  }).catch(() => {
    // 取消删除
  });
};
</script>
<style scoped lang="scss">
.xuxibiji{
  .addBtn{
    cursor: pointer;
    margin-top: 20px;
    padding: 10px 20px;
    color: #fff;
  }
}
</style>
