Parcourir la source

按要求修改为通用接口

快乐的梦鱼 il y a 2 mois
Parent
commit
177e18c623

+ 14 - 0
src/api/inhert/VillageApi.ts

@@ -171,6 +171,20 @@ export class VillageApi extends AppServerRequestModule<DataModel> {
     return (await this.post('/village/volunteer/getInfo', {
     }, '获取志愿者信息', undefined, VolunteerInfo)).data as VolunteerInfo
   }
+  async getCollectModuleMap() {
+    const res = (await this.post('/village/volunteer/getCollectModuleList', {}, '采集板块列表'))
+    const map = new Map<string, number>();
+    if (!res.data2 || typeof res.data2 !== 'object') 
+      return map;
+    for (const key in res.data2) {
+      if (typeof res.data2[key] !== 'string')
+        throw new Error(`采集板块列表键值对值不是字符串: ${key} -> ${res.data2[key]}`);
+      if (isNaN(Number(key)))
+        throw new Error(`采集板块列表键值对键不是数字: ${key}`);
+      map.set(res.data2[key], Number(key));
+    }
+    return map;
+  }
   async getVolunteerRanklist(category?: number) {
     return (this.post('/village/volunteer/getRanklist', {
       category,

+ 61 - 25
src/api/inhert/VillageInfoApi.ts

@@ -1,6 +1,6 @@
-import { DataModel, transformArrayDataModel, type NewDataModel } from '@imengyu/js-request-transform';
-import CommonContent from '../CommonContent';
+import { DataModel, transformArrayDataModel } from '@imengyu/js-request-transform';
 import { AppServerRequestModule } from '../RequestModules';
+import CommonContent from '../CommonContent';
 
 export class CategoryListItem extends DataModel<CategoryListItem> {
   constructor() {
@@ -30,6 +30,9 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
       id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
 
     },
+    this._blackList.toServer.push(
+      'updatedAt', 'createdAt', 'deletedAt',
+    );
     this._afterSolveServer = () => {
       if (this.province && this.city && this.district) {
         this.cityAddress = [this.province as string, this.city as string, this.district as string];
@@ -45,7 +48,6 @@ export class CommonInfoModel extends DataModel<CommonInfoModel> {
   }
   id !: number;
   cityAddress?: string[];
-
 }
 
 export class VillageEnvInfo extends DataModel<VillageEnvInfo> {
@@ -58,7 +60,11 @@ export class VillageEnvInfo extends DataModel<VillageEnvInfo> {
         { clientSide: 'splitCommaArray', serverSide: 'commaArrayMerge' },
         { clientSide: 'arrayInt', serverSide: 'original' },
       ],
+      villageType: { clientSide: 'number', serverSide: 'number' },
     },
+    this._blackList.toServer.push(
+      'updatedAt', 'createdAt', 'deletedAt',
+    );
     this._afterSolveServer = () => {
       if (this.longitude && this.latitude) {
         this.lonlat = [this.longitude as number, this.latitude as number];
@@ -82,6 +88,9 @@ export class VillageListItem extends DataModel<VillageListItem> {
     this._convertTable = {
       id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
     },
+    this._blackList.toServer.push(
+      'updatedAt', 'createdAt', 'deletedAt',
+    );
     this._convertKeyType = (key, direction) => {
       if (key.endsWith('At'))
         return {
@@ -93,10 +102,10 @@ export class VillageListItem extends DataModel<VillageListItem> {
     this._afterSolveServer = () => {
       if (!this.title) {
         if (this.name) this.title = this.name as string;
-        else if (typeof this.content === 'object' && (this.content as any)?.title) this.title = (this.content as any).title as string;
-        else if (this.content) this.title = this.content as string;
-        else if (this.structure) this.title = this.structure as string;
-        else if (this.wisdom) this.title = this.wisdom as string;
+        if (typeof this.content === 'object' && (this.content as any)?.title) this.title = (this.content as any).title as string;
+        if (this.content) this.title = this.content as string;
+        if (this.structure) this.title = this.structure as string;
+        if (this.wisdom) this.title = this.wisdom as string;
       }
       if (!this.image) {
         if (this.distribution) this.image = this.distribution as string;
@@ -116,6 +125,9 @@ export class VillageBulidingInfo extends DataModel<VillageBulidingInfo> {
     this._convertTable = {
       id: { clientSide: 'number', serverSide: 'number', clientSideRequired: true },
     }
+    this._blackList.toServer.push(
+      'updatedAt', 'createdAt', 'deletedAt',
+    );
     const commaArrayKeys = [
       'purpose','floorType','wallType','roofForm','bearingType',
     ]
@@ -159,29 +171,40 @@ export class VillageInfoApi extends AppServerRequestModule<DataModel> {
   }
 
   async getInfo<T extends DataModel>(
-    sub: string,
-    subId: number,
+    collectModuleId: number|undefined,
+    subType: string,
+    subId: number|undefined,
+    subKey: string|undefined,
     villageId: number,
     villageVolunteerId: number,
-    id?: number,
+    id?: number, 
     modelClassCreator: (new () => T) = CommonInfoModel as any
   ) {
-    return (await this.post(`/village/${sub}/getInfo`, {
-      type: subId,
-      village_id: villageId,
-      village_volunteer_id: villageVolunteerId,
-      id,
-    }, '获取信息详情', undefined, modelClassCreator)).data as T
+    if (subType === 'overview') {
+      return (await this.post(`/village/${subType}/getInfo`, {
+        type: subId,
+        village_id: villageId,
+        village_volunteer_id: villageVolunteerId,
+        id,
+      }, '获取村落概况', undefined, modelClassCreator)).data as T
+    } else {
+      return (await this.post(`/village/collect/info`, {
+        collect_module_id: collectModuleId,
+        id,
+      }, '通用获取信息详情', undefined, modelClassCreator)).data as T
+    }
   }
   async getList<T extends DataModel = VillageListItem>(
-    sub: string,
+    collectModuleId: number|undefined,
+    subType: string,
     subId: number|undefined,
     subKey: string|undefined,
     villageId: number,
     villageVolunteerId: number,
     modelClassCreator: (new () => T) = VillageListItem as any 
   ) {
-    return (this.post(`/village/${sub}/getList`, {
+    return (this.post(`/village/collect/list`, {
+      collect_module_id: collectModuleId,
       [subKey ? subKey : 'type']: subId,
       village_id: villageId,
       village_volunteer_id: villageVolunteerId,
@@ -190,17 +213,30 @@ export class VillageInfoApi extends AppServerRequestModule<DataModel> {
       .catch(e => { throw e });
   }
   async updateInfo<T extends DataModel>(
-    sub: string,
+    collectModuleId: number|undefined,
+    subType: string,
+    subKey: string,
+    subId: number,
     villageId: number,
     villageVolunteerId: number,
     data: T,
   ) {
-    return (await this.post(`/village/${sub}/save`, {
-      sub,
-      village_id: villageId,
-      village_volunteer_id: villageVolunteerId,
-      ...data.toServerSide(),
-    }, '更新信息详情'));
+    if (subType === 'overview') {
+      return (await this.post(`/village/${subType}/save`, {
+        subType,
+        village_id: villageId,
+        village_volunteer_id: villageVolunteerId,
+        ...data.toServerSide(),
+      }, '更新信息详情'));
+    } else {
+      return (await this.post(`/village/collect/save`, {
+        collect_module_id: collectModuleId,
+        [subKey||'type']: subId,
+        village_id: villageId,
+        village_volunteer_id: villageVolunteerId,
+        ...data.toServerSide(),
+      }, '通用更新信息详情'));
+    }
   }
 }
 

+ 12 - 1
src/pages/dig/components/TaskList.vue

@@ -25,6 +25,10 @@ defineProps({
     type: Boolean,
     default: true,
   },
+  enable: {
+    type: Boolean,
+    default: true,
+  }
 })
 </script>
 
@@ -41,7 +45,14 @@ defineProps({
         <Text class="desc" :fontSize="24" color="text.second" :text="desc" />
       </FlexCol>
     </FlexRow>
-    <Button v-if="button" type="primary" shape="round" size="small" :radius="40" @click="$emit('click')">去完成</Button>
+    <Button v-if="button" 
+      type="primary" 
+      shape="round" 
+      size="small" 
+      :radius="40" 
+      :touchable="enable"
+      @click="$emit('click')"
+    >去完成</Button>
     <view v-else></view>
   </FlexRow>
 </template>

+ 28 - 17
src/pages/dig/details.vue

@@ -28,7 +28,7 @@
       :padding="30"
       align="center"
       backgroundColor="background.primary"
-      @click="goForm('collect', 1, '随手记')"
+      @click="goCollect"
     >
       <Icon icon="edit-filling" color="primary" :size="100" />
       <Height :height="20" />
@@ -38,15 +38,22 @@
     </Touchable>
 
     <FlexCol :gap="20">
+      
+      <Alert
+        v-if="!authStore.isAdmin && isEmpty"
+        type="warning"
+        message="您当前没有可完成的任务"
+        description="请联系管理员认领可采编栏目"
+      />
+
       <TaskList
-        v-if="canCollect('village')"
         icon="icon-task-summary"
         title="村落概况"
         desc="探索村落的历史渊源与发生轨迹"
+        :enable="canCollect('overview')"
         @click="navTo('task/summary', nextPageData)"
       />
       <TaskList
-        v-if="canCollect('cultural')"
         icon="icon-task-history"
         title="历史文化"
         desc="传承百年文化遗产和精神财富"
@@ -57,57 +64,48 @@
         icon="icon-task-custom-1"
         title="非物质文化遗产项目"
         desc="维护文化多样性"
+        :enable="canCollect('ich')"
         @click="goForm('ich', 0, '非物质文化遗产项目')"
       />
       <TaskList
-        v-if="canCollect('building')"
         icon="icon-task-environment"
         title="环境格局"
         desc="感受自然人文环境之美"
         @click="navTo('task/environment', nextPageData)"
       />
       <TaskList
-        v-if="canCollect('building')"
         icon="icon-task-building"
         title="传统建筑"
         desc="领略古建筑的独特魅力"
         @click="navTo('task/building', nextPageData)"
       />
       <TaskList
-        v-if="canCollect('folk_culture')"
         icon="icon-task-custom"
         title="民俗文化"
         desc="体验民间传统习俗与节庆"
+        :enable="canCollect('folk_culture')"
         @click="navTo('task/custom', nextPageData)"
       />
       <TaskList
-        v-if="canCollect('food_product')"
         icon="icon-task-food"
         title="地道美食"
         desc="正宗、传统地方特色美食"
+        :enable="canCollect('food_product')"
         @click="navTo('task/food', nextPageData)"
       />
       <TaskList
-        v-if="canCollect('food_product')"
         icon="icon-task-mine"
         title="物产资源"
-        desc="特定地域的植物、矿物或手工艺"
+        desc="特定地域的植物、矿物或工艺品"
+        :enable="canCollect('food_product')"
         @click="navTo('task/mine', nextPageData)"
       />
       <TaskList
-        v-if="canCollect('route')"
         icon="icon-task-trip"
         title="旅游路线"
         desc="体验独特的文化魅力"
         @click="navTo('task/trip', nextPageData)"
       />
-      <TaskList
-        v-if="!authStore.isAdmin && isEmpty"
-        icon="icon-task-summary"
-        title="您当前没有可完成的任务"
-        desc="请联系管理员认领可采编栏目"
-        :button="false"
-      />
     </FlexCol>
     <XBarSpace />
   </FlexCol>
@@ -129,6 +127,7 @@ import FlexRow from '@/components/layout/FlexRow.vue';
 import TaskList from './components/TaskList.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import Width from '@/components/layout/space/Width.vue';
+import Alert from '@/components/feedback/Alert.vue';
 
 const { querys } = useLoadQuerys({ 
   id: 0,  
@@ -146,6 +145,18 @@ const nextPageData = computed(() => ({
   villageVolunteerId: querys.value.villageVolunteerId,
 }));
 
+function goCollect() {
+  if (!canCollect('collect')) {
+    uni.showToast({
+      title: '您当前没有可采编随手记的权限',
+      icon: 'none',
+      duration: 2000
+    });
+    return;
+  }
+  goForm('collect', 1, '随手记')
+}
+
 function goForm(subType: string, subId: number, title: string) {
   navTo('/pages/dig/forms/list', {
     villageId: querys.value.id,  

+ 8 - 0
src/pages/dig/forms/common.vue

@@ -35,9 +35,11 @@ import { backAndCallOnPageBack } from '@/components/utils/PageAction';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import { toast } from '@/components/utils/DialogAction';
 import { confirm } from '@/components/dialog/CommonRoot';
+import { useCollectStore } from '@/store/collect';
 
 const loading = ref(false);
 const subTitle = ref('');
+const collectStore = useCollectStore();
 
 const formRef = ref<IDynamicFormRef>();
 const formModel = ref(new CommonInfoModel()) as Ref<CommonInfoModel>;
@@ -67,7 +69,10 @@ async function submit() {
     formModel.value.type = querys.value.subId;
     await waitTimeOut(800);
     await VillageInfoApi.updateInfo(
+      collectStore.getCollectModuleId(querys.value.subType),
       querys.value.subType,
+      querys.value.subKey,
+      querys.value.subId,
       querys.value.villageId,
       querys.value.villageVolunteerId,
       formModel.value as CommonInfoModel,
@@ -96,6 +101,7 @@ const { querys } = useLoadQuerys({
   villageVolunteerId: 0,
   subType: '',
   subId: 0,
+  subKey: '',
   subTitle: '',
   id: 0,
 }, async (querys) => {
@@ -120,8 +126,10 @@ const { querys } = useLoadQuerys({
     };
     if (querys.id >= 0)
       formData = await VillageInfoApi.getInfo(
+        collectStore.getCollectModuleId(querys.subType),
         querys.subType, 
         querys.subId,
+        querys.subKey,
         querys.villageId, 
         querys.villageVolunteerId,
         querys.id,

+ 19 - 3
src/pages/dig/forms/data/cultural.ts

@@ -9,6 +9,7 @@ import { useAliOssUploadCo } from "@/common/components/upload/AliOssUploadCo";
 import { villageCommonContent } from "./common";
 import { goFormStatic } from "../../composeable/TaskEntryForm";
 import type { ButtonProp } from "@/components/basic/Button.vue";
+import { useCollectStore } from "@/store/collect";
 
 export function villageInfoFolkCultureForm(title: string) : SingleForm {
   return [VillageBulidingInfo, (m) => ({
@@ -33,8 +34,10 @@ export function villageInfoFolkCultureForm(title: string) : SingleForm {
         defaultValue: null,
         additionalProps: {
           loadData: {
-            callback: (m, r, p, i) => async () => 
-              (await VillageInfoApi.getList(
+            callback: (m, r, p, i) => async () => {
+              const collectStore = useCollectStore();
+              return (await VillageInfoApi.getList(
+                collectStore.getCollectModuleId('ich'),
                 'ich', undefined, undefined,
                 i.formGlobalParams.villageId,
                 i.formGlobalParams.villageVolunteerId
@@ -42,6 +45,7 @@ export function villageInfoFolkCultureForm(title: string) : SingleForm {
                 value: p.id,
                 text: p.title,
               }))
+            }
           },
         } as IDynamicFormItemCallbackAdditionalProps<PickerIdFieldProps>,
         formProps: { showRightArrow: true } as FieldProps,
@@ -101,7 +105,10 @@ export const villageInfoCulture : GroupForm = {
         additionalProps: {
           loadData: { 
             callback(_, m, p, i) { 
-              return async () => (await VillageInfoApi.getList('speaker', undefined, undefined,
+              const collectStore = useCollectStore();
+              return async () => (await VillageInfoApi.getList(
+                collectStore.getCollectModuleId('speaker'),
+                'speaker', undefined, undefined,
                 i.formGlobalParams.villageId,
                 i.formGlobalParams.villageVolunteerId
               ))
@@ -127,6 +134,15 @@ export const villageInfoCulture : GroupForm = {
           text: '口述人管理',
           onClick: { callback(v, m, p, i) {
             return () => {
+              const collectStore = useCollectStore();
+              if (!collectStore.getCollectModuleId('speaker')) {
+                uni.showToast({
+                  title: '您暂无权限采编口述人,请联系管理员。',
+                  icon: 'none',
+                  duration: 3000
+                });
+                return;
+              }
               goFormStatic(
                 i.formGlobalParams.villageId,
                 i.formGlobalParams.villageVolunteerId,

+ 3 - 0
src/pages/dig/forms/list.vue

@@ -69,9 +69,11 @@ import Height from '@/components/layout/space/Height.vue';
 import H4 from '@/components/typography/H4.vue';
 import Touchable from '@/components/feedback/Touchable.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
+import { useCollectStore } from '@/store/collect';
 
 const subTitle = ref('');
 const searchText = ref('');
+const collectStore = useCollectStore();
 const listLoader = useSimplePageListLoader<{
   id: number,
   image: string,
@@ -87,6 +89,7 @@ const listLoader = useSimplePageListLoader<{
   if (!params || !params.subType || !params.villageId || !params.villageVolunteerId)
     throw new Error("未传入参数,当前页面需要参数");
   let res = (page == 1 ? await VillageInfoApi.getList(
+    collectStore.getCollectModuleId(params.subType),
     params.subType,
     params.subId,
     params.subKey,

+ 11 - 3
src/pages/dig/index.vue

@@ -77,7 +77,6 @@ import Image from '@/components/basic/Image.vue';
 import SubTitle from '@/components/display/title/SubTitle.vue';
 import FlexCol from '@/components/layout/FlexCol.vue';
 import FlexRow from '@/components/layout/FlexRow.vue';
-import Width from '@/components/layout/space/Width.vue';
 import H3 from '@/components/typography/H3.vue';
 import Text from '@/components/basic/Text.vue';
 import Height from '@/components/layout/space/Height.vue';
@@ -87,8 +86,17 @@ const collectStore = useCollectStore();
 const villageListLoader = useSimpleDataLoader(async () => await VillageApi.getClaimedVallageList(), true);
 const volunteerInfoLoader = useSimpleDataLoader(async () =>{
   const res = await VillageApi.getVolunteerInfo();
-  const collectableModules = volunteerInfoLoader.content.value?.collectModule || [];
-  collectStore.setCollectableModules(collectableModules);
+  const collectableModules = res.collectModule || [];
+  const collectableModulesMap = await VillageApi.getCollectModuleMap();
+  const needRemoveKeys = new Set<string>();
+  if (!authStore.isAdmin) {
+    for (const [key,id] of collectableModulesMap)
+      if (!collectableModules.includes(key))
+        needRemoveKeys.add(key);
+  }
+  for (const key of needRemoveKeys)
+    collectableModulesMap.delete(key);
+  collectStore.setCollectableModules(collectableModulesMap);
   return res;
 }, true);
 const rankListLoader = useSimpleDataLoader(async () => await VillageApi.getVolunteerRanklist(), true);

+ 4 - 1
src/pages/dig/task/building.vue

@@ -8,28 +8,31 @@
     />
     <FlexCol :gap="20">
       <TaskList
-        v-if="canCollect('distribution')"
         icon="icon-task-building-1"
         title="建筑分布"
         desc="村落内传统建筑分布情况"
+        :enable="canCollect('distribution')"
         @click="goForm('distribution', 0, undefined, undefined, '建筑分布')"
       />
       <TaskList
         icon="icon-task-building-2"
         title="文物建筑"
         desc="历史、艺术、科学价值"
+        :enable="canCollect('building')"
         @click="goForm('building', 1, 'nature', undefined, '文物建筑')"
       />
       <TaskList
         icon="icon-task-building-3"
         title="历史建筑"
         desc="重大历史事件记录"
+        :enable="canCollect('building')"
         @click="goForm('building', 2, 'nature', undefined, '历史建筑')"
       />
       <TaskList
         icon="icon-task-building-4"
         title="重要传统建筑"
         desc="重要传统建筑的信息"
+        :enable="canCollect('building')"
         @click="goForm('building', 3, 'nature', undefined, '重要传统建筑')"
       />
     </FlexCol>

+ 0 - 6
src/pages/dig/task/custom.vue

@@ -8,12 +8,6 @@
     />
     <FlexCol :gap="20">
       <TaskList
-        icon="icon-task-custom-1"
-        title="非物质文化遗产项目"
-        desc="维护文化多样性"
-        @click="goForm('ich', 0, undefined, undefined, '非物质文化遗产项目')"
-      />
-      <TaskList
         icon="icon-task-custom-2"
         title="节庆活动"
         desc="欢庆与传承并重的文化盛宴"

+ 1 - 1
src/pages/dig/task/environment.vue

@@ -14,7 +14,7 @@
         @click="goForm('environment', 0, undefined, undefined, '自然环境')"
       />
       <TaskList
-        v-if="canCollect('cultural_relic')"
+        v-if="canCollect('relic')"
         icon="icon-task-environment-5"
         title="文物古迹"
         desc="重要历史文献资料"

+ 6 - 1
src/pages/dig/task/history.vue

@@ -12,37 +12,42 @@
         icon="icon-task-history-1"
         title="建村历史"
         desc="村落建立与发展历程"
+        :enable="canCollect('cultural')"
         @click="goForm('cultural', 1, undefined, undefined, '建村历史')"
       />
       <TaskList
         icon="icon-task-history-2"
         title="历史人物"
         desc="重要历史人物事迹"
+        :enable="canCollect('cultural')"
         @click="goForm('figure', 0, undefined, undefined, '历史人物')"
       />
       <TaskList
         icon="icon-task-history-3"
         title="历史事件"
         desc="重大历史事件记录"
+        :enable="canCollect('cultural')"
         @click="goForm('cultural', 2, undefined, undefined, '历史事件')"
       />
       <TaskList
-        v-if="canCollect('story')"
         icon="icon-task-history-4"
         title="掌故轶事"
         desc="民间传说与历史故事"
+        :enable="canCollect('story')"
         @click="goForm('story', 0, undefined, undefined, '掌故轶事')"
       />
       <TaskList
         icon="icon-task-history-5"
         title="历史文献"
         desc="重要历史文献资料"
+        :enable="canCollect('cultural')"
         @click="goForm('cultural', 3, undefined, undefined, '历史文献')"
       />
       <TaskList
         icon="icon-task-history-6"
         title="口述历史"
         desc="村民口述历史记录"
+        :enable="canCollect('cultural')"
         @click="goForm('cultural', 4, undefined, undefined, '口述历史')"
       />
     </FlexCol>

+ 4 - 2
src/pages/dig/task/trip.vue

@@ -9,25 +9,27 @@
     />
     <FlexCol :gap="20">
       <TaskList
-        v-if="canCollect('travel_guide')"
         icon="icon-task-trip-3"
         title="旅游导览"
+        :enable="canCollect('travel_guide')"
         @click="goForm('travel_guide', 0, undefined, undefined, '旅游导览')"
       />
       <TaskList
-        v-if="canCollect('route')"
         icon="icon-task-trip-1"
         title="游览路线"
+        :enable="canCollect('route')"
         @click="goForm('route', 1, undefined, undefined, '游览路线')"
       />
       <TaskList
         icon="icon-task-trip-2"
         title="活动时间"
+        :enable="canCollect('route')"
         @click="goForm('route', 2, undefined, undefined, '活动时间')"
       />
       <TaskList
         icon="icon-task-trip-4"
         title="路线特色"
+        :enable="canCollect('route')"
         @click="goForm('route', 3, undefined, undefined, '路线特色')"
       />
     </FlexCol>

+ 35 - 4
src/store/collect.ts

@@ -2,25 +2,56 @@ import { computed, ref } from 'vue'
 import { defineStore } from 'pinia'
 import { useAuthStore } from './auth';
 
+const CollectableModulesNameMapping : Record<string, string> = {
+  'overview': '村落概况',
+  'distribution': '建筑分布',
+  'building': '传统建筑',
+  'folk_culture': '民俗文化',
+  'food_product': '美食物产',
+  'route': '旅游路线',
+  'travel_guide': '旅游导览',
+  'element': '环境要素',
+  'environment': '环境格局',
+  'relic': '文物古迹',
+  'cultural': '历史文化',
+  'figure': '历史人物',
+  'ich': '非遗',
+  'story': '掌故轶事',
+  'village': '风景名胜',
+  'speaker': '口述者',
+  'collect': '随手记',
+}
+
 export const useCollectStore = defineStore('collect', () => {
-  const collectableModules = ref<string[]>([]);
+  const collectableModules = ref(new Map<string, number>());
   const authStore = useAuthStore();
 
-  function setCollectableModules(modules: string[]) {
+
+  function setCollectableModules(modules: Map<string, number>) {
     collectableModules.value = modules;
+    console.log(modules);
+    
   }
   function canCollect(module: string) {
     if (authStore.isAdmin)
       return true;
-    return collectableModules.value.includes(module);
+    if (collectableModules.value.has(CollectableModulesNameMapping[module]))
+      return true;
+    return collectableModules.value.has(module);
+  }
+  function getCollectModuleId(module: string) {
+    if (collectableModules.value.has(CollectableModulesNameMapping[module]))
+      return collectableModules.value.get(CollectableModulesNameMapping[module]);
+    return collectableModules.value.get(module);
   }
   
-  const isEmpty = computed(() => collectableModules.value.length === 0);
+  const isEmpty = computed(() => collectableModules.value.size === 0);
 
   return { 
     isEmpty,
     collectableModules,
     setCollectableModules,
+    getCollectModuleId,
     canCollect,
   }
 })