<template>
  <div class="project org">
    <ProjectMenu cur-key="org/project" />

    <div class="project-list">
      <el-table :data="list">
        <el-table-column label="序号" width="60" align="center" header-align="center" class-name="index-column">
          <template slot-scope="{ $index }">
            {{ cur_page_begin_index + $index }}
          </template>
        </el-table-column>
        <el-table-column prop="sn" label="编号" width="140" header-align="center" />
        <el-table-column prop="name" label="名称" width="260" header-align="center" />
        <el-table-column prop="org_name" label="所属机构" width="120" header-align="center" />
        <el-table-column prop="leader_name_desc" label="项目组长" width="140" header-align="center" />
        <el-table-column prop="create_time" label="创建时间" width="180" header-align="center" />
        <el-table-column prop="content_count_SJ" label="教材页面数" width="100" header-align="center" />
        <el-table-column label="退改" header-align="center" align="center">
          <template slot-scope="{ row }">
            <span style="color: #f53f3f">{{ isTrue(row.is_rollback) ? '√' : '' }}</span>
          </template>
        </el-table-column>

        <el-table-column fixed="right" label="操作" width="150" align="center" header-align="center">
          <template slot-scope="{ row }">
            <span class="link">查看信息</span>
            <span class="link" @click="previewProject(row.id)">预览项目</span>
          </template>
        </el-table-column>
      </el-table>

      <PaginationPage :total="total" @getList="pageQueryProjectList_OrgManager" />
    </div>
  </div>
</template>

<script>
import PaginationPage from '@/components/PaginationPage.vue';
import ProjectMenu from '@/views/project_manage/common/ProjectMenu.vue';

import { PageQueryProjectList_OrgManager } from '@/api/list';
import { isTrue } from '@/utils/common';

export default {
  name: 'OrgProjectPage',
  components: {
    PaginationPage,
    ProjectMenu,
  },
  data() {
    return {
      list: [],
      total: 0,
      cur_page_begin_index: 0,
      isTrue,
    };
  },
  methods: {
    pageQueryProjectList_OrgManager(data) {
      PageQueryProjectList_OrgManager({ ...data, status: 0 }).then(
        ({ total_count, cur_page_begin_index, project_list }) => {
          this.total = total_count;
          this.cur_page_begin_index = cur_page_begin_index;
          this.list = project_list;
        },
      );
    },
    previewProject(projectId) {
      this.$router.push({ path: `/project_manage/org/project/preview/${projectId}` });
    },
  },
};
</script>

<style lang="scss" scoped>
@use '@/styles/mixin.scss' as *;

.project {
  @include page-base;
  @include table-list;
}
</style>
