<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>{{ scope.row.baoliu10 }}</b>
|
<el-divider direction="vertical" border-style="dashed" />{{ scope.row.objectid }}
|
</span>
|
</template>
|
<template #Context="scope">
|
<el-tabs>
|
<el-tab-pane :label="t('Warning.alarmInfo')">
|
<p>{{ t("Warning.type") }}:{{ scope.row.type }}</p>
|
<p>{{ t("Warning.fence") }}:{{ scope.row.baoliu2 }}</p>
|
<p>{{ t("Config.time") }}:{{ scope.row.time }}</p>
|
<!-- 基本信息字段 -->
|
</el-tab-pane>
|
</el-tabs>
|
</template>
|
<template #Footer>
|
<el-button type="danger">{{ t("Warning.handle") }}</el-button>
|
<el-button type="primary">{{ t("Warning.details") }}</el-button>
|
</template>
|
<!-- 表格操作 -->
|
</ProTable>
|
|
<UserDrawer ref="drawerRef" />
|
<ImportExcel ref="dialogRef" />
|
</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 {} from "@element-plus/icons-vue";
|
import { getGpsTrackList } from "@/api/modules/hxzk/track/jingwei";
|
import { useI18n } from "vue-i18n";
|
|
// 使用 useI18n 获取 i18n 实例
|
const { t } = useI18n({
|
useScope: "global"
|
});
|
|
// ProTable 实例
|
const proTable = ref<ProTableInstance>();
|
|
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
|
const initParam = reactive({ type: 1 });
|
const getTableList = (params: any) => {
|
let newParams = JSON.parse(JSON.stringify(params));
|
|
// 提取 tableList 对象
|
const { pageSize, pageNum, tagid, addtime, ...restParams } = newParams;
|
const tableList = { pageSize, pageNum };
|
|
// 提取 person 对象
|
const { ...restParams2 } = restParams;
|
const gpsTrack = { tagid, addtime };
|
|
// 处理 createTime 字段
|
if (restParams2.createTime) {
|
restParams2.startTime = restParams2.createTime[0];
|
restParams2.endTime = restParams2.createTime[1];
|
delete restParams2.createTime;
|
}
|
|
// 合并所有参数
|
const finalParams = {
|
...restParams2,
|
tableList,
|
gpsTrack
|
};
|
|
return getGpsTrackList(finalParams);
|
};
|
|
// 表格配置项
|
const columns = reactive<ColumnProps<User.ResUserList>[]>([
|
{ type: "index", fixed: "left", width: 70 },
|
{
|
prop: "tagid",
|
search: { el: "input", span: 3 },
|
label: t("Tag.tagId")
|
},
|
{
|
prop: "gspJingdu",
|
label: t("Anchor.longitude")
|
},
|
{
|
prop: "gpsWeidu",
|
label: t("Anchor.latitude")
|
},
|
{
|
prop: "gpsState",
|
label: t("Warning.status")
|
},
|
{
|
prop: "gpsUtcTime",
|
label: t("jingwei.utcTime")
|
},
|
{
|
prop: "addtime",
|
search: {
|
el: "date-picker",
|
label: t("Config.time"),
|
span: 3,
|
props: {
|
rangeSeparator: t("SearchForm.rangeSeparator"),
|
startPlaceholder: t("SearchForm.startTime"),
|
endPlaceholder: t("SearchForm.endTime")
|
}
|
},
|
label: t("Config.time")
|
}
|
]);
|
|
// 打开 drawer(新增、查看、编辑)
|
const drawerRef = ref<InstanceType<typeof UserDrawer> | null>(null);
|
</script>
|