tangning 4 months ago
parent
commit
f5f7f2d08d
4 changed files with 106 additions and 20 deletions
  1. 2 0
      src/request/urls.ts
  2. 10 1
      src/store/case.ts
  3. 44 0
      src/util/index.ts
  4. 50 19
      src/view/case/records/index.vue

+ 2 - 0
src/request/urls.ts

@@ -255,6 +255,8 @@ export const getDictFileList = "/service/manage/dict/getByKey/media-library";
 export const delDictFileList = "/service/manage/dictFile/del/media-library";
 export const getListFileList = "/service/manage/dictFile/pageList/media-library";
 export const caseaddOrUpdate = '/service/manage/case/addOrUpdate';
+export const getByImage = '/fusion/ai/getByImage';
+export const getFloor = "/fusion/ai/getFloor/";
 //地图相关
 // export const getTips = "http://map.jms.gd//s/api/gettips";
 // export const getTipsName = "http://map.jms.gd/s/api/gettips_name";

+ 10 - 1
src/store/case.ts

@@ -36,7 +36,9 @@ import {
   caseaddOrUpdate,
   isdyrh,
   getTips,
-  getTipsName
+  getTipsName,
+  getByImage,
+  getFloor,
 } from "@/request";
 import { router } from "@/router";
 import { ModelScene, QuoteScene, Scene, SceneType } from "./scene";
@@ -64,6 +66,12 @@ export const setCaseSharePWD = (params: { caseId: number; randCode: string }) =>
 export const setCaseaddOrUpdate = (params) =>
   axios.post(caseaddOrUpdate, params);
 
+export const getAiByImage = async (params) =>
+  (await axios.post<string>(getByImage, params)).data;
+
+export const getFloorList = async (caseId) =>
+  (await axios.get<string>(getFloor+caseId, {})).data;
+
 export const getCaseSharePWD = async (params: { caseId: number }) =>
   (await axios.get<string>(getCasePsw, { params })).data;
 
@@ -256,6 +264,7 @@ export const getSceneListHasAi = (caseId: number) =>
 export const getTipsList = (key) =>
   axios.get(getTips, { params: { 
     basic: 'y',
+
     key,
     location: '113.05,22.61',
    } });

+ 44 - 0
src/util/index.ts

@@ -369,3 +369,47 @@ export const getDomMatrix = (dom: HTMLElement) => {
     1,
   ];
 };
+export function copyTextToClipboard(input: string, { target = document.body }: Options = {}) {
+  const element = document.createElement('textarea');
+  const previouslyFocusedElement = document.activeElement;
+
+  element.value = input;
+
+  element.setAttribute('readonly', '');
+
+  (element.style as any).contain = 'strict';
+  element.style.position = 'absolute';
+  element.style.left = '-9999px';
+  element.style.fontSize = '12pt';
+
+  const selection = document.getSelection();
+  let originalRange;
+  if (selection && selection.rangeCount > 0) {
+    originalRange = selection.getRangeAt(0);
+  }
+
+  target.append(element);
+  element.select();
+
+  element.selectionStart = 0;
+  element.selectionEnd = input.length;
+
+  let isSuccess = false;
+  try {
+    isSuccess = document.execCommand('copy');
+  } catch (e: any) {
+    throw new Error(e);
+  }
+
+  element.remove();
+
+  if (originalRange && selection) {
+    selection.removeAllRanges();
+    selection.addRange(originalRange);
+  }
+
+  if (previouslyFocusedElement) {
+    (previouslyFocusedElement as HTMLElement).focus();
+  }
+  return isSuccess;
+}

+ 50 - 19
src/view/case/records/index.vue

@@ -236,7 +236,7 @@
       <div class="textarea">
         <div>
           <span>现场勘验情况 :</span>
-          <span @click="()=>{aiImgShow=true}" style="color:#000;cursor: pointer;float: right;font-weight: bold;">AI</span>
+          <span @click="()=>{aiImgShow=true}" style="color:#26559B;cursor: pointer;float: right;font-weight: bold;">AI</span>
         </div>
         <el-input
           type="textarea"
@@ -476,38 +476,44 @@
     <el-dialog
       v-model="aiImgShow"
       title="AI识别平面图"
-      width="1000"
+      width="1300px"
       align-center
-      @close="recorderInfoDialogSelect = null"
+      @close="aiImgData.src = null"
     >
       <div class="flex space-x-4 items-center content-center justify-center text-center">
         <div class="flex-1" style="width: 80%;">
         <el-select
-          v-model="recorderInfoDialogSelect"
-          placeholder="请选择现场勘验记录人员"
+          v-model="aiImgData.src"
+          placeholder="请选择平面图"
           size="large"
         >
           <el-option
-            v-for="item in recorderInfoType"
-            :key="item.type"
-            :label="item.typeLabel"
-            :value="item.type"
+            v-for="item in aiImgData.list"
+            :key="item.num"
+            :label="item.num"
+            :value="item.urls[0]"
           />
         </el-select>
-        <div class="viewImg mt-4 text-center" style="height: 300px; line-height: 300px; background: #d8d8d8;">
+        <div class="viewImg mt-4 text-center" style="height: 400px; line-height: 400px; border-radius: 0px 0px 0px 0px;
+border: 1px solid #D9D9D9;">
           <img class="w-full h-full object-cover" v-if="aiImgData.src" :src="aiImgData.src" alt="" />
           <span v-else>预览选中的平面图</span>
         </div>
       </div>
-      <div class="flex-1">
+      <div class="flex-1 text-center content-start" style="border-radius: 0px 0px 0px 0px;
+border: 1px solid #D9D9D9;">
         <span v-if="aiImgData.loading">识别中</span>
-        <span v-else>{{ aiImgData.result || '识别结果'}}</span>
+        <div class="text-left" style="height: 450px;padding: 10px" v-else v-html="aiImgData.result"></div>
       </div>
       </div>
       <template #footer>
-        <div class="dialog-footer text-center">
-          <el-button type="primary" @click="handleAI"> 识别 </el-button>
-          <el-button v-if="aiImgData.result" @click="handleAI"> 复制 </el-button>
+        <div class="dialog-footer text-center flex">
+          <div style="width: 50%">
+            <el-button type="primary" @click="handleAI"> 识别 </el-button>
+          </div>
+          <div style="width: 50%">
+            <el-button :disabled="aiImgData.result" @click="handleCopy"> 复制 </el-button>
+          </div>
         </div>
       </template>
     </el-dialog>
@@ -522,12 +528,15 @@ import {
   saveCaseInquestInfo,
   exportCaseInquestInfo,
   getCaseInquestInfoOld,
+  getAiByImage,
+  getFloorList,
 } from "@/store/case";
 import { ElMessage, ElMessageBox } from "element-plus";
 import saveAs from "@/util/file-serve";
 import { CirclePlus, CircleClose, MagicStick } from "@element-plus/icons-vue";
 import { recorderInfoType, ChangeReasonType } from "./formData.ts";
 import { confirm } from "@/helper/message";
+import { copyTextToClipboard } from "@/util/index";
 const props = defineProps({ caseId: Number, title: String });
 console.log("router.currentRoute", router.currentRoute.value?.params);
 const fileId = computed(() => router.currentRoute.value?.params?.fileId);
@@ -535,9 +544,10 @@ const caseId = computed(() => router.currentRoute.value?.params?.caseId);
 const isDisableExport = ref(false);
 const aiImgShow = ref(false)
 const aiImgData = ref({
-  src: '',
-  result: '',
-  loading: false
+  src: '/oss/scene_view_data/YZL-jm-Z7xsq0T8502/user/floor-cad-0.png',
+  result: ``,
+  loading: false,
+  list: [],
 })
 
 const data = reactive({
@@ -613,7 +623,24 @@ const initInfo = async (inquestFileId) => {
     initSignatureAndWitInfo();
   }, 500);
 };
-const handleAI = () => {
+const handleCopy = () => {
+  copyTextToClipboard(aiImgData.value.result);
+  ElMessage.success("复制成功!");
+}
+const handleAI = async () => {
+  aiImgData.value.loading = true;
+  let orgin = window.location.origin;
+  let imageUrl = orgin + aiImgData.value.src
+  try {
+  const res = await getAiByImage({imageUrl: 'http://192.168.0.25/oss/scene_view_data/YZL-jm-Z7xsq0T8502/user/floor-cad-0.png'})
+  console.log("handleAI", res)
+  aiImgData.value = {
+    result: res,
+    loading: false
+  }
+  } catch (error) {
+    aiImgData.value.loading = false;
+  }
 
 };
 const initSignatureAndWitInfo = () => {
@@ -640,6 +667,10 @@ const initSignatureAndWitInfo = () => {
 
 onMounted(() => {
   initInfo();
+  getFloorList(caseId.value).then((res) => {
+    aiImgData.value.list = res.filter((i) => i.urls && i.urls.length);
+    console.log("getFloorList", res);
+  });
 });
 
 const addRecorderInfo = () => {