zhitong.yu
8 天以前 378d781e6f35f89652aa36e079a8b7fc44cea77e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
<template>
  <!-- 搜索框区域 -->
  <div class="transparent-search-container">
    <el-input
      v-model="searchText"
      :placeholder="t('messageInfo.searchPlaceholder')"
      clearable
      class="transparent-input"
      @clear="handleSearchClear"
    />
    <el-button class="transparent-search-btn" @click="handleSearch">
      <img src="../images/search.png" width="20" style="margin-right: 5px" />
      <span class="cell">{{ t("messageInfo.search") }}</span>
    </el-button>
  </div>
  <el-table :data="tableData" :show-overflow-tooltip="true" class="alarmTable" :row-style="rowStyle">
    <el-table-column :label="t('Person.name')" width="110" align="center">
      <template #default="scope">
        <el-image style="width: 15px; height: 15px; margin-top: 0" :src="my" />&nbsp;
        <span @click="PersonInfoMessage(scope)">
          {{ getSafeValue(scope.row.pname) }}
        </span>
      </template>
    </el-table-column>
 
    <el-table-column :label="t('Person.tagid')" width="70" align="center">
      <template #default="scope">
        <span>
          {{ getSafeValue(scope.row.ptagid) }}
        </span>
      </template>
    </el-table-column>
 
    <el-table-column :label="t('PersonInfoCard.status')" width="60" align="center">
      <template #default="scope">
        <template v-if="scope.row.ponline">
          <img
            :src="scope.row.ponline === '0' ? offlineImgUrl : onlineImgUrl"
            :title="t('PersonInfoCard.status')"
            :style="{ width: '25px', height: '25px' }"
          />
        </template>
        <span v-else>--</span>
      </template>
    </el-table-column>
 
    <el-table-column :label="t('Person.power')" width="70" align="center">
      <template #default="scope">
        <span>
          {{ getSafeValue(scope.row.ppower) }}
        </span>
      </template>
    </el-table-column>
 
    <el-table-column :label="t('messageInfo.position')" width="90" align="center">
      <template #default="scope">
        <span @click="sendDataToParent(scope)">
          <img
            :src="scope.row.ponline === '0' ? position1 : position"
            :title="t('messageInfo.position')"
            :style="{ width: '25px', height: '25px' }"
          />
        </span>
      </template>
    </el-table-column>
  </el-table>
  <el-dialog
    v-model="centerDialogVisible"
    :title="t('Person.PersonInfo')"
    align-center
    width="800"
    destroy-on-close
    center
    style="background-size: 100% 100%"
  >
    <template #header="">
      <div class="my-header" style="color: white">{{ t("Person.PersonInfo") }}</div>
    </template>
    <!-- 个人信息模板 -->
    <div class="person-info">
      <el-row>
        <!-- 左侧图片区域 -->
        <el-col :span="4">
          <div class="image-container">
            <!-- 第一张图片 -->
            <el-image class="person-image" :src="drawerProps.row.baoliu38" @error="handleImageError">
              <template #error>
                <el-image class="person-image" :src="defaultImage" />
              </template>
            </el-image>
            <p style="color: white" class="stroke-with-shadow">【 {{ t("Person.photo") }} 】</p>
 
            <!-- 第二张图片 -->
            <el-image class="person-image" :src="url" @error="handleImageError">
              <template #error>
                <el-image class="person-image" :src="defaultImage" />
              </template>
            </el-image>
            <p class="image-label stroke-with-shadow" style="color: white">【 {{ t("PersonInfoCard.icon") }} 】</p>
          </div>
        </el-col>
        <!-- 右侧信息区域 -->
        <el-col :span="20">
          <div class="info-list">
            <!-- 上部分:个人信息 -->
            <div class="info-section">
              <h4 class="section-title" style="color: white">{{ t("PersonInfoCard.basicInfo") }}</h4>
              <el-row :gutter="9">
                <el-col :span="9" v-for="(item, index) in personalInfo" :key="index">
                  <p class="stroke-with-shadow">
                    <span>{{ item.label }}:</span> {{ item.value }}
                  </p>
                </el-col>
              </el-row>
            </div>
 
            <!-- 下部分:位置/状态信息 -->
            <div class="info-section">
              <h4 class="section-title" style="color: white">{{ t("PersonInfoCard.locationInfo") }}</h4>
              <el-row :gutter="16">
                <el-col :span="8" v-for="(item, index) in locationInfo" :key="index">
                  <p class="stroke-with-shadow">
                    <span>{{ item.label }}:</span> {{ item.value }}
                  </p>
                </el-col>
              </el-row>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>
  </el-dialog>
</template>
<script lang="ts">
import { defineComponent, onMounted, reactive, ref, toRefs, nextTick, onUnmounted, computed } from "vue";
import { getPersonList } from "@/api/modules/hxzk/person/person";
import trBackground from "../images/map/trbackground.png";
import position from "../images/map/position.png";
import position1 from "../images/map/position1.png";
import my from "../images/map/my.png";
import onlineImgUrl from "../images/map/zaixian.png";
import { FindOneDepartMent } from "@/api/modules/hxzk/department/department";
import offlineImgUrl from "../images/map/lixianimage.png";
import { Search } from "@element-plus/icons-vue"; // 引入搜索图标
import infoBack from "@/views/hxzk/images/map/infoBack.png";
import notData from "@/assets/images/notData1.png";
import { getSafeValue } from "@/views/hxzk/utils/common";
import { useI18n } from "vue-i18n";
 
export default defineComponent({
  emits: ["personPostionClick"], // 声明自定义事件
 
  setup(props, { emit }) {
    const { t } = useI18n({ useScope: "global" });
 
    // 表格的数据类型
    interface tableType {
      name: string;
      money: number;
    }
    const centerDialogVisible = ref(false);
    interface DrawerProps {
      title: string;
      isView: boolean;
      initParam: Partial<User.ResUserList>;
      row: Partial<User.ResUserList>;
      api?: (params: any) => Promise<any>;
      getTableList?: () => void;
    }
    const drawerProps = ref<DrawerProps>({
      isView: false,
      initParam: {},
      title: "",
      row: {}
    });
    const data = reactive({
      tableData: [] as Array<tableType>, // 表格的数据
      currentPage: 1, // 当前展示的页码
      pageSize: 6, // 当前表格一页展示多少条数据
      tableDom: {} as HTMLElement // 表格内容的dom
    });
    let timeInterval: NodeJS.Timer; // 定时器的对象
    let tableScroll = ref(false); // 是否需要滚动
 
    // 定时器 ID,用于在组件卸载时清除定时器
    let intervalId: number | null = null;
 
    onMounted(() => {
      // 初始化表格的数据
      list();
      // 每秒执行一次 list 函数
      intervalId = setInterval(list, 20000);
      scrollTable();
    });
 
    onUnmounted(() => {
      clearInterval(timeInterval);
      // 组件卸载时清除定时器,避免内存泄漏
      if (intervalId) {
        clearInterval(intervalId);
      }
    });
    const searchText = ref(""); // 搜索文本
    const formatValue = (val, suffix = "") => {
      return val === "null" ? "--" : val + suffix;
    };
 
    // 默认图片路径(可以是本地或网络图片)
    const defaultImage = notData;
 
    // 图片加载失败时的处理
    const handleImageError = e => {
      console.error(t("PersonInfoCard.imageLoadError"), e);
    };
 
    // 个人信息字段标签翻译
    const personalInfo = computed(() => [
      { label: t("Person.name"), value: formatValue(drawerProps.value.row.pname) },
      { label: t("Person.tagid"), value: formatValue(drawerProps.value.row.ptagid) },
      { label: t("Person.department"), value: formatValue(drawerProps.value.row.pdepartment) },
      { label: t("Person.company"), value: formatValue(drawerProps.value.row.company) },
      { label: t("Person.power"), value: formatValue(drawerProps.value.row.ppower, "%") },
      { label: t("Person.phone"), value: formatValue(drawerProps.value.row.pphone) },
      { label: t("dayCount.type"), value: formatValue(drawerProps.value.row.baoliu19) },
      { label: t("Person.cardNumber"), value: formatValue(drawerProps.value.row.baoliu1) }
    ]);
 
    // 位置信息字段标签翻译
    const locationInfo = computed(() => [
      { label: t("PersonInfoCard.longitude"), value: formatValue(drawerProps.value.row.baoliu2) },
      { label: t("PersonInfoCard.latitude"), value: formatValue(drawerProps.value.row.baoliu3) },
      { label: t("PersonInfoCard.elevation"), value: formatValue(Number(drawerProps.value.row.baoliu4).toFixed(2), "cm") },
      {
        label: t("Person.status"),
        value: formatValue(drawerProps.value.row.ponline) === "1" ? t("status.online") : t("status.offline")
      },
      { label: t("PersonInfoCard.xCoordinate"), value: formatValue(drawerProps.value.row.px) },
      { label: t("PersonInfoCard.yCoordinate"), value: formatValue(drawerProps.value.row.py) },
      { label: t("PersonInfoCard.floor"), value: formatValue(drawerProps.value.row.pfloor) },
      { label: t("Person.status"), value: formatValue(drawerProps.value.row.baoliu13) },
      { label: t("PersonInfoCard.heartRate"), value: "--" },
      { label: t("PersonInfoCard.bloodOxygen"), value: "--" },
      { label: t("PersonInfoCard.temperature"), value: "--" },
      { label: t("Config.time"), value: formatValue(drawerProps.value.row.paddtiem) }
    ]);
 
    // 计算属性:过滤表格数据
    const filteredTableData = computed(() => {
      if (!searchText.value) {
        return data.tableData;
      }
      const search = searchText.value.toLowerCase();
      return data.tableData.filter(
        item =>
          (item.pname && item.pname.toLowerCase().includes(search)) || (item.ptagid && item.ptagid.toString().includes(search))
      );
    });
    // 在setup中添加原始数据引用
    const originalTableData = ref<Array<tableType>>([]); // 用于存储原始数据
 
    // 修改搜索处理函数
    const handleSearch = () => {
      if (!searchText.value) {
        // 如果搜索内容为空,显示全部原始数据
        data.tableData = [...originalTableData.value];
        return;
      }
 
      const search = searchText.value.toLowerCase();
      data.tableData = originalTableData.value.filter(
        item =>
          (item.pname && item.pname.toLowerCase().includes(search)) || (item.ptagid && item.ptagid.toString().includes(search))
      );
    };
 
    // 修改清除搜索函数
    const handleSearchClear = () => {
      searchText.value = "";
      data.tableData = [...originalTableData.value]; // 恢复原始数据
    };
 
    // 初始化表格的数据
    const list = () => {
      const params = {
        pageNum: 1,
        pageSize: 1000
      };
      getPersonList(params).then(dt => {
        data.tableData = dt.data.list;
        originalTableData.value = [...dt.data.list]; // 保存原始数据的副本
      });
    };
 
    // 表格的数据滚动
    const scrollTable = () => {
      nextTick(() => {
        // 获取当前表格内容的dom
        let table = document.getElementsByClassName("alarmTable")[0];
        data.tableDom = table.getElementsByClassName("el-scrollbar__wrap")[0]! as HTMLElement;
        // 鼠标放在表格内容,暂停滚动
        data.tableDom.addEventListener("mouseover", () => {
          tableScroll.value = false;
        });
        // 鼠标移出表格内容,继续滚动
        // data.tableDom.addEventListener("mouseout", () => {
        //   tableScroll.value = true;
        // });
        //
        timeInterval = setInterval(() => {
          if (tableScroll.value) {
            // 每次内容滚动的距离
            data.tableDom.scrollTop += 1;
            if (data.tableDom.clientHeight + data.tableDom.scrollTop == data.tableDom.scrollHeight) {
              data.tableDom.scrollTop = 0;
            }
          }
        }, 10);
      });
    };
    const rowStyle = ({}) => {
      // 设置统一的背景图片,这里假设图片路径为 'path/to/your-background-image.jpg'
      // 可以根据实际情况修改图片路径
      return {
        backgroundImage: `url('${trBackground}')`,
        backgroundSize: "100% 150%", // 可根据需求调整背景图片的显示方式
        backgroundRepeat: "no-repeat"
      };
    };
 
    //定位
    const sendDataToParent = person => {
      emit("personPostionClick", person.row); // 触发自定义事件并传递数据
    };
    const url = ref("");
    // 暴露给模板的方法
    const PersonInfoMessage = data => {
      drawerProps.value.row = data.row;
      FindOneDepartMent(drawerProps.value.row).then(data => {
        url.value = data.baoliu3;
      });
      centerDialogVisible.value = true;
    };
 
    return {
      position,
      ...toRefs(data),
      rowStyle,
      my,
      onlineImgUrl,
      infoBack,
      offlineImgUrl,
      sendDataToParent,
      PersonInfoMessage,
      drawerProps,
      url,
      centerDialogVisible,
      handleSearch,
      handleSearchClear,
      filteredTableData,
      searchText,
      Search,
      personalInfo,
      locationInfo,
      handleImageError,
      defaultImage,
      getSafeValue,
      position1,
      t
    };
  }
});
</script>
<style lang="scss" scoped>
.transparent-search-container {
  position: relative;
  top: 30px;
  display: flex;
  align-items: center;
  width: 370px;
  padding: 2px 0;
  margin: auto;
  margin-bottom: 15px;
  overflow: hidden;
  background: rgb(69 148 204 / 10%); /* 半透明背景 */
  backdrop-filter: blur(5px); /* 毛玻璃效果 */
  border: 1px solid rgb(41 199 255); /* 半透明边框 */
}
.transparent-input {
  flex: 1;
  :deep(.el-input__wrapper) {
    background: transparent;
    border: none;
    box-shadow: none;
    .el-input__inner {
      color: #eeeeee; /* 浅色文字 */
      &::placeholder {
        color: rgb(238 238 238 / 60%); /* 半透明占位符 */
      }
    }
  }
}
.transparent-search-btn {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 80px;
  height: 32px;
  padding: 0 15px;
  color: #ffffff;
  background: transparent;
  border: none;
  border: 1px solid rgb(69 148 204 / 0%); /* 半透明边框 */
  border-radius: 0;
  &:hover {
    color: #ffffff;
    background: rgb(69 148 204 / 10%); /* 半透明边框 */
  }
  &:active {
    background: rgb(69 148 204 / 10%); /* 半透明边框 */
  }
  .el-icon {
    font-size: 16px;
  }
}
.alarmTable {
  height: 85%;
  padding: 10px 0;
  margin-top: 10px;
  overflow: hidden;
  font-size: 14px;
  font-weight: bolder;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000;
  scroll-behavior: smooth;
}
.person-info {
  padding: 2px;
}
.image-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}
.person-image {
  width: 120px;
  height: 120px;
  border-radius: 10px;
  box-shadow: 0 0 8px rgb(0 0 0 / 20%);
}
.info-list {
  padding: 0 20px;
}
.info-list p {
  margin: 8px 0;
  font-size: 14px;
}
.info-list p span {
  margin-right: 10px;
  font-weight: bold;
}
.stroke-with-shadow {
  color: white;
 
  /* 从四个方向添加阴影来模拟描边 */
  text-shadow:
    -1px -1px 0 rgb(12 12 12),
    1px -1px 0 rgb(0 0 0),
    -1px 1px 0 rgb(0 0 0),
    1px 1px 0 rgb(17 17 17);
}
.section-title {
  padding-bottom: 5px;
  margin-bottom: 10px;
  color: white;
  border-bottom: 1px solid #444444;
}
</style>