แก้อัพไฟล์
This commit is contained in:
parent
15c1c2038f
commit
e92997302b
13 changed files with 448 additions and 108 deletions
|
|
@ -1,30 +1,37 @@
|
|||
import { ref, computed } from "vue";
|
||||
import { defineStore } from "pinia";
|
||||
import type { DataOptionInsignia,DataOption } from "@/modules/04_registryPerson/interface/index/Main";
|
||||
import type {
|
||||
DataOptionInsignia,
|
||||
DataOption,
|
||||
InsigniasType,
|
||||
InsigniasTypeSub,
|
||||
} 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[]>([]);
|
||||
const insigniaOption = ref<InsigniasType[]>([]);
|
||||
|
||||
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[];
|
||||
const insigniaTypeOp = ref<InsigniasType[]>([]);
|
||||
const insigniaTypeOpMain = ref<InsigniasType[]>([]);
|
||||
const allNameInsignia = ref<InsigniasTypeSub[]>([]);
|
||||
|
||||
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(),
|
||||
});
|
||||
});
|
||||
function mapInsigniaOption(resData: InsigniasType[]) {
|
||||
insigniaTypeOpMain.value = resData;
|
||||
insigniaTypeOp.value = resData;
|
||||
|
||||
allNameInsignia.value = resData
|
||||
.flatMap((item: InsigniasType) => item.insignias)
|
||||
.map((i: InsigniasTypeSub) => ({
|
||||
...i,
|
||||
name: `${i.name} (${i.shortName})`,
|
||||
}));
|
||||
}
|
||||
|
||||
return { insigniaOption, mapInsigniaOption,insigniaTypeOp };
|
||||
return {
|
||||
insigniaOption,
|
||||
mapInsigniaOption,
|
||||
insigniaTypeOp,
|
||||
insigniaTypeOpMain,
|
||||
allNameInsignia,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue