<template>
  <div class="abstract">
    <div class="title1">场景列表</div>
    <div>仅 Mesh 场景支持 AI 现勘，请在列表中选择一个场景</div>
    <div class="blList">
      <div
        class="listItem p-2 cursor-pointer"
        v-for="(item, index) in list"
        :key="index"
        @click="handleItem(item)"
      >
        <div class="title1">{{ item.title }}</div>
      </div>
      <span class="title" v-if="!list.length"> 暂无数据</span>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed, ref, reactive } from "vue";
import { addCaseFile } from "../originalPhoto/quisk";
import { ElMessage, ElMessageBox } from "element-plus";
import { useUpload } from "@/hook/upload";
import { RouteName, router } from "@/router";
import { getSceneListHasAi } from "@/store/case";
import { Delete, Edit } from "@element-plus/icons-vue";
const srcList = [
  "https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg",
  "https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg",
];
const caseId = computed(() => (router.currentRoute.value?.params?.caseId));
const active = ref(null);
const list = ref([]);
const ruleFormRef = ref(null);
const activeName = ref("1");
const showModal = ref(false);
const { size, fileList, upload, removeFile, previewFile, file, accept } =
  useUpload({
    maxSize: 10 * 1024 * 1024,
    formats: [".doc", ".docx", , ".pdf"],
  });
const handleItem = (item) => {
  window.open(`/floorplan/index.html?m=${item.num}`)
  active.value = item;
};
const getList = async () => {
  getSceneListHasAi(caseId.value).then((res) => {
    let newradioList = []
    res.data.map(ele => {
      if(ele.hasAi == 1){
        newradioList.push(ele)
      }
    })
    list.value = newradioList;
    console.log("getSceneListData", res);
  });
};
getList();
const submitForm = async (formEl) => {
  if (!formEl) return;
  await formEl.validate((valid, fields) => {
    if (valid) {
      console.log("submit!");
    } else {
      console.log("error submit!", fields);
    }
  });
};
const resetForm = (formEl) => {
  if (!formEl) return;
  formEl.resetFields();
};
function handleActive(params) {
  console.log("handleActive", params);
}
async function handleAdd() {
  await addCaseFile({ caseId: 2, fileType: 1 });
  console.log("handleAdd");
}
function handleDel() {
  ElMessageBox.confirm("确定删除？", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    ElMessage({
      type: "success",
      message: "删除成功",
    });
  });
}
</script>
<style lang="scss" scoped>
.abstract {
  height: 100%;
  .el-form-item--label-top {
    margin-bottom: 14px;
  }
  .form-content {
    height: calc(100vh - 225px);
    overflow-y: scroll;
  }
  .demo-tabs {
    .el-tabs__item {
      height: 32px;
      line-height: 32px;
    }
  }
  .active {
    background-color: #f0f2f5;
  }
  .title1 {
    overflow: hidden; //超出的文本隐藏
    text-overflow: ellipsis; //溢出用省略号显示
    white-space: nowrap; //溢出不换行
  }
}
</style>
