|
@@ -1,49 +1,49 @@
|
|
|
import { ref } from 'vue';
|
|
import { ref } from 'vue';
|
|
|
-import { getWorkLocationList } from '@/api/datamanagement/alert'
|
|
|
|
|
|
|
+import { getWorkLocationList } from '@/api/datamanagement/alert';
|
|
|
|
|
|
|
|
type Location = {
|
|
type Location = {
|
|
|
- value: number,
|
|
|
|
|
- label: string,
|
|
|
|
|
|
|
+ value: number;
|
|
|
|
|
+ label: string;
|
|
|
children: {
|
|
children: {
|
|
|
- value: number,
|
|
|
|
|
- label: string
|
|
|
|
|
- }[]
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ value: number;
|
|
|
|
|
+ label: string;
|
|
|
|
|
+ }[];
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
export function useWorkLocation() {
|
|
export function useWorkLocation() {
|
|
|
const locationOptions = ref<Location[]>([]);
|
|
const locationOptions = ref<Location[]>([]);
|
|
|
|
|
|
|
|
const getLocationOptions = () => {
|
|
const getLocationOptions = () => {
|
|
|
getWorkLocationList().then((res) => {
|
|
getWorkLocationList().then((res) => {
|
|
|
- locationOptions.value = res?.map((item) => {
|
|
|
|
|
- const newChildren = item.workspaceList?.map(x => {
|
|
|
|
|
- return { value: x.workspaceId, label: x.workspaceName }
|
|
|
|
|
- }) || []
|
|
|
|
|
- return {
|
|
|
|
|
- value: item.workshopId,
|
|
|
|
|
- label: item.workshopName,
|
|
|
|
|
- children: newChildren
|
|
|
|
|
- }
|
|
|
|
|
- }) || []
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ locationOptions.value =
|
|
|
|
|
+ res?.map((item) => {
|
|
|
|
|
+ const newChildren =
|
|
|
|
|
+ item.workspaceList?.map((x) => {
|
|
|
|
|
+ return { value: x.workspaceId, label: x.workspaceName };
|
|
|
|
|
+ }) || [];
|
|
|
|
|
+ return {
|
|
|
|
|
+ value: item.workshopId,
|
|
|
|
|
+ label: item.workshopName,
|
|
|
|
|
+ children: newChildren,
|
|
|
|
|
+ };
|
|
|
|
|
+ }) || [];
|
|
|
|
|
+ });
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // 根据workshopId + workspaceId 指定表格显示 地点 label
|
|
|
|
|
const getNameByWorkid = (workshopId, workspaceId, array) => {
|
|
const getNameByWorkid = (workshopId, workspaceId, array) => {
|
|
|
- if (workshopId < 0 || workshopId > array.length) return '-';
|
|
|
|
|
- const obj = array[workshopId - 1];
|
|
|
|
|
-
|
|
|
|
|
- if (!obj.children || !Array.isArray(obj.children)) return '-';
|
|
|
|
|
- if (workspaceId < 0) return '-';
|
|
|
|
|
- if (obj.children) {
|
|
|
|
|
- const subObj = obj.children.find(subobj => subobj.value === workspaceId);
|
|
|
|
|
- return obj.label + ' - ' + subObj?.label;
|
|
|
|
|
|
|
+ const shop = array.find((item) => item.value === workshopId);
|
|
|
|
|
+ if (!shop) {
|
|
|
|
|
+ return '-';
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (!shop.children || !Array.isArray(shop.children)) return '-';
|
|
|
|
|
+ const space = shop.children.find((item) => item.value === workspaceId);
|
|
|
|
|
+ return shop.label + ' - ' + space?.label;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
locationOptions,
|
|
locationOptions,
|
|
|
getLocationOptions,
|
|
getLocationOptions,
|
|
|
- getNameByWorkid
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ getNameByWorkid,
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|