30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { ref, computed } from "vue";
|
|
import { defineStore } from "pinia";
|
|
import type { DataOptionInsignia,DataOption } from "@/modules/04_registryPerson/interface/index/Main";
|
|
import type { ResponseObject as Insignia } from "@/modules/07_insignia/interface/response/Main";
|
|
|
|
export const useInsigniaDataStore = defineStore("insigniaDataStore", () => {
|
|
const insigniaOption = ref<DataOptionInsignia[]>([]);
|
|
const insigniaTypeOp = ref<DataOption[]>([]);
|
|
const insigniaTypeOpMain = ref<DataOption[]>([]);
|
|
|
|
function mapInsigniaOption(resData: any) {
|
|
insigniaTypeOp.value = Array.from(
|
|
new Map(
|
|
resData.map((item:any) => [item.insigniaTypeName, { id: item.insigniaTypeId, name: item.insigniaTypeName }])
|
|
).values()
|
|
) as DataOption[];
|
|
|
|
insigniaOption.value = [];
|
|
resData.map((r: Insignia) => {
|
|
insigniaOption.value.push({
|
|
id: r.id.toString(),
|
|
name: r.name.toString() + ` (${r.shortName})`,
|
|
typeId: r.insigniaTypeId.toString(),
|
|
typeName: r.insigniaTypeName.toString(),
|
|
});
|
|
});
|
|
}
|
|
|
|
return { insigniaOption, mapInsigniaOption,insigniaTypeOp };
|
|
});
|