gemercheung 1 год назад
Родитель
Сommit
fb5fef5df8
2 измененных файлов с 32 добавлено и 4 удалено
  1. 11 0
      src/api/scene/list.ts
  2. 21 4
      src/views/scenes/list.vue

+ 11 - 0
src/api/scene/list.ts

@@ -29,6 +29,7 @@ enum Api {
   unCollaborate = 'service/manage_jp/contractor/unCollaborate',
   unCollaborateList = 'service/manage_jp/contractor/details',
   genOBJ = 'service/manage_jp/scene/generateObjFile',
+  updateMapShow = 'service/manage_jp/scene/updateMapShow',
 }
 
 /**
@@ -177,3 +178,13 @@ export const generateObjFileAPI = (params: GenOBJParam) =>
       ignoreCancelToken: true,
     },
   });
+
+export const updateMapShowApi = (params: { num: string; mapShow: number }) =>
+  defHttp.post<Result>({
+    url: Api.updateMapShow,
+    data: params,
+    headers: {
+      // @ts-ignore
+      ignoreCancelToken: true,
+    },
+  });

+ 21 - 4
src/views/scenes/list.vue

@@ -24,8 +24,13 @@
           <!-- <a-button type="primary" color="warning" @click="() => {}"> 编辑</a-button>
         <a-button type="primary" color="error" @click="() => {}"> 删除</a-button> -->
         </template>
-        <template #showMap="{ record }">
-          <Switch v-model:checked="record.showMap" />
+        <template #mapShow="{ record }">
+          <Switch
+            v-model:checked="record.mapShow"
+            :checkedValue="1"
+            :unCheckedValue="0"
+            @click="handleUpdateSwitch(record)"
+          />
         </template>
         <template #cover="{ record }">
           <TableImg
@@ -159,6 +164,7 @@
     sceneCopy,
     patchcoldStorageApi,
     generateObjFileAPI,
+    updateMapShowApi,
   } from '/@/api/scene/list';
   import { useI18n } from '/@/hooks/web/useI18n';
   import {
@@ -276,8 +282,8 @@
         },
         {
           title: t('routes.scenes.showMap'),
-          dataIndex: 'showMap',
-          slots: { customRender: 'showMap' },
+          dataIndex: 'mapShow',
+          slots: { customRender: 'mapShow' },
           width: 180,
         },
         {
@@ -540,6 +546,16 @@
       const handleMigrateCancel = () => {
         reload();
       };
+      async function handleUpdateSwitch(record: any) {
+        // const reveseValue = Math.abs(record.mapShow - 1);
+        // record.mapShow = record.mapShow;
+        console.log('reveseValue', record.mapShow);
+        await updateMapShowApi({
+          num: record.num,
+          mapShow: record.mapShow,
+        });
+        setTimeout(reload, 100);
+      }
 
       return {
         reload,
@@ -568,6 +584,7 @@
         handleMigrate,
         handleMigrateSuccess,
         handleMigrateCancel,
+        handleUpdateSwitch,
       };
     },
   });