<template>
|
<ResourceCard v-bind="props">
|
<template #title-right>
|
<div class="more-btn" @click.stop="handleMore">
|
<img :src="IconMore" class="more-btn-icon" />
|
</div>
|
</template>
|
<template #footer>
|
<div class="common-card-footer-time" style="margin-left: 0">
|
创建于:{{ dayjs(props.time).format('MM-DD HH:mm') }}
|
</div>
|
</template>
|
</ResourceCard>
|
</template>
|
|
<script setup lang="ts">
|
import dayjs from 'dayjs';
|
import { ResourceStatus } from '@12333/constants';
|
import IconMore from '@/assets/order/icon-more.png';
|
import { Portal } from 'senin-mini/components';
|
import { ActionSheet } from '@nutui/nutui-taro';
|
import { ManageActions } from '@/subpackages/setting/constants';
|
|
defineOptions({
|
name: 'ResourceManageCard',
|
});
|
|
type Props = {
|
title?: string;
|
src?: string;
|
name?: string;
|
jobTitle?: string;
|
time?: string;
|
resourceCount?: number;
|
intendedDeliveryCities?: API.CityInfo[];
|
status?: ResourceStatus;
|
};
|
|
const props = withDefaults(defineProps<Props>(), {});
|
|
const emit = defineEmits<{
|
(e: 'edit'): void;
|
(e: 'detail'): void;
|
(e: 'publish'): void;
|
(e: 'stop'): void;
|
(e: 'copy'): void;
|
(e: 'delete'): void;
|
}>();
|
|
const menuList = computed(() => {
|
let _menuList = [];
|
if (props.status !== ResourceStatus.WaitAudit) {
|
_menuList.push({
|
name: '编辑',
|
value: ManageActions.Edit,
|
});
|
}
|
_menuList.push({
|
name: '查看详情',
|
value: ManageActions.Detail,
|
});
|
if (props.status === ResourceStatus.OffShelf) {
|
_menuList.push({
|
name: '重新发布',
|
value: ManageActions.Publish,
|
});
|
}
|
if (props.status === ResourceStatus.Running) {
|
_menuList.push({
|
name: '停止发布',
|
value: ManageActions.Stop,
|
});
|
}
|
if (props.status !== ResourceStatus.WaitAudit) {
|
_menuList.push(
|
{
|
name: '复制',
|
value: ManageActions.Copy,
|
},
|
{
|
name: '删除',
|
value: ManageActions.Delete,
|
}
|
);
|
}
|
|
return _menuList;
|
});
|
|
function handleMore() {
|
Portal.add((key) => {
|
return h(
|
Portal.Container,
|
{ keyNumber: key, delayOpen: true },
|
{
|
default: ({ open, onClose }) =>
|
// @ts-ignore
|
h(ActionSheet, {
|
visible: open.value,
|
'onUpdate:visible': () => onClose(),
|
menuItems: menuList.value,
|
onChoose: (item) => {
|
handleEmit(item);
|
onClose();
|
},
|
}),
|
}
|
);
|
});
|
}
|
|
function handleEmit(action: { name: string; value: number }) {
|
switch (action.value) {
|
case ManageActions.Edit:
|
emit('edit');
|
break;
|
case ManageActions.Detail:
|
emit('detail');
|
break;
|
case ManageActions.Publish:
|
emit('publish');
|
break;
|
case ManageActions.Stop:
|
emit('stop');
|
break;
|
case ManageActions.Copy:
|
emit('copy');
|
break;
|
case ManageActions.Delete:
|
emit('delete');
|
break;
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
@import '@/styles/common.scss';
|
|
.more-btn {
|
padding-left: 40px;
|
|
.more-btn-icon {
|
width: 32px;
|
height: 32px;
|
}
|
}
|
</style>
|