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

    <div class="book-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="240" header-align="center" />
        <el-table-column prop="project_sn" label="项目编号" width="140" header-align="center" />
        <el-table-column prop="project_name" label="项目名称" width="240" header-align="center" />
        <el-table-column prop="org_name" label="所属机构" width="120" header-align="center" />
        <el-table-column prop="content_count" label="教材页面数" width="100" header-align="center" />
        <el-table-column prop="shangjia_time" label="上架时间" width="180" header-align="center" />
        <el-table-column label="已申请下架" align="center" header-align="center">
          <template slot-scope="{ row }">
            <span style="color: #f53f3f">
              {{ isTrue(row.is_request_xiajia) ? '√' : '' }}
            </span>
          </template>
        </el-table-column>

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

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

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

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

export default {
  name: 'OrgBookPage',
  components: {
    ProjectMenu,
    PaginationPage,
  },
  data() {
    return {
      list: [],
      total: 0,
      cur_page_begin_index: 0,
      isTrue,
    };
  },
  methods: {
    pageQueryYSJBookList_OrgManager(data) {
      PageQueryYSJBookList_OrgManager(data).then(({ total_count, book_list, cur_page_begin_index }) => {
        this.list = book_list;
        this.total = total_count;
        this.cur_page_begin_index = cur_page_begin_index;
      });
    },
    previewBook(id) {
      this.$router.push({ path: `/project_manage/org/book/preview/${id}` });
    },
  },
};
</script>

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

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