feat: 重构sidebar菜单块逻辑
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
v-if="props.product.status === Status.Enable || props.product.status === Status.ON_TRIAL"
|
||||
class="primary-button"
|
||||
type="primary"
|
||||
@click="gotoModule(props.product.menu_id)"
|
||||
@click="gotoModule(props.product.id)"
|
||||
>
|
||||
进入模块
|
||||
</a-button>
|
||||
@ -71,12 +71,12 @@ import { useRouter } from 'vue-router';
|
||||
import CustomerServiceModal from '@/components/customer-service-modal.vue';
|
||||
import { appRoutes } from '@/router/routes';
|
||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||
import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||
|
||||
const props = defineProps<{
|
||||
product: Product;
|
||||
}>();
|
||||
const emit = defineEmits(['refresh']);
|
||||
const sidebarStore = useSidebarStore();
|
||||
|
||||
enum Status {
|
||||
Disable = 0, // 禁用
|
||||
@ -87,30 +87,34 @@ enum Status {
|
||||
}
|
||||
|
||||
interface Product {
|
||||
id: number;
|
||||
status: Status;
|
||||
name: string;
|
||||
image: string;
|
||||
desc: string;
|
||||
menu_id: number;
|
||||
id: number;
|
||||
expired_at?: number;
|
||||
}
|
||||
|
||||
const visible = ref(false);
|
||||
const router = useRouter();
|
||||
const enterpriseStore = useEnterpriseStore();
|
||||
|
||||
const handleTrial = async (id: any) => {
|
||||
await trialProduct(id);
|
||||
AMessage.success('试用成功!');
|
||||
emit('refresh');
|
||||
const { code } = await trialProduct(id);
|
||||
if (code === 200) {
|
||||
enterpriseStore.updateEnterpriseInfo();
|
||||
AMessage.success('试用成功!');
|
||||
emit('refresh');
|
||||
}
|
||||
};
|
||||
|
||||
const gotoModule = (menuId: number) => {
|
||||
const _target = appRoutes.find((v) => v.meta.id === menuId);
|
||||
if (_target) {
|
||||
console.log({ _target });
|
||||
router.push({ name: _target.name });
|
||||
}
|
||||
const routeMap: Record<number, string> = {
|
||||
'1': 'DataEngineHotTranslation',
|
||||
'2': 'RepositoryBrandMaterials',
|
||||
};
|
||||
console.log(routeMap[menuId]);
|
||||
router.push({ name: routeMap[menuId] });
|
||||
};
|
||||
</script>
|
||||
<style scoped lang="less">
|
||||
|
||||
Reference in New Issue
Block a user