import {
  SceneLabelType,
  querySceneLabel,
  TemplateType,
  querytemplate,
  queryWorkshopModule,
  WorkshopModuleType,
} from '@/api/scene/secene-templet';
import { onMounted, ref } from 'vue';

export function useSceneTemplete() {
  //场景标签
  const sceneList = ref<SceneLabelType[]>([]);

  const getSceneLabel = () => {
    querySceneLabel().then((res) => {
      sceneList.value = res;
    });
  };

  //场景模板
  const templateList = ref<TemplateType[]>([]);

  const getTemplete = () => {
    querytemplate().then((res) => {
      templateList.value = res?.filter((x) => x.status === 0) || [];
      console.log('templateList.value', templateList.value);
    });
  };

  //车间模板
  const workshopTemplateList = ref<WorkshopModuleType[]>([]);

  const getWorkshopTemplete = () => {
    queryWorkshopModule().then((res) => {
      workshopTemplateList.value = res;
    });
  };

  onMounted(() => {
    getSceneLabel();
    getTemplete();
    getWorkshopTemplete();
  });

  return {
    sceneList,
    getSceneLabel,
    templateList,
    getTemplete,
    workshopTemplateList,
    getWorkshopTemplete,
  };
}

export default useSceneTemplete;
