wenhongquan 3 vuotta sitten
vanhempi
commit
8f4d58fd67
2 muutettua tiedostoa jossa 21 lisäystä ja 7 poistoa
  1. 15 6
      src/components/MarkerMap/dialog.ts
  2. 6 1
      src/components/MarkerMap/index.tsx

+ 15 - 6
src/components/MarkerMap/dialog.ts

@@ -171,7 +171,10 @@ export const GET_TEAM_DIALOG_HTML = (item: ResourceItemDetail) => {
 };
 
 
-export const GET_SINGLE_DEVICE_DIALOG_HTML = (item: SingleDeviceItem) => {
+export const GET_SINGLE_DEVICE_DIALOG_HTML = (
+  item: SingleDeviceItem,
+  callback: Function 
+) => {
   const el = document.createElement('div');
   el.innerHTML = `
   <div>
@@ -181,15 +184,21 @@ export const GET_SINGLE_DEVICE_DIALOG_HTML = (item: SingleDeviceItem) => {
       <div><span>设备号:</span><span>${item.deviceCode ?? '-'}</span></div>
       <div><span>定位时间:</span><span>${item.time ?? '-'}</span></div>
     </div>
-    <div class="action">
-      <button class="el-button el-button--primary el-button--small" type="button">
-        <span>查看单兵</span>
-      </button>
-    </div>
+    
     <i class="card-border-bottom-left"></i>
     <i class="card-border-bottom-right"></i>
   </div>
   `;
+  const action = document.createElement('div');
+  action.className = 'action';
+  const button = document.createElement('button');
+  button.className = 'el-button el-button--primary el-button--small';
+  button.innerHTML = '查看单兵';
+  action.appendChild(button);
+  button.addEventListener('click', callback);
+
+  el.appendChild(action);
+
   return el;
 };
 

+ 6 - 1
src/components/MarkerMap/index.tsx

@@ -43,6 +43,7 @@ import Popup from '../Popup';
 import { ElMessage } from 'element-plus';
 import { isEmpty } from 'lodash';
 import clsx from 'clsx';
+import { SingleDeviceItem } from '@/api/resource';
 
 const MARKER_MAP_TYPES = [
   // '待派发事件',
@@ -187,7 +188,11 @@ export default defineComponent({
             store.currentIncident = marker;
           });
         case '单兵': { 
-            return GET_SINGLE_DEVICE_DIALOG_HTML(marker);
+          var callback = () => {
+            console.log(marker["deviceCode"])
+
+          };
+            return GET_SINGLE_DEVICE_DIALOG_HTML(marker as SingleDeviceItem,callback);
         }
         
         case '应急仓库':