<template>
|
<div class="table-box">
|
<!-- 根据布局模式渲染不同的组件 -->
|
|
<ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam">
|
<!-- 表格 header 按钮 -->
|
<template #tableHeader> </template>
|
<!-- Expand -->
|
<template #expand="scope">
|
{{ scope.row }}
|
</template>
|
<template #Sign="scope">
|
<span style="margin-left: 10px">
|
<b>{{ t("RtkAnchor.radarId") }} </b>
|
<el-divider direction="vertical" border-style="dashed" />{{ scope.row.achorid }}
|
</span>
|
</template>
|
<template #Context="scope">
|
<el-tabs>
|
<el-tab-pane :label="t('RtkAnchor.radarInfo')">
|
<p>{{ t("RtkAnchor.boundDevice") }}:{{ scope.row.name }}</p>
|
<p>{{ t("RtkAnchor.collisionDistance") }}:{{ scope.row.fzdis }}</p>
|
<p>{{ t("RtkAnchor.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="View" @click="openDrawer('查看', scope.row)">{{ $t("Config.view") }}</el-button>
|
<el-button type="primary" v-if="BUTTONS.edit" link :icon="EditPen" @click="openDrawer('编辑', scope.row)">{{
|
$t("Config.update")
|
}}</el-button>
|
<el-button type="primary" v-if="BUTTONS.delete" link :icon="Delete" @click="deleteAccount(scope.row)">{{
|
$t("Config.delete")
|
}}</el-button>
|
</template>
|
</ProTable>
|
|
<RadarDrawer ref="drawerRef" />
|
<ImportExcel ref="dialogRef" />
|
</div>
|
</template>
|
|
<script setup lang="tsx" name="useProTable">
|
import { ref, reactive } from "vue";
|
import { User } from "@/api/interface";
|
import { useHandleData } from "@/hooks/useHandleData";
|
import ProTable from "@/components/ProTable/card.vue";
|
import ImportExcel from "@/components/ImportExcel/index.vue";
|
import RadarDrawer from "@/views/proTable/components/hxzk/device/RadarDrawer.vue";
|
import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface";
|
import { View, EditPen, Delete } from "@element-plus/icons-vue";
|
import { getRtkAnchorList } from "@/api/modules/hxzk/device/rtkanchor";
|
import { useAuthButtons } from "@/hooks/useAuthButtons";
|
import { useI18n } from "vue-i18n";
|
|
// 使用 useI18n 获取 i18n 实例
|
const { t } = useI18n({
|
useScope: "global"
|
});
|
|
const { BUTTONS } = useAuthButtons();
|
// 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, acid, ...restParams } = newParams;
|
const tableList = { pageSize, pageNum };
|
|
// 提取 person 对象
|
const { ...restParams2 } = restParams;
|
const rtkanchor = { acid };
|
|
// 处理 createTime 字段
|
if (restParams2.createTime) {
|
restParams2.startTime = restParams2.createTime[0];
|
restParams2.endTime = restParams2.createTime[1];
|
delete restParams2.createTime;
|
}
|
|
// 合并所有参数
|
const finalParams = {
|
...restParams2,
|
tableList,
|
rtkanchor
|
};
|
|
return getRtkAnchorList(finalParams);
|
};
|
|
// 表格配置项
|
const columns = reactive<ColumnProps<User.ResUserList>[]>([
|
{ type: "selection", fixed: "left", width: 70 },
|
{
|
prop: "acid",
|
search: { el: "input", span: 4 },
|
label: t("RtkAnchor.baseStationId")
|
},
|
{
|
prop: "state",
|
label: t("RtkAnchor.status")
|
},
|
{
|
prop: "jingdu",
|
label: t("RtkAnchor.longitude")
|
},
|
{
|
prop: "weidu",
|
label: t("RtkAnchor.latitude")
|
},
|
{
|
prop: "gaodu",
|
label: t("RtkAnchor.elevation")
|
},
|
{
|
prop: "posx",
|
label: t("RtkAnchor.xCoordinate")
|
},
|
{
|
prop: "posy",
|
label: t("RtkAnchor.yCoordinate")
|
},
|
{
|
prop: "floor",
|
label: t("RtkAnchor.layer")
|
},
|
{
|
prop: "distance",
|
label: t("RtkAnchor.coverageDistance")
|
},
|
{
|
prop: "port",
|
label: t("RtkAnchor.port")
|
},
|
{
|
prop: "company",
|
label: t("Person.company"),
|
render: scope => {
|
return (
|
<el-tag size="large" effect="plain">
|
{scope.row.company}
|
</el-tag>
|
);
|
}
|
},
|
{ prop: "operation", label: t("Config.operation"), width: 260 }
|
]);
|
|
// 打开 drawer(新增、查看、编辑)
|
const drawerRef = ref<InstanceType<typeof UserDrawer> | null>(null);
|
const openDrawer = (title: string, row: Partial<User.ResUserList> = {}) => {
|
const params = {
|
title,
|
initParam,
|
isView: title === "查看",
|
row: { ...row },
|
api: title === "新增" ? addRtkAnchor : title === "编辑" ? editRtkAnchor : undefined,
|
getTableList: proTable.value?.getTableList
|
};
|
drawerRef.value?.acceptParams(params);
|
};
|
|
// 删除差分基站信息
|
const deleteAccount = async (params: User.ResUserList) => {
|
await useHandleData(deleteRtkAnchor, { acid: params.acid }, t("RtkAnchor.deleteConfirm", { id: params.acid }), t);
|
proTable.value?.getTableList();
|
};
|
</script>
|