2025-03-31 18:24:37 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div class="container">
|
|
|
|
|
<TableSearch :query="query" :options="searchOpt" :search="handleSearch" />
|
|
|
|
|
<div class="table-container">
|
2025-04-03 18:21:17 +08:00
|
|
|
|
<TableCustom :columns="columns" :tableData="tableData" :total="paging.total" :refresh="getData" :currentPage="paging.page" :changePage="changePage">
|
2025-03-31 18:24:37 +08:00
|
|
|
|
<template #toolbarBtn>
|
2025-04-02 18:40:20 +08:00
|
|
|
|
<!-- <el-button type="primary" @click="handleAdd">新增</el-button> -->
|
|
|
|
|
<el-button @click="handleEdit">手铐关联</el-button>
|
|
|
|
|
<!-- <el-button>地图位置</el-button> -->
|
|
|
|
|
<!-- <el-button>导出</el-button> -->
|
2025-03-31 18:24:37 +08:00
|
|
|
|
</template>
|
2025-04-03 18:21:17 +08:00
|
|
|
|
|
2025-03-31 18:24:37 +08:00
|
|
|
|
<template #state="{ rows }">
|
2025-04-03 18:21:17 +08:00
|
|
|
|
{{ stateEnum[rows.state] }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #deviceSwitch="{ rows }">
|
|
|
|
|
{{ deviceSwitchEnum[rows.deviceSwitch] }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #mode="{ rows }">
|
|
|
|
|
{{ modeEnum[rows.mode] }}
|
|
|
|
|
</template>
|
|
|
|
|
<template #monitorMode="{ rows }">
|
|
|
|
|
{{ monitorModeEnum[rows.monitorMode] }}
|
2025-03-31 18:24:37 +08:00
|
|
|
|
</template>
|
2025-04-03 18:21:17 +08:00
|
|
|
|
<template #battery="{ rows }"> {{ rows.battery }}% </template>
|
|
|
|
|
|
2025-04-01 13:52:57 +08:00
|
|
|
|
<template #operator="{ rows }">
|
2025-04-03 18:21:17 +08:00
|
|
|
|
<el-button link type="primary" size="small" @click="toPage('deviceInfo', rows)"> 详细信息 </el-button>
|
|
|
|
|
<el-button link type="primary" size="small" @click="toPage('mapLocation', rows)"> 地图位置 </el-button>
|
|
|
|
|
<el-button link type="primary" size="small" @click="toPage('setting', rows)"> 专项配置 </el-button>
|
|
|
|
|
<el-button link type="primary" size="small" @click="handelRow(rows)"> 设备控制 </el-button>
|
2025-04-01 13:52:57 +08:00
|
|
|
|
<el-button link type="primary" size="small" @click="handleEdit(rows)"> 修改 </el-button>
|
2025-04-02 18:40:20 +08:00
|
|
|
|
<!-- <el-button link type="danger" size="small" @click="handelDel(rows)"> 删除 </el-button> -->
|
2025-03-31 18:24:37 +08:00
|
|
|
|
</template>
|
|
|
|
|
</TableCustom>
|
|
|
|
|
</div>
|
|
|
|
|
<el-dialog :title="isEdit ? '编辑' : '新增'" v-model="visible" width="700px" destroy-on-close :close-on-click-modal="false" @close="closeDialog">
|
2025-04-02 18:40:20 +08:00
|
|
|
|
<TableEdit :form-data="rowData" :options="TableEditOptions" :edit="isEdit" :update="updateData" @close="closeDialog" />
|
|
|
|
|
</el-dialog>
|
2025-04-03 18:21:17 +08:00
|
|
|
|
|
2025-04-02 18:40:20 +08:00
|
|
|
|
<el-dialog title="设备控制" v-model="visible1" width="700px" destroy-on-close :close-on-click-modal="false" @close="closeDialog">
|
|
|
|
|
<!-- <TableEdit :form-data="rowData" :options="controlOptions" :update="updateData" /> -->
|
2025-04-03 18:21:17 +08:00
|
|
|
|
<DeviceControl v-model="controlForm" @change="handelControl" />
|
2025-03-31 18:24:37 +08:00
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts" name="basetable">
|
|
|
|
|
import { ref, reactive } from "vue";
|
2025-04-01 13:52:57 +08:00
|
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
2025-04-03 18:21:17 +08:00
|
|
|
|
import { deviceList, setMode, deviceGetLocation, deviceControl } from "@/api/index";
|
|
|
|
|
import { TDevice } from "@/api/index.d";
|
2025-03-31 18:24:37 +08:00
|
|
|
|
import TableCustom from "@/components/table-custom.vue";
|
|
|
|
|
import TableSearch from "@/components/table-search.vue";
|
|
|
|
|
import TableEdit from "@/components/table-edit.vue";
|
2025-04-03 18:21:17 +08:00
|
|
|
|
import DeviceControl from "./deviceControl.vue";
|
2025-03-31 18:24:37 +08:00
|
|
|
|
import { TableItem } from "@/types/table";
|
|
|
|
|
import { FormOption, FormOptionList } from "@/types/form-option";
|
|
|
|
|
import { useRouter } from "vue-router";
|
2025-04-07 18:35:54 +08:00
|
|
|
|
|
2025-04-03 18:21:17 +08:00
|
|
|
|
enum stateEnum {
|
|
|
|
|
"离线" = 0,
|
|
|
|
|
"在线",
|
|
|
|
|
"充电中",
|
|
|
|
|
}
|
|
|
|
|
enum deviceSwitchEnum {
|
|
|
|
|
"禁用" = 0,
|
|
|
|
|
"启用",
|
|
|
|
|
}
|
|
|
|
|
enum modeEnum {
|
|
|
|
|
"室内" = 0,
|
|
|
|
|
"室外",
|
|
|
|
|
}
|
|
|
|
|
enum monitorModeEnum {
|
|
|
|
|
"室内" = 0,
|
|
|
|
|
"室外",
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-31 18:24:37 +08:00
|
|
|
|
const router = useRouter();
|
|
|
|
|
// 新增/编辑弹窗相关
|
|
|
|
|
let TableEditOptions = ref<FormOption>({
|
|
|
|
|
labelWidth: "100px",
|
|
|
|
|
span: 24,
|
|
|
|
|
list: [],
|
|
|
|
|
});
|
|
|
|
|
const addOp = [{ type: "input", label: "唯一编码", prop: "name", required: true }];
|
|
|
|
|
const editOp = [
|
|
|
|
|
{ type: "select", label: "选择手铐", prop: "name", required: true },
|
|
|
|
|
{ type: "input", label: "唯一编码", prop: "name1" },
|
|
|
|
|
{ type: "select", label: "辖区绑定", prop: "name2" },
|
|
|
|
|
{ type: "input", label: "紧急电话", prop: "name3" },
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// 查询相关
|
|
|
|
|
const query = reactive({
|
|
|
|
|
name: "",
|
|
|
|
|
});
|
|
|
|
|
const searchOpt = ref<FormOptionList[]>([
|
|
|
|
|
{ type: "input", label: "手铐SN:", prop: "name" },
|
|
|
|
|
{ type: "input", label: "警察账号:", prop: "name1" },
|
|
|
|
|
]);
|
|
|
|
|
const handleSearch = () => {
|
|
|
|
|
changePage(1);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 表格相关
|
|
|
|
|
let columns = ref([
|
|
|
|
|
{ type: "selection" },
|
|
|
|
|
{ type: "index", label: "序号", width: 55, align: "center" },
|
2025-04-03 18:21:17 +08:00
|
|
|
|
{ prop: "deviceId", label: "手铐IMEI" },
|
|
|
|
|
{ prop: "name", label: "绑定警察名称" },
|
|
|
|
|
{ prop: "username", label: "绑定警察账户" },
|
|
|
|
|
{ prop: "state", label: "设备状态" },
|
|
|
|
|
{ prop: "mode", label: "当前模式" },
|
|
|
|
|
{ prop: "deviceSwitch", label: "开关" },
|
|
|
|
|
{ prop: "monitorMode", label: "监测模式" },
|
|
|
|
|
{ prop: "battery", label: "电量" },
|
|
|
|
|
{ prop: "deviceVersion", label: "版本号" },
|
|
|
|
|
{ prop: "createTime", label: "创建时间" },
|
|
|
|
|
{ prop: "orgName", label: "关联辖区编号" },
|
2025-03-31 18:24:37 +08:00
|
|
|
|
{ prop: "operator", label: "操作", width: 400 },
|
|
|
|
|
]);
|
2025-04-03 18:21:17 +08:00
|
|
|
|
const paging = reactive({
|
|
|
|
|
page: 1,
|
2025-03-31 18:24:37 +08:00
|
|
|
|
size: 10,
|
2025-04-03 18:21:17 +08:00
|
|
|
|
total: 0,
|
2025-03-31 18:24:37 +08:00
|
|
|
|
});
|
2025-04-02 18:40:20 +08:00
|
|
|
|
const controlForm = reactive({
|
2025-04-03 18:21:17 +08:00
|
|
|
|
pattern: 1,
|
|
|
|
|
location: 1,
|
2025-04-02 18:40:20 +08:00
|
|
|
|
});
|
|
|
|
|
|
2025-04-03 18:21:17 +08:00
|
|
|
|
const tableData = ref<TDevice.IListRes[]>([]);
|
2025-03-31 18:24:37 +08:00
|
|
|
|
const getData = async () => {
|
2025-04-03 18:21:17 +08:00
|
|
|
|
const res = await deviceList(paging);
|
|
|
|
|
tableData.value = res.records;
|
|
|
|
|
paging.total = res.total;
|
2025-03-31 18:24:37 +08:00
|
|
|
|
};
|
|
|
|
|
getData();
|
|
|
|
|
|
|
|
|
|
const changePage = (val: number) => {
|
2025-04-03 18:21:17 +08:00
|
|
|
|
paging.page = val;
|
2025-03-31 18:24:37 +08:00
|
|
|
|
getData();
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-02 18:40:20 +08:00
|
|
|
|
const visible1 = ref(false);
|
2025-03-31 18:24:37 +08:00
|
|
|
|
const visible = ref(false);
|
|
|
|
|
const isEdit = ref(false);
|
2025-04-03 18:21:17 +08:00
|
|
|
|
const rowData = ref<TDevice.IListRes>();
|
2025-03-31 18:24:37 +08:00
|
|
|
|
|
|
|
|
|
const handleAdd = () => {
|
|
|
|
|
TableEditOptions.value.list = addOp;
|
|
|
|
|
visible.value = true;
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-01 13:52:57 +08:00
|
|
|
|
// 编辑
|
2025-04-03 18:21:17 +08:00
|
|
|
|
const handleEdit = (row?: TDevice.IListRes) => {
|
|
|
|
|
rowData.value = { ...row };
|
2025-03-31 18:24:37 +08:00
|
|
|
|
TableEditOptions.value.list = editOp;
|
|
|
|
|
isEdit.value = true;
|
|
|
|
|
visible.value = true;
|
|
|
|
|
};
|
2025-04-03 18:21:17 +08:00
|
|
|
|
|
|
|
|
|
const handelRow = (row?: TDevice.IListRes) => {
|
|
|
|
|
rowData.value = { ...row };
|
|
|
|
|
visible1.value = true;
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-02 18:40:20 +08:00
|
|
|
|
const handelControl = (type: number) => {
|
2025-04-03 18:21:17 +08:00
|
|
|
|
switch (type) {
|
|
|
|
|
case 4:
|
|
|
|
|
deviceGetLocation({
|
|
|
|
|
deviceId: rowData.value.deviceId,
|
|
|
|
|
}).then(() => {
|
|
|
|
|
ElMessage.success("操作成功");
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
let cmdEnum = {
|
|
|
|
|
1: "poweroff",
|
|
|
|
|
2: "restart",
|
|
|
|
|
3: "factory",
|
|
|
|
|
};
|
|
|
|
|
deviceControl({
|
|
|
|
|
deviceId: rowData.value.deviceId,
|
|
|
|
|
cmd: cmdEnum[type],
|
|
|
|
|
}).then(() => {
|
|
|
|
|
ElMessage.success("操作成功");
|
|
|
|
|
});
|
|
|
|
|
break;
|
2025-04-02 18:40:20 +08:00
|
|
|
|
}
|
2025-04-03 18:21:17 +08:00
|
|
|
|
|
2025-04-02 18:40:20 +08:00
|
|
|
|
visible1.value = false;
|
|
|
|
|
};
|
2025-04-01 13:52:57 +08:00
|
|
|
|
// 删除
|
|
|
|
|
const handelDel = (row: TableItem) => {
|
|
|
|
|
ElMessageBox.confirm("确定要删除吗?", "提示", {
|
|
|
|
|
type: "warning",
|
|
|
|
|
})
|
|
|
|
|
.then(async () => {
|
|
|
|
|
// ElMessage.success("删除成功");
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {});
|
|
|
|
|
};
|
|
|
|
|
|
2025-03-31 18:24:37 +08:00
|
|
|
|
const updateData = () => {
|
|
|
|
|
closeDialog();
|
|
|
|
|
getData();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const closeDialog = () => {
|
|
|
|
|
visible.value = false;
|
|
|
|
|
isEdit.value = false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 删除相关
|
|
|
|
|
const handleDelete = (row: TableItem) => {
|
|
|
|
|
ElMessage.success("删除成功");
|
|
|
|
|
};
|
2025-04-03 18:21:17 +08:00
|
|
|
|
//
|
|
|
|
|
const toPage = (path: string, row: TDevice.IListRes) => {
|
|
|
|
|
let p;
|
|
|
|
|
if (path == "deviceInfo") {
|
|
|
|
|
p = { ...row };
|
|
|
|
|
} else if (path == "mapLocation") {
|
|
|
|
|
p = { id: row.id };
|
|
|
|
|
} else if (path == "setting") {
|
|
|
|
|
p = { id: row.id };
|
|
|
|
|
}
|
|
|
|
|
router.push({
|
|
|
|
|
path,
|
|
|
|
|
query: p,
|
|
|
|
|
});
|
|
|
|
|
};
|
2025-03-31 18:24:37 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.table-td-thumb {
|
|
|
|
|
display: block;
|
|
|
|
|
margin: auto;
|
|
|
|
|
width: 40px;
|
|
|
|
|
height: 40px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|