basic-card.vue 3.69 KB
<script setup lang="ts">
import { Activity } from '@/types/activity';
import { computed } from 'vue';
import { User } from '@/types/user';
import UserTag from '@/views/audition/activity-show/components/user-tag.vue';
import { unionBy } from 'lodash';
import useActivityApi from '@/api/activity';

const props = defineProps<{ data: Activity; loading?: boolean }>();

const links = computed(() => {
  return unionBy(props.data.links || [], 'id');
});

const inSideLyricist = computed(
  (): User[] => links.value?.filter((item: User) => props.data.expand?.lyricist?.ids?.indexOf(item.id) !== -1) || []
);
const outSideLyricist = computed(() => props.data.expand?.lyricist?.supplement || []);

const inSideComposer = computed(
  (): User[] => links.value?.filter((item: User) => props.data.expand?.composer?.ids?.indexOf(item.id) !== -1) || []
);
const outSideComposer = computed(() => props.data.expand?.composer?.supplement || []);
</script>

<template>
  <a-spin :loading="loading as boolean" style="width: 100%">
    <a-card :bordered="false">
      <a-form auto-label-width label-align="left">
        <a-layout>
          <a-layout-sider :width="130" style="background: none; box-shadow: none; padding-top: 6px">
            <a-image show-loader :height="130" :width="130" :src="data.cover" />
          </a-layout-sider>
          <a-layout-content style="margin-left: 16px">
            <a-form-item :hide-label="true">
              <div class="title">{{ data.song_name }}</div>
              <a-tag v-for="item in data.tags" :key="item.id" size="small" style="margin-right: 5px">
                {{ item.name }}
              </a-tag>
              <span style="font-size: 10px">
                {{ useActivityApi.statusOption.find((item) => item.value === data.status)?.label }}
              </span>
            </a-form-item>
            <a-form-item
              :label-col-style="{ flex: 0 }"
              :wrapper-col-style="{ flex: 'unset', width: 'inherit' }"
              :show-colon="true"
              label="关联厂牌"
            >
              <div v-if="data.project">{{ data.project.name }}</div>
              <div v-else></div>
            </a-form-item>
            <a-form-item style="margin-bottom: 0 !important" hide-label>
              <a-form-item :label-col-style="{ flex: 0 }" :show-colon="true" label="作词">
                <user-tag v-for="item in inSideLyricist" :key="item.id" :user="{ nick_name: item.nick_name }" style="margin-right: 5px" />
                <user-tag v-for="item in outSideLyricist" :key="`lyricist-${item}`" :user="{ nick_name: item }" style="margin-right: 5px" />
              </a-form-item>
              <a-form-item :label-col-style="{ flex: 0 }" :show-colon="true" label="作曲">
                <user-tag v-for="item in inSideComposer" :key="item.id" :user="{ nick_name: item.nick_name }" style="margin-right: 5px" />
                <user-tag v-for="item in outSideComposer" :key="`lyricist-${item}`" :user="{ nick_name: item }" style="margin-right: 5px" />
              </a-form-item>
            </a-form-item>
            <a-form-item style="margin-bottom: 0 !important" :label-col-style="{ flex: 0 }" :show-colon="true" label="创建信息">
              <span v-if="data.user" style="margin-right: 8px">{{ data.user.nick_name }}</span>
              <span style="margin-right: 8px">{{ data.created_at }} </span>
            </a-form-item>
          </a-layout-content>
        </a-layout>
      </a-form>
    </a-card>
  </a-spin>
</template>

<style lang="less" scoped>
.arco-form-item {
  margin-bottom: 10px;
}

.arco-form-item-label-col {
  flex: 0;
}

.title {
  font-size: 16px;
  font-weight: bold;
  margin-right: 8px;
}

.right {
  margin: 0 20px;
  min-width: 600px;
}
</style>