tangning 9 月之前
父节点
当前提交
44e3a4298b
共有 1 个文件被更改,包括 63 次插入41 次删除
  1. 63 41
      src/view/vrmodel/index.vue

+ 63 - 41
src/view/vrmodel/index.vue

@@ -1,40 +1,57 @@
 <template>
   <div class="scene">
-    <span class="title1" style="line-height: 32px ">多元融合</span>
+    <span class="title1" style="line-height: 32px">多元融合</span>
     <el-button class="w-full my-4" @click="handleAdddyrh">编辑</el-button>
     <div class="scene-list">
-        <div class="scene-title flex justify-between content-center">
-          <span class="title1" style="line-height: 32px ">场景列表</span>
-          <!-- <el-switch v-model="active" @change="handleActive" /> -->
-        </div>
-    <el-button class="w-full my-4" @click="handleAdd" style="margin-left: 0; margin-right: 0">新增</el-button>
-        <div class="list" v-if="active" style="min-height: 630px;">
-          <div
-            class="listItem flex justify-between py-2"
-            v-for="item,index in list"
-            :key="index"
-          >
-            <span class="anmc" :title="item.name">{{ item.name || '多元融合' }}</span>
-            <div class="cursor-pointer" quaternary type="primary">
-              <span class="mr-4" @click="handlegotoelT(item)" :style="{color: item.inFusion?'#ccc':''}">移除</span>
-              <span @click="handlegotoEdit(item)">编辑</span>
-            </div>
-            <!-- <div @click="handlegotoEdit(item)" class="cursor-pointer" quaternary type="primary">编辑</div> -->
+      <div class="scene-title flex justify-between content-center">
+        <span class="title1" style="line-height: 32px">场景列表</span>
+        <!-- <el-switch v-model="active" @change="handleActive" /> -->
+      </div>
+      <el-button
+        class="w-full my-4"
+        @click="handleAdd"
+        style="margin-left: 0; margin-right: 0"
+        >新增</el-button
+      >
+      <div class="list" v-if="active" style="min-height: 630px">
+        <div
+          class="listItem flex justify-between py-2"
+          v-for="(item, index) in list"
+          :key="index"
+        >
+          <span class="anmc" :title="item.name">{{
+            item.name || "多元融合"
+          }}</span>
+          <div class="cursor-pointer" quaternary type="primary">
+            <span
+              class="mr-4"
+              @click="handlegotoelT(item)"
+              :style="{ color: item.inFusion ? '#ccc' : '' }"
+              >移除</span
+            >
+            <span @click="handlegotoEdit(item)">编辑</span>
           </div>
+          <!-- <div @click="handlegotoEdit(item)" class="cursor-pointer" quaternary type="primary">编辑</div> -->
         </div>
-        <!-- <el-button
+      </div>
+      <!-- <el-button
                 class="w-full"
                 type="primary"
                 @click="submitForm"
               >
                 保存
               </el-button> -->
-      </div>
+    </div>
   </div>
 </template>
 
 <script setup lang="ts">
-import { getCaseSceneList, getUrlSrc, getSceneListTree, setCaseaddOrUpdate } from "@/store/case";
+import {
+  getCaseSceneList,
+  getUrlSrc,
+  getSceneListTree,
+  setCaseaddOrUpdate,
+} from "@/store/case";
 import { router } from "@/router";
 import comSelect from "@/components/company-select/index.vue";
 import List from "./list.vue";
@@ -46,10 +63,10 @@ import { computed, ref, onMounted } from "vue";
 import { tableModelScene } from "./quisk";
 const active = ref(true);
 const list = ref([]);
-const isEdit = ref(false)
+const isEdit = ref(false);
 const showModal = ref(false);
 const params = useScenePaggingParams();
-const caseId = computed(() => (router.currentRoute.value?.params?.caseId));
+const caseId = computed(() => router.currentRoute.value?.params?.caseId);
 onMounted(() => {
   geiList();
   console.log("router.currentRoute.value", caseId);
@@ -59,11 +76,14 @@ async function geiList() {
   console.log("res", list.value);
 }
 function handlegotoEdit(record) {
-  let url = record.type == 2 || record.type == 5 ?  `/mega/index.html?m=${record.num}` : `/epg.html?m=${record.num}`
+  let url =
+    record.type == 2 || record.type == 5
+      ? `/mega/index.html?m=${record.num}`
+      : `/epg.html?m=${record.num}`;
   window.open(url.replace("spg", "epg"));
 }
 function handleAdddyrh(record) {
-  let url = `/code/index.html?caseId=${caseId.value}#/fuseEdit/merge`
+  let url = `/code/index.html?caseId=${caseId.value}#/fuseEdit/merge`;
   window.open(url);
 }
 async function handlegotoelT(record) {
@@ -72,7 +92,7 @@ async function handlegotoelT(record) {
   //   ElMessage.error("无法移除,场景已加入多元融合,请进入多元融合移除场景后再试");
   //   return
   // }
-  if (await confirm("确定要移除当前场景吗?")) {
+  if (record.inFusion || (await confirm("确定要移除当前场景吗?"))) {
     list.value = list.value.filter((item) => item.num !== record.num);
     submitForm();
   }
@@ -80,21 +100,24 @@ async function handlegotoelT(record) {
 }
 async function submitForm() {
   isEdit.value = false;
-  let sublist = getSceneListTree(list.value)
+  let sublist = getSceneListTree(list.value);
   const apiData = {
     // caseTitle: caseId.value,
     caseId: caseId.value,
     sceneNumParam: sublist,
   };
-  await setCaseaddOrUpdate(apiData)
-  ElMessage({
-      message: '操作成功',
-      type: 'success',
-    })
-  window.location.reload()
+  setCaseaddOrUpdate(apiData).then((res) => {
+    ElMessage({
+      message: "操作成功",
+      type: "success",
+    });
+  }).catch((errr) => {
+    console.log("setCaseaddOrUpdateerrr", errr);
+    return geiList();
+  })
+};
+  // window.location.reload()
   // console.log("handleActive", params);
-}
-
 async function handleAdd() {
   // if(isEdit.value){
   //   await confirm("请先保存当前移除的场景信息!")
@@ -102,22 +125,21 @@ async function handleAdd() {
   // }
   let numList = list.value.map((item) => item.num);
   console.log("handleAdd", numList);
-  let val = await tableModelScene({numList: numList});
+  let val = await tableModelScene({ numList: numList });
   geiList();
   if (val) {
     console.log("刷新列表");
   }
-
 }
 </script>
 <style scoped>
 .anmc {
   overflow: hidden;
-    text-overflow: ellipsis;
-    white-space: nowrap;
-    width: 190px;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  width: 190px;
 }
-.cursor-pointer{
+.cursor-pointer {
   color: var(--primaryColor);
 }
 </style>