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-01 13:52:57 +08:00
|
|
|
|
<TableCustom :columns="columns" :tableData="tableData" :total="page.total" :refresh="getData" :currentPage="page.index" :changePage="changePage">
|
2025-03-31 18:24:37 +08:00
|
|
|
|
<template #toolbarBtn>
|
|
|
|
|
<el-button type="primary" @click="handleAdd">新增</el-button>
|
2025-04-01 09:05:07 +08:00
|
|
|
|
<el-button @click="visible = true">手铐关联</el-button>
|
2025-03-31 18:24:37 +08:00
|
|
|
|
<el-button>地图位置</el-button>
|
|
|
|
|
<el-button>导出</el-button>
|
|
|
|
|
<el-button type="danger">删除</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
<template #money="{ rows }"> ¥{{ rows.money }} </template>
|
|
|
|
|
<template #thumb="{ rows }">
|
|
|
|
|
<el-image class="table-td-thumb" :src="rows.thumb" :z-index="10" :preview-src-list="[rows.thumb]" preview-teleported> </el-image>
|
|
|
|
|
</template>
|
|
|
|
|
<template #state="{ rows }">
|
|
|
|
|
<el-tag :type="rows.state ? 'success' : 'danger'">
|
|
|
|
|
{{ rows.state ? "正常" : "异常" }}
|
|
|
|
|
</el-tag>
|
|
|
|
|
</template>
|
2025-04-01 13:52:57 +08:00
|
|
|
|
<template #operator="{ rows }">
|
2025-03-31 18:24:37 +08:00
|
|
|
|
<el-button link type="primary" size="small" @click="router.push('deviceInfo')"> 详细信息 </el-button>
|
|
|
|
|
<el-button link type="primary" size="small" @click="router.push('mapLocation')"> 地图位置 </el-button>
|
|
|
|
|
<el-button link type="primary" size="small" @click="router.push('setting')"> 专项配置 </el-button>
|
2025-04-01 13:52:57 +08:00
|
|
|
|
<el-button link type="primary" size="small" @click="handleEdit(rows)"> 修改 </el-button>
|
|
|
|
|
<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">
|
|
|
|
|
<TableEdit :form-data="rowData" :options="TableEditOptions" :edit="isEdit" :update="updateData" />
|
|
|
|
|
</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-03-31 18:24:37 +08:00
|
|
|
|
import { fetchData } from "@/api/index";
|
|
|
|
|
import TableCustom from "@/components/table-custom.vue";
|
|
|
|
|
import TableSearch from "@/components/table-search.vue";
|
|
|
|
|
import TableEdit from "@/components/table-edit.vue";
|
|
|
|
|
import { TableItem } from "@/types/table";
|
|
|
|
|
import { FormOption, FormOptionList } from "@/types/form-option";
|
|
|
|
|
import { useRouter } from "vue-router";
|
|
|
|
|
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" },
|
|
|
|
|
{ prop: "name", label: "手铐SN" },
|
|
|
|
|
{ prop: "money", label: "绑定警察名称" },
|
|
|
|
|
{ prop: "thumb", label: "绑定警察账户" },
|
|
|
|
|
{ prop: "state", label: "当前状态" },
|
|
|
|
|
{ prop: "state", label: "登录时间" },
|
|
|
|
|
{ prop: "state", label: "最近使用时间" },
|
|
|
|
|
{ prop: "state", label: "关联辖区编号" },
|
|
|
|
|
{ prop: "operator", label: "操作", width: 400 },
|
|
|
|
|
]);
|
|
|
|
|
const page = reactive({
|
|
|
|
|
index: 1,
|
|
|
|
|
size: 10,
|
|
|
|
|
total: 200,
|
|
|
|
|
});
|
|
|
|
|
const tableData = ref<TableItem[]>([]);
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
const res = await fetchData();
|
|
|
|
|
tableData.value = res.data.list;
|
|
|
|
|
};
|
|
|
|
|
getData();
|
|
|
|
|
|
|
|
|
|
const changePage = (val: number) => {
|
|
|
|
|
page.index = val;
|
|
|
|
|
getData();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const visible = ref(false);
|
|
|
|
|
const isEdit = ref(false);
|
|
|
|
|
const rowData = ref({});
|
|
|
|
|
|
|
|
|
|
const handleAdd = () => {
|
|
|
|
|
TableEditOptions.value.list = addOp;
|
|
|
|
|
visible.value = true;
|
|
|
|
|
};
|
|
|
|
|
|
2025-04-01 13:52:57 +08:00
|
|
|
|
// 编辑
|
2025-03-31 18:24:37 +08:00
|
|
|
|
const handleEdit = (row: TableItem) => {
|
|
|
|
|
// rowData.value = { ...row };
|
|
|
|
|
TableEditOptions.value.list = editOp;
|
|
|
|
|
isEdit.value = true;
|
|
|
|
|
visible.value = true;
|
|
|
|
|
};
|
|
|
|
|
|
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("删除成功");
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.table-td-thumb {
|
|
|
|
|
display: block;
|
|
|
|
|
margin: auto;
|
|
|
|
|
width: 40px;
|
|
|
|
|
height: 40px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|