index.vue 4.39 KB
<template>
  <page-view has-bread>
    <basic-card :project="project as any" :loading="loading" />

    <a-card :bordered="false" style="margin-top: 16px">
      <a-tabs v-model:active-key="tabKey" type="rounded" :animation="true" size="small" :justify="true">
        <a-tab-pane key="activity" :title="`歌曲列表(${activityCount})`">
          <activity-card
            style="padding: 0"
            :has-bread="false"
            :hide-tool="true"
            :init-filter="{ status: '', project_id: projectKey }"
            :hide-search-item="['projectName']"
            :export-name="project.name"
            :query-hook="() => syncActivityCount()"
          />
        </a-tab-pane>
        <a-tab-pane key="demo" :title="`Demo列表(${demoCount})`">
          <demo-card
            :hide-tool="true"
            :init-filter="{ project_id: projectKey }"
            style="padding: 0"
            :has-bread="false"
            :hide-create="true"
            :hide-search-item="['projectName']"
            :query-hook="() => syncDemoCount()"
          />
        </a-tab-pane>
        <a-tab-pane key="member" :title="`厂牌成员(${memberCount})`">
          <member-table :project-key="projectKey" :query-hook="() => syncMemberCount()" />
        </a-tab-pane>
        <a-tab-pane key="manage" :title="`厂牌管理(${manageCount})`">
          <manage-table :project-key="projectKey" :query-hook="() => syncManageCount()" />
        </a-tab-pane>
        <a-tab-pane key="out-manage" :title="`外部管理(${outManageCount})`">
          <out-manage-table
            :project-key="projectKey"
            :has-permission="project.is_can_manage as boolean"
            :query-hook="() => syncOutManageCount()"
          />
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </page-view>
</template>

<script lang="ts" setup>
import { useRoute } from 'vue-router';
import { useRouteQuery } from '@vueuse/router';
import { onMounted, ref } from 'vue';
import useLoading from '@/hooks/loading';

import useProjectApi from '@/api/project';
import useActivityApi from '@/api/activity';
import { useSelectionStore } from '@/store';
import BasicCard from '@/views/project-show/components/basic-card.vue';
import ManageTable from '@/views/project-show/components/manage-table.vue';
import OutManageTable from '@/views/project-show/components/out-manage-table.vue';
import ActivityCard from '@/views/audition/activity/index.vue';
import DemoCard from '@/views/audition/demo/index.vue';
import MemberTable from '@/views/project-show/components/member-table.vue';

const tabKey = useRouteQuery('tabKey', 'activity');

const projectKey = Number(useRoute().params?.id);

const project = ref({ name: '', is_can_manage: 0 });

const { loading, setLoading } = useLoading(true);

const manageCount = ref(0);
const outManageCount = ref(0);
const memberCount = ref(0);
const demoCount = ref(0);
const activityCount = ref(0);

const syncParams = { pageSize: 1, limit: 1 };

const syncManageCount = () =>
  // eslint-disable-next-line no-return-assign
  useProjectApi.manageUsers(projectKey, syncParams).then(({ meta }) => (manageCount.value = meta.total));

const syncMemberCount = () =>
  // eslint-disable-next-line no-return-assign
  useProjectApi.memberUsers(projectKey, { pageSize: 1, limit: 1 }).then(({ meta }) => (memberCount.value = meta.total));

const syncOutManageCount = () =>
  // eslint-disable-next-line no-return-assign
  useProjectApi.outManageUsers(projectKey, syncParams).then(({ meta }) => (outManageCount.value = meta.total));

const syncActivityCount = () =>
  // eslint-disable-next-line import/no-named-as-default-member,no-return-assign
  useActivityApi
    .get({ status: '', song_type: 1, audit_status: 1, project_id: projectKey, ...syncParams })
    // eslint-disable-next-line no-return-assign
    .then(({ meta }) => (activityCount.value = meta.total));

const syncDemoCount = () => {
  // eslint-disable-next-line import/no-named-as-default-member,no-return-assign
  useActivityApi
    .get({ status: '', song_type: 2, audit_status: 1, project_id: projectKey, ...syncParams })
    // eslint-disable-next-line no-return-assign
    .then(({ meta }) => (demoCount.value = meta.total));
};

const { queryAll } = useSelectionStore();

onMounted(() => {
  useProjectApi
    .show(projectKey)
    // eslint-disable-next-line no-return-assign
    .then((data) => (project.value = data as any))
    .finally(() => setLoading(false));

  queryAll();
});
</script>