|
@@ -4,20 +4,32 @@ import { useAuthStore } from './auth';
|
|
|
import { CollectableModulesNameMapping } from '@/pages/dig/forms/forms';
|
|
import { CollectableModulesNameMapping } from '@/pages/dig/forms/forms';
|
|
|
import VillageApi from '@/api/inhert/VillageApi';
|
|
import VillageApi from '@/api/inhert/VillageApi';
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+ * 采集模块状态
|
|
|
|
|
+ */
|
|
|
export const useCollectStore = defineStore('collect', () => {
|
|
export const useCollectStore = defineStore('collect', () => {
|
|
|
const collectableModules = ref(new Map<string, number>());
|
|
const collectableModules = ref(new Map<string, number>());
|
|
|
const collectableAllModules = ref(new Map<string, number>());
|
|
const collectableAllModules = ref(new Map<string, number>());
|
|
|
const collectableCatalogs = ref<number[]>([]);
|
|
const collectableCatalogs = ref<number[]>([]);
|
|
|
const authStore = useAuthStore();
|
|
const authStore = useAuthStore();
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设置采集模块状态数据
|
|
|
|
|
+ */
|
|
|
function setCollectableModules(modules: Map<string, number>) {
|
|
function setCollectableModules(modules: Map<string, number>) {
|
|
|
collectableModules.value = modules;
|
|
collectableModules.value = modules;
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断是否可以采集指定目录
|
|
|
|
|
+ */
|
|
|
function canCollectCatalog(catalogId: number) {
|
|
function canCollectCatalog(catalogId: number) {
|
|
|
if (authStore.isAdmin)
|
|
if (authStore.isAdmin)
|
|
|
return true;
|
|
return true;
|
|
|
return collectableCatalogs.value.includes(catalogId);
|
|
return collectableCatalogs.value.includes(catalogId);
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断是否可以采集指定模块
|
|
|
|
|
+ */
|
|
|
function canCollect(module: string) {
|
|
function canCollect(module: string) {
|
|
|
if (authStore.isAdmin)
|
|
if (authStore.isAdmin)
|
|
|
return true;
|
|
return true;
|
|
@@ -25,11 +37,17 @@ export const useCollectStore = defineStore('collect', () => {
|
|
|
return true;
|
|
return true;
|
|
|
return collectableModules.value.has(module);
|
|
return collectableModules.value.has(module);
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取采集模块的内部名称
|
|
|
|
|
+ */
|
|
|
function getCollectModuleId(module: string) {
|
|
function getCollectModuleId(module: string) {
|
|
|
if (collectableAllModules.value.has(CollectableModulesNameMapping[module]))
|
|
if (collectableAllModules.value.has(CollectableModulesNameMapping[module]))
|
|
|
return collectableAllModules.value.get(CollectableModulesNameMapping[module]);
|
|
return collectableAllModules.value.get(CollectableModulesNameMapping[module]);
|
|
|
return collectableAllModules.value.get(module);
|
|
return collectableAllModules.value.get(module);
|
|
|
}
|
|
}
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 从ID获取采集模块的内部名称
|
|
|
|
|
+ */
|
|
|
function getCollectModuleInternalNameById(id: number) {
|
|
function getCollectModuleInternalNameById(id: number) {
|
|
|
for (const [key, value] of collectableAllModules.value) {
|
|
for (const [key, value] of collectableAllModules.value) {
|
|
|
if (value == id) {
|
|
if (value == id) {
|
|
@@ -61,6 +79,9 @@ export const useCollectStore = defineStore('collect', () => {
|
|
|
setCollectableModules(collectableModulesMap);
|
|
setCollectableModules(collectableModulesMap);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 判断采集模块状态是否为空
|
|
|
|
|
+ */
|
|
|
const isEmpty = computed(() => collectableModules.value.size === 0 && collectableCatalogs.value.length === 0);
|
|
const isEmpty = computed(() => collectableModules.value.size === 0 && collectableCatalogs.value.length === 0);
|
|
|
|
|
|
|
|
return {
|
|
return {
|