<template>
  <div class="scene">
    <el-button class="w-full" @click="handleAdddyrh">编辑多元融合</el-button>
    <el-button class="w-full my-4" @click="handleAdd" style="margin-left: 0; margin-right: 0">添加场景</el-button>
    <div class="scene-list">
        <div class="scene-title flex justify-between content-center">
          <span style="line-height: 32px title1">场景列表</span>
          <el-switch v-model="active" @change="handleActive" />
        </div>
        <div class="list" v-if="active">
          <div
            class="listItem flex justify-between py-2"
            v-for="item,index in list"
            :key="index"
          >
            <span>{{ item.name || item.modelTitle }}</span>
            <div @click="handlegotoEdit(item)" class="cursor-pointer" quaternary type="primary">编辑</div>
          </div>
        </div>
      </div>
  </div>
</template>

<script setup lang="ts">
import { getCaseSceneList } from "@/store/case";
import { router } from "@/router";
import comSelect from "@/components/company-select/index.vue";
import List from "./list.vue";
import SceneContent from "./sceneContent.vue";
import ModelContent from "./modelContent.vue";
import { useScenePaggingParams } from "./pagging";
import { computed, ref, onMounted } from "vue";
import { tableModelScene } from "./quisk";
const active = ref(true);
const list = ref([]);
const showModal = ref(false);
const params = useScenePaggingParams();
const caseId = computed(() => (router.currentRoute.value?.params?.caseId));
onMounted(() => {
  geiList();
  console.log("router.currentRoute.value", caseId);
});
async function geiList() {
  list.value = await getCaseSceneList(caseId.value);
  console.log("res", list.value);
}
function handlegotoEdit(record) {
  let url = `/epg.html?m=${record.num}`
  window.open(url);
}
function handleAdddyrh(record) {
  let url = `/code/index.html?caseId=${caseId.value}#/fuseEdit/merge`
  window.open(url);
}
function handleActive(params) {
  console.log("handleActive", params);
}
async function handleAdd() {
  let numList = list.value.map((item) => item.num);
  console.log("handleAdd", numList);
  let val = await tableModelScene({numList: numList});
  geiList();
  if (val) {
    console.log("刷新列表");
  }

}
</script>
