|
@@ -1,57 +1,70 @@
|
|
|
<template>
|
|
|
<div class="table-box">
|
|
|
- <ProTable
|
|
|
- ref="proTable"
|
|
|
- :columns="columns"
|
|
|
- :request-api="getTableList"
|
|
|
- :init-param="initParam"
|
|
|
- :data-callback="dataCallback"
|
|
|
- @drag-sort="sortTable"
|
|
|
- >
|
|
|
- <!-- 表格 搜索 按钮 -->
|
|
|
- <template #tableHeader="">
|
|
|
- <el-form :model="queryParams" label-width="auto" :inline="true">
|
|
|
- <el-form-item label="自动站:">
|
|
|
- <el-select v-model="queryParams.name" placeholder="请选择自动站" clearable style="width: 200px">
|
|
|
- <el-option label="站1" value="1" />
|
|
|
- <el-option label="站2" value="2" />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item>
|
|
|
- <el-button type="primary" @click="handleQuery"> 查询 </el-button>
|
|
|
- <el-button style="margin-left: 10px" @click="resetQuery"> 重置 </el-button>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- </template>
|
|
|
- </ProTable>
|
|
|
+ <div class="card table-main">
|
|
|
+ <!-- 表格头部 操作按钮 -->
|
|
|
+ <div class="table-header">
|
|
|
+ <div class="header-button-lf">
|
|
|
+ <el-form :model="queryParams" label-width="auto" :inline="true">
|
|
|
+ <el-form-item label="自动站:">
|
|
|
+ <el-select v-model="queryParams.name" placeholder="请选择自动站" clearable style="width: 200px">
|
|
|
+ <el-option label="站1" value="1" />
|
|
|
+ <el-option label="站2" value="2" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="handleQuery"> 查询 </el-button>
|
|
|
+ <el-button style="margin-left: 10px" @click="resetQuery"> 重置 </el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <div class="header-button-ri">
|
|
|
+ <slot name="toolButton">
|
|
|
+ <img class="setting" src="@/assets/images/setting2.png" />
|
|
|
+ </slot>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!-- 表格主体 -->
|
|
|
+ <el-table stripe ref="tableRef" :border="true" :data="processTableData" size="small">
|
|
|
+ <el-table-column align="left" label="序号" width="80px" :show-overflow-tooltip="true">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <template v-for="item in columns" :key="item">
|
|
|
+ <el-table-column v-bind="item" :align="item.align ?? 'left'" :reserve-selection="item.type == 'selection'" :show-overflow-tooltip="true">
|
|
|
+ </el-table-column>
|
|
|
+ </template>
|
|
|
+ <!-- 无数据 -->
|
|
|
+ <template #empty>
|
|
|
+ <div class="table-empty">
|
|
|
+ <slot name="empty">
|
|
|
+ <img src="@/assets/images/notData.png" alt="notData" />
|
|
|
+ <div>暂无数据</div>
|
|
|
+ </slot>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table>
|
|
|
+ <!-- 分页组件 -->
|
|
|
+ <Pagination :pageable="pageable" :handle-size-change="handleSizeChange" :handle-current-change="handleCurrentChange" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" name="useProTable">
|
|
|
+import Pagination from "@/components/ProTable/components/Pagination.vue";
|
|
|
import { ref, reactive } from "vue";
|
|
|
-import { User } from "@/api/interface";
|
|
|
-import { ElMessage } from "element-plus";
|
|
|
-import ProTable from "@/components/ProTable/index.vue";
|
|
|
-import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface";
|
|
|
-import { getUserList } from "@/api/modules/user";
|
|
|
-
|
|
|
-// ProTable 实例
|
|
|
-const proTable = ref<ProTableInstance>();
|
|
|
-
|
|
|
-// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
|
|
|
-const initParam = reactive({ type: 1 });
|
|
|
-// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
|
|
|
-const dataCallback = (data: any) => {
|
|
|
- return {
|
|
|
- list: data.list,
|
|
|
- total: data.total
|
|
|
- };
|
|
|
-};
|
|
|
+import { ColumnProps } from "@/components/ProTable/interface";
|
|
|
+const pageable = ref<any>({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ total: 1
|
|
|
+});
|
|
|
|
|
|
const queryParams = ref({
|
|
|
name: "",
|
|
|
pageNum: 1,
|
|
|
- pageSize: 10
|
|
|
+ pageSize: 20,
|
|
|
+ total: 1
|
|
|
});
|
|
|
|
|
|
// 查询功能
|
|
@@ -64,31 +77,265 @@ const resetQuery = () => {
|
|
|
queryParams.value.pageNum = 1;
|
|
|
};
|
|
|
|
|
|
-// 翻页
|
|
|
-const getTableList = (params: any) => {
|
|
|
- let newParams = JSON.parse(JSON.stringify(params));
|
|
|
- newParams.createTime && (newParams.startTime = newParams.createTime[0]);
|
|
|
- newParams.createTime && (newParams.endTime = newParams.createTime[1]);
|
|
|
- delete newParams.createTime;
|
|
|
- return getUserList(newParams);
|
|
|
+/**
|
|
|
+ * @description 每页条数改变
|
|
|
+ * @param {Number} val 当前条数
|
|
|
+ * @return void
|
|
|
+ * */
|
|
|
+const handleSizeChange = (val: number) => {
|
|
|
+ console.log(val);
|
|
|
};
|
|
|
|
|
|
-// 表格配置项
|
|
|
-const columns = reactive<ColumnProps<User.ResUserList>[]>([
|
|
|
- { prop: "username", label: "站号" },
|
|
|
- { prop: "gender", label: "性别" },
|
|
|
- { prop: "user.detail.age", label: "年龄" },
|
|
|
- { prop: "idCard", label: "身份证号", search: { el: "input" } },
|
|
|
- { prop: "email", label: "邮箱" },
|
|
|
- { prop: "address", label: "居住地址" },
|
|
|
- { prop: "status", label: "用户状态" },
|
|
|
- { prop: "createTime", label: "创建时间", width: 180 }
|
|
|
+/**
|
|
|
+ * @description 当前页改变
|
|
|
+ * @param {Number} val 当前页
|
|
|
+ * @return void
|
|
|
+ * */
|
|
|
+const handleCurrentChange = (val: number) => {
|
|
|
+ console.log(val);
|
|
|
+};
|
|
|
+
|
|
|
+const processTableData = ref([
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ id: "681913747276782417",
|
|
|
+ a: "测试本地",
|
|
|
+ b: "RS001",
|
|
|
+ c: "公园",
|
|
|
+ d: "2024-09-02 22:57",
|
|
|
+ e: "0.2",
|
|
|
+ f: "150",
|
|
|
+ g: "25.3",
|
|
|
+ h: "61",
|
|
|
+ i: "17.2"
|
|
|
+ }
|
|
|
]);
|
|
|
|
|
|
-// 表格拖拽排序
|
|
|
-const sortTable = ({ newIndex, oldIndex }: { newIndex?: number; oldIndex?: number }) => {
|
|
|
- console.log(newIndex, oldIndex);
|
|
|
- console.log(proTable.value?.tableData);
|
|
|
- ElMessage.success("修改列表排序成功");
|
|
|
-};
|
|
|
+// 表格配置项
|
|
|
+const columns = reactive<ColumnProps[]>([
|
|
|
+ { prop: "a", label: "站名" },
|
|
|
+ { prop: "b", label: "站号" },
|
|
|
+ { prop: "c", label: "地址" },
|
|
|
+ { prop: "d", label: "观测时间" },
|
|
|
+ { prop: "e", label: "瞬风风速(m/s)" },
|
|
|
+ { prop: "f", label: "瞬风方向(°)" },
|
|
|
+ { prop: "g", label: "气温(℃)" },
|
|
|
+ { prop: "h", label: "相对湿度(%)" },
|
|
|
+ { prop: "i", label: "漏点温度(℃)" }
|
|
|
+]);
|
|
|
</script>
|