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
<template>
  <div class="table-box">
    <!-- 根据布局模式渲染不同的组件 -->
 
    <ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam">
      <!-- Expand -->
      <template #expand="scope">
        {{ scope.row }}
      </template>
      <template #Sign="scope">
        <span style="margin-left: 10px">
          <b>{{ t("historyAttendance.radarId") }} </b>
          <el-divider direction="vertical" border-style="dashed" />{{ scope.row.achorid }}
        </span>
      </template>
      <template #Context="scope">
        <el-tabs>
          <el-tab-pane :label="t('historyAttendance.radarInfo')">
            <p>{{ t("historyAttendance.boundDevice") }}:{{ scope.row.name }}</p>
            <p>{{ t("historyAttendance.distance") }}:{{ scope.row.fzdis }}</p>
            <p>{{ t("historyAttendance.cardNumber") }}:{{ scope.row.ccid }}</p>
            <!-- 基本信息字段 -->
          </el-tab-pane>
        </el-tabs>
      </template>
      <template #Footer="scope">
        <span>
          <b>{{ t("Config.time") }}:</b>{{ scope.row.addtime }}
        </span>
      </template>
      <!-- 表格操作 -->
      <template #operation="scope">
        <el-button type="primary" link :icon="VideoPlay" @click="handleViewTrack(scope.row)">
          {{ $t("historyAttendance.viewTrack") }}
        </el-button>
      </template>
    </ProTable>
 
    <UserDrawer ref="drawerRef" />
    <ImportExcel ref="dialogRef" />
 
    <!-- 轨迹回放对话框 -->
    <TrackReplayDialog v-model="trackDialogVisible" :track-data="currentTrackData" />
  </div>
</template>
 
<script setup lang="tsx" name="useProTable">
import { ref, reactive } from "vue";
import { User } from "@/api/interface";
import {} from "@/hooks/useHandleData";
// import { ElMessage } from "element-plus";
import ProTable from "@/components/ProTable/card.vue";
import ImportExcel from "@/components/ImportExcel/index.vue";
import UserDrawer from "@/views/proTable/components/UserDrawer.vue";
import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface";
import { VideoPlay } from "@element-plus/icons-vue";
import { getAttendanceList } from "@/api/modules/hxzk/statistics/historyAttendance";
import { useI18n } from "vue-i18n";
 
// 使用 useI18n 获取 i18n 实例
const { t } = useI18n({
  useScope: "global"
});
 
// ProTable 实例
const proTable = ref<ProTableInstance>();
 
// 轨迹回放对话框相关
const trackDialogVisible = ref(false);
const currentTrackData = ref({});
 
// 处理查看轨迹
const handleViewTrack = row => {
  // 设置当前轨迹数据
  currentTrackData.value = {
    tagid: row.tagid,
    name: row.name,
    intime: row.intime,
    outtime: row.outtime
  };
 
  // 显示轨迹回放对话框
  trackDialogVisible.value = true;
};
 
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
const initParam = reactive({ type: 1 });
const getTableList = (params: any) => {
  let newParams = JSON.parse(JSON.stringify(params));
 
  // 提取 tableList 对象
  const { pageSize, pageNum, name, tagid, intime, ...restParams } = newParams;
  const tableList = { pageSize, pageNum };
 
  // 提取 person 对象
  const { ...restParams2 } = restParams;
  const kaoqing = { name, tagid, intime };
 
  // 处理 createTime 字段
  if (restParams2.createTime) {
    restParams2.startTime = restParams2.createTime[0];
    restParams2.endTime = restParams2.createTime[1];
    delete restParams2.createTime;
  }
 
  // 合并所有参数
  const finalParams = {
    ...restParams2,
    tableList,
    kaoqing
  };
 
  return getAttendanceList(finalParams);
};
 
// 表格配置项
const columns = reactive<ColumnProps<User.ResUserList>[]>([
  { type: "index", fixed: "left", width: 70 },
  {
    prop: "area",
    label: t("historyAttendance.area")
  },
  {
    prop: "name",
    label: t("Person.name"),
    search: { el: "input", span: 3 }
  },
  {
    prop: "bumen",
    label: t("Person.department")
  },
  {
    prop: "tagid",
    search: { el: "input", span: 3 },
    label: t("Tag.tagId")
  },
  {
    prop: "intime",
    label: t("historyAttendance.entryTime"),
    search: {
      el: "date-picker",
      label: t("Config.time"),
      span: 3,
      props: {
        rangeSeparator: t("SearchForm.rangeSeparator"),
        startPlaceholder: t("SearchForm.startTime"),
        endPlaceholder: t("SearchForm.endTime")
      }
    }
  },
  {
    prop: "outtime",
    label: t("historyAttendance.exitTime")
  },
  {
    prop: "alltime",
    label: t("historyAttendance.stayTime")
  },
  {
    prop: "operation",
    label: t("historyAttendance.operation"),
    fixed: "right",
    width: 120
  }
]);
 
// 打开 drawer(新增、查看、编辑)
const drawerRef = ref<InstanceType<typeof UserDrawer> | null>(null);
</script>